Ejemplo n.º 1
0
        public static RMARefundInfo Reject(int rmaRefundSysNo, LoginUser operateUser)
        {
            RMARefundInfo info = LoadWithRefundSysNo(rmaRefundSysNo, operateUser.SellerSysNo);

            if (info == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退款单", rmaRefundSysNo));
            }
            if (info.Status != RMARefundStatus.WaitingAudit)
            {
                throw new BusinessException(L("退款单不是“待审核”,不能审核拒绝"));
            }

            info.Status         = RMARefundStatus.Abandon;
            info.SOIncomeStatus = SOIncomeStatus.Abandon;
            using (ITransaction ts = TransactionManager.Create())
            {
                RMARefundDA.Update(info);
                RMARefundDA.BatchUpdateRegisterRefundStatusAndStatus(info.SysNo.Value, RMARefundStatus.Abandon, RMARequestStatus.Complete);

                var rmaRequstSysNoList = RMARefundDA.QueryRMARequsetSysNoByRefundSysNo(info.SysNo.Value);
                if (rmaRequstSysNoList != null && rmaRequstSysNoList.Count > 0)
                {
                    foreach (var rmaRequestSysNo in rmaRequstSysNoList)
                    {
                        RMARequestService.RefreshRequestStatus(rmaRequestSysNo, operateUser.SellerSysNo);
                    }
                }

                ts.Complete();
            }

            return(info);
        }
Ejemplo n.º 2
0
        public static RMARefundInfo Create(RMARefundInfo refundInfo)
        {
            DataCommand command = DataCommandManager.GetDataCommand("CreateRMARefund");

            command.SetParameterValue("@SysNo", refundInfo.SysNo);
            command.SetParameterValue("@RefundID", refundInfo.RefundID);
            command.SetParameterValue("@SOSysNo", refundInfo.SOSysNo);
            command.SetParameterValue("@CustomerSysNo", refundInfo.CustomerSysNo);
            command.SetParameterValue("@CreateTime", refundInfo.InDate);
            command.SetParameterValue("@CreateUserSysNo", refundInfo.InUserSysNo);
            command.SetParameterValue("@CreateUserName", refundInfo.InUserName);
            command.SetParameterValue("@OrgCashAmt", refundInfo.OrgCashAmt);
            command.SetParameterValue("@CashAmt", refundInfo.CashAmt);
            command.SetParameterValue("@OrgPointAmt", refundInfo.OrgPointAmt);
            command.SetParameterValue("@PointAmt", refundInfo.PointPay);
            command.SetParameterValue("@OrgGiftCardAmt", refundInfo.OrgGiftCardAmt);
            command.SetParameterValue("@GiftCardAmt", refundInfo.GiftCardAmt);
            command.SetParameterValue("@RefundPayType", refundInfo.RefundPayType);
            command.SetParameterValue("@Status", refundInfo.Status);
            command.SetParameterValue("@CashFlag", refundInfo.CashAmt > 0 ? 0 : 1);
            command.SetParameterValue("@CompanyCode", refundInfo.CompanyCode);
            command.SetParameterValue("@LanguageCode", refundInfo.LanguageCode);
            command.SetParameterValue("@StoreCompanyCode", refundInfo.CompanyCode);
            command.ExecuteNonQuery();

            return(refundInfo);
        }
Ejemplo n.º 3
0
        public ActionResult AjaxRefundRequest()
        {
            var sysnoData = Request["SysNo"];
            int sysno;

            if (!int.TryParse(sysnoData, out sysno) || sysno <= 0)
            {
                throw new BusinessException(L("退换货申请单编号不正确"));
            }
            var           refundData = Request["RefundInfo"];
            RMARefundInfo refundInfo = SerializationUtility.JsonDeserialize <RMARefundInfo>(refundData);

            if (string.IsNullOrWhiteSpace(refundData) || refundInfo == null)
            {
                throw new BusinessException(L("退款信息为空"));
            }
            //退款方式为“网关直接退款”
            refundInfo.RefundPayType = RefundPayType.NetWorkRefund;

            LoginUser user = EntityConverter <UserAuthVM, LoginUser> .Convert(UserAuthHelper.GetCurrentUser());

            RMARequestInfo data = RMARequestService.Refund(sysno, refundInfo, user);

            return(Json(data));
        }
Ejemplo n.º 4
0
 public static RMARefundInfo LoadWithRefundSysNo(int rmaRefundSysNo, int sellerSysNo)
 {
     if (rmaRefundSysNo > 0)
     {
         RMARefundInfo info = RMARefundDA.LoadWithRefundSysNo(rmaRefundSysNo, sellerSysNo);
         return(info);
     }
     return(null);
 }
