예제 #1
0
        /// <summary>
        /// 商家申请提现
        /// </summary>
        /// <param name="draw">申请提现实体</param>
        /// <returns></returns>
        public static bool ShopApplyWithDraw(ShopWithDraw draw)
        {
            var mAccount = _iBillingService.GetShopAccount(draw.ShopId);

            if (mAccount.Balance >= draw.WithdrawalAmount)
            {
                var    model       = _iShopService.GetShop(draw.ShopId);
                string Account     = "";
                string AccountName = "";
                if (draw.WithdrawType.Equals(WithdrawType.BankCard))
                {
                    Account     = model.BankAccountNumber;
                    AccountName = model.BankAccountName;
                }
                else
                {
                    Account     = model.WeiXinOpenId;
                    AccountName = model.WeiXinTrueName;
                }


                lock (obj)
                {
                    //处理余额
                    var mShopAccountInfo = _iBillingService.GetShopAccount(draw.ShopId);
                    mShopAccountInfo.Balance -= draw.WithdrawalAmount;
                    _iBillingService.UpdateShopAccount(mShopAccountInfo);


                    ShopWithDrawInfo Models = new ShopWithDrawInfo()
                    {
                        Account     = Account,
                        AccountName = AccountName,
                        ApplyTime   = DateTime.Now,
                        CashAmount  = draw.WithdrawalAmount,
                        CashType    = draw.WithdrawType,
                        SellerId    = draw.SellerId,
                        SellerName  = draw.SellerName,
                        ShopId      = draw.ShopId,
                        ShopRemark  = "",
                        Status      = Himall.CommonModel.WithdrawStaus.WatingAudit,
                        ShopName    = model.ShopName,
                        CashNo      = DateTime.Now.ToString("yyyyMMddHHmmssffff")
                    };
                    _iBillingService.AddShopWithDrawInfo(Models);
                }


                return(true);
            }
            else
            {
                return(false);
            }
        }