protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (!filterContext.HttpContext.Request.IsAjaxRequest())
            {
                CurrentDb.SysPageAccessRecord.Add(new SysPageAccessRecord()
                {
                    UserId = this.CurrentUserId, AccessTime = DateTime.Now, PageUrl = filterContext.HttpContext.Request.Url.AbsolutePath, Ip = CommonUtils.GetIP()
                });
                CurrentDb.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private static int GetIncrNum()
        {
            lock (lock_GetIncrNum)
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                    {
                        LumosDbContext _dbContext = new LumosDbContext();

                        string date = DateTime.Now.ToString("yyyy-MM-dd");

                        var bizSn = _dbContext.BizSn.Where(m => m.IncrDate == date).FirstOrDefault();
                        if (bizSn == null)
                        {
                            bizSn          = new Entity.BizSn();
                            bizSn.IncrNum  = 0;
                            bizSn.IncrDate = date;
                            _dbContext.BizSn.Add(bizSn);
                            _dbContext.SaveChanges();
                        }

                        bizSn.IncrNum += 1;

                        _dbContext.SaveChanges();
                        ts.Complete();

                        return(bizSn.IncrNum);
                    }
                }
                catch (Exception ex)
                {
                    LogUtil.Error("业务流水号生成发生异常,错误编码:005", ex);

                    throw new Exception("业务流水号生成发生异常,错误编码:005");
                }
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int a = GetHeight(1920, 616, 1020);
            //OAuthApi.CardCodeDecrypt("13_uev3UiFHaQYf_qG882v2w9_FBz8a18dIRMjWG1Axv7Wv4mpOLDzwgJB1tySq5QaT__5IBYRNrURk_K_T1GoHshkvWPasfTtIip2V5BzdNEBHNqIO1I3_SPRNIv0gfDUE7zlE-POZHdQo2aOKVDHhAHALTX", "ftp40hZGeN2MQYDTWpH4q93CwcrbioZuSXfi16qfI4o=");
            var operater = "00000000000000000000000000000000";


            //BizFactory.Order.PayResultNotify(operater, Enumeration.OrderNotifyLogNotifyFrom.WebApp, "fdfsf", "2018090218544434811746");

            Dictionary <string, string> sParams = new Dictionary <string, string>();

            sParams.Add("nonce_str", "86e46cbd7f3043a6aaff39526a2f0d9a");
            sParams.Add("timestamp", "1540600830");
            sParams.Add("card_id", "pxQXdstVsRECMX_KAVV4McvL-3No");
            //sParams.Add("code", "5555");2
            //sParams.Add("openid", "7777");
            sParams.Add("api_ticket", "E0o2-at6NcC2OsJiQTlwlKMSjtVtlHwVgHPyQXlh-RRu0M7pp7T-oWWkn7bFiipLVf0kMiaQpZ_K4KGLRI2cBg");

            //string s = Lumos.WeiXinSdk.CommonUtil.MakeCardSign(sParams);
            //Console.WriteLine(s);
            //string xml= "<xml><ToUserName><![CDATA[gh_fc0a06a20993]]></ToUserName><FromUserName><![CDATA[oZI8Fj040-be6rlDohc6gkoPOQTQ]]></FromUserName><CreateTime>1472551036</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[user_get_card]]></Event><CardId><![CDATA[pZI8Fjwsy5fVPRBeD78J4RmqVvBc]]></CardId><IsGiveByFriend>0</IsGiveByFriend><UserCardCode><![CDATA[226009850808]]></UserCardCode><FriendUserName><![CDATA[]]></FriendUserName><OuterId>0</OuterId><OldUserCardCode><![CDATA[]]></OldUserCardCode><OuterStr><![CDATA[12b]]></OuterStr><IsRestoreMemberCard>0</IsRestoreMemberCard><IsRecommendByFriend>0</IsRecommendByFriend><UnionId>o6_bmasdasdsad6_2sgVt7hMZOPfL</UnionId></xml>";

            // var baseEventMsg = WxMsgFactory.CreateMessage(xml);


            //OAuthApi.UploadMultimediaImage("13_biDPYMhICk8L9pCaDLBYdYdCrHRpYjUSUfACRKGgr8ezw-lxqQxYLYXKTkWVwo6fKju-5XjZ675hOk7w7r3zV5I8KoqjFajap6gaJK2PAhoWujJCLf03E4j0er-ZLs3VU_1e7B69QUl-TwX_FFGhAFAYYZ", "d:\\hb1.jpg");

            //System.Drawing.Image oImg = System.Drawing.Image.FromFile("d:\\hb1.jpg");


            //BarcodeWriter writer = new BarcodeWriter();
            //writer.Format = BarcodeFormat.QR_CODE;
            //QrCodeEncodingOptions options = new QrCodeEncodingOptions();
            //options.DisableECI = true;
            ////设置内容编码
            //options.CharacterSet = "UTF-8";
            ////设置二维码的宽度和高度
            //options.Width = 500;
            //options.Height = 500;
            ////设置二维码的边距,单位不是固定像素
            //options.Margin = 1;
            //writer.Options = options;

            //System.Drawing.Image oImg1 = writer.Write("http://www.qq.com");

            //System.Drawing.Bitmap map = new Bitmap(oImg);
            //oImg.Dispose();
            //Graphics g = Graphics.FromImage(map);
            //g.InterpolationMode = InterpolationMode.HighQualityBilinear;
            //SolidBrush brush = new SolidBrush(Color.Green);
            //PointF P = new PointF(600, 100);
            //Font f = new Font("Arial", 20);
            ////g.DrawString(nickName, f, brush, 310, 542);
            //g.DrawImage(oImg1, 320, 1655, 150, 150);//画二维码图片


            //var oImg4 = CirclePhoto("http://thirdwx.qlogo.cn/mmopen/vi_32/6zcicmSoM5yjdWG9MoHydE6suFUGaHsKATFUPU7yU4d7PhLcsKWj51NhxA4PichkuYkYAflFOloKOKCSNhIeD4mQ/132", 100);

            //g.DrawImage(oImg4, 620, 1655, 150, 150);

            //// g.DrawImage(oImg3, 85, 730, 220, 220);//画二维码图片
            //map.Save("d:\\hb3.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            //f.Dispose();
            //g.Dispose();


            //BizFactory.Order.PayCompleted(operater, "2018090214233885209742", DateTime.Now);
            //SnUtil.BulidOrderNo(Enumeration.BizSnType.Order);

            LumosDbContext CurrentDb = new LumosDbContext();

            int x          = 4;
            var promoteId  = "akkk753c5fe14e26bbecad576b6a6kkk";
            var clientId   = "0000000000000000000000000000000" + (x + 1).ToString();
            var refereerId = "0000000000000000000000000000000" + x.ToString();
            var createTime = DateTime.Now;


            var promoteUser = CurrentDb.PromoteUser.Where(m => m.ClientId == clientId && m.PromoteId == promoteId).FirstOrDefault();

            if (promoteUser == null)
            {
                promoteUser            = new PromoteUser();
                promoteUser.Id         = GuidUtil.New();
                promoteUser.PromoteId  = promoteId;
                promoteUser.ClientId   = clientId;
                promoteUser.RefereerId = refereerId;
                promoteUser.CreateTime = createTime;
                promoteUser.Creator    = operater;
                CurrentDb.PromoteUser.Add(promoteUser);
                CurrentDb.SaveChanges();
            }

            var promoteUserRelation = CurrentDb.PromoteUserRelation.Where(m => m.ClientId == clientId && m.RefereerDept == 1 && m.PromoteId == promoteId).FirstOrDefault();

            if (promoteUserRelation == null)
            {
                promoteUserRelation              = new PromoteUserRelation();
                promoteUserRelation.Id           = GuidUtil.New();
                promoteUserRelation.PromoteId    = promoteId;
                promoteUserRelation.ClientId     = clientId;
                promoteUserRelation.RefereerId   = refereerId;
                promoteUserRelation.RefereerDept = 1;
                promoteUserRelation.CreateTime   = createTime;
                promoteUserRelation.Creator      = operater;
                CurrentDb.PromoteUserRelation.Add(promoteUserRelation);
                CurrentDb.SaveChanges();
            }


            var promoteUserRelationAll = CurrentDb.PromoteUserRelation.Where(m => m.PromoteId == promoteId).OrderByDescending(m => m.RefereerDept).ToList();

            var promoteUserFathers = GetFatherList2(promoteUserRelationAll, clientId).Take(3).ToList();

            for (int i = 0; i < promoteUserFathers.Count; i++)
            {
                int    dept2       = (i + 1);
                string refereerId2 = promoteUserFathers[i].RefereerId;
                //string clientId2 = promoteUserFathers[i].ClientId;
                Console.WriteLine("用户Id: " + clientId + "是用户Id:" + refereerId2 + "的" + dept2 + "级分销商");


                var promoteUserRelation2 = CurrentDb.PromoteUserRelation.Where(m => m.ClientId == clientId && m.RefereerId == refereerId2 && m.PromoteId == promoteId && m.RefereerDept == dept2).FirstOrDefault();
                if (promoteUserRelation2 == null)
                {
                    promoteUserRelation2              = new PromoteUserRelation();
                    promoteUserRelation2.Id           = GuidUtil.New();
                    promoteUserRelation2.ClientId     = clientId;
                    promoteUserRelation2.PromoteId    = promoteId;
                    promoteUserRelation2.RefereerId   = refereerId2;
                    promoteUserRelation2.RefereerDept = dept2;
                    promoteUserRelation2.CreateTime   = createTime;
                    promoteUserRelation2.Creator      = operater;
                    CurrentDb.PromoteUserRelation.Add(promoteUserRelation2);
                    CurrentDb.SaveChanges();
                }
            }


            //var promoteUsers = CurrentDb.PromoteUser.Where(m => m.PromoteId == promoteId).ToList();

            //var promoteUserFathers = GetFatherList(promoteUsers, clientId).Where(m => m.ClientId != clientId && m.IsAgent == false).Take(3).ToList();

            //for (int i = 0; i < promoteUserFathers.Count; i++)
            //{
            //    int dept = (i + 1);
            //    Console.WriteLine("用户Id: " + clientId + "是用户Id:" + promoteUserFathers[i].ClientId + "的" + dept + "级分销商");
            //    var promoteUserRelation = new PromoteUserRelation();
            //    promoteUserRelation.Id = GuidUtil.New();
            //    promoteUserRelation.ClientId = promoteUserFathers[i].ClientId;
            //    promoteUserRelation.PromoteId = promoteId;
            //    promoteUserRelation.CClientId = clientId;
            //    promoteUserRelation.Dept = dept;
            //    promoteUserRelation.CreateTime = createTime;
            //    promoteUserRelation.Creator = operater;
            //    CurrentDb.PromoteUserRelation.Add(promoteUserRelation);
            //    CurrentDb.SaveChanges();

            //}

            //foreach (var item in promoteUserFathers)
            //{
            //    Console.WriteLine("父用户Id:" + item.UserId);

            //    var son = GetSonList(promoteUser, item.PUserId).ToList();
            //    for (int i = 0; i < son.Count; i++)
            //    {
            //        Console.WriteLine("第" + (i + 1) + "个子用户Id:" + son[i].ClientId);
            //    }

            //}
        }
        public static CustomJsonResult Send(string template, string smsparam, string mobile)
        {
            ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            LumosDbContext currentDb = new LumosDbContext();

            SysSmsSendHistory sendHistory = new SysSmsSendHistory();

            sendHistory.ApiName        = "sms.market.alicloudapi.com";
            sendHistory.TemplateParams = smsparam;
            sendHistory.TemplateCode   = template;
            sendHistory.Phone          = mobile;
            sendHistory.Creator        = 0;
            sendHistory.CreateTime     = DateTime.Now;

            CustomJsonResult result = new CustomJsonResult();


            try
            {
                String querys = string.Format("ParamString={1}&RecNum={2}&SignName={3}&TemplateCode={0}", template, UrlEncode(smsparam), mobile, "收款易");

                String          bodys        = "";
                String          url          = host + path;
                HttpWebRequest  httpRequest  = null;
                HttpWebResponse httpResponse = null;

                if (0 < querys.Length)
                {
                    url = url + "?" + querys;
                }

                if (host.Contains("https://"))
                {
                    httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
                }
                else
                {
                    httpRequest = (HttpWebRequest)WebRequest.Create(url);
                }
                httpRequest.Method = method;
                httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
                if (0 < bodys.Length)
                {
                    byte[] data = Encoding.UTF8.GetBytes(bodys);
                    using (Stream stream = httpRequest.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }
                }

                httpResponse = (HttpWebResponse)httpRequest.GetResponse();

                Stream       st     = httpResponse.GetResponseStream();
                StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));

                string r = reader.ReadToEnd();


                AliCloudApiResult apiResult = Newtonsoft.Json.JsonConvert.DeserializeObject <AliCloudApiResult>(r);

                if (apiResult.Success)
                {
                    sendHistory.Result = Enumeration.SysSmsSendResult.Success;
                    currentDb.SysSmsSendHistory.Add(sendHistory);
                    currentDb.SaveChanges();


                    result = new CustomJsonResult(ResultType.Success, "发送成功");
                }
                else
                {
                    sendHistory.Result        = Enumeration.SysSmsSendResult.Failure;
                    sendHistory.FailureReason = string.Format("描述:{0}", apiResult.Message);
                    currentDb.SysSmsSendHistory.Add(sendHistory);
                    currentDb.SaveChanges();

                    log.ErrorFormat("调用短信{0}接口-错误信息:{1}", sendHistory.ApiName, apiResult.Message);

                    result = new CustomJsonResult(ResultType.Failure, "发送失败");
                }


                return(result);
            }
            catch (Exception ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.Message;

                currentDb.SysSmsSendHistory.Add(sendHistory);
                currentDb.SaveChanges();

                log.ErrorFormat("调用短信{0}接口-错误信息:{1},描述:{2}", sendHistory.ApiName, ex.Message, ex.StackTrace);

                return(new CustomJsonResult(ResultType.Failure, "发送失败"));
            }

            return(result);
        }
