推送邮政订单

master
YIN 2025-02-13 10:11:42 +08:00
parent a740e600cc
commit f8bcb36269
4 changed files with 82 additions and 7 deletions

View File

@ -5,11 +5,16 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.domain.BizOrderSub;
import com.cpxt.biz.domain.BizOrderSubStatusChangeLog;
import com.cpxt.biz.domain.OrderStatusChangePushEntity;
import com.cpxt.biz.mapper.BizOrderMapper;
import com.cpxt.biz.mapper.BizOrderSubMapper;
import com.cpxt.biz.mapper.BizOrderSubStatusChangeLogMapper;
import com.cpxt.common.annotation.Anonymous;
import com.cpxt.common.core.domain.AjaxResult;
import com.cpxt.common.utils.DateUtils;
import com.cpxt.common.utils.Helper;
import com.cpxt.common.utils.bean.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -32,6 +37,9 @@ public class OpenContrller {
@Autowired
private BizOrderSubMapper bizOrderSubMapper;
@Autowired
private BizOrderSubStatusChangeLogMapper logMapper;
/**
*
@ -56,7 +64,6 @@ public class OpenContrller {
if (ObjectUtil.isNotEmpty(orderStatusChangePushEntity.getRemark().getDeliverTime())){
bizOrderSub.setExpectTime(DateUtil.parseTime(orderStatusChangePushEntity.getRemark().getDeliverTime()));
}
bizOrderSubMapper.updateById(bizOrderSub);
// 修改订单信息(状态、开始配送时间和到达时间)
BizOrder bizOrder = bizOrderMapper.selectByOrderSn(bizOrderSub.getOrderSn());
String status = orderStatusChangePushEntity.getStatus();
@ -81,12 +88,21 @@ public class OpenContrller {
}else {
bizOrder.setStatus(4); //已取消
}
bizOrderSubMapper.updateById(bizOrderSub);
bizOrderMapper.updateById(bizOrder);
resultMap.put("code", 200);
resultMap.put("message", "操作成功!");
resultMap.put("result", "");
resultMap.put("success", "true");
}
BizOrderSubStatusChangeLog log = new BizOrderSubStatusChangeLog();
BeanUtils.copyProperties(orderStatusChangePushEntity, log);
log.setEmailNbr(orderStatusChangePushEntity.getRemark().getExpressNbr());
if (!Helper.NStr(orderStatusChangePushEntity.getRemark().getDeliverTime()).equals(""))
log.setDeliverTime(DateUtils.parseDate(orderStatusChangePushEntity.getRemark().getDeliverTime()));
logMapper.insert(log);
resultMap.put("timestamp",System.currentTimeMillis());
return resultMap;
}

View File

@ -9,10 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.*;
@RestController
@Slf4j
@ -113,4 +110,65 @@ public class TestContrller {
log.info("timestamp" + timeStamp);
log.info("sign" + genSign);
}
/**
* token
*/
@Anonymous
@GetMapping("/getToken")
public void getTokenPostMan() {
Long timeStamp = System.currentTimeMillis();
String nonce = UUID.randomUUID().toString().replace("-", "");
System.out.println("timeStamp" + timeStamp);
System.out.println("nonce" + nonce);
//body
Map map = new HashMap();
map.put("clientKey", clientKey);
map.put("clientSecret", clientSecret);
map.put("appType", appType);
map.put("clientType", client_type);
map.put("version", version);
Map<String, Object> sortedParams1 = new TreeMap<>(map);
Set<Map.Entry<String, Object>> entrySet1 = sortedParams1.entrySet();
StringBuilder stringToSign = new StringBuilder();
for (Map.Entry<String, Object> param : entrySet1) {
stringToSign.append(param.getKey()).append("=").append(param.getValue()).append(",");
}
String encryptBase64 = CityDelivery_SM4Util.encryptCBC(stringToSign.toString(), clientSecret, sm4Key);
System.out.println("body:" + encryptBase64);
//签名
Map<String, Object> sortedMap2 = new TreeMap<>();
//get请求组装成 k v类型
// sortedMap2.put(paramName,request.getParameter(paramName));
/**
* postdata
*/
Map bodyMap = new HashMap();
bodyMap.put("body", encryptBase64);
String bodyJson = JSON.toJSONString(bodyMap);
sortedMap2.put("data", JSON.toJSONString(bodyJson));
sortedMap2.put("access_id", clientKey);
sortedMap2.put("nonce", nonce);
sortedMap2.put("timestamp", timeStamp);
//排序
Map<String, Object> sortedParams2 = new TreeMap<>(sortedMap2);
Set<Map.Entry<String, Object>> entrySet2 = sortedParams2.entrySet();
// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
StringBuilder stringToSign2 = new StringBuilder();
for (Map.Entry<String, Object> param : entrySet2) {
stringToSign2.append(param.getKey()).append("=").append(param.getValue()).append(",");
}
stringToSign2.append("accessSecret").append("=").append(clientSecret);
// String genSign = DigestUtils.md5Hex(stringToSign2.toString());
String genSign = CityDelivery_SM4Util.encryptCBC(stringToSign2.toString(), clientSecret, sm4Key);
System.out.println("------------");
System.out.println("sign:" + genSign);
log.info("nonce" + nonce);
log.info("timestamp" + timeStamp);
log.info("sign" + genSign);
}
}

View File

@ -112,6 +112,7 @@ public class SecurityConfig
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
.antMatchers("/cpxt-api/**").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@ -397,7 +397,7 @@ public class BizOrderServiceImpl implements IBizOrderService {
bizOrderSubMapper.insert(bizOrderSub);
// 同步调用同城急送平台入口
// callThirdPartyInterface(bizOrder, subList.get(0), bizOrderSub);
callThirdPartyInterface(bizOrder, subList.get(0), bizOrderSub);
}
}
}else {
@ -420,7 +420,7 @@ public class BizOrderServiceImpl implements IBizOrderService {
bizOrderSubMapper.insert(bizOrderSub);
// 同步调用同城急送平台入口
// callThirdPartyInterface(bizOrder, map1, bizOrderSub);
callThirdPartyInterface(bizOrder, map1, bizOrderSub);
}
}
}