示例#1
0
        public void RefuseApplyWithDraw(long id, ApplyWithdrawInfo.ApplyWithdrawStatus status, string opuser, string remark)
        {
            //var model = Context.ApplyWithDrawInfo.FirstOrDefault(e => e.Id == id);
            var model = DbFactory.Default.Get <ApplyWithdrawInfo>().Where(e => e.Id == id).FirstOrDefault();

            model.ApplyStatus = status;
            model.OpUser      = opuser;
            model.Remark      = remark;
            model.ConfirmTime = DateTime.Now;
            DbFactory.Default.Update(model);
            //var capital = Context.CapitalInfo.FirstOrDefault(e => e.MemId == model.MemId);
            var capital = DbFactory.Default.Get <CapitalInfo>().Where(e => e.MemId == model.MemId).FirstOrDefault();

            //capital.Balance = capital.Balance.Value + model.ApplyAmount;
            //capital.FreezeAmount = capital.FreezeAmount - model.ApplyAmount;
            DbFactory.Default.Set <CapitalInfo>().Set(n => n.Balance, capital.Balance + model.ApplyAmount)
            .Set(n => n.FreezeAmount, capital.FreezeAmount - model.ApplyAmount).Where(p => p.Id == capital.Id).Succeed();
            //发送消息
            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.SendMessageOnMemberWithDrawFail(model.MemId, message));
            //Context.SaveChanges();
        }
示例#2
0
        public string SendMessageOnMemberWithDrawFail(string destination, MessageWithDrawInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.MemberWithDrawFail.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, info.SiteName + "提现失败", text);
            return(text);
        }
示例#3
0
        public string SendMessageOnMemberWithDrawSuccess(string destination, MessageWithDrawInfo info)
        {
            var config = SMSCore.GetMessageContentConfig();
            var text   = config.MemberWithDrawSuccess.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, text, "2");
            return(text);
        }
示例#4
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));
                }
            }
        }
示例#5
0
        /// <summary>
        /// 支付提现
        /// </summary>
        public static void PaymentWithdraw(long withdrawId)
        {
            var model = Service.GetWithdraw(withdrawId);

            try
            {
                switch (model.WithdrawType)
                {
                case DistributionWithdrawType.Alipay:
                    var result = Payment(DistributionWithdrawType.Alipay, model.WithdrawAccount, model.Amount, $"(单号 {withdrawId})", model.Id.ToString(), model.WithdrawName);
                    Service.SuccessWithdraw(withdrawId, result.TradNo.ToString());
                    break;

                case DistributionWithdrawType.Capital:
                    var no = MemberCapitalApplication.BrokerageTransfer(model.MemberId, model.Amount, $"(单号 {withdrawId})", model.Id.ToString());
                    Service.SuccessWithdraw(withdrawId, no.ToString());
                    break;

                case DistributionWithdrawType.WeChat:
                    var resultWechat = Payment(DistributionWithdrawType.WeChat, model.WithdrawAccount, model.Amount, $"(单号 {withdrawId})", model.Id.ToString());
                    Service.SuccessWithdraw(withdrawId, resultWechat.TradNo.ToString());
                    break;
                }
            }
            catch (Exception ex)
            {
                //支付失败(回滚提现状态)
                Service.FailWithdraw(withdrawId, ex.Message);
                throw ex;
            }
            //发送消息
            var member  = MemberApplication.GetMember(model.MemberId);
            var message = new MessageWithDrawInfo();

            message.UserName  = member != null ? member.UserName : "";
            message.Amount    = model.Amount;
            message.ApplyType = model.WithdrawType.GetHashCode();
            message.ApplyTime = model.ApplyTime;
            message.Remark    = model.Remark;
            message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;
            Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnDistributionMemberWithDrawSuccess(model.MemberId, message));
        }
示例#6
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));
            }
        }
示例#7
0
 /// <summary>
 /// 分销会员提现成功
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="info"></param>
 public static void SendMessageOnDistributionMemberWithDrawSuccess(long userId, MessageWithDrawInfo info)
 {
     _iMessageService.SendMessageOnDistributionMemberWithDrawSuccess(userId, info);
 }
示例#8
0
 /// <summary>
 /// 会员提现失败
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="info"></param>
 public static void SendMessageOnMemberWithDrawFail(long userId, MessageWithDrawInfo info)
 {
     _iMessageService.SendMessageOnMemberWithDrawFail(userId, info);
 }
示例#9
0
        /// <summary>
        /// 提现申请
        /// </summary>
        /// <param name="apply"></param>
        public static void ApplyWithdraw(DistributionApplyWithdraw apply)
        {
            if (!MemberApplication.VerificationPayPwd(apply.MemberId, apply.Password))
            {
                throw new MallException("交易密码错误");
            }

            if (apply.Amount > SiteSettingApplication.SiteSettings.DistributorWithdrawMaxLimit)
            {
                throw new MallException("超过最大提现额限");
            }

            if (apply.Amount < SiteSettingApplication.SiteSettings.DistributorWithdrawMinLimit)
            {
                throw new MallException("小于最低提现额限");
            }

            var distributor = Service.GetDistributor(apply.MemberId);

            if (apply.Amount > distributor.Balance)
            {
                throw new MallException("超过最多提现金额");
            }

            var settings = SiteSettingApplication.SiteSettings;

            if (apply.Type == DistributionWithdrawType.Alipay)
            {
                if (!settings.DistributorWithdrawTypes.ToLower().Contains("alipay"))
                {
                    throw new MallException("暂不支持支付宝提现");
                }
                if (string.IsNullOrEmpty(apply.WithdrawAccount))
                {
                    throw new MallException("支付宝账户不可为空");
                }
                if (string.IsNullOrEmpty(apply.WithdrawName))
                {
                    throw new MallException("真实姓名不可为空");
                }
            }
            else if (apply.Type == DistributionWithdrawType.WeChat)
            {
                if (!settings.DistributorWithdrawTypes.ToLower().Contains("wechat"))
                {
                    throw new MallException("暂不支持微信提现");
                }
                if (string.IsNullOrEmpty(apply.WithdrawAccount))
                {
                    throw new MallException("尚未绑定微信,请先绑定微信账户");
                }
            }

            var info = new DistributionWithdrawInfo
            {
                Amount          = apply.Amount,
                WithdrawType    = apply.Type,
                MemberId        = apply.MemberId,
                WithdrawAccount = apply.WithdrawAccount,
                WithdrawName    = apply.WithdrawName
            };

            Service.ApplyWithdraw(info);

            //发送消息
            var member  = MemberApplication.GetMember(apply.MemberId);
            var message = new MessageWithDrawInfo();

            message.UserName  = member != null ? member.UserName : "";
            message.Amount    = info.Amount;
            message.ApplyType = info.WithdrawType.GetHashCode();
            message.ApplyTime = info.ApplyTime;
            message.Remark    = info.Remark;
            message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;
            Task.Factory.StartNew(() => MessageApplication.SendMessageOnDistributionMemberWithDrawApply(apply.MemberId, message));

            //预付款提现,自动审核
            if (info.WithdrawType == DistributionWithdrawType.Capital)
            {
                AuditingWithdraw(info.Id, "System", "预存款提现,自动审核");
            }
        }