记得上下班打卡 | git大法好,push需谨慎

Commit 7524f4c4 authored by jiangxiulong's avatar jiangxiulong

微信用户增加phone user_id

parent 83d93b55
......@@ -441,6 +441,9 @@ CREATE TABLE `sweet_wechat_user`
ROW_FORMAT = DYNAMIC COMMENT '正在现场服务号关注事件储存用户信息表';
alter table sweet_wechat_user add type tinyint NOT NULL DEFAULT 1 COMMENT '服务类型 1正在 2摩登' after user_id;
alter table sweet_wechat_user add adam_user_id varchar(200) NOT NULL DEFAULT '' COMMENT 'adam用户id' after user_id;
alter table sweet_wechat_user add adam_phone varchar(200) NOT NULL DEFAULT '' COMMENT 'adam用户手机号' after adam_user_id;
-- 小程序登录记录用户解密后信息表
drop TABLE if exists `sweet_applet_user`;
CREATE TABLE `sweet_applet_user`
......
......@@ -23,6 +23,7 @@ public class SweetConstant {
public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO="sweet:wechatUser:unionId:";
public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO_STR="sweet:wechatUser:unionIdStr:";
public final static String REDIS_KEY_SWEET_WECHAT_USER_UNIONID="sweet:wechatUser:openId:";
public final static String REDIS_KEY_SWEET_WECHAT_USER_UNIONID_PHONE="sweet:wechatUser:phone:";
public final static String REDIS_KEY_SWEET_ANSWER_PHONE="sweet:answer:phone:";
public final static String REDIS_KEY_SWEET_CITY_VOTE_STAT_LIST=":StatList";
public final static String REDIS_KEY_SWEET_CITY_VOTE_CITY_CODE=":cityCode:";
......
......@@ -52,12 +52,16 @@ public class SweetWechatTemplateController {
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "String", name = "unionId", value = "微信unionId", required = true),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "type", value = "type 1正在 2摩登", required = false),
@ApiImplicitParam(type = "form", dataType = "String", name = "userId", value = "正在用户ID", required = false),
@ApiImplicitParam(type = "form", dataType = "String", name = "phone", value = "正在用户手机号", required = false),
})
public ResponseDto followStatus(
@RequestParam() String unionId,
@RequestParam(defaultValue = "1") Integer type
@RequestParam(defaultValue = "1") Integer type,
@RequestParam(defaultValue = "") String userId,
@RequestParam(defaultValue = "") String phone
) {
boolean status = sweetTemplateService.followStatus(unionId, type);
boolean status = sweetTemplateService.followStatus(unionId, type, userId, phone);
if (status) {
return ResponseDto.success(1);
} else {
......
......@@ -30,6 +30,16 @@ public class SweetWechatUser implements Serializable {
*/
private String userId;
/**
* adam_user_id
*/
private String adamUserId;
/**
* adam_phone
*/
private String adamPhone;
/**
* openId
*/
......
......@@ -6,6 +6,7 @@ import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketTimesVo;
......@@ -31,6 +32,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -259,7 +261,7 @@ public class SweetWechatTemplateServiceImpl {
}
}
public boolean followStatus(String unionId, Integer type) {
public boolean followStatus(String unionId, Integer type, String userId, String phone) {
SweetWechatUser sweetWechatUser = null;
if (null == type || type <= 1) {
sweetWechatUser = redisDataUtils.getSweetWechatUser(unionId);
......@@ -268,6 +270,29 @@ public class SweetWechatTemplateServiceImpl {
}
if (null != sweetWechatUser && !sweetWechatUser.getUnionId().isEmpty()) {
// 同步手机号
String oldAdamUserId = sweetWechatUser.getAdamUserId();
String oldAdamPhone = sweetWechatUser.getAdamPhone();
if (!phone.isEmpty() && (oldAdamUserId.isEmpty() || oldAdamPhone.isEmpty())) {
sweetWechatUser.setAdamUserId(userId);
sweetWechatUser.setAdamPhone(phone);
if (null == type || type <= 1) {
redisDataUtils.setSweetWechatUser(sweetWechatUser);
} else if (type == 2) {
redisDataUtils.setSweetWechatUserModernsky(sweetWechatUser);
}
redisDataUtils.setUnionIdByPhone(phone, unionId);
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_user.update2"));
LocalDateTime now = LocalDateTime.now();
sqlsDataA.add(new Object[]{
userId, phone, now, unionId, type
});
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_USER_INSERT_DRAW.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
}
return true;
} else {
return false;
......
......@@ -338,6 +338,21 @@ public class RedisDataUtils {
return (String) redisUtil.get(redisKey);
}
public String getUnionIdByPhone(String phone) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_WECHAT_USER_UNIONID_PHONE.concat(phone);
Object obj = redisUtil.get(redisKey);
if (null == obj) {
return "";
} else {
return (String) redisUtil.get(redisKey);
}
}
public void setUnionIdByPhone(String phone, String unionId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_WECHAT_USER_UNIONID_PHONE.concat(phone);
redisUtil.set(redisKey, unionId);
}
public SweetWechatUser getSweetWechatUser(String unionid) {
if (unionid.isEmpty()) {
return null;
......
......@@ -45,6 +45,7 @@ sweet_answer.insert=INSERT INTO sweet_answer (answer_id,phone,answer_json,img_ur
# --------------------------关注/取消服务号的用户信息--------------------------
sweet_user.insert=INSERT INTO sweet_wechat_user (user_id,type,openId,unionId,nickname,sexDesc,sex,headImgUrl,language,country,province,city,subscribeTime,subscribeScene) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
sweet_user.update=UPDATE sweet_wechat_user SET is_cancel = ?, updated_at = ? WHERE unionId = ? and type = ?
sweet_user.update2=UPDATE sweet_wechat_user SET adam_user_id = ?, adam_phone = ?, updated_at = ? WHERE unionId = ? and type = ?
# --------------------------提醒记录--------------------------
sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performancesId) VALUES (?,?,?,?)
# --------------------------小程序登录记录用户解密后信息--------------------------
......
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