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
@ -145,9 +135,7 @@ 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();
// 买家备注 // 买家备注
@ -252,7 +240,7 @@ 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);
@ -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();
// 买家备注 // 买家备注
@ -438,7 +423,7 @@ 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);
@ -503,7 +488,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 将订单数据插入到数据库 * 将订单数据插入到数据库
*
* @param orders 订单数据 * @param orders 订单数据
*/ */
private void insertOrdersToDatabase(List<ShopOrderListItem> orders) { private void insertOrdersToDatabase(List<ShopOrderListItem> orders) {
@ -631,7 +615,7 @@ 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);
@ -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
*/ */
@ -757,7 +737,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 分页查询订单 * 分页查询订单
*
* @param accessToken 访问令牌 * @param accessToken 访问令牌
* @param createTimeStart 创建时间起始 * @param createTimeStart 创建时间起始
* @param createTimeEnd 创建时间结束 * @param createTimeEnd 创建时间结束
@ -811,7 +790,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
/** /**
* 批量解密接口 * 批量解密接口
*
* @param cipherInfos 待解密数据 一次性最多50条 * @param cipherInfos 待解密数据 一次性最多50条
* @return * @return
*/ */
@ -841,7 +819,6 @@ public class DouDianOrderCatchServiceImpl implements OrderCatchService {
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");