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

Commit 94058b07 authored by wanglele's avatar wanglele

批量空投

parent 9d581e43
...@@ -70,6 +70,8 @@ public abstract class AbstractHttpRedisReceiver implements StreamListener<String ...@@ -70,6 +70,8 @@ public abstract class AbstractHttpRedisReceiver implements StreamListener<String
}); });
if (rsp.isSuccess()) { if (rsp.isSuccess()) {
addLink.add(new Object[]{adminUid,codeList.get(i)}); addLink.add(new Object[]{adminUid,codeList.get(i)});
}else {
log.error("airdrop send fail:[{}]"+userIdList.get(i));
} }
} }
...@@ -79,8 +81,7 @@ public abstract class AbstractHttpRedisReceiver implements StreamListener<String ...@@ -79,8 +81,7 @@ public abstract class AbstractHttpRedisReceiver implements StreamListener<String
sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getKey(),sqlData); sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getKey(),sqlData);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("airdrop send fail:[{}]");
log.error("发送空投失败!");
} }
return true; return true;
......
...@@ -129,7 +129,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -129,7 +129,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
if (gnc.getState().equals(2)) { if (gnc.getState().equals(2)) {
if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getBoxSkuId().equals(goblinGoodsSku.getSkuId())) { if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getBoxSkuId().equals(goblinGoodsSku.getSkuId())) {
goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName()); goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName());
} else if (StringUtil.isBlank(gnc.getBoxSkuId()) && gnc.getSkuId().equals(goblinGoodsSku.getSkuId())){ } else if (StringUtil.isBlank(gnc.getBoxSkuId()) && gnc.getSkuId().equals(goblinGoodsSku.getSkuId())) {
goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName()); goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName());
} }
} }
...@@ -377,40 +377,68 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -377,40 +377,68 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
@Override @Override
public ResponseDto<Boolean> addAirdrops(MultipartFile file, String activityId, String adminUid) { public ResponseDto<Boolean> addAirdrops(MultipartFile file, String activityId, String adminUid) {
try {
// 手机号集合 // 手机号集合
StringBuffer phonestr = new StringBuffer(); StringBuffer phonestr = new StringBuffer();
List<String> phoneList = CollectionUtil.arrayListString();
try {
EasyExcel.read(file.getInputStream(), GoblinNftExCodeFetchExcelVo.class, new PageReadListener<GoblinNftExCodeFetchExcelVo>(dataList -> { EasyExcel.read(file.getInputStream(), GoblinNftExCodeFetchExcelVo.class, new PageReadListener<GoblinNftExCodeFetchExcelVo>(dataList -> {
for (GoblinNftExCodeFetchExcelVo data : dataList) { for (GoblinNftExCodeFetchExcelVo data : dataList) {
if (data.getPhone() == null) { if (data.getPhone() == null) {
continue; continue;
} }
phonestr.append(data.getPhone()).append(","); phonestr.append(data.getPhone()).append(",");
phoneList.add(data.getPhone());
} }
})).sheet().doRead(); })).sheet().doRead();
} catch (Exception e) {
e.printStackTrace();
return ResponseDto.failure("解析文件失败!");
}
if (StringUtil.isNotBlank(phonestr)) { if (StringUtil.isNotBlank(phonestr)) {
phonestr.deleteCharAt(phonestr.length() - 1); phonestr.deleteCharAt(phonestr.length() - 1);
} }
// 根据手机号获取用户 // 根据手机号获取用户
List<AdamUserInfoDto> adamUserMappers = adamUserMapper.selectByPhones(phonestr.toString()); List<AdamUserInfoDto> adamUserInfoDtoList = adamUserMapper.selectByPhones(phonestr.toString());
if (adamUserInfoDtoList == null || adamUserInfoDtoList.size() <= 0 ){
return ResponseDto.failure("根据手机号未能查询到用户!");
}
ArrayList<String> phoneCheckList = CollectionUtil.arrayListString();
for (AdamUserInfoDto adamUserInfoDto : adamUserInfoDtoList) {
phoneCheckList.add(adamUserInfoDto.getMobile());
}
// 根据活动id获取可用兑换码 // 根据活动id获取可用兑换码
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
if (goblinNftExCodes.size() < adamUserMappers.size()) { if (goblinNftExCodes.size() < phoneList.size()) {
return ResponseDto.failure("可用兑换码数量不足!"); return ResponseDto.failure("可用兑换码数量不足!");
} }
// 页条数 // 页条数
int pageSize = 1; int pageSize = 1;
ArrayList<String> userIdList = CollectionUtil.arrayListString(); ArrayList<String> userIdList = CollectionUtil.arrayListString();
StringBuffer userIds = new StringBuffer(); StringBuffer userIds = new StringBuffer();
int i = 1; int i = 1;
for (AdamUserInfoDto adamUserInfoDto : adamUserMappers) { for (String phone : phoneList) {
userIdList.add(adamUserInfoDto.getUid()); if (!phoneCheckList.contains(phone)) {
userIds.append(adamUserInfoDto.getUid()).append(","); log.error("mobile select not user :[{}]" + phone);
continue;
}
AdamUserInfoDto adamUserInfo = null;
for (AdamUserInfoDto adamUserInfoDto : adamUserInfoDtoList) {
if (phone.equals(adamUserInfoDto.getMobile())) {
adamUserInfo = adamUserInfoDto;
}
}
userIdList.add(adamUserInfo.getUid());
userIds.append(adamUserInfo.getUid()).append(",");
if (userIdList.size() == pageSize) { if (userIdList.size() == pageSize) {
StringBuffer codes = new StringBuffer(); StringBuffer codes = new StringBuffer();
PageHelper.startPage(i, pageSize, true); PageHelper.startPage(i, pageSize, true);
...@@ -426,6 +454,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -426,6 +454,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
hashMap.put("adminUid", adminUid); hashMap.put("adminUid", adminUid);
queueUtils.sendMssPhoneCodeRedis(hashMap); queueUtils.sendMssPhoneCodeRedis(hashMap);
userIdList.clear(); userIdList.clear();
userIds = new StringBuffer();
i++; i++;
} }
} }
...@@ -448,10 +477,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -448,10 +477,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
} }
} catch (Exception e) { return ResponseDto.success(true);
e.printStackTrace();
}
return null;
} }
public static void main(String[] args) { public static void main(String[] args) {
......
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