Exemplo n.º 5
0
        public static CustomJsonResult Send(string template, string smsparam, string mobile, out string token, string validCode = null, int?expireSecond = null)
        {
            CustomJsonResult result  = new CustomJsonResult();
            IClientProfile   profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAInW2wvf70MRTU", "wCceTF0BOmMPgctSPPLfmMNMfyFRXS");
            IAcsClient       client  = new DefaultAcsClient(profile);

            SingleSendSmsRequest request = new SingleSendSmsRequest();

            LumosDbContext currentDb = new LumosDbContext();

            SysSmsSendHistory sendHistory = new SysSmsSendHistory();

            token                      = Guid.NewGuid().ToString();
            sendHistory.Token          = token;
            sendHistory.ApiName        = "AliyunSingleSendSmsUtils";
            sendHistory.TemplateParams = smsparam;
            sendHistory.TemplateCode   = template;
            sendHistory.Phone          = mobile;
            sendHistory.CreateTime     = DateTime.Now;
            sendHistory.Creator        = 0;
            sendHistory.ValidCode      = validCode;
            if (expireSecond != null)
            {
                sendHistory.ExpireTime = sendHistory.CreateTime.AddSeconds(expireSecond.Value);
            }

            try
            {
                request.SignName     = "全线通信息";  //"管理控制台中配置的短信签名(状态必须是验证通过)"
                request.TemplateCode = template; //管理控制台中配置的审核通过的短信模板的模板CODE(状态必须是验证通过)"
                request.RecNum       = mobile;   //"接收号码,多个号码可以逗号分隔"
                request.ParamString  = smsparam; //短信模板中的变量;数字需要转换为字符串;个人用户每个变量长度必须小于15个字符。"
                SingleSendSmsResponse httpResponse = client.GetAcsResponse(request);


                sendHistory.Result = Enumeration.SysSmsSendResult.Success;

                result = new CustomJsonResult(ResultType.Success, "发送成功");
            }
            catch (ServerException ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.ErrorCode;

                result = new CustomJsonResult(ResultType.Exception, "发送失败");
            }
            catch (ClientException ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.ErrorCode;

                result = new CustomJsonResult(ResultType.Exception, "发送失败");
            }
            catch (Exception ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.Message;

                result = new CustomJsonResult(ResultType.Exception, "发送失败");
            }

            currentDb.SysSmsSendHistory.Add(sendHistory);
            currentDb.SaveChanges();

            return(result);
        }
        public static CustomJsonResult Send(string template, string smsparam, string mobile, out string token, string validCode = null, int?expireSecond = null)
        {
            String           product = "Dysmsapi";              //短信API产品名称
            String           domain  = "dysmsapi.aliyuncs.com"; //短信API产品域名
            CustomJsonResult result  = new CustomJsonResult();
            IClientProfile   profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAI1kaGcK7uE9Hf", "95x0VXSdph8lMvjLRvsv8sscCpTvWL");

            DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
            IAcsClient     acsClient = new DefaultAcsClient(profile);
            SendSmsRequest request   = new SendSmsRequest();

            LumosDbContext currentDb = new LumosDbContext();

            SysSmsSendHistory sendHistory = new SysSmsSendHistory();

            token                      = Guid.NewGuid().ToString();
            sendHistory.Token          = token;
            sendHistory.ApiName        = "AliyunSingleSendSmsUtils";
            sendHistory.TemplateParams = smsparam;
            sendHistory.TemplateCode   = template;
            sendHistory.Phone          = mobile;
            sendHistory.CreateTime     = DateTime.Now;
            sendHistory.Creator        = 0;
            sendHistory.ValidCode      = validCode;
            if (expireSecond != null)
            {
                sendHistory.ExpireTime = sendHistory.CreateTime.AddSeconds(expireSecond.Value);
            }

            try
            {
                request.SignName      = "好易联";    //"管理控制台中配置的短信签名(状态必须是验证通过)"
                request.PhoneNumbers  = mobile;   //"接收号码,多个号码可以逗号分隔"
                request.TemplateCode  = template; //管理控制台中配置的审核通过的短信模板的模板CODE(状态必须是验证通过)"
                request.TemplateParam = smsparam; //短信模板中的变量;数字需要转换为字符串;个人用户每个变量长度必须小于15个字符。"
                SendSmsResponse sendSmsResponse = acsClient.GetAcsResponse(request);
                if (sendSmsResponse.Code == "OK")
                {
                    sendHistory.Result = Enumeration.SysSmsSendResult.Success;
                    result             = new CustomJsonResult(ResultType.Success, "发送成功.");
                }
                else
                {
                    sendHistory.Result        = Enumeration.SysSmsSendResult.Failure;
                    sendHistory.FailureReason = sendSmsResponse.Message;
                    result = new CustomJsonResult(ResultType.Failure, "发送失败.");
                }
            }
            catch (ServerException ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.ErrorCode;

                result = new CustomJsonResult(ResultType.Exception, "发送失败..");
            }
            catch (ClientException ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.ErrorCode;

                result = new CustomJsonResult(ResultType.Exception, "发送失败...");
            }
            catch (Exception ex)
            {
                sendHistory.Result = Enumeration.SysSmsSendResult.Exception;

                sendHistory.FailureReason = ex.Message;

                result = new CustomJsonResult(ResultType.Exception, "发送失败....");
            }

            currentDb.SysSmsSendHistory.Add(sendHistory);
            currentDb.SaveChanges();

            return(result);
        }
Exemplo n.º 7
0
        private void PromoteRefereerRewardByBuyerBuy()
        {
            LogUtil.Info(string.Format("正在处理消息类型为:{0},具体的参数未:{1}", this.Type.GetCnName(), Newtonsoft.Json.JsonConvert.SerializeObject(this.Pms)));

            using (LumosDbContext CurrentDb = new LumosDbContext())
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    #region 购买前奖励
                    var model = ((JObject)this.Pms).ToObject <RedisMqHandlePms4PromoteRefereerRewardByBuyerBuy>();

                    var promote = CurrentDb.Promote.Where(m => m.Id == model.PromoteId).FirstOrDefault();

                    if (promote == null)
                    {
                        LogUtil.Info("活动:" + model.PromoteId + ",为空");
                        return;
                    }

                    if (model.BuyerId == null)
                    {
                        LogUtil.Info("购买人,为空");
                        return;
                    }

                    if (model.RefereerId == null)
                    {
                        LogUtil.Info("推荐人,为空");
                        return;
                    }

                    if (model.BuyerId == model.RefereerId)
                    {
                        LogUtil.Info("购买人和推荐人是同一个人");
                        return;
                    }



                    var promoteRefereerRewardSets = CurrentDb.PromoteRefereerRewardSet.Where(m => m.PromoteId == model.PromoteId && m.Channel == Enumeration.PromoteRefereerRewardSetChannel.BuyerBuyProductSku).ToList();

                    if (promoteRefereerRewardSets.Count > 0)
                    {
                        foreach (var reward in promoteRefereerRewardSets)
                        {
                            var rewardModel = Newtonsoft.Json.JsonConvert.DeserializeObject <RewardModel>(reward.Reward);

                            var promoteRefereerRewardFactor = CurrentDb.PromoteRefereerRewardFactor.Where(m => m.RefereerId == model.RefereerId && m.PromoteId == reward.PromoteId && m.PromoteRefereerRewardSetId == reward.Id).FirstOrDefault();
                            if (promoteRefereerRewardFactor == null)
                            {
                                promoteRefereerRewardFactor    = new PromoteRefereerRewardFactor();
                                promoteRefereerRewardFactor.Id = GuidUtil.New();
                                promoteRefereerRewardFactor.PromoteRefereerRewardSetId = reward.Id;
                                promoteRefereerRewardFactor.RefereerId = model.RefereerId;
                                promoteRefereerRewardFactor.PromoteId  = model.PromoteId;
                                promoteRefereerRewardFactor.Factor     = reward.IncreaseFactor;
                                CurrentDb.PromoteRefereerRewardFactor.Add(promoteRefereerRewardFactor);
                                CurrentDb.SaveChanges();
                            }

                            if (model.RefereerRefereeCount == promoteRefereerRewardFactor.Factor)
                            {
                                promoteRefereerRewardFactor.Factor += reward.IncreaseFactor;

                                foreach (var gift in rewardModel.Gifts)
                                {
                                    var giftGive = CurrentDb.GiftGive.Where(m => m.ClientId == model.RefereerId && m.SkuId == gift.SkuId).FirstOrDefault();
                                    if (giftGive == null)
                                    {
                                        giftGive                   = new GiftGive();
                                        giftGive.Id                = GuidUtil.New();
                                        giftGive.ClientId          = model.RefereerId;
                                        giftGive.CurrentQuantity   = gift.Quantity;
                                        giftGive.AvailableQuantity = gift.Quantity;
                                        giftGive.LockQuantity      = 0;
                                        giftGive.SkuId             = gift.SkuId;
                                        giftGive.Creator           = GuidUtil.New();
                                        giftGive.CreateTime        = DateTime.Now;
                                        CurrentDb.GiftGive.Add(giftGive);
                                        CurrentDb.SaveChanges();
                                    }
                                    else
                                    {
                                        giftGive.CurrentQuantity   += gift.Quantity;
                                        giftGive.AvailableQuantity += gift.Quantity;
                                        giftGive.Mender             = GuidUtil.New();
                                        giftGive.MendTime           = DateTime.Now;
                                    }


                                    var giftGiveTrans = new GiftGiveTrans();
                                    giftGiveTrans.Id                = GuidUtil.New();
                                    giftGiveTrans.Sn                = SnUtil.Build(Enumeration.BizSnType.GiftGiveTrans, model.RefereerId);
                                    giftGiveTrans.ClientId          = model.RefereerId;
                                    giftGiveTrans.SkuId             = giftGive.SkuId;
                                    giftGiveTrans.ChangeType        = Enumeration.GiftGiveTransType.SignupGift;
                                    giftGiveTrans.ChangeQuantity    = gift.Quantity;
                                    giftGiveTrans.AvailableQuantity = giftGive.AvailableQuantity;
                                    giftGiveTrans.CurrentQuantity   = giftGive.CurrentQuantity;
                                    giftGiveTrans.LockQuantity      = giftGive.LockQuantity;
                                    giftGiveTrans.Description       = "您推荐的用户参与报名成功,得到奖品";
                                    giftGiveTrans.Creator           = GuidUtil.New();
                                    giftGiveTrans.CreateTime        = DateTime.Now;
                                    CurrentDb.GiftGiveTrans.Add(giftGiveTrans);
                                    CurrentDb.SaveChanges();
                                }
                            }
                        }
                    }



                    //var fund = CurrentDb.Fund.Where(m => m.ClientId == model.RefereerId).FirstOrDefault();

                    //if (fund == null)
                    //{
                    //    LogUtil.Info("用户:" + model.ClientId + ",找不到钱包");
                    //    return;
                    //}

                    //var wxUserInfo = CurrentDb.WxUserInfo.Where(m => m.ClientId == model.ClientId).FirstOrDefault();

                    //if (wxUserInfo == null)
                    //{
                    //    LogUtil.Info("用户:" + model.ClientId + ",找不到信息");
                    //    return;
                    //}

                    //var order = CurrentDb.Order.Where(m => m.Id == model.OrderId).FirstOrDefault();

                    //if (order == null)
                    //{
                    //    LogUtil.Info("订单:" + model.OrderId + ",找不到信息");
                    //    return;
                    //}

                    //if (order.BuyProfitIsSettled)
                    //{
                    //    LogUtil.Info("订单:" + model.OrderId + ",已经结算佣金");
                    //    return;
                    //}

                    //order.BuyProfitIsSettled = true;
                    //order.BuyProfitSettledTime = DateTime.Now;

                    //string nickname = "";
                    //string headImgUrl = IconUtil.BuyCoupon;
                    //if (wxUserInfo != null)
                    //{
                    //    nickname = wxUserInfo.Nickname;

                    //    if (!string.IsNullOrEmpty(wxUserInfo.HeadImgUrl))
                    //    {
                    //        headImgUrl = wxUserInfo.HeadImgUrl;
                    //    }
                    //}

                    //decimal profit = 0;

                    //fund.CurrentBalance += profit;
                    //fund.AvailableBalance += profit;
                    //fund.MendTime = DateTime.Now;
                    //fund.Mender = GuidUtil.Empty();

                    //var fundTrans = new FundTrans();
                    //fundTrans.Id = GuidUtil.New();
                    //fundTrans.Sn = SnUtil.Build(Enumeration.BizSnType.FundTrans, fund.ClientId);
                    //fundTrans.ClientId = fund.ClientId;
                    //fundTrans.ChangeType = Enumeration.FundTransChangeType.BuyCoupon;
                    //fundTrans.ChangeAmount = profit;
                    //fundTrans.CurrentBalance = fund.CurrentBalance;
                    //fundTrans.AvailableBalance = fund.AvailableBalance;
                    //fundTrans.LockBalance = fund.LockBalance;
                    //fundTrans.CreateTime = DateTime.Now;
                    //fundTrans.Creator = GuidUtil.Empty();
                    //fundTrans.Description = string.Format("分享给用户({0})购买入场券", nickname);
                    //fundTrans.TipsIcon = headImgUrl;
                    //fundTrans.IsNoDisplay = false;
                    //CurrentDb.FundTrans.Add(fundTrans);
                    CurrentDb.SaveChanges();
                    ts.Complete();

                    #endregion
                }
            }
        }