批量生成子单功能以及维护客户的code码

master
luojian 2025-02-11 17:11:18 +08:00
parent 6247b1eba6
commit 11f69ca5f0
3 changed files with 101 additions and 55 deletions

View File

@ -31,6 +31,10 @@ public class BizCustomer
@Excel(name = "客户全称")
private String fullName;
/** 客户代码(对接邮政系统) */
@Excel(name = "客户代码(对接邮政系统)")
private String code;
/** 联系人 */
@Excel(name = "联系人")
private String linkman;

View File

@ -6,11 +6,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.cpxt.biz.domain.BizCustomer;
import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.domain.BizOrderSub;
import com.cpxt.biz.domain.SysArea;
import com.cpxt.biz.mapper.BizCustomerMapper;
import com.cpxt.biz.mapper.SysAreaMapper;
import com.cpxt.common.annotation.Anonymous;
import com.cpxt.common.utils.DateUtils;
import com.cpxt.common.utils.Helper;
import com.cpxt.system.mapper.SysDictDataMapper;
@ -18,9 +19,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
@ -46,6 +44,9 @@ public class CityDelivery {
@Autowired
private SysAreaMapper sysAreaMapper;
@Autowired
private BizCustomerMapper bizCustomerMapper;
// test
String clientKey = "7480617400984563";//accessKey
String clientSecret = "91wCEvn82CeyMg3k";
@ -152,6 +153,9 @@ public class CityDelivery {
* post
*/
public String addOrder(BizOrder bizOrder,BizOrderSub bizOrderSub) {
BizCustomer bizCustomer = bizCustomerMapper.selectByName(bizOrder.getCustomerName());
String code = bizCustomer.getCode();
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/base/order/add";
String goodsType = bizOrderSub.getGoodsType();
String goodsTypeLabel = sysDictDataMapper.selectDictLabel("sys_goods_type", goodsType);
@ -279,7 +283,7 @@ public class CityDelivery {
Map<String, Object> sortedMap = new TreeMap<>();
//下单接口
String body = "{\n" +
" \"customerCode\": \"HFCP\",\n" +
" \"customerCode\": \"" + code + "\",\n" +
" \"payTypeFirst\": \"" + payType + "\",\n" +
" \"channelOrderNo\": \"" + subOrderSn + "\",\n" +
" \"platformOrderNo\": \"\",\n" +

View File

@ -361,8 +361,46 @@ public class BizOrderServiceImpl implements IBizOrderService {
@Override
@Transactional
public void insertBizOrderSub(Map map) {
String orderSn = (String) map.get("orderSn");
String orderSn = (String) map.get("orderSn"); // 订单号
Integer orderFee; // 订单总价
Integer totalQuantity = (Integer) map.get("totalQuantity"); // 运单总件数
if (ObjectUtil.isEmpty(map.get("orderFee"))) orderFee = 0;
else orderFee = (Integer) map.get("orderFee");
List<Map> subList = (List<Map>) map.get("sublist");
// 同步更新订单表的运单状态、订单费用、运单总件数
BizOrder bizOrder = bizOrderMapper.selectByOrderSn(orderSn);
bizOrder.setSubStatus(1);
bizOrder.setOrderFee(BigDecimal.valueOf(Helper.FDouble(orderFee)));
bizOrder.setTotalQuantity(totalQuantity);
bizOrderMapper.updateById(bizOrder);
// 判断是否是批量生成
Boolean showlist = (Boolean) map.get("showlist");
if (!showlist){ // 批量生成
if (totalQuantity != 0){
for (int i = 1; i <= totalQuantity; i++) {
BizOrderSub bizOrderSub = new BizOrderSub();
bizOrderSub.setOrderSn(orderSn);
bizOrderSub.setSubOrderSn(orderSn + "-" + i);
if (ObjectUtil.isNotEmpty(subList.get(0).get("weight"))) bizOrderSub.setWeight(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("weight"))));
if (ObjectUtil.isNotEmpty(subList.get(0).get("length"))) bizOrderSub.setLength(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("length"))));
if (ObjectUtil.isNotEmpty(subList.get(0).get("width"))) bizOrderSub.setWidth(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("width"))));
if (ObjectUtil.isNotEmpty(subList.get(0).get("height"))) bizOrderSub.setHeight(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("height"))));
if (ObjectUtil.isNotEmpty(subList.get(0).get("length")) && ObjectUtil.isNotEmpty(subList.get(0).get("width")) && ObjectUtil.isNotEmpty(subList.get(0).get("height"))){
bizOrderSub.setVolume(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("length"))).multiply(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("width")))).multiply(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("height")))));
}
bizOrderSub.setGoodsType((String) subList.get(0).get("goodsType"));
bizOrderSub.setGoodsName((String) subList.get(0).get("goodsName"));
if (ObjectUtil.isNotEmpty(subList.get(0).get("orderFee"))) bizOrderSub.setOrderFee(BigDecimal.valueOf(Helper.FDouble( subList.get(0).get("orderFee"))));
bizOrderSub.setRemark((String) subList.get(0).get("remark"));
bizOrderSubMapper.insert(bizOrderSub);
// 同步调用同城急送平台入口
// callThirdPartyInterface(bizOrder, subList.get(0), bizOrderSub);
}
}
}else {
for (Map map1 : subList) {
if (map1.get("orderSn").equals(orderSn)){
BizOrderSub bizOrderSub = new BizOrderSub();
@ -380,13 +418,15 @@ public class BizOrderServiceImpl implements IBizOrderService {
if (ObjectUtil.isNotEmpty(map1.get("orderFee"))) bizOrderSub.setOrderFee(BigDecimal.valueOf(Helper.FDouble( map1.get("orderFee"))));
bizOrderSub.setRemark((String) map1.get("remark"));
bizOrderSubMapper.insert(bizOrderSub);
// 同步更新订单表的运单状态
BizOrder bizOrder = bizOrderMapper.selectByOrderSn(orderSn);
bizOrder.setSubStatus(1);
bizOrderMapper.updateById(bizOrder);
// 同步调用同城急送平台入口
// callThirdPartyInterface(bizOrder, map1, bizOrderSub);
}
}
}
}
private void callThirdPartyInterface(BizOrder bizOrder, Map map1, BizOrderSub bizOrderSub) {
String response = cityDelivery.addOrder(bizOrder, bizOrderSub);
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.get("code").equals("200")) {
@ -416,8 +456,6 @@ public class BizOrderServiceImpl implements IBizOrderService {
bizOrderSubMapper.updateById(orderSub);
}
}
}
}
/**
*