Пример #1
0
        public static RMARefundItemInfo CreateItem(RMARefundItemInfo item)
        {
            DataCommand command = DataCommandManager.GetDataCommand("CreateRMARefundItem");

            command.SetParameterValue("@RefundSysNo", item.RefundSysNo);
            command.SetParameterValue("@RegisterSysNo", item.RegisterSysNo);
            command.SetParameterValue("@OrgPrice", item.OrgPrice);
            command.SetParameterValue("@UnitDiscount", item.UnitDiscount);
            command.SetParameterValue("@ProductValue", item.ProductValue);
            command.SetParameterValue("@OrgPoint", item.OrgPoint);
            command.SetParameterValue("@RefundPrice", item.RefundPrice);
            command.SetParameterValue("@PointType", item.PointType);
            command.SetParameterValue("@RefundCash", item.RefundCash);
            command.SetParameterValue("@RefundPoint", item.RefundPoint);
            command.SetParameterValue("@RefundPriceType", item.RefundPriceType);
            command.SetParameterValue("@RefundCost", item.RefundCost);
            command.SetParameterValue("@RefundCostWithoutTax", item.RefundCostWithoutTax);
            command.SetParameterValue("@RefundCostPoint", item.RefundCostPoint);
            command.SetParameterValue("@OrgGiftCardAmt", item.OrgGiftCardAmt);
            command.SetParameterValue("@CompanyCode", item.CompanyCode);
            command.SetParameterValue("@LanguageCode", item.LanguageCode);
            command.SetParameterValue("@StoreCompanyCode", item.CompanyCode);
            command.ExecuteNonQuery();

            return(item);
        }
Пример #2
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
        }
Пример #3
0
        public int InsertItem(RMARefundItemInfo oParam)
        {
            string     sql = @"INSERT INTO rma_refund_item
                            (
                            RefundSysNo, RegisterSysNo, OrgPrice, 
                            UnitDiscount, ProductValue, OrgPoint, RefundPrice, 
                            PointType, RefundCash, RefundPoint , RefundPriceType , RefundCost , RefundCostPoint
                            )
                            VALUES (
                            @RefundSysNo, @RegisterSysNo, @OrgPrice, 
                            @UnitDiscount, @ProductValue, @OrgPoint, @RefundPrice, 
                            @PointType, @RefundCash, @RefundPoint , @RefundPriceType , @RefundCost , @RefundCostPoint
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo           = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramRefundSysNo     = new SqlParameter("@RefundSysNo", SqlDbType.Int, 4);
            SqlParameter paramRegisterSysNo   = new SqlParameter("@RegisterSysNo", SqlDbType.Int, 4);
            SqlParameter paramOrgPrice        = new SqlParameter("@OrgPrice", SqlDbType.Decimal, 9);
            SqlParameter paramUnitDiscount    = new SqlParameter("@UnitDiscount", SqlDbType.Decimal, 9);
            SqlParameter paramProductValue    = new SqlParameter("@ProductValue", SqlDbType.Decimal, 9);
            SqlParameter paramOrgPoint        = new SqlParameter("@OrgPoint", SqlDbType.Int, 4);
            SqlParameter paramRefundPrice     = new SqlParameter("@RefundPrice", SqlDbType.Decimal, 9);
            SqlParameter paramPointType       = new SqlParameter("@PointType", SqlDbType.Int, 4);
            SqlParameter paramRefundCash      = new SqlParameter("@RefundCash", SqlDbType.Decimal, 9);
            SqlParameter paramRefundPoint     = new SqlParameter("@RefundPoint", SqlDbType.Int, 4);
            SqlParameter paramRefundPriceType = new SqlParameter("@RefundPriceType", SqlDbType.Int, 4);
            SqlParameter paramRefundCost      = new SqlParameter("@RefundCost", SqlDbType.Decimal, 9);
            SqlParameter paramRefundCostPoint = new SqlParameter("@RefundCostPoint", SqlDbType.Int, 4);

            paramSysNo.Direction = ParameterDirection.Output;

            if (oParam.RefundSysNo != AppConst.IntNull)
            {
                paramRefundSysNo.Value = oParam.RefundSysNo;
            }
            else
            {
                paramRefundSysNo.Value = System.DBNull.Value;
            }
            if (oParam.RegisterSysNo != AppConst.IntNull)
            {
                paramRegisterSysNo.Value = oParam.RegisterSysNo;
            }
            else
            {
                paramRegisterSysNo.Value = System.DBNull.Value;
            }
            if (oParam.OrgPrice != AppConst.DecimalNull)
            {
                paramOrgPrice.Value = oParam.OrgPrice;
            }
            else
            {
                paramOrgPrice.Value = System.DBNull.Value;
            }
            if (oParam.UnitDiscount != AppConst.DecimalNull)
            {
                paramUnitDiscount.Value = oParam.UnitDiscount;
            }
            else
            {
                paramUnitDiscount.Value = System.DBNull.Value;
            }
            if (oParam.ProductValue != AppConst.DecimalNull)
            {
                paramProductValue.Value = oParam.ProductValue;
            }
            else
            {
                paramProductValue.Value = System.DBNull.Value;
            }
            if (oParam.OrgPoint != AppConst.IntNull)
            {
                paramOrgPoint.Value = oParam.OrgPoint;
            }
            else
            {
                paramOrgPoint.Value = System.DBNull.Value;
            }
            if (oParam.RefundPrice != AppConst.DecimalNull)
            {
                paramRefundPrice.Value = oParam.RefundPrice;
            }
            else
            {
                paramRefundPrice.Value = System.DBNull.Value;
            }
            if (oParam.PointType != AppConst.IntNull)
            {
                paramPointType.Value = oParam.PointType;
            }
            else
            {
                paramPointType.Value = System.DBNull.Value;
            }
            if (oParam.RefundCash != AppConst.DecimalNull)
            {
                paramRefundCash.Value = oParam.RefundCash;
            }
            else
            {
                paramRefundCash.Value = System.DBNull.Value;
            }
            if (oParam.RefundPoint != AppConst.IntNull)
            {
                paramRefundPoint.Value = oParam.RefundPoint;
            }
            else
            {
                paramRefundPoint.Value = System.DBNull.Value;
            }

            if (oParam.RefundPriceType != AppConst.IntNull)
            {
                paramRefundPriceType.Value = oParam.RefundPriceType;
            }
            else
            {
                paramRefundPriceType.Value = System.DBNull.Value;
            }

            if (oParam.RefundCost != AppConst.DecimalNull)
            {
                paramRefundCost.Value = oParam.RefundCost;
            }
            else
            {
                paramRefundCost.Value = System.DBNull.Value;
            }

            if (oParam.RefundCostPoint != AppConst.IntNull)
            {
                paramRefundCostPoint.Value = oParam.RefundCostPoint;
            }
            else
            {
                paramRefundCostPoint.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramRefundSysNo);
            cmd.Parameters.Add(paramRegisterSysNo);
            cmd.Parameters.Add(paramOrgPrice);
            cmd.Parameters.Add(paramUnitDiscount);
            cmd.Parameters.Add(paramProductValue);
            cmd.Parameters.Add(paramOrgPoint);
            cmd.Parameters.Add(paramRefundPrice);
            cmd.Parameters.Add(paramPointType);
            cmd.Parameters.Add(paramRefundCash);
            cmd.Parameters.Add(paramRefundPoint);
            cmd.Parameters.Add(paramRefundPriceType);
            cmd.Parameters.Add(paramRefundCost);
            cmd.Parameters.Add(paramRefundCostPoint);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }