检查订单同步是否结束

20230922-ljl-fixBug
daixiaogang 1 year ago
parent cc77d4293a
commit 6d023b12b0

@ -81,4 +81,6 @@ public interface OpOrderService {
Boolean batchCancelIsolation(String shopId, List<String> orderIds);
Long tryRsyncOpOrder(Long shopid, String app, Integer priority, Date forceStart);
Map<String, Object> checkRsyncDataFinished(List<String> shopIds);
}

@ -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<OpOrderRsyncQueue> 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<String, Object> checkRsyncDataFinished(List<String> shopIds) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("orderRsyncFinished", 1);
result.put("synchronizingUserIds", new ArrayList<>());
if (ObjectUtil.isEmpty(shopIds)) {
return result;
}
List<OpOrderRsyncQueue> 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;
}
}

@ -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<Void, Ret> {
@Resource
private OpOrderService opOrderService;
@Override
public BaseResponse<Ret> handle(BaseRequest<Void> req) {
initHandle(req);
return R.ok(Ret.success(opOrderService.checkRsyncDataFinished(Arrays.asList(req.getAuthId()))));
}
}

@ -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<OpOrderRsyncQueue> getByShopId(@Param("shopIds") List<String> shopid);
}

@ -43,7 +43,13 @@
<select id="getByShopId" resultType="com.ms.dal.entity.OpOrderRsyncQueue">
select *
from op_order_rsync_queue
where shop_id = #{shopId}
where 1=1
<if test="shopIds!=null and shopIds.size>0">
AND shop_id IN
<foreach collection="shopIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

@ -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<Pager<JSONObject>> searchDsOrderList() {
String shopId = AppConst.TEST_SHOP_ID;
@ -70,6 +74,13 @@ public class OrderTestController {
return R.ok(pager);
}
@GetMapping("/checkRsyncDataFinished")
public BaseResponse<Ret> checkRsyncDataFinished() {
String shopId = AppConst.TEST_SHOP_ID;
return R.ok(Ret.success(opOrderService.checkRsyncDataFinished(Arrays.asList(shopId))));
}
@GetMapping("/rsyncFullOrder")
public BaseResponse<Ret> rsyncFullOrder() {
String shopId = AppConst.TEST_SHOP_ID;

Loading…
Cancel
Save