|
@@ -213,7 +213,8 @@ public class TOrderController {
|
|
|
price = price.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
} else {
|
|
|
// 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
- price = BigDecimal.ZERO;
|
|
|
+// price = BigDecimal.ZERO;
|
|
|
+ return JsonMessage.success("0");
|
|
|
}
|
|
|
} else {
|
|
|
price = product.getRmbPrice().multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -337,7 +338,7 @@ public class TOrderController {
|
|
|
// String client6 = clientId.substring(clientId.length() - 6);
|
|
|
String productName1 = productName + "-" + equipment.getName() + "-" + client6;
|
|
|
String result = null;
|
|
|
- if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform) && payPlatform.equals("1")){
|
|
|
// 汇付分账参数
|
|
|
order.setAcctSplitBunch(acctSplitBunch.toString());
|
|
|
if(frpCode.equals("WEIXIN_NATIVE")) {
|
|
@@ -498,7 +499,8 @@ public class TOrderController {
|
|
|
price = price.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
} else {
|
|
|
// 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
- price = BigDecimal.ZERO;
|
|
|
+// price = BigDecimal.ZERO;
|
|
|
+ return JsonMessage.success("0");
|
|
|
}
|
|
|
} else {
|
|
|
price = product.getRmbPrice().multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -763,7 +765,8 @@ public class TOrderController {
|
|
|
price = price.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
} else {
|
|
|
// 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
- price = BigDecimal.ZERO;
|
|
|
+// price = BigDecimal.ZERO;
|
|
|
+ return JsonMessage.success("0");
|
|
|
}
|
|
|
} else {
|
|
|
price = price.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -1046,6 +1049,10 @@ public class TOrderController {
|
|
|
for (String key : productNameMap.keySet()) {
|
|
|
String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
+ boolean hasDuplicate = hasDuplicateValue(value);
|
|
|
+ if (hasDuplicate) {
|
|
|
+ return JsonMessage.error("优惠码输入重复,单个商品只能使用一个优惠码");
|
|
|
+ }
|
|
|
List<TPromoCode> promoCodeList = new ArrayList<>();
|
|
|
// 1、校验优惠码
|
|
|
if(value.size()>0){
|
|
@@ -1090,10 +1097,10 @@ public class TOrderController {
|
|
|
//旧优惠码
|
|
|
return JsonMessage.success("0");
|
|
|
}
|
|
|
- if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
- //0折
|
|
|
- return JsonMessage.success("0");
|
|
|
- }
|
|
|
+// if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
+// //0折
|
|
|
+// return JsonMessage.success("0");
|
|
|
+// }
|
|
|
promoCodeList.add(promoCode);
|
|
|
}
|
|
|
}
|
|
@@ -1119,7 +1126,8 @@ public class TOrderController {
|
|
|
for( i = 0;i<promoCodeList.size();i++){
|
|
|
BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
BigDecimal price1 = new BigDecimal(0.0);
|
|
|
- if (StringUtils.isNotEmpty(promoCodeList.get(i).getType()) && promoCodeList.get(i).getType().equals("1")) {
|
|
|
+ TPromoCode tPromoCode = promoCodeList.get(i);
|
|
|
+ if (StringUtils.isNotEmpty(tPromoCode.getType()) && tPromoCode.getType().equals("1")) {
|
|
|
if (productPrice.compareTo(discount) > 0) {
|
|
|
// 如果 price 大于 discount,从 price 中减去 discount
|
|
|
price1 = productPrice.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -1128,7 +1136,11 @@ public class TOrderController {
|
|
|
price1 = BigDecimal.ZERO;
|
|
|
}
|
|
|
} else {
|
|
|
- price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ if (tPromoCode.getDiscount() == 0) {
|
|
|
+ price1 = BigDecimal.ZERO;
|
|
|
+ } else {
|
|
|
+ price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ }
|
|
|
}
|
|
|
price = price.add(price1);
|
|
|
onePrice = onePrice.add(price1);
|
|
@@ -1207,7 +1219,10 @@ public class TOrderController {
|
|
|
|
|
|
Long equipmentId = equipment.getId();
|
|
|
//查找商品
|
|
|
- if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ if(BigDecimal.ZERO.compareTo(price) == 0) {
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) > 0) {
|
|
|
return JsonMessage.error("商品价格异常");
|
|
|
}
|
|
|
Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
@@ -1378,6 +1393,18 @@ public class TOrderController {
|
|
|
} else {
|
|
|
productName1 = productName + "-" + equipment.getName() + "-" + client6;
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ String[] products = order.getNote().split(",");
|
|
|
+ for (String product : products) {
|
|
|
+ String[] parts = product.split(":");
|
|
|
+ // 商品名称-商品编号
|
|
|
+ String key = parts[0];
|
|
|
+ // 商品单价-商品数量
|
|
|
+ String value = parts[1];
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
String result = null;
|
|
|
if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
// 汇付分账参数
|
|
@@ -1415,15 +1442,29 @@ public class TOrderController {
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
kindData.put("sn", sn1+"-"+sn2);
|
|
|
kindData.put("rd_Pic", qrcode);
|
|
|
- for (String key : productMap.keySet()) {
|
|
|
- Integer productNum = productMap.get(key);
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), key));
|
|
|
+// for (String key : productMap.keySet()) {
|
|
|
+// Integer productNum = productMap.get(key);
|
|
|
+// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), key));
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setProductNo(product.getNo());
|
|
|
+// orderDetails.setProductName(key);
|
|
|
+// orderDetails.setPrice(product.getRmbPrice());
|
|
|
+// orderDetails.setProductNumber(productNum);
|
|
|
+// orderDetails.setAmount(product.getRmbPrice().multiply(new BigDecimal(productNum)));
|
|
|
+// orderDetails.setOrderSn(sn2);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// }
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ // key:"玫瑰精灵-A01",value:"0.50-1"
|
|
|
+ String value = map.get(key);
|
|
|
+ String[] GoodsInfo = key.split("-");
|
|
|
+ String[] GoodsValue = value.split("-");
|
|
|
orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
- orderDetails.setProductNo(product.getNo());
|
|
|
- orderDetails.setProductName(key);
|
|
|
- orderDetails.setPrice(product.getRmbPrice());
|
|
|
- orderDetails.setProductNumber(productNum);
|
|
|
- orderDetails.setAmount(product.getRmbPrice().multiply(new BigDecimal(productNum)));
|
|
|
+ orderDetails.setProductName(GoodsInfo[0]);
|
|
|
+ orderDetails.setProductNo(GoodsInfo[1]);
|
|
|
+ orderDetails.setPrice(new BigDecimal(GoodsValue[0]).divide(new BigDecimal(GoodsValue[1])).setScale(2));
|
|
|
+ orderDetails.setProductNumber(Integer.valueOf(GoodsValue[1]));
|
|
|
+ orderDetails.setAmount(new BigDecimal(GoodsValue[0]).setScale(2));
|
|
|
orderDetails.setOrderSn(sn2);
|
|
|
orderDetailsService.save(orderDetails);
|
|
|
}
|
|
@@ -1466,14 +1507,32 @@ public class TOrderController {
|
|
|
kindData.put("sn", sn1+"-"+sn2);
|
|
|
kindData.put("rd_Pic", rd_Pic);
|
|
|
// 添加到订单明细表
|
|
|
- for (String key : productMap.keySet()) {
|
|
|
- Integer productNum = productMap.get(key);
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), key));
|
|
|
- orderDetails.setProductNo(product.getNo());
|
|
|
- orderDetails.setProductName(key);
|
|
|
- orderDetails.setPrice(product.getRmbPrice());
|
|
|
- orderDetails.setProductNumber(productNum);
|
|
|
- orderDetails.setAmount(product.getRmbPrice().multiply(new BigDecimal(productNum)));
|
|
|
+// for (String key : productMap.keySet()) {
|
|
|
+// Integer productNum = productMap.get(key);
|
|
|
+// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), key));
|
|
|
+// orderDetails.setProductNo(product.getNo());
|
|
|
+// orderDetails.setProductName(key);
|
|
|
+// orderDetails.setPrice(product.getRmbPrice());
|
|
|
+// orderDetails.setProductNumber(productNum);
|
|
|
+// orderDetails.setAmount(product.getRmbPrice().multiply(new BigDecimal(productNum)));
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setOrderSn(sn1);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setOrderSn(sn2);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// }
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ // key:"玫瑰精灵-A01",value:"0.50-1"
|
|
|
+ String value = map.get(key);
|
|
|
+ String[] GoodsInfo = key.split("-");
|
|
|
+ String[] GoodsValue = value.split("-");
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetails.setProductName(GoodsInfo[0]);
|
|
|
+ orderDetails.setProductNo(GoodsInfo[1]);
|
|
|
+ orderDetails.setPrice(new BigDecimal(GoodsValue[0]).divide(new BigDecimal(GoodsValue[1])).setScale(2));
|
|
|
+ orderDetails.setProductNumber(Integer.valueOf(GoodsValue[1]));
|
|
|
+ orderDetails.setAmount(new BigDecimal(GoodsValue[0]).setScale(2));
|
|
|
orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
orderDetails.setOrderSn(sn1);
|
|
|
orderDetailsService.save(orderDetails);
|
|
@@ -2048,7 +2107,8 @@ public class TOrderController {
|
|
|
price = price.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
} else {
|
|
|
// 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
- price = BigDecimal.ZERO;
|
|
|
+// price = BigDecimal.ZERO;
|
|
|
+ return JsonMessage.success("0");
|
|
|
}
|
|
|
} else {
|
|
|
price = price.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -2338,6 +2398,10 @@ public class TOrderController {
|
|
|
for (String key : productNameMap.keySet()) {
|
|
|
String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
+ boolean hasDuplicate = hasDuplicateValue(value);
|
|
|
+ if (hasDuplicate) {
|
|
|
+ return JsonMessage.error("优惠码输入重复,单个商品只能使用一个优惠码");
|
|
|
+ }
|
|
|
List<TPromoCode> promoCodeList = new ArrayList<>();
|
|
|
// 1、校验优惠码
|
|
|
if(value.size()>0){
|
|
@@ -2382,10 +2446,10 @@ public class TOrderController {
|
|
|
//旧优惠码
|
|
|
return JsonMessage.success("0");
|
|
|
}
|
|
|
- if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
- //0折
|
|
|
- return JsonMessage.success("0");
|
|
|
- }
|
|
|
+// if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
+// //0折
|
|
|
+// return JsonMessage.success("0");
|
|
|
+// }
|
|
|
promoCodeList.add(promoCode);
|
|
|
}
|
|
|
}
|
|
@@ -2429,7 +2493,8 @@ public class TOrderController {
|
|
|
for( i = 0;i<promoCodeList.size();i++){
|
|
|
BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
BigDecimal price1 = new BigDecimal(0.0);
|
|
|
- if (StringUtils.isNotEmpty(promoCodeList.get(i).getType()) && promoCodeList.get(i).getType().equals("1")) {
|
|
|
+ TPromoCode tPromoCode = promoCodeList.get(i);
|
|
|
+ if (StringUtils.isNotEmpty(tPromoCode.getType()) && tPromoCode.getType().equals("1")) {
|
|
|
if (productPrice.compareTo(discount) > 0) {
|
|
|
// 如果 price 大于 discount,从 price 中减去 discount
|
|
|
price1 = productPrice.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
@@ -2438,7 +2503,11 @@ public class TOrderController {
|
|
|
price1 = BigDecimal.ZERO;
|
|
|
}
|
|
|
} else {
|
|
|
- price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ if (tPromoCode.getDiscount() == 0) {
|
|
|
+ price1 = BigDecimal.ZERO;
|
|
|
+ } else {
|
|
|
+ price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ }
|
|
|
}
|
|
|
// BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
price = price.add(price1);
|
|
@@ -2539,7 +2608,10 @@ public class TOrderController {
|
|
|
|
|
|
Long equipmentId = equipment.getId();
|
|
|
//查找商品
|
|
|
- if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ if(BigDecimal.ZERO.compareTo(price) == 0) {
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) > 0) {
|
|
|
return JsonMessage.error("商品价格异常");
|
|
|
}
|
|
|
Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
@@ -2706,6 +2778,18 @@ public class TOrderController {
|
|
|
} else {
|
|
|
productName1 = productName + "-" + equipment.getName() + "-" + client6;
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ String[] products = order.getNote().split(",");
|
|
|
+ for (String product : products) {
|
|
|
+ String[] parts = product.split(":");
|
|
|
+ // 商品名称-商品编号
|
|
|
+ String key = parts[0];
|
|
|
+ // 商品单价-商品数量
|
|
|
+ String value = parts[1];
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
String result = null;
|
|
|
if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
// 汇付分账参数
|
|
@@ -2743,16 +2827,30 @@ public class TOrderController {
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
kindData.put("sn", sn1+"-"+sn2);
|
|
|
kindData.put("rd_Pic", qrcode);
|
|
|
- for (String key : productMap.keySet()) {
|
|
|
- Integer productNum = productMap.get(key);
|
|
|
- String[] split = key.split("-");
|
|
|
- BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
+// for (String key : productMap.keySet()) {
|
|
|
+// Integer productNum = productMap.get(key);
|
|
|
+// String[] split = key.split("-");
|
|
|
+// BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setProductNo(productNo);
|
|
|
+// orderDetails.setProductName(split[0]);
|
|
|
+// orderDetails.setPrice(unitPrice);
|
|
|
+// orderDetails.setProductNumber(productNum);
|
|
|
+// orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+// orderDetails.setOrderSn(sn2);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// }
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ // key:"玫瑰精灵-A01",value:"0.50-1"
|
|
|
+ String value = map.get(key);
|
|
|
+ String[] GoodsInfo = key.split("-");
|
|
|
+ String[] GoodsValue = value.split("-");
|
|
|
orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
- orderDetails.setProductNo(productNo);
|
|
|
- orderDetails.setProductName(split[0]);
|
|
|
- orderDetails.setPrice(unitPrice);
|
|
|
- orderDetails.setProductNumber(productNum);
|
|
|
- orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+ orderDetails.setProductName(GoodsInfo[0]);
|
|
|
+ orderDetails.setProductNo(GoodsInfo[1]);
|
|
|
+ orderDetails.setPrice(new BigDecimal(GoodsValue[0]).divide(new BigDecimal(GoodsValue[1])).setScale(2));
|
|
|
+ orderDetails.setProductNumber(Integer.valueOf(GoodsValue[1]));
|
|
|
+ orderDetails.setAmount(new BigDecimal(GoodsValue[0]).setScale(2));
|
|
|
orderDetails.setOrderSn(sn2);
|
|
|
orderDetailsService.save(orderDetails);
|
|
|
}
|
|
@@ -2795,15 +2893,33 @@ public class TOrderController {
|
|
|
kindData.put("sn", sn1+"-"+sn2);
|
|
|
kindData.put("rd_Pic", rd_Pic);
|
|
|
// 添加到订单明细表
|
|
|
- for (String key : productMap.keySet()) {
|
|
|
- Integer productNum = productMap.get(key);
|
|
|
- String[] split = key.split("-");
|
|
|
- BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
- orderDetails.setProductNo(productNo);
|
|
|
- orderDetails.setProductName(split[0]);
|
|
|
- orderDetails.setPrice(unitPrice);
|
|
|
- orderDetails.setProductNumber(productNum);
|
|
|
- orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+// for (String key : productMap.keySet()) {
|
|
|
+// Integer productNum = productMap.get(key);
|
|
|
+// String[] split = key.split("-");
|
|
|
+// BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
+// orderDetails.setProductNo(productNo);
|
|
|
+// orderDetails.setProductName(split[0]);
|
|
|
+// orderDetails.setPrice(unitPrice);
|
|
|
+// orderDetails.setProductNumber(productNum);
|
|
|
+// orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setOrderSn(sn1);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+// orderDetails.setOrderSn(sn2);
|
|
|
+// orderDetailsService.save(orderDetails);
|
|
|
+// }
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ // key:"玫瑰精灵-A01",value:"0.50-1"
|
|
|
+ String value = map.get(key);
|
|
|
+ String[] GoodsInfo = key.split("-");
|
|
|
+ String[] GoodsValue = value.split("-");
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetails.setProductName(GoodsInfo[0]);
|
|
|
+ orderDetails.setProductNo(GoodsInfo[1]);
|
|
|
+ orderDetails.setPrice(new BigDecimal(GoodsValue[0]).divide(new BigDecimal(GoodsValue[1])).setScale(2));
|
|
|
+ orderDetails.setProductNumber(Integer.valueOf(GoodsValue[1]));
|
|
|
+ orderDetails.setAmount(new BigDecimal(GoodsValue[0]).setScale(2));
|
|
|
orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
orderDetails.setOrderSn(sn1);
|
|
|
orderDetailsService.save(orderDetails);
|
|
@@ -4668,6 +4784,18 @@ public class TOrderController {
|
|
|
return altInfo.toString();
|
|
|
}
|
|
|
|
|
|
+ public boolean hasDuplicateValue(List<String> values) {
|
|
|
+ Set<String> uniqueValues = new HashSet<>();
|
|
|
+ for (String value : values) {
|
|
|
+ if (!uniqueValues.add(value)) {
|
|
|
+ // 如果添加失败,说明已存在相同的值,返回 true
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果循环结束仍未找到相同的值,则返回 false
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 汇聚查询退款更新订单状态
|
|
|
*
|