Compare commits

..

19 Commits

Author SHA1 Message Date
ljl 11873ae979 修改 6 months ago
ljl bbe54f88d0 修改 6 months ago
ljl 863dc8a84f 修改 7 months ago
ljl 902a34f36e 修改 7 months ago
ljl 460ee57c46 修改 7 months ago
ljl a51a588961 修改 7 months ago
ljl 1fa0154147 修改bug 8 months ago
ljl 5354f9175a yh 9 months ago
ljl b89c918999 修改 9 months ago
ljl 4ba3e2bec9 yh 9 months ago
ljl cf24159a9b 铺货消息推送 9 months ago
ljl 7e6cfe4e0a yh 9 months ago
ljl d4c36f1fc0 yh 9 months ago
ljl 1ccf00955f 修改 9 months ago
ljl a18396e831 优化 9 months ago
ljl 2323b23ebd 修改 9 months ago
ljl 01ed6e46ff 新增1688店铺解绑spi 10 months ago
ljl 2a7efea444 修改 10 months ago
ljl b448c5606a 修改 10 months ago

@ -0,0 +1,8 @@
package com.ms.api.dto;
import lombok.Data;
@Data
public class DsMessageDao {
Long messageId;
}

@ -0,0 +1,8 @@
package com.ms.api.dto;
import lombok.Data;
@Data
public class ShopInfoDao {
private String shopId;
}

@ -0,0 +1,10 @@
package com.ms.api.dto.dfapi.request;
import lombok.Data;
@Data
public class SupplyCenterMessage {
private String tag;
private String msgId;
private String data;
}

@ -0,0 +1,10 @@
package com.ms.api.dto.dfapi.request;
import lombok.Data;
import java.util.List;
@Data
public class SupplyCenterMessageRequestDao {
private List<SupplyCenterMessage> messages;
}

@ -0,0 +1,24 @@
package com.ms.api.dto.dfapi.response;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class CommonResponseDTO {
@JSONField(name = "code")
protected String code;
@JSONField(name = "message")
protected String message;
@JSONField(name = "result")
protected String result;
@JSONField(name = "reason")
protected String reason;
public boolean isSuccess() {
return "success".equals(result);
}
}

