|
@@ -29,6 +29,7 @@ import com.szwl.model.utils.*;
|
|
|
import com.szwl.service.*;
|
|
|
import com.szwl.service.es.EsTOrderService;
|
|
|
import com.szwl.utils.HuifuUtils;
|
|
|
+import com.szwl.utils.IDGenerator;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -260,6 +261,7 @@ public class TOrderController {
|
|
|
}
|
|
|
Integer productNumber = 1;
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
@@ -526,6 +528,7 @@ public class TOrderController {
|
|
|
BigDecimal marketingAmount = null;
|
|
|
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
@@ -640,12 +643,12 @@ public class TOrderController {
|
|
|
*
|
|
|
* @param clientId 设备client id
|
|
|
* @param productName 商品名称
|
|
|
- * @param
|
|
|
+ * @param pri DIY花型价格
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "请求在线支付 二码合一")
|
|
|
@GetMapping("/twoPayCode")
|
|
|
- public Object twoPayCode(String code, String clientId, String productName) {
|
|
|
+ public Object twoPayCode(String code, String clientId, String productName, String pri) {
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
if(equipment==null||equipment.getId()==null){
|
|
|
return JsonMessage.error("找不到设备");
|
|
@@ -704,17 +707,27 @@ public class TOrderController {
|
|
|
|
|
|
Long equipmentId = equipment.getId();
|
|
|
//查找商品
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
- if (product == null) {
|
|
|
- return JsonMessage.error("找不到商品");
|
|
|
+ BigDecimal price;
|
|
|
+ Long productId = null;
|
|
|
+ // A99:DIY花型
|
|
|
+ String productNo = "A99";
|
|
|
+ if (StringUtils.isEmpty(pri)) {
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
+ if (product == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ price = product.getRmbPrice();
|
|
|
+ productId = product.getId();
|
|
|
+ productNo = product.getNo();
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ return JsonMessage.error("商品价格异常");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ price = new BigDecimal(pri);
|
|
|
}
|
|
|
- BigDecimal price = product.getRmbPrice();
|
|
|
if(StringUtils.isNotEmpty(code)){
|
|
|
BigDecimal discount = BigDecimal.valueOf(promoCode.getDiscount());
|
|
|
- price = product.getRmbPrice().multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
- }
|
|
|
- if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
- return JsonMessage.error("商品价格异常");
|
|
|
+ price = price.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
}
|
|
|
String sn1 = orderService.initSn(equipmentId);
|
|
|
String sn2 = orderService.initSn(equipmentId);
|
|
@@ -765,12 +778,13 @@ public class TOrderController {
|
|
|
Integer productNumber = 1;
|
|
|
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
|
order.setSn(sn1);
|
|
|
- order.setProductId(product.getId());
|
|
|
- order.setProductNo(product.getNo());
|
|
|
+ order.setProductId(productId);
|
|
|
+ order.setProductNo(productNo);
|
|
|
order.setProductName(productName);
|
|
|
order.setProductNumber(productNumber);
|
|
|
order.setPrice(price);
|
|
@@ -808,12 +822,13 @@ public class TOrderController {
|
|
|
order.setIsSettlement("0");
|
|
|
}
|
|
|
TOrder order2 = new TOrder();
|
|
|
+ order2.setId(IDGenerator.orderID());
|
|
|
order2.setCreateDate(new Date());
|
|
|
order2.setModifyDate(new Date());
|
|
|
order2.setAdminId(admin.getId());
|
|
|
order2.setSn(sn2);
|
|
|
- order2.setProductId(product.getId());
|
|
|
- order2.setProductNo(product.getNo());
|
|
|
+ order2.setProductId(productId);
|
|
|
+ order2.setProductNo(productNo);
|
|
|
order2.setProductName(productName);
|
|
|
order2.setProductNumber(productNumber);
|
|
|
order2.setPrice(price);
|
|
@@ -857,7 +872,7 @@ public class TOrderController {
|
|
|
orderDetails.setCreateDate(new Date());
|
|
|
orderDetails.setPrice(price);
|
|
|
orderDetails.setProductName(productName);
|
|
|
- orderDetails.setProductNo(product.getNo());
|
|
|
+ orderDetails.setProductNo(productNo);
|
|
|
orderDetails.setProductNumber(productNumber);
|
|
|
orderDetails.setAmount(price);
|
|
|
orderDetails.setCompanyType(companyType);
|
|
@@ -1182,6 +1197,7 @@ public class TOrderController {
|
|
|
String frpCode2 = "ALIPAY_NATIVE";
|
|
|
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
@@ -1231,6 +1247,7 @@ public class TOrderController {
|
|
|
}
|
|
|
order.setNote(note.toString());
|
|
|
TOrder order2 = new TOrder();
|
|
|
+ order2.setId(IDGenerator.orderID());
|
|
|
order2.setCreateDate(new Date());
|
|
|
order2.setModifyDate(new Date());
|
|
|
order2.setAdminId(admin.getId());
|
|
@@ -1689,6 +1706,7 @@ public class TOrderController {
|
|
|
String frpCode1 = "WEIXIN_XCX";
|
|
|
BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
@@ -2013,8 +2031,12 @@ public class TOrderController {
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
- }
|
|
|
+ if (!order.getIsNotified().equals("1")) {
|
|
|
+ String paySuccess = equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+ if (paySuccess.equals("success")) {
|
|
|
+ order.setIsNotified("1");
|
|
|
+ }
|
|
|
+ } }
|
|
|
orderService.updateById(order);
|
|
|
// equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
try {
|
|
@@ -2025,14 +2047,19 @@ public class TOrderController {
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- try {
|
|
|
+ // try {
|
|
|
+ LambdaQueryWrapper<TOrderTask> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(TOrderTask::getSn, sn);
|
|
|
+ TOrderTask oldOrderTask = orderTaskService.getOne(queryWrapper);
|
|
|
+ if (oldOrderTask == null) {
|
|
|
TOrderTask orderTask = new TOrderTask();
|
|
|
BeanUtils.copyPropertiesIgnoreNull(order, orderTask, true);
|
|
|
orderTask.setAgencyId(order.getId());
|
|
|
orderTaskService.save(orderTask);
|
|
|
- }catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
+// }catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
//传送数据
|
|
|
sentJingZhun(order);
|
|
|
return R.ok("支付成功");
|
|
@@ -2041,8 +2068,12 @@ public class TOrderController {
|
|
|
String gtClientId = equipment.getGtClientId();
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
kindData.put("sn", order.getSn());
|
|
|
- equipmentService.sentMessage(equipment.getClientId(),PushUtils.buildJson("pay_faile", kindData.toString()).toString());
|
|
|
- order.setNote(gtClientId + "支付失败");
|
|
|
+ if (!order.getIsNotified().equals("2")) {
|
|
|
+ String payFail = equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_faile", kindData.toString()).toString());
|
|
|
+ if (payFail.equals("success")) {
|
|
|
+ order.setIsNotified("2");
|
|
|
+ }
|
|
|
+ } order.setNote(gtClientId + "支付失败");
|
|
|
orderService.updateById(order);
|
|
|
return R.fail(ResponseCodesEnum.A0001,"支付失败");
|
|
|
}
|
|
@@ -2055,7 +2086,7 @@ public class TOrderController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/notify", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Object refund(HttpServletRequest request) {
|
|
|
+ public String notify(HttpServletRequest request) {
|
|
|
|
|
|
String r6_Status = request.getParameter("r6_Status");
|
|
|
|
|
@@ -2144,7 +2175,12 @@ public class TOrderController {
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+ if (!order.getIsNotified().equals("1")) {
|
|
|
+ String paySuccess = equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+ if (paySuccess.equals("success")) {
|
|
|
+ order.setIsNotified("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
orderService.updateById(order);
|
|
|
|
|
@@ -2156,14 +2192,19 @@ public class TOrderController {
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- try {
|
|
|
+// try {
|
|
|
+ LambdaQueryWrapper<TOrderTask> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(TOrderTask::getSn, sn);
|
|
|
+ TOrderTask oldOrderTask = orderTaskService.getOne(queryWrapper);
|
|
|
+ if (oldOrderTask == null) {
|
|
|
TOrderTask orderTask = new TOrderTask();
|
|
|
BeanUtils.copyPropertiesIgnoreNull(order, orderTask, true);
|
|
|
orderTask.setAgencyId(order.getId());
|
|
|
orderTaskService.save(orderTask);
|
|
|
- }catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
+// }catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
//传送数据
|
|
|
sentJingZhun(order);
|
|
|
return "success";
|
|
@@ -2172,13 +2213,18 @@ public class TOrderController {
|
|
|
String gtClientId = byClientId.getGtClientId();
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
kindData.put("sn", order.getSn());
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(),PushUtils.buildJson("pay_faile", kindData.toString()).toString());
|
|
|
+ if (!order.getIsNotified().equals("2")) {
|
|
|
+ String payFail = equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_faile", kindData.toString()).toString());
|
|
|
+ if (payFail.equals("success")) {
|
|
|
+ order.setIsNotified("2");
|
|
|
+ }
|
|
|
+ }
|
|
|
order.setNote(gtClientId + "支付失败");
|
|
|
orderService.updateById(order);
|
|
|
+ return "success";
|
|
|
}
|
|
|
-
|
|
|
- return "success";
|
|
|
}
|
|
|
+
|
|
|
//发送两次mq
|
|
|
private void sendMqTwo(String clientId, String kind) {
|
|
|
// 定时任务1
|
|
@@ -2844,7 +2890,7 @@ public class TOrderController {
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "添加订单")
|
|
|
+ @ApiOperation(value = "添加国内订单")
|
|
|
@PostMapping("/addOrder")
|
|
|
public ResponseModel<?> addOrder(@RequestBody TOrder order) {
|
|
|
boolean save = orderService.save(order);
|
|
@@ -3090,6 +3136,7 @@ public class TOrderController {
|
|
|
|
|
|
TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|