handle exception
This commit is contained in:
@@ -206,7 +206,7 @@ public class BuyOrderController {
|
||||
Set<String> sn_no = new HashSet<String>();
|
||||
for (BuyOrderDetail buyOrderDetail : orderDetail) {
|
||||
resultOrder.add(buyOrderDetail);
|
||||
sn_no.add(buyOrderDetail.getExpressOrderId());
|
||||
// sn_no.add(buyOrderDetail.getExpressOrderId());
|
||||
}
|
||||
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
|
||||
@@ -92,8 +92,4 @@ public class BuyOrderDetail implements Serializable {
|
||||
* 评价 ID
|
||||
*/
|
||||
private Integer recordId;
|
||||
/**
|
||||
* 快递订单 ID
|
||||
*/
|
||||
private String expressOrderId;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface ExpressOrderService extends IService<ExpressOrder> {
|
||||
* @param expressOrder
|
||||
* @throws Exception
|
||||
*/
|
||||
void placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder) throws Exception;
|
||||
String placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSplitPackageOrder(String expressCompanyCode, Integer userAddressId, List<Integer> buyOrderDetailId) throws Exception {
|
||||
public void createSplitPackageOrder(String expressCompanyCode, Integer userAddressId, List<Integer> buyOrderDetailId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", buyOrderDetailId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
@@ -273,6 +273,10 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
expressOrder.setCommodity(commodityList);
|
||||
expressOrder.setExpressCompanyCode(expressCompanyCode);
|
||||
// 生成快递面单
|
||||
expressOrderService.placeExpressOrder(address, expressOrder);
|
||||
String expressBill = expressOrderService.placeExpressOrder(address, expressOrder);
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
buyOrderDetail.setExpressBill(expressBill);
|
||||
}
|
||||
buyOrderDetailService.saveBatch(buyOrderDetailList);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.peanut.modules.book.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ExpressOrderRequestVo;
|
||||
import com.peanut.modules.book.vo.ExpressOrderResponseVo;
|
||||
import com.peanut.modules.book.vo.ExpressUserInfoVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -50,7 +51,7 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
|
||||
|
||||
@Override
|
||||
public void placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder) throws Exception {
|
||||
public String placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder) {
|
||||
ExpressOrderRequestVo orderRequestVo = new ExpressOrderRequestVo();
|
||||
// 订单号
|
||||
orderRequestVo.setOrderCode(expressOrder.getOrderId().toString());
|
||||
@@ -84,11 +85,17 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
params.put("RequestData", RequestData);
|
||||
params.put("EBusinessID", Constants.EXPRESS_BUSINESS_ID);
|
||||
params.put("RequestType", Constants.EXPRESS_REQUEST_TYPE_PLACE_ORDER);
|
||||
try {
|
||||
String dataSign = KdUtils.encrypt(RequestData, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
params.put("DataType", "2");
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_PLACE_ORDER_URL, params);
|
||||
System.out.println(response);
|
||||
ExpressOrderResponseVo responseVo = JSONObject.parseObject(response, ExpressOrderResponseVo.class);
|
||||
return responseVo.getPrintTemplate();
|
||||
}
|
||||
|
||||
private ExpressUserInfoVo buildReceiverBasedOnUserAddress(UserAddress userAddress) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递下单响应 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/17
|
||||
*/
|
||||
@Data
|
||||
public class ExpressOrderResponseVo {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String EBusinessID;
|
||||
/**
|
||||
* 返回模板
|
||||
*/
|
||||
private String PrintTemplate;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private boolean Success;
|
||||
/**
|
||||
* 结果响应编码
|
||||
*/
|
||||
private String ResultCode;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
private String Reason;
|
||||
}
|
||||
Reference in New Issue
Block a user