Ejemplo n.º 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       = ShopApplication.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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取一个最小价格或区间价格文本
        /// </summary>
        /// <param name="productInfo">商品实体</param>
        /// <param name="skus">商品规格集合</param>
        /// <param name="discount">会员几折</param>
        public static string GetProductPriceStr2(ProductInfo productInfo, List <Himall.DTO.SKU> skus, decimal discount = 1M)
        {
            if (productInfo == null || skus == null)
            {
                return(string.Empty);
            }
            var shopInfo = ShopApplication.GetShop(productInfo.ShopId);

            if (!shopInfo.IsSelf)
            {
                discount = 1M;
            }

            decimal min = productInfo.MinSalePrice, max = 0;
            var     strPrice = string.Empty;
            var     skusql   = skus.Where(s => s.Stock >= 0);

            if (skusql.Count() > 0)
            {
                min = skusql.Min(s => s.SalePrice);
                max = skusql.Max(s => s.SalePrice);
            }

            if (max > min)
            {
                strPrice = string.Format("{0}-{1}", (min * discount).ToString("f2"), (max * discount).ToString("f2"));
            }
            else if (min == 0 && max == 0)
            {
                strPrice = (productInfo.MinSalePrice * discount).ToString("f2");
            }
            else
            {
                strPrice = string.Format("{0}", (min * discount).ToString("f2"));
            }

            return(strPrice);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 诊所提现审核
        /// </summary>
        /// <param name="Id">审核ID</param>
        /// <param name="status">审核状态</param>
        /// <param name="Remark">平台备注</param>
        /// <param name="IpAddress">操作IP</param>
        /// <param name="UserName">操作人名称</param>
        /// <returns></returns>
        public static bool ShopApplyWithDraw(long Id, Himall.CommonModel.WithdrawStaus status, string Remark, string IpAddress = "", string UserName = "")
        {
            var model = _iBillingService.GetShopWithDrawInfo(Id);

            if (status == Himall.CommonModel.WithdrawStaus.Refused)//拒绝
            {
                model.Status     = status;
                model.PlatRemark = Remark;
                model.DealTime   = DateTime.Now;
                _iBillingService.UpdateShopWithDraw(model);

                lock (obj)
                {
                    //处理余额
                    var mShopAccountInfo = _iBillingService.GetShopAccount(model.ShopId);
                    mShopAccountInfo.Balance += model.CashAmount;
                    _iBillingService.UpdateShopAccount(mShopAccountInfo);
                }


                //操作日志
                OperationLogApplication.AddPlatformOperationLog(
                    new LogInfo
                {
                    Date        = DateTime.Now,
                    Description = string.Format("诊所提现拒绝,诊所Id={0},状态为:{1}, 说明是:{2}", model.ShopId,
                                                status, Remark),
                    IPAddress = IpAddress,
                    PageUrl   = "/Admin/ShopWithDraw/Management",
                    UserName  = UserName,
                    ShopId    = 0
                });
                return(true);
            }
            else if (model.CashType == Himall.CommonModel.WithdrawType.BankCard)//银行卡
            {
                model.Status     = status;
                model.PlatRemark = Remark;
                model.DealTime   = DateTime.Now;
                _iBillingService.UpdateShopWithDraw(model);
                //资金处理
                UpdateAccount(model.ShopId, model.CashAmount, Himall.CommonModel.ShopAccountType.WithDraw, DateTime.Now.ToString("yyyyMMddHHmmssffff"), "银行卡提现", Id);


                //操作日志
                OperationLogApplication.AddPlatformOperationLog(
                    new LogInfo
                {
                    Date        = DateTime.Now,
                    Description = string.Format("诊所银行卡提现审核成功,诊所Id={0},状态为:{1}, 说明是:{2}", model.ShopId,
                                                status, Remark),
                    IPAddress = IpAddress,
                    PageUrl   = "/Admin/ShopWithDraw/Management",
                    UserName  = UserName,
                    ShopId    = 0
                });
                return(true);
            }
            else
            {
                var plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault();
                if (plugins != null)
                {
                    try
                    {
                        var shopModel          = ShopApplication.GetShop(model.ShopId);
                        EnterprisePayPara para = new EnterprisePayPara()
                        {
                            amount       = model.CashAmount,
                            check_name   = false,
                            openid       = shopModel.WeiXinOpenId,
                            out_trade_no = model.CashNo.ToString(),
                            desc         = "提现"
                        };
                        PaymentInfo result = plugins.Biz.EnterprisePay(para);

                        model.SerialNo   = result.TradNo;
                        model.DealTime   = DateTime.Now;
                        model.Status     = WithdrawStaus.Succeed;
                        model.PlatRemark = Remark;
                        _iBillingService.UpdateShopWithDraw(model);
                        //资金处理
                        UpdateAccount(model.ShopId, model.CashAmount, Himall.CommonModel.ShopAccountType.WithDraw, result.TradNo, "微信提现", Id);

                        //操作日志
                        OperationLogApplication.AddPlatformOperationLog(
                            new LogInfo
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("诊所微信提现审核成功,诊所Id={0},状态为:{1}, 说明是:{2}", model.ShopId,
                                                        status, Remark),
                            IPAddress = IpAddress,
                            PageUrl   = "/Admin/ShopWithDraw/Management",
                            UserName  = UserName,
                            ShopId    = 0
                        });

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("调用企业付款接口异常:" + ex.Message);
                        model.Status     = WithdrawStaus.Fail;
                        model.PlatRemark = Remark;
                        model.DealTime   = DateTime.Now;
                        _iBillingService.UpdateShopWithDraw(model);

                        //操作日志
                        OperationLogApplication.AddPlatformOperationLog(
                            new LogInfo
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("诊所微信提现审核失败,诊所Id={0},状态为:{1}, 说明是:{2}", model.ShopId,
                                                        status, Remark),
                            IPAddress = IpAddress,
                            PageUrl   = "/Admin/ShopWithDraw/Management",
                            UserName  = UserName,
                            ShopId    = 0
                        });
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }