diff --git a/ms-api/src/main/java/com/ms/api/dto/common/ResultDTO.java b/ms-api/src/main/java/com/ms/api/dto/common/ResultDTO.java new file mode 100644 index 00000000..6a298dad --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/common/ResultDTO.java @@ -0,0 +1,68 @@ +package com.ms.api.dto.common; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ResultDTO { + public final static String SUCCESS = "success"; + public final static String FAIL = "fail"; + + private String result; + private String reason; + private String code; + private String message; + private Map data = new HashMap<>(); + + public boolean isSuccess() { + return "success".equals(result); + } + + public static ResultDTO success() { + ResultDTO result = new ResultDTO(); + result.setResult(SUCCESS); + result.setReason("成功"); + result.setCode(SUCCESS); + result.setMessage("成功"); + return result; + } + + public static ResultDTO success(Map data) { + ResultDTO result = new ResultDTO(); + result.setResult(SUCCESS); + result.setReason("成功"); + result.setCode(SUCCESS); + result.setMessage("成功"); + result.setData(data); + return result; + } + + public static ResultDTO fail() { + ResultDTO result = new ResultDTO(); + result.setResult(FAIL); + result.setReason("失败"); + result.setCode(FAIL); + result.setMessage("失败"); + return result; + } + + public static ResultDTO fail(String message) { + ResultDTO result = new ResultDTO(); + result.setResult(FAIL); + result.setReason(message); + result.setCode(FAIL); + result.setMessage(message); + return result; + } + + public static ResultDTO fail(String code, String message) { + ResultDTO result = new ResultDTO(); + result.setResult(FAIL); + result.setReason(message); + result.setCode(code); + result.setMessage(message); + return result; + } +} diff --git a/ms-api/src/main/java/com/ms/api/dto/dsapi/response/GetOrderPayProtocolPayResponseDTO.java b/ms-api/src/main/java/com/ms/api/dto/dsapi/response/GetOrderPayProtocolPayResponseDTO.java new file mode 100644 index 00000000..b3ef21dd --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/dsapi/response/GetOrderPayProtocolPayResponseDTO.java @@ -0,0 +1,31 @@ +package com.ms.api.dto.dsapi.response; + +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Data +public class GetOrderPayProtocolPayResponseDTO extends CommonResponseDTO { + + private Map data; + + public List getPaymentAgreements() { + List result = new ArrayList<>(); + if(data.get("paymentAgreements") instanceof List) { + for (Object o : (List) data.get("paymentAgreements")) { + result.add((PaymentAgreement) o); + } + } + return result; + } + + @Data + public static class PaymentAgreement implements Serializable { + private String payChannel; + private String signedStatus; + private String bindingStatus; + } +} diff --git a/ms-biz/src/main/java/com/ms/api/service/DsApiService.java b/ms-biz/src/main/java/com/ms/api/service/DsApiService.java index a508d7be..e31d7e00 100644 --- a/ms-biz/src/main/java/com/ms/api/service/DsApiService.java +++ b/ms-biz/src/main/java/com/ms/api/service/DsApiService.java @@ -20,4 +20,6 @@ public interface DsApiService { CommonResponseDTO cancelPurchaseOrderRelate(String platform, Long shopId, String orderId, List skuIds); CommonResponseDTO cancelPurchaseOrder(String platform, Long shopId, String orderId, String purchaseOrderSn); GetPurchaseOrderPayUrlResponseDTO getPurchaseOrderPayUrl(List sourceOrderId, Long shopId); + GetOrderPayProtocolPayResponseDTO getOrderPayProtocolPay(Long shopId); + String findSimilarProducts(String img, String authCode); } diff --git a/ms-biz/src/main/java/com/ms/api/service/DsMessageService.java b/ms-biz/src/main/java/com/ms/api/service/DsMessageService.java index 6e74e031..fd7bfea5 100644 --- a/ms-biz/src/main/java/com/ms/api/service/DsMessageService.java +++ b/ms-biz/src/main/java/com/ms/api/service/DsMessageService.java @@ -1,7 +1,7 @@ package com.ms.api.service; import com.ms.api.dto.dsorder.DsMessageDTO; -import com.ms.api.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.dal.entity.DsMessage; import com.ms.dal.entity.DsMessageConsumerQueue; import org.springframework.lang.Nullable; diff --git a/ms-biz/src/main/java/com/ms/api/service/OpOrderOutstorageHistoryService.java b/ms-biz/src/main/java/com/ms/api/service/OpOrderOutstorageHistoryService.java index 9fabd1a3..18c0ddb7 100644 --- a/ms-biz/src/main/java/com/ms/api/service/OpOrderOutstorageHistoryService.java +++ b/ms-biz/src/main/java/com/ms/api/service/OpOrderOutstorageHistoryService.java @@ -1,16 +1,12 @@ package com.ms.api.service; import java.util.List; -import java.util.Map; import com.ms.api.common.Pager; -import com.ms.api.dto.dsorder.ResultDTO; -import com.ms.api.dto.move.SearchMoveProductItemRequestDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.order.SearchOutstorageLogListRequestDTO; -import com.ms.dal.entity.MicroMoveProductItem; import com.ms.dal.entity.OpOrder; import com.ms.dal.entity.OpOrderOutstorageHistory; -import com.ms.dal.entity.PurchaseOrder; /** * diff --git a/ms-biz/src/main/java/com/ms/api/service/OutstorageService.java b/ms-biz/src/main/java/com/ms/api/service/OutstorageService.java index 5ba87f0b..8a10816f 100644 --- a/ms-biz/src/main/java/com/ms/api/service/OutstorageService.java +++ b/ms-biz/src/main/java/com/ms/api/service/OutstorageService.java @@ -1,8 +1,7 @@ package com.ms.api.service; -import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData; import com.ms.api.bo.ShopBO; -import com.ms.api.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; import com.ms.dal.bo.OpLogisticsPlatformBO; import com.ms.dal.entity.OpOrder; diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/DsApiServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/DsApiServiceImpl.java index e2db3a59..ce863d9b 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/DsApiServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/DsApiServiceImpl.java @@ -110,6 +110,23 @@ public class DsApiServiceImpl implements DsApiService { return JSON.parseObject(resp, GetPurchaseOrderPayUrlResponseDTO.class); } + @Override + public GetOrderPayProtocolPayResponseDTO getOrderPayProtocolPay(Long shopId) { + Map params = new HashMap<>(); + params.put("shopId", SecurityTool.encodeByAES(String.valueOf(shopId))); + params.put("platform", CommonConst.PLATFORM); + String resp = execute("/order/getOrderPayProtocolPay", params); + return JSON.parseObject(resp, GetOrderPayProtocolPayResponseDTO.class); + } + + @Override + public String findSimilarProducts(String img, String authCode) { + Map params = new HashMap<>(); + params.put("img", img); + params.put("authCode", authCode); + return execute("/move/find_similar_products", params); + } + private Map objectToMap(Object obj) { Map map = new HashMap<>(); Class clazz = obj.getClass(); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageConsumerQueueServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageConsumerQueueServiceImpl.java index 5cace7be..bdb7a4a6 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageConsumerQueueServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageConsumerQueueServiceImpl.java @@ -1,12 +1,10 @@ package com.ms.api.service.impl; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.ms.api.common.ApiResult; import com.ms.api.consts.RedisKeyConst; import com.ms.api.consts.TblConst; -import com.ms.api.dto.dsorder.ResultDTO; import com.ms.dal.entity.DsMessageConsumerBuffer; import com.ms.dal.entity.DsMessageConsumerQueue; import com.ms.api.service.DsMessageConsumerQueueService; @@ -19,7 +17,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageServiceImpl.java index 37cc5749..7dc33cf1 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/DsMessageServiceImpl.java @@ -3,6 +3,7 @@ package com.ms.api.service.impl; import com.alibaba.fastjson.JSONObject; import com.ms.api.consts.DsMessageConst; import com.ms.api.consts.StatusConst; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.dsorder.*; import com.ms.api.service.DsMessageConsumerBufferService; import com.ms.api.service.DsMessageConsumerQueueService; diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderOutstorageHistoryServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderOutstorageHistoryServiceImpl.java index 92bb85c5..8a225dbc 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderOutstorageHistoryServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderOutstorageHistoryServiceImpl.java @@ -5,9 +5,8 @@ import java.util.*; import cn.hutool.core.util.ObjectUtil; import com.ms.api.common.Pager; import com.ms.api.consts.StatusConst; -import com.ms.api.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.order.SearchOutstorageLogListRequestDTO; -import com.ms.dal.entity.MicroMoveProductItem; import com.ms.dal.entity.OpOrder; import com.ms.dal.entity.OpOrderOutstorageHistory; import com.ms.api.service.OpOrderOutstorageHistoryService; @@ -58,7 +57,7 @@ public class OpOrderOutstorageHistoryServiceImpl implements OpOrderOutstorageHis @Override public List getLastHistoryId(List shopIds, List orderIds) { if (ObjectUtil.isEmpty(shopIds) || ObjectUtil.isEmpty(orderIds)) { - return new ArrayList(); + return new ArrayList<>(); } return opOrderOutstorageHistoryMapper.getLastHistoryId(shopIds, orderIds); } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java index 70776ace..e8c4fde9 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java @@ -17,13 +17,12 @@ import com.ms.api.bo.ShopBO; import com.ms.api.consts.*; import com.ms.api.dto.dsorder.DeliverInfoDTO; import com.ms.api.dto.dsorder.OrderPackageInfoDTO; -import com.ms.api.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; import com.ms.api.exception.DeliveryNotReceivedException; import com.ms.api.service.*; import com.ms.api.tool.CommonTool; import com.ms.api.tool.OrderTool; -import com.ms.api.tool.PurchaseTool; import com.ms.dal.bo.OpLogisticsBO; import com.ms.dal.bo.OpLogisticsPlatformBO; import com.ms.dal.entity.*; @@ -286,7 +285,13 @@ public class OutstorageServiceImpl implements OutstorageService { } } catch (RuntimeException e) { log.error("dsPurchaseAutoOutStorageError_" + opOrder.getOrderId(), e); - opOrderOutstorageHistoryService.addOrderOutstorageHistory(shopBO.getShopId(), Collections.singletonList(opOrder.getOrderId()), 0, purchaseOrder.getPurchaseOrderWaybillCode(), LogisticsConst.outstorageSourceDsAuto, 0, ResultDTO.fail(e.getMessage())); + Map logisticsNameAndLogisticsInfoMap = opLogisticsPlatformService.getDdLogisticsNameAndLogisticsInfoMap(); + Map logisticsInfo = matchPurchaseLogisticsInfo(purchaseOrder.getPurchasePlatform(), purchaseOrder.getPurchaseOrderLogisticsName(), purchaseOrder.getPurchaseOrderWaybillCode(), logisticsNameAndLogisticsInfoMap); + Integer logisticsId = 0; + if (logisticsInfo != null && logisticsNameAndLogisticsInfoMap.containsKey(logisticsInfo.get("logisticsName"))) { + logisticsId = logisticsNameAndLogisticsInfoMap.get(logisticsInfo.get("logisticsName")).getLogisticsId(); + } + opOrderOutstorageHistoryService.addOrderOutstorageHistory(shopBO.getShopId(), Collections.singletonList(opOrder.getOrderId()), logisticsId, purchaseOrder.getPurchaseOrderWaybillCode(), LogisticsConst.outstorageSourceDsAuto, 0, ResultDTO.fail(e.getMessage())); } } @@ -620,7 +625,9 @@ public class OutstorageServiceImpl implements OutstorageService { throw new RuntimeException("外部订单【" + purchaseOrder.getPurchaseOrderSn() + "】未揽收"); } - String logisticsName = PurchaseTool.getDdLogisticsNameByDsLogisticsName(purchaseOrder.getPurchaseOrderLogisticsName()); + Map logisticsInfo = matchPurchaseLogisticsInfo(purchaseOrder.getPurchasePlatform(), purchaseOrder.getPurchaseOrderLogisticsName(), purchaseOrder.getPurchaseOrderWaybillCode(), logisticsNameAndLogisticsInfoMap); +// String logisticsName = PurchaseTool.getDdLogisticsNameByDsLogisticsName(purchaseOrder.getPurchaseOrderLogisticsName()); + String logisticsName = logisticsInfo.get("logisticsName"); log.info("logisticsName: " + logisticsName); OpLogisticsPlatformBO logisticsPlatformBO = logisticsNameAndLogisticsInfoMap.get(logisticsName); log.info("logisticsPlatformBO: " + logisticsPlatformBO); 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 eb49d660..4aa11e73 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 @@ -29,25 +29,10 @@ import com.ms.api.common.ApiResult; import com.ms.api.common.MSException; import com.ms.api.common.Pager; import com.ms.api.consts.*; +import com.ms.api.dto.dsapi.response.GetOrderPayProtocolPayResponseDTO; import com.ms.api.dto.dsorder.AppendVenderRemarkTplItemDTO; import com.ms.api.dto.order.*; -import com.ms.api.service.AfterSaleService; -import com.ms.api.service.OpLogisticsPlatformService; -import com.ms.api.service.OpOrderAddressHistoryService; -import com.ms.api.service.OpOrderAmountDetailService; -import com.ms.api.service.OpOrderChildLogisticsService; -import com.ms.api.service.OpOrderDsService; -import com.ms.api.service.OpOrderEncryptIndexService; -import com.ms.api.service.OpOrderGivenProductService; -import com.ms.api.service.OpOrderOutstorageHistoryService; -import com.ms.api.service.OpOrderPhaseService; -import com.ms.api.service.OpOrderPriceProtectionService; -import com.ms.api.service.OpOrderRedpackInfoService; -import com.ms.api.service.OrderPrintService; -import com.ms.api.service.ProductToDsItemService; -import com.ms.api.service.PurchaseOrderService; -import com.ms.api.service.PurchaseSettingService; -import com.ms.api.service.ShopService; +import com.ms.api.service.*; import com.ms.api.tool.*; import com.ms.api.util.DdRequestUtil; import com.ms.api.util.WebUtil; @@ -234,6 +219,9 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService { @Autowired private DsAutoPurchaseOrderQueueMapper dsAutoPurchaseOrderQueueMapper; + @Autowired + private DsApiService dsApiService; + @Override public int deleteByPrimaryKey(Long id) { return purchaseOrderMapper.deleteByPrimaryKey(id); @@ -2060,27 +2048,18 @@ log.info("getOrderIdAndPurchaseOrdersMap where: " + where.toString()); /** * 检测是否开通自动扣款 * @param shopId - * @return - * @throws Exception + * @return boolean */ @Override - public boolean checkSignedAutoPayProtocol(Long shopId) throws Exception { - Map params = new HashMap<>(); - params.put("shopId", SecurityTool.encodeByAES(String.valueOf(shopId))); - params.put("platform", CommonConst.PLATFORM); - String res = dsJsonRequestTemplate.execute("/order/getOrderPayProtocolPay", params); - log.info(res); - JSONObject jsonObject = JSON.parseObject(res); + public boolean checkSignedAutoPayProtocol(Long shopId) { boolean isSigned = false; - if (jsonObject.getString("result").equals("fail")) { - log.error("自动扣款协议请求失败,原因:" + jsonObject.getString("reason")); - throw new MSException(jsonObject.getString("reason")); + GetOrderPayProtocolPayResponseDTO response = dsApiService.getOrderPayProtocolPay(shopId); + if (!response.isSuccess()) { + log.error("自动扣款协议请求失败,原因:" + response.getReason()); + throw new MSException(response.getReason()); } else { - JSONArray paymentAgreements = jsonObject.getJSONObject("data").getJSONArray("paymentAgreements"); - for (int i = 0; i < paymentAgreements.size(); i++) { - JSONObject obj = paymentAgreements.getJSONObject(i); - String signedStatus = obj.getString("signedStatus"); - if (signedStatus.equals("true")) { + for (GetOrderPayProtocolPayResponseDTO.PaymentAgreement paymentAgreement: response.getPaymentAgreements()) { + if ("true".equals(paymentAgreement.getSignedStatus())) { isSigned = true; break; } 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 b011da7b..a61accd8 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 @@ -77,9 +77,7 @@ public class QueueServiceImpl implements QueueService { queueIdWhere.append(where); } queueIdWhere.append(String.format(" order by %s asc limit %s", queueIdColumnName, limit)); -// log.info("whereStr: " + queueIdWhere); List> queueList = queueMapper.select(queueName, queueIdWhere.toString()); -// log.info("queueList size: " + queueList.size()); if (ObjectUtil.isEmpty(queueList)) { break; } @@ -100,8 +98,6 @@ 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) { String queueIdStr = queue.get(queueIdColumnName).toString(); if (tempRedisIds.contains(queueIdStr)) { @@ -125,12 +121,11 @@ public class QueueServiceImpl implements QueueService { return 0; } String queueIdColumnName = QueueConst.getQueueIdColumnName(tableName); - int ar1 = 0; for (Map queue : queueList) { String queueIdStr = queue.get(queueIdColumnName).toString(); Long queueId = Long.valueOf(queueIdStr); if (ObjectUtil.isNotNull(queueId)) { - ar1 = queueMapper.updateLocked(tableName, queueIdColumnName, queueId, 0, DateUtil.now()); + queueMapper.updateLocked(tableName, queueIdColumnName, queueId, 0, DateUtil.now()); String queueRedisKey = RedisKeyConst.getQueueRedisKey(tableName, false); redisTemplate.opsForList().leftPush(queueRedisKey, queueId.toString()); } diff --git a/ms-biz/src/main/java/com/ms/api/spi/order/CheckSignedAutoPayProtocolService.java b/ms-biz/src/main/java/com/ms/api/spi/order/CheckSignedAutoPayProtocolService.java index 67a55df1..ca777f8d 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/order/CheckSignedAutoPayProtocolService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/order/CheckSignedAutoPayProtocolService.java @@ -24,14 +24,14 @@ public class CheckSignedAutoPayProtocolService extends SPIBaseService implements @Override public BaseResponse handle(BaseRequest req) { initHandle(req); - boolean checkRes = false; + boolean checkRes; try { checkRes = purchaseOrderService.checkSignedAutoPayProtocol(shopId); } catch (Exception e) { log.error("检测是否开通自动扣款失败", e); return R.ok(Ret.fail("检测是否开通自动扣款失败")); } - Map retMap = new HashMap(); + Map retMap = new HashMap<>(); retMap.put("isSignedAutoPayProtocol", checkRes ? 1 : 0); return R.ok(Ret.success(retMap)); } diff --git a/ms-biz/src/main/java/com/ms/api/spi/order/OrderMultiPackageOutstorageService.java b/ms-biz/src/main/java/com/ms/api/spi/order/OrderMultiPackageOutstorageService.java index e5e8e0ce..9f6f0dee 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/order/OrderMultiPackageOutstorageService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/order/OrderMultiPackageOutstorageService.java @@ -6,7 +6,6 @@ package com.ms.api.spi.order; */ import cn.hutool.core.collection.CollectionUtil; -import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData; import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.ExtensionService; @@ -14,18 +13,14 @@ 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.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; import com.ms.api.service.OutstorageService; -import com.ms.api.service.PurchaseOrderService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; -import java.util.HashMap; -import java.util.Map; - @ExtensionService("orderMultiPackageOutstorage") @Slf4j @AllArgsConstructor @@ -38,30 +33,16 @@ public class OrderMultiPackageOutstorageService extends SPIBaseService implement @Override public BaseResponse handle(BaseRequest req) { initHandle(req); - // ----参数校验---- - OrderMultiPackageOutstorageDTO fields = req.getData(); - if (CollectionUtil.isEmpty(fields.getPackageList())) { + OrderMultiPackageOutstorageDTO dto = req.getData(); + if (CollectionUtil.isEmpty(dto.getPackageList())) { return R.fail("包裹信息不能为空"); } - - // ----逻辑校验---- - - // ----业务处理---- - ResultDTO result = null; + ResultDTO result; try { - result = outstorageService.orderMultiPackageOutstorage(shopInfo, fields.getOrderId(), fields.getPackageList()); + result = outstorageService.orderMultiPackageOutstorage(shopInfo, dto.getOrderId(), dto.getPackageList()); } catch (RuntimeException exception) { return R.fail(exception.getLocalizedMessage()); } - - // ----结果返回---- - Map retData = new HashMap(); - retData.put("packList", result.getData()); - return BaseResponse.builder() - .success(true) - .message("success") - .data(Ret.success(retData)) - .code("10000") - .build(); + return R.ok(Ret.success(result.getData())); } } diff --git a/ms-biz/src/main/java/com/ms/api/task/DoudianTradeMsgConsumerTaskService.java b/ms-biz/src/main/java/com/ms/api/task/DoudianTradeMsgConsumerTaskService.java index a480863a..decb0be5 100644 --- a/ms-biz/src/main/java/com/ms/api/task/DoudianTradeMsgConsumerTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/DoudianTradeMsgConsumerTaskService.java @@ -60,8 +60,7 @@ public class DoudianTradeMsgConsumerTaskService extends TaskBaseService { @Override public Object getTask() { - DoudianTradeMsgQueue queue = doudianMsgService.lockConsumerDoudianTradeMsg(); - return queue; + return doudianMsgService.lockConsumerDoudianTradeMsg(); } @Override diff --git a/ms-biz/src/main/java/com/ms/api/task/DsMessageConsumeMsgTaskService.java b/ms-biz/src/main/java/com/ms/api/task/DsMessageConsumeMsgTaskService.java index d8cdc886..b1efb8c1 100644 --- a/ms-biz/src/main/java/com/ms/api/task/DsMessageConsumeMsgTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/DsMessageConsumeMsgTaskService.java @@ -1,7 +1,7 @@ package com.ms.api.task; import com.ms.api.common.TaskBaseService; -import com.ms.api.dto.dsorder.ResultDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.service.DistributionOrderService; import com.ms.api.service.DsMessageConsumerQueueService; import com.ms.api.service.DsMessageService; diff --git a/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java b/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java index 51828c1f..b80e5d52 100644 --- a/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java +++ b/ms-biz/src/main/java/com/ms/api/tool/CommonTool.java @@ -1002,4 +1002,16 @@ public class CommonTool { } return new String(bytes, 0, i, "Unicode"); } + + public static List castList(Object obj, Class clazz) { + List result = new ArrayList<>(); + if(obj instanceof List) { + for (Object o : (List) obj) + { + result.add(clazz.cast(o)); + } + return result; + } + return null; + } } diff --git a/ms-web/src/main/java/com/ms/web/Test.java b/ms-web/src/main/java/com/ms/web/Test.java index d321032c..57078000 100644 --- a/ms-web/src/main/java/com/ms/web/Test.java +++ b/ms-web/src/main/java/com/ms/web/Test.java @@ -5,20 +5,14 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; -import com.ms.api.common.Pager; import com.ms.api.common.R; import com.ms.api.common.Ret; -import com.ms.api.consts.AppConst; -import com.ms.api.dto.dsapi.response.GetPlatformShopPurchaseSettingResponseDTO; +import com.ms.api.dto.common.ResultDTO; import com.ms.api.dto.dsorder.DsMessageCallbackDTO; -import com.ms.api.dto.dsorder.DsMessageCallbackRequestDTO; -import com.ms.api.dto.dsorder.RemarkTplTagDTO; -import com.ms.api.dto.order.SearchDsOrderFilterDTO; -import com.ms.api.dto.order.SearchDsOrderListRequestDTO; +import com.ms.api.dto.dsorder.OrderItemDTO; import com.ms.api.service.*; import com.ms.api.spi.callback.OpenMsgConsumerService; import com.ms.api.tool.CommonTool; -import com.ms.api.tool.PurchaseTool; import com.ms.common.util.DsClient; import com.ms.common.util.HttpClient; import com.ms.dal.entity.PurchaseOrderItem; @@ -36,6 +30,9 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -161,7 +158,34 @@ public class Test { } } - public static void main(String[] args) throws ParseException { + public static void main(String[] args) throws ParseException, ExecutionException, InterruptedException { + Callable callable = () -> { + Thread.sleep(1000); + System.out.println(Thread.currentThread()); + System.out.println(Thread.currentThread().getName()); + return "info: " + Thread.currentThread().getName(); + }; + FutureTask task1 = new FutureTask<>(callable); + FutureTask task2 = new FutureTask<>(callable); + + Thread t1 = new Thread(task1); + Thread t2 = new Thread(task2); + + t1.setName("thread1"); + t2.setName("thread2"); + + t1.start(); + t2.start(); + + System.out.println(Thread.currentThread()); + String result = task1.get(); + System.out.println(result); + + String result1 = task2.get(); + System.out.println(result1); + + System.out.println(ResultDTO.success()); + System.out.println("ni号顺11".length()); System.out.println("ni号顺11".substring(0, 6)); try {