public static bool SendSMSForSO(int soSysNo, SMSType smsType) { SOInfo soInfo = SOService.GetSOInfo(soSysNo); CustomerBasicInfo customerInfo = CustomerService.GetCustomerInfo(soInfo.CustomerSysNo); string customerLanguageCode = customerInfo.LanguageCode; var sms = CommonDA.GetShipTypeSMSInfo(soInfo.ShipType.ShipTypeSysNo, smsType, null); var smsContent = sms.SMSContent; if (string.IsNullOrEmpty(smsContent)) { return(false); } string mobilePhone = string.Empty; if (!string.IsNullOrEmpty(soInfo.ReceiveCellPhone)) { mobilePhone = soInfo.ReceiveCellPhone; } else { mobilePhone = soInfo.ReceivePhone; } if (smsContent.IndexOf("SO#") != -1) { smsContent = smsContent.Replace("SO#", soInfo.SOSysNo.ToString()); } else { return(false); } return(SendSMS(mobilePhone, smsContent, SMSPriority.Normal)); }
public ActionResult AjaxIsNetPayed() { var soInfo = SOService.GetSOInfo(int.Parse(Request.QueryString["soSysNo"])); var result = new JsonResult { Data = soInfo.IsNetPayed == 1, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
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 }
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); }