diff --git a/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessage.java b/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessage.java new file mode 100644 index 0000000..c497e68 --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessage.java @@ -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; +} diff --git a/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessageRequestDao.java b/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessageRequestDao.java new file mode 100644 index 0000000..fe464bc --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/dfapi/request/SupplyCenterMessageRequestDao.java @@ -0,0 +1,10 @@ +package com.ms.api.dto.dfapi.request; + +import lombok.Data; + +import java.util.List; + +@Data +public class SupplyCenterMessageRequestDao { + private List messages; +} diff --git a/ms-api/src/main/java/com/ms/api/dto/dfapi/response/CommonResponseDTO.java b/ms-api/src/main/java/com/ms/api/dto/dfapi/response/CommonResponseDTO.java new file mode 100644 index 0000000..67815a9 --- /dev/null +++ b/ms-api/src/main/java/com/ms/api/dto/dfapi/response/CommonResponseDTO.java @@ -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); + } +} + diff --git a/ms-biz/src/main/java/com/ms/biz/consts/DoudianMsgConst.java b/ms-biz/src/main/java/com/ms/biz/consts/DoudianMsgConst.java index c932e1a..55d0500 100644 --- a/ms-biz/src/main/java/com/ms/biz/consts/DoudianMsgConst.java +++ b/ms-biz/src/main/java/com/ms/biz/consts/DoudianMsgConst.java @@ -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 ALL_TRADE_TAGS = new ArrayList<>(); static { diff --git a/ms-biz/src/main/java/com/ms/biz/quque/Group.java b/ms-biz/src/main/java/com/ms/biz/quque/Group.java index 6d54962..f12e7c3 100644 --- a/ms-biz/src/main/java/com/ms/biz/quque/Group.java +++ b/ms-biz/src/main/java/com/ms/biz/quque/Group.java @@ -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"; } diff --git a/ms-biz/src/main/java/com/ms/biz/quque/Topic.java b/ms-biz/src/main/java/com/ms/biz/quque/Topic.java index b5df6e4..bce2125 100644 --- a/ms-biz/src/main/java/com/ms/biz/quque/Topic.java +++ b/ms-biz/src/main/java/com/ms/biz/quque/Topic.java @@ -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; diff --git a/ms-biz/src/main/java/com/ms/biz/quque/consumer/SupplyCenterMessageConsumer.java b/ms-biz/src/main/java/com/ms/biz/quque/consumer/SupplyCenterMessageConsumer.java new file mode 100644 index 0000000..69d0b05 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/quque/consumer/SupplyCenterMessageConsumer.java @@ -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 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; + } +} diff --git a/ms-biz/src/main/java/com/ms/biz/quque/message/SupplyCenterMessage.java b/ms-biz/src/main/java/com/ms/biz/quque/message/SupplyCenterMessage.java new file mode 100644 index 0000000..70e0e49 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/quque/message/SupplyCenterMessage.java @@ -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; +} diff --git a/ms-biz/src/main/java/com/ms/biz/service/DdSupplyCenterMsgService.java b/ms-biz/src/main/java/com/ms/biz/service/DdSupplyCenterMsgService.java new file mode 100644 index 0000000..e9fe004 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/DdSupplyCenterMsgService.java @@ -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); +} diff --git a/ms-biz/src/main/java/com/ms/biz/service/DfApiService.java b/ms-biz/src/main/java/com/ms/biz/service/DfApiService.java new file mode 100644 index 0000000..d258187 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/DfApiService.java @@ -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); +} diff --git a/ms-biz/src/main/java/com/ms/biz/service/DoudianMsgService.java b/ms-biz/src/main/java/com/ms/biz/service/DoudianMsgService.java index 860971a..f50c900 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/DoudianMsgService.java +++ b/ms-biz/src/main/java/com/ms/biz/service/DoudianMsgService.java @@ -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 messageList); } diff --git a/ms-biz/src/main/java/com/ms/biz/service/SupplyCenterService.java b/ms-biz/src/main/java/com/ms/biz/service/SupplyCenterService.java new file mode 100644 index 0000000..a1dde45 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/SupplyCenterService.java @@ -0,0 +1,5 @@ +package com.ms.biz.service; + +public interface SupplyCenterService { + void processMessage(String msgId); +} diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DdSupplyCenterMsgServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DdSupplyCenterMsgServiceImpl.java new file mode 100644 index 0000000..e2a50a0 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DdSupplyCenterMsgServiceImpl.java @@ -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); + } + +} + + + + diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DfApiServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DfApiServiceImpl.java new file mode 100644 index 0000000..0b5c381 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DfApiServiceImpl.java @@ -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("/api/open/supply_center/message/receiver_dd_supply_center_msg", objectToMap(request)); + return JSON.parseObject(resp, CommonResponseDTO.class); + } + + private Map objectToMap(Object obj) { + Map 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 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))); + } +} diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DoudianMsgServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DoudianMsgServiceImpl.java index 0b9ebea..982ce92 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/DoudianMsgServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DoudianMsgServiceImpl.java @@ -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 messageList) { + List 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); + } + } + } diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/SupplyCenterServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/SupplyCenterServiceImpl.java new file mode 100644 index 0000000..1dfb907 --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/SupplyCenterServiceImpl.java @@ -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 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); + } +} diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/DoudianMsgReceiveService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/DoudianMsgReceiveService.java index 063ca69..a7cd6ac 100644 --- a/ms-biz/src/main/java/com/ms/biz/spi/callback/DoudianMsgReceiveService.java +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/DoudianMsgReceiveService.java @@ -23,14 +23,16 @@ public class DoudianMsgReceiveService extends SPIBaseService implements Extensio @Override public BaseResponse handle(BaseRequest> req) { - List msgList = req.getData(); - if (msgList == null || msgList.isEmpty()) { - return R.ok(); + try { + List msgList = req.getData(); + if (msgList == null || msgList.isEmpty()) { + R.ok(); + } + doudianMsgService.receiveMessages(msgList); + return BaseResponse.builder().success(true).code("0").build(); + } catch (Throwable e) { + log.error("receive message error"); + return BaseResponse.builder().success(false).code("1").build(); } - for (String msgStr: msgList) { - DoudianMessage msg = JSON.parseObject(msgStr, DoudianMessage.class); - } - // 处理成功则返回 true code 0 - return BaseResponse.builder().success(true).code("0").build(); } } diff --git a/ms-biz/src/main/java/com/ms/biz/tool/DfJsonRequestTemplate.java b/ms-biz/src/main/java/com/ms/biz/tool/DfJsonRequestTemplate.java new file mode 100644 index 0000000..970673d --- /dev/null +++ b/ms-biz/src/main/java/com/ms/biz/tool/DfJsonRequestTemplate.java @@ -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 body) throws Exception { + // 选择环境 + if (StringUtils.isEmpty(dfHost)) { + if (SystemTool.isProdEnv()) { + // 当前为生产环境 + dfHost = dfHostProd; + dfToken = dfTokenProd; + } else { + dfHost = dfHostTest; + dfToken = dfTokenTest; + } + } + System.out.println(dfHost + url); + + // 构建头部 + HttpHeaders headers = new HttpHeaders(); + // 微应用固定传msddMicro + headers.set("x-app-name", "msddMicro"); + // 使用json方式更符合外部服务管理 + headers.setContentType(MediaType.APPLICATION_JSON_UTF8); + HashMap params = (HashMap)body; + // 构建签名 + Set 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); + } +} diff --git a/ms-dal/src/main/java/com/ms/dal/entity/DdSupplyCenterMsg.java b/ms-dal/src/main/java/com/ms/dal/entity/DdSupplyCenterMsg.java new file mode 100644 index 0000000..5f0fb6d --- /dev/null +++ b/ms-dal/src/main/java/com/ms/dal/entity/DdSupplyCenterMsg.java @@ -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; +} \ No newline at end of file diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/DdSupplyCenterMsgMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/DdSupplyCenterMsgMapper.java new file mode 100644 index 0000000..371bd7e --- /dev/null +++ b/ms-dal/src/main/java/com/ms/dal/mapper/DdSupplyCenterMsgMapper.java @@ -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 list); + + List selectByMsgIds(@Param("msgIds") List msgIds); + + DdSupplyCenterMsg selectByMsgId(String msgId); + + int updateByMsgIdSelective(DdSupplyCenterMsg record); +} diff --git a/ms-dal/src/main/resources/application.properties b/ms-dal/src/main/resources/application.properties index c4b6be6..1133560 100644 --- a/ms-dal/src/main/resources/application.properties +++ b/ms-dal/src/main/resources/application.properties @@ -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/open +jx.df.host-test=https://df.91miaoshou.com/open +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*#@@) diff --git a/ms-dal/src/main/resources/mapper/DdSupplyCenterMsgMapper.xml b/ms-dal/src/main/resources/mapper/DdSupplyCenterMsgMapper.xml new file mode 100644 index 0000000..e5c2109 --- /dev/null +++ b/ms-dal/src/main/resources/mapper/DdSupplyCenterMsgMapper.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + dd_supply_center_msg_id,msg_id,shop_id, + tag,data,status, + reason,gmt_create,gmt_modified + + + + + + + + + delete from dd_supply_center_msg + where dd_supply_center_msg_id = #{ddSupplyCenterMsgId,jdbcType=BIGINT} + + + 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 into dd_supply_center_msg + + dd_supply_center_msg_id, + msg_id, + shop_id, + tag, + data, + status, + reason, + gmt_create, + gmt_modified, + + + #{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}, + + ON DUPLICATE KEY UPDATE + + + 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}, + + + + + insert into dd_supply_center_msg + + dd_supply_center_msg_id, + msg_id, + shop_id, + tag, + data, + status, + reason, + gmt_create, + gmt_modified, + + + #{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 into dd_supply_center_msg + (dd_supply_center_msg_id,msg_id,shop_id + ,tag,data,status + ,reason,gmt_create,gmt_modified + ) + values + + (#{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} + ) + + + + update dd_supply_center_msg + + + 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 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 dd_supply_center_msg + + + 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 msg_id = #{msgId,jdbcType=VARCHAR} + +