Commit f0f6ef26 authored by shiyu's avatar shiyu

一次性订阅新增类

parent 1a017c09
...@@ -73,4 +73,9 @@ public interface CommConsts { ...@@ -73,4 +73,9 @@ public interface CommConsts {
* 平台收货地址 * 平台收货地址
*/ */
public final static String SYSTEM_DEFAULT_ADDRESS = "换藏平台,13216703670,浙江省杭州市钱塘区2号大街海聚中心1幢1601"; public final static String SYSTEM_DEFAULT_ADDRESS = "换藏平台,13216703670,浙江省杭州市钱塘区2号大街海聚中心1幢1601";
/**
* 消息跳转专场页面
*/
public final static String SPECIAL_PERFORMANCE_URL = "/pages/saleSpecialList/index";
} }
...@@ -11,6 +11,28 @@ public class AuctionOfferNoticeMsg implements Entity { ...@@ -11,6 +11,28 @@ public class AuctionOfferNoticeMsg implements Entity {
private String templetId; private String templetId;
/**
* 专场id
*/
private Integer specialId;
private String specialPerformanceTitle;
/**
* 专场开始时间
*/
private String specialPerformanceStartTime;
/**
* 专场结束时间
*/
private String specialPerformanceEndTime;
/**
* 专场剩余时间
*/
private String specialPerformanceSurplusTime;
/** /**
* 分销订单号 * 分销订单号
*/ */
......
package com.wwdz.ch.core.impl; package com.wwdz.ch.core.impl;
import com.wwdz.ch.core.api.OfficialAccountApi; import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.entity.*; import com.wwdz.ch.core.entity.*;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.OkHttpUtil; import com.wwdz.ch.core.util.OkHttpUtil;
...@@ -607,52 +608,92 @@ public class SendMsgServiceImpl implements SendMsgService { ...@@ -607,52 +608,92 @@ public class SendMsgServiceImpl implements SendMsgService {
/** /**
* 竞拍开始通知 * 专场即将开始订阅消息
* @param auctionOfferNoticeMsg * @param auctionOfferNoticeMsg
* @return * @return
*/ */
public boolean sendAuctionStartMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) { public boolean sendSpecialPerformanceStartMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId = auctionOfferNoticeMsg.getOpenId(); String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken(); String token = officialAccountApi.getAccessToken();
String url = SEND_SUBSCRIBE_MSG_URL + "?access_token=" + token; String url = SEND_SUBSCRIBE_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url); OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("touser", openId); map.put("touser", openId);
map.put("template_id", "RjUUMuLyyW1g6ULUr9HWO8oEKoE-Vd_3s3p0XRI7tS0"); map.put("template_id", "AzJht7hkLJHSCN7trT3zsV3TaOE0Xk8faqm2sTf3Pm4");
Map<String, Object> miniprogramMap = new HashMap<>(); Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID); miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(AUCTION_MSG_URL); StringBuffer stringBuffer = new StringBuffer(CommConsts.SPECIAL_PERFORMANCE_URL);
stringBuffer.append("?itemId=" + auctionOfferNoticeMsg.getItemId()); stringBuffer.append("?specialId==" + auctionOfferNoticeMsg.getSpecialId());
if (StringUtils.hasLength(auctionOfferNoticeMsg.getShareRecordId())) { miniprogramMap.put("pagepath", stringBuffer.toString());
stringBuffer.append("&shareRecordId=" + auctionOfferNoticeMsg.getShareRecordId()); map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing2", new HashMap() {{
put("value", auctionOfferNoticeMsg.getSpecialPerformanceTitle());
}});
paramMap.put("time4", new HashMap() {{
put("value", auctionOfferNoticeMsg.getSpecialPerformanceStartTime());
}});
map.put("data", paramMap);
logger.info("============ 专场即将开始订阅消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送专场即将开始订阅消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送专场即将开始订阅消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return false;
}
logger.info("============= 发送专场即将开始订阅消息成功 ===========");
return true;
} }
/**
* 专场即将结束订阅消息
* @param auctionOfferNoticeMsg
* @return
*/
public boolean sendSpecialPerformanceEndMsg(AuctionOfferNoticeMsg auctionOfferNoticeMsg) {
String openId = auctionOfferNoticeMsg.getOpenId();
String token = officialAccountApi.getAccessToken();
String url = SEND_SUBSCRIBE_MSG_URL + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("touser", openId);
map.put("template_id", "G-GwA4yn63RJ6IysFotHB4anctNqbOy5qrz_R6vBJkM");
Map<String, Object> miniprogramMap = new HashMap<>();
miniprogramMap.put("appid", APPLET_APPID);
StringBuffer stringBuffer = new StringBuffer(CommConsts.SPECIAL_PERFORMANCE_URL);
stringBuffer.append("?specialId==" + auctionOfferNoticeMsg.getSpecialId());
miniprogramMap.put("pagepath", stringBuffer.toString()); miniprogramMap.put("pagepath", stringBuffer.toString());
map.put("miniprogram", miniprogramMap); map.put("miniprogram", miniprogramMap);
Map<String, Object> paramMap = new LinkedHashMap<>(); Map<String, Object> paramMap = new LinkedHashMap<>();
paramMap.put("thing1", new HashMap() {{ paramMap.put("thing4", new HashMap() {{
put("value", auctionOfferNoticeMsg.getItemName()); put("value", auctionOfferNoticeMsg.getSpecialPerformanceTitle());
}}); }});
paramMap.put("time2", new HashMap() {{ paramMap.put("thing3", new HashMap() {{
put("value", auctionOfferNoticeMsg.getCreateTime()); put("value", auctionOfferNoticeMsg.getSpecialPerformanceSurplusTime());
}}); }});
paramMap.put("time3", new HashMap() {{ paramMap.put("time7", new HashMap() {{
put("value", auctionOfferNoticeMsg.getContent()); put("value", auctionOfferNoticeMsg.getSpecialPerformanceEndTime());
}}); }});
map.put("data", paramMap); map.put("data", paramMap);
logger.info("============ 竞拍开始通知内容 : {}", JsonUtils.fromMap(map)); logger.info("============ 专场即将结束订阅消息内容 : {}", JsonUtils.fromMap(map));
okHttpUtil.addParams(map); okHttpUtil.addParams(map);
okHttpUtil.post(true); okHttpUtil.post(true);
String responseStr = okHttpUtil.async(); String responseStr = okHttpUtil.async();
logger.info("openid : {}, 发送竞拍开始通知 response :{}", openId, responseStr); logger.info("openid : {}, 发送专场即将结束订阅消息 response :{}", openId, responseStr);
String errorCode = JsonUtils.getValueByPath(responseStr, "errcode"); String errorCode = JsonUtils.getValueByPath(responseStr, "errcode");
String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg"); String errmsg = JsonUtils.getValueByPath(responseStr, "errmsg");
if (!"0".equals(errorCode)) { if (!"0".equals(errorCode)) {
logger.error("openid : {}, 发送竞拍开始通知, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg); logger.error("openid : {}, 发送专场即将结束订阅消息, errorCode : {}, errmsg : {} ", openId, errorCode, errmsg);
return false; return false;
} }
logger.info("============= 发送竞拍开始通知成功 ==========="); logger.info("============= 发送专场即将结束订阅消息成功 ===========");
return true; return true;
} }
......
...@@ -16,7 +16,7 @@ public interface DisposableSubscribeRecordDao { ...@@ -16,7 +16,7 @@ public interface DisposableSubscribeRecordDao {
* @param templateId * @param templateId
* @return * @return
*/ */
boolean isExisted(String openid, String templateId); boolean isExisted(String openid, long targetId, String templateId);
/** /**
* 是否订阅 * 是否订阅
...@@ -24,7 +24,7 @@ public interface DisposableSubscribeRecordDao { ...@@ -24,7 +24,7 @@ public interface DisposableSubscribeRecordDao {
* @param templateId * @param templateId
* @return * @return
*/ */
boolean isSubscribed(String openid, String templateId); boolean isSubscribed(String openid, long targetId, String templateId);
List<DisposableSubscribeRecord> findList(long userId); List<DisposableSubscribeRecord> findList(long userId);
} }
...@@ -10,7 +10,7 @@ import lombok.Data; ...@@ -10,7 +10,7 @@ import lombok.Data;
/** /**
* @author shiyu * @author shiyu
* @date 2024/04/07 * @date 2024/07/01
*/ */
@Data @Data
public class DisposableSubscribeRecord implements Entity { public class DisposableSubscribeRecord implements Entity {
...@@ -31,6 +31,11 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -31,6 +31,11 @@ public class DisposableSubscribeRecord implements Entity {
*/ */
private String templateId; private String templateId;
/**
* 订阅对象id
*/
private Long targetId;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -41,6 +46,11 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -41,6 +46,11 @@ public class DisposableSubscribeRecord implements Entity {
*/ */
private Date updateTime; private Date updateTime;
/**
* 类型
*/
private Integer type;
/** /**
* 是否有效 * 是否有效
*/ */
...@@ -58,8 +68,10 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -58,8 +68,10 @@ public class DisposableSubscribeRecord implements Entity {
sb.append(", userId=").append(userId); sb.append(", userId=").append(userId);
sb.append(", openid=").append(openid); sb.append(", openid=").append(openid);
sb.append(", templateId=").append(templateId); sb.append(", templateId=").append(templateId);
sb.append(", targetId=").append(targetId);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
sb.append(", type=").append(type);
sb.append(", isValid=").append(isValid); sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID); sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]"); sb.append("]");
...@@ -82,8 +94,10 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -82,8 +94,10 @@ public class DisposableSubscribeRecord implements Entity {
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getOpenid() == null ? other.getOpenid() == null : this.getOpenid().equals(other.getOpenid())) && (this.getOpenid() == null ? other.getOpenid() == null : this.getOpenid().equals(other.getOpenid()))
&& (this.getTemplateId() == null ? other.getTemplateId() == null : this.getTemplateId().equals(other.getTemplateId())) && (this.getTemplateId() == null ? other.getTemplateId() == null : this.getTemplateId().equals(other.getTemplateId()))
&& (this.getTargetId() == null ? other.getTargetId() == null : this.getTargetId().equals(other.getTargetId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid())); && (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
} }
...@@ -95,8 +109,10 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -95,8 +109,10 @@ public class DisposableSubscribeRecord implements Entity {
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getOpenid() == null) ? 0 : getOpenid().hashCode()); result = prime * result + ((getOpenid() == null) ? 0 : getOpenid().hashCode());
result = prime * result + ((getTemplateId() == null) ? 0 : getTemplateId().hashCode()); result = prime * result + ((getTemplateId() == null) ? 0 : getTemplateId().hashCode());
result = prime * result + ((getTargetId() == null) ? 0 : getTargetId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode()); result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result; return result;
} }
...@@ -113,8 +129,10 @@ public class DisposableSubscribeRecord implements Entity { ...@@ -113,8 +129,10 @@ public class DisposableSubscribeRecord implements Entity {
userId("user_id", "userId", "BIGINT", false), userId("user_id", "userId", "BIGINT", false),
openid("openid", "openid", "VARCHAR", false), openid("openid", "openid", "VARCHAR", false),
templateId("template_id", "templateId", "VARCHAR", false), templateId("template_id", "templateId", "VARCHAR", false),
targetId("target_id", "targetId", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false), updateTime("update_time", "updateTime", "TIMESTAMP", false),
type("type", "type", "INTEGER", true),
isValid("is_valid", "isValid", "BIT", false); isValid("is_valid", "isValid", "BIT", false);
/** /**
......
...@@ -696,6 +696,138 @@ public class DisposableSubscribeRecordExample { ...@@ -696,6 +696,138 @@ public class DisposableSubscribeRecordExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTargetIdIsNull() {
addCriterion("target_id is null");
return (Criteria) this;
}
public Criteria andTargetIdIsNotNull() {
addCriterion("target_id is not null");
return (Criteria) this;
}
public Criteria andTargetIdEqualTo(Long value) {
addCriterion("target_id =", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdNotEqualTo(Long value) {
addCriterion("target_id <>", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdNotEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdGreaterThan(Long value) {
addCriterion("target_id >", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdGreaterThanColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdGreaterThanOrEqualTo(Long value) {
addCriterion("target_id >=", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdGreaterThanOrEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdLessThan(Long value) {
addCriterion("target_id <", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdLessThanColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdLessThanOrEqualTo(Long value) {
addCriterion("target_id <=", value, "targetId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTargetIdLessThanOrEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("target_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTargetIdIn(List<Long> values) {
addCriterion("target_id in", values, "targetId");
return (Criteria) this;
}
public Criteria andTargetIdNotIn(List<Long> values) {
addCriterion("target_id not in", values, "targetId");
return (Criteria) this;
}
public Criteria andTargetIdBetween(Long value1, Long value2) {
addCriterion("target_id between", value1, value2, "targetId");
return (Criteria) this;
}
public Criteria andTargetIdNotBetween(Long value1, Long value2) {
addCriterion("target_id not between", value1, value2, "targetId");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() { public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null"); addCriterion("create_time is null");
return (Criteria) this; return (Criteria) this;
...@@ -960,6 +1092,138 @@ public class DisposableSubscribeRecordExample { ...@@ -960,6 +1092,138 @@ public class DisposableSubscribeRecordExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeNotEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeGreaterThanColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeGreaterThanOrEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeLessThanColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table disposable_subscribe_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeLessThanOrEqualToColumn(DisposableSubscribeRecord.Column column) {
addCriterion(new StringBuilder("`type` <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andIsValidIsNull() { public Criteria andIsValidIsNull() {
addCriterion("is_valid is null"); addCriterion("is_valid is null");
return (Criteria) this; return (Criteria) this;
......
package com.wwdz.ch.db.dto.request.distribution;
import com.wwdz.ch.db.dto.request.BaseRequestDto;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
@Data
public class DisposableSubscribeRecordRequestDto extends BaseRequestDto implements Entity {
private Integer id;
/**
* 用户id
*/
private Long userId;
/**
* openid
*/
private String openid;
/**
* 模板id
*/
private String templateId;
/**
* 订阅对象id
*/
private Long targetId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 类型
*/
private Integer type;
/**
* 是否有效
*/
private Boolean isValid;
}
...@@ -28,25 +28,28 @@ public class DisposableSubscribeRecordDaoImpl implements DisposableSubscribeReco ...@@ -28,25 +28,28 @@ public class DisposableSubscribeRecordDaoImpl implements DisposableSubscribeReco
DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample(); DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample();
DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria(); DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria();
criteria.andOpenidEqualTo(disposableSubscribeRecord.getOpenid()); criteria.andOpenidEqualTo(disposableSubscribeRecord.getOpenid());
criteria.andTargetIdEqualTo(disposableSubscribeRecord.getTargetId());
criteria.andTemplateIdEqualTo(disposableSubscribeRecord.getTemplateId()); criteria.andTemplateIdEqualTo(disposableSubscribeRecord.getTemplateId());
disposableSubscribeRecord.setUpdateTime(new Date()); disposableSubscribeRecord.setUpdateTime(new Date());
return disposableSubscribeRecordMapper.updateByExampleSelective(disposableSubscribeRecord, example) > 0; return disposableSubscribeRecordMapper.updateByExampleSelective(disposableSubscribeRecord, example) > 0;
} }
@Override @Override
public boolean isExisted(String openid, String templateId) { public boolean isExisted(String openid, long targetId, String templateId) {
DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample(); DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample();
DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria(); DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria();
criteria.andOpenidEqualTo(openid); criteria.andOpenidEqualTo(openid);
criteria.andTargetIdEqualTo(targetId);
criteria.andTemplateIdEqualTo(templateId); criteria.andTemplateIdEqualTo(templateId);
return disposableSubscribeRecordMapper.countByExample(example) > 0; return disposableSubscribeRecordMapper.countByExample(example) > 0;
} }
@Override @Override
public boolean isSubscribed(String openid, String templateId) { public boolean isSubscribed(String openid, long targetId, String templateId) {
DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample(); DisposableSubscribeRecordExample example = new DisposableSubscribeRecordExample();
DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria(); DisposableSubscribeRecordExample.Criteria criteria = example.createCriteria();
criteria.andOpenidEqualTo(openid); criteria.andOpenidEqualTo(openid);
criteria.andTargetIdEqualTo(targetId);
criteria.andTemplateIdEqualTo(templateId); criteria.andTemplateIdEqualTo(templateId);
criteria.andIsValidEqualTo(true); criteria.andIsValidEqualTo(true);
return disposableSubscribeRecordMapper.countByExample(example) > 0; return disposableSubscribeRecordMapper.countByExample(example) > 0;
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
<result column="user_id" jdbcType="BIGINT" property="userId" /> <result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="openid" jdbcType="VARCHAR" property="openid" /> <result column="openid" jdbcType="VARCHAR" property="openid" />
<result column="template_id" jdbcType="VARCHAR" property="templateId" /> <result column="template_id" jdbcType="VARCHAR" property="templateId" />
<result column="target_id" jdbcType="BIGINT" property="targetId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="is_valid" jdbcType="BIT" property="isValid" /> <result column="is_valid" jdbcType="BIT" property="isValid" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, user_id, openid, template_id, create_time, update_time, is_valid id, user_id, openid, template_id, target_id, create_time, update_time, `type`, is_valid
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecordExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecordExample" resultMap="BaseResultMap">
select select
...@@ -98,13 +100,14 @@ ...@@ -98,13 +100,14 @@
distinct distinct
</if> </if>
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, openid, template_id, create_time, update_time, is_valid id, user_id, openid, template_id, target_id, create_time, update_time, `type`, is_valid
</otherwise> </otherwise>
</choose> </choose>
from disposable_subscribe_record from disposable_subscribe_record
...@@ -129,13 +132,14 @@ ...@@ -129,13 +132,14 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, openid, template_id, create_time, update_time, is_valid id, user_id, openid, template_id, target_id, create_time, update_time, `type`, is_valid
</otherwise> </otherwise>
</choose> </choose>
from disposable_subscribe_record from disposable_subscribe_record
...@@ -156,11 +160,11 @@ ...@@ -156,11 +160,11 @@
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into disposable_subscribe_record (user_id, openid, template_id, insert into disposable_subscribe_record (user_id, openid, template_id,
create_time, update_time, is_valid target_id, create_time, update_time,
) `type`, is_valid)
values (#{userId,jdbcType=BIGINT}, #{openid,jdbcType=VARCHAR}, #{templateId,jdbcType=VARCHAR}, values (#{userId,jdbcType=BIGINT}, #{openid,jdbcType=VARCHAR}, #{templateId,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT} #{targetId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
) #{type,jdbcType=INTEGER}, #{isValid,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
...@@ -177,12 +181,18 @@ ...@@ -177,12 +181,18 @@
<if test="templateId != null"> <if test="templateId != null">
template_id, template_id,
</if> </if>
<if test="targetId != null">
target_id,
</if>
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
</if> </if>
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="type != null">
`type`,
</if>
<if test="isValid != null"> <if test="isValid != null">
is_valid, is_valid,
</if> </if>
...@@ -197,12 +207,18 @@ ...@@ -197,12 +207,18 @@
<if test="templateId != null"> <if test="templateId != null">
#{templateId,jdbcType=VARCHAR}, #{templateId,jdbcType=VARCHAR},
</if> </if>
<if test="targetId != null">
#{targetId,jdbcType=BIGINT},
</if>
<if test="createTime != null"> <if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
<if test="isValid != null"> <if test="isValid != null">
#{isValid,jdbcType=BIT}, #{isValid,jdbcType=BIT},
</if> </if>
...@@ -229,12 +245,18 @@ ...@@ -229,12 +245,18 @@
<if test="record.templateId != null"> <if test="record.templateId != null">
template_id = #{record.templateId,jdbcType=VARCHAR}, template_id = #{record.templateId,jdbcType=VARCHAR},
</if> </if>
<if test="record.targetId != null">
target_id = #{record.targetId,jdbcType=BIGINT},
</if>
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
<if test="record.isValid != null"> <if test="record.isValid != null">
is_valid = #{record.isValid,jdbcType=BIT}, is_valid = #{record.isValid,jdbcType=BIT},
</if> </if>
...@@ -249,8 +271,10 @@ ...@@ -249,8 +271,10 @@
user_id = #{record.userId,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT},
openid = #{record.openid,jdbcType=VARCHAR}, openid = #{record.openid,jdbcType=VARCHAR},
template_id = #{record.templateId,jdbcType=VARCHAR}, template_id = #{record.templateId,jdbcType=VARCHAR},
target_id = #{record.targetId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
`type` = #{record.type,jdbcType=INTEGER},
is_valid = #{record.isValid,jdbcType=BIT} is_valid = #{record.isValid,jdbcType=BIT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -268,12 +292,18 @@ ...@@ -268,12 +292,18 @@
<if test="templateId != null"> <if test="templateId != null">
template_id = #{templateId,jdbcType=VARCHAR}, template_id = #{templateId,jdbcType=VARCHAR},
</if> </if>
<if test="targetId != null">
target_id = #{targetId,jdbcType=BIGINT},
</if>
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
<if test="isValid != null"> <if test="isValid != null">
is_valid = #{isValid,jdbcType=BIT}, is_valid = #{isValid,jdbcType=BIT},
</if> </if>
...@@ -285,8 +315,10 @@ ...@@ -285,8 +315,10 @@
set user_id = #{userId,jdbcType=BIGINT}, set user_id = #{userId,jdbcType=BIGINT},
openid = #{openid,jdbcType=VARCHAR}, openid = #{openid,jdbcType=VARCHAR},
template_id = #{templateId,jdbcType=VARCHAR}, template_id = #{templateId,jdbcType=VARCHAR},
target_id = #{targetId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
`type` = #{type,jdbcType=INTEGER},
is_valid = #{isValid,jdbcType=BIT} is_valid = #{isValid,jdbcType=BIT}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
...@@ -317,13 +349,14 @@ ...@@ -317,13 +349,14 @@
select select
'true' as QUERYID, 'true' as QUERYID,
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, openid, template_id, create_time, update_time, is_valid id, user_id, openid, template_id, target_id, create_time, update_time, `type`, is_valid
</otherwise> </otherwise>
</choose> </choose>
from disposable_subscribe_record from disposable_subscribe_record
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution" <javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/> targetProject="ch-dao/src/main/java"/>
<table tableName="special_performance" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"> <table tableName="disposable_subscribe_record" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" /> <generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table> </table>
......
...@@ -5,6 +5,7 @@ import com.wwdz.ch.core.api.OfficialAccountApi; ...@@ -5,6 +5,7 @@ import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.consts.OfficalAccountEnum; import com.wwdz.ch.core.consts.OfficalAccountEnum;
import com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg; import com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.DisposableSubscribeRecordDao;
import com.wwdz.ch.db.dao.UserDao; import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord; import com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
...@@ -63,6 +64,9 @@ public class OfficialAccountCallbackController { ...@@ -63,6 +64,9 @@ public class OfficialAccountCallbackController {
@Autowired @Autowired
UserDao userDao; UserDao userDao;
@Autowired
DisposableSubscribeRecordDao disposableSubscribeRecordDao;
@RequestMapping(value ="/getNotice") @RequestMapping(value ="/getNotice")
public Object getNotice(@RequestParam(required = false, name = "signature") String signature, public Object getNotice(@RequestParam(required = false, name = "signature") String signature,
...@@ -132,7 +136,6 @@ public class OfficialAccountCallbackController { ...@@ -132,7 +136,6 @@ public class OfficialAccountCallbackController {
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("微信公众号通知回调接口 error : {}", e); logger.error("微信公众号通知回调接口 error : {}", e);
......
...@@ -3,6 +3,7 @@ package com.wwdz.ch.wx.impl.distribution; ...@@ -3,6 +3,7 @@ package com.wwdz.ch.wx.impl.distribution;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.DisposableSubscribeRecordDao; import com.wwdz.ch.db.dao.DisposableSubscribeRecordDao;
import com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord; import com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord;
import com.wwdz.ch.db.dto.request.distribution.DisposableSubscribeRecordRequestDto;
import com.wwdz.ch.wx.service.distribution.DisposableSubscribeRecordService; import com.wwdz.ch.wx.service.distribution.DisposableSubscribeRecordService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -20,16 +21,17 @@ public class DisposableSubscribeRecordServiceImpl implements DisposableSubscribe ...@@ -20,16 +21,17 @@ public class DisposableSubscribeRecordServiceImpl implements DisposableSubscribe
DisposableSubscribeRecordDao disposableSubscribeRecordDao; DisposableSubscribeRecordDao disposableSubscribeRecordDao;
@Override @Override
public Result insert(DisposableSubscribeRecord disposableSubscribeRecord) { public Result subscribed(DisposableSubscribeRecordRequestDto dto) {
try { try {
Long userId = disposableSubscribeRecord.getUserId(); Long userId = dto.getUserId();
String openid = disposableSubscribeRecord.getOpenid(); String openid = dto.getOpenid();
String templateId = disposableSubscribeRecord.getTemplateId(); String templateId = dto.getTemplateId();
boolean isExisted = disposableSubscribeRecordDao.isExisted(openid, templateId); long targetId = dto.getTargetId();
boolean isExisted = disposableSubscribeRecordDao.isExisted(openid, targetId, templateId);
DisposableSubscribeRecord disposableSubscribeRecord = new DisposableSubscribeRecord();
disposableSubscribeRecord.setIsValid(true);
//如果有历史记录,则做更新 //如果有历史记录,则做更新
if (isExisted) { if (!disposableSubscribeRecordDao.isSubscribed(openid, targetId, templateId)) {
disposableSubscribeRecordDao.update(disposableSubscribeRecord);
} else {
disposableSubscribeRecordDao.insert(disposableSubscribeRecord); disposableSubscribeRecordDao.insert(disposableSubscribeRecord);
} }
return Result.success(); return Result.success();
...@@ -46,12 +48,12 @@ public class DisposableSubscribeRecordServiceImpl implements DisposableSubscribe ...@@ -46,12 +48,12 @@ public class DisposableSubscribeRecordServiceImpl implements DisposableSubscribe
} }
@Override @Override
public Result isExisted(String openid, String templateId) { public Result isExisted(DisposableSubscribeRecordRequestDto dto) {
return null; return null;
} }
@Override @Override
public Result isSubscribed(String openid, String templateId) { public Result isSubscribed(DisposableSubscribeRecordRequestDto dto) {
return null; return null;
} }
......
...@@ -2,6 +2,7 @@ package com.wwdz.ch.wx.service.distribution; ...@@ -2,6 +2,7 @@ package com.wwdz.ch.wx.service.distribution;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord; import com.wwdz.ch.db.domain.distribution.DisposableSubscribeRecord;
import com.wwdz.ch.db.dto.request.distribution.DisposableSubscribeRecordRequestDto;
import java.util.List; import java.util.List;
...@@ -10,13 +11,18 @@ import java.util.List; ...@@ -10,13 +11,18 @@ import java.util.List;
*/ */
public interface DisposableSubscribeRecordService { public interface DisposableSubscribeRecordService {
Result insert(DisposableSubscribeRecord disposableSubscribeRecord); /**
* 用户订阅
* @param dto
* @return
*/
Result subscribed(DisposableSubscribeRecordRequestDto dto);
Result update(DisposableSubscribeRecord disposableSubscribeRecord); Result update(DisposableSubscribeRecord disposableSubscribeRecord);
Result isExisted(String openid, String templateId); Result isExisted(DisposableSubscribeRecordRequestDto dto);
Result isSubscribed(String openid, String templateId); Result isSubscribed(DisposableSubscribeRecordRequestDto dto);
List<DisposableSubscribeRecord> findList(long userId); List<DisposableSubscribeRecord> findList(long userId);
} }
...@@ -25,8 +25,8 @@ public class LogisticsApiTest { ...@@ -25,8 +25,8 @@ public class LogisticsApiTest {
@Test @Test
public void findTrails() { public void findTrails() {
LogisticsRequestDto dto = new LogisticsRequestDto(); LogisticsRequestDto dto = new LogisticsRequestDto();
dto.setLogisticsCode("YTO"); dto.setLogisticsCode("YD");
dto.setWaybill("YT1160805180957"); dto.setWaybill("312421269717964");
Result result = logisticsApi.findTrails(dto); Result result = logisticsApi.findTrails(dto);
logger.info("物流轨迹: {}" + result); logger.info("物流轨迹: {}" + result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment