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

Commit bca590c0 authored by jiangxiulong's avatar jiangxiulong

unid to openId

parent 17f7c342
...@@ -487,7 +487,7 @@ CREATE TABLE `sweet_city_vote` ...@@ -487,7 +487,7 @@ CREATE TABLE `sweet_city_vote`
`mid` bigint unsigned NOT NULL AUTO_INCREMENT, `mid` bigint unsigned NOT NULL AUTO_INCREMENT,
`vote_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'vote_id', `vote_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'vote_id',
`phone` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号', `phone` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`unionId` varchar(255) NOT NULL DEFAULT '' COMMENT 'unionId', `openId` varchar(255) NOT NULL DEFAULT '' COMMENT 'openId',
`city_code` varchar(255) NOT NULL DEFAULT '' COMMENT '城市代码', `city_code` varchar(255) NOT NULL DEFAULT '' COMMENT '城市代码',
`city_name` varchar(255) NOT NULL DEFAULT '' COMMENT '城市名称', `city_name` varchar(255) NOT NULL DEFAULT '' COMMENT '城市名称',
`day_time` varchar(255) NOT NULL DEFAULT '' COMMENT '投票天', `day_time` varchar(255) NOT NULL DEFAULT '' COMMENT '投票天',
......
...@@ -35,13 +35,13 @@ public class SweetCityVoteController { ...@@ -35,13 +35,13 @@ public class SweetCityVoteController {
@ApiOperation("城市投票排名") @ApiOperation("城市投票排名")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "phone", value = "手机号", required = true), @ApiImplicitParam(type = "query", dataType = "String", name = "phone", value = "手机号", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "unionId", value = "unionId", required = true) @ApiImplicitParam(type = "query", dataType = "String", name = "openId", value = "openId", required = true)
}) })
public ResponseDto<List<SweetCItyVoteStatVo>> getList( public ResponseDto<List<SweetCItyVoteStatVo>> getList(
@RequestParam String phone, @RequestParam String phone,
@RequestParam String unionId @RequestParam String openId
) { ) {
return sweetCityVoteService.getList(phone, unionId); return sweetCityVoteService.getList(phone, openId);
} }
@PostMapping("createVote") @PostMapping("createVote")
......
...@@ -36,10 +36,10 @@ public class SweetCityVote implements Serializable { ...@@ -36,10 +36,10 @@ public class SweetCityVote implements Serializable {
private String phone; private String phone;
/** /**
* unionId * openId
*/ */
@TableField("unionId") @TableField("openId")
private String unionId; private String openId;
/** /**
* 城市代码 * 城市代码
......
...@@ -16,9 +16,9 @@ public class SweetCityVoteParam implements java.io.Serializable { ...@@ -16,9 +16,9 @@ public class SweetCityVoteParam implements java.io.Serializable {
@NotBlank(message = "phone不能为空") @NotBlank(message = "phone不能为空")
private String phone; private String phone;
@ApiModelProperty(position = 11, required = true, value = "unionId", example = "unionId") @ApiModelProperty(position = 11, required = true, value = "openId", example = "openId")
@NotBlank(message = "unionId不能为空") @NotBlank(message = "openId不能为空")
private String unionId; private String openId;
@ApiModelProperty(position = 12, required = true, value = "城市代码", example = "10001") @ApiModelProperty(position = 12, required = true, value = "城市代码", example = "10001")
@NotBlank(message = "cityCode不能为空") @NotBlank(message = "cityCode不能为空")
......
...@@ -22,5 +22,5 @@ public interface ISweetCityVoteService extends IService<SweetCityVote> { ...@@ -22,5 +22,5 @@ public interface ISweetCityVoteService extends IService<SweetCityVote> {
ResponseDto setStatList(); ResponseDto setStatList();
ResponseDto<List<SweetCItyVoteStatVo>> getList(String phone, String unionId); ResponseDto<List<SweetCItyVoteStatVo>> getList(String phone, String openId);
} }
...@@ -52,9 +52,9 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S ...@@ -52,9 +52,9 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
private SweetCityVoteStatMapper sweetCityVoteStatMapper; private SweetCityVoteStatMapper sweetCityVoteStatMapper;
@Override @Override
public ResponseDto<List<SweetCItyVoteStatVo>> getList(String phone, String unionId) { public ResponseDto<List<SweetCItyVoteStatVo>> getList(String phone, String openId) {
List<SweetCItyVoteStatVo> sweetCityVoteStatList = redisDataUtils.getSweetCityVoteStatList(); List<SweetCItyVoteStatVo> sweetCityVoteStatList = redisDataUtils.getSweetCityVoteStatList();
String userVote = redisDataUtils.getUserVote(phone, unionId); String userVote = redisDataUtils.getUserVote(phone, openId);
for (SweetCItyVoteStatVo info : sweetCityVoteStatList) { for (SweetCItyVoteStatVo info : sweetCityVoteStatList) {
if (userVote.isEmpty() || !userVote.equals(info.getCityCode())) { if (userVote.isEmpty() || !userVote.equals(info.getCityCode())) {
info.setIsVote(1); info.setIsVote(1);
...@@ -67,14 +67,14 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S ...@@ -67,14 +67,14 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
@Override @Override
public ResponseDto createVote(SweetCityVoteParam param) { public ResponseDto createVote(SweetCityVoteParam param) {
String userVote = redisDataUtils.getUserVote(param.getPhone(), param.getUnionId()); String userVote = redisDataUtils.getUserVote(param.getPhone(), param.getOpenId());
if (!userVote.isEmpty()) { if (!userVote.isEmpty()) {
return ResponseDto.failure("已经投过票啦~"); return ResponseDto.failure("已经投过票啦~");
} }
SweetCityVote aNew = SweetCityVote.getNew(); SweetCityVote aNew = SweetCityVote.getNew();
aNew.setVoteId(IDGenerator.nextSnowId()); aNew.setVoteId(IDGenerator.nextSnowId());
aNew.setPhone(param.getPhone()); aNew.setPhone(param.getPhone());
aNew.setUnionId(param.getUnionId()); aNew.setOpenId(param.getOpenId());
aNew.setCityCode(param.getCityCode()); aNew.setCityCode(param.getCityCode());
aNew.setCityName(param.getCityName()); aNew.setCityName(param.getCityName());
...@@ -84,7 +84,7 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S ...@@ -84,7 +84,7 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
LinkedList<Object[]> sqlsDataB = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlsDataB = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_city_vote.insert")); sqls.add(SqlMapping.get("sweet_city_vote.insert"));
sqlsDataA.add(new Object[]{ sqlsDataA.add(new Object[]{
aNew.getVoteId(), aNew.getPhone(), aNew.getUnionId(), aNew.getCityCode(), aNew.getCityName(), DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMdd) aNew.getVoteId(), aNew.getPhone(), aNew.getOpenId(), aNew.getCityCode(), aNew.getCityName(), DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMdd)
}); });
Integer cityVoteNum = redisDataUtils.getSweetCityVote(aNew.getCityCode()); Integer cityVoteNum = redisDataUtils.getSweetCityVote(aNew.getCityCode());
if (cityVoteNum > 0) { // 已有 incr if (cityVoteNum > 0) { // 已有 incr
...@@ -103,7 +103,7 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S ...@@ -103,7 +103,7 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
redisDataUtils.incrSweetCityVote(aNew.getCityCode()); redisDataUtils.incrSweetCityVote(aNew.getCityCode());
redisDataUtils.setUserVote(param.getPhone(), param.getUnionId(), param.getCityCode()); redisDataUtils.setUserVote(param.getPhone(), param.getOpenId(), param.getCityCode());
return ResponseDto.success(); return ResponseDto.success();
} }
......
...@@ -504,12 +504,12 @@ public class RedisDataUtils { ...@@ -504,12 +504,12 @@ public class RedisDataUtils {
return (Integer) obj; return (Integer) obj;
} }
} }
public void setUserVote(String phone, String unionId, String cityCode) { public void setUserVote(String phone, String openId, String cityCode) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_USER.concat(phone).concat("-").concat(unionId); String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_USER.concat(phone).concat("-").concat(openId);
redisUtil.set(redisKey, cityCode); redisUtil.set(redisKey, cityCode);
} }
public String getUserVote(String phone, String unionId) { public String getUserVote(String phone, String openId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_USER.concat(phone).concat("-").concat(unionId); String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_USER.concat(phone).concat("-").concat(openId);
Object obj = redisUtil.get(redisKey); Object obj = redisUtil.get(redisKey);
if (null == obj) { if (null == obj) {
return ""; return "";
......
...@@ -70,6 +70,6 @@ sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performan ...@@ -70,6 +70,6 @@ sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performan
# --------------------------小程序登录记录用户解密后信息-------------------------- # --------------------------小程序登录记录用户解密后信息--------------------------
sweet_applet_user.insert=INSERT INTO sweet_applet_user (user_id,openId,unionId,getPhoneNumber,getPurePhoneNumber,getCountryCode,type) VALUES (?,?,?,?,?,?,?) sweet_applet_user.insert=INSERT INTO sweet_applet_user (user_id,openId,unionId,getPhoneNumber,getPurePhoneNumber,getCountryCode,type) VALUES (?,?,?,?,?,?,?)
# --------------------------用户投票记录-------------------------- # --------------------------用户投票记录--------------------------
sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,unionId,city_code,city_name,day_time) VALUES (?,?,?,?,?,?) sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,openId,city_code,city_name,day_time) VALUES (?,?,?,?,?,?)
sweet_city_vote_stat.insert=INSERT INTO sweet_city_vote_stat (stat_id,city_code,city_name,vote_num) VALUES (?,?,?,?) sweet_city_vote_stat.insert=INSERT INTO sweet_city_vote_stat (stat_id,city_code,city_name,vote_num) VALUES (?,?,?,?)
sweet_city_vote_stat.update=UPDATE sweet_city_vote_stat SET vote_num = IFNULL(vote_num, 0) + 1, updated_at = ? WHERE city_code = ? sweet_city_vote_stat.update=UPDATE sweet_city_vote_stat SET vote_num = IFNULL(vote_num, 0) + 1, updated_at = ? WHERE city_code = ?
\ No newline at end of file
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