示例#1
0
        /// <summary>
        /// 平安订单解止付(查询平安订单状态并判断--解止付)
        /// </summary>
        /// <param name="orderPaid"></param>
        private void PingAnUnFreeze(OrderPaid orderPaid)
        {
            var iPingAnAPIService               = DIFactory.GetContainer().Resolve <IPingAnAPIService>();
            var iOrderPaidService               = DIFactory.GetContainer().Resolve <IOrderPaidService>();
            var iPingAnOrderPaidService         = DIFactory.GetContainer().Resolve <IPingAnOrderPaidService>();
            var iPingAnOrderPaidUnFreezeService = DIFactory.GetContainer().Resolve <IPingAnOrderPaidUnFreezeService>();

            PingAnOrderPaidUnFreeze pingAnOrderPaidUnFreeze = new PingAnOrderPaidUnFreeze();

            pingAnOrderPaidUnFreeze.OrderPaid = orderPaid;
            pingAnOrderPaidUnFreeze.Amount    = orderPaid.TransactionAmount;

            iPingAnOrderPaidUnFreezeService.Save(pingAnOrderPaidUnFreeze);
            iPingAnOrderPaidUnFreezeService.Commit();

            var orderDetailResponse = QueryPingAnMarginsOrderDetail(orderPaid.PingAnOrderPaid.BankOrderNo);

            if (orderDetailResponse.IsOK)
            {
                if (orderDetailResponse.dataObject.marginsOrderInfoList != null)
                {
                    if (orderDetailResponse.dataObject.marginsOrderInfoList.FirstOrDefault().transStatus == PingAnOrderPaidStatusOption.FrozenSuccess.ToInt().ToString())
                    {
                        var response = iPingAnAPIService.UnFreezeMarginsOrder(orderPaid);

                        pingAnOrderPaidUnFreeze.ResponseCode    = response.responseCode;
                        pingAnOrderPaidUnFreeze.ResponseMessage = response.responseMsg;

                        if (response.IsOK)
                        {
                            PingAnUnFreezeSuccess(pingAnOrderPaidUnFreeze);

                            Commit();
                        }
                        else
                        {
                            pingAnOrderPaidUnFreeze.Status = PingAnOrderPaidUnFreezeStatusOption.Fail.ToInt();
                            iPingAnOrderPaidUnFreezeService.Save(pingAnOrderPaidUnFreeze);

                            Commit();

                            throw new APIException("解止付失败:" + response.responseMsg);
                        }
                    }
                    else
                    {
                        throw new APIException("订单状态" + ((PingAnOrderPaidStatusOption)Convert.ToInt32(orderDetailResponse.dataObject.marginsOrderInfoList.FirstOrDefault().transStatus)).ToDescription() + "不可操作");
                    }
                }
            }
            else
            {
                throw new APIException("查询失败:" + orderDetailResponse.responseMsg);
            }
        }
示例#2
0
        private void PingAnUnFreezeSuccess(PingAnOrderPaidUnFreeze pingAnOrderPaidUnFreeze)
        {
            var iMemberService = DIFactory.GetContainer().Resolve <IMemberService>();
            var iPingAnOrderPaidUnFreezeService = DIFactory.GetContainer().Resolve <IPingAnOrderPaidUnFreezeService>();
            var iPingAnOrderPaidService         = DIFactory.GetContainer().Resolve <IPingAnOrderPaidService>();

            pingAnOrderPaidUnFreeze.OrderPaid.Status = OrderPaidStatusOption.UnFrozenSuccess.ToInt();  //更新订单主表状态
            Save(pingAnOrderPaidUnFreeze.OrderPaid);

            pingAnOrderPaidUnFreeze.OrderPaid.PingAnOrderPaid.Status = PingAnOrderPaidStatusOption.UnFrozenSuccess.ToInt();  //更新平安订单子表状态
            iPingAnOrderPaidService.Save(pingAnOrderPaidUnFreeze.OrderPaid.PingAnOrderPaid);

            pingAnOrderPaidUnFreeze.Status    = PingAnOrderPaidUnFreezeStatusOption.Success.ToInt(); //更新解止付订单状态
            pingAnOrderPaidUnFreeze.TransTime = DateTime.Now;
            iPingAnOrderPaidUnFreezeService.Save(pingAnOrderPaidUnFreeze);

            iMemberService.BalanceChange(pingAnOrderPaidUnFreeze.OrderPaid.Member, pingAnOrderPaidUnFreeze.Amount, MemberBalanceHistoryTypeOption.UnFreeze, (AccountBankOption)pingAnOrderPaidUnFreeze.OrderPaid.Merchant.AccountBank, pingAnOrderPaidUnFreeze.Amount * -1, remark: pingAnOrderPaidUnFreeze.SerialNumber);
        }