|
@@ -2884,151 +2884,184 @@ public class TOrderController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/huifuNotify", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public ResponseModel<?> huifuNotify(HttpServletRequest request) {
|
|
|
+ public String huifuNotify(HttpServletRequest request) {
|
|
|
String respData = request.getParameter("resp_data");
|
|
|
- JSONObject data = JSONObject.parseObject(respData);
|
|
|
- String transStat = data.getString("trans_stat");
|
|
|
- // 订单号
|
|
|
- String sn = data.getString("req_seq_id");
|
|
|
- if(StrUtil.hasEmpty(sn)) {
|
|
|
- return R.fail(ResponseCodesEnum.A0001,"订单号为空!");
|
|
|
- }
|
|
|
- // 查到指定订单
|
|
|
- LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(TOrder::getSn,sn);
|
|
|
- TOrder order = orderService.getOne(wrapper);
|
|
|
- if(HuifuConstant.TRANS_STAT_S.equals(transStat)) {
|
|
|
- // 查到对应订单明细表
|
|
|
- LambdaQueryWrapper<TOrderDetails> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(TOrderDetails::getOrderSn,sn);
|
|
|
- List<TOrderDetails> orderDetails = orderDetailsService.list(lambdaQueryWrapper);
|
|
|
- for (TOrderDetails orderDetail : orderDetails) {
|
|
|
- // 修改状态订单明细状态
|
|
|
- orderDetail.setRefundStatus("1");
|
|
|
- orderDetailsService.updateById(orderDetail);
|
|
|
- }
|
|
|
- // 已支付
|
|
|
- order.setStatus(1);
|
|
|
- // 支付平台产生的全局流水号:hf_seq_id
|
|
|
+ try{
|
|
|
+ // 验签请参sign
|
|
|
+ String sign = request.getParameter("sign");
|
|
|
+ // 使用汇付公钥验签
|
|
|
+ if (!RSAUtil.verify(respData, HuifuConstant.HUIFU_PUBLIC_KEY, sign)) {
|
|
|
+ // 验签失败处理
|
|
|
+ log.info("验签失败");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ JSONObject data = JSONObject.parseObject(respData);
|
|
|
+ String transStat = data.getString("trans_stat");
|
|
|
+ // 订单号
|
|
|
+ String sn = data.getString("req_seq_id");
|
|
|
+ if(StrUtil.hasEmpty(sn)) {
|
|
|
+// return "R.fail(ResponseCodesEnum.A0001,"订单号为空!")";
|
|
|
+ log.info("返回参数订单编号为空");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ // 查到指定订单
|
|
|
+ LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TOrder::getSn,sn);
|
|
|
+ wrapper.eq(TOrder::getStatus, 0);
|
|
|
+ TOrder order = orderService.getOne(wrapper);
|
|
|
+ if(order == null) {
|
|
|
+ log.info("找不到订单");
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if(HuifuConstant.TRANS_STAT_S.equals(transStat)) {
|
|
|
+ // 查到对应订单明细表
|
|
|
+ LambdaQueryWrapper<TOrderDetails> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(TOrderDetails::getOrderSn,sn);
|
|
|
+ List<TOrderDetails> orderDetails = orderDetailsService.list(lambdaQueryWrapper);
|
|
|
+ for (TOrderDetails orderDetail : orderDetails) {
|
|
|
+ // 修改状态订单明细状态
|
|
|
+ orderDetail.setRefundStatus("1");
|
|
|
+ orderDetailsService.updateById(orderDetail);
|
|
|
+ }
|
|
|
+ // 已支付
|
|
|
+ order.setStatus(1);
|
|
|
+ // 支付平台产生的全局流水号:hf_seq_id
|
|
|
// String hfSeqId = data.getString("hf_seq_id");
|
|
|
- // 支付平台产生的全局流水号:party_order_id
|
|
|
- String partyOrderId = data.getString("party_order_id");
|
|
|
- order.setTrxNo(partyOrderId);
|
|
|
- // 支付时间,格式:YYYY-MM-DD HH:mm:ss
|
|
|
- String payTime = data.getString("end_time");
|
|
|
- SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- // 临时表修改支付状态
|
|
|
- String id = data.getString("remark");
|
|
|
- if(StrUtil.isNotEmpty(id)) {
|
|
|
- LambdaQueryWrapper<THuifuTempOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(THuifuTempOrder::getId,id);
|
|
|
- THuifuTempOrder huifuTempOrder = huifuTempOrderService.getOne(queryWrapper);
|
|
|
- huifuTempOrder.setStatus(1);
|
|
|
- huifuTempOrderService.updateById(huifuTempOrder);
|
|
|
- }
|
|
|
- try {
|
|
|
- Date date = inputFormat.parse(URLDecoder.decode(payTime, "UTF-8"));
|
|
|
- String formattedDate = outputFormat.format(date);
|
|
|
- Date payDate = outputFormat.parse(URLDecoder.decode(formattedDate, "UTF-8"));
|
|
|
- order.setPayDate(payDate);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- // 修改订单信息
|
|
|
- orderService.updateById(order);
|
|
|
- //
|
|
|
- JSONObject kindData = new JSONObject();
|
|
|
- kindData.put("sn", order.getSn());
|
|
|
- kindData.put("productName", order.getProductName());
|
|
|
-
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- if(order.getFrpCode().equals("WEIXIN_XCX")){
|
|
|
- JSONObject kindData1 = new JSONObject();
|
|
|
- kindData1.put("sn", order.getSn());
|
|
|
- kindData1.put("productDesc", order.getProductDesc());
|
|
|
- String s = order.getId().toString();
|
|
|
- if(s.length()>6){
|
|
|
- s = s.substring(s.length()-6,s.length());
|
|
|
+ // 支付平台产生的全局流水号:party_order_id
|
|
|
+ String partyOrderId = data.getString("party_order_id");
|
|
|
+ order.setTrxNo(partyOrderId);
|
|
|
+ // 支付时间,格式:YYYY-MM-DD HH:mm:ss
|
|
|
+ String payTime = data.getString("end_time");
|
|
|
+ SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ // 临时表修改支付状态
|
|
|
+ String id = data.getString("remark");
|
|
|
+ if(StrUtil.isNotEmpty(id)) {
|
|
|
+ LambdaQueryWrapper<THuifuTempOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(THuifuTempOrder::getId,id);
|
|
|
+ THuifuTempOrder huifuTempOrder = huifuTempOrderService.getOne(queryWrapper);
|
|
|
+ huifuTempOrder.setStatus(1);
|
|
|
+ huifuTempOrderService.updateById(huifuTempOrder);
|
|
|
}
|
|
|
- kindData1.put("mealCode", s);
|
|
|
- order.setOrderStatus("-1");
|
|
|
- equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("cardPayXCX", kindData1.toString()).toString());
|
|
|
- if(StringUtils.isNotEmpty(equipment.getApkVersion())){
|
|
|
- //发送两次mq
|
|
|
- if(equipment.getApkVersion().equals("1.0.131-jz11")||equipment.getApkVersion().equals("1.0.131-jz12")||equipment.getApkVersion().equals("1.0.131-jz13")||equipment.getApkVersion().equals("1.0.131-jz14")||equipment.getApkVersion().equals("1.0.131-jz15")){
|
|
|
- sendMqTwo(equipment.getClientId(),kindData1.toString());
|
|
|
- }
|
|
|
+ try {
|
|
|
+ Date date = inputFormat.parse(URLDecoder.decode(payTime, "UTF-8"));
|
|
|
+ String formattedDate = outputFormat.format(date);
|
|
|
+ Date payDate = outputFormat.parse(URLDecoder.decode(formattedDate, "UTF-8"));
|
|
|
+ order.setPayDate(payDate);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- TSzsmWx szsmWx = szsmWxService.getById(order.getWxId());
|
|
|
- BigDecimal integral = szsmWx.getIntegral();
|
|
|
- if(integral!=null){
|
|
|
- integral = order.getPrice().add(integral);
|
|
|
+ // 修改订单信息
|
|
|
+ orderService.updateById(order);
|
|
|
+ //
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", order.getSn());
|
|
|
+ kindData.put("productName", order.getProductName());
|
|
|
+
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+ if(order.getFrpCode().equals("WEIXIN_XCX")){
|
|
|
+ JSONObject kindData1 = new JSONObject();
|
|
|
+ kindData1.put("sn", order.getSn());
|
|
|
+ kindData1.put("productDesc", order.getProductDesc());
|
|
|
+ String s = order.getId().toString();
|
|
|
+ if(s.length()>6){
|
|
|
+ s = s.substring(s.length()-6,s.length());
|
|
|
+ }
|
|
|
+ kindData1.put("mealCode", s);
|
|
|
+ order.setOrderStatus("-1");
|
|
|
+ equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("cardPayXCX", kindData1.toString()).toString());
|
|
|
+ if(StringUtils.isNotEmpty(equipment.getApkVersion())){
|
|
|
+ //发送两次mq
|
|
|
+ if(equipment.getApkVersion().equals("1.0.131-jz11")||equipment.getApkVersion().equals("1.0.131-jz12")||equipment.getApkVersion().equals("1.0.131-jz13")||equipment.getApkVersion().equals("1.0.131-jz14")||equipment.getApkVersion().equals("1.0.131-jz15")){
|
|
|
+ sendMqTwo(equipment.getClientId(),kindData1.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TSzsmWx szsmWx = szsmWxService.getById(order.getWxId());
|
|
|
+ BigDecimal integral = szsmWx.getIntegral();
|
|
|
+ if(integral!=null){
|
|
|
+ integral = order.getPrice().add(integral);
|
|
|
+ }else {
|
|
|
+ integral = order.getPrice();
|
|
|
+ }
|
|
|
+ szsmWx.setIntegral(integral);
|
|
|
+ szsmWxService.updateById(szsmWx);
|
|
|
+ if(StringUtils.isNotEmpty(order.getCoupons())){
|
|
|
+ String coupons = order.getCoupons();
|
|
|
+ coupons= coupons.substring(1,coupons.length()-1);
|
|
|
+ List<String> list1 = Arrays.asList(coupons);
|
|
|
+ if(list1.size()>0){
|
|
|
+ for(String code:list1){
|
|
|
+ szwlFeign.useYHJ(code, String.valueOf(order.getAdminId()),order.getClientId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else {
|
|
|
- integral = order.getPrice();
|
|
|
- }
|
|
|
- szsmWx.setIntegral(integral);
|
|
|
- szsmWxService.updateById(szsmWx);
|
|
|
- if(StringUtils.isNotEmpty(order.getCoupons())){
|
|
|
- String coupons = order.getCoupons();
|
|
|
- coupons= coupons.substring(1,coupons.length()-1);
|
|
|
- List<String> list1 = Arrays.asList(coupons);
|
|
|
- if(list1.size()>0){
|
|
|
- for(String code:list1){
|
|
|
- szwlFeign.useYHJ(code, String.valueOf(order.getAdminId()),order.getClientId());
|
|
|
+ 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");
|
|
|
+ // 推送微信订单
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(order.getAdminId())));
|
|
|
+ // 判断是否开启订单推送功能
|
|
|
+ if(admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
+ String openId = R.getDataIfSuccess(szwlFeign.getOpenId(order.getAdminId()));
|
|
|
+ // 获取openId
|
|
|
+ if(StringUtils.isNotEmpty(openId)) {
|
|
|
+ orderService.sendWechatMessage(openId, equipment, order, admin.getCompanyType());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
- 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 {
|
|
|
+ if(order.getProductNumber()==null||order.getProductNumber()==0){
|
|
|
+ order.setProductNumber(1);
|
|
|
}
|
|
|
+ orderFeign.saveToEs(order);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
- orderService.updateById(order);
|
|
|
-// equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
try {
|
|
|
- if(order.getProductNumber()==null||order.getProductNumber()==0){
|
|
|
- order.setProductNumber(1);
|
|
|
+ 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);
|
|
|
}
|
|
|
- orderFeign.saveToEs(order);
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- // 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();
|
|
|
-// }
|
|
|
- //传送数据
|
|
|
- sentJingZhun(order);
|
|
|
- return R.ok("支付成功");
|
|
|
- } else {
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- String gtClientId = equipment.getGtClientId();
|
|
|
- JSONObject kindData = new JSONObject();
|
|
|
- kindData.put("sn", order.getSn());
|
|
|
- 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");
|
|
|
+ //传送数据
|
|
|
+ sentJingZhun(order);
|
|
|
+// return R.ok("支付成功");
|
|
|
+ log.info("支付成功");
|
|
|
+ } else {
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+ String gtClientId = equipment.getGtClientId();
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", order.getSn());
|
|
|
+ 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,"支付失败");
|
|
|
+ order.setNote(gtClientId + "支付失败");
|
|
|
+ orderService.updateById(order);
|
|
|
+ log.info("支付失败");
|
|
|
+ }
|
|
|
+ return "RECV_ORD_ID_" + sn;
|
|
|
+ } catch (Exception e){
|
|
|
+ log.info("异步回调开始,参数,request={}", respData, e);
|
|
|
}
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -3046,6 +3079,7 @@ public class TOrderController {
|
|
|
String sn = request.getParameter("r2_OrderNo");
|
|
|
LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TOrder::getSn,sn);
|
|
|
+ query.eq(TOrder::getStatus, 0);
|
|
|
if(StringUtils.isEmpty(sn)){
|
|
|
return "error";
|
|
|
}
|
|
@@ -3089,7 +3123,7 @@ public class TOrderController {
|
|
|
kindData.put("sn", order.getSn());
|
|
|
kindData.put("productName", order.getProductName());
|
|
|
|
|
|
- TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
if(order.getFrpCode().equals("WEIXIN_XCX")){
|
|
|
JSONObject kindData1 = new JSONObject();
|
|
|
kindData1.put("sn", order.getSn());
|
|
@@ -3100,11 +3134,11 @@ public class TOrderController {
|
|
|
}
|
|
|
kindData1.put("mealCode", s);
|
|
|
order.setOrderStatus("-1");
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("cardPayXCX", kindData1.toString()).toString());
|
|
|
- if(StringUtils.isNotEmpty(byClientId.getApkVersion())){
|
|
|
+ equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("cardPayXCX", kindData1.toString()).toString());
|
|
|
+ if(StringUtils.isNotEmpty(equipment.getApkVersion())){
|
|
|
//发送两次mq
|
|
|
- if(byClientId.getApkVersion().equals("1.0.131-jz11")||byClientId.getApkVersion().equals("1.0.131-jz12")||byClientId.getApkVersion().equals("1.0.131-jz13")||byClientId.getApkVersion().equals("1.0.131-jz14")||byClientId.getApkVersion().equals("1.0.131-jz15")){
|
|
|
- sendMqTwo(byClientId.getClientId(),kindData1.toString());
|
|
|
+ if(equipment.getApkVersion().equals("1.0.131-jz11")||equipment.getApkVersion().equals("1.0.131-jz12")||equipment.getApkVersion().equals("1.0.131-jz13")||equipment.getApkVersion().equals("1.0.131-jz14")||equipment.getApkVersion().equals("1.0.131-jz15")){
|
|
|
+ sendMqTwo(equipment.getClientId(),kindData1.toString());
|
|
|
}
|
|
|
}
|
|
|
TSzsmWx szsmWx = szsmWxService.getById(order.getWxId());
|
|
@@ -3128,10 +3162,20 @@ public class TOrderController {
|
|
|
}
|
|
|
}else {
|
|
|
if (!order.getIsNotified().equals("1")) {
|
|
|
- String paySuccess = equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
+ String paySuccess = equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
if (paySuccess.equals("success")) {
|
|
|
order.setIsNotified("1");
|
|
|
}
|
|
|
+ // 推送微信订单
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(order.getAdminId())));
|
|
|
+ // 判断是否开启订单推送功能
|
|
|
+ if(admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
+ String openId = R.getDataIfSuccess(szwlFeign.getOpenId(order.getAdminId()));
|
|
|
+ // 获取openId
|
|
|
+ if(StringUtils.isNotEmpty(openId)) {
|
|
|
+ orderService.sendWechatMessage(openId, equipment, order, admin.getCompanyType());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
orderService.updateById(order);
|