Ejemplo n.º 5
0
        public static void ConfirmRefundSOIncome(RMARefundInfo info)
        {
            DataCommand command = DataCommandManager.GetDataCommand("ConfirmRefundSOIncome");

            command.SetParameterValue("@OrderSysNo", info.SysNo);
            command.SetParameterValue("@OrderType", info.OrderType);
            command.SetParameterValue("@Status", info.Status);
            command.SetParameterValue("@ConfirmUserSysNo", info.RefundUserSysNo);
            command.SetParameterValue("@ConfirmUserName", info.RefundUserName);
            command.SetParameterValue("@ConfirmTime", info.RefundDate);
            command.ExecuteNonQuery();
        }
Ejemplo n.º 6
0
        public static void Update(RMARefundInfo info)
        {
            DataCommand command = DataCommandManager.GetDataCommand("UpdateRMARefund");

            command.SetParameterValue("@SysNo", info.SysNo.Value);
            command.SetParameterValue("@Status", info.Status);
            command.SetParameterValue("@AuditUserSysNo", info.AuditUserSysNo);
            command.SetParameterValue("@AuditUserName", info.AuditUserName);
            command.SetParameterValue("@AuditTime", info.AuditDate);
            command.SetParameterValue("@RefundUserSysNo", info.RefundUserSysNo);
            command.SetParameterValue("@RefundUserName", info.RefundUserName);
            command.SetParameterValue("@RefundTime", info.RefundDate);
            command.SetParameterValue("@FinanceStatus", info.SOIncomeStatus);
            command.ExecuteNonQuery();
        }
Ejemplo n.º 7
0
        public static RMARefundInfo LoadWithRefundSysNo(int rmaRefundSysNo, int sellerSysNo)
        {
            DataCommand command = DataCommandManager.GetDataCommand("LoadRMARefundWithRefundSysNo");

            command.SetParameterValue("@SysNo", rmaRefundSysNo);
            command.SetParameterValue("@SellerSysNo", sellerSysNo);
            RMARefundInfo refundInfo = command.ExecuteEntity <RMARefundInfo>();

            if (refundInfo != null)
            {
                refundInfo.RefundItems = LoadItemWithRefundSysNo(rmaRefundSysNo);
            }

            return(refundInfo);
        }
Ejemplo n.º 8
0
 private static void RefundPrepay(RMARefundInfo refundInfo)
 {
     if (refundInfo.RefundPayType == RefundPayType.PrepayRefund)
     {
         CustomerPrepayLog prepayLogInfo = new CustomerPrepayLog()
         {
             SOSysNo       = refundInfo.SOSysNo.Value,
             CustomerSysNo = refundInfo.CustomerSysNo.Value,
             AdjustAmount  = refundInfo.CashAmt ?? 0M,
             PrepayType    = PrepayType.ROReturn,
             Note          = "RMA退款单退入余额账户"
         };
         CustomerService.AdjustPrePay(prepayLogInfo);
     }
 }
