Example #1
0
        //临时裁判绑定
        public bool BindTempReferee(BindTempRefereeRequest request, out string msg)
        {
            bool flag = false;

            msg = string.Empty;
            try
            {
                //校验数据的真实性
                if (request.TempRefereeNum.IsEmpty())
                {
                    msg = "临时裁判编码不能为空";
                    return(flag);
                }

                if (request.ContactMobile.IsEmpty())
                {
                    msg = "手机号码不能为空";
                    return(flag);
                }

                var data = _dbContext.Select <t_member_temp>(c => c.contactmobile == request.ContactMobile && c.code == request.TempRefereeNum && c.tempType == Model.enums.TempTypeEm.临时裁判 && c.tempStatus == TempStatusEm.待绑定).FirstOrDefault();
                if (data == null)
                {
                    msg = "数据不存在或已绑定过,请核对后再操作";
                    return(flag);
                }

                t_event t_event = _dbContext.Get <t_event>(data.eventId);
                if (t_event.eventStatus != EventStatusEm.比赛完成)
                {
                    msg = "赛事未完成不能进行绑定";
                    return(flag);
                }

                try
                {
                    _dbContext.BeginTransaction();
                    t_member_points points = _dbContext.Select <t_member_points>(c => c.memberId == data.memberId).FirstOrDefault();
                    _dbContext.Execute($"update t_member_points set playerPoints=playerPoints+{points.playerPoints},coachPoints=coachPoints+{points.coachPoints},refereePoints=refereePoints+{points.refereePoints} where memberId={request.MemberId}");
                    _dbContext.Execute($"update t_member_temp set tomemberId={request.MemberId},updateTime='{DateTime.Now}',tempStatus={(int)TempStatusEm.已绑定}  where id={data.id}");
                    _dbContext.Execute($"update t_member_points_record set memberId={request.MemberId} where memberId={data.memberId} and isdelete=0");
                    _dbContext.Execute($"update t_event_referee_signup set memberId={request.MemberId} where memberId={data.memberId} and isdelete=0");
                    _dbContext.Execute($"update t_event_cycling_match set refereeId={request.MemberId} where  refereeId={data.memberId} and isdelete=0");
                    _dbContext.Execute($"update t_event_cycling_match_playerresult set refereeId={request.MemberId} where refereeId={data.memberId} and isdelete=0");
                    _dbContext.CommitChanges();
                    flag = true;
                }
                catch (Exception ex)
                {
                    _dbContext.Rollback();
                    LogUtils.LogError("MemberTempService.BindTempRefereeTran", ex);
                }
            }
            catch (Exception ex)
            {
                LogUtils.LogError("MemberTempService.BindTempReferee", ex);
            }
            return(flag);
        }
Example #2
0
        // 支付回调 进行数据迁移
        public void Callback(int memberId, int sourceId)
        {
            try
            {
                using (IDBContext dbcontext = new MySqlDBContext())
                {
                    t_member_temp temp = dbcontext.Get <t_member_temp>(sourceId);
                    if (temp != null && temp.memberId == memberId)
                    {
                        try
                        {
                            dbcontext.BeginTransaction();
                            t_member_points points = dbcontext.Select <t_member_points>(c => c.memberId == temp.memberId).FirstOrDefault();
                            dbcontext.Execute($"update t_member_points set playerPoints=playerPoints+{points.playerPoints},coachPoints=coachPoints+{points.coachPoints},refereePoints=refereePoints+{points.refereePoints} where memberId={temp.tomemberId}");
                            dbcontext.Execute($"update t_member_temp set updateTime='{DateTime.Now}',tempStatus={(int)TempStatusEm.已绑定}  where id={temp.id}");
                            dbcontext.Execute($"update t_member_points_record set memberId={temp.tomemberId} where memberId={temp.memberId} and isdelete=0");
                            dbcontext.Execute($"update t_event_player_signup set memberId={temp.tomemberId} where memberId={temp.memberId} and isdelete=0");
                            //对垒表也要修改
                            //1 循环赛
                            dbcontext.Execute($"update t_event_cycling_match_playerresult set playerId={temp.tomemberId} where playerId={temp.memberId} and isdelete=0");
                            //2 淘汰赛

                            dbcontext.CommitChanges();
                        }
                        catch (Exception ex)
                        {
                            dbcontext.Rollback();
                            LogUtils.LogError("MemberTempService.CallbackTran", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.LogError("MemberTempService.Callback", ex);
            }
        }