diff --git a/ms-api/src/main/java/com/ms/api/dto/move/GetRecommendProductListRequestDTO.java b/ms-api/src/main/java/com/ms/api/dto/move/GetRecommendProductListRequestDTO.java new file mode 100644 index 00000000..d0c32653 --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/move/GetRecommendProductListRequestDTO.java @@ -0,0 +1,9 @@ +package com.ms.api.dto.move; + +import lombok.Data; + +@Data +public class GetRecommendProductListRequestDTO { + private Integer pageNo; + private Integer pageSize; +} diff --git a/ms-biz/src/main/java/com/ms/api/biz/DsCatService.java b/ms-biz/src/main/java/com/ms/api/biz/DsCatService.java new file mode 100644 index 00000000..b7e61e89 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/biz/DsCatService.java @@ -0,0 +1,65 @@ +package com.ms.api.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ms.api.common.Ret; +import com.ms.api.paas.StorageService; +import com.ms.api.tool.DsJsonRequestTemplate; +import com.ms.api.tool.MoveTool; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; + +@Component +@Slf4j +public class DsCatService { + +// @Autowired +// private CategoryService categoryService; + + @Autowired + private DsJsonRequestTemplate dsJsonRequestTemplate; + + @Autowired + private StorageService storageService; + + public JSONArray getDSProductCatTree() { + HashMap params = new HashMap<>(); + String res = null; + JSONObject resObj = null; + String tosPath = MoveTool.getAllProductCatTreeOssPath(); + JSONArray arrayData = null; + try { + Ret getTosContentRet = storageService.getContent(tosPath); + if (getTosContentRet.getResult().equals("success")) { + arrayData = JSONObject.parseArray(getTosContentRet.getData().get("data").toString()); + } else { + try { + res = dsJsonRequestTemplate.execute("/move/search_ds_product_cat_tree", params); + log.info(res); + resObj = JSON.parseObject(res); + if (resObj.get("result").equals("success")) { + JSONObject cateTree = resObj.getJSONObject("cateTree"); + arrayData = new JSONArray(); + arrayData.add(cateTree.values()); + try { + storageService.uploadContent(tosPath, JSONObject.toJSONString(arrayData)); + } catch (Exception e) { + log.error("商品类目TOS写入操作过程异常:", e); + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("strerror2:", e); + } + } + } catch (Exception e) { + log.error("商品类目TOS读取操作过程异常:", e); + } + return arrayData; + } + +} diff --git a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java index 21cc0549..4b46728b 100644 --- a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java +++ b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java @@ -201,8 +201,11 @@ public class MoveService { productDetailBase.put("categoryLeafId", queueMsg.getCid()); // 尺寸模版 - Long size = getSizeTemplateId(shopId, Long.parseLong(queueMsg.getCid())); - productDetailBase.put("sizeTemplateId", size); + if(StrUtil.isNotBlank(queueMsg.getCid())){ + Long size = getSizeTemplateId(shopId, Long.parseLong(queueMsg.getCid())); + productDetailBase.put("sizeTemplateId", size); + } + // 发货时间 long deliveryDelayDay = condition.getDeliveryDelayDay(); diff --git a/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java b/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java index b6584414..cf99b6cb 100644 --- a/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java +++ b/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java @@ -68,6 +68,8 @@ public class MoveProductPublishQueueBO { private MoveShopSettingBO condition; + private String conditionTxt; + private String cnaliDsDetailId; private String site; diff --git a/ms-biz/src/main/java/com/ms/api/service/AfterSaleService.java b/ms-biz/src/main/java/com/ms/api/service/AfterSaleService.java index 7b906b2c..a3b38769 100644 --- a/ms-biz/src/main/java/com/ms/api/service/AfterSaleService.java +++ b/ms-biz/src/main/java/com/ms/api/service/AfterSaleService.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; import java.util.Set; +import com.doudian.open.core.AccessToken; import com.ms.api.common.ApiResult; import com.ms.dal.entity.AfterSale; @@ -30,7 +31,7 @@ public interface AfterSaleService { Integer tryRsyncAfterSale(String authShopId, Integer priority , Date forceStart); - ApiResult rsyncAfterSaleByAftersaleIds(String authShopId, String aftersaleIds, boolean fromDyCloud); + ApiResult rsyncAfterSaleByAftersaleIds(String authShopId, String aftersaleIds, AccessToken accessToken, boolean fromDyCloud); boolean processDoudianAftersaleMsg(Long shopId, String msgId); diff --git a/ms-biz/src/main/java/com/ms/api/service/CategoryShopService.java b/ms-biz/src/main/java/com/ms/api/service/CategoryShopService.java index 7273e67d..0ac7508c 100644 --- a/ms-biz/src/main/java/com/ms/api/service/CategoryShopService.java +++ b/ms-biz/src/main/java/com/ms/api/service/CategoryShopService.java @@ -24,4 +24,6 @@ public interface CategoryShopService { List getCategoryListByShopId(long shopId, long maxCid, int stepLen); + Category getCategoryListByCategoryId(Long shopId,Long categoryId); + } diff --git a/ms-biz/src/main/java/com/ms/api/service/PurchaseOrderItemService.java b/ms-biz/src/main/java/com/ms/api/service/PurchaseOrderItemService.java index f8304f7f..2857e501 100644 --- a/ms-biz/src/main/java/com/ms/api/service/PurchaseOrderItemService.java +++ b/ms-biz/src/main/java/com/ms/api/service/PurchaseOrderItemService.java @@ -1,6 +1,7 @@ package com.ms.api.service; import com.ms.dal.entity.PurchaseOrderItem; +import org.apache.ibatis.annotations.Param; import java.util.HashMap; import java.util.List; @@ -31,6 +32,8 @@ public interface PurchaseOrderItemService { int updateStatusByIds(String status, List ids); + int updateStatusByPurchaseIds(String status, List purchaseOrderIds); + List getRelatePurchaseOrderItemsByPurchaseOrderId(Long purchaseOrderId); int updateStatusByOrderId(Long shopId, String orderId, String status); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/AfterSaleServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/AfterSaleServiceImpl.java index 937233e3..82707f9d 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/AfterSaleServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/AfterSaleServiceImpl.java @@ -27,6 +27,8 @@ import com.doudian.open.api.afterSale_Detail.data.Return; import com.doudian.open.api.afterSale_Detail.data.SkuOrderInfosItem; import com.doudian.open.api.afterSale_Detail.data.ValueAddedServicesItem; import com.doudian.open.api.afterSale_Detail.param.AfterSaleDetailParam; +import com.doudian.open.core.AccessToken; +import com.ms.api.bo.ShopBO; import com.ms.api.common.ApiResult; import com.ms.api.consts.AfterSaleConst; import com.ms.api.consts.LogisticsConst; @@ -34,6 +36,7 @@ import com.ms.api.consts.RedisKeyConst; import com.ms.api.consts.StatusConst; import com.ms.api.consts.TblConst; import com.ms.api.service.AfterSaleService; +import com.ms.api.service.ShopService; import com.ms.api.tool.CommonTool; import com.ms.api.util.DdRequestUtil; import com.ms.dal.entity.AfterSale; @@ -80,7 +83,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { private final DdAftersaleMsgMapper ddAftersaleMsgMapper; - private final ShopMapper shopMapper; + private final ShopService shopService; @Override public int deleteByPrimaryKey(Long id) { @@ -177,7 +180,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { } @Override - public ApiResult rsyncAfterSaleByAftersaleIds(String shopId, String aftersaleIds, boolean fromDyCloud) { + public ApiResult rsyncAfterSaleByAftersaleIds(String shopId, String aftersaleIds, AccessToken accessToken, boolean fromDyCloud) { if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(aftersaleIds) || ObjectUtil.isEmpty(fromDyCloud)) { return ApiResult.fail("参数错误"); } @@ -188,7 +191,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { // // TODO: 2023/9/3 未找到抖店云推送数据 } if (ObjectUtil.isEmpty(ddRet) || !ddRet.isSuccess()) { - ddRet = getAfterSaleDetailFromDd(aftersaleId); + ddRet = getAfterSaleDetailFromDd(aftersaleId, accessToken); } if (!ddRet.isSuccess()) { return ApiResult.fail(ddRet.getMsg()); @@ -407,10 +410,10 @@ public class AfterSaleServiceImpl implements AfterSaleService { return true; } - private ApiResult getAfterSaleDetailFromDd(String aftersaleId) { + private ApiResult getAfterSaleDetailFromDd(String aftersaleId, AccessToken accessToken) { AfterSaleDetailParam param = new AfterSaleDetailParam(); param.setAfterSaleId(aftersaleId); - return DdRequestUtil.getAfterSaleDetailFromDd(param); + return DdRequestUtil.getAfterSaleDetailFromDd(param, accessToken); } @Override @@ -437,10 +440,11 @@ public class AfterSaleServiceImpl implements AfterSaleService { JSONObject msgData = null; String targetShopId = null; + ShopBO shopInfo = null; if (isSuccess) { msgData = StringUtils.isEmpty(aftersaleMsgInfo.getData()) ? new JSONObject() : JSONObject.parseObject(aftersaleMsgInfo.getData()); targetShopId = msgData.getString("shop_id"); - Shop shopInfo = shopMapper.selectByPrimaryKey(Long.valueOf(targetShopId)); + shopInfo = shopService.getShopInfo(Long.valueOf(targetShopId)); if (shopInfo == null) { log.info(String.format("shopId[%s] shop is empty", targetShopId)); isSuccess = false; @@ -454,7 +458,7 @@ public class AfterSaleServiceImpl implements AfterSaleService { afterSaleId = msgData.getString("after_sale_id"); } log.info(String.format("afterSaleId[%s]", afterSaleId)); - ApiResult processRet = rsyncAfterSaleByAftersaleIds(targetShopId, afterSaleId, true); + ApiResult processRet = rsyncAfterSaleByAftersaleIds(targetShopId, afterSaleId, shopInfo.getShopAccessToken(), true); log.info(String.format("processRet: ", JSONObject.toJSONString(processRet))); if (!processRet.isSuccess()) { isSuccess = false; diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/CategoryShopServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/CategoryShopServiceImpl.java index 224670e5..55313300 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/CategoryShopServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/CategoryShopServiceImpl.java @@ -54,6 +54,10 @@ public class CategoryShopServiceImpl implements CategoryShopService{ return categoryShopMapper.getCategoryListByShopId(shopId, maxCid, stepLen); } + @Override + public Category getCategoryListByCategoryId(Long shopId,Long categoryId) { + return categoryShopMapper.getCategoryListByCategoryId(shopId, categoryId); + } } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java index 753a9cf5..4f1a50ce 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/DistributionOrderServiceImpl.java @@ -445,7 +445,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { OpOrder opOrder = orderIdAndOrderMap.get(platformOrder.getPlatformOrderId()); if (purchaseSetting.getIsAutoFillRemark() >= 1) { String autoFillRemarkTpl = buildRemarkTplHtml(purchaseSetting.getAutoFillRemarkTpl()); - platformOrder.setSourceOrderSellerMemo(buildSourceOrderRemarkAndMemo(shop, autoFillRemarkTpl, opOrder)); + platformOrder.setSourceOrderBuyerRemark(buildSourceOrderRemarkAndMemo(shop, autoFillRemarkTpl, opOrder)); } if (purchaseSetting.getIsAutoFillOrderMemo() >= 1) { String autoFillOrderMemoTpl = buildRemarkTplHtml(purchaseSetting.getAutoFillOrderMemoTpl()); @@ -463,6 +463,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { matchRes.appendReplacement(resString, result); } matchRes.appendTail(resString); + log.info("appendRemarkTpl: " + appendRemarkTpl); + log.info("buildSourceOrderRemarkAndMemo: " + resString); return resString.toString(); } @@ -506,8 +508,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { private HashMap buildAndUpdateNewPurchaseOrderRemark(ShopBO shopBO, OpOrder opOrder) { HashMap result = new HashMap<>(); PurchaseSetting purchaseSetting = purchaseSettingService.getByShopId(opOrder.getShopId()); + log.info("purchaseSetting: " + purchaseSetting); List purchaseOrders = purchaseOrderService.getListByOrderId(opOrder.getShopId(), opOrder.getOrderId(), StatusConst.normal,true); - System.out.println("purchaseOrders1" + purchaseOrders); if (purchaseSetting.getIsAppendShopNote() == 0 && purchaseSetting.getIsAppendShopRemark() == 0 && purchaseSetting.getShopRemarkFlag() > 0) { return result; } @@ -534,6 +536,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { if (newSellerWords.equals(oldSellerWords) && String.valueOf(shopRemarkFlag).equals(opOrder.getSellerRemarkStars())) { return newSellerWords; } + log.info("shopRemarkFlag: " + shopRemarkFlag); opOrderService.updateOpOrderSellerRemarkToDb(shopBO, opOrder.getOrderId(), newSellerWords, shopRemarkFlag, false, OrderPrintConst.UPDATE_SELLER_WORD_SOURCE_SINGLE, purchaseOrderRemark); return newSellerWords; } @@ -969,7 +972,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { } if (!needCancelPurchaseOrderIds.isEmpty()) { purchaseOrderService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderIds); - purchaseOrderItemService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderIds); + purchaseOrderItemService.updateStatusByPurchaseIds(StatusConst.cancel, needCancelPurchaseOrderIds); } if (!needCancelPurchaseOrderItemIds.isEmpty()) { purchaseOrderItemService.updateStatusByIds(StatusConst.cancel, needCancelPurchaseOrderItemIds); @@ -1300,7 +1303,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { if (opOrders.isEmpty()) { throw new RuntimeException("订单不存在"); } - List shopIds = opOrders.stream().map(OpOrder::getShopId).collect(Collectors.toList()); + Set shopIds = opOrders.stream().map(OpOrder::getShopId).collect(Collectors.toSet()); if (shopIds.size() != 1 || !shopIds.contains(shopId)) { throw new RuntimeException("订单所属店铺异常"); } @@ -1692,12 +1695,21 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { private void autoPurchaseAfterUpdateDsAutoPurchaseLog(String orderId, List items, Map skuIdAndDsAutoPurchaseLogIdMap, BatchCreateDistributionOrdersResponseDTO dsRet) { List relatePurchaseOrderInfos = new ArrayList<>(); - for (DsSuccessRetDTO successRet : dsRet.getSuccessList()) { + List errorList = dsRet.getErrorList(); + List successList = dsRet.getSuccessList(); + if (errorList == null) { + errorList = new ArrayList<>(); + } + if (successList == null) { + successList = new ArrayList<>(); + } + + for (DsSuccessRetDTO successRet : successList) { relatePurchaseOrderInfos.addAll(successRet.getRelatePurchaseOrderInfos()); } Map platformOrderIdAndRelatePurchaseOrderInfoMap = CommonTool.convertListToMap(relatePurchaseOrderInfos, PurchaseOrderDTO::getPlatformOrderId); - Map platformOrderIdAndReasonMap = dsRet.getErrorList().stream().collect(Collectors.toMap(DsErrorRetDTO::getPlatformOrderId, DsErrorRetDTO::getReason, (value1, value2) -> value1)); + Map platformOrderIdAndReasonMap = errorList.stream().collect(Collectors.toMap(DsErrorRetDTO::getPlatformOrderId, DsErrorRetDTO::getReason, (value1, value2) -> value1)); for (PlatformOrderItemDTO platformItemInfo : items) { PurchaseOrderDTO relatePurchaseOrderInfo = platformOrderIdAndRelatePurchaseOrderInfoMap.get(orderId); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/MoveProductPublishQueueServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/MoveProductPublishQueueServiceImpl.java index dc34f224..a2074b06 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/MoveProductPublishQueueServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/MoveProductPublishQueueServiceImpl.java @@ -76,6 +76,7 @@ public class MoveProductPublishQueueServiceImpl implements MoveProductPublishQue lockMsg.setCopyType(moveCollectTask.getCopyType()); MoveShopSettingBO moveShopSetting = JSON.parseObject(moveCollectTask.getCondition(), MoveShopSettingBO.class); lockMsg.setCondition(moveShopSetting); + lockMsg.setConditionTxt(moveCollectTask.getCondition()); if (!Objects.isNull(lockMsg.getCondition())) { MoveShopSettingBO moveShopSettingBO = lockMsg.getCondition(); moveShopSettingBO.setIsFastMode(moveCollectTaskDetail.getIsFastMode()); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java index 2cedaddf..0a9c3904 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java @@ -1509,7 +1509,7 @@ public class OpOrderServiceImpl implements OpOrderService { } // 添加抖店备注 - Boolean addToDs = addOrderSellerRemarkToDs(shopBO, orderId, remark, BeanUtil.isEmpty(flag), flag); + Boolean addToDs = addOrderSellerRemarkToDd(shopBO, orderId, remark, !BeanUtil.isEmpty(flag), flag); if (BeanUtil.isEmpty(addToDs) || !addToDs) { throw new RuntimeException("添加抖店备注失败"); } @@ -1518,7 +1518,7 @@ public class OpOrderServiceImpl implements OpOrderService { updateShopRemarkUpdateLog(updateLogId); // 最后更新订单的备注 - Boolean update = updateOpOrderSellerRemark(shopId, orderId, remark, BeanUtil.isEmpty(flag), flag); + Boolean update = updateOpOrderSellerRemark(shopId, orderId, remark, !BeanUtil.isEmpty(flag), flag); if (!update) { throw new RuntimeException("修改备注失败"); } @@ -1587,13 +1587,13 @@ public class OpOrderServiceImpl implements OpOrderService { * @param star * @return */ - private Boolean addOrderSellerRemarkToDs(ShopBO shopBO, String orderId, String remark, Boolean isAddStar, Integer star) { + private Boolean addOrderSellerRemarkToDd(ShopBO shopBO, String orderId, String remark, Boolean isAddStar, Integer star) { OrderAddOrderRemarkRequest request = new OrderAddOrderRemarkRequest(); OrderAddOrderRemarkParam param = new OrderAddOrderRemarkParam(); param.setOrderId(orderId); param.setRemark(remark); if (!BeanUtil.isEmpty(isAddStar) && isAddStar && !BeanUtil.isEmpty(star)) { - param.setIsAddStar(isAddStar ? "true" : "false"); + param.setIsAddStar("true"); param.setStar("" + star); } request.setParam(param); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderItemServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderItemServiceImpl.java index 3ea44088..2c9a41e6 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderItemServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderItemServiceImpl.java @@ -71,6 +71,11 @@ public class PurchaseOrderItemServiceImpl implements PurchaseOrderItemService{ return purchaseOrderItemMapper.updateStatusByIds(status, ids); } + @Override + public int updateStatusByPurchaseIds(String status, List purchaseOrderIds) { + return purchaseOrderItemMapper.updateStatusByPurchaseIds(status, purchaseOrderIds); + } + @Override public List getRelatePurchaseOrderItemsByPurchaseOrderId(Long purchaseOrderId) { return purchaseOrderItemMapper.getRelatePurchaseOrderItemsByPurchaseOrderId(purchaseOrderId); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java index 8f47f66e..d0103423 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/PurchaseOrderServiceImpl.java @@ -415,8 +415,9 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { if (ObjectUtil.isNotEmpty(filter.getDsWaitPayStatus())) { whereConditions.append(String.format(" AND ood.ds_wait_pay_status IN (%s)", CommonTool.intToSQLIN(filter.getDsWaitPayStatus()))); } - if (ObjectUtil.isNotEmpty(filter.getPurchaseOrderStatus())) { - whereConditions.append(String.format(" AND ood.ds_purchase_status IN (%s)", CommonTool.stringToSQLIN(CommonTool.splitWithComma(filter.getPurchaseOrderStatus())))); + if (ObjectUtil.isNotEmpty(filter.getDsPurchaseStatus())) { + List dsPurchaseStatus = filter.getDsPurchaseStatus().stream().map(String::valueOf).collect(Collectors.toList()); + whereConditions.append(String.format(" AND ood.ds_purchase_status IN (%s)", CommonTool.stringToSQLIN(dsPurchaseStatus))); } if (ObjectUtil.isNotEmpty(filter.getOrderIds())) { whereConditions.append(String.format(" AND %s.`order_id` IN (%s)", masterTblAlias, CommonTool.stringToSQLIN(filter.getOrderIds()))); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/QueueServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/QueueServiceImpl.java index 2cf9e86e..b515ff83 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/QueueServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/QueueServiceImpl.java @@ -25,10 +25,12 @@ import com.ms.api.service.QueueService; import com.ms.api.tool.CommonTool; import com.ms.dal.mapper.QueueMapper; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @Service +@Slf4j @AllArgsConstructor public class QueueServiceImpl implements QueueService { @@ -58,6 +60,7 @@ public class QueueServiceImpl implements QueueService { } private int unlockSolidRedisSkipQueue(String queueName, String status) { + log.info(String.format("unlockSolidRedisSkipQueue start %s", queueName)); String queueRedisKey = RedisKeyConst.getQueueRedisKey(queueName, false); List redisIds = redisTemplate.opsForList().range(queueRedisKey, 0, -1); if (ObjectUtil.isEmpty(redisIds)) { @@ -80,7 +83,9 @@ public class QueueServiceImpl implements QueueService { queueIdWhere.append(where); } queueIdWhere.append(String.format(" order by %s asc limit %s", queueIdColumnName, limit)); + log.info("whereStr: " + queueIdWhere.toString()); List> queueList = queueMapper.select(queueName, queueIdWhere.toString()); + log.info("queueList size: " + queueList.size()); if (ObjectUtil.isEmpty(queueList)) { break; } @@ -100,16 +105,21 @@ public class QueueServiceImpl implements QueueService { Set tempRedisIds = new HashSet<>(); tempRedisIds.addAll(redisIds); tempRedisIds.addAll(newRedisIds); + log.info("allQueueList count: " + allQueueList.size()); + log.info("tempRedisIds count: " + tempRedisIds.size()); for (Map queue : allQueueList) { - Long queueId = (Long) queue.getOrDefault(queueIdColumnName, null); + Long queueId = ((BigInteger)queue.getOrDefault(queueIdColumnName, null)).longValue(); + log.info("queueId: " + queueId); if (ObjectUtil.isNotNull(queueId)) { String queueIdStr = queueId.toString(); if (redisIds.contains(queueIdStr)) { continue; } + log.info("push queueIdStr: " + queueIdStr); redisTemplate.opsForList().leftPush(queueRedisKey, queueIdStr); } } + log.info(String.format("unlockSolidRedisSkipQueue end %s", queueName)); return allQueueList.size(); } @@ -143,7 +153,7 @@ public class QueueServiceImpl implements QueueService { Map> dataMap = queueMapper.selectShopIdAndCnt(queueName, null); Map shopIdAndQueueCntMap = new HashMap<>(); for (Map.Entry> entry : dataMap.entrySet()) { - shopIdAndQueueCntMap.put(entry.getKey(), (Long) entry.getValue().getOrDefault("cnt", 0L)); + shopIdAndQueueCntMap.put(entry.getKey(), ((BigInteger) entry.getValue().getOrDefault("cnt", 0L)).longValue()); } Map resultMap = new HashMap<>(); for (Map.Entry entry : shopIdAndCntMap.entrySet()) { @@ -196,7 +206,7 @@ public class QueueServiceImpl implements QueueService { Map> dataMap = queueMapper.selectShopIdAndCnt(bufferName, whereStr); for (Map.Entry> entry : dataMap.entrySet()) { String shopId = String.valueOf(entry.getKey()); - result.put(Long.valueOf(shopId), (Long) entry.getValue().getOrDefault("cnt", 0L)); + result.put(Long.valueOf(shopId), ((BigInteger) entry.getValue().getOrDefault("cnt", 0L)).longValue()); } return result; } @@ -223,7 +233,7 @@ public class QueueServiceImpl implements QueueService { public int unlockTimeoutQueue(String tableName, int heartbeatExpiredSeconds, String status) { DateTime deadTime = DateUtil.offsetSecond(new Date(), -heartbeatExpiredSeconds); String where = String.format(" WHERE locked > 0 AND gmt_last_heartbeat < '%s' ", DateUtil.formatDateTime(deadTime)); - if (StrUtil.isBlank(status)) { + if (StrUtil.isNotBlank(status)) { where = where.concat(String.format(" and `status` = %s ", status)); } List> queueList = queueMapper.select(tableName, where); diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java index 6074090e..b94c9892 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java @@ -12,9 +12,11 @@ import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.move.GetProductInfoRequestDTO; import com.ms.api.service.CategoryService; +import com.ms.api.service.CategoryShopService; import com.ms.api.service.MoveSystemSourceCategoryService; import com.ms.api.tool.DsJsonRequestTemplate; import com.ms.dal.entity.Category; +import com.ms.dal.entity.CategoryShop; import com.ms.dal.entity.MoveSystemSourceCategory; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -45,6 +47,9 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi @Autowired private CategoryService categoryService; + @Autowired + private CategoryShopService categoryShopService; + @Override public BaseResponse handle(BaseRequest req) { // ----逻辑校验---- @@ -140,7 +145,7 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi Long categoryId = null; for (Object key : assocMap.keySet()) { System.out.println("key:" + key + ", value:" + assocMap.get(key)); - Category category = categoryService.selectByPrimaryKey(Long.valueOf(key.toString())); + Category category = categoryShopService.getCategoryListByCategoryId(shopId, (Long.valueOf(key.toString()))); if (!ObjectUtil.isEmpty(category)) { Double score = this.getJaroWinklerDistance(sourceCateListStr, category.getPath()); if (score > max) { diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java index 93a47fec..0e3eaaaa 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java @@ -12,12 +12,14 @@ import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.move.GetProductInfoRequestDTO; import com.ms.api.service.CategoryService; +import com.ms.api.service.CategoryShopService; import com.ms.api.service.MoveSystemSourceCategoryService; import com.ms.api.tool.DsJsonRequestTemplate; import com.ms.api.common.UniqueKeyMultiValueMap; import com.ms.dal.entity.Category; import com.ms.dal.entity.MoveSystemSourceCategory; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.phprpc.util.AssocArray; import org.phprpc.util.PHPSerializer; import org.springframework.beans.factory.annotation.Autowired; @@ -47,6 +49,9 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe @Autowired private CategoryService categoryService; + @Autowired + private CategoryShopService categoryShopService; + @Override public BaseResponse handle(BaseRequest req) { initHandle(req); @@ -74,24 +79,26 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe resObj = JSON.parseObject(res); JSONObject product = resObj.getJSONObject("productInfo"); Long sourceCategoryId = product.getLong("1688cid"); + String sourceCateListStr = StringUtils.join(product.getJSONArray("cateList"), ">"); log.info("productInfo:::"+sourceCategoryId.toString()); MoveSystemSourceCategory moveSystemSourceCategory = moveSystemSourceCategoryService.selectBySourceCategoryId(sourceCategoryId.toString()); if (!ObjectUtil.isEmpty(moveSystemSourceCategory)) { - Long moveSystemSourceCategoryId = moveSystemSourceCategory.getMoveSystemSourceCategoryId(); PHPSerializer p = new PHPSerializer(); String content = moveSystemSourceCategory.getMatchCategoryList(); AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes()); - Map assocMap = assocArrayToHash(assocArray); - List assocMapKeys = new ArrayList<>(assocMap.keySet()); - - log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1)); - Long categoryId = Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1)); - List categoryIds = this.getCategoryIdList(categoryId); - Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1))); - String path = category.getPath(); - List pathArr = Arrays.asList(path.split(">")); - product.put("ddCid", categoryIds); - product.put("ddCategoryList", pathArr); + Map assocMap = assocArrayToHash(assocArray); + Long categoryId = this.getBestCategoryId(sourceCateListStr, assocMap); + if (ObjectUtil.isEmpty(categoryId)) { + product.put("ddCid", ""); + product.put("ddCategoryList", ""); + } else { + List categoryIds = this.getCategoryIdList(categoryId); + Category category = categoryService.selectByPrimaryKey(categoryId); + String path = category.getPath(); + List pathArr = Arrays.asList(path.split(">")); + product.put("ddCid", categoryIds); + product.put("ddCategoryList", pathArr); + } } else { product.put("ddCid", ""); product.put("ddCategoryList", ""); @@ -143,4 +150,24 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe log.info(result + "result"); return result; } + private Long getBestCategoryId(String sourceCateListStr, Map assocMap) { + Double max = 0.00; + Long categoryId = null; + for (Object key : assocMap.keySet()) { + System.out.println("key:" + key + ", value:" + assocMap.get(key)); + Category category = categoryShopService.getCategoryListByCategoryId(shopId, (Long.valueOf(key.toString()))); + if (!ObjectUtil.isEmpty(category)) { + Double score = this.getJaroWinklerDistance(sourceCateListStr, category.getPath()); + if (score > max) { + max = score; + categoryId = Long.valueOf(key.toString()); + } + } + } + return categoryId; + } + + private double getJaroWinklerDistance(String first, String second) { + return StringUtils.getJaroWinklerDistance(first, second); + } } diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetRecommendProductListService.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetRecommendProductListService.java new file mode 100644 index 00000000..b3a8c4b6 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetRecommendProductListService.java @@ -0,0 +1,99 @@ +package com.ms.api.spi.move; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.jinritemai.cloud.base.api.BaseRequest; +import com.jinritemai.cloud.base.api.BaseResponse; +import com.jinritemai.cloud.base.api.ExtensionService; +import com.jinritemai.cloud.base.api.ExtensionServiceHandler; +import com.ms.api.biz.DsCatService; +import com.ms.api.common.R; +import com.ms.api.common.Ret; +import com.ms.api.common.SPIBaseService; +import com.ms.api.dto.move.GetRecommendProductListRequestDTO; +import com.ms.api.service.CategoryService; +import com.ms.api.tool.DsJsonRequestTemplate; +import com.ms.dal.entity.Category; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +@ExtensionService("getRecommendProductList") +@Slf4j +public class GetRecommendProductListService extends SPIBaseService implements ExtensionServiceHandler { + + @Autowired + private DsJsonRequestTemplate dsJsonRequestTemplate; + + @Autowired + private DsCatService dsCatService; + + @Autowired + private CategoryService categoryService; + + @Override + public BaseResponse handle(BaseRequest req) { + initHandle(req); + getAuthCode(); + + GetRecommendProductListRequestDTO requestDTO = req.getData(); + + // 1688类目树 + JSONArray arrayData = dsCatService.getDSProductCatTree(); + + // 获取商家抖店类目列表 + List categoryList = categoryService.getAllLeafProductCatListFromTos(shopId.intValue(), false); + Collections.shuffle(categoryList); + + int productCnt = 0; + int categoryIndex = 0; + while (productCnt < requestDTO.getPageSize()) { + + + categoryIndex++; + } + + +// HashMap params = new HashMap<>(); +//// params.put("keyword",fields.getKeyword()); +//// params.put("topCid",fields.getTopCid()); +// params.put("cid",fields.getCid()); +// params.put("sort", "saleCntDesc"); +//// params.put("ruleIds", fields.getRuleIds()); +// params.put("isHideMoved", 1); +// params.put("pageNo",requestDTO.getPageNo()); +// params.put("pageSize",requestDTO.getPageSize()); +// params.put("authCode",authCode); +// log.info(params.toString()); +// JSONObject resObj = null; +// String res = null; +// List products = new LinkedList<>(); +// +// try { +// res = dsJsonRequestTemplate.execute("/move/search_choiceness_source_item", params); +// resObj = JSON.parseObject(res); +// if (resObj.get("result").equals("success")) { +// log.info("resObj::"+resObj.toString()); +// Map result = new HashMap(); +// List sourceItems = new ArrayList<>(); +// JSONArray sourceItemjson = resObj.getJSONArray("sourceItems"); +// if (!ObjectUtil.isEmpty(sourceItemjson)) { +// sourceItems = sourceItemjson; +// } +// result.put("result", resObj.getString("result")); +// result.put("sourceItems", sourceItems); +// result.put("total", resObj.getInteger("total")); +// res = JSON.toJSONString(result); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// log.error(e.getMessage()); +// } + + + return R.ok(Ret.success()); + } +} diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/SearchDSProductCatTreeService.java b/ms-biz/src/main/java/com/ms/api/spi/move/SearchDSProductCatTreeService.java index 0f86e633..a573f4f8 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/SearchDSProductCatTreeService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/SearchDSProductCatTreeService.java @@ -1,29 +1,20 @@ package com.ms.api.spi.move; -import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.ExtensionService; import com.jinritemai.cloud.base.api.ExtensionServiceHandler; +import com.ms.api.biz.DsCatService; import com.ms.api.common.R; import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; import com.ms.api.dto.move.SearchDSProductCatTreeRequestDTO; -import com.ms.api.paas.StorageService; -import com.ms.api.tool.DsJsonRequestTemplate; -import com.ms.api.common.UniqueKeyMultiValueMap; -import com.ms.api.tool.MoveTool; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.MultiValueMap; -import java.io.*; -import java.net.URL; -import java.sql.Array; -import java.util.*; +import java.util.HashMap; +import java.util.Map; /** * 获取搜索列表的类目过滤条件 @@ -35,10 +26,7 @@ import java.util.*; public class SearchDSProductCatTreeService extends SPIBaseService implements ExtensionServiceHandler { @Autowired - private DsJsonRequestTemplate dsJsonRequestTemplate; - - @Autowired - private StorageService storageService; + private DsCatService dsCatService; @Override public BaseResponse handle(BaseRequest req) { @@ -48,37 +36,7 @@ public class SearchDSProductCatTreeService extends SPIBaseService implements Ext // ----逻辑校验---- // ----业务处理---- - HashMap params = new HashMap<>(); - String res = null; - JSONObject resObj = null; - String tosPath = MoveTool.getAllProductCatTreeOssPath(); - List arrayData = null; - try { - Ret getTosContentRet = storageService.getContent(tosPath); - if (getTosContentRet.getResult().equals("success")) { - arrayData = JSONObject.parseArray(getTosContentRet.getData().get("data").toString()); - } else { - try { - res = dsJsonRequestTemplate.execute("/move/search_ds_product_cat_tree", params); - log.info(res); - resObj = JSON.parseObject(res); - if (resObj.get("result").equals("success")) { - JSONObject cateTree = resObj.getJSONObject("cateTree"); - arrayData = new ArrayList<>(cateTree.values()); - try { - storageService.uploadContent(tosPath, JSONObject.toJSONString(arrayData)); - } catch (Exception e) { - log.error("商品类目TOS写入操作过程异常:", e); - } - } - } catch (Exception e) { - e.printStackTrace(); - log.error("strerror2:" + e); - } - } - } catch (Exception e) { - log.error("商品类目TOS读取操作过程异常:", e); - } + JSONArray arrayData = dsCatService.getDSProductCatTree(); Map result = new HashMap<>(); result.put("data", arrayData.toString()); diff --git a/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseMoveBufferToQueueTaskService.java b/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseMoveBufferToQueueTaskService.java index aaa59d79..f20435bf 100644 --- a/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseMoveBufferToQueueTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseMoveBufferToQueueTaskService.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -53,6 +54,7 @@ public class DsAutoPurchaseMoveBufferToQueueTaskService extends TaskBaseService } @Async("dsAutoPurchaseMoveBufferToQueueTaskPool") + @Scheduled(fixedRate = 10000) @Override public void runTask() { super.runTask(); diff --git a/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseTaskService.java b/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseTaskService.java index 1a97ff10..1b94d63f 100644 --- a/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/DsAutoPurchaseTaskService.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -60,6 +61,7 @@ public class DsAutoPurchaseTaskService extends TaskBaseService { } @Async("dsAutoPurchaseTaskPool") + @Scheduled(fixedRate = 10000) @Override public void runTask() { super.runTask(); diff --git a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java index fb06c3bc..e1d9a3b9 100644 --- a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java @@ -49,7 +49,14 @@ import com.doudian.open.api.product_getCatePropertyV2.data.ProductGetCatePropert import com.doudian.open.core.AccessToken; import com.ms.api.biz.MoveService; import com.ms.api.biz.SaveBatchMoveTaskBizService; -import com.ms.api.bo.*; +import com.ms.api.bo.AttributeBO; +import com.ms.api.bo.CateAttributeResultBO; +import com.ms.api.bo.CategoryBO; +import com.ms.api.bo.MoveProductPublishQueueBO; +import com.ms.api.bo.MoveShopSettingBO; +import com.ms.api.bo.RedisKeyBO; +import com.ms.api.bo.SkuDetailBO; +import com.ms.api.bo.SkuInfoBO; import com.ms.api.common.ApiResult; import com.ms.api.common.E; import com.ms.api.common.Ret; @@ -98,7 +105,6 @@ import com.ms.dal.entity.Shop; import com.ms.dal.entity.Shop1688DsAuth; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -623,7 +629,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService { return CommonTool.numFormat(price, 0) + Double.parseDouble("." + strPriceDecimalDiyValue); } - private List checkHasRepeatSpec(List colorSpecArrCalc, List sizeSpecArrCalc) { List repeatSpecArr = new ArrayList<>(); @@ -777,7 +782,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { ProductGetCatePropertyV2Data attrRetData = (ProductGetCatePropertyV2Data) categoryAttrRet.getData().get("data"); List attributes = attrRetData.getData(); String title = productDetailBase.getString("title"); - Map> productFormatNew = buildProductAttrs(attributes, sourceAttrs, title); + Map> productFormatNew = buildProductAttrs(attributes, sourceAttrs, title,queueMsg); productFormatNew = attachBrand2ProductFormatNew(brandId, brandName, productFormatNew); productDetailBase.put("productFormatNew", productFormatNew); @@ -890,9 +895,17 @@ public class ProcessProductPublishTaskService extends TaskBaseService { return productFormatNew; } - private Map> buildProductAttrs(List attributes, JSONObject sourceAttrs, String title) { + private Map> buildProductAttrs(List attributes, JSONObject sourceAttrs, String title,MoveProductPublishQueueBO queueMsg) { + JSONObject condition = JSONObject.parseObject(queueMsg.getConditionTxt()); + JSONArray presetAttrs = condition.containsKey("presetAttrs") ? condition.getJSONArray("presetAttrs") : new JSONArray(); + if (condition.containsKey("taskPresetAttrs")){ + presetAttrs.addAll(condition.getJSONArray("taskPresetAttrs")); + } + Map> matchAttrs = new HashMap<>(); + List currAttrName= new ArrayList<>(); for (DataItem attribute : attributes) { + currAttrName.add(attribute.getPropertyName()); long currAid = attribute.getPropertyId(); List matchList = matchSourceAttr(attribute, sourceAttrs, title); if (ObjectUtil.isNotEmpty(matchList)) { @@ -925,9 +938,9 @@ public class ProcessProductPublishTaskService extends TaskBaseService { if (ObjectUtil.isNotEmpty(matchAttr)) { for (StrObjMap v : matchAttr) { StrObjMap item = new StrObjMap(); - item.put("name",v.get("name")); - item.put("diy_type",v.get("diy_type")); - item.put("value",100); + item.put("name", v.get("name")); + item.put("diy_type", v.get("diy_type")); + item.put("value", 100); result.add(item); // if (v.containsKey("value")) { @@ -950,7 +963,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { TreeMap matchVids = new TreeMap<>(Collections.reverseOrder()); Map matchSourceAttrs = new HashMap<>(); double maxPercent = -1; - String maxMatchAttrValue = ObjectUtil.isNotEmpty(attribute.getOptions())? attribute.getOptions().get(0).getValue():""; + String maxMatchAttrValue = ObjectUtil.isEmpty(attribute.getOptions()) ? "0" : attribute.getOptions().get(0).getValue(); StrObjMap sourceValueMap = searchSourceValue(sourceAttrs, attribute.getPropertyName()); String sourceValue = (String) sourceValueMap.get("sourceValue"); @@ -1537,11 +1550,11 @@ public class ProcessProductPublishTaskService extends TaskBaseService { private String buildSkuListKey(JSONObject firstAttr, JSONObject secondAttr, List filterWordArray) { String firstName = firstAttr.getString("newName") != null ? firstAttr.getString("newName") : - (firstAttr.getString("calName") != null ? firstAttr.getString("calName") : firstAttr.getString("name")); + (firstAttr.getString("calName") != null ? firstAttr.getString("calName") : firstAttr.getString("name")); firstName = filterBanWordsList(filterWordArray, firstName, true); String secondName = secondAttr.getString("newName") != null ? secondAttr.getString("newName") : - (secondAttr.getString("calName") != null ? secondAttr.getString("calName") : secondAttr.getString("name")); + (secondAttr.getString("calName") != null ? secondAttr.getString("calName") : secondAttr.getString("name")); secondName = filterBanWordsList(filterWordArray, secondName, true); if (secondAttr != null && secondName.isEmpty()) { @@ -1562,7 +1575,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService { return firstName + ";-;" + secondName; } - private String filterBanWordsList(List filterWordArray, String oriText, boolean isReplace) { String[] banWords = {"&", "\\", "\r\n", "\r", "\n", "\t"}; for (String word : banWords) { @@ -1637,7 +1649,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService { return stepStock; } - private int buildSkuStock(JSONObject skuMap, String cAv, String sAv) { int stock = 0; @@ -1682,20 +1693,19 @@ public class ProcessProductPublishTaskService extends TaskBaseService { if (checkBuidSkuCondition) { String sourceSkuCode = skuInfo.containsKey("skuCode") ? skuInfo.getString("skuCode") : ""; skuCode = skuInfo.containsKey("newSkuCode") ? skuInfo.getString("newSkuCode") : - (skuInfo.containsKey("calSkuCode") ? skuInfo.getString("calSkuCode") : sourceSkuCode); + (skuInfo.containsKey("calSkuCode") ? skuInfo.getString("calSkuCode") : sourceSkuCode); break; } } return skuCode != null ? skuCode : ""; } - private double buildSkuPrice(JSONObject skuMap, String cAv, String sAv, double defaultPrice) { double price = 0; for (Map.Entry entry : skuMap.entrySet()) { - String skuPropStr = (String)entry.getKey(); - SkuInfoBO skuInfo = JSONObject.parseObject (JSON.toJSONString(entry.getValue()),SkuInfoBO.class); + String skuPropStr = (String) entry.getKey(); + SkuInfoBO skuInfo = JSONObject.parseObject(JSON.toJSONString(entry.getValue()), SkuInfoBO.class); boolean checkBuildSkuCondition = checkBuildSkuCondition(skuPropStr, cAv, sAv); if (checkBuildSkuCondition) { @@ -1715,7 +1725,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { } } - return price > 0 ? CommonTool.numFormat(price,2) : CommonTool.numFormat(defaultPrice,2); + return price > 0 ? CommonTool.numFormat(price, 2) : CommonTool.numFormat(defaultPrice, 2); } public boolean checkBuildSkuCondition(String skuPropStr, String cAv, String sAv) { @@ -1727,7 +1737,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { boolean checkSize = false; skuPropStr = skuPropStr.trim(); - sAv = StringUtils.isNotBlank(sAv)? sAv.trim():""; + sAv = StringUtils.isNotBlank(sAv) ? sAv.trim() : ""; if (ObjectUtil.isNotEmpty(sAv) && ObjectUtil.isNotEmpty(skuPropStr)) { checkSize = true; } else { @@ -1769,7 +1779,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { price = skuInfo.getDouble("sale_price"); } - priceArr.add(CommonTool.numFormat(price,2)); + priceArr.add(CommonTool.numFormat(price, 2)); } return priceArr.stream().mapToDouble(v -> v).max().orElse(0.0); diff --git a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java index c674b354..37be697c 100644 --- a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java +++ b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java @@ -1,7 +1,5 @@ package com.ms.api.util; -import java.util.List; - import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.doudian.open.api.afterSale_Detail.AfterSaleDetailRequest; @@ -58,6 +56,8 @@ import com.ms.api.consts.AppConst; import com.ms.api.tool.CommonTool; import lombok.extern.slf4j.Slf4j; +import java.util.List; + @Slf4j public class DdRequestUtil { @@ -143,7 +143,7 @@ public class DdRequestUtil { return ApiResult.fail(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg())); } - public static ApiResult getAfterSaleDetailFromDd(AfterSaleDetailParam param) { + public static ApiResult getAfterSaleDetailFromDd(AfterSaleDetailParam param, AccessToken accessToken) { String activeProfile = System.getenv("sys-deploy-env"); if (!"Prod".equals(activeProfile)) { AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID); @@ -151,7 +151,7 @@ public class DdRequestUtil { AfterSaleDetailRequest request = new AfterSaleDetailRequest(); request.setParam(param); log.info("=============Dd请求餐素:{}===================", JSONObject.toJSONString(param)); - AfterSaleDetailResponse response = request.execute(); + AfterSaleDetailResponse response = ObjectUtil.isNull(accessToken) ? request.execute() : request.execute(accessToken); log.info("=============Dd请求返回:{}===================", JSONObject.toJSONString(response)); boolean success = CommonTool.checkDdApiRequestIsSuccess(response); if (success && ObjectUtil.isNotEmpty(response.getData())) { diff --git a/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java b/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java index 4cfe4f61..753f45c9 100644 --- a/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java +++ b/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java @@ -91,6 +91,6 @@ public class OrderUtil { afterSaleService.tryRsyncAfterSale(authShopId,100,null); return ApiResult.ok(); } - return afterSaleService.rsyncAfterSaleByAftersaleIds(authShopId, aftersaleIds,false); + return afterSaleService.rsyncAfterSaleByAftersaleIds(authShopId, aftersaleIds, null, false); } } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/CategoryShopMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/CategoryShopMapper.java index c556fdf7..66869026 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/CategoryShopMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/CategoryShopMapper.java @@ -29,5 +29,7 @@ public interface CategoryShopMapper { List selectCategoryIdListByShopId(Integer shopId); + Category getCategoryListByCategoryId(Long shopId,Long categoryId); + int deleteByShopIdAndCategoryIds(@Param("shopId") Integer shopId, @Param("categoryIds") List categoryIds); } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java index 3de081d6..621d5342 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java @@ -36,6 +36,8 @@ public interface PurchaseOrderItemMapper { int updateStatusByIds(@Param("status") String status, @Param("ids") List ids); + int updateStatusByPurchaseIds(@Param("status") String status, @Param("purchaseOrderIds") List purchaseOrderIds); + int updateStatusByOrderId(@Param("shopId") Long shopId, @Param("orderId") String orderId, @Param("status") String status); List getSkuIdsByOrderId(@Param("orderId") String orderId); diff --git a/ms-dal/src/main/resources/mapper/CategoryShopMapper.xml b/ms-dal/src/main/resources/mapper/CategoryShopMapper.xml index 74a6572d..3c76f886 100644 --- a/ms-dal/src/main/resources/mapper/CategoryShopMapper.xml +++ b/ms-dal/src/main/resources/mapper/CategoryShopMapper.xml @@ -11,6 +11,18 @@ + + + + + + + + + + + + shop_id,category_id,gmt_create, gmt_modified @@ -27,6 +39,17 @@ LIMIT #{stepLen} + + select poi.ware_id, poi.sku_id, poi.purchase_platform