Ejemplo n.º 9
0
        public static RMARefundInfo Valid(int rmaRefundSysNo, LoginUser operateUser)
        {
            RMARefundInfo info = LoadWithRefundSysNo(rmaRefundSysNo, operateUser.SellerSysNo);

            if (info == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退款单", rmaRefundSysNo));
            }
            if (info.Status != RMARefundStatus.WaitingAudit)
            {
                throw new BusinessException(L("退款单不是“待审核”,不能审核通过"));
            }

            //info.Status = RMARefundStatus.WaitingRefund;
            info.Status         = RMARefundStatus.Refunded;
            info.SOIncomeStatus = SOIncomeStatus.Origin;
            info.AuditUserSysNo = operateUser.UserSysNo;
            info.AuditUserName  = operateUser.UserDisplayName;
            info.AuditDate      = DateTime.Now;

            using (ITransaction ts = TransactionManager.Create())
            {
                RMARefundDA.Update(info);
                //更新BankInfoStatus的为审核通过
                RMARefundDA.AuditSOIncomeRefund(info.SysNo.Value, (int)info.OrderType, (int)RefundStatus.Refunded, operateUser.UserSysNo, operateUser.UserDisplayName);
                RMARefundDA.BatchUpdateRegisterRefundStatus(info.SysNo.Value, RMARefundStatus.WaitingRefund);
                //写入退款单
                SOIncomeInfo soIncomeInfo = new SOIncomeInfo()
                {
                    OrderType      = SOIncomeOrderType.RO,
                    OrderSysNo     = info.SysNo,
                    OrderAmt       = -1 * info.CashAmt,
                    IncomeStyle    = SOIncomeOrderStyle.RO,
                    IncomeAmt      = -1 * info.CashAmt,
                    PayAmount      = -1 * info.CashAmt,
                    InUserSysNo    = operateUser.UserSysNo,
                    InUserName     = operateUser.UserDisplayName,
                    Status         = SOIncomeStatus.Origin,
                    PointPay       = info.PointPay,
                    GiftCardPayAmt = info.GiftCardAmt,
                };
                RMARefundDA.CreateRefundSOIncome(soIncomeInfo);

                ts.Complete();
            }

            return(info);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="rmaRequestSysNo">退换货申请单编号</param>
        /// <param name="refundInfo">退款信息</param>
        /// <param name="userSysNo">操作人用户</param>
        /// <returns></returns>
        public static RMARequestInfo Refund(int rmaRequestSysNo, RMARefundInfo refundInfo, LoginUser operateUser)
        {
            RMARequestInfo requestInfo = LoadWithRequestSysNo(rmaRequestSysNo, operateUser.SellerSysNo);

            if (requestInfo == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退换货申请单", rmaRequestSysNo));
            }
            if (requestInfo.Status != RMARequestStatus.Handling)
            {
                throw new BusinessException(L("不是“处理中”的申请单不能退款"));
            }
            if (refundInfo == null || !refundInfo.RefundPayType.HasValue)
            {
                throw new ArgumentException(L("退款信息为空"));
            }

            requestInfo.Registers = requestInfo.Registers.Where(g => g.RequestType == RMARequestType.Return &&
                                                                g.Status == RMARequestStatus.Handling).ToList();
            if (requestInfo.Registers.Count <= 0)
            {
                throw new ArgumentException(L("没有“待处理”的退货商品"));
            }

            refundInfo.SOSysNo       = requestInfo.SOSysNo;
            refundInfo.CustomerSysNo = requestInfo.CustomerSysNo;
            //计算退款金额
            CalcRefundAmount(refundInfo, requestInfo);

            using (ITransaction trans = TransactionManager.Create())
            {
                //创建退款单
                RMARefundService.Create(refundInfo, operateUser);
                //设置单件的退款状态为退款中
                foreach (var registerInfo in requestInfo.Registers)
                {
                    registerInfo.RefundStatus = RMARefundStatus.WaitingAudit;
                    RMARequestDA.UpdateRegisterStatus(registerInfo);
                }

                trans.Complete();
            }

            return(requestInfo);
        }
Ejemplo n.º 11
0
        private static void ReturnProductPoint(RMARefundInfo refundInfo, int userSysNo)
        {
            int affectedPoint1 = -1 * (refundInfo.DeductPointFromAccount ?? 0) + (refundInfo.PointPay ?? 0);

            if (affectedPoint1 != 0)
            {
                AdjustPointRequest itemPointInfo = new AdjustPointRequest()
                {
                    Source        = "RMA",
                    CustomerSysNo = refundInfo.CustomerSysNo.Value,
                    Point         = affectedPoint1,
                    PointType     = (int)AdjustPointType.ReturnProductPoint,
                    Memo          = refundInfo.SysNo.ToString(),
                    OperationType = AdjustPointOperationType.Abandon,
                    SOSysNo       = refundInfo.SOSysNo
                };

                CustomerService.AdjustPoint(itemPointInfo, userSysNo);//item积分撤消
            }
        }
Ejemplo n.º 12
0
        public void InsertSOIncomeVoucherList(Hashtable ht)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                foreach (SOIncomeVoucherInfo oParam in ht.Keys)
                {
                    SOIncomeVoucherInfo newInfo = LoadSOIncomeVoucher(oParam);
                    if (newInfo == null)
                    {
                        InsertSOIncomeVoucher(oParam);
                    }
                    else
                    {
                        newInfo.VoucherID   = oParam.VoucherID;
                        newInfo.VoucherTime = oParam.VoucherTime;
                        UpdateSOIncomeVoucher(newInfo);
                    }

                    SOIncomeInfo oInfo = SOIncomeManager.GetInstance().Load(oParam.FSISysNo);
                    if (oInfo.OrderType == (int)AppEnum.SOIncomeOrderType.RO)
                    {
                        RMARefundInfo oRefundInfo = RMARefundManager.GetInstance().LoadRMARefund(oInfo.OrderSysNo);
                        if (oRefundInfo != null)
                        {
                            Hashtable rmaht = new Hashtable();
                            rmaht.Add("SysNo", oRefundInfo.SysNo);
                            rmaht.Add("VoucherID", oParam.VoucherID);
                            rmaht.Add("VoucherTime", oParam.VoucherTime);
                            RMARefundManager.GetInstance().UpdateMasterMemo(rmaht);
                        }
                    }
                }
                scope.Complete();
            }
        }
