diff --git a/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java b/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java index 701060e9..1d0e3972 100644 --- a/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java +++ b/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java @@ -81,4 +81,6 @@ public interface OpOrderService { Boolean batchCancelIsolation(String shopId, List orderIds); Long tryRsyncOpOrder(Long shopid, String app, Integer priority, Date forceStart); + + Map checkRsyncDataFinished(List shopIds); } 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 b28b7234..0016e3f2 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 @@ -1687,7 +1687,8 @@ public class OpOrderServiceImpl implements OpOrderService { @Override public Long tryRsyncOpOrder(Long shopid, String app, Integer priority, Date forceStart) { - OpOrderRsyncQueue queueInfo = opOrderRsyncQueueMapper.getByShopId(shopid); + List list = opOrderRsyncQueueMapper.getByShopId(Arrays.asList(shopid.toString())); + OpOrderRsyncQueue queueInfo = ObjectUtil.isEmpty(list) ? null : list.get(0); Long queueId = 0L; if (ObjectUtil.isNull(queueInfo)) { queueInfo = new OpOrderRsyncQueue(); @@ -1719,12 +1720,25 @@ public class OpOrderServiceImpl implements OpOrderService { queueInfo.setGmtModified(new Date()); queueInfo.setPriority(priority < queueInfo.getPriority() ? priority : queueInfo.getPriority()); - if (ObjectUtil.isNotNull(forceStart)){ + if (ObjectUtil.isNotNull(forceStart)) { queueInfo.setGmtForceStart(forceStart); } opOrderRsyncQueueMapper.updateByPrimaryKey(queueInfo); return queueInfo.getOpOrderRsyncQueueId(); } + @Override + public Map checkRsyncDataFinished(List shopIds) { + Map result = new HashMap(); + result.put("orderRsyncFinished", 1); + result.put("synchronizingUserIds", new ArrayList<>()); + if (ObjectUtil.isEmpty(shopIds)) { + return result; + } + List opOrderRsyncQueueList = opOrderRsyncQueueMapper.getByShopId(shopIds); + result.put("orderRsyncFinished", ObjectUtil.isNotEmpty(opOrderRsyncQueueList) ? 0 : 1); + result.put("synchronizingUserIds", opOrderRsyncQueueList.stream().map(OpOrderRsyncQueue::getShopId).collect(Collectors.toList())); + return result; + } } diff --git a/ms-biz/src/main/java/com/ms/api/spi/order/CheckRsyncDataFinishedService.java b/ms-biz/src/main/java/com/ms/api/spi/order/CheckRsyncDataFinishedService.java new file mode 100644 index 00000000..68e71d5d --- /dev/null +++ b/ms-biz/src/main/java/com/ms/api/spi/order/CheckRsyncDataFinishedService.java @@ -0,0 +1,37 @@ +package com.ms.api.spi.order; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Resource; + +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.common.R; +import com.ms.api.common.Ret; +import com.ms.api.common.SPIBaseService; +import com.ms.api.consts.DsOrderConst; +import com.ms.api.consts.PurchaseOrderConst; +import com.ms.api.dto.order.SearchDsOrderFilterDTO; +import com.ms.api.dto.order.SearchDsOrderListRequestDTO; +import com.ms.api.service.OpOrderService; +import com.ms.api.service.PurchaseOrderService; +import com.ms.api.util.PurchaseOrderUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +@ExtensionService("checkRsyncDataFinished") +@Slf4j +public class CheckRsyncDataFinishedService extends SPIBaseService implements ExtensionServiceHandler { + + @Resource + private OpOrderService opOrderService; + + @Override + public BaseResponse handle(BaseRequest req) { + initHandle(req); + return R.ok(Ret.success(opOrderService.checkRsyncDataFinished(Arrays.asList(req.getAuthId())))); + } +} diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncQueueMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncQueueMapper.java index 4a8b5397..cb568a75 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncQueueMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/OpOrderRsyncQueueMapper.java @@ -1,5 +1,7 @@ package com.ms.dal.mapper; +import java.util.List; + import com.ms.dal.entity.OpOrderRsyncQueue; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -22,5 +24,5 @@ public interface OpOrderRsyncQueueMapper { int updateByPrimaryKey(OpOrderRsyncQueue record); - OpOrderRsyncQueue getByShopId(@Param("shopId") Long shopid); + List getByShopId(@Param("shopIds") List shopid); } diff --git a/ms-dal/src/main/resources/mapper/OpOrderRsyncQueueMapper.xml b/ms-dal/src/main/resources/mapper/OpOrderRsyncQueueMapper.xml index eca4dc10..096f1ce3 100644 --- a/ms-dal/src/main/resources/mapper/OpOrderRsyncQueueMapper.xml +++ b/ms-dal/src/main/resources/mapper/OpOrderRsyncQueueMapper.xml @@ -43,7 +43,13 @@ diff --git a/ms-web/src/main/java/com/ms/web/OrderTestController.java b/ms-web/src/main/java/com/ms/web/OrderTestController.java index ea71e6a6..5e7944a7 100644 --- a/ms-web/src/main/java/com/ms/web/OrderTestController.java +++ b/ms-web/src/main/java/com/ms/web/OrderTestController.java @@ -21,6 +21,7 @@ import com.ms.api.dto.order.RsyncFullOrderRequestDTO; import com.ms.api.dto.order.SearchDsOrderFilterDTO; import com.ms.api.dto.order.SearchDsOrderListRequestDTO; import com.ms.api.service.OpOrderExtService; +import com.ms.api.service.OpOrderService; import com.ms.api.service.PurchaseOrderService; import com.ms.api.tool.CommonTool; import com.ms.api.util.OrderUtil; @@ -57,6 +58,9 @@ public class OrderTestController { @Resource private PurchaseOrderUtil purchaseOrderUtil; + @Resource + private OpOrderService opOrderService; + @GetMapping("/searchDsOrderList") public BaseResponse> searchDsOrderList() { String shopId = AppConst.TEST_SHOP_ID; @@ -70,6 +74,13 @@ public class OrderTestController { return R.ok(pager); } + + @GetMapping("/checkRsyncDataFinished") + public BaseResponse checkRsyncDataFinished() { + String shopId = AppConst.TEST_SHOP_ID; + return R.ok(Ret.success(opOrderService.checkRsyncDataFinished(Arrays.asList(shopId)))); + } + @GetMapping("/rsyncFullOrder") public BaseResponse rsyncFullOrder() { String shopId = AppConst.TEST_SHOP_ID;