Example #1
0
        public JsonResult ConfirmApply(long id, ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark)
        {
            IMemberCapitalService memberCapitalService = this._iMemberCapitalService;

            ApplyWithDrawInfo.ApplyWithDrawStatus status = comfirmStatus;
            ApplyWithDrawInfo applyWithDrawInfo1         = memberCapitalService.GetApplyWithDrawInfo(id);

            if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse)
            {
                memberCapitalService.RefuseApplyWithDraw(id, status, this.CurrentManager.UserName, remark);
                this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                {
                    Date        = DateTime.Now,
                    Description = string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                    IPAddress   = this.Request.UserHostAddress,
                    PageUrl     = "/Admin/Capital/WithDraw",
                    UserName    = this.CurrentManager.UserName,
                    ShopId      = 0L
                });
                return(this.Json((object)new BaseController.Result()
                {
                    success = true,
                    msg = "审核成功!"
                }));
            }
            UserWithdrawType?applyType = applyWithDrawInfo1.ApplyType;

            if ((applyType.GetValueOrDefault() != UserWithdrawType.ALiPay ? 0 : (applyType.HasValue ? 1 : 0)) != 0)
            {
                if (applyWithDrawInfo1.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending)
                {
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = false,
                        msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!"
                    }));
                }
                Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId == "Himall.Plugin.Payment.Alipay"));
                if (plugin != null)
                {
                    try
                    {
                        string            format = CurrentUrlHelper.CurrentUrlNoPort() + "/Pay/EnterpriseNotify/{0}?outid={1}";
                        EnterprisePayPara para   = new EnterprisePayPara()
                        {
                            amount       = applyWithDrawInfo1.ApplyAmount,
                            check_name   = false,
                            openid       = applyWithDrawInfo1.OpenId,
                            re_user_name = applyWithDrawInfo1.NickName,
                            out_trade_no = applyWithDrawInfo1.Id.ToString(),
                            desc         = "提现",
                            notify_url   = string.Format(format, (object)this.EncodePaymentId(plugin.PluginInfo.PluginId), (object)applyWithDrawInfo1.Id.ToString())
                        };
                        PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(para);
                        ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo();
                        applyWithDrawInfo2.PayNo       = paymentInfo.TradNo;
                        applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending;
                        ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2;
                        DateTime?         tradeTime          = paymentInfo.TradeTime;
                        DateTime          now;
                        if (!tradeTime.HasValue)
                        {
                            now = DateTime.Now;
                        }
                        else
                        {
                            tradeTime = paymentInfo.TradeTime;
                            now       = tradeTime.Value;
                        }
                        DateTime?nullable = new DateTime?(now);
                        applyWithDrawInfo3.PayTime     = nullable;
                        applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now);
                        applyWithDrawInfo2.OpUser      = this.CurrentManager.UserName;
                        applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount;
                        applyWithDrawInfo2.Id          = applyWithDrawInfo1.Id;
                        ApplyWithDrawInfo info = applyWithDrawInfo2;
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = true,
                            msg = "审核操作成功",
                            status = 2,
                            Data = (object)paymentInfo.ResponseContentWhenFinished
                        }));
                    }
                    catch (PluginException ex)
                    {
                        Log.Error((object)("调用企业付款接口异常:" + ex.Message));
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = ex.Message
                        }));
                    }
                    catch (Exception ex)
                    {
                        Log.Error((object)("提现审核异常:" + ex.Message));
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = "付款接口异常"
                        }));
                    }
                }
                else
                {
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = false,
                        msg = "未找到支付插件"
                    }));
                }
            }
            else
            {
                Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(Enumerable.Where <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId.ToLower().Contains("weixin"))));
                if (plugin != null)
                {
                    try
                    {
                        EnterprisePayPara para = new EnterprisePayPara()
                        {
                            amount       = applyWithDrawInfo1.ApplyAmount,
                            check_name   = false,
                            openid       = applyWithDrawInfo1.OpenId,
                            out_trade_no = applyWithDrawInfo1.Id.ToString(),
                            desc         = "提现"
                        };
                        PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(para);
                        ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo();
                        applyWithDrawInfo2.PayNo       = paymentInfo.TradNo;
                        applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess;
                        applyWithDrawInfo2.Remark      = plugin.PluginInfo.Description;
                        ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2;
                        DateTime?         tradeTime          = paymentInfo.TradeTime;
                        DateTime          now;
                        if (!tradeTime.HasValue)
                        {
                            now = DateTime.Now;
                        }
                        else
                        {
                            tradeTime = paymentInfo.TradeTime;
                            now       = tradeTime.Value;
                        }
                        DateTime?nullable = new DateTime?(now);
                        applyWithDrawInfo3.PayTime     = nullable;
                        applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now);
                        applyWithDrawInfo2.OpUser      = this.CurrentManager.UserName;
                        applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount;
                        applyWithDrawInfo2.Id          = applyWithDrawInfo1.Id;
                        ApplyWithDrawInfo info = applyWithDrawInfo2;
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                    }
                    catch (PluginException ex)
                    {
                        Log.Error((object)("调用企业付款接口异常:" + ex.Message));
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = ex.Message
                        }));
                    }
                    catch (Exception ex)
                    {
                        Log.Error((object)("提现审核异常:" + ex.Message));
                        ApplyWithDrawInfo info = new ApplyWithDrawInfo()
                        {
                            ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                            Remark      = plugin.PluginInfo.Description,
                            ConfirmTime = new DateTime?(DateTime.Now),
                            OpUser      = this.CurrentManager.UserName,
                            ApplyAmount = applyWithDrawInfo1.ApplyAmount,
                            Id          = applyWithDrawInfo1.Id
                        };
                        memberCapitalService.ConfirmApplyWithDraw(info);
                        this._iOperationLogService.AddPlatformOperationLog(new LogInfo()
                        {
                            Date        = DateTime.Now,
                            Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark),
                            IPAddress   = this.Request.UserHostAddress,
                            PageUrl     = "/Admin/Capital/WithDraw",
                            UserName    = this.CurrentManager.UserName,
                            ShopId      = 0L
                        });
                        return(this.Json((object)new BaseController.Result()
                        {
                            success = false,
                            msg = "付款接口异常"
                        }));
                    }
                    return(this.Json((object)new BaseController.Result()
                    {
                        success = true,
                        msg = "审核操作成功"
                    }));
                }
                return(this.Json((object)new BaseController.Result()
                {
                    success = false,
                    msg = "未找到支付插件"
                }));
            }
        }
Example #2
0
        public JsonResult ConfirmPay(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string remark)
        {
            JsonResult            jsonResult;
            IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>();

            if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse)
            {
                memberCapitalService.RefuseApplyWithDraw(id, status, base.CurrentManager.UserName, remark);
                return(Json(new { success = true, msg = "审核成功!" }));
            }
            ApplyWithDrawQuery applyWithDrawQuery = new ApplyWithDrawQuery()
            {
                withDrawNo = new long?(id),
                PageNo     = 1,
                PageSize   = 1
            };
            ApplyWithDrawQuery      applyWithDrawQuery1 = applyWithDrawQuery;
            ApplyWithDrawInfo       applyWithDrawInfo   = memberCapitalService.GetApplyWithDraw(applyWithDrawQuery1).Models.FirstOrDefault();
            Plugin <IPaymentPlugin> plugin = (
                from e in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                where e.PluginInfo.PluginId.ToLower().Contains("weixin")
                select e).FirstOrDefault <Plugin <IPaymentPlugin> >();

            if (plugin == null)
            {
                return(Json(new { success = false, msg = "未找到支付插件" }));
            }
            try
            {
                EnterprisePayPara enterprisePayPara = new EnterprisePayPara()
                {
                    amount       = applyWithDrawInfo.ApplyAmount,
                    check_name   = false,
                    openid       = applyWithDrawInfo.OpenId,
                    out_trade_no = applyWithDrawInfo.Id.ToString(),
                    desc         = "提现"
                };
                PaymentInfo       paymentInfo        = plugin.Biz.EnterprisePay(enterprisePayPara);
                ApplyWithDrawInfo applyWithDrawInfo1 = new ApplyWithDrawInfo()
                {
                    PayNo       = paymentInfo.TradNo,
                    ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess,
                    Remark      = plugin.PluginInfo.Description,
                    PayTime     = new DateTime?((paymentInfo.TradeTime.HasValue ? paymentInfo.TradeTime.Value : DateTime.Now)),
                    ConfirmTime = new DateTime?(DateTime.Now),
                    OpUser      = base.CurrentManager.UserName,
                    ApplyAmount = applyWithDrawInfo.ApplyAmount,
                    Id          = applyWithDrawInfo.Id
                };
                memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo1);
                return(Json(new { success = true, msg = "付款成功" }));
            }
            catch (Exception exception)
            {
                Log.Error(string.Concat("调用企业付款接口异常:", exception.Message));
                ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo()
                {
                    ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                    Remark      = plugin.PluginInfo.Description,
                    ConfirmTime = new DateTime?(DateTime.Now),
                    OpUser      = base.CurrentManager.UserName,
                    ApplyAmount = applyWithDrawInfo.ApplyAmount,
                    Id          = applyWithDrawInfo.Id
                };
                memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo2);
                jsonResult = Json(new { success = false, msg = "付款接口异常" });
            }
            return(jsonResult);
        }
 /// <summary>
 /// 拒绝会员提现申请
 /// </summary>
 /// <param name="id"></param>
 /// <param name="status"></param>
 /// <param name="opuser"></param>
 /// <param name="remark"></param>
 public static void RefuseApplyWithDraw(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string opuser, string remark)
 {
     _iMemberCapitalService.RefuseApplyWithDraw(id, status, opuser, remark);
 }
Example #4
0
        public JsonResult BatchConfirmApply(string ids, Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark)
        {
            if (string.IsNullOrWhiteSpace(ids))
            {
                return(ErrorResult("审核的ID,不能为空"));
            }
            var idArray = ids.Split(',').Select(e =>
            {
                long id = 0;
                long.TryParse(e, out id);
                return(id);
            }).Where(e => e > 0);

            var status      = comfirmStatus;
            var models      = _iMemberCapitalService.GetApplyWithDrawInfoByIds(idArray);
            var isHaveError = false;

            foreach (var model in models)
            {
                if (status == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse)
                {
                    _iMemberCapitalService.RefuseApplyWithDraw(model.Id, status, CurrentManager.UserName, remark);
                    //操作日志
                    WithDrawOperateLog(string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark));
                    //return Json(new Result { success = true, msg = "审核成功!" });
                }
                else
                {
                    if (model.ApplyStatus == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending)
                    {
                        return(Json(new Result {
                            success = false, msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!"
                        }));
                    }
                    Plugin <IPaymentPlugin> plugins = null;
                    bool isCheckName = false;
                    if (model.ApplyType == CommonModel.UserWithdrawType.ALiPay)
                    {
                        isCheckName = true;
                        plugins     = PluginsManagement.GetPlugins <IPaymentPlugin>(true).FirstOrDefault(e => e.PluginInfo.PluginId == PLUGIN_PAYMENT_ALIPAY);
                    }
                    else
                    {
                        plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault();
                    }
                    if (plugins != null)
                    {
                        try
                        {
                            var tradeno            = model.ApplyTime.ToString("yyyyMMddHHmmss") + model.Id.ToString();
                            EnterprisePayPara para = new EnterprisePayPara()
                            {
                                amount       = model.ApplyAmount,
                                check_name   = isCheckName,
                                openid       = model.OpenId,
                                re_user_name = model.NickName,
                                out_trade_no = tradeno,
                                desc         = "提现"
                            };
                            //调用转账接口
                            PaymentInfo result = plugins.Biz.EnterprisePay(para);
                            //更新提现状态
                            Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo
                            {
                                PayNo       = result.TradNo,
                                ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess,
                                Remark      = remark,
                                PayTime     = result.TradeTime.HasValue ? result.TradeTime.Value : DateTime.Now,
                                ConfirmTime = DateTime.Now,
                                OpUser      = CurrentManager.UserName,
                                ApplyAmount = model.ApplyAmount,
                                Id          = model.Id
                            };
                            _iMemberCapitalService.ConfirmApplyWithDraw(info);
                            //操作日志
                            WithDrawOperateLog(string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark));
                        }
                        catch (PluginException pex)
                        {//转账失败(业务级别),直接返回错误信息
                            Log.Error("调用企业付款接口异常:" + pex.Message);
                            isHaveError = true;
                            //更新提现状态
                            Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo
                            {
                                ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                                Remark      = pex.Message,
                                ConfirmTime = DateTime.Now,
                                OpUser      = CurrentManager.UserName,
                                ApplyAmount = model.ApplyAmount,
                                Id          = model.Id
                            };
                            _iMemberCapitalService.ConfirmApplyWithDraw(info);
                            //操作日志
                            WithDrawOperateLog(string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark));
                            //return Json(new Result { success = false, msg = pex.Message });
                        }
                        catch (Exception ex)
                        {//转账失败(系统级别),直接返回错误信息
                            Log.Error("提现审核异常:" + ex.Message);
                            isHaveError = true;
                            //更新提现状态
                            Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo
                            {
                                ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail,
                                Remark      = "审核操作异常,请检查一下支付配置",
                                ConfirmTime = DateTime.Now,
                                OpUser      = CurrentManager.UserName,
                                ApplyAmount = model.ApplyAmount,
                                Id          = model.Id
                            };
                            _iMemberCapitalService.ConfirmApplyWithDraw(info);
                            //操作日志
                            WithDrawOperateLog(string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark));
                            //return Json(new Result { success = false, msg = "付款接口异常" });
                        }
                    }
                    else
                    {
                        return(Json(new Result {
                            success = false, msg = "未找到支付插件"
                        }));
                    }
                }
            }
            if (isHaveError)
            {
                return(Json(new Result {
                    success = true, msg = "审核操作完成,但部分提现失败,请检查!"
                }));
            }
            else
            {
                return(Json(new Result {
                    success = true, msg = "审核操作完成!"
                }));
            }
        }