记得上下班打卡 | 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,63 +377,72 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -377,63 +377,72 @@ 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) {
// 手机号集合
StringBuffer phonestr = new StringBuffer();
List<String> phoneList = CollectionUtil.arrayListString();
try { try {
// 手机号集合
StringBuffer phonestr = new StringBuffer();
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();
if (StringUtil.isNotBlank(phonestr)) { } catch (Exception e) {
phonestr.deleteCharAt(phonestr.length() - 1); e.printStackTrace();
} return ResponseDto.failure("解析文件失败!");
}
if (StringUtil.isNotBlank(phonestr)) {
phonestr.deleteCharAt(phonestr.length() - 1);
}
// 根据手机号获取用户
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获取可用兑换码
List<AdamUserInfoDto> adamUserMappers = adamUserMapper.selectByPhones(phonestr.toString()); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
if (goblinNftExCodes.size() < phoneList.size()) {
return ResponseDto.failure("可用兑换码数量不足!");
}
// 根据活动id获取可用兑换码 // 页条数
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId); int pageSize = 1;
if (goblinNftExCodes.size() < adamUserMappers.size()) { ArrayList<String> userIdList = CollectionUtil.arrayListString();
return ResponseDto.failure("可用兑换码数量不足!"); StringBuffer userIds = new StringBuffer();
int i = 1;
for (String phone : phoneList) {
if (!phoneCheckList.contains(phone)) {
log.error("mobile select not user :[{}]" + phone);
continue;
} }
// 页条数 AdamUserInfoDto adamUserInfo = null;
int pageSize = 1; for (AdamUserInfoDto adamUserInfoDto : adamUserInfoDtoList) {
ArrayList<String> userIdList = CollectionUtil.arrayListString(); if (phone.equals(adamUserInfoDto.getMobile())) {
StringBuffer userIds = new StringBuffer(); adamUserInfo = adamUserInfoDto;
int i = 1;
for (AdamUserInfoDto adamUserInfoDto : adamUserMappers) {
userIdList.add(adamUserInfoDto.getUid());
userIds.append(adamUserInfoDto.getUid()).append(",");
if (userIdList.size() == pageSize) {
StringBuffer codes = new StringBuffer();
PageHelper.startPage(i, pageSize, true);
List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) {
codes.append(goblinNftExCode.getCode()).append(",");
}
HashMap<String, String> hashMap = CollectionUtil.mapStringString();
codes.deleteCharAt(codes.length() - 1);
userIds.deleteCharAt(userIds.length() - 1);
hashMap.put("codes", codes.toString());
hashMap.put("userIds", userIds.toString());
hashMap.put("adminUid", adminUid);
queueUtils.sendMssPhoneCodeRedis(hashMap);
userIdList.clear();
i++;
} }
} }
if (userIdList.size() > 0) { userIdList.add(adamUserInfo.getUid());
userIds.append(adamUserInfo.getUid()).append(",");
if (userIdList.size() == pageSize) {
StringBuffer codes = new StringBuffer();
PageHelper.startPage(i, pageSize, true); PageHelper.startPage(i, pageSize, true);
List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId); List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
StringBuffer codes = new StringBuffer();
for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) { for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) {
codes.append(goblinNftExCode.getCode()).append(","); codes.append(goblinNftExCode.getCode()).append(",");
} }
...@@ -445,13 +454,30 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -445,13 +454,30 @@ 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++;
} }
}
if (userIdList.size() > 0) {
} catch (Exception e) { PageHelper.startPage(i, pageSize, true);
e.printStackTrace(); List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
StringBuffer codes = new StringBuffer();
for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) {
codes.append(goblinNftExCode.getCode()).append(",");
}
HashMap<String, String> hashMap = CollectionUtil.mapStringString();
codes.deleteCharAt(codes.length() - 1);
userIds.deleteCharAt(userIds.length() - 1);
hashMap.put("codes", codes.toString());
hashMap.put("userIds", userIds.toString());
hashMap.put("adminUid", adminUid);
queueUtils.sendMssPhoneCodeRedis(hashMap);
userIdList.clear();
} }
return null;
return ResponseDto.success(true);
} }
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