@ -19,6 +19,7 @@ public class DoudianMsgConst {
public static final Integer TAG_TRADE_APPOINTMENT = 112;//预约发货提交消息
public static final Integer TAG_TRADE_MEMO_MODIFY = 113;//订单商家备注消息推送
public static final Integer TAG_TRADE_LOGISTICS_ORDER_TAG_PUSH = 10003;//订单标记推送
public static final Integer TAG_TRADE_DISTRIBUTE_CARGO = 16000;//分销商品铺货成功
public static final List<Integer> ALL_TRADE_TAGS = new ArrayList<>();
static {

@ -0,0 +1,13 @@
package com.ms.biz.dto.openspi.request;
import com.doudian.open.gson.annotations.SerializedName;
import lombok.Data;
@Data
public class QuerySupplyPlatformBindNameParam {
@SerializedName("shop_id")
private Long shopId;
@SerializedName("supply_platform_type")
private Long supplyPlatformType;
}

@ -0,0 +1,12 @@
package com.ms.biz.dto.openspi.request;
import com.doudian.open.core.DoudianOpSpiRequest;
import com.doudian.open.core.DoudianOpSpiResponse;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthResponse;
public class QuerySupplyPlatformBindNameRequest extends DoudianOpSpiRequest<QuerySupplyPlatformBindNameParam> {
@Override
public Class<? extends DoudianOpSpiResponse<?>> getResponseClass() {
return QuerySupplyPlatformAuthResponse.class;
}
}

@ -0,0 +1,13 @@
package com.ms.biz.dto.openspi.request;
import com.doudian.open.gson.annotations.SerializedName;
import lombok.Data;
@Data
public class UnbindParam {
@SerializedName("shop_id")
private Long shopId;
@SerializedName("supply_platform_type")
private Long supplyPlatformType;
}

@ -0,0 +1,13 @@
package com.ms.biz.dto.openspi.request;
import com.doudian.open.core.DoudianOpSpiRequest;
import com.doudian.open.core.DoudianOpSpiResponse;
import com.ms.biz.dto.openspi.response.UnbindResponse;
public class UnbindRequest extends DoudianOpSpiRequest<UnbindParam> {
@Override
public Class<? extends DoudianOpSpiResponse<?>> getResponseClass() {
return UnbindResponse.class;
}
}

@ -0,0 +1,12 @@
package com.ms.biz.dto.openspi.response;
import com.alibaba.fastjson.annotation.JSONField;
import com.doudian.open.gson.annotations.SerializedName;
import lombok.Data;
@Data
public class QuerySupplyPlatformBindNameData {
@JSONField(name = "bind_name")
@SerializedName("bind_name")
private String bindName;
}

@ -0,0 +1,6 @@
package com.ms.biz.dto.openspi.response;
import com.doudian.open.core.DoudianOpSpiResponse;
public class QuerySupplyPlatformBindNameResponse extends DoudianOpSpiResponse<QuerySupplyPlatformBindNameData> {
}

@ -0,0 +1,7 @@
package com.ms.biz.dto.openspi.response;
import lombok.Data;
@Data
public class UnbindData {
}

@ -0,0 +1,7 @@
package com.ms.biz.dto.openspi.response;
import com.doudian.open.core.DoudianOpSpiResponse;
public class UnbindResponse extends DoudianOpSpiResponse<UnbindData> {
}

@ -0,0 +1,17 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
abstract public class BaseRuntimeException extends RuntimeException {
protected String code;
public BaseRuntimeException() {
super();
}
public BaseRuntimeException(String message) {
super(message);
}
}

@ -0,0 +1,18 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BindMemberNotExistsException extends BaseRuntimeException {
protected String code = "100501";
public BindMemberNotExistsException() {
super("当前没有绑定的账号信息,请重试");
}
public BindMemberNotExistsException(String message) {
super(message);
}
}

@ -0,0 +1,19 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends BaseRuntimeException {
protected String code = "100004";
public BusinessException(String message, String code) {
super(message);
this.code = code;
}
public BusinessException(String message) {
super(message);
}
}

@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class DeliveryNotReceivedException extends RuntimeException {
public class DeliveryNotReceivedException extends BaseRuntimeException {
private Long shipTimestamp;
public DeliveryNotReceivedException(String message, Long shipTimestamp) {
super(message);

@ -0,0 +1,18 @@
package com.ms.biz.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class MemberAlreadyUnbindException extends BaseRuntimeException {
protected String code = "100401";
public MemberAlreadyUnbindException() {
super("当前已解绑,无需再次解绑");
}
public MemberAlreadyUnbindException(String message) {
super(message);
}
}

@ -2,5 +2,7 @@ package com.ms.biz.quque;
public class Group {
public static final String GROUP_DS_MESSAGE = "GID_miaoshougoods_ds_message";
public static final String GROUP_SUPPLY_CENTER_MESSAGE = "GID_miaoshougoods_supply_center_message";
}

@ -4,6 +4,8 @@ import com.ms.biz.tool.SystemTool;
public class Topic {
public static final String TOPIC_DS_MESSAGE = "miaoshougoods_ds_message";
public static final String TOPIC_SUPPLY_CENTER_MESSAGE = "miaoshougoods_supply_center_message";
public static String rebuild(String topic) {
if (SystemTool.isDevEnv()) {
return "local%" + topic;

@ -0,0 +1,42 @@
package com.ms.biz.quque.consumer;
import com.alibaba.fastjson.JSON;
import com.jinritemai.cloud.base.core.util.LogUtils;
import com.ms.biz.quque.ConsumerListener;
import com.ms.biz.quque.Group;
import com.ms.biz.quque.Topic;
import com.ms.biz.quque.message.SupplyCenterMessage;
import com.ms.biz.service.SupplyCenterService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@ConsumerListener(consumerGroup = Group.GROUP_SUPPLY_CENTER_MESSAGE, topic = Topic.TOPIC_SUPPLY_CENTER_MESSAGE)
@Component
public class SupplyCenterMessageConsumer extends BaseConsumer {
@Autowired
private SupplyCenterService supplyCenterService;
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
LogUtils.setLogId(LogUtils.generateLogId());
log.info("SupplyCenterMessageConsumer Receive New Messages: {}", JSON.toJSONString(list));
for (MessageExt message: list) {
try {
log.info("consume message: {}", new String(message.getBody()));
SupplyCenterMessage supplyCenterMessage = JSON.parseObject(new String(message.getBody()), SupplyCenterMessage.class);
supplyCenterService.processMessage(supplyCenterMessage.getMsgId());
} catch (Throwable e) {
log.error("SupplyCenterMessageConsumerError", e);
}
}
log.info("SupplyCenterMessageConsumer consumeMessage success");
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}

@ -0,0 +1,11 @@
package com.ms.biz.quque.message;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class SupplyCenterMessage extends BaseMessage {
private String msgId;
private Long shopId;
}

@ -0,0 +1,21 @@
package com.ms.biz.service;
import com.ms.dal.entity.DdSupplyCenterMsg;
/**
*
*/
public interface DdSupplyCenterMsgService {
int deleteByPrimaryKey(Long id);
int insert(DdSupplyCenterMsg record);
int insertSelective(DdSupplyCenterMsg record);
DdSupplyCenterMsg selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(DdSupplyCenterMsg record);
int updateByPrimaryKey(DdSupplyCenterMsg record);
}

@ -0,0 +1,9 @@
package com.ms.biz.service;
import com.ms.api.dto.dfapi.request.SupplyCenterMessageRequestDao;
import com.ms.api.dto.dfapi.response.CommonResponseDTO;
public interface DfApiService {
CommonResponseDTO receiverDdSupplyCenterMsg(SupplyCenterMessageRequestDao request);
}

@ -3,6 +3,8 @@ package com.ms.biz.service;
import com.ms.dal.entity.DoudianMsg;
import com.ms.dal.entity.DoudianMsgParseQueue;
import java.util.List;
/**
*
*/
@ -29,4 +31,6 @@ public interface DoudianMsgService {
void failProcessDoudianMsgParseQueue(Long doudianMsgId);
boolean deleteDoudianMsgParseQueue(Long doudianMsgId);
void receiveMessages(List<String> messageList);
}

@ -26,4 +26,5 @@ public interface DsApiService {
GetAuthInfoResponseDTO getAuthInfo(Long shopId);
CheckDsAppAuthExpireResponseDTO checkDsAppAuthExpire(Long shopId, String memberId, String authCode);
GetAuthShopMemberInfosResponseDTO getAuthShopMemberInfos(Long shopId);
CommonResponseDTO delAuthShop(Long shopId);
}

@ -4,7 +4,10 @@ import java.util.List;
import com.ms.biz.bo.ShopBO;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam;
import com.ms.biz.dto.openspi.request.UnbindParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.dal.entity.Shop;
/**
@ -35,4 +38,8 @@ public interface ShopService {
ShopBO getShopInfoByShop(Shop shop);
void querySupplyPlatformAuth(QuerySupplyPlatformAuthParam param, QuerySupplyPlatformAuthData data);
void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data);
void unbind(UnbindParam param);
}

@ -0,0 +1,5 @@
package com.ms.biz.service;
public interface SupplyCenterService {
void processMessage(String msgId);
}

@ -0,0 +1,53 @@
package com.ms.biz.service.impl;
import com.ms.dal.entity.DdSupplyCenterMsg;
import com.ms.dal.mapper.DdSupplyCenterMsgMapper;
import com.ms.biz.service.DdSupplyCenterMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class DdSupplyCenterMsgServiceImpl implements DdSupplyCenterMsgService{
@Autowired
private DdSupplyCenterMsgMapper ddSupplyCenterMsgMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return ddSupplyCenterMsgMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(DdSupplyCenterMsg record) {
return ddSupplyCenterMsgMapper.insert(record);
}
@Override
public int insertSelective(DdSupplyCenterMsg record) {
return ddSupplyCenterMsgMapper.insertSelective(record);
}
@Override
public DdSupplyCenterMsg selectByPrimaryKey(Long id) {
return ddSupplyCenterMsgMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(DdSupplyCenterMsg record) {
return ddSupplyCenterMsgMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(DdSupplyCenterMsg record) {
return ddSupplyCenterMsgMapper.updateByPrimaryKey(record);
}
}

@ -0,0 +1,64 @@
package com.ms.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.ms.api.dto.dfapi.request.SupplyCenterMessageRequestDao;
import com.ms.api.dto.dfapi.response.CommonResponseDTO;
import com.ms.api.dto.dsapi.request.OperateInfoDTO;
import com.ms.biz.consts.CommonConst;
import com.ms.biz.service.DfApiService;
import com.ms.biz.tool.DfJsonRequestTemplate;
import com.ms.biz.tool.SecurityTool;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
@AllArgsConstructor
public class DfApiServiceImpl implements DfApiService {
private DfJsonRequestTemplate dfJsonRequestTemplate;
@Override
public CommonResponseDTO receiverDdSupplyCenterMsg(SupplyCenterMessageRequestDao request) {
String resp = execute("/open/supply_center/message/receiver_dd_supply_center_msg", objectToMap(request));
return JSON.parseObject(resp, CommonResponseDTO.class);
}
private Map<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();
System.out.println(clazz);
try {
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
String fieldName = field.getName();
Object value = field.get(obj);
map.put(fieldName, value);
}
} catch (Exception e) {
throw new RuntimeException("参数解析错误");
}
return map;
}
private String execute(String url, Map<String, Object> params) {
log.info("DsApiURL:" + url);
log.info("DsApiRequest:" + params);
try {
String response = dfJsonRequestTemplate.execute(url, params);
log.info("DsApiResponse:" + response);
return response;
} catch (Exception e) {
log.error("DsApiException", e);
throw new RuntimeException("请求异常" + e.getMessage());
}
}
private OperateInfoDTO createOperateInfo(Long shopId) {
return new OperateInfoDTO(SecurityTool.encodeByAES(String.valueOf(shopId)));
}
}

@ -82,9 +82,19 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
storeCreateOrders(shopId, param.getOrders(), purOrderIds);
}
storeCreateOrders(shopId, param.getOrders(), purOrderIds);
boolean isRepurchase = false;
Map<String, PlatformPurchaseOrder> repurchasePlatformPurchaseOrderMap = new HashMap<>();
if (!platformPurchaseOrders.isEmpty()) {
for (PlatformPurchaseOrder platformPurchaseOrder: platformPurchaseOrders) {
log.info("platformPurchaseOrder[" + platformPurchaseOrder.getPurOrderId() + "]exist, purchaseStatus:" + platformPurchaseOrder.getPurchaseStatus());
if (platformPurchaseOrder.getPurchaseStatus().equals(StatusConst.cancel)) {
isRepurchase = true;
repurchasePlatformPurchaseOrderMap.put(platformPurchaseOrder.getPurOrderId(), platformPurchaseOrder);
}
}
}
BatchCreateDistributionOrdersRequestDTO request = buildBatchCreateDistributionOrdersRequestDTO(param);
BatchCreateDistributionOrdersRequestDTO request = buildBatchCreateDistributionOrdersRequestDTO(param, isRepurchase);
BatchCreateDistributionOrdersResponseDTO response = dsApiService.batchCreateDistributionOrders(param.getShopId(), request);
// String res = "{\"result\":\"success\",\"successCount\":1,\"failCount\":0,\"successList\":[{\"result\":\"success\",\"data\":{\"success\":true,\"totalSuccessAmount\":598,\"orderId\":\"3641170788609141341\",\"postFee\":0,\"mutilOrders\":null},\"createAlibabaOrderLogId\":1496,\"platformOrderIds\":[\"6923971910449173607\"],\"isEncryptOrder\":\"true\",\"isSupportEncryptOrder\":1,\"isUseManualConsignee\":0,\"flow\":\"fenxiao\",\"includeSplitJxhy\":false,\"sourceOrderIds\":[\"3641170788609141341\"],\"payRet\":null,\"platformOrderId\":\"6923971910449173607\",\"relatePurchaseOrderInfos\":[{\"platformOrderId\":\"6923971910449173607\",\"purchasePlatform\":\"1688DS\",\"purchaseOrderSn\":\"3641170788609141341\",\"purchaseOrderBuyer\":\"douhuotest\",\"purchaseOrderSeller\":\"\\u798f\\u5dde\\u67cf\\u4e3a\\u5546\\u8d38\\u6709\\u9650\\u516c\\u53f8\",\"purchaseOrderPayment\":\"5.98\",\"purchaseOrderFullname\":\"\\u6de1*\",\"purchaseOrderMobile\":\"1********80\",\"purchaseOrderFullAddress\":\"\\u6d59\\u6c5f\\u7701 \\u676d\\u5dde\\u5e02 \\u4f59\\u676d\\u533a \\u4ed3\\u524d\\u8857\\u9053 \\u4f59\\u676d*\\u8def****\",\"purchaseOrderStartTime\":\"2023-11-22 11:03:37\",\"platformPushStatus\":\"wait\",\"purchaseOrderLogisticsName\":\"\",\"purchaseOrderWaybillCode\":\"\",\"purchaseOrderStatus\":\"wait_pay\",\"purchaseOrderFlow\":\"fenxiao\",\"alibabaOrderStatus\":\"waitbuyerpay\",\"isUseManualConsignee\":0,\"isDsEncryptOrder\":0,\"isSupportEncryptOrder\":0,\"logisticsIsAccept\":false,\"items\":[{\"skuId\":\"3386515436145410\",\"wareId\":\"3651940874226638524\",\"purchaseNum\":\"2\",\"purchasePrice\":\"2.99\",\"sourceItemId\":\"712130508984\",\"subItemId\":\"3641170788609141341\"}],\"mergePurchasePlatformOrderIds\":null,\"purchaseOrderUpdateTime\":\"2023-11-22 11:03:37\",\"purchaseOrderPayTime\":null}]}],\"errorList\":null,\"lockSourceItems\":[{\"createPurchaseOrderLockSkuId\":\"2224\",\"createPurchaseOrderLockId\":\"20001680\",\"sourceItemId\":\"712130508984\",\"sourceSkuId\":\"4987755988437\",\"createPurchaseOrderLogId\":\"1553\",\"sourceOrderId\":\"3641170788609141341\",\"sourceNum\":null,\"reqId\":null,\"status\":\"lock\",\"gmtCreate\":\"2023-11-22 11:03:36\",\"gmtModified\":\"2023-11-22 11:03:37\",\"platformOrderId\":\"6923971910449173607\",\"platformItemId\":\"3651940874226638524\",\"platformSkuId\":\"3386515436145410\"}]}";
@ -112,11 +122,19 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
purchaseOrderItems.addAll(items);
OrderResult orderResult = buildOrderResult(purchaseOrderDTO, orderIdAndPurOrderIdMap, skuIdAndPurSkuOrderIdMap);
orderResults.add(orderResult);
if (isRepurchase && repurchasePlatformPurchaseOrderMap.containsKey(purOrderId)) {
PlatformPurchaseOrder platformPurchaseOrder = repurchasePlatformPurchaseOrderMap.get(purOrderId);
platformPurchaseOrder.setPurchaseStatus(PurchaseOrderConst.PURCHASE_ORDER_STATUS_WAIT_PAY);
platformPurchaseOrder.setStatus(StatusConst.normal);
platformPurchaseOrder.setGmtModified(new Date());
platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder);
}
}
}
data.setOrderResults(orderResults);
PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurOrderId(purOrderIds.iterator().next());
if (purchaseOrder == null) {
List<PurchaseOrder> currentPurchaseOrders = purchaseOrderMapper.getListByPurOrderId(purOrderIds.iterator().next());
if (currentPurchaseOrders.isEmpty() || isRepurchase) {
purchaseOrderMapper.insertBatch(purchaseOrders);
purchaseOrderItemMapper.insertBatch(purchaseOrderItems);
}
@ -449,7 +467,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
return item;
}
private BatchCreateDistributionOrdersRequestDTO buildBatchCreateDistributionOrdersRequestDTO(BatchCreateParam param) {
private BatchCreateDistributionOrdersRequestDTO buildBatchCreateDistributionOrdersRequestDTO(BatchCreateParam param, boolean isRepurchase) {
Map<Long, String> productIdAndOutProductIdMap = new HashMap<>();
Map<Long, String> skuIdAndOutSkuIdMap = new HashMap<>();
for (CreateOrder order: param.getOrders()) {
@ -467,45 +485,46 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
PlatformOrderDTO platformOrder = buildPlatformOrderDTO(param.getShopId(), order, productIdAndSourceProductInfoMap, skuIdAndOutSkuIdMap);
platformOrders.add(platformOrder);
}
request.setRepurchase(isRepurchase);
request.setPlatformOrders(platformOrders);
request.setPlatform(CommonConst.PLATFORM);
request.setActionSource(DsOrderConst.ACTION_SOURCE_BATCH_PURCHASE);
request.setPurchaseSource(DsOrderConst.PURCHASE_SOURCE_PLATFORM_BATCH);
request.setIsAutoPay(0);
request.setRepurchase(false);
return request;
}
@Override
public void batchPay(BatchPayParam param, BatchPayData data) {
List<String> purOrderIds = new ArrayList<>();
for (BatchPayParam.Param payParam: param.getParams()) {
purOrderIds.add(payParam.getPurOrderId());
if (param.getParams().size() != 1) {
throw new RuntimeException("每次只能请求1个采购单");
}
List<PlatformPurchaseOrder> platformPurchaseOrders = platformPurchaseOrderMapper.getListByPurOrderIds(purOrderIds);
if (platformPurchaseOrders.isEmpty()) {
String purOrderId = param.getParams().get(0).getPurOrderId();
PlatformPurchaseOrder platformPurchaseOrder = platformPurchaseOrderMapper.selectByPrimaryKey(param.getParams().get(0).getPurOrderId());
if (platformPurchaseOrder == null) {
throw new RuntimeException("采购单不存在");
}
List<PurchaseOrder> purchaseOrders = purchaseOrderMapper.getListByPurOrderIds(purOrderIds);
List<PurchaseOrder> purchaseOrders = purchaseOrderMapper.getListByPurOrderId(purOrderId);
List<String> sourceOrderIds = new ArrayList<>();
for (PurchaseOrder purchaseOrder: purchaseOrders) {
sourceOrderIds.add(purchaseOrder.getPurchaseOrderSn());
}
Long shopId = param.getParams().get(0).getShopId();
GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "PC");
GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "WIRELESS");
if (!response1.isSuccess()) {
throw new RuntimeException(response1.getReason());
}
if (!response2.isSuccess()) {
throw new RuntimeException(response2.getReason());
if (sourceOrderIds.isEmpty()) {
throw new RuntimeException("采购单号不存在");
}
List<PaymentResult> paymentResults = new ArrayList<>();
for (BatchPayParam.Param p: param.getParams()) {
GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "PC");
GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "WIRELESS");
if (!response1.isSuccess()) {
throw new RuntimeException(response1.getReason());
}
if (!response2.isSuccess()) {
throw new RuntimeException(response2.getReason());
}
PaymentResult paymentResult = new PaymentResult();
PaymentResult.PayUrl payUrl = new PaymentResult.PayUrl();
@ -515,8 +534,11 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
paymentResult.setPayUrl(payUrl);
paymentResult.setPurOrderId(p.getPurOrderId());
paymentResults.add(paymentResult);
platformPurchaseOrder.setPayPcUrl(response1.getPayUrl());
platformPurchaseOrder.setPayH5Url(response2.getPayUrl());
platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder);
}
platformPurchaseOrderMapper.updatePayUrlByPurOrderIds(response1.getPayUrl(), response2.getPayUrl(), purOrderIds);
data.setPaymentResults(paymentResults);
}

@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ms.biz.consts.DoudianMsgConst;
import com.ms.biz.consts.StatusConst;
import com.ms.biz.quque.Group;
import com.ms.biz.quque.Producer;
import com.ms.biz.quque.Topic;
import com.ms.biz.quque.message.SupplyCenterMessage;
import com.ms.dal.entity.*;
import com.ms.biz.service.DoudianMsgService;
import com.ms.dal.mapper.*;
@ -12,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
@ -30,6 +35,9 @@ public class DoudianMsgServiceImpl implements DoudianMsgService{
@Autowired
private DoudianMsgMapper doudianMsgMapper;
@Autowired
private DdSupplyCenterMsgMapper ddSupplyCenterMsgMapper;
@Autowired
private DoudianMsgParseQueueMapper doudianMsgParseQueueMapper;
@ -235,6 +243,44 @@ public class DoudianMsgServiceImpl implements DoudianMsgService{
int affRow = doudianMsgParseQueueMapper.deleteByPrimaryKey(queueId);
return affRow > 0;
}
@Override
public void receiveMessages(List<String> messageList) {
List<DdSupplyCenterMsg> ddSupplyCenterMsgList = new ArrayList<>();
for (String message : messageList) {
JSONObject msgItem = JSONObject.parseObject(message);
Map currentMsgData = JSONObject.parseObject(msgItem.getString("data"), Map.class);
Long shopId = Long.valueOf(currentMsgData.get("shop_id").toString());
if (DoudianMsgConst.TAG_TRADE_DISTRIBUTE_CARGO.equals(Integer.valueOf(msgItem.get("tag").toString()))) {
DdSupplyCenterMsg msgObj = new DdSupplyCenterMsg();
msgObj.setMsgId(msgItem.get("msg_id").toString());
msgObj.setShopId(shopId);
msgObj.setTag(Integer.valueOf(msgItem.get("tag").toString()));
msgObj.setData(msgItem.get("data").toString());
msgObj.setReason("");
msgObj.setStatus(StatusConst.wait);
msgObj.setGmtCreate(new Date());
msgObj.setGmtModified(new Date());
ddSupplyCenterMsgList.add(msgObj);
}
}
if (!ddSupplyCenterMsgList.isEmpty()) {
ddSupplyCenterMsgMapper.insertBatch(ddSupplyCenterMsgList);
}
Producer producer = new Producer(Group.GROUP_SUPPLY_CENTER_MESSAGE);
// 插入分好类的数据
for (DdSupplyCenterMsg item : ddSupplyCenterMsgList) {
SupplyCenterMessage message = new SupplyCenterMessage();
message.setMsgId(item.getMsgId());
message.setShopId(item.getShopId());
log.info("DdTradeMsg topic: " + Topic.TOPIC_SUPPLY_CENTER_MESSAGE);
producer.send(message.build(Topic.TOPIC_SUPPLY_CENTER_MESSAGE), 3000);
}
}
}

@ -166,6 +166,15 @@ public class DsApiServiceImpl implements DsApiService {
return JSON.parseObject(resp, GetAuthShopMemberInfosResponseDTO.class);
}
@Override
public CommonResponseDTO delAuthShop(Long shopId) {
HashMap<String, Object> params = new HashMap<>();
params.put("userId", SecurityTool.encodeByAES(String.valueOf(shopId)));
params.put("platform", CommonConst.PLATFORM);
String resp = execute("/micro_move/del_auth_shop", params);
return JSON.parseObject(resp, CommonResponseDTO.class);
}
private Map<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();

@ -215,7 +215,7 @@ public class DsMessageServiceImpl implements DsMessageService {
PurchaseOrderDTO purchaseOrderDTO = ((PurchaseOrderRelateMessageDTO)messageDTO).getPurchaseOrderInfo();
// do something
}
log.error("handleDsMessage: 消息已过期");
log.info("handleDsMessage: 消息已过期");
// throw new RuntimeException("消息已过期");
}
@ -267,7 +267,7 @@ public class DsMessageServiceImpl implements DsMessageService {
return;
}
log.error("handleDsMessage purchaseOrderStatus: " + purchaseOrderStatus);
log.info("handleDsMessage purchaseOrderStatus: " + purchaseOrderStatus);
if (!Objects.equals(purchaseOrder.getPurchaseOrderStatus(),purchaseOrderStatus)){
switch (purchaseOrderStatus) {

@ -1,17 +1,21 @@
package com.ms.biz.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import cn.hutool.core.util.ObjectUtil;
import com.doudian.open.core.AccessToken;
import com.ms.api.dto.dsapi.response.CheckDsAppAuthExpireResponseDTO;
import com.ms.api.dto.dsapi.response.CommonResponseDTO;
import com.ms.api.dto.dsapi.response.GetAuthInfoResponseDTO;
import com.ms.api.dto.dsapi.response.GetPlatformAuthUrlResponseDTO;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam;
import com.ms.biz.dto.openspi.request.UnbindParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.biz.exception.BindMemberNotExistsException;
import com.ms.biz.exception.BusinessException;
import com.ms.biz.exception.MemberAlreadyUnbindException;
import com.ms.biz.service.DsApiService;
import com.ms.biz.service.ShopService;
import com.ms.biz.bo.ShopBO;
@ -114,6 +118,7 @@ public class ShopServiceImpl implements ShopService {
return shopBO;
}
@Override
public void querySupplyPlatformAuth(QuerySupplyPlatformAuthParam param, QuerySupplyPlatformAuthData data) {
Long shopId = param.getShopId();
if (shopId == null || shopId == 0) {
@ -158,6 +163,52 @@ public class ShopServiceImpl implements ShopService {
throw new RuntimeException(response.getReason());
}
}
@Override
public void querySupplyPlatformBindName(QuerySupplyPlatformBindNameParam param, QuerySupplyPlatformBindNameData data) {
Long shopId = param.getShopId();
if (shopId == null || shopId == 0) {
throw new BusinessException("参数错误:请检查您的查询参数是否正确", "100500");
}
ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId);
if (member == null) {
throw new BindMemberNotExistsException();
}
GetAuthInfoResponseDTO response = dsApiService.getAuthInfo(shopId);
if (response.isSuccess()) {
if (Objects.equals(response.getAuthStatus(), "notBind")) {
throw new BindMemberNotExistsException();
}
data.setBindName(response.getMemberName());
} else {
throw new BusinessException(response.getReason());
}
}
@Override
public void unbind(UnbindParam param) {
Long shopId = param.getShopId();
if (shopId == null || shopId == 0) {
throw new BusinessException("参数错误:请检查您的查询参数是否正确", "100400");
}
ShopTo1688DsMember member = shopTo1688DsMemberMapper.getDetailByShopId(shopId);
if (member == null) {
throw new MemberAlreadyUnbindException();
}
CommonResponseDTO response = dsApiService.delAuthShop(shopId);
if (!response.isSuccess()) {
if (Objects.equals(response.getCode(), "biz.platform-shop-member-not-exist")) {
throw new MemberAlreadyUnbindException();
} else {
throw new BusinessException(response.getReason());
}
}
shopTo1688DsMemberMapper.deleteByPrimaryKey(member.getShopTo1688DsMemberId());
}
}

@ -0,0 +1,46 @@
package com.ms.biz.service.impl;
import com.ms.api.dto.dfapi.request.SupplyCenterMessage;
import com.ms.api.dto.dfapi.request.SupplyCenterMessageRequestDao;
import com.ms.api.dto.dfapi.response.CommonResponseDTO;
import com.ms.biz.consts.StatusConst;
import com.ms.biz.service.DfApiService;
import com.ms.biz.service.SupplyCenterService;
import com.ms.dal.entity.DdSupplyCenterMsg;
import com.ms.dal.mapper.DdSupplyCenterMsgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class SupplyCenterServiceImpl implements SupplyCenterService {
@Autowired
private DfApiService dfApiService;
@Autowired
private DdSupplyCenterMsgMapper ddSupplyCenterMsgMapper;
@Override
public void processMessage(String msgId) {
DdSupplyCenterMsg msg = ddSupplyCenterMsgMapper.selectByMsgId(msgId);
List<SupplyCenterMessage> messages = new ArrayList<>();
SupplyCenterMessage message = new SupplyCenterMessage();
message.setTag(msg.getTag().toString());
message.setMsgId(msg.getMsgId());
message.setData(msg.getData());
messages.add(message);
SupplyCenterMessageRequestDao request = new SupplyCenterMessageRequestDao();
request.setMessages(messages);
CommonResponseDTO response = dfApiService.receiverDdSupplyCenterMsg(request);
if (response.isSuccess()) {
msg.setStatus(StatusConst.success);
} else {
msg.setStatus(StatusConst.fail);
msg.setReason(response.getReason());
}
ddSupplyCenterMsgMapper.updateByMsgIdSelective(msg);
}
}

@ -11,6 +11,7 @@ import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.BatchCreateParam;
import com.ms.biz.dto.openspi.response.BatchCreateData;
import com.ms.biz.dto.openspi.response.BatchPayData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.DistributionOrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -28,6 +29,8 @@ public class BatchCreateService extends SPIBaseService implements ExtensionServi
BatchCreateData data = new BatchCreateData();
distributionOrderService.batchCreate(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) {
log.error("batchCreate error1", e);
String message = e.getMessage() == null ? "系统异常" : e.getMessage();

@ -11,6 +11,7 @@ import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.BatchPayParam;
import com.ms.biz.dto.openspi.response.BatchPayData;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.DistributionOrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -28,6 +29,8 @@ public class BatchPayService extends SPIBaseService implements ExtensionServiceH
BatchPayData data = new BatchPayData();
distributionOrderService.batchPay(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {

@ -23,14 +23,16 @@ public class DoudianMsgReceiveService extends SPIBaseService implements Extensio
@Override
public BaseResponse<Void> handle(BaseRequest<List<String>> req) {
List<String> msgList = req.getData();
if (msgList == null || msgList.isEmpty()) {
return R.ok();
try {
List<String> msgList = req.getData();
if (msgList == null || msgList.isEmpty()) {
R.ok();
}
doudianMsgService.receiveMessages(msgList);
return BaseResponse.<Void>builder().success(true).code("0").build();
} catch (Throwable e) {
log.error("receive message error");
return BaseResponse.<Void>builder().success(false).code("1").build();
}
for (String msgStr: msgList) {
DoudianMessage msg = JSON.parseObject(msgStr, DoudianMessage.class);
}
// 处理成功则返回 true code 0
return BaseResponse.<Void>builder().success(true).code("0").build();
}
}

@ -10,6 +10,7 @@ import com.ms.biz.common.R;
import com.ms.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformAuthParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformAuthData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -27,6 +28,8 @@ public class QuerySupplyPlatformAuthService extends SPIBaseService implements Ex
QuerySupplyPlatformAuthData data = new QuerySupplyPlatformAuthData();
shopService.querySupplyPlatformAuth(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {

@ -0,0 +1,39 @@
package com.ms.biz.spi.callback;
import com.alibaba.fastjson.JSON;
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.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.QuerySupplyPlatformBindNameParam;
import com.ms.biz.dto.openspi.response.QuerySupplyPlatformBindNameData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ExtensionService("querySupplyPlatformBindName")
@Slf4j
@AllArgsConstructor
public class QuerySupplyPlatformBindNameService extends SPIBaseService implements ExtensionServiceHandler<QuerySupplyPlatformBindNameParam, JSONObject> {
private ShopService shopService;
@Override
public BaseResponse<JSONObject> handle(BaseRequest<QuerySupplyPlatformBindNameParam> req) {
try {
QuerySupplyPlatformBindNameParam param = req.getData();
QuerySupplyPlatformBindNameData data = new QuerySupplyPlatformBindNameData();
shopService.querySupplyPlatformBindName(param, data);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {
log.error("querySupplyPlatformBindName error", e);
return BaseResponse.<JSONObject>builder().success(true).message("系统异常").code("100003").build();
}
}
}

@ -0,0 +1,39 @@
package com.ms.biz.spi.callback;
import com.alibaba.fastjson.JSON;
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.biz.common.SPIBaseService;
import com.ms.biz.dto.openspi.request.UnbindParam;
import com.ms.biz.dto.openspi.response.UnbindData;
import com.ms.biz.exception.BaseRuntimeException;
import com.ms.biz.service.ShopService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ExtensionService("unbind")
@Slf4j
@AllArgsConstructor
public class UnbindService extends SPIBaseService implements ExtensionServiceHandler<UnbindParam, JSONObject> {
private ShopService shopService;
@Override
public BaseResponse<JSONObject> handle(BaseRequest<UnbindParam> req) {
try {
UnbindParam param = req.getData();
UnbindData data = new UnbindData();
shopService.unbind(param);
return BaseResponse.<JSONObject>builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build();
} catch (BaseRuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code(e.getCode()).build();
} catch (RuntimeException e) {
return BaseResponse.<JSONObject>builder().success(true).message(e.getMessage()).code("100003").build();
} catch (Throwable e) {
log.error("querySupplyPlatformBindName error", e);
return BaseResponse.<JSONObject>builder().success(true).message("系统异常").code("100003").build();
}
}
}

@ -0,0 +1,40 @@
package com.ms.biz.spi.timer;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.data.OpenGetAuthInfoData;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.doudian.open.utils.StringUtil;
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.jinritemai.cloud.base.core.util.AuthThreadLocalUtil;
import com.ms.api.dto.ShopInfoDao;
import com.ms.biz.common.R;
import com.ms.biz.common.Ret;
import com.ms.biz.common.TimerBaseService;
import com.ms.biz.util.DDApi;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;
@ExtensionService("getAuthInfoTimer")
@Slf4j
public class GetAuthInfoTimerService extends TimerBaseService implements ExtensionServiceHandler<ShopInfoDao, Ret> {
@Override
public BaseResponse<Ret> handle(BaseRequest<ShopInfoDao> req) {
String shopId = req.getData().getShopId();
if (StringUtil.isEmpty(shopId)) {
shopId = "4463798";
}
AuthThreadLocalUtil.set(shopId);
OpenGetAuthInfoParam param = new OpenGetAuthInfoParam();
param.setAuthId(shopId);
OpenGetAuthInfoData data = DDApi.getAuthInfo(param);
log.info("GetAuthInfoService" + JSONObject.toJSONString(data));
Map<String, String> result = new HashMap<>();
result.put("result", JSONObject.toJSONString(data));
return R.ok(Ret.success(result));
}
}

@ -0,0 +1,28 @@
package com.ms.biz.spi.timer;
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.dto.DsMessageDao;
import com.ms.biz.common.R;
import com.ms.biz.common.Ret;
import com.ms.biz.common.TimerBaseService;
import com.ms.biz.service.DsMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ExtensionService("processDsMessage")
@Slf4j
public class ProcessDsMessageService extends TimerBaseService implements ExtensionServiceHandler<DsMessageDao, Ret> {
@Autowired
private DsMessageService dsMessageService;
@Override
public BaseResponse<Ret> handle(BaseRequest<DsMessageDao> req) {
Long messageId = req.getData().getMessageId();
dsMessageService.processDsMessage(messageId);
return R.ok(Ret.success());
}
}

@ -0,0 +1,39 @@
package com.ms.biz.spi.timer;
import com.doudian.open.utils.StringUtil;
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.jinritemai.cloud.base.core.util.AuthThreadLocalUtil;
import com.ms.api.dto.ShopInfoDao;
import com.ms.biz.common.R;
import com.ms.biz.common.Ret;
import com.ms.biz.common.TimerBaseService;
import com.ms.biz.service.DoudianMsgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
@ExtensionService("testSendMsg")
@Slf4j
public class TestSendMsgService extends TimerBaseService implements ExtensionServiceHandler<ShopInfoDao, Ret> {
@Autowired
private DoudianMsgService doudianMsgService;
@Override
public BaseResponse<Ret> handle(BaseRequest<ShopInfoDao> req) {
String shopId = req.getData().getShopId();
if (StringUtil.isEmpty(shopId)) {
shopId = "4463798";
}
AuthThreadLocalUtil.set(shopId);
List<String> msgList = new ArrayList<>();
msgList.add("{\"tag\":\"16000\",\"msg_id\":\"57088508275362107630:037250343:16000:1709036986:1925842976:7290512081592305208\",\"data\":\"{\\\"cargo_id\\\":3658552585478095162,\\\"event_time\\\":1709036986,\\\"product_id\\\":3670126357280588075,\\\"shop_id\\\":37250343}\"}");
doudianMsgService.receiveMessages(msgList);
return R.ok(Ret.success());
}
}

@ -0,0 +1,71 @@
package com.ms.biz.task;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.data.OpenGetAuthInfoData;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.ms.biz.common.TaskBaseService;
import com.ms.biz.util.DDApi;
import lombok.extern.slf4j.Slf4j;
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;
import java.util.concurrent.Executor;
@Configuration
@Component
@Slf4j
public class GetAuthInfoTaskService extends TaskBaseService {
@Bean(name = "getAuthInfoTaskPool")
@Override
public Executor getAsyncExecutor() {
return super.getAsyncExecutor();
}
@Resource(name = "getAuthInfoTaskPool")
protected Executor taskPool;
@Async("getAuthInfoTaskPool")
@Scheduled(fixedRate = 10000)
@Override
public void runTask() {
super.runTask();
}
@Override
public int getCorePoolSiz() {
return 3;
}
@Override
public String getTaskExecutorName() {
return "getAuthInfoTaskPool";
}
@Override
protected Executor getTaskPool() {
return taskPool;
}
@Override
public Object getTask() {
return true;
}
@Override
public Object processTask(Object params) {
OpenGetAuthInfoParam param = new OpenGetAuthInfoParam();
param.setAuthId("1111502210");
OpenGetAuthInfoData data = DDApi.getAuthInfo(param);
log.info("GetAuthInfoService" + JSONObject.toJSONString(data));
return null;
}
@Override
public void clearTask(Object params) {
}
}

@ -0,0 +1,80 @@
package com.ms.biz.tool;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*;
@Slf4j
@Component
public class DfJsonRequestTemplate {
@Autowired
private CloudRequestTemplate cloudRequestTemplate;
@Value("${jx.df.host-prod}")
private String dfHostProd;
@Value("${jx.df.host-test}")
private String dfHostTest;
@Value("${jx.df.token-prod}")
private String dfTokenProd;
@Value("${jx.df.token-test}")
private String dfTokenTest;
private String dfHost;
private String dfToken;
public String execute(String url, Map<String, Object> body) throws Exception {
// 选择环境
if (StringUtils.isEmpty(dfHost)) {
if (SystemTool.isProdEnv()) {
// 当前为生产环境
dfHost = dfHostProd;
dfToken = dfTokenProd;
} else {
dfHost = dfHostProd;
dfToken = dfTokenProd;
}
}
System.out.println(dfHost + url);
// 构建头部
HttpHeaders headers = new HttpHeaders();
// 微应用固定传msddMicro
headers.set("x-app-name", "msddMicro");
// 使用json方式更符合外部服务管理
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HashMap<String,Object> params = (HashMap<String,Object>)body;
// 构建签名
Set<String> keySet = params.keySet();
String[] keyArray = keySet.toArray(new String[0]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
sb.append(dfToken);
for (String s : keyArray) {
if (!Objects.isNull(params.get(s))) {
String value = JSON.toJSONString(params.get(s), SerializerFeature.MapSortField);
value = CommonTool.removeQuotes(value);
sb.append(s).append(value);
}
}
log.info("req url:" + dfHost + url);
sb.append(dfToken);
log.info("row str:" + sb);
String sign = SecureUtil.md5(sb.toString());
log.info("sign str:" + sign);
headers.set("x-dd-micro-app-sign", sign);
log.info("body str:" + JSON.toJSONString(params, SerializerFeature.MapSortField));
return cloudRequestTemplate.executePost(dfHost + url, JSON.toJSONString(params, SerializerFeature.MapSortField), headers);
}
}

@ -47,8 +47,8 @@ public class DsJsonRequestTemplate {
dsHost = dsHostProd;
dsToken = dsTokenProd;
} else {
dsHost = dsHostProd;
dsToken = dsTokenProd;
dsHost = dsHostTest;
dsToken = dsTokenTest;
}
}
System.out.println(dsHost + url);
@ -73,6 +73,7 @@ public class DsJsonRequestTemplate {
sb.append(s).append(value);
}
}
log.info("req url:" + dsHost + url);
sb.append(dsToken);
log.info("row str:" + sb);
String sign = SecureUtil.md5(sb.toString());

@ -2,6 +2,10 @@ package com.ms.biz.util;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoRequest;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoResponse;
import com.doudian.open.api.open_getAuthInfo.data.OpenGetAuthInfoData;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackRequest;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackResponse;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
@ -148,6 +152,16 @@ public class DDApi {
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static OpenGetAuthInfoData getAuthInfo(OpenGetAuthInfoParam param) {
OpenGetAuthInfoRequest request = new OpenGetAuthInfoRequest();
request.setParam(param);
OpenGetAuthInfoResponse response = request.execute();
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
private static <T, R> T execute(DoudianOpRequest<R> request) {
// GlobalConfig.getGlobalConfig().addHttpRequestHeader("X-USE-BOE", "1");
// GlobalConfig.getGlobalConfig().addHttpRequestHeader("Origin-From", "djt_prod");

@ -0,0 +1,60 @@
package com.ms.dal.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName dd_supply_center_msg
*/
@Data
public class DdSupplyCenterMsg implements Serializable {
/**
* id
*/
private Long ddSupplyCenterMsgId;
/**
* id
*/
private String msgId;
/**
* id
*/
private Long shopId;
/**
*
*/
private Integer tag;
/**
* json
*/
private String data;
/**
*
*/
private String status;
/**
*
*/
private String reason;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,37 @@
package com.ms.dal.mapper;
import com.ms.dal.entity.DdSupplyCenterMsg;
import com.ms.dal.entity.DdTradeMsg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Entity com.ms.dal.entity.DdSupplyCenterMsg
*/
@Mapper
public interface DdSupplyCenterMsgMapper {
int deleteByPrimaryKey(Long id);
int insert(DdSupplyCenterMsg record);
int insertOrUpdate(DdSupplyCenterMsg record);
int insertSelective(DdSupplyCenterMsg record);
DdSupplyCenterMsg selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(DdSupplyCenterMsg record);
int updateByPrimaryKey(DdSupplyCenterMsg record);
int insertBatch(List<DdSupplyCenterMsg> list);
List<DdSupplyCenterMsg> selectByMsgIds(@Param("msgIds") List<String> msgIds);
DdSupplyCenterMsg selectByMsgId(String msgId);
int updateByMsgIdSelective(DdSupplyCenterMsg record);
}

@ -27,6 +27,4 @@ public interface PlatformPurchaseOrderMapper {
int updateByPrimaryKey(PlatformPurchaseOrder record);
List<PlatformPurchaseOrder> getListByPurOrderIds(@Param("purOrderIds") List<String> purOrderIds);
int updatePayUrlByPurOrderIds(@Param("payPcUrl") String payPcUrl, @Param("payH5Url") String payH5Url, @Param("purOrderIds") List<String> purOrderIds);
}

@ -33,5 +33,5 @@ public interface PurchaseOrderMapper {
PurchaseOrder getByPurOrderId(@Param("purOrderId") String purOrderId);
List<PurchaseOrder> getListByPurOrderIds(@Param("purOrderIds") List<String> purOrderIds);
List<PurchaseOrder> getListByPurOrderId(@Param("purOrderId") String purOrderId);
}

@ -48,6 +48,10 @@ jx.ds.host-test=https://acn-ds-test.chengji-inc.com/open
jx.ds.token-prod=dighgfghf^&)l3sedi&(.D@BC
jx.ds.token-test=dighgfghf^&)l3sedi&(.D@BC
jx.df.host-prod=https://df.91miaoshou.com/api
jx.df.host-test=https://df-api-dev.91miaoshou.com
jx.df.token-prod=dighgfghf^&)l3sedi&(.D@BC
jx.df.token-test=dighgfghf^&)l3sedi&(.D@BC
smd5.key1=^w46a~!%$2djKDUuI)#@
smd5.key2=2gk2li3l>2OJG13*#(OQG*#@@)

@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.DdSupplyCenterMsgMapper">
<resultMap id="BaseResultMap" type="com.ms.dal.entity.DdSupplyCenterMsg">
<id property="ddSupplyCenterMsgId" column="dd_supply_center_msg_id" jdbcType="BIGINT"/>
<result property="msgId" column="msg_id" jdbcType="VARCHAR"/>
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
<result property="tag" column="tag" jdbcType="SMALLINT"/>
<result property="data" column="data" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="reason" column="reason" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
dd_supply_center_msg_id,msg_id,shop_id,
tag,data,status,
reason,gmt_create,gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dd_supply_center_msg
where dd_supply_center_msg_id = #{ddSupplyCenterMsgId,jdbcType=BIGINT}
</select>
<select id="selectByMsgIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dd_supply_center_msg
where msg_id in
<foreach collection="msgIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectByMsgId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dd_supply_center_msg
where msg_id = #{msgId,jdbcType=VARCHAR}
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from dd_supply_center_msg
where dd_supply_center_msg_id = #{ddSupplyCenterMsgId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="dd_supply_center_msg_id" keyProperty="ddSupplyCenterMsgId" parameterType="com.ms.dal.entity.DdSupplyCenterMsg" useGeneratedKeys="true">
insert into dd_supply_center_msg
( dd_supply_center_msg_id,msg_id,shop_id
,tag,data,status
,reason,gmt_create,gmt_modified
)
values (#{ddSupplyCenterMsgId,jdbcType=BIGINT},#{msgId,jdbcType=VARCHAR},#{shopId,jdbcType=BIGINT}
,#{tag,jdbcType=SMALLINT},#{data,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR}
,#{reason,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP}
)
</insert>
<update id="insertOrUpdate" keyColumn="dd_supply_center_msg_id" keyProperty="ddSupplyCenterMsgId" parameterType="com.ms.dal.entity.DdSupplyCenterMsg"
useGeneratedKeys="true">
insert into dd_supply_center_msg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ddSupplyCenterMsgId != null">dd_supply_center_msg_id,</if>
<if test="msgId != null">msg_id,</if>
<if test="shopId != null">shop_id,</if>
<if test="tag != null">tag,</if>
<if test="data != null">data,</if>
<if test="status != null">status,</if>
<if test="reason != null">reason,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ddSupplyCenterMsgId != null">#{ddSupplyCenterMsgId,jdbcType=BIGINT},</if>
<if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
<if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
<if test="tag != null">#{tag,jdbcType=SMALLINT},</if>
<if test="data != null">#{data,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=VARCHAR},</if>
<if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
<if test="msgId != null">
msg_id = #{msgId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="tag != null">
tag = #{tag,jdbcType=SMALLINT},
</if>
<if test="data != null">
data = #{data,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</trim>
</update>
<insert id="insertSelective" keyColumn="dd_supply_center_msg_id" keyProperty="ddSupplyCenterMsgId" parameterType="com.ms.dal.entity.DdSupplyCenterMsg" useGeneratedKeys="true">
insert into dd_supply_center_msg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ddSupplyCenterMsgId != null">dd_supply_center_msg_id,</if>
<if test="msgId != null">msg_id,</if>
<if test="shopId != null">shop_id,</if>
<if test="tag != null">tag,</if>
<if test="data != null">data,</if>
<if test="status != null">status,</if>
<if test="reason != null">reason,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ddSupplyCenterMsgId != null">#{ddSupplyCenterMsgId,jdbcType=BIGINT},</if>
<if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
<if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
<if test="tag != null">#{tag,jdbcType=SMALLINT},</if>
<if test="data != null">#{data,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=VARCHAR},</if>
<if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<insert id="insertBatch" useGeneratedKeys="true" keyColumn="dd_supply_center_msg_id" keyProperty="list.ddSupplyCenterMsgId" parameterType="java.util.List">
insert into dd_supply_center_msg
(dd_supply_center_msg_id,msg_id,shop_id
,tag,data,status
,reason,gmt_create,gmt_modified
)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.ddSupplyCenterMsgId,jdbcType=BIGINT},#{item.msgId,jdbcType=VARCHAR},#{item.shopId,jdbcType=BIGINT}
,#{item.tag,jdbcType=SMALLINT},#{item.data,jdbcType=VARCHAR},#{item.status,jdbcType=VARCHAR}
,#{item.reason,jdbcType=VARCHAR},#{item.gmtCreate,jdbcType=TIMESTAMP},#{item.gmtModified,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.DdSupplyCenterMsg">
update dd_supply_center_msg
<set>
<if test="msgId != null">
msg_id = #{msgId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="tag != null">
tag = #{tag,jdbcType=SMALLINT},
</if>
<if test="data != null">
data = #{data,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where dd_supply_center_msg_id = #{ddSupplyCenterMsgId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.DdSupplyCenterMsg">
update dd_supply_center_msg
set
msg_id = #{msgId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=BIGINT},
tag = #{tag,jdbcType=SMALLINT},
data = #{data,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
reason = #{reason,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where dd_supply_center_msg_id = #{ddSupplyCenterMsgId,jdbcType=BIGINT}
</update>
<update id="updateByMsgIdSelective" parameterType="com.ms.dal.entity.DdSupplyCenterMsg">
update dd_supply_center_msg
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="tag != null">
tag = #{tag,jdbcType=SMALLINT},
</if>
<if test="data != null">
data = #{data,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where msg_id = #{msgId,jdbcType=VARCHAR}
</update>
</mapper>

@ -41,6 +41,7 @@
<if test="purchaseOrderSn != null">
and data like '%${purchaseOrderSn}%'
</if>
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from ds_message

@ -234,23 +234,4 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where pur_order_id = #{purOrderId,jdbcType=VARCHAR}
</update>
<update id="updatePayUrlByPurOrderIds">
update platform_purchase_order
set
pay_h5_url = #{payH5Url,jdbcType=VARCHAR},
pay_pc_url = #{payPcUrl,jdbcType=VARCHAR},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where 1=1
<choose>
<when test="purOrderIds!=null and purOrderIds.size>0">
and pur_order_id in
<foreach collection="purOrderIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
AND 1=0
</otherwise>
</choose>
</update>
</mapper>

@ -56,22 +56,11 @@
from purchase_order
where pur_order_id = #{purOrderId,jdbcType=VARCHAR}
</select>
<select id="getListByPurOrderIds" resultType="com.ms.dal.entity.PurchaseOrder">
<select id="getListByPurOrderId" resultType="com.ms.dal.entity.PurchaseOrder">
select
<include refid="Base_Column_List" />
from purchase_order
where 1=1
<choose>
<when test="purOrderIds!=null and purOrderIds.size>0">
and pur_order_id in
<foreach collection="purOrderIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
AND 1=0
</otherwise>
</choose>
where pur_order_id = #{purOrderId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

@ -205,7 +205,7 @@ public class Test {
@RequestMapping("/getAuthInfo")
public String getAuthInfo() { // 30459766L
GetAuthInfoResponseDTO responseDTO = dsApiService.getAuthInfo(1111502210L);
GetAuthInfoResponseDTO responseDTO = dsApiService.getAuthInfo(139183158L);
System.out.println(responseDTO);
return "";
}

Loading…
Cancel
Save