Commit e6c73967 authored by Quxl's avatar Quxl

xx

parent d63e4806
...@@ -167,9 +167,18 @@ public class CartRedisServiceImpl implements CartRedisService { ...@@ -167,9 +167,18 @@ public class CartRedisServiceImpl implements CartRedisService {
"nApID", "nAdID", "sIpInfo", "sDeviceInfo", "sUserBrower"); "nApID", "nAdID", "sIpInfo", "sDeviceInfo", "sUserBrower");
rjx.set("totalCount", datas.size()); rjx.set("totalCount", datas.size());
rjx.set("wmsList", wmsList); rjx.set("wmsList", wmsList);
rjx.set("shopGoodsObj", Util.listToMM(datas, "$", "contractNo", "goodsId", "goodsType", "nIdx", "promoNo")); Map<String, Map<String, Object>> gmm = Util.listToMM(datas, "$", "contractNo", "goodsId", "goodsType", "nIdx", "promoNo");
rjx.set("shopGoodsObj", gmm);
rjx.putAll(this.processFreightAmount(wmsList, gmm));
}
if(!rjx.keySet().contains("shopGoodsObj")) {
rjx.set("shopGoodsObj", new HashMap<String, Object>());
rjx.set("totalCount", 0);
rjx.set("wmsList", new ArrayList<Object>());
rjx.set("freightPayAmount", BigDecimal.ZERO);
rjx.set("freightFreeAmount", BigDecimal.ZERO);
rjx.set("freightTotalAmount", BigDecimal.ZERO);
} }
if (!rjx.keySet().contains("shopGoodsObj")) { if (!rjx.keySet().contains("shopGoodsObj")) {
rjx.set("shopGoodsObj", new HashMap<String, Object>()); rjx.set("shopGoodsObj", new HashMap<String, Object>());
rjx.set("totalCount", 0); rjx.set("totalCount", 0);
...@@ -182,6 +191,62 @@ public class CartRedisServiceImpl implements CartRedisService { ...@@ -182,6 +191,62 @@ public class CartRedisServiceImpl implements CartRedisService {
this.cacheData(orgNo, shopNo, terminal, rjx); this.cacheData(orgNo, shopNo, terminal, rjx);
return rjx; return rjx;
} }
/**
* --计算运费
* @param wmsList
* @param gmm
* @return
*/
private Map<String, BigDecimal> processFreightAmount(List<Map<String, Object>> wmsList, Map<String, Map<String, Object>> gmm) {
BigDecimal freightPayAmount = BigDecimal.ZERO;
BigDecimal freightFreeAmount = BigDecimal.ZERO;
BigDecimal freightTotalAmount = BigDecimal.ZERO;
for(Map<String, Object> wmsMap : wmsList) {
BigDecimal nOrderMeetAmountFree = (BigDecimal)wmsMap.get("nOrderMeetAmountFree");
BigDecimal nMinTranAmount = (BigDecimal)wmsMap.get("nMinTranAmount");
BigDecimal nPerPiecePrice = (BigDecimal)wmsMap.get("nPerPiecePrice");
Integer nMinTranCase_int = (Integer)wmsMap.get("nMinTranCase");
BigDecimal nMinTranCase = nMinTranCase_int == null ? BigDecimal.ZERO : BigDecimal.valueOf(nMinTranCase_int);
nOrderMeetAmountFree = nOrderMeetAmountFree == null ? BigDecimal.valueOf(Long.MAX_VALUE) : nOrderMeetAmountFree;
nMinTranAmount = nMinTranAmount == null ? BigDecimal.ZERO : nMinTranAmount;
nPerPiecePrice = nPerPiecePrice == null ? BigDecimal.ZERO : nPerPiecePrice;
List<?> goodsIdList = (List<?>)wmsMap.get("goodsIdList");
BigDecimal unitSum = BigDecimal.ZERO;
for(Object goodsId : goodsIdList) {
Map<String, Object> goodsMap = gmm.get(goodsId);
Integer nTag = (Integer) goodsMap.get("nTag");
if((nTag&2048) == 0) {
BigDecimal orderUnit = (BigDecimal)goodsMap.get("orderUnit");
orderUnit = orderUnit == null ? BigDecimal.ONE : orderUnit;
BigDecimal saleQty = (BigDecimal)goodsMap.get("saleQty");
unitSum = unitSum.add(saleQty.divide(orderUnit, 0, BigDecimal.ROUND_UP));
}
}
BigDecimal wmsFreightAmount = BigDecimal.ZERO;
if(unitSum.compareTo(nMinTranCase) <= 0) {
wmsFreightAmount = nMinTranAmount;
} else {
wmsFreightAmount = nMinTranAmount.add(unitSum.subtract(nMinTranCase).multiply(nPerPiecePrice));
}
if(wmsFreightAmount.compareTo(nOrderMeetAmountFree) >= 0) {
freightFreeAmount = freightFreeAmount.add(wmsFreightAmount.subtract(nOrderMeetAmountFree));
wmsFreightAmount = nOrderMeetAmountFree;
}
wmsMap.put("freightAmount", wmsFreightAmount);
freightTotalAmount = freightTotalAmount.add(wmsFreightAmount);
wmsMap.put("isFreeFreight", false);
freightPayAmount = freightPayAmount.add(wmsFreightAmount);
}
Map<String, BigDecimal> freightAmountMap = new HashMap<String, BigDecimal>();
freightAmountMap.put("freightPayAmount", freightPayAmount);
freightAmountMap.put("freightFreeAmount", freightFreeAmount);
freightAmountMap.put("freightTotalAmount", freightTotalAmount);
return freightAmountMap;
}
private void cacheTmpData(String orgNo, String shopNo, String terminal) { private void cacheTmpData(String orgNo, String shopNo, String terminal) {
this.redisTemplate.opsForHash().put("CART_" + orgNo + "_" + shopNo, terminal, this.redisTemplate.opsForHash().put("CART_" + orgNo + "_" + shopNo, terminal,
...@@ -816,6 +881,13 @@ public class CartRedisServiceImpl implements CartRedisService { ...@@ -816,6 +881,13 @@ public class CartRedisServiceImpl implements CartRedisService {
Double MinOrderAmt = Util.objTo(goodsFirst.get("nMinDCAmount"), Double.class); // 最小配送金额 Double MinOrderAmt = Util.objTo(goodsFirst.get("nMinDCAmount"), Double.class); // 最小配送金额
String WMSInfo = (String) goodsFirst.get("sWarehouseName"); // 物流名称 String WMSInfo = (String) goodsFirst.get("sWarehouseName"); // 物流名称
String sWarehouseNO = (String) goodsFirst.get("sWarehouseNO"); // 物流名称 String sWarehouseNO = (String) goodsFirst.get("sWarehouseNO"); // 物流名称
BigDecimal nMinTranAmount = (BigDecimal)goodsFirst.get("nMinTranAmount");
Integer nMinTranCase = (Integer)goodsFirst.get("nMinTranCase");
BigDecimal nPerPiecePrice = (BigDecimal)goodsFirst.get("nPerPiecePrice");
BigDecimal nOrderMeetAmountFree = (BigDecimal)goodsFirst.get("nOrderMeetAmountFree");
String sOrgNO = (String)goodsFirst.get("wOrgNO"); // 物流名称
for (Map<String, Object> goods : GoodsList) { for (Map<String, Object> goods : GoodsList) {
BigDecimal goodsAmount = (BigDecimal) goods.get("nRealSalePrice"); // 当前销售价格 BigDecimal goodsAmount = (BigDecimal) goods.get("nRealSalePrice"); // 当前销售价格
BigDecimal nSaleQty = (BigDecimal) goods.get("nSaleQty"); // 购物车商品数量 BigDecimal nSaleQty = (BigDecimal) goods.get("nSaleQty"); // 购物车商品数量
...@@ -828,8 +900,13 @@ public class CartRedisServiceImpl implements CartRedisService { ...@@ -828,8 +900,13 @@ public class CartRedisServiceImpl implements CartRedisService {
Map<String, Object> zoneGoods = new HashMap<String, Object>(); Map<String, Object> zoneGoods = new HashMap<String, Object>();
zoneGoods.put("wmsInfo", WMSInfo); zoneGoods.put("wmsInfo", WMSInfo);
zoneGoods.put("warehouseNo", sWarehouseNO); zoneGoods.put("warehouseNo", sWarehouseNO);
zoneGoods.put("nPerPiecePrice", nPerPiecePrice);
zoneGoods.put("nOrderMeetAmountFree", nOrderMeetAmountFree);
zoneGoods.put("nMinTranAmount", nMinTranAmount);
zoneGoods.put("nMinTranCase", nMinTranCase);
zoneGoods.put("minOrderAmt", MinOrderAmt); zoneGoods.put("minOrderAmt", MinOrderAmt);
zoneGoods.put("totalAmount", TotalAmount); zoneGoods.put("totalAmount", TotalAmount);
zoneGoods.put("orgNo", sOrgNO);
zoneGoods.put("goodsIdList", pidlist); zoneGoods.put("goodsIdList", pidlist);
wmsList.add(zoneGoods); wmsList.add(zoneGoods);
TotalCount += GoodsList.size(); TotalCount += GoodsList.size();
...@@ -951,4 +1028,7 @@ public class CartRedisServiceImpl implements CartRedisService { ...@@ -951,4 +1028,7 @@ public class CartRedisServiceImpl implements CartRedisService {
} }
return datas; return datas;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment