Merge branch 'develop' of gitee.com:peng-ou/haoka-server into develop

# Conflicts:
#	yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/orderCatch/DouDianOrderCatchServiceImpl.java
This commit is contained in:
Owen 2025-02-22 12:18:53 +08:00
commit 3e6c3adcca
1 changed files with 141 additions and 164 deletions

View File

@ -1,24 +1,16 @@
package cn.iocoder.yudao.module.haoka.service.orderCatch; package cn.iocoder.yudao.module.haoka.service.orderCatch;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO;
import cn.iocoder.yudao.module.haoka.controller.admin.orderCatch.po.Message; import cn.iocoder.yudao.module.haoka.controller.admin.orderCatch.po.Message;
import cn.iocoder.yudao.module.haoka.controller.admin.orderCatch.vo.OrderCatchRepVO;
import cn.iocoder.yudao.module.haoka.controller.admin.ordersynclog.vo.OrderSyncLogPageReqVO;
import cn.iocoder.yudao.module.haoka.controller.admin.ordersynclog.vo.OrderSyncLogSaveReqVO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.onsaleproduct.OnSaleProductDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.onsaleproduct.OnSaleProductDO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.orders.OrdersDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.orders.OrdersDO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.ordersynclog.OrderSyncLogDO;
import cn.iocoder.yudao.module.haoka.dal.mysql.onsaleproduct.OnSaleProductMapper; import cn.iocoder.yudao.module.haoka.dal.mysql.onsaleproduct.OnSaleProductMapper;
import cn.iocoder.yudao.module.haoka.dal.mysql.orders.OrdersMapper; import cn.iocoder.yudao.module.haoka.dal.mysql.orders.OrdersMapper;
import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService;
import cn.iocoder.yudao.module.haoka.service.ordersynclog.OrderSyncLogService; import cn.iocoder.yudao.module.haoka.service.ordersynclog.OrderSyncLogService;
import cn.iocoder.yudao.module.haoka.service.ordersynclog.OrderSyncLogServiceImpl;
import cn.iocoder.yudao.module.haoka.utils.GroupListUtil; import cn.iocoder.yudao.module.haoka.utils.GroupListUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doudian.open.api.order_batchDecrypt.OrderBatchDecryptRequest; import com.doudian.open.api.order_batchDecrypt.OrderBatchDecryptRequest;
import com.doudian.open.api.order_batchDecrypt.OrderBatchDecryptResponse; import com.doudian.open.api.order_batchDecrypt.OrderBatchDecryptResponse;
import com.doudian.open.api.order_batchDecrypt.data.DecryptInfosItem; import com.doudian.open.api.order_batchDecrypt.data.DecryptInfosItem;
@ -84,7 +76,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
private OnSaleProductService onSaleProductService; private OnSaleProductService onSaleProductService;
@Resource @Resource
private OrderSyncLogService orderSyncLogService; private OrderSyncLogService orderSyncLogService;
@Override @Override
public void syncOrder(AccessToken accessToken, long createTimeStart, long createTimeEnd) { public void syncOrder(AccessToken accessToken, long createTimeStart, long createTimeEnd) {
// 分页查询订单 // 分页查询订单
@ -95,7 +86,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 抖音消息推送订单抓取/更新 订单 * 抖音消息推送订单抓取/更新 订单
*
* @param catchRepVO * @param catchRepVO
*/ */
@Override @Override
@ -110,25 +100,25 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
String msgId = message.getMsgId(); String msgId = message.getMsgId();
Object data = message.getData(); Object data = message.getData();
// 插入日志 // 插入日志
if ("200".equals(tag)) { if("200".equals(tag)){
// 200 doudian_refund_RefundCreated // 200 doudian_refund_RefundCreated
// 买家发起售后申请消息 // 买家发起售后申请消息
RefundRefundCreatedParam refundRefundCreatedParam = gson.fromJson(message.getData() + "", RefundRefundCreatedParam.class); RefundRefundCreatedParam refundRefundCreatedParam = gson.fromJson(message.getData()+"", RefundRefundCreatedParam.class);
} else if ("201".equals(tag)) { } else if("201".equals(tag)) {
// 201 doudian_refund_RefundAgreed // 201 doudian_refund_RefundAgreed
// 同意退款消息 // 同意退款消息
RefundRefundAgreedParam refundRefundAgreedParam = gson.fromJson(message.getData() + "", RefundRefundAgreedParam.class); RefundRefundAgreedParam refundRefundAgreedParam = gson.fromJson(message.getData()+"", RefundRefundAgreedParam.class);
} else if ("202".equals(tag)) { } else if("202".equals(tag)) {
// 202 doudian_refund_ReturnApplyAgreed // 202 doudian_refund_ReturnApplyAgreed
// 同意退货申请消息 // 同意退货申请消息
RefundReturnApplyAgreedParam refundReturnApplyAgreedParam = gson.fromJson(message.getData() + "", RefundReturnApplyAgreedParam.class); RefundReturnApplyAgreedParam refundReturnApplyAgreedParam = gson.fromJson(message.getData()+"", RefundReturnApplyAgreedParam.class);
} else if ("101".equals(tag)) { } else if("101".equals(tag)) {
// 101 doudian_trade_TradePaid // 101 doudian_trade_TradePaid
// 订单支付/确认消息 抓取订单 // 订单支付/确认消息 抓取订单
TradeTradePaidParam tradeTradePaidParam = gson.fromJson(message.getData() + "", TradeTradePaidParam.class); TradeTradePaidParam tradeTradePaidParam = gson.fromJson(message.getData()+"", TradeTradePaidParam.class);
// 订单id // 订单id
Long pId = tradeTradePaidParam.getPId(); Long pId = tradeTradePaidParam.getPId();
// 根据订单id查询订单详情 // 根据订单id查询订单详情
OrderOrderDetailData orderDetail = orderDetail(String.valueOf(pId)); OrderOrderDetailData orderDetail = orderDetail(String.valueOf(pId));
ShopOrderDetail order = orderDetail.getShopOrderDetail(); ShopOrderDetail order = orderDetail.getShopOrderDetail();
// 所有的订单数据 // 所有的订单数据
@ -145,18 +135,16 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
* 2.1 需更新的数据 订单状态 退款状态 * 2.1 需更新的数据 订单状态 退款状态
*/ */
// 所有在售商品 // 所有在售商品
List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper.selectList(new LambdaQueryWrapperX<OnSaleProductDO>().eq(OnSaleProductDO::getDeleted, 0) List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper.selectList(new LambdaQueryWrapperX<OnSaleProductDO>().eq(OnSaleProductDO::getDeleted, 0).eq(OnSaleProductDO::getOnSale, true));
.eq(OnSaleProductDO::getOnSale, true));
// 所有在售商品sku // 所有在售商品sku
List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList(); List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList();
// 买家备注 // 买家备注
String buyerWords = order.getBuyerWords(); String buyerWords = order.getBuyerWords();
// 收件人电话 // 收件人电话
// String postTel = order.getPostTel(); // String postTel = order.getPostTel();
String encryptPostTel = order.getEncryptPostTel(); String encryptPostTel = order.getEncryptPostTel();
// 收件人姓名 // 收件人姓名
// String postReceiver = order.getPostReceiver(); // String postReceiver = order.getPostReceiver();
String encryptPostReceiver = order.getEncryptPostReceiver(); String encryptPostReceiver = order.getEncryptPostReceiver();
// 收件人地址 // 收件人地址
com.doudian.open.api.order_orderDetail.data.PostAddr postAddr = order.getPostAddr(); com.doudian.open.api.order_orderDetail.data.PostAddr postAddr = order.getPostAddr();
@ -168,13 +156,13 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
com.doudian.open.api.order_orderDetail.data.Town town = postAddr.getTown(); com.doudian.open.api.order_orderDetail.data.Town town = postAddr.getTown();
// 街道/ // 街道/
com.doudian.open.api.order_orderDetail.data.Street street = postAddr.getStreet(); com.doudian.open.api.order_orderDetail.data.Street street = postAddr.getStreet();
// String detail = postAddr.getDetail(); // String detail = postAddr.getDetail();
String encryptDetail = postAddr.getEncryptDetail(); String encryptDetail = postAddr.getEncryptDetail();
//用户信息 //用户信息
com.doudian.open.api.order_orderDetail.data.UserIdInfo userIdInfo = order.getUserIdInfo(); com.doudian.open.api.order_orderDetail.data.UserIdInfo userIdInfo = order.getUserIdInfo();
// String idCardNo = userIdInfo.getIdCardNo(); // String idCardNo = userIdInfo.getIdCardNo();
String encryptIdCardNo = userIdInfo.getEncryptIdCardNo(); String encryptIdCardNo = userIdInfo.getEncryptIdCardNo();
// String idCardName = userIdInfo.getIdCardName(); // String idCardName = userIdInfo.getIdCardName();
String encryptIdCardName = userIdInfo.getEncryptIdCardName(); String encryptIdCardName = userIdInfo.getEncryptIdCardName();
List<OrdersDO> orderList = new ArrayList<>(); List<OrdersDO> orderList = new ArrayList<>();
List<OrdersDO> orderListAll = new ArrayList<>(); List<OrdersDO> orderListAll = new ArrayList<>();
@ -185,13 +173,13 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
com.doudian.open.api.order_orderDetail.data.AfterSaleInfo afterSaleInfo = skuOrderListItem.getAfterSaleInfo(); com.doudian.open.api.order_orderDetail.data.AfterSaleInfo afterSaleInfo = skuOrderListItem.getAfterSaleInfo();
// 售后状态 0-售后初始化 6-售后申请 7-售后退货中 27-拒绝售后申请 12-售后成功 28-售后失败 11-售后已发货 29-退货后拒绝退款 13-售后换货商家发货 14-售后换货用户收货 51-取消成功 53-逆向交易完成 // 售后状态 0-售后初始化 6-售后申请 7-售后退货中 27-拒绝售后申请 12-售后成功 28-售后失败 11-售后已发货 29-退货后拒绝退款 13-售后换货商家发货 14-售后换货用户收货 51-取消成功 53-逆向交易完成
Long afterSaleStatus = afterSaleInfo.getAfterSaleStatus(); Long afterSaleStatus = afterSaleInfo.getAfterSaleStatus();
// 1-待退款3-退款成功 4-退款失败当买家发起售后后又主动取消售后此时after_sale_status=28并且refund_status=1的状态不变不会流转至4状态 // 1-待退款3-退款成功 4-退款失败当买家发起售后后又主动取消售后此时after_sale_status=28并且refund_status=1的状态不变不会流转至4状态
Long refundStatus = afterSaleInfo.getRefundStatus(); Long refundStatus = afterSaleInfo.getRefundStatus();
// 商品sku 判断是否抓单 // 商品sku 判断是否抓单
String code = skuOrderListItem.getCode(); String code = skuOrderListItem.getCode();
if (skuList.contains(code)) { if(skuList.contains(code)){
for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) { for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) {
if (onSaleProductDO.getSku().equals(code)) { if(onSaleProductDO.getSku().equals(code)){
// 注入产品生产方式 记录初始产品+接口相关信息 // 注入产品生产方式 记录初始产品+接口相关信息
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId()); OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId());
ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType()); ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType());
@ -207,25 +195,25 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
// 1 待确认/待支付-订单创建完毕;105-已支付; 2-备货中 101-部分发货; 3-已发货全部发货;4- 已取消;5 已完成已收货; // 1 待确认/待支付-订单创建完毕;105-已支付; 2-备货中 101-部分发货; 3-已发货全部发货;4- 已取消;5 已完成已收货;
Long HaokaOrderStatus;// 号卡订单状态 Long HaokaOrderStatus;// 号卡订单状态
Long HaokaOrderRefundStatus;// 号卡订单退款状态 Long HaokaOrderRefundStatus;// 号卡订单退款状态
// 解析订单状态 // 解析订单状态
if (orderStatus == 105L) { if(orderStatus == 105L){
HaokaOrderStatus = 100L; HaokaOrderStatus = 100L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else if (orderStatus == 101L || orderStatus == 3L) { }else if(orderStatus == 101L || orderStatus == 3L){
HaokaOrderStatus = 500L; HaokaOrderStatus = 500L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else { }else {
// 更新订单退款状态 订单状态不变 // 更新订单退款状态 订单状态不变
} }
ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc()); ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc());
// 解析售后状态 // 解析售后状态
if (0L == afterSaleStatus) { if(0L == afterSaleStatus){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (afterSaleStatus == 28L || refundStatus == 1L) { } else if(afterSaleStatus == 28L || refundStatus == 1L){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (refundStatus == 3L) { } else if(refundStatus == 3L){
// 进入售后 // 进入售后
HaokaOrderRefundStatus = 300L; HaokaOrderRefundStatus = 300L;
} else { } else {
@ -237,14 +225,14 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
for (com.doudian.open.api.order_orderDetail.data.LogisticsInfoItem logisticsInfoItem : logisticsInfo) { for (com.doudian.open.api.order_orderDetail.data.LogisticsInfoItem logisticsInfoItem : logisticsInfo) {
for (com.doudian.open.api.order_orderDetail.data.ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) { for (com.doudian.open.api.order_orderDetail.data.ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) {
String skuOrderId = productInfoItem.getSkuOrderId(); String skuOrderId = productInfoItem.getSkuOrderId();
if (skuOrderId.equals(orderId)) { if(skuOrderId.equals(orderId)){
String productName = productInfoItem.getProductName(); String productName = productInfoItem.getProductName();
ordersDO.setSupplierProductName(productName); ordersDO.setSupplierProductName(productName);
List<com.doudian.open.api.order_orderDetail.data.SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs(); List<com.doudian.open.api.order_orderDetail.data.SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs();
for (com.doudian.open.api.order_orderDetail.data.SkuSpecsItem skuSpec : skuSpecs) { for (com.doudian.open.api.order_orderDetail.data.SkuSpecsItem skuSpec : skuSpecs) {
String name = skuSpec.getName(); String name = skuSpec.getName();
String planMobile = getPlanMobile(name); String planMobile = getPlanMobile(name);
if (planMobile != null) { if(planMobile != null){
ordersDO.setPlanMobile(planMobile); ordersDO.setPlanMobile(planMobile);
} }
} }
@ -252,13 +240,13 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
} }
} }
// 查询订单是否存在 不存在则新增存在则更新 // 查询订单是否存在 不存在则新增存在则更新
List<OrdersDO> ordersDOS = ordersMapper.selectList(new QueryWrapper<OrdersDO>().eq("real_source_id", orderId).eq("deleted", 0)); List<OrdersDO> ordersDOS = ordersMapper.selectList(new LambdaQueryWrapperX<OrdersDO>().eq(OrdersDO::getRealSourceId, orderId).eq(OrdersDO::getDeleted, 0));
if (CollectionUtil.isNotEmpty(ordersDOS)) { if(CollectionUtil.isNotEmpty(ordersDOS)){
// 更新订单 // 更新订单
OrdersDO ordersDO1 = ordersDOS.get(0); OrdersDO ordersDO1 = ordersDOS.get(0);
ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus)); ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus));
ordersMapper.updateById(ordersDO1); ordersMapper.updateById(ordersDO1);
} else { }else {
// 新增订单 // 新增订单
ordersDO.setShopId(String.valueOf(shopId)); ordersDO.setShopId(String.valueOf(shopId));
ordersDO.setShopName(shopName); ordersDO.setShopName(shopName);
@ -303,14 +291,14 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
for (List<OrdersDO> ordersDOS : GroupListUtil.groupList(orderListAll, 50)) { for (List<OrdersDO> ordersDOS : GroupListUtil.groupList(orderListAll, 50)) {
batchDecryptOrderAndUpdate(ordersDOS); batchDecryptOrderAndUpdate(ordersDOS);
} }
} else if ("106".equals(tag)) { } else if("106".equals(tag)) {
// 106 doudian_trade_TradeCanceled // 106 doudian_trade_TradeCanceled
// 订单取消消息 // 订单取消消息
TradeTradeCanceledParam tradeTradeCanceledParam = gson.fromJson(message.getData() + "", TradeTradeCanceledParam.class); TradeTradeCanceledParam tradeTradeCanceledParam = gson.fromJson(message.getData()+"", TradeTradeCanceledParam.class);
} else if ("110".equals(tag)) { } else if("110".equals(tag)) {
// 110 doudian_trade_TradePending // 110 doudian_trade_TradePending
// 订单已支付待处理 // 订单已支付待处理
TradeTradePendingParam tradeTradePendingParam = gson.fromJson(message.getData() + "", TradeTradePendingParam.class); TradeTradePendingParam tradeTradePendingParam = gson.fromJson(message.getData()+"", TradeTradePendingParam.class);
// 订单id // 订单id
Long pId = tradeTradePendingParam.getPId(); Long pId = tradeTradePendingParam.getPId();
// 根据订单id查询订单详情 // 根据订单id查询订单详情
@ -330,10 +318,7 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
* 2.1 需更新的数据 订单状态 退款状态 * 2.1 需更新的数据 订单状态 退款状态
*/ */
// 所有在售商品 // 所有在售商品
// List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper.selectList(new QueryWrapper<OnSaleProductDO>().eq("deleted", 0).eq("onSale", true)); List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper.selectList(new LambdaQueryWrapperX<OnSaleProductDO>().eq(OnSaleProductDO::getDeleted, 0).eq(OnSaleProductDO::getOnSale, true));
List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper.selectList(new LambdaQueryWrapperX<OnSaleProductDO>().eq(OnSaleProductDO::getDeleted, 0)
.eq(OnSaleProductDO::getOnSale, true));
// 所有在售商品sku // 所有在售商品sku
List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList(); List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList();
// 买家备注 // 买家备注
@ -375,9 +360,9 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
Long refundStatus = afterSaleInfo.getRefundStatus(); Long refundStatus = afterSaleInfo.getRefundStatus();
// 商品sku 判断是否抓单 // 商品sku 判断是否抓单
String code = skuOrderListItem.getCode(); String code = skuOrderListItem.getCode();
if (skuList.contains(code)) { if(skuList.contains(code)){
for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) { for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) {
if (onSaleProductDO.getSku().equals(code)) { if(onSaleProductDO.getSku().equals(code)){
// 注入产品生产方式 记录初始产品+接口相关信息 // 注入产品生产方式 记录初始产品+接口相关信息
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId()); OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId());
ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType()); ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType());
@ -394,24 +379,24 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
Long HaokaOrderStatus;// 号卡订单状态 Long HaokaOrderStatus;// 号卡订单状态
Long HaokaOrderRefundStatus;// 号卡订单退款状态 Long HaokaOrderRefundStatus;// 号卡订单退款状态
// 解析订单状态 // 解析订单状态
if (orderStatus == 105L) { if(orderStatus == 105L){
HaokaOrderStatus = 100L; HaokaOrderStatus = 100L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else if (orderStatus == 101L || orderStatus == 3L) { }else if(orderStatus == 101L || orderStatus == 3L){
HaokaOrderStatus = 500L; HaokaOrderStatus = 500L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else { }else {
// 更新订单退款状态 订单状态不变 // 更新订单退款状态 订单状态不变
} }
ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc()); ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc());
// 解析售后状态 // 解析售后状态
if (0L == afterSaleStatus) { if(0L == afterSaleStatus){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (afterSaleStatus == 28L || refundStatus == 1L) { } else if(afterSaleStatus == 28L || refundStatus == 1L){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (refundStatus == 3L) { } else if(refundStatus == 3L){
// 进入售后 // 进入售后
HaokaOrderRefundStatus = 300L; HaokaOrderRefundStatus = 300L;
} else { } else {
@ -423,14 +408,14 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
for (com.doudian.open.api.order_orderDetail.data.LogisticsInfoItem logisticsInfoItem : logisticsInfo) { for (com.doudian.open.api.order_orderDetail.data.LogisticsInfoItem logisticsInfoItem : logisticsInfo) {
for (com.doudian.open.api.order_orderDetail.data.ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) { for (com.doudian.open.api.order_orderDetail.data.ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) {
String skuOrderId = productInfoItem.getSkuOrderId(); String skuOrderId = productInfoItem.getSkuOrderId();
if (skuOrderId.equals(orderId)) { if(skuOrderId.equals(orderId)){
String productName = productInfoItem.getProductName(); String productName = productInfoItem.getProductName();
ordersDO.setSupplierProductName(productName); ordersDO.setSupplierProductName(productName);
List<com.doudian.open.api.order_orderDetail.data.SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs(); List<com.doudian.open.api.order_orderDetail.data.SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs();
for (com.doudian.open.api.order_orderDetail.data.SkuSpecsItem skuSpec : skuSpecs) { for (com.doudian.open.api.order_orderDetail.data.SkuSpecsItem skuSpec : skuSpecs) {
String name = skuSpec.getName(); String name = skuSpec.getName();
String planMobile = getPlanMobile(name); String planMobile = getPlanMobile(name);
if (planMobile != null) { if(planMobile != null){
ordersDO.setPlanMobile(planMobile); ordersDO.setPlanMobile(planMobile);
} }
} }
@ -438,13 +423,13 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
} }
} }
// 查询订单是否存在 不存在则新增存在则更新 // 查询订单是否存在 不存在则新增存在则更新
List<OrdersDO> ordersDOS = ordersMapper.selectList(new QueryWrapper<OrdersDO>().eq("real_source_id", orderId).eq("deleted", 0)); List<OrdersDO> ordersDOS = ordersMapper.selectList(new LambdaQueryWrapperX<OrdersDO>().eq(OrdersDO::getRealSourceId, orderId).eq(OrdersDO::getDeleted, 0));
if (CollectionUtil.isNotEmpty(ordersDOS)) { if(CollectionUtil.isNotEmpty(ordersDOS)){
// 更新订单 // 更新订单
OrdersDO ordersDO1 = ordersDOS.get(0); OrdersDO ordersDO1 = ordersDOS.get(0);
ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus)); ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus));
ordersMapper.updateById(ordersDO1); ordersMapper.updateById(ordersDO1);
} else { }else {
// 新增订单 // 新增订单
ordersDO.setShopId(String.valueOf(shopId)); ordersDO.setShopId(String.valueOf(shopId));
ordersDO.setShopName(shopName); ordersDO.setShopName(shopName);
@ -490,12 +475,12 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
batchDecryptOrderAndUpdate(ordersDOS); batchDecryptOrderAndUpdate(ordersDOS);
} }
} else { } else {
// 未接入的消息类型 // 未接入的消息类型
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(),e);
log.error("订单解析执行报错,错误原因:{}", e); log.error("订单解析执行报错,错误原因:{}",e);
} }
} }
@ -503,15 +488,14 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 将订单数据插入到数据库 * 将订单数据插入到数据库
*
* @param orders 订单数据 * @param orders 订单数据
*/ */
private void insertOrdersToDatabase(List<ShopOrderListItem> orders) { private void insertOrdersToDatabase(List<ShopOrderListItem> orders) {
// 所有在售商品 // 所有在售商品
List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper List<OnSaleProductDO> onSaleProductDOS = onSaleProductMapper
.selectList(new LambdaQueryWrapperX<OnSaleProductDO>() .selectList(new LambdaQueryWrapperX<OnSaleProductDO>()
.eq(OnSaleProductDO::getDeleted, 0) .eq(OnSaleProductDO::getDeleted,0)
.eq(OnSaleProductDO::getOnSale, true)); .eq(OnSaleProductDO::getOnSale,true));
// 所有在售商品sku // 所有在售商品sku
List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList(); List<String> skuList = onSaleProductDOS.stream().map(OnSaleProductDO::getSku).toList();
//数据分片处理 分片理由 每次最多徐解密50条数据一条订单解密5个数据10个订单解密50条 //数据分片处理 分片理由 每次最多徐解密50条数据一条订单解密5个数据10个订单解密50条
@ -568,9 +552,9 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
Long refundStatus = afterSaleInfo.getRefundStatus(); Long refundStatus = afterSaleInfo.getRefundStatus();
// 商品sku 判断是否抓单 // 商品sku 判断是否抓单
String code = skuOrderListItem.getCode(); String code = skuOrderListItem.getCode();
if (skuList.contains(code)) { if(skuList.contains(code)){
for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) { for (OnSaleProductDO onSaleProductDO : onSaleProductDOS) {
if (onSaleProductDO.getSku().equals(code)) { if(onSaleProductDO.getSku().equals(code)){
// 注入产品生产方式 记录初始产品+接口相关信息 // 注入产品生产方式 记录初始产品+接口相关信息
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId()); OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(onSaleProductDO.getId());
ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType()); ordersDO.setAutoType(onSaleProductPreOrder.getParentProduct().getAutoType());
@ -587,90 +571,90 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
Long HaokaOrderStatus;// 号卡订单状态 Long HaokaOrderStatus;// 号卡订单状态
Long HaokaOrderRefundStatus;// 号卡订单退款状态 Long HaokaOrderRefundStatus;// 号卡订单退款状态
// 解析订单状态 // 解析订单状态
if (orderStatus == 105L) { if(orderStatus == 105L){
HaokaOrderStatus = 100L; HaokaOrderStatus = 100L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else if (orderStatus == 101L || orderStatus == 3L) { }else if(orderStatus == 101L || orderStatus == 3L){
HaokaOrderStatus = 500L; HaokaOrderStatus = 500L;
ordersDO.setStatus(HaokaOrderStatus); ordersDO.setStatus(HaokaOrderStatus);
} else { }else {
// 更新订单退款状态 订单状态不变 // 更新订单退款状态 订单状态不变
} }
// 解析售后状态 // 解析售后状态
if (0L == afterSaleStatus) { if(0L == afterSaleStatus){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (afterSaleStatus == 28L || refundStatus == 1L) { } else if(afterSaleStatus == 28L || refundStatus == 1L){
// 未进入售后 // 未进入售后
HaokaOrderRefundStatus = 800L; HaokaOrderRefundStatus = 800L;
} else if (refundStatus == 3L) { } else if(refundStatus == 3L){
// 进入售后 // 进入售后
HaokaOrderRefundStatus = 300L; HaokaOrderRefundStatus = 300L;
} else { } else {
// 进入售后 // 进入售后
HaokaOrderRefundStatus = 200L; HaokaOrderRefundStatus = 200L;
} }
ordersDO.setRefundStatus(String.valueOf(HaokaOrderRefundStatus)); ordersDO.setRefundStatus(String.valueOf(HaokaOrderRefundStatus));
ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc()); ordersDO.setStatusName(skuOrderListItem.getOrderStatusDesc());
// 获取计划手机号 // 获取计划手机号
for (LogisticsInfoItem logisticsInfoItem : logisticsInfo) { for (LogisticsInfoItem logisticsInfoItem : logisticsInfo) {
for (ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) { for (ProductInfoItem productInfoItem : logisticsInfoItem.getProductInfo()) {
String skuOrderId = productInfoItem.getSkuOrderId(); String skuOrderId = productInfoItem.getSkuOrderId();
if (skuOrderId.equals(orderId)) { if(skuOrderId.equals(orderId)){
String productName = productInfoItem.getProductName(); String productName = productInfoItem.getProductName();
ordersDO.setSupplierProductName(productName); ordersDO.setSupplierProductName(productName);
List<SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs(); List<SkuSpecsItem> skuSpecs = productInfoItem.getSkuSpecs();
for (SkuSpecsItem skuSpec : skuSpecs) { for (SkuSpecsItem skuSpec : skuSpecs) {
String name = skuSpec.getName(); String name = skuSpec.getName();
String planMobile = getPlanMobile(name); String planMobile = getPlanMobile(name);
if (planMobile != null) { if(planMobile != null){
ordersDO.setPlanMobile(planMobile); ordersDO.setPlanMobile(planMobile);
}
} }
} }
} }
} }
// 查询订单是否存在 不存在则新增存在则更新 }
List<OrdersDO> ordersDOS = ordersMapper.selectList(new QueryWrapper<OrdersDO>().eq("real_source_id", orderId).eq("deleted", 0)); // 查询订单是否存在 不存在则新增存在则更新
if (CollectionUtil.isNotEmpty(ordersDOS)) { List<OrdersDO> ordersDOS = ordersMapper.selectList(new LambdaQueryWrapperX<OrdersDO>().eq(OrdersDO::getRealSourceId, orderId).eq(OrdersDO::getDeleted, 0));
// 更新订单 if(CollectionUtil.isNotEmpty(ordersDOS)){
OrdersDO ordersDO1 = ordersDOS.get(0); // 更新订单
ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus)); OrdersDO ordersDO1 = ordersDOS.get(0);
ordersMapper.updateById(ordersDO1); ordersDO1.setRefundStatus(String.valueOf(HaokaOrderRefundStatus));
} else { ordersMapper.updateById(ordersDO1);
// 新增订单 }else {
ordersDO.setShopId(String.valueOf(shopId)); // 新增订单
ordersDO.setShopName(shopName); ordersDO.setShopId(String.valueOf(shopId));
// 真实订单 ordersDO.setShopName(shopName);
ordersDO.setRealSourceId(orderId); // 真实订单
ordersDO.setSourceId(orderId); ordersDO.setRealSourceId(orderId);
// 买家备注 ordersDO.setSourceId(orderId);
ordersDO.setBuyerMemo(buyerWords); // 买家备注
//证件信息 ordersDO.setBuyerMemo(buyerWords);
// ordersDO.setIdCardNum(idCardNo); //证件信息
ordersDO.setEncryptIdCardNum(encryptIdCardNo); // ordersDO.setIdCardNum(idCardNo);
// ordersDO.setIdCardName(idCardName); ordersDO.setEncryptIdCardNum(encryptIdCardNo);
ordersDO.setEncryptIdCardName(encryptIdCardName); // ordersDO.setIdCardName(idCardName);
// 收件人信息 ordersDO.setEncryptIdCardName(encryptIdCardName);
// ordersDO.setAddressMobile(postTel); // 收件人信息
ordersDO.setEncryptAddressMobile(encryptPostTel); // ordersDO.setAddressMobile(postTel);
// ordersDO.setAddressName(postReceiver); ordersDO.setEncryptAddressMobile(encryptPostTel);
ordersDO.setEncryptAddressName(encryptPostReceiver); // ordersDO.setAddressName(postReceiver);
// 收件人地址 ordersDO.setEncryptAddressName(encryptPostReceiver);
ordersDO.setAddressProvince(province.getName()); // 收件人地址
ordersDO.setAddressProvinceCode(province.getId()); ordersDO.setAddressProvince(province.getName());
// ordersDO.setAddressProvinceCode(province.getId());
ordersDO.setAddressCity(city.getName()); //
ordersDO.setAddressCityCode(city.getId()); ordersDO.setAddressCity(city.getName());
// ordersDO.setAddressCityCode(city.getId());
ordersDO.setAddressDistrict(town.getName()); //
ordersDO.setAddressDistrictCode(town.getId()); ordersDO.setAddressDistrict(town.getName());
// 街道/ ordersDO.setAddressDistrictCode(town.getId());
ordersDO.setTown(street.getName()); // 街道/
// 详细地址 ordersDO.setTown(street.getName());
// ordersDO.setAddress(detail); // 详细地址
ordersDO.setEncryptAddress(encryptDetail); // ordersDO.setAddress(detail);
orderList.add(ordersDO); ordersDO.setEncryptAddress(encryptDetail);
orderList.add(ordersDO);
} }
} }
@ -684,14 +668,12 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
batchDecryptOrderAndUpdate(ordersDOS); batchDecryptOrderAndUpdate(ordersDOS);
} }
} }
private CipherInfosItem createCipherItem(String cipherText, String authId) { private CipherInfosItem createCipherItem(String cipherText, String authId) {
CipherInfosItem item = new CipherInfosItem(); CipherInfosItem item = new CipherInfosItem();
item.setCipherText(cipherText); item.setCipherText(cipherText);
item.setAuthId(authId); item.setAuthId(authId);
return item; return item;
} }
private void updateOrderFields(OrdersDO order, String cipherText, String decryptText) { private void updateOrderFields(OrdersDO order, String cipherText, String decryptText) {
// 检查并更新每个加密字段 // 检查并更新每个加密字段
if (cipherText.equals(order.getEncryptAddress())) { if (cipherText.equals(order.getEncryptAddress())) {
@ -706,7 +688,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
order.setEncryptAddressMobile(decryptText); order.setEncryptAddressMobile(decryptText);
} }
} }
private void batchDecryptOrderAndUpdate(List<OrdersDO> orderList) { private void batchDecryptOrderAndUpdate(List<OrdersDO> orderList) {
List<CipherInfosItem> cipherInfos = new ArrayList<>(); List<CipherInfosItem> cipherInfos = new ArrayList<>();
for (OrdersDO ordersDO : orderList) { for (OrdersDO ordersDO : orderList) {
@ -736,7 +717,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 使用正则表达式获取手机号 * 使用正则表达式获取手机号
*
* @param skuName * @param skuName
* @return * @return
*/ */
@ -746,10 +726,10 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
String pattern = "(?<=\\/)\\d{11}"; String pattern = "(?<=\\/)\\d{11}";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(noSpace); Matcher matcher = compile.matcher(noSpace);
if (matcher.find()) { if(matcher.find()){
// 找到匹配手机号 // 找到匹配手机号
return matcher.group(1); return matcher.group(1);
} else { }else {
return null; return null;
} }
} }
@ -757,10 +737,9 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 分页查询订单 * 分页查询订单
* * @param accessToken 访问令牌
* @param accessToken 访问令牌
* @param createTimeStart 创建时间起始 * @param createTimeStart 创建时间起始
* @param createTimeEnd 创建时间结束 * @param createTimeEnd 创建时间结束
* @return 所有订单数据 * @return 所有订单数据
*/ */
private List<ShopOrderListItem> fetchOrders(AccessToken accessToken, long createTimeStart, long createTimeEnd) { private List<ShopOrderListItem> fetchOrders(AccessToken accessToken, long createTimeStart, long createTimeEnd) {
@ -811,15 +790,14 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 批量解密接口 * 批量解密接口
*
* @param cipherInfos 待解密数据 一次性最多50条 * @param cipherInfos 待解密数据 一次性最多50条
* @return * @return
*/ */
private List<DecryptInfosItem> batchDecrypt(List<CipherInfosItem> cipherInfos) { private List<DecryptInfosItem> batchDecrypt(List<CipherInfosItem> cipherInfos){
GlobalConfig.initAppKey(SYNC_APP_KEY); GlobalConfig.initAppKey(SYNC_APP_KEY);
GlobalConfig.initAppSecret(SYNC_APP_SECRET); GlobalConfig.initAppSecret(SYNC_APP_SECRET);
//入参为code //入参为code
AccessToken accessToken = AccessTokenBuilder.build(SYNC_SHOP_ID); AccessToken accessToken= AccessTokenBuilder.build(SYNC_SHOP_ID);
OrderBatchDecryptRequest request = new OrderBatchDecryptRequest(); OrderBatchDecryptRequest request = new OrderBatchDecryptRequest();
OrderBatchDecryptParam param = request.getParam(); OrderBatchDecryptParam param = request.getParam();
param.setCipherInfos(cipherInfos); param.setCipherInfos(cipherInfos);
@ -834,20 +812,19 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
GlobalConfig.initAppKey(SYNC_APP_KEY); GlobalConfig.initAppKey(SYNC_APP_KEY);
GlobalConfig.initAppSecret(SYNC_APP_SECRET); GlobalConfig.initAppSecret(SYNC_APP_SECRET);
//入参为code //入参为code
AccessToken accessToken = AccessTokenBuilder.build(SYNC_SHOP_ID); AccessToken accessToken= AccessTokenBuilder.build(SYNC_SHOP_ID);
OrderOrderDetailRequest request = new OrderOrderDetailRequest(); OrderOrderDetailRequest request = new OrderOrderDetailRequest();
OrderOrderDetailParam param = request.getParam(); OrderOrderDetailParam param = request.getParam();
param.setShopOrderId(shopOrderId); param.setShopOrderId(shopOrderId);
OrderOrderDetailResponse response = request.execute(accessToken); OrderOrderDetailResponse response = request.execute(accessToken);
return response.getData(); return response.getData();
} }
public void refreshToken() { public void refreshToken() {
//设置appKey和appSecret全局设置一次 //设置appKey和appSecret全局设置一次
GlobalConfig.initAppKey("7381306825771091495"); GlobalConfig.initAppKey("7381306825771091495");
GlobalConfig.initAppSecret("09c06553-b77c-4712-aed9-84cbfe16ca13"); GlobalConfig.initAppSecret("09c06553-b77c-4712-aed9-84cbfe16ca13");
//入参为code //入参为code
AccessToken accessToken = AccessTokenBuilder.build(20811777L); AccessToken accessToken= AccessTokenBuilder.build(20811777L);
String refreshToken = accessToken.getRefreshToken();//16dde1a3-2d6f-4946-aef2-afbd29d2eb92是code String refreshToken = accessToken.getRefreshToken();//16dde1a3-2d6f-4946-aef2-afbd29d2eb92是code
TokenRefreshRequest request = new TokenRefreshRequest(); TokenRefreshRequest request = new TokenRefreshRequest();
TokenRefreshParam param = request.getParam(); TokenRefreshParam param = request.getParam();