铺货消息推送

master
ljl 9 months ago
parent 7e6cfe4e0a
commit cf24159a9b

@ -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_APPOINTMENT = 112;//预约发货提交消息
public static final Integer TAG_TRADE_MEMO_MODIFY = 113;//订单商家备注消息推送 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_LOGISTICS_ORDER_TAG_PUSH = 10003;//订单标记推送
public static final Integer TAG_TRADE_DISTRIBUTE_CARGO = 16000;//分销商品铺货成功
public static final List<Integer> ALL_TRADE_TAGS = new ArrayList<>(); public static final List<Integer> ALL_TRADE_TAGS = new ArrayList<>();
static { static {

@ -2,5 +2,7 @@ package com.ms.biz.quque;
public class Group { public class Group {
public static final String GROUP_DS_MESSAGE = "GID_miaoshougoods_ds_message"; 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 class Topic {
public static final String TOPIC_DS_MESSAGE = "miaoshougoods_ds_message"; 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) { public static String rebuild(String topic) {
if (SystemTool.isDevEnv()) { if (SystemTool.isDevEnv()) {
return "local%" + topic; 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.DoudianMsg;
import com.ms.dal.entity.DoudianMsgParseQueue; import com.ms.dal.entity.DoudianMsgParseQueue;
import java.util.List;
/** /**
* *
*/ */
@ -29,4 +31,6 @@ public interface DoudianMsgService {
void failProcessDoudianMsgParseQueue(Long doudianMsgId); void failProcessDoudianMsgParseQueue(Long doudianMsgId);
boolean deleteDoudianMsgParseQueue(Long doudianMsgId); boolean deleteDoudianMsgParseQueue(Long doudianMsgId);
void receiveMessages(List<String> messageList);
} }

@ -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("/api/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)));
}
}

@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ms.biz.consts.DoudianMsgConst; import com.ms.biz.consts.DoudianMsgConst;
import com.ms.biz.consts.StatusConst; 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.dal.entity.*;
import com.ms.biz.service.DoudianMsgService; import com.ms.biz.service.DoudianMsgService;
import com.ms.dal.mapper.*; 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.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,6 +35,9 @@ public class DoudianMsgServiceImpl implements DoudianMsgService{
@Autowired @Autowired
private DoudianMsgMapper doudianMsgMapper; private DoudianMsgMapper doudianMsgMapper;
@Autowired
private DdSupplyCenterMsgMapper ddSupplyCenterMsgMapper;
@Autowired @Autowired
private DoudianMsgParseQueueMapper doudianMsgParseQueueMapper; private DoudianMsgParseQueueMapper doudianMsgParseQueueMapper;
@ -235,6 +243,44 @@ public class DoudianMsgServiceImpl implements DoudianMsgService{
int affRow = doudianMsgParseQueueMapper.deleteByPrimaryKey(queueId); int affRow = doudianMsgParseQueueMapper.deleteByPrimaryKey(queueId);
return affRow > 0; 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);
}
}
} }

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

@ -23,14 +23,16 @@ public class DoudianMsgReceiveService extends SPIBaseService implements Extensio
@Override @Override
public BaseResponse<Void> handle(BaseRequest<List<String>> req) { public BaseResponse<Void> handle(BaseRequest<List<String>> req) {
List<String> msgList = req.getData(); try {
if (msgList == null || msgList.isEmpty()) { List<String> msgList = req.getData();
return R.ok(); 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();
} }
} }

@ -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 = 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<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);
}
}

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

@ -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-prod=dighgfghf^&)l3sedi&(.D@BC
jx.ds.token-test=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.key1=^w46a~!%$2djKDUuI)#@
smd5.key2=2gk2li3l>2OJG13*#(OQG*#@@) 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>
Loading…
Cancel
Save