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

Commit 7cd058ff authored by Administrator's avatar Administrator 🎨

Merge branch 'pre' into 'master'

Pre

See merge request !18
parents be8c398b f512ac53
...@@ -15,6 +15,7 @@ public class SweetConstant { ...@@ -15,6 +15,7 @@ public class SweetConstant {
public final static String REDIS_KEY_SWEET_SHOP = "sweet:artists:shop:manual:"; public final static String REDIS_KEY_SWEET_SHOP = "sweet:artists:shop:manual:";
public final static String REDIS_KEY_SWEET_LUCK_DRAW = "sweet:luckDraw:mobile:"; public final static String REDIS_KEY_SWEET_LUCK_DRAW = "sweet:luckDraw:mobile:";
public final static String REDIS_KEY_SWEET_LUCK_DRAW_RESULT = "sweet:luckDraw:num:";
public final static String REDIS_KEY_SWEET_LUCK_DRAW_SURPLUS = "sweet:luckDraw:num:";//中奖库存 public final static String REDIS_KEY_SWEET_LUCK_DRAW_SURPLUS = "sweet:luckDraw:num:";//中奖库存
public final static String REDIS_KEY_SWEET_LUCK_DRAW_ALL = "sweet:luckDraw:num:";//中奖总量 public final static String REDIS_KEY_SWEET_LUCK_DRAW_ALL = "sweet:luckDraw:num:";//中奖总量
public final static String REDIS_KEY_SWEET_LUCK_DRAW_PRESENT_MOBILE = "sweet:luckDraw:present:mobile:";//中奖库存 public final static String REDIS_KEY_SWEET_LUCK_DRAW_PRESENT_MOBILE = "sweet:luckDraw:present:mobile:";//中奖库存
......
...@@ -336,6 +336,7 @@ public class SweetAppletController { ...@@ -336,6 +336,7 @@ public class SweetAppletController {
HashMap<String, Integer> hashMap = CollectionUtil.mapStringInteger(); HashMap<String, Integer> hashMap = CollectionUtil.mapStringInteger();
hashMap.put("count", redisDataUtils.getLuckDrawStatus(mobile, luckDrawNum)); hashMap.put("count", redisDataUtils.getLuckDrawStatus(mobile, luckDrawNum));
hashMap.put("prize", redisDataUtils.getLuckDrawResult(mobile, luckDrawNum));
return ResponseDto.success(hashMap); return ResponseDto.success(hashMap);
} }
......
...@@ -6,6 +6,7 @@ import io.swagger.annotations.Api; ...@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
...@@ -19,6 +20,7 @@ import java.io.*; ...@@ -19,6 +20,7 @@ import java.io.*;
@Api(tags = "同步微信用户数据") @Api(tags = "同步微信用户数据")
@RestController @RestController
@RequestMapping("/wechatSync") @RequestMapping("/wechatSync")
@Slf4j
public class SweetWechatSyncDataController { public class SweetWechatSyncDataController {
@Autowired @Autowired
...@@ -35,8 +37,7 @@ public class SweetWechatSyncDataController { ...@@ -35,8 +37,7 @@ public class SweetWechatSyncDataController {
BufferedReader bufferedReader = new BufferedReader(read); BufferedReader bufferedReader = new BufferedReader(read);
String mobile = null; String mobile = null;
while ((mobile = bufferedReader.readLine()) != null) { while ((mobile = bufferedReader.readLine()) != null) {
System.out.println(mobile); log.info("regMobilen:mobile:[{}]", mobile);
try { try {
MultiValueMap<String, String> params = new LinkedMultiValueMap(); MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("mobile", mobile); params.add("mobile", mobile);
...@@ -46,7 +47,7 @@ public class SweetWechatSyncDataController { ...@@ -46,7 +47,7 @@ public class SweetWechatSyncDataController {
String url = ""; String url = "";
HttpUtil.post(url, params); HttpUtil.post(url, params);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.info("regMobileException:mobile:[{}]", mobile);
} }
} }
...@@ -62,7 +63,7 @@ public class SweetWechatSyncDataController { ...@@ -62,7 +63,7 @@ public class SweetWechatSyncDataController {
try { try {
sweetWechatMpService.userInfo(); sweetWechatMpService.userInfo();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("getUsers", e);
} }
} }
...@@ -75,7 +76,7 @@ public class SweetWechatSyncDataController { ...@@ -75,7 +76,7 @@ public class SweetWechatSyncDataController {
try { try {
sweetWechatMpService.getUser(openId); sweetWechatMpService.getUser(openId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("getUser", e);
} }
} }
......
...@@ -47,9 +47,12 @@ public class SweetWechatMpService { ...@@ -47,9 +47,12 @@ public class SweetWechatMpService {
log.info("nextOpenid:[{}] ", nextOpenid); log.info("nextOpenid:[{}] ", nextOpenid);
for (String openId : openids) { for (String openId : openids) {
try {
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(openId); WxMpUser wxMpUser = wxMpService.getUserService().userInfo(openId);
log.info("openId:[{}],wxMpUsers:[{}]", openId, wxMpUser); if (!wxMpUser.getSubscribe()) {
log.info("getSubscribeFalse:openId:[{}]", openId);
continue;
}
SweetWechatUser userInfo = redisDataUtils.getSweetWechatUser(wxMpUser.getUnionId()); SweetWechatUser userInfo = redisDataUtils.getSweetWechatUser(wxMpUser.getUnionId());
if (null == userInfo) { if (null == userInfo) {
SweetWechatUser sweetWechatUser = SweetWechatUser.getNew(); SweetWechatUser sweetWechatUser = SweetWechatUser.getNew();
...@@ -80,9 +83,13 @@ public class SweetWechatMpService { ...@@ -80,9 +83,13 @@ public class SweetWechatMpService {
// 入缓存 // 入缓存
redisDataUtils.setSweetWechatUser(sweetWechatUser); redisDataUtils.setSweetWechatUser(sweetWechatUser);
} }
} catch (Exception e) {
log.info("forException:openId:[{}]", openId);
} }
}
log.info("nextOpenidSuccess:[{}] ", nextOpenid);
} while (!nextOpenid.isEmpty()); } while (!nextOpenid.isEmpty());
log.info("同步微信用户完成");
} }
public void getUser(String openId) throws WxErrorException { public void getUser(String openId) throws WxErrorException {
......
...@@ -404,6 +404,17 @@ public class RedisDataUtils { ...@@ -404,6 +404,17 @@ public class RedisDataUtils {
} }
} }
//获取抽奖状态
public int getLuckDrawResult(String mobile, String luckDrawNum) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_LUCK_DRAW_RESULT.concat(luckDrawNum).concat(":mobile:" + mobile);
Object obj = redisUtil.get(redisKey);
if(obj==null){
return 0;
}else{
return (int) redisUtil.get(redisKey);
}
}
//修改抽奖状态 //修改抽奖状态
public SweetPrizeVo changeLuckDrawStatus(String mobile, String unionId,String luckDrawNum) { public SweetPrizeVo changeLuckDrawStatus(String mobile, String unionId,String luckDrawNum) {
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
...@@ -444,6 +455,7 @@ public class RedisDataUtils { ...@@ -444,6 +455,7 @@ public class RedisDataUtils {
if (surplus < prizeALl) { if (surplus < prizeALl) {
prize = (int) redisUtil.incr(redisSurplus, 1); prize = (int) redisUtil.incr(redisSurplus, 1);
redisUtil.set(redisKey, 2); redisUtil.set(redisKey, 2);
redisUtil.set(SweetConstant.REDIS_KEY_SWEET_LUCK_DRAW_RESULT.concat(luckDrawNum).concat(":mobile:" + mobile),prize);
} }
} }
} }
......
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