|
@@ -1,28 +1,25 @@
|
|
|
package com.kmall.admin.cuspay.biz.merch;
|
|
|
|
|
|
-import com.kmall.admin.cuspay.biz.CuspayBiz;
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
import com.kmall.admin.cuspay.common.contant.MerchNoticeDict;
|
|
|
+import com.kmall.admin.cuspay.util.Contants;
|
|
|
import com.kmall.admin.dao.cuspay.merch.MerchNotiMapper;
|
|
|
import com.kmall.admin.cuspay.entity.merch.MerchNoti;
|
|
|
-import com.kmall.admin.cuspay.support.msg.resp.ResponseMessage;
|
|
|
-import com.kmall.admin.cuspay.support.msg.resp.ResponseStatus;
|
|
|
-import com.kmall.admin.cuspay.util.OkHttpUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.google.common.collect.Maps;
|
|
|
-import com.google.gson.Gson;
|
|
|
-import okhttp3.Request;
|
|
|
-import okhttp3.RequestBody;
|
|
|
+import com.kmall.admin.haikong.constant.Constants;
|
|
|
+import com.kmall.admin.service.OrderProcessRecordService;
|
|
|
+import com.kmall.admin.service.OrderService;
|
|
|
+import com.kmall.admin.service.PickUpCodeService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 商户通知请求回执
|
|
@@ -36,7 +33,7 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Component
|
|
|
@PropertySource(value = {"classpath:conf/cuspay/cuspay-merch-notice.properties"})
|
|
|
-public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
+public class MerchantNoticeBiz {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(MerchantNoticeBiz.class);
|
|
|
|
|
|
@Autowired
|
|
@@ -47,8 +44,16 @@ public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
@Autowired
|
|
|
private MerchNotiMapper merchNotiMapper;
|
|
|
|
|
|
- @Override
|
|
|
- public void biz(Map<String, Object> params) {
|
|
|
+ @Autowired
|
|
|
+ private PickUpCodeService pickUpCodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderProcessRecordService orderProcessRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderService orderService;
|
|
|
+
|
|
|
+ public void biz() {
|
|
|
limit = Integer.parseInt(environment.getProperty("db.merch.notice.limit"));
|
|
|
|
|
|
limit = (limit != null && limit > 0) ? limit : 20;
|
|
@@ -64,7 +69,7 @@ public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
|
|
|
notis.forEach(noti->{
|
|
|
|
|
|
- if (noti.getNotifyUrl() == null) {
|
|
|
+ if (StringUtils.isEmpty(noti.getNotifyUrl())) {
|
|
|
logger.error("商户通知回调接口为空");
|
|
|
noti.setNotiStatue(MerchNoticeDict.NoticeStatus.i_3.getItem()); //发送失败
|
|
|
noti.setIsStoped(MerchNoticeDict.IsStopStatus.i_1.getItem());
|
|
@@ -72,7 +77,7 @@ public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (noti.getNotiCount() == null || noti.getNotiCount() <= 0) {
|
|
|
+ if (Objects.isNull(noti.getNotiCount()) || noti.getNotiCount() <= 0) {
|
|
|
logger.error("通知商户次数为空");
|
|
|
noti.setNotiStatue(MerchNoticeDict.NoticeStatus.i_3.getItem()); //发送失败
|
|
|
noti.setIsStoped(MerchNoticeDict.IsStopStatus.i_1.getItem());
|
|
@@ -80,28 +85,32 @@ public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //组装需要请求的参数
|
|
|
- String jsonStr = createJsonByNoti(noti);
|
|
|
- logger.info("商户通知回调参数Parameters:"+ jsonStr);
|
|
|
-
|
|
|
- int counter = 0;
|
|
|
-
|
|
|
- while (counter < noti.getNotiCount()) {
|
|
|
- ++counter;
|
|
|
-
|
|
|
- Request request = OkHttpUtils.buildRequest(noti.getNotifyUrl(),
|
|
|
- RequestBody.create(OkHttpUtils.JSON, jsonStr));
|
|
|
- String result = null;
|
|
|
- try{
|
|
|
- result = OkHttpUtils.post(request);
|
|
|
- noti.setNotiStatue(MerchNoticeDict.NoticeStatus.i_2.getItem()); //通知发送成功
|
|
|
- noti.setIsStoped(MerchNoticeDict.IsStopStatus.i_1.getItem());//停止通知
|
|
|
- break;
|
|
|
- }catch (IOException e) {
|
|
|
- logger.error("商户回调通知异常", e);
|
|
|
- noti.setNotiStatue(MerchNoticeDict.NoticeStatus.i_3.getItem()); //发送失败
|
|
|
- noti.setIsStoped(MerchNoticeDict.IsStopStatus.i_1.getItem());
|
|
|
+ if(Constants.DocStatus.item_12.getItem().equals(noti.getCusDeclStatus())){
|
|
|
+ // 身份信息不一致
|
|
|
+ if("2".equals(noti.getBuyerPayerCheck())){
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 新增修改kmall中取货码表的状态
|
|
|
+ Map<String,String> pickUpCodeMap = new HashMap<>();
|
|
|
+ pickUpCodeMap.put("orderSn", noti.getOrderSn());
|
|
|
+ pickUpCodeMap.put("pickUpCodeSn","4");
|
|
|
+ pickUpCodeService.updatePickUpCode(pickUpCodeMap);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, Object> recordMap = ImmutableMap.of("orderSn", noti.getOrderSn(), "paymentSuccTime", new Date(),"isPaymentSend", Contants.WX_SUCC);
|
|
|
+ orderProcessRecordService.updateMallOrderProcessRecord(recordMap);
|
|
|
+ Map<String, Object> alipayMap = ImmutableMap.of("orderSn", noti.getOrderSn(), "buyerPayCheck", noti.getBuyerPayerCheck());
|
|
|
+ orderService.updateBuyerPayCheck(alipayMap);
|
|
|
+
|
|
|
+ }else if(Constants.DocStatus.item_13.getItem().equals(noti.getCusDeclStatus())){
|
|
|
+ Map<String, Object> recordMap = ImmutableMap.of("orderSn", noti.getOrderSn(), "paymentSuccTime", new Date(),"isPaymentSend", Contants.WX_FAIL);
|
|
|
+ orderProcessRecordService.updateMallOrderProcessRecord(recordMap);
|
|
|
+
|
|
|
}
|
|
|
noticeList.add(noti);
|
|
|
});
|
|
@@ -117,31 +126,6 @@ public class MerchantNoticeBiz implements CuspayBiz{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String createJsonByNoti(MerchNoti noti) {
|
|
|
- Map<String, String> request = Maps.newHashMap();
|
|
|
- request.put("merchErpOrderSn",noti.getMerchErpOrderSn());
|
|
|
- request.put("merchSn", noti.getMerchSn());
|
|
|
- request.put("allPaySn",noti.getAllPaySn());
|
|
|
- request.put("allPayNo",noti.getAllPayNo());
|
|
|
- request.put("allMerchId",noti.getAllMerchId());
|
|
|
- request.put("allSubOrderNo",noti.getAllSubOrderNo());
|
|
|
- request.put("buyerPayerCheck",noti.getBuyerPayerCheck());
|
|
|
- request.put("payChnlFlag",noti.getPayChnlFlag());
|
|
|
- request.put("code",noti.getCode());
|
|
|
- request.put("msg",noti.getMsg());
|
|
|
- request.put("cusDeclStatus", noti.getCusDeclStatus());
|
|
|
- request.put("thirdPartyMerchCode",noti.getThirdPartyMerchCode());
|
|
|
- request.put("thirdPartyMerchName",noti.getThirdPartyMerchName());
|
|
|
- request.put("platNo", noti.getPlatSn());
|
|
|
- request.put("platName", noti.getPlatName());
|
|
|
- request.put("merchOrderSn",noti.getAllSubOrderId());
|
|
|
-
|
|
|
- ResponseMessage responseMessage = new ResponseMessage.Builder()
|
|
|
- .setCode(ResponseStatus.SUCCESS.getItem())
|
|
|
- .setData(request).build();
|
|
|
- return new Gson().toJson(responseMessage);
|
|
|
- }
|
|
|
-
|
|
|
public void bizsTest() {
|
|
|
logger.info("测试定时执行11");
|
|
|
logger.info("测试定时执行11");
|