Ejemplo n.º 13
0
        private static void CalcRefundAmount(RMARefundInfo refundInfo, RMARequestInfo request)
        {
            refundInfo.RefundItems = new List <RMARefundItemInfo>();
            SOInfo soInfo = SOService.GetSOInfo(request.SOSysNo.Value);

            //计算积分支付比例
            decimal originalSOCashPointRate = soInfo.PointAmt / (
                soInfo.Amount.SOAmt
                + soInfo.Amount.ShipPrice
                - Math.Abs(soInfo.PromotionAmt)
                - Math.Abs(soInfo.Amount.DiscountAmt));

            refundInfo.SOCashPointRate = Decimal.Round(originalSOCashPointRate, 4);

            List <SOItemInfo> soItems = SOService.GetSOItemInfoList(request.SOSysNo.Value);
            //计算总计应退金额,包括应退现金+积分+余额
            decimal totalRefundProductValue = Decimal.Round(request.Registers.Sum(registerInfo =>
            {
                var soItem = soItems.Find(x => x.ProductSysNo == registerInfo.ProductSysNo.Value &&
                                          x.ProductType == registerInfo.SoItemType.Value);
                return(soItem.OriginalPrice - Math.Abs(soItem.PromotionDiscount) - Math.Abs(soItem.DiscountAmt / soItem.Quantity));
            }), 2);

            decimal assignedRefundCashAmt = 0m;

            refundInfo.OrgCashAmt = 0m; refundInfo.OrgPointAmt = 0; refundInfo.PointPay = 0;

            for (var index = 0; index < request.Registers.Count; index++)
            {
                RMARegisterInfo   registerInfo = request.Registers[index];
                RMARefundItemInfo refundItem   = new RMARefundItemInfo();
                var soItem = soItems.Find(x => x.ProductSysNo == registerInfo.ProductSysNo.Value &&
                                          x.ProductType == registerInfo.SoItemType.Value);

                refundItem.OrgPrice             = soItem.OriginalPrice;
                refundItem.OrgPoint             = soItem.Point;
                refundItem.PointType            = soItem.PointType;
                refundItem.UnitDiscount         = soItem.DiscountAmt / soItem.Quantity;
                refundItem.ProductValue         = (soItem.OriginalPrice - Math.Abs(soItem.PromotionDiscount)) - Math.Abs(refundItem.UnitDiscount.Value);
                refundItem.RefundCost           = soItem.Cost;
                refundItem.RefundCostWithoutTax = soItem.UnitCostWithoutTax;
                refundItem.RefundPoint          = soItem.Point;
                refundItem.RegisterSysNo        = registerInfo.SysNo;

                if (totalRefundProductValue <= 0m)
                {
                    refundItem.RefundCash = 0m;
                }
                else
                {
                    //按商品价值比例计算单个商品退款金额
                    if (index < request.Registers.Count - 1)
                    {
                        refundItem.RefundCash =
                            ((refundItem.ProductValue / totalRefundProductValue) * refundInfo.CashAmt * (1 - originalSOCashPointRate)).Value;
                    }
                    else
                    {
                        refundItem.RefundCash = refundInfo.CashAmt.Value - assignedRefundCashAmt;
                    }
                }
                refundItem.RefundPrice     = refundItem.RefundCash;
                refundItem.RefundPoint     = Convert.ToInt32(Decimal.Round((refundItem.RefundCash * originalSOCashPointRate).Value, 0));
                refundItem.RefundPriceType = RefundPriceType.OriginPrice;

                refundInfo.OrgCashAmt  += refundItem.RefundCash.Value;
                refundInfo.OrgPointAmt += (-1) * refundItem.RefundPoint.Value;
                refundInfo.PointPay    += refundInfo.OrgPointAmt;

                assignedRefundCashAmt += refundItem.RefundCash.Value;
                refundInfo.RefundItems.Add(refundItem);
            }

            #region 计算顾客积分归还积分折合现金

            refundInfo.DeductPointFromAccount     = 0;
            refundInfo.DeductPointFromCurrentCash = 0m;
            if (refundInfo.OrgPointAmt < 0)
            {
                CustomerBasicInfo customer = CustomerService.GetCustomerInfo(refundInfo.CustomerSysNo.Value);
                if (refundInfo.OrgPointAmt * -1 < customer.ValidScore)
                {
                    refundInfo.DeductPointFromAccount = refundInfo.OrgPointAmt * -1;
                }
                else
                {
                    refundInfo.DeductPointFromAccount     = customer.ValidScore;
                    refundInfo.DeductPointFromCurrentCash =
                        Decimal.Round(((refundInfo.OrgPointAmt ?? 0) * -1
                                       - (customer.ValidScore ?? 0)) / CustomerService.GetPointToMoneyRatio(), 2);
                }
            }
            #endregion
        }
