20230922-ljl-fixBug
ljl 1 year ago
parent bd0116a550
commit 1a33bfe998

@ -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<String, Object> 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<String, Object> 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;
}
}

@ -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<String, Object> data;
public List<PaymentAgreement> getPaymentAgreements() {
List<PaymentAgreement> 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;
}
}

@ -20,4 +20,6 @@ public interface DsApiService {
CommonResponseDTO cancelPurchaseOrderRelate(String platform, Long shopId, String orderId, List<Long> skuIds);
CommonResponseDTO cancelPurchaseOrder(String platform, Long shopId, String orderId, String purchaseOrderSn);
GetPurchaseOrderPayUrlResponseDTO getPurchaseOrderPayUrl(List<String> sourceOrderId, Long shopId);
GetOrderPayProtocolPayResponseDTO getOrderPayProtocolPay(Long shopId);
String findSimilarProducts(String img, String authCode);
}

@ -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;

@ -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;
/**
*

@ -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;

@ -110,6 +110,23 @@ public class DsApiServiceImpl implements DsApiService {
return JSON.parseObject(resp, GetPurchaseOrderPayUrlResponseDTO.class);
}
@Override
public GetOrderPayProtocolPayResponseDTO getOrderPayProtocolPay(Long shopId) {
Map<String, Object> 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<String, Object> params = new HashMap<>();
params.put("img", img);
params.put("authCode", authCode);
return execute("/move/find_similar_products", params);
}
private Map<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();

@ -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;

@ -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;

@ -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<Long> getLastHistoryId(List<String> shopIds, List<String> orderIds) {
if (ObjectUtil.isEmpty(shopIds) || ObjectUtil.isEmpty(orderIds)) {
return new ArrayList<Long>();
return new ArrayList<>();
}
return opOrderOutstorageHistoryMapper.getLastHistoryId(shopIds, orderIds);
}

@ -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<String, OpLogisticsPlatformBO> logisticsNameAndLogisticsInfoMap = opLogisticsPlatformService.getDdLogisticsNameAndLogisticsInfoMap();
Map<String, String> 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<String, String> 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);

@ -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<String, Object> 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;
}

@ -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<Map<String, Object>> 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<String> tempRedisIds = new HashSet<>();
tempRedisIds.addAll(redisIds);
tempRedisIds.addAll(newRedisIds);
// log.info("allQueueList count: " + allQueueList.size());
// log.info("tempRedisIds count: " + tempRedisIds.size());
for (Map<String, Object> 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<String, Object> 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());
}

@ -24,14 +24,14 @@ public class CheckSignedAutoPayProtocolService extends SPIBaseService implements
@Override
public BaseResponse<Ret> handle(BaseRequest<Void> 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<String, Integer> retMap = new HashMap<>();
retMap.put("isSignedAutoPayProtocol", checkRes ? 1 : 0);
return R.ok(Ret.success(retMap));
}

@ -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<Ret> handle(BaseRequest<OrderMultiPackageOutstorageDTO> 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.<Ret>builder()
.success(true)
.message("success")
.data(Ret.success(retData))
.code("10000")
.build();
return R.ok(Ret.success(result.getData()));
}
}

@ -60,8 +60,7 @@ public class DoudianTradeMsgConsumerTaskService extends TaskBaseService {
@Override
public Object getTask() {
DoudianTradeMsgQueue queue = doudianMsgService.lockConsumerDoudianTradeMsg();
return queue;
return doudianMsgService.lockConsumerDoudianTradeMsg();
}
@Override

@ -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;

@ -1002,4 +1002,16 @@ public class CommonTool {
}
return new String(bytes, 0, i, "Unicode");
}
public static <T> List<T> castList(Object obj, Class<T> clazz) {
List<T> result = new ArrayList<>();
if(obj instanceof List<?>) {
for (Object o : (List<?>) obj)
{
result.add(clazz.cast(o));
}
return result;
}
return null;
}
}

@ -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<String> callable = () -> {
Thread.sleep(1000);
System.out.println(Thread.currentThread());
System.out.println(Thread.currentThread().getName());
return "info: " + Thread.currentThread().getName();
};
FutureTask<String> task1 = new FutureTask<>(callable);
FutureTask<String> 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 {

Loading…
Cancel
Save