public CustomJsonResult EditPromoteUserInfo(RopPromoteUserInfoEdit rop)
        {
            LogUtil.Info("用户:" + this.CurrentUserId + ",提交卡券信息");

            var promoteUser = CurrentDb.PromoteUser.Where(m => m.ClientId == this.CurrentUserId && m.PromoteId == rop.PromoteId).FirstOrDefault();

            if (promoteUser == null)
            {
                promoteUser             = new PromoteUser();
                promoteUser.Id          = GuidUtil.New();
                promoteUser.PromoteId   = rop.PromoteId;
                promoteUser.ClientId    = this.CurrentUserId;
                promoteUser.CtName      = rop.CtName;
                promoteUser.CtPhone     = rop.CtPhone;
                promoteUser.CtIsStudent = rop.CtIsStudent;
                promoteUser.CtSchool    = rop.CtSchool;
                promoteUser.CreateTime  = DateTime.Now;
                promoteUser.Creator     = this.CurrentUserId;
                CurrentDb.PromoteUser.Add(promoteUser);
            }
            else
            {
                promoteUser.CtName      = rop.CtName;
                promoteUser.CtPhone     = rop.CtPhone;
                promoteUser.CtIsStudent = rop.CtIsStudent;
                promoteUser.CtSchool    = rop.CtSchool;
            }

            CurrentDb.SaveChanges();

            return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "保存成功"));
        }
Beispiel #2
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);
            //    }

            //}
        }