Ejemplo n.º 14
0
        public static RMARefundInfo Create(RMARefundInfo refundInfo, LoginUser operateUser)
        {
            if (!refundInfo.SOSysNo.HasValue)
            {
                throw new BusinessException(L("订单号不能为空"));
            }

            if (refundInfo.RefundPayType == RefundPayType.BankRefund)
            {
                if (string.IsNullOrWhiteSpace(refundInfo.CardOwnerName))
                {
                    throw new BusinessException(L("收款人不能为空"));
                }
                if (string.IsNullOrWhiteSpace(refundInfo.BankName))
                {
                    throw new BusinessException(L("银行名称不能为空"));
                }
                if (string.IsNullOrWhiteSpace(refundInfo.CardNumber))
                {
                    throw new BusinessException(L("银行卡号不能为空"));
                }
                if (!refundInfo.CashAmt.HasValue || refundInfo.CashAmt.Value < 0m)
                {
                    throw new BusinessException(L("退款金额不能小于0"));
                }
                var maxRefundAmt = Decimal.Round(refundInfo.RefundItems.Sum(x => x.ProductValue.Value), 2, MidpointRounding.AwayFromZero);
                if (refundInfo.CashAmt > maxRefundAmt)
                {
                    throw new BusinessException(L("实际退款金额不能大于应退金额:{0}", maxRefundAmt));
                }
            }

            #region 检查订单最大可退金额
            //数据check不包含在事务中
            using (ITransaction trans = TransactionManager.SuppressTransaction())
            {
                var     soItemList      = SOService.GetSOItemInfoList(refundInfo.SOSysNo.Value);
                decimal maxRMARefundAmt = soItemList.Sum(soItem =>
                {
                    return((soItem.OriginalPrice - Math.Abs(soItem.PromotionDiscount)
                            - Math.Abs(soItem.DiscountAmt / soItem.Quantity)) * soItem.Quantity);
                });

                decimal thisRefundAmt = Math.Abs(refundInfo.CashAmt.GetValueOrDefault()) + Math.Abs(refundInfo.PointPay.GetValueOrDefault() * pointExchangeRate)
                                        + Math.Abs(refundInfo.GiftCardAmt.GetValueOrDefault());
                decimal historyRefundAmt = 0m;

                var validRefundList = RMARefundDA.GetValidRefundListBySOSysNo(refundInfo.SOSysNo.Value);
                if (validRefundList != null && validRefundList.Count > 0)
                {
                    historyRefundAmt = validRefundList.Sum(info =>
                    {
                        return(Math.Abs(info.CashAmt.GetValueOrDefault()) + Math.Abs(info.PointPay.GetValueOrDefault() * pointExchangeRate)
                               + Math.Abs(info.GiftCardAmt.GetValueOrDefault()));
                    });
                }
                if (thisRefundAmt + historyRefundAmt > Decimal.Round(maxRMARefundAmt, 2))
                {
                    throw new BusinessException(L("超过原始购物订单#{0}的最大可退金额{1},不能再退款", refundInfo.SOSysNo, Decimal.Round(maxRMARefundAmt, 2)));
                }
                trans.Complete();
            }
            #endregion

            refundInfo.Status         = RMARefundStatus.WaitingAudit;
            refundInfo.SOIncomeStatus = SOIncomeStatus.Origin;
            refundInfo.InUserSysNo    = operateUser.UserSysNo;
            refundInfo.InUserName     = operateUser.UserDisplayName;
            using (ITransaction trans = TransactionManager.Create())
            {
                int newSysNo = RMARefundDA.CreateNewRefundSysNo();
                refundInfo.SysNo    = newSysNo;
                refundInfo.RefundID = String.Format("R3{0:00000000}", newSysNo);
                //创建RMA Refund记录
                RMARefundDA.Create(refundInfo);

                //创建退款银行信息
                SOIncomeRefundInfo soIncomeRefundInfo = new SOIncomeRefundInfo()
                {
                    OrderType       = refundInfo.OrderType,
                    OrderSysNo      = refundInfo.SysNo,
                    SOSysNo         = refundInfo.SOSysNo,
                    BankName        = refundInfo.BankName,
                    CardNumber      = refundInfo.CardNumber,
                    CardOwnerName   = refundInfo.CardOwnerName,
                    RefundPayType   = refundInfo.RefundPayType,
                    CreateUserSysNo = operateUser.UserSysNo,
                    CreateUserName  = operateUser.UserDisplayName,
                    Status          = RefundStatus.Origin,
                    HaveAutoRMA     = false,
                    RefundCashAmt   = refundInfo.CashAmt,
                    RefundPoint     = refundInfo.PointPay,
                    RefundGiftCard  = refundInfo.GiftCardAmt
                };
                RMARefundDA.CreateRefundBankInfo(soIncomeRefundInfo);

                if (refundInfo.RefundItems != null)
                {
                    foreach (var item in refundInfo.RefundItems)
                    {
                        item.RefundSysNo = refundInfo.SysNo;
                        RMARefundDA.CreateItem(item);
                    }
                }
                trans.Complete();
            }

            return(refundInfo);
        }
