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

Commit 65bc8bcc authored by GaoHu's avatar GaoHu

exit

parent 01ee3ac8
......@@ -22,6 +22,13 @@ import java.util.List;
@Data
public class GoblinGoodsAnticipateAddParam {
/**
* 预约名称
*/
@ApiModelProperty(value = "预约名称")
@NotBlank(message = "预约名称")
private String name;
/**
* 预约规则
*/
......
......@@ -33,6 +33,11 @@ public class GoblinGoodsAnticipateVo implements Serializable,Cloneable {
*/
private String id;
/**
* 预约名称
*/
private String name;
/**
* ant_id
*/
......@@ -83,6 +88,7 @@ public class GoblinGoodsAnticipateVo implements Serializable,Cloneable {
public GoblinGoodsAnticipateVo copy(GoblinGoodsAnticipateAddParam goodsAnticipateAddParam) {
if (null==goodsAnticipateAddParam) return this;
this.name = goodsAnticipateAddParam.getName();
this.people = goodsAnticipateAddParam.getPeople();
this.type = goodsAnticipateAddParam.getType();
this.setRule(goodsAnticipateAddParam.getRule());
......
......@@ -47,13 +47,13 @@ public class GoblinGoodsAnticipateController {
}
@ApiOperation("用户为他人助力")
@PatchMapping("help")
@PostMapping("help")
public ResponseDto<Object> help(@RequestParam(name = "sid", required = true) String sid) {
return goblinGoodsAnticipateService.help(sid);
}
@ApiOperation("获取助力头像")
@PatchMapping("getHelpAvatar")
@PostMapping("getHelpAvatar")
public ResponseDto<Object> getHelpAvatar(@RequestParam(name = "sid", required = true) String sid) {
return goblinGoodsAnticipateService.getHelpAvatar(sid);
}
......
......@@ -36,7 +36,7 @@ public class GoblinGoodsAnticipateMgController {
@ApiOperation("创建预约信息")
@PostMapping("/add")
public ResponseDto<Object> add(@Validated @RequestBody GoblinGoodsAnticipateAddParam goodsAnticipateAddParam) {
public ResponseDto<Object> add(@RequestBody GoblinGoodsAnticipateAddParam goodsAnticipateAddParam) {
return goblinGoodsAnticipateMgService.add(goodsAnticipateAddParam);
}
......
......@@ -65,11 +65,24 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr();
if (userVo == null) {
//接入助力人数判断
//获取需要多少人助力
GoblinGoodsAnticipateHelp sharePeopleBySkuId = goblinRedisUtils.getSharePeopleBySkuId(skuId);
Integer people = goblinRedisUtils.getHelpSidAddHelp(skuId);
if (sharePeopleBySkuId.getPeople() <= people) {
int num = sharePeopleBySkuId.getPeople() - people;
return ResponseDto.failure("预约失败!预约助力人数还差" + num + "人!");
//判断如果所需助力人数
if (sharePeopleBySkuId.getPeople() != 0) {
//用户得到助力人数
String sid = goblinRedisUtils.getShare(skuId, uid);
if (sid != null) {
Integer people = goblinRedisUtils.getHelpSidAddHelp(sid);
if (sharePeopleBySkuId.getPeople() > people) {
int num = sharePeopleBySkuId.getPeople() - people;
log.debug(" skuId:{},分享sid:{},预约uid:{},需要助力人数:{},助力人数:{}", skuId, sid, uid, sharePeopleBySkuId.getPeople(), people);
return ResponseDto.failure("预约失败!");
}
} else {
log.debug("skuId:{},需要助力人数:{},uid:{},该用户未开启分享助力!",skuId,sharePeopleBySkuId.getPeople(),uid);
return ResponseDto.failure("预约失败!");
}
}
GoblinGoodAnticipateUserVo user = new GoblinGoodAnticipateUserVo();
......@@ -127,16 +140,13 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
String uid = CurrentUtil.getCurrentUid();
//可以创建分享
//查询redis关联记录
Integer share = goblinRedisUtils.getShare(skuId, uid);
if (share != null) {
String sid = goblinRedisUtils.getShare(skuId, uid);
if (sid!=null) {
return ResponseDto.failure("已开启助力");
} else {
//查询sku需要助力人数
//Integer skuIdPeople = goblinRedisUtils.getSharePeopleBySkuId(skuId);
//redis缓存
goblinRedisUtils.setShare(skuId, uid, 0);
String sId = IDGenerator.nextTimeId2();
GoblinGoodsAnticipateShareVo goblinGoodsAnticipateShareVo = GoblinGoodsAnticipateShareVo.getNew();
goblinGoodsAnticipateShareVo.setSid(sId);
......@@ -150,6 +160,9 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//mongodb缓存
//goblinMongoUtils.setGoblinGoodsAnticipateShareVo(goblinGoodsAnticipateShareVo);
//redis缓存
goblinRedisUtils.setShare(skuId, uid, sId);
//redis存储用户分享
goblinRedisUtils.setShareVo(goblinGoodsAnticipateShareVo);
......@@ -163,7 +176,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
goblinGoodsAnticipateShareVo.getUrl(),
goblinGoodsAnticipateShareVo.getCreatedDate()
});
sendRedis("goblin_goods_anticipate_user", sqlValue);
sendRedis("goblin_goods_anticipate_share", sqlValue);
}
return ResponseDto.success();
}
......
......@@ -78,7 +78,10 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
//redis消息预约消息表
LinkedList<Object[]> sqlAnt = CollectionUtil.linkedListObjectArr();
sqlAnt.add(new Object[]{
goodsAnticipateVo.getName(),
antId,
goodsAnticipateVo.getPeople(),
goodsAnticipateVo.getType(),
goodsAnticipateVo.getRule(),
goodsAnticipateVo.getCreatedDate(),
goodsAnticipateVo.getDelTag()
......
......@@ -160,9 +160,17 @@ public class GoblinRedisUtils {
/**
* 存用户助力关联
*/
public void setShare(String skuId, String uid,Integer people) {
public void setShare(String skuId, String uid,String sid) {
String key = GoblinRedisConst.ANTICIPATE_SHARE_UID_SKUID.concat(uid).concat(":").concat(skuId);
redisUtil.set(key,people);
redisUtil.set(key,sid);
}
/**
* 获取用户是否开启关联助力
*/
public String getShare(String skuId,String uid){
String key = GoblinRedisConst.ANTICIPATE_SHARE_UID_SKUID.concat(uid).concat(":").concat(skuId);
return (String) redisUtil.get(key);
}
/**
......@@ -189,14 +197,6 @@ public class GoblinRedisUtils {
redisUtil.del(key);
}
/**
* 获取用户是否开启关联助力
*/
public Integer getShare(String skuId,String uid){
String key = GoblinRedisConst.ANTICIPATE_SHARE_UID_SKUID.concat(uid).concat(":").concat(skuId);
return (Integer) redisUtil.get(key);
}
/**
* 保存用户头像
*/
......@@ -261,7 +261,8 @@ public class GoblinRedisUtils {
* 获取 助力id人数
*/
public Integer getHelpSidAddHelp(String sid){
return (Integer) redisUtil.get(GoblinRedisConst.ANTICIPATE_SHARE_SID.concat(sid));
Integer people = (Integer) redisUtil.get(GoblinRedisConst.ANTICIPATE_SHARE_SID.concat(sid));
return people != null ? people : 0;
}
......
......@@ -135,7 +135,7 @@ goblin_user_digital_artwork.update_for_chain=UPDATE goblin_user_digital_artwork
goblin_user_digital_artwork.update_for_unboxing=UPDATE goblin_user_digital_artwork SET state=1,del_flg='1',opening_at=?,updated_at=?,deleted_at=? WHERE artwork_id=? AND state<>1
#----
#---- \u9884\u7EA6
goblin_goods_anticipate=INSERT INTO goblin_goods_anticipate(ant_id,`rule`,created_date,del_tag) VALUES(?,?,?,?)
goblin_goods_anticipate=INSERT INTO goblin_goods_anticipate(`name`,ant_id,people,`type`,`rule`,created_date,del_tag) VALUES(?,?,?,?,?,?,?)
goblin_goods_anticipate_value=INSERT INTO goblin_goods_anticipate_value (uid,ant_id,sku_name,sku_id,spu_id,about_people,actual_people,rule,about_start_date,about_end_date,created_date,del_tag) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods_anticipate_value_update_proper=UPDATE goblin_goods_anticipate_value SET about_people = ?,update_date = NOW() WHERE sku_id = ?
goblin_goods_anticipate_value_delete=UPDATE goblin_goods_anticipate_value SET `del_tag` = 1,update_date = NOW() WHERE sku_id = ?
......
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