Exemplo n.º 1
0
        private void process()
        {
            showMessage("开始下一批处理");
            var noPorcess = AutoPayService.QueryNoPorcess();
            //var str = Environment.CurrentDirectory;
            string msg = "";

            foreach (var item in noPorcess)
            {
                if (!_run)
                {
                    break;
                }
                AccountTradeDTO tradeView = null;
                //处理订单
                if (item.OrderType == OrderType.Order)
                {
                    OrderProcessService.Payable(item.OrderId, out msg);
                    if (string.IsNullOrEmpty(msg))
                    {
                        Order order = OrderQueryService.QueryOrder(item.OrderId);
                        tradeView = getPayTradeView(order, getPayAccountNo(item.PayType, order.Purchaser.Amount, order.Purchaser.CompanyId), "");
                    }
                }
                //处理申请单
                else if (item.OrderType == OrderType.Postpone)
                {
                    ApplyformProcessService.Payable(item.OrderId, out msg);
                    if (string.IsNullOrEmpty(msg))
                    {
                        PostponeApplyform applyform = ApplyformQueryService.QueryPostponeApplyform(item.OrderId);
                        if (applyform.PayBill.Tradement == null)
                        {
                            msg = "申请单:" + item.OrderId + " 不能进行代扣,无支付信息!";
                        }
                        tradeView = getPayTradeView(applyform, getPayAccountNo(item.PayType, Math.Abs(applyform.PayBill.Applier.Amount), applyform.PurchaserId), "");
                    }
                }
                if (item.PayType == WithholdingAccountType.Alipay)
                {
                    tradeView.BuyerEmail = item.PayAccountNo;
                }
                try
                {
                    if (string.IsNullOrEmpty(msg))
                    {
                        global::PoolPay.DomainModel.Trade.PayTrade pay = AutoPayService.AutoPay(tradeView, item.PayType);
                        if (item.PayType == WithholdingAccountType.Poolpay)
                        {
                            //如果是国付通代扣就直接修改订单状态
                            if (pay != null && pay.Status == global::PoolPay.DataTransferObject.PayStatus.PaySuccess)
                            {
                                NotifyService.PaySuccess(item.OrderId, pay.CustomParameter, pay.Id.ToString(), pay.FillChargeId.ToString(), pay.PayDate.Value, "", (pay.BuyerAccount.Character as global::PoolPay.DomainModel.Accounts.CreditAccount) == null ? "0" : "1", pay.BuyerAccount.AccountNo);
                            }
                        }
                        showMessage("处理成功");
                    }
                    else
                    {
                        showMessage("处理失败" + Environment.NewLine + "原因:" + msg);
                    }
                }
                catch (Exception ex)
                {
                    showMessage("处理失败" + Environment.NewLine + "原因:" + ex.Message);
                }
                AutoPayService.UpdateProcess(item.OrderId);
                System.Threading.Thread.Sleep(50);
            }
            showMessage("当前批次处理结束,共处理 " + noPorcess.Count + " 条");
        }
Exemplo n.º 2
0
        protected override string ExecuteCore()
        {
            var orderId   = Context.GetParameterValue("id");
            var payType   = Context.GetParameterValue("payType");
            var orderType = Context.GetParameterValue("businessType");

            if (string.IsNullOrWhiteSpace(orderId))
            {
                InterfaceInvokeException.ThrowParameterMissException("id");
            }
            if (string.IsNullOrWhiteSpace(payType) || (payType != "0" && payType != "1"))
            {
                InterfaceInvokeException.ThrowParameterMissException("payType");
            }
            if (string.IsNullOrWhiteSpace(orderType) || (orderType != "0" && orderType != "1"))
            {
                InterfaceInvokeException.ThrowParameterMissException("businessType");
            }
            decimal oid;
            string  msg = "";

            if (decimal.TryParse(orderId, out oid))
            {
                decimal amount = 0M;
                if (orderType == "0")
                {
                    OrderProcessService.Payable(oid, out msg);
                    if (!string.IsNullOrEmpty(msg))
                    {
                        InterfaceInvokeException.ThrowCustomMsgException(msg);
                    }
                    var orderInfo = OrderQueryService.QueryOrder(oid);
                    if (orderInfo.Purchaser.CompanyId != Company.CompanyId)
                    {
                        InterfaceInvokeException.ThrowCustomMsgException("暂无此订单");
                    }
                    amount = orderInfo.Purchaser.Amount;
                }
                else if (orderType == "1")
                {
                    ApplyformProcessService.Payable(oid, out msg);
                    if (!string.IsNullOrEmpty(msg))
                    {
                        InterfaceInvokeException.ThrowCustomMsgException(msg);
                    }
                    var orderInfo = ApplyformQueryService.QueryPostponeApplyform(oid);
                    if (orderInfo.Purchaser.CompanyId != Company.CompanyId)
                    {
                        InterfaceInvokeException.ThrowCustomMsgException("暂无此订单");
                    }
                    amount = orderInfo.PayBill.Applier.Amount;
                }
                if (AutoPayService.QueryAuto(oid) != null)
                {
                    InterfaceInvokeException.ThrowCustomMsgException("存在重复的代扣记录");
                }
                var auto = AccountService.GetWithholding((WithholdingAccountType)byte.Parse(payType), Employee.Owner);
                if (auto == null || auto.Status == WithholdingProtocolStatus.Submitted)
                {
                    InterfaceInvokeException.ThrowCustomMsgException("该账户还没有进行代扣设置,请先登录平台进行设置!");
                }
                if (payType == "0" && amount > auto.Amount)
                {
                    InterfaceInvokeException.ThrowCustomMsgException("订单[ " + orderId + " ] 需要支付的金额超过的代扣金额上限!");
                }
                AutoPayService.InsertAutoPay(new ChinaPay.B3B.Service.Order.Domain.AutoPay.AutoPay()
                {
                    PayAccountNo = auto.AccountNo, PayType = (WithholdingAccountType)byte.Parse(payType), OrderId = oid, OrderType = (OrderType)byte.Parse(orderType), ProcessState = false, Success = false, Time = DateTime.Now
                });
            }
            else
            {
                InterfaceInvokeException.ThrowParameterMissException("orderId");
            }
            return("");
        }