Ejemplo n.º 15
0
        public static RMARefundInfo Confirm(int rmaRefundSysNo, LoginUser operateUser)
        {
            RMARefundInfo info = LoadWithRefundSysNo(rmaRefundSysNo, operateUser.SellerSysNo);

            if (info == null)
            {
                throw new BusinessException(L("未找到编号为【{0}】的退款单", rmaRefundSysNo));
            }
            if (info.Status != RMARefundStatus.WaitingRefund)
            {
                throw new BusinessException(L("退款单不是“待退款”,不能确认退款"));
            }
            SOInfo soInfo = SOService.GetSOInfo(info.SOSysNo.Value);

            if (soInfo == null)
            {
                throw new BusinessException(L("订单不存在"));
            }
            info.Status          = RMARefundStatus.Refunded;
            info.SOIncomeStatus  = SOIncomeStatus.Confirmed;
            info.RefundUserSysNo = operateUser.UserSysNo;
            info.RefundUserName  = operateUser.UserDisplayName;
            info.RefundDate      = DateTime.Now;

            //using (ITransaction ts = TransactionManager.Create(
            //     System.Transactions.TransactionScopeOption.Required, System.Transactions.IsolationLevel.ReadUncommitted))
            using (ITransaction ts = TransactionManager.Create())
            {
                //积分撤销
                ReturnProductPoint(info, operateUser.UserSysNo);
                //退入余额帐户
                RefundPrepay(info);

                //更新客户累计购买金额
                if (info.CashAmt != 0)
                {
                    CustomerService.UpdateCustomerOrderedAmt(info.CustomerSysNo.Value, -1 * info.CashAmt.Value);
                }
                RMARefundDA.Update(info);
                RMARefundDA.BatchUpdateRegisterRefundStatusAndStatus(info.SysNo.Value, RMARefundStatus.Refunded, RMARequestStatus.Complete);
                //RMARefundDA.ConfirmRefundSOIncome(info);
                SOIncomeInfo soIncomeInfo = new SOIncomeInfo()
                {
                    OrderType      = SOIncomeOrderType.RO,
                    OrderSysNo     = info.SysNo,
                    OrderAmt       = -1 * info.CashAmt,
                    IncomeStyle    = SOIncomeOrderStyle.RO,
                    IncomeAmt      = -1 * info.CashAmt,
                    PayAmount      = -1 * info.CashAmt,
                    InUserSysNo    = operateUser.UserSysNo,
                    InUserName     = operateUser.UserDisplayName,
                    Status         = SOIncomeStatus.Origin,
                    PointPay       = info.PointPay,
                    GiftCardPayAmt = info.GiftCardAmt,
                };
                RMARefundDA.CreateRefundSOIncome(soIncomeInfo);


                var rmaRequstSysNoList = RMARefundDA.QueryRMARequsetSysNoByRefundSysNo(info.SysNo.Value);
                if (rmaRequstSysNoList != null && rmaRequstSysNoList.Count > 0)
                {
                    foreach (var rmaRequestSysNo in rmaRequstSysNoList)
                    {
                        RMARequestService.RefreshRequestStatus(rmaRequestSysNo, operateUser.SellerSysNo);
                    }
                }

                SOIncomeInfo rmaIncomeInfo = SOIncomeDA.GetValidSOIncomeInfo(info.SysNo.Value, SOIncomeOrderType.RO);
                //ECC确认退款开始
                if (info.RefundPayType == RefundPayType.NetWorkRefund)
                {
                    //发起银行网关退款
                    RefundResult result = ProcessNetWorkRefund(rmaIncomeInfo, soInfo);
                    if (!result.Result)
                    {
                        throw new BusinessException(result.Message);
                    }
                    else
                    {
                        rmaIncomeInfo.ExternalKey = result.ExternalKey;       //退款流水号
                        rmaIncomeInfo.Status      = SOIncomeStatus.Confirmed; //等待银行后台回调处理中
                        RMARefundDA.ConfirmRefundSOIncomeNet(info, soIncomeInfo);
                    }
                }
                else if (info.RefundPayType == RefundPayType.BankRefund)
                {
                    RMARefundDA.ConfirmRefundSOIncome(info);
                }


                ts.Complete();
            }
            return(info);
        }
