Beispiel #1
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="model">数据模型</param>
        public int Insert(FnCashout model)
        {
            var result = DBContext.Insert <FnCashout>("agent_fncashout", model)
                         .AutoMap(x => x.SysNo)
                         .ExecuteReturnLastId <int>("sysNo");

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 提现申请
        /// </summary>
        /// <param name="request">参数</param>
        public JResult Cashout(CashoutRequest request)
        {
            var response = new JResult()
            {
                Status = false
            };

            using (var tran = new TransactionProvider())
            {
                try
                {
                    //更新会员钱包(钱包金额-提现金额)(升级金额+提现金额/(如果是普通、区域、全国才除)2)
                    if (Using <ICrCustomer>().UpdateWalletAmount(new UpdateWalletAmountRequest()
                    {
                        CustomerSysNo = request.CustomerSysNo,
                        WalletAmount = request.WalletAmount,
                        UpgradeFundAmount = request.UpgradeFundAmount
                    }) <= 0)
                    {
                        throw new Exception("更新会员钱包失败");
                    }
                    //添加提现记录
                    var amount = request.WalletAmount - request.UpgradeFundAmount;
                    var model  = new FnCashout()
                    {
                        CustomerSysNo = request.CustomerSysNo,
                        RealName      = request.Account,
                        CashoutType   = request.CashoutType,
                        Amount        = amount,
                        Remarks       = string.Format("提现金额:{0} 实际到账金额:{1} 升级基金:{2}", request.WalletAmount, request.WalletAmount - request.UpgradeFundAmount, request.UpgradeFundAmount),
                        Status        = amount < 200?FnEnum.CashoutStatus.完成.GetHashCode(): FnEnum.CashoutStatus.处理中.GetHashCode(),//FnEnum.CashoutStatus.处理中.GetHashCode()
                        CreatedDate   = DateTime.Now
                    };

                    var cashoutSysNo = Using <IFnCashout>().Insert(model);
                    if (cashoutSysNo <= 0)
                    {
                        throw new Exception("添加提现记录失败");
                    }

                    if (amount < 200)
                    {
                        var result = FnCashoutApp.Instance.H5CashoutWeiXin(cashoutSysNo, request.CertPath);

                        Log4Helper.WriteInfoLog("EC.H5 提现" + result.ToJson2(), "Cashout");

                        if (!result.Status)
                        {
                            throw new Exception(result.Message);
                        }
                    }

                    tran.Commit();
                    response.Status  = true;
                    response.Message = "提现申请成功、等待管理员审核!";
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    response.Message = ex.Message;
                }
                finally
                {
                    tran.Dispose();
                }
            }

            return(response);
        }