예제 #1
0
        public void ConfirmApplyWithDraw(ApplyWithdrawInfo info)
        {
            var model = DbFactory.Default.Get <ApplyWithdrawInfo>().Where(e => e.Id == info.Id).FirstOrDefault();

            var flag = DbFactory.Default.InTransaction(() =>
            {
                model.ApplyStatus = info.ApplyStatus;
                model.OpUser      = info.OpUser;
                model.Remark      = info.Remark;
                model.ConfirmTime = info.ConfirmTime.HasValue ? info.ConfirmTime.Value : DateTime.Now;
                //Context.SaveChanges();
                DbFactory.Default.Update(model);
                if (info.ApplyStatus == ApplyWithdrawInfo.ApplyWithdrawStatus.WithDrawSuccess)
                {
                    //model.PayNo = info.PayNo;
                    //model.PayTime = info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now;
                    //DbFactory.Default.Update(model);
                    DbFactory.Default.Set <ApplyWithdrawInfo>().Set(n => n.PayNo, info.PayNo).Set(n => n.PayTime, info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now).Where(p => p.Id == model.Id).Succeed();
                    CapitalDetailModel capitalDetail = new CapitalDetailModel
                    {
                        Amount     = -info.ApplyAmount,
                        UserId     = model.MemId,
                        PayWay     = info.Remark,
                        SourceType = CapitalDetailInfo.CapitalDetailType.WithDraw,
                        SourceData = info.Id.ToString()
                    };
                    AddCapital(capitalDetail, false);
                }
                //scope.Complete();
                return(true);
            });

            if (flag)
            {
                //发送消息
                var member  = DbFactory.Default.Get <MemberInfo>(m => m.Id == model.MemId).FirstOrDefault();
                var message = new MessageWithDrawInfo();
                message.UserName  = model.NickName;
                message.UserName  = member != null ? member.UserName : "";
                message.Amount    = model.ApplyAmount;
                message.ApplyType = model.ApplyType.GetHashCode();
                message.ApplyTime = model.ApplyTime;
                message.Remark    = model.Remark;
                message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;

                if (info.ApplyStatus == ApplyWithdrawInfo.ApplyWithdrawStatus.WithDrawSuccess)
                {
                    Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawSuccess(model.MemId, message));
                }

                if (info.ApplyStatus == ApplyWithdrawInfo.ApplyWithdrawStatus.Refuse)
                {
                    Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawFail(model.MemId, message));
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 提现
 /// </summary>
 /// <param name="weixinMsg"></param>
 /// <param name="sceneid"></param>
 /// <param name="model"></param>
 /// <returns></returns>
 private string ProcessWithDrawScene(RequestMessageEventBase weixinMsg, string sceneid, SceneModel model)
 {
     try
     {
         var key         = CacheKeyCollection.SceneReturn(sceneid);
         var sceneResult = Core.Cache.Get <ApplyWithdrawInfo>(key);
         if (sceneResult == null)
         {
             var siteSetting = SiteSettingApplication.SiteSettings;
             if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret)))
             {
                 string token    = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                 var    userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, weixinMsg.FromUserName);
                 var    withDraw = new ApplyWithdrawInfo
                 {
                     MemId       = long.Parse(model.Object.ToString()),
                     OpenId      = weixinMsg.FromUserName,
                     ApplyStatus = ApplyWithdrawInfo.ApplyWithdrawStatus.WaitConfirm,
                     NickName    = userinfo.nickname
                 };
                 if (Core.Cache.Get <ApplyWithdrawInfo>(key) != null)
                 {
                     Core.Cache.Remove(key);
                 }
                 Core.Cache.Insert(key, withDraw, 300);
             }
             else
             {
                 Core.Log.Error("微信事件回调:未设置公众号配置参数!");
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error("ProcessWithDrawScene:" + ex.Message);
     }
     return(string.Empty);
 }
예제 #3
0
        public void AddWithDrawApply(ApplyWithdrawInfo model)
        {
            DbFactory.Default.Add(model);
            var capital = DbFactory.Default.Get <CapitalInfo>().Where(e => e.MemId == model.MemId).FirstOrDefault();

            capital.Balance     -= model.ApplyAmount;
            capital.FreezeAmount = capital.FreezeAmount + model.ApplyAmount;
            var result = DbFactory.Default.Update(capital);

            //发送消息
            if (result > 0)
            {
                var member  = DbFactory.Default.Get <MemberInfo>(m => m.Id == model.MemId).FirstOrDefault();
                var message = new MessageWithDrawInfo();
                message.UserName  = model.NickName;
                message.UserName  = member != null ? member.UserName : "";
                message.Amount    = model.ApplyAmount;
                message.ApplyType = model.ApplyType.GetHashCode();
                message.ApplyTime = model.ApplyTime;
                message.Remark    = model.Remark;
                message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;
                Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawApply(model.MemId, message));
            }
        }
예제 #4
0
 public JsonResult GetStateCompleted(bool state, ApplyWithdrawInfo model)
 {
     return(Json(new { success = state, data = model }));
 }
예제 #5
0
 /// <summary>
 /// 添加提现申请
 /// </summary>
 /// <param name="memid"></param>
 /// <param name="amount"></param>
 /// <param name="nickname"></param>
 public static void AddWithDrawApply(ApplyWithdrawInfo model)
 {
     Service.AddWithDrawApply(model);
 }
예제 #6
0
 /// <summary>
 /// 审核会员申请提现
 /// </summary>
 /// <param name="id"></param>
 public static void ConfirmApplyWithDraw(ApplyWithdrawInfo info)
 {
     Service.ConfirmApplyWithDraw(info);
 }