|
@@ -257,8 +257,13 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
|
|
int totalOrderItemCount = fsStoreOrderItems.size();
|
|
int totalOrderItemCount = fsStoreOrderItems.size();
|
|
BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
|
|
JSONArray goodArr = new JSONArray();
|
|
JSONArray goodArr = new JSONArray();
|
|
|
|
+ //总优惠
|
|
|
|
+ BigDecimal discountMoney = fsOrder.getDiscountMoney();
|
|
|
|
+ //已计算算优惠
|
|
|
|
+ BigDecimal alreadySum = new BigDecimal(0);
|
|
|
|
|
|
- for (FsStoreOrderItem fsStoreOrderItem : fsStoreOrderItems) {
|
|
|
|
|
|
+ for (int i = 0, fsStoreOrderItemsSize = fsStoreOrderItems.size(); i < fsStoreOrderItemsSize; i++) {
|
|
|
|
+ FsStoreOrderItem fsStoreOrderItem = fsStoreOrderItems.get(i);
|
|
JSONObject goodItem = new JSONObject();
|
|
JSONObject goodItem = new JSONObject();
|
|
//商品编码
|
|
//商品编码
|
|
goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
|
|
goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
|
|
@@ -268,9 +273,9 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
|
|
FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(fsStoreOrderItem.getProductId());
|
|
FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(fsStoreOrderItem.getProductId());
|
|
FsStoreProductAttrValue fsStoreProductAttrValue = new FsStoreProductAttrValue();
|
|
FsStoreProductAttrValue fsStoreProductAttrValue = new FsStoreProductAttrValue();
|
|
//判断是否含有商品规格信息 有则查询商品规格信息 没有取商品的价格
|
|
//判断是否含有商品规格信息 有则查询商品规格信息 没有取商品的价格
|
|
- if(null != fsStoreOrderItem.getProductAttrValueId()){
|
|
|
|
|
|
+ if (null != fsStoreOrderItem.getProductAttrValueId()) {
|
|
fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(fsStoreOrderItem.getProductAttrValueId());
|
|
fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(fsStoreOrderItem.getProductAttrValueId());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
fsStoreProductAttrValue.setPrice(fsStoreProduct.getPrice());
|
|
fsStoreProductAttrValue.setPrice(fsStoreProduct.getPrice());
|
|
}
|
|
}
|
|
//商品名称
|
|
//商品名称
|
|
@@ -281,9 +286,17 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
|
|
goodItem.put("fqty", fsStoreOrderItem.getNum());
|
|
goodItem.put("fqty", fsStoreOrderItem.getNum());
|
|
//原单价
|
|
//原单价
|
|
goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
|
|
goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
|
|
|
|
+ BigDecimal subtract = fsStoreProductAttrValue.getPrice().subtract(divide);
|
|
|
|
+ //前面的所有商品采用平均优惠计算 最后一个采用减法
|
|
|
|
+ if (i != fsStoreOrderItemsSize - 1) {
|
|
|
|
+ alreadySum = alreadySum.add(divide);
|
|
|
|
+ } else {
|
|
|
|
+ BigDecimal d = discountMoney.subtract(alreadySum);
|
|
|
|
+ subtract = fsStoreProductAttrValue.getPrice().subtract(d);
|
|
|
|
+ }
|
|
|
|
|
|
//实售单价 优惠后的单价 单位元
|
|
//实售单价 优惠后的单价 单位元
|
|
- goodItem.put("fprice", fsStoreProductAttrValue.getPrice().subtract(divide));
|
|
|
|
|
|
+ goodItem.put("fprice", subtract);
|
|
//商品优惠金额 f
|
|
//商品优惠金额 f
|
|
// goodItem.put("fdiscprice", new BigDecimal(0));
|
|
// goodItem.put("fdiscprice", new BigDecimal(0));
|
|
//商品条码 f
|
|
//商品条码 f
|
|
@@ -354,7 +367,13 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
|
|
List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsOrder.getOrderId());
|
|
List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsOrder.getOrderId());
|
|
int totalOrderItemCount = fsStoreOrderItems.size();
|
|
int totalOrderItemCount = fsStoreOrderItems.size();
|
|
BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
|
|
BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
|
|
- fsStoreOrderItems.forEach(fsStoreOrderItem -> {
|
|
|
|
|
|
+ //总优惠
|
|
|
|
+ BigDecimal discountMoney = fsOrder.getDiscountMoney();
|
|
|
|
+ //已计算算优惠
|
|
|
|
+ BigDecimal alreadySum = new BigDecimal(0);
|
|
|
|
+
|
|
|
|
+ for (int i = 0, fsStoreOrderItemsSize = fsStoreOrderItems.size(); i < fsStoreOrderItemsSize; i++) {
|
|
|
|
+ FsStoreOrderItem fsStoreOrderItem = fsStoreOrderItems.get(i);
|
|
JSONObject goodItem = new JSONObject();
|
|
JSONObject goodItem = new JSONObject();
|
|
//商品编码
|
|
//商品编码
|
|
goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
|
|
goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
|
|
@@ -371,11 +390,20 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
|
|
goodItem.put("fqty", fsStoreOrderItem.getNum());
|
|
goodItem.put("fqty", fsStoreOrderItem.getNum());
|
|
//原单价
|
|
//原单价
|
|
goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
|
|
goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
|
|
|
|
+ BigDecimal subtract = fsStoreProductAttrValue.getPrice().subtract(divide);
|
|
|
|
+ //前面的所有商品采用平均优惠计算 最后一个采用减法
|
|
|
|
+ if (i != fsStoreOrderItemsSize - 1) {
|
|
|
|
+ alreadySum = alreadySum.add(divide);
|
|
|
|
+ } else {
|
|
|
|
+ BigDecimal d = discountMoney.subtract(alreadySum);
|
|
|
|
+ subtract = fsStoreProductAttrValue.getPrice().subtract(d);
|
|
|
|
+ }
|
|
|
|
+
|
|
//本次申请退款单价 单位元
|
|
//本次申请退款单价 单位元
|
|
- goodItem.put("fprice", fsStoreProductAttrValue.getPrice().subtract(divide));
|
|
|
|
|
|
+ goodItem.put("fprice", subtract);
|
|
|
|
|
|
goodsList.add(goodItem);
|
|
goodsList.add(goodItem);
|
|
- });
|
|
|
|
|
|
+ }
|
|
//售后商品信息
|
|
//售后商品信息
|
|
obj.put("ptreturnorder_goods_list", goodsList);
|
|
obj.put("ptreturnorder_goods_list", goodsList);
|
|
|
|
|