Beispiel #3
0
        public CustomJsonResult <RetOrderUnifiedOrder> UnifiedOrder(string operater, string clientId, RopOrderUnifiedOrder rop)
        {
            CustomJsonResult <RetOrderUnifiedOrder> result = new CustomJsonResult <RetOrderUnifiedOrder>();

            try
            {
                lock (lock_UnifiedOrder)
                {
                    var ret = new RetOrderUnifiedOrder();

                    using (TransactionScope ts = new TransactionScope())
                    {
                        LogUtil.Info("用户id:" + clientId);

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

                        if (wxUserInfo == null)
                        {
                            return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "找不到用户微信信息", null));
                        }

                        var orderByBuyed = CurrentDb.Order.Where(m => m.ClientId == clientId && m.PromoteId == rop.PromoteId && m.Status == Enumeration.OrderStatus.Payed).FirstOrDefault();
                        if (orderByBuyed != null)
                        {
                            return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "您已成功抢购,支付成功", null));
                        }

                        var promoteBlackList = CurrentDb.PromoteBlackList.Where(m => m.PromoteId == rop.PromoteId && m.ClientId == clientId).FirstOrDefault();
                        if (promoteBlackList != null)
                        {
                            return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "谢谢参与,已售罄", null));
                        }

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

                        if (promote != null)
                        {
                            if (promote.TargetType == Enumeration.PromoteTargetType.NotStudent)
                            {
                                var student = CurrentDb.Student.Where(m => m.Phone == rop.PromoteUser.CtPhone).FirstOrDefault();
                                if (student != null)
                                {
                                    return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "仅限于非学员参与报名,谢谢关注", null));
                                }
                            }


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

                            if (promoteUser == null)
                            {
                                promoteUser                    = new PromoteUser();
                                promoteUser.Id                 = GuidUtil.New();
                                promoteUser.PromoteId          = rop.PromoteId;
                                promoteUser.ClientId           = clientId;
                                promoteUser.BroadcastChannelId = rop.BcId;
                                promoteUser.RefereerId         = rop.RefereerId;
                                promoteUser.CtName             = rop.PromoteUser.CtName;
                                promoteUser.CtPhone            = rop.PromoteUser.CtPhone;
                                promoteUser.CtIsStudent        = rop.PromoteUser.CtIsStudent;
                                promoteUser.CtSchool           = rop.PromoteUser.CtSchool;
                                promoteUser.CreateTime         = DateTime.Now;
                                promoteUser.Creator            = operater;
                                CurrentDb.PromoteUser.Add(promoteUser);
                            }
                            else
                            {
                                promoteUser.BroadcastChannelId = rop.BcId;
                                promoteUser.RefereerId         = rop.RefereerId;
                                promoteUser.CtName             = rop.PromoteUser.CtName;
                                promoteUser.CtPhone            = rop.PromoteUser.CtPhone;
                                promoteUser.CtIsStudent        = rop.PromoteUser.CtIsStudent;
                                promoteUser.CtSchool           = rop.PromoteUser.CtSchool;
                            }



                            foreach (var sku in rop.Skus)
                            {
                                var productSku = CurrentDb.ProductSku.Where(m => m.Id == sku.SkuId).FirstOrDefault();

                                if (productSku == null)
                                {
                                    return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "找不到该商品", null));
                                }

                                var promoteSku = CurrentDb.PromoteSku.Where(m => m.PromoteId == rop.PromoteId && m.SkuId == sku.SkuId && m.BuyStartTime <= this.DateTime && m.BuyEndTime >= this.DateTime).FirstOrDefault();

                                if (promoteSku == null)
                                {
                                    return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "谢谢参与,活动已经结束", null));
                                }

                                if (!string.IsNullOrEmpty(promoteSku.RefereePromoteId))
                                {
                                    var clientCoupon = CurrentDb.ClientCoupon.Where(m => m.PromoteId == promoteSku.RefereePromoteId && m.ClientId == clientId && m.IsBuy == true).FirstOrDefault();
                                    if (clientCoupon == null)
                                    {
                                        return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "谢谢参与,您没有资格参与购买", null));
                                    }
                                }

                                if (promoteSku.StockQuantity > -1)
                                {
                                    if (promoteSku.SellQuantity <= 0)
                                    {
                                        return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "谢谢参与,商品已经售罄", null));
                                    }
                                }
                            }
                        }

                        var order = CurrentDb.Order.Where(m => m.PromoteId == rop.PromoteId && m.ClientId == clientId && m.Status == Entity.Enumeration.OrderStatus.WaitPay).FirstOrDefault();

                        if (order == null)
                        {
                            string orderId = GuidUtil.New();

                            var l_orderDetails = new List <OrderDetails>();

                            foreach (var sku in rop.Skus)
                            {
                                var productSku = CurrentDb.ProductSku.Where(m => m.Id == sku.SkuId).FirstOrDefault();

                                var productSkuOriginalPrice = productSku.SalePrice;
                                var productSkuSalePrice     = productSku.SalePrice;

                                var promoteSku = CurrentDb.PromoteSku.Where(m => m.PromoteId == rop.PromoteId && m.SkuId == sku.SkuId && m.BuyStartTime <= this.DateTime && m.BuyEndTime >= this.DateTime).FirstOrDefault();
                                if (promoteSku != null)
                                {
                                    productSkuSalePrice = promoteSku.SkuSalePrice;

                                    if (promoteSku.StockQuantity > -1)
                                    {
                                        promoteSku.SellQuantity -= 1;
                                        promoteSku.LockQuantity += 1;
                                    }
                                }

                                var orderDetails = new OrderDetails();
                                orderDetails.Id                 = GuidUtil.New();
                                orderDetails.ClientId           = clientId;
                                orderDetails.OrderId            = orderId;
                                orderDetails.BroadcastChannelId = rop.BcId;
                                orderDetails.PromoteId          = rop.PromoteId;
                                orderDetails.SkuId              = productSku.Id;
                                orderDetails.SkuName            = productSku.Name;
                                orderDetails.SkuImgUrl          = ImgSet.GetMain(productSku.DisplayImgUrls);
                                orderDetails.Quantity           = 1;
                                orderDetails.SalePrice          = productSkuSalePrice;
                                orderDetails.OriginalAmount     = productSkuOriginalPrice;
                                orderDetails.DiscountAmount     = productSkuOriginalPrice - productSkuSalePrice;
                                orderDetails.ChargeAmount       = orderDetails.OriginalAmount - orderDetails.DiscountAmount;
                                orderDetails.CreateTime         = this.DateTime;
                                orderDetails.Creator            = operater;
                                orderDetails.Status             = Enumeration.OrderDetailsStatus.WaitPay;
                                CurrentDb.OrderDetails.Add(orderDetails);
                                l_orderDetails.Add(orderDetails);
                            }


                            order                    = new Order();
                            order.Id                 = orderId;
                            order.ClientId           = clientId;
                            order.Sn                 = SnUtil.Build(Enumeration.BizSnType.Order, order.ClientId);
                            order.BroadcastChannelId = rop.BcId;
                            order.PromoteId          = rop.PromoteId;
                            order.RefereerId         = rop.RefereerId;
                            order.OriginalAmount     = l_orderDetails.Sum(m => m.OriginalAmount);
                            order.DiscountAmount     = l_orderDetails.Sum(m => m.DiscountAmount);
                            order.ChargeAmount       = order.OriginalAmount - order.DiscountAmount;
                            order.SubmitTime         = this.DateTime;
                            order.CreateTime         = this.DateTime;
                            order.Creator            = operater;
                            order.IsInVisiable       = true;
                            order.Status             = Enumeration.OrderStatus.WaitPay; //待支付状态

                            CurrentDb.Order.Add(order);
                            CurrentDb.SaveChanges();
                        }


                        bool    isNeedBuy    = true;
                        decimal chargeAmount = order.ChargeAmount;
                        if (chargeAmount <= 0)
                        {
                            isNeedBuy = false;
                        }

                        string[] testClientId = new string[2] {
                            "62c587c13c124f96b436de9522fb31f0", "4faecb3507aa48698405cf492dc26916"
                        };

                        if (isNeedBuy)
                        {
                            if (testClientId.Contains(order.ClientId))
                            {
                                chargeAmount = 0.01m;
                            }

                            string goods_tag = "";
                            string prepayId  = SdkFactory.Wx.Instance().GetPrepayId(operater, "JSAPI", wxUserInfo.OpenId, order.Sn, chargeAmount, goods_tag, Common.CommonUtil.GetIP(), "商品购买", order.PayExpireTime);
                            if (string.IsNullOrEmpty(prepayId))
                            {
                                LogUtil.Error("去结算,微信支付中生成预支付订单失败");
                                return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Failure, ResultCode.Failure, "抢购失败,刷新页面再试试", null));
                            }

                            order.WxPrepayId    = prepayId;
                            order.PayExpireTime = this.DateTime.AddMinutes(2);

                            Task4Factory.Tim2Global.Enter(TimerTaskType.CheckOrderPay, order.PayExpireTime.Value, order);

                            ret.IsBuy      = false;
                            ret.WxPrepayId = order.WxPrepayId;
                        }
                        else
                        {
                            ret.IsBuy = true;
                            BizFactory.Order.PayCompleted(operater, order.Sn, this.DateTime);
                        }

                        CurrentDb.SaveChanges();
                        ts.Complete();

                        ret.OrderId = order.Id;
                        ret.OrderSn = order.Sn;

                        result = new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Success, ResultCode.Success, "操作成功", ret);
                        LogUtil.Info("去结算结束");
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                LogUtil.Error("检查下单发生异常", ex);

                return(new CustomJsonResult <RetOrderUnifiedOrder>(ResultType.Exception, ResultCode.Exception, "下单发生异常", null));
            }
        }
Beispiel #4
0
        public string GetWxPromoteImgMediaId(string promoteId, string clientId)
        {
            try
            {
                var wxUserInfo = CurrentDb.WxUserInfo.Where(m => m.ClientId == clientId).FirstOrDefault();
                if (wxUserInfo == null)
                {
                    return(null);
                }
                var promote = CurrentDb.Promote.Where(m => m.Id == promoteId).FirstOrDefault();

                if (promote == null)
                {
                    return(null);
                }

                var promoteUser = CurrentDb.PromoteUser.Where(m => m.PromoteId == promoteId && m.ClientId == clientId).FirstOrDefault();
                if (promoteUser == null)
                {
                    promoteUser            = new PromoteUser();
                    promoteUser.Id         = GuidUtil.New();
                    promoteUser.PromoteId  = promoteId;
                    promoteUser.ClientId   = clientId;
                    promoteUser.RefereerId = null;
                    promoteUser.CreateTime = DateTime.Now;
                    promoteUser.Creator    = clientId;
                    CurrentDb.PromoteUser.Add(promoteUser);
                    CurrentDb.SaveChanges();
                }

                if (string.IsNullOrEmpty(promoteUser.WxPromoteImgMediaId))
                {
                    System.Drawing.Image oImg   = System.Drawing.Image.FromFile(Server.MapPath("~/Content/images/promote20181029/referee_bg.png"));
                    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(string.Format("http://qyj.17fanju.com/Promotec/Coupon?promoteId={0}&refereerId={1}", promoteId, clientId));
                    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(100, 100);
                    Font       f     = new Font("Arial", 20);
                    g.DrawImage(oImg1, 320, 1655, 150, 150);//画二维码图片


                    if (wxUserInfo != null)
                    {
                        if (!string.IsNullOrEmpty(wxUserInfo.HeadImgUrl))
                        {
                            var oImg4 = CirclePhoto(wxUserInfo.HeadImgUrl, 100);

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

                    string key  = GuidUtil.New();
                    string path = Server.MapPath("~/Static/Promote/User/") + key + ".jpg";

                    map.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
                    f.Dispose();
                    g.Dispose();

                    string media_Id = SdkFactory.Wx.Instance().UploadMultimediaImage(path);
                    promoteUser.PromoteImgUrl       = string.Format("http://qyj.17fanju.com/Static/Promote/User/{0}.jpg", key);
                    promoteUser.WxPromoteImgMediaId = media_Id;
                    CurrentDb.SaveChanges();

                    return(media_Id);
                }
                else
                {
                    return(promoteUser.WxPromoteImgMediaId);
                }
            }
            catch (Exception ex)
            {
                LogUtil.Error("", ex);
                return(null);
            }
        }