Ejemplo n.º 16
0
        public ActionResult LoadRefundWithSysNo(int refundSysNo)
        {
            RMARefundInfo refundInfo = RMARefundService.LoadWithRefundSysNo(refundSysNo, UserAuthHelper.GetCurrentUser().SellerSysNo);

            return(PartialView("_RefundOrderPop", refundInfo ?? new RMARefundInfo()));
        }
Ejemplo n.º 17
0
        public int InsertMaster(RMARefundInfo oParam)
        {
            string sql = @"INSERT INTO rma_refund
                            (
                            SysNo, RefundID, SOSysNo, CustomerSysNo, 
                            CreateTime, CreateUserSysNo, AuditTime, AuditUserSysNo, 
                            RefundTime, RefundUserSysNo, CompensateShipPrice, SOCashPointRate, 
                            OrgCashAmt, OrgPointAmt, DeductPointFromAccount, DeductPointFromCurrentCash, 
                            CashAmt, PointAmt, RefundPayType, Note, 
                            Status
                            )
                            VALUES (
                            @SysNo, @RefundID, @SOSysNo, @CustomerSysNo, 
                            @CreateTime, @CreateUserSysNo, @AuditTime, @AuditUserSysNo, 
                            @RefundTime, @RefundUserSysNo, @CompensateShipPrice, @SOCashPointRate, 
                            @OrgCashAmt, @OrgPointAmt, @DeductPointFromAccount, @DeductPointFromCurrentCash, 
                            @CashAmt, @PointAmt, @RefundPayType, @Note, 
                            @Status
                            )";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo                      = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramRefundID                   = new SqlParameter("@RefundID", SqlDbType.NVarChar, 10);
            SqlParameter paramSOSysNo                    = new SqlParameter("@SOSysNo", SqlDbType.Int, 4);
            SqlParameter paramCustomerSysNo              = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4);
            SqlParameter paramCreateTime                 = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramCreateUserSysNo            = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAuditTime                  = new SqlParameter("@AuditTime", SqlDbType.DateTime);
            SqlParameter paramAuditUserSysNo             = new SqlParameter("@AuditUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramRefundTime                 = new SqlParameter("@RefundTime", SqlDbType.DateTime);
            SqlParameter paramRefundUserSysNo            = new SqlParameter("@RefundUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramCompensateShipPrice        = new SqlParameter("@CompensateShipPrice", SqlDbType.Decimal, 9);
            SqlParameter paramSOCashPointRate            = new SqlParameter("@SOCashPointRate", SqlDbType.Decimal, 9);
            SqlParameter paramOrgCashAmt                 = new SqlParameter("@OrgCashAmt", SqlDbType.Decimal, 9);
            SqlParameter paramOrgPointAmt                = new SqlParameter("@OrgPointAmt", SqlDbType.Int, 4);
            SqlParameter paramDeductPointFromAccount     = new SqlParameter("@DeductPointFromAccount", SqlDbType.Int, 4);
            SqlParameter paramDeductPointFromCurrentCash = new SqlParameter("@DeductPointFromCurrentCash", SqlDbType.Decimal, 9);
            SqlParameter paramCashAmt                    = new SqlParameter("@CashAmt", SqlDbType.Decimal, 9);
            SqlParameter paramPointAmt                   = new SqlParameter("@PointAmt", SqlDbType.Int, 4);
            SqlParameter paramRefundPayType              = new SqlParameter("@RefundPayType", SqlDbType.Int, 4);
            SqlParameter paramNote   = new SqlParameter("@Note", SqlDbType.NVarChar, 500);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4);

            if (oParam.SysNo != AppConst.IntNull)
            {
                paramSysNo.Value = oParam.SysNo;
            }
            else
            {
                paramSysNo.Value = System.DBNull.Value;
            }
            if (oParam.RefundID != AppConst.StringNull)
            {
                paramRefundID.Value = oParam.RefundID;
            }
            else
            {
                paramRefundID.Value = System.DBNull.Value;
            }
            if (oParam.SOSysNo != AppConst.IntNull)
            {
                paramSOSysNo.Value = oParam.SOSysNo;
            }
            else
            {
                paramSOSysNo.Value = System.DBNull.Value;
            }
            if (oParam.CustomerSysNo != AppConst.IntNull)
            {
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            }
            else
            {
                paramCustomerSysNo.Value = System.DBNull.Value;
            }
            if (oParam.CreateTime != AppConst.DateTimeNull)
            {
                paramCreateTime.Value = oParam.CreateTime;
            }
            else
            {
                paramCreateTime.Value = System.DBNull.Value;
            }
            if (oParam.CreateUserSysNo != AppConst.IntNull)
            {
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            }
            else
            {
                paramCreateUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AuditTime != AppConst.DateTimeNull)
            {
                paramAuditTime.Value = oParam.AuditTime;
            }
            else
            {
                paramAuditTime.Value = System.DBNull.Value;
            }
            if (oParam.AuditUserSysNo != AppConst.IntNull)
            {
                paramAuditUserSysNo.Value = oParam.AuditUserSysNo;
            }
            else
            {
                paramAuditUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.RefundTime != AppConst.DateTimeNull)
            {
                paramRefundTime.Value = oParam.RefundTime;
            }
            else
            {
                paramRefundTime.Value = System.DBNull.Value;
            }
            if (oParam.RefundUserSysNo != AppConst.IntNull)
            {
                paramRefundUserSysNo.Value = oParam.RefundUserSysNo;
            }
            else
            {
                paramRefundUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.CompensateShipPrice != AppConst.DecimalNull)
            {
                paramCompensateShipPrice.Value = oParam.CompensateShipPrice;
            }
            else
            {
                paramCompensateShipPrice.Value = System.DBNull.Value;
            }
            if (oParam.SOCashPointRate != AppConst.DecimalNull)
            {
                paramSOCashPointRate.Value = oParam.SOCashPointRate;
            }
            else
            {
                paramSOCashPointRate.Value = System.DBNull.Value;
            }
            if (oParam.OrgCashAmt != AppConst.DecimalNull)
            {
                paramOrgCashAmt.Value = oParam.OrgCashAmt;
            }
            else
            {
                paramOrgCashAmt.Value = System.DBNull.Value;
            }
            if (oParam.OrgPointAmt != AppConst.IntNull)
            {
                paramOrgPointAmt.Value = oParam.OrgPointAmt;
            }
            else
            {
                paramOrgPointAmt.Value = System.DBNull.Value;
            }
            if (oParam.DeductPointFromAccount != AppConst.IntNull)
            {
                paramDeductPointFromAccount.Value = oParam.DeductPointFromAccount;
            }
            else
            {
                paramDeductPointFromAccount.Value = System.DBNull.Value;
            }
            if (oParam.DeductPointFromCurrentCash != AppConst.DecimalNull)
            {
                paramDeductPointFromCurrentCash.Value = oParam.DeductPointFromCurrentCash;
            }
            else
            {
                paramDeductPointFromCurrentCash.Value = System.DBNull.Value;
            }
            if (oParam.CashAmt != AppConst.DecimalNull)
            {
                paramCashAmt.Value = oParam.CashAmt;
            }
            else
            {
                paramCashAmt.Value = System.DBNull.Value;
            }
            if (oParam.PointAmt != AppConst.IntNull)
            {
                paramPointAmt.Value = oParam.PointAmt;
            }
            else
            {
                paramPointAmt.Value = System.DBNull.Value;
            }
            if (oParam.RefundPayType != AppConst.IntNull)
            {
                paramRefundPayType.Value = oParam.RefundPayType;
            }
            else
            {
                paramRefundPayType.Value = System.DBNull.Value;
            }
            if (oParam.Note != AppConst.StringNull)
            {
                paramNote.Value = oParam.Note;
            }
            else
            {
                paramNote.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramRefundID);
            cmd.Parameters.Add(paramSOSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramAuditTime);
            cmd.Parameters.Add(paramAuditUserSysNo);
            cmd.Parameters.Add(paramRefundTime);
            cmd.Parameters.Add(paramRefundUserSysNo);
            cmd.Parameters.Add(paramCompensateShipPrice);
            cmd.Parameters.Add(paramSOCashPointRate);
            cmd.Parameters.Add(paramOrgCashAmt);
            cmd.Parameters.Add(paramOrgPointAmt);
            cmd.Parameters.Add(paramDeductPointFromAccount);
            cmd.Parameters.Add(paramDeductPointFromCurrentCash);
            cmd.Parameters.Add(paramCashAmt);
            cmd.Parameters.Add(paramPointAmt);
            cmd.Parameters.Add(paramRefundPayType);
            cmd.Parameters.Add(paramNote);
            cmd.Parameters.Add(paramStatus);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }