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

Commit 94058b07 authored by wanglele's avatar wanglele

批量空投

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