|
@@ -20,6 +20,7 @@ import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.*;
|
|
|
import com.szwl.model.query.TAdminParam;
|
|
|
+import com.szwl.model.utils.DateUtils;
|
|
|
import com.szwl.model.utils.JoinpayConstant;
|
|
|
import com.szwl.model.utils.PushUtils;
|
|
|
import com.szwl.service.*;
|
|
@@ -42,6 +43,8 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.szwl.model.utils.DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
@@ -1910,6 +1913,7 @@ public class TOrderController {
|
|
|
if(equipment==null||equipment.getId()==null){
|
|
|
return JsonMessage.error("找不到设备");
|
|
|
}
|
|
|
+ List<TPromoCode> promoCodeAll = new ArrayList<>();
|
|
|
BigDecimal price = new BigDecimal("0.00");
|
|
|
// JSONObject mapList = JSON.parseObject(productNameMap);
|
|
|
TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
@@ -1987,30 +1991,46 @@ public class TOrderController {
|
|
|
return JsonMessage.success("0");
|
|
|
}
|
|
|
promoCodeList.add(promoCode);
|
|
|
+ promoCodeAll.add(promoCode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- productName.append(productNamea).append(num);
|
|
|
- note.append(productNamea).append(num).append(":");
|
|
|
- productName1.append(productNamea).append(num);
|
|
|
- //确定价格,然后叠加R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea.toString()));
|
|
|
if (product == null) {
|
|
|
return JsonMessage.error("找不到商品");
|
|
|
}
|
|
|
+ productName.append(productNamea).append(num);
|
|
|
+ String no = product.getNo();
|
|
|
+ if(StringUtils.isEmpty(no)){
|
|
|
+ no="A00";
|
|
|
+ }
|
|
|
+ note.append(no).append("-").append(productNamea).append("-").append(num).append(":");
|
|
|
+ productName1.append(productNamea).append(num);
|
|
|
+ //确定价格,然后叠加R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
+
|
|
|
BigDecimal productPrice = product.getRmbPrice();
|
|
|
if(promoCodeList.size()>0){
|
|
|
//有优惠码
|
|
|
BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
int i;
|
|
|
for( i = 0;i<promoCodeList.size();i++){
|
|
|
- BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
- BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
- price = price.add(price1);
|
|
|
- onePrice = onePrice.add(price1);
|
|
|
+ TPromoCode tPromoCode = promoCodeList.get(i);
|
|
|
+ BigDecimal discount = BigDecimal.valueOf(tPromoCode.getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ if(StringUtils.isEmpty(tPromoCode.getType())||tPromoCode.getType().equals("0")){
|
|
|
+ //折扣优惠码
|
|
|
+ BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ price = price.add(price1);
|
|
|
+ onePrice = onePrice.add(price1);
|
|
|
+ }else {
|
|
|
+ //折扣价优惠码
|
|
|
+ BigDecimal price1 = productPrice.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ price = price.add(price1);
|
|
|
+ onePrice = onePrice.add(price1);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if(i<Integer.valueOf(num)){
|
|
|
int a = Integer.valueOf(num)-i;
|
|
@@ -2093,9 +2113,9 @@ public class TOrderController {
|
|
|
// return JsonMessage.error("找不到商品");
|
|
|
// }
|
|
|
|
|
|
- if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
- return JsonMessage.error("商品价格异常");
|
|
|
- }
|
|
|
+// if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+// return JsonMessage.error("商品价格异常");
|
|
|
+// }
|
|
|
String sn1 = orderService.initSn(equipmentId);
|
|
|
// String sn2 = orderService.initSn(equipmentId);
|
|
|
//获取分销 关联设备
|
|
@@ -2299,6 +2319,7 @@ public class TOrderController {
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
|
order.setSn(sn1);
|
|
|
+ order.setProductDesc(String.valueOf(productNameMap));
|
|
|
// order.setProductId(product.getId());
|
|
|
// order.setProductNo(product.getNo());
|
|
|
order.setProductName(productName.toString());
|
|
@@ -2340,6 +2361,19 @@ public class TOrderController {
|
|
|
order.setWxId(Long.valueOf(id));
|
|
|
}
|
|
|
orderService.save(order);
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ order.setStatus(1);
|
|
|
+ orderService.updateById(order);
|
|
|
+ //修改优惠码状态
|
|
|
+ if(promoCodeAll.size()>0){
|
|
|
+ for(TPromoCode code:promoCodeAll){
|
|
|
+ szwlFeign.updatePromoCode(String.valueOf(code.getId()),"2");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //发送远程命令到机器那边,让机器做糖
|
|
|
+ equipmentService.sentMessage(equipment.getClientId(),PushUtils.buildJson("cardPayXCX", String.valueOf(productNameMap)).toString());
|
|
|
+ return JsonMessage.success("支付成功");
|
|
|
+ }
|
|
|
Iterator<Object> iterator = altInfo.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
JSONObject jsonObject = (JSONObject) iterator.next();
|
|
@@ -2455,8 +2489,17 @@ public class TOrderController {
|
|
|
kindData.put("productName", order.getProductName());
|
|
|
|
|
|
TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- String gtClientId = byClientId.getGtClientId();
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+// String gtClientId = byClientId.getGtClientId();
|
|
|
+ if(order.getFrpCode().equals("WEIXIN_XCX")){
|
|
|
+ TSzsmWx szsmWx = szsmWxService.getById(order.getWxId());
|
|
|
+ BigDecimal integral = szsmWx.getIntegral();
|
|
|
+ integral = order.getPrice().add(integral);
|
|
|
+ szsmWxService.updateById(szsmWx);
|
|
|
+ equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("cardPayXCX", order.getProportionDesc()).toString());
|
|
|
+
|
|
|
+ }else {
|
|
|
+ equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+ }
|
|
|
// PushUtils.push(gtClientId, "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
// order.setNote(gtClientId + "已推送");
|
|
|
try {
|