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

Commit dc572436 authored by zhanggb's avatar zhanggb

Merge remote-tracking branch 'origin/dev_yy_dh' into dev_yy_dh

parents 52136feb c02aa3ab
...@@ -23,7 +23,7 @@ public class GoblinStoreMgtGoodsSkuFilterParam implements Serializable { ...@@ -23,7 +23,7 @@ public class GoblinStoreMgtGoodsSkuFilterParam implements Serializable {
private Integer pageNum; private Integer pageNum;
@ApiModelProperty(position = 13, required = false, value = "搜索关键字[128]") @ApiModelProperty(position = 13, required = false, value = "搜索关键字[128]")
private String keyword; private String keyword;
@ApiModelProperty(position = 14, required = false, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架]", allowableValues = "0,1,2,3") @ApiModelProperty(position = 14, required = false, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架|4-已上架未开售]", allowableValues = "0,1,2,3")
private String shelvesStatus; private String shelvesStatus;
} }
...@@ -149,6 +149,12 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable { ...@@ -149,6 +149,12 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable {
*/ */
@ApiModelProperty(position = 26,required = true,value ="sku名称") @ApiModelProperty(position = 26,required = true,value ="sku名称")
private String skuName; private String skuName;
/**
* 兑换结果sku名称
*/
@ApiModelProperty(position = 27,required = true,value = "兑换结果sku名称")
private String resultSkuName;
/** /**
* 是否盲和 * 是否盲和
......
...@@ -41,7 +41,8 @@ public interface IGoblinNftExCodeService { ...@@ -41,7 +41,8 @@ public interface IGoblinNftExCodeService {
* 批量发送空投 * 批量发送空投
* @param file * @param file
* @param activityId * @param activityId
* @param adminUid
* @return * @return
*/ */
ResponseDto<Boolean> addAirdrops(MultipartFile file, GoblinNftExCodeParam goblinNftExCodeParam); ResponseDto<Boolean> addAirdrops(MultipartFile file,String activityId,String adminUid);
} }
...@@ -274,7 +274,8 @@ public class MQConst { ...@@ -274,7 +274,8 @@ public class MQConst {
GOBLIN_STORE_ORDER_OPERA("goblin:stream:order:store", "group.order:store", "商铺订单操作"), GOBLIN_STORE_ORDER_OPERA("goblin:stream:order:store", "group.order:store", "商铺订单操作"),
GOBLIN_USER_ORDER_OPERA("goblin:stream:order:user", "group.order:user", "用户订单操作"), GOBLIN_USER_ORDER_OPERA("goblin:stream:order:user", "group.order:user", "用户订单操作"),
GOBLIN_XLS_OPERA("goblin:stream:xls", "group.xls", "xls文件操作"), GOBLIN_XLS_OPERA("goblin:stream:xls", "group.xls", "xls文件操作"),
GOBLIN_PHONE_CODE_OPERA("goblin:stream:phone:code","goblin.phone.code","批量空投操作"), GOBLIN_PHONE_CODE_OPERA("goblin:stream:phone:code","group.phone:code","批量空投操作"),
GOBLIN_CODE_OPERA("goblin:stream:code","group.code","修改兑换码操作人"),
GOBLIN_UN_PAY_0("goblin:stream:order:back:0", "group.order:back", "回滚关闭订单库存队列"), GOBLIN_UN_PAY_0("goblin:stream:order:back:0", "group.order:back", "回滚关闭订单库存队列"),
GOBLIN_UN_PAY_1("goblin:stream:order:back:1", "group.order:back", "回滚关闭订单库存队列"), GOBLIN_UN_PAY_1("goblin:stream:order:back:1", "group.order:back", "回滚关闭订单库存队列"),
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</set> </set>
where code_id = #{codeId} where code_id = #{codeId}
</update> </update>
<update id="updateCodeAdminUids"> <update id="updateCodeAdminUids">
update goblin_nft_ex_code update goblin_nft_ex_code
<set> <set>
...@@ -80,7 +80,8 @@ ...@@ -80,7 +80,8 @@
<select id="selectGoblinNftCode" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode" <select id="selectGoblinNftCode" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultMap="BeseResult"> resultMap="BeseResult">
select select
DISTINCT gnec.code,gnec.code_id,gnec.sku_id,gnec.box_sku_id,gnec.activity_id,gnec.state,gnec.redeem_uid,gnec.redeem_at,gnec.admin_uid,gnec.created_at DISTINCT
gnec.code,gnec.code_id,gnec.sku_id,gnec.box_sku_id,gnec.activity_id,gnec.state,gnec.redeem_uid,gnec.redeem_at,gnec.admin_uid,gnec.created_at
from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes on gnec.sku_id = gnes.sku_id from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes on gnec.sku_id = gnes.sku_id
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and gnec.code = #{code,jdbcType=VARCHAR} and gnec.code = #{code,jdbcType=VARCHAR}
......
package com.liquidnet.service; package com.liquidnet.service;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
...@@ -13,6 +14,7 @@ import java.util.Arrays; ...@@ -13,6 +14,7 @@ import java.util.Arrays;
@Slf4j @Slf4j
@SpringBootApplication(scanBasePackages = {"com.liquidnet"}) @SpringBootApplication(scanBasePackages = {"com.liquidnet"})
@MapperScan(basePackages = "com.liquidnet.service.*.mapper")
public class ServiceConsumerKylinApplication implements CommandLineRunner { public class ServiceConsumerKylinApplication implements CommandLineRunner {
@Autowired @Autowired
private Environment environment; private Environment environment;
......
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerGoblinCodeReceiver;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
@Configuration
public class ConsumerGoblinCodeStreamConfig extends RedisStreamConfig {
@Autowired
ConsumerGoblinCodeReceiver consumerGoblinCodeReceiver;
public Subscription receiveCodeExamine(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(Consumer.from(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getGroup(), getConsumerName(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.name() + t)),
StreamOffset.create(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getKey(), ReadOffset.lastConsumed()), consumerGoblinCodeReceiver);
}
@Bean
public Subscription codeExamine0(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveCodeExamine(listenerContainer, 0);
listenerContainer.start();
return subscription;
}
}
package com.liquidnet.service.consumer.kylin.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import com.liquidnet.service.consumer.kylin.receiver.ConsumerGoblinPhoneCodeReceiver;
@Configuration
public class ConsumerGoblinPhoneCodeStreamConfig extends RedisStreamConfig {
@Autowired
ConsumerGoblinPhoneCodeReceiver consumerGoblinPhoneCodeReceiver;
public Subscription receivePhoneCodeExamine(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(Consumer.from(MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getGroup(), getConsumerName(MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.name() + t)),
StreamOffset.create(MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getKey(), ReadOffset.lastConsumed()), consumerGoblinPhoneCodeReceiver);
}
@Bean
public Subscription phoneCodeExamine0(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receivePhoneCodeExamine(listenerContainer, 0);
listenerContainer.start();
return subscription;
}
/* @Bean
public Subscription phoneCodeExamine1(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receivePhoneCodeExamine(listenerContainer, 1);
listenerContainer.start();
return subscription;
}*/
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.*;
@Slf4j
public abstract class AbstractHttpRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
@Autowired
StringRedisTemplate stringRedisTemplate;
@Value("${liquidnet.service.order.url}")
private String orderUrl;
@Override
public void onMessage(MapRecord<String, String, String> message) {
String redisStreamKey = this.getRedisStreamKey();
log.debug("CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]", redisStreamKey, message.getId(), message.getStream(), message.getValue());
boolean result = this.consumerMessageHandler(message.getValue());
log.info("CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}", result, redisStreamKey, message.getId());
try {
stringRedisTemplate.opsForStream().acknowledge(getRedisStreamGroup(), message);
} catch (Exception e) {
log.error("#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
}
try {
stringRedisTemplate.opsForStream().delete(redisStreamKey, message.getId());
} catch (Exception e) {
log.error("#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}", redisStreamKey, result, message.getValue(), e);
}
}
private boolean consumerMessageHandler(Map<String, String> message) {
try {
String codestr = message.get("codes");
String userIds = message.get("userIds");
String adminUid = message.get("adminUid");
List<String> codeList = Arrays.asList(codestr.split(","));
List<String> userIdList = Arrays.asList(userIds.split(","));
LinkedList<Object[]> addLink = CollectionUtil.linkedListObjectArr();
for (int i = 0; i < userIdList.size(); i++) {
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("code", codeList.get(i));
params.add("userId", userIdList.get(i));
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
String post = HttpUtil.post(orderUrl + "/order/goblin/nft/airdrop", params, headers);
ResponseDto<Boolean> rsp = JsonUtils.fromJson(post, new TypeReference<ResponseDto<Boolean>>() {
});
if (rsp.isSuccess()) {
addLink.add(new Object[]{adminUid,codeList.get(i)});
}
}
LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_activity.code.admin"));
String sqlData = SqlMapping.gets(sqls, addLink);
sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getKey(),sqlData);
} catch (Exception e) {
e.printStackTrace();
log.error("发送空投失败!");
}
return true;
}
public void sendMsgByRedis(String streamKey, String jsonMsg) {
HashMap<String, String> map = CollectionUtil.mapStringString();
map.put(MQConst.QUEUE_MESSAGE_KEY, jsonMsg);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey));
}
protected abstract String getRedisStreamKey();
protected abstract String getRedisStreamGroup();
}
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class ConsumerGoblinCodeReceiver extends AbstractSqlRedisReceiver{
@Override
protected String getRedisStreamKey() {
return MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GoblinQueue.GOBLIN_CODE_OPERA.getGroup();
}
}
...@@ -10,6 +10,7 @@ import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper; ...@@ -10,6 +10,7 @@ import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
...@@ -20,49 +21,7 @@ import java.util.Map; ...@@ -20,49 +21,7 @@ import java.util.Map;
@Slf4j @Slf4j
@Component @Component
public class ConsumerGoblinPhoneCodeReceiver extends AbstractBizRedisReceiver{ public class ConsumerGoblinPhoneCodeReceiver extends AbstractHttpRedisReceiver{
@Autowired
private GoblinNftExCodeMapper goblinNftExCodeMapper;
@Value("${liquidnet.service.order.url}")
private String orderUrl;
@Override
protected boolean consumerMessageHandler(String msg) {
Boolean bol = false;
try{
JSONObject jsonObject = JSON.parseObject(msg);
String codestr = jsonObject.getString("codes");
String userIds = jsonObject.getString("userIds");
String adminUid = jsonObject.getString("adminUid");
List<String> codeList = Arrays.asList(codestr.split(","));
List<String> userIdList = Arrays.asList(userIds.split(","));
StringBuffer codes = new StringBuffer();
for (int i = 0; i < userIdList.size(); i++) {
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("code", codeList.get(i));
params.add("userId", userIdList.get(i));
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
headers.add("Authorization", "Bearer " + CurrentUtil.getToken());
String post = HttpUtil.post(orderUrl + "/order/goblin/nft/airdrop", params, headers);
ResponseDto<Boolean> rsp = JsonUtils.fromJson(post, new TypeReference<ResponseDto<Boolean>>() {
});
if (rsp.isSuccess()) {
codes.append(codeList.get(i)).append(",");
}
}
if (StringUtil.isNotBlank(codes)){
codes.deleteCharAt(codes.length()-1);
}
goblinNftExCodeMapper.updateCodeAdminUids(codes.toString(),adminUid);
}catch (Exception e){
log.error("发送空投失败!");
}
return bol;
}
@Override @Override
protected String getRedisStreamKey() { protected String getRedisStreamKey() {
...@@ -73,4 +32,5 @@ public class ConsumerGoblinPhoneCodeReceiver extends AbstractBizRedisReceiver{ ...@@ -73,4 +32,5 @@ public class ConsumerGoblinPhoneCodeReceiver extends AbstractBizRedisReceiver{
protected String getRedisStreamGroup() { protected String getRedisStreamGroup() {
return MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getGroup(); return MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getGroup();
} }
} }
...@@ -3,4 +3,7 @@ goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at = ...@@ -3,4 +3,7 @@ goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at =
goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_user_coupon.updateState=UPDATE goblin_user_coupon SET state = ? , used_for = ? ,updated_at = ? where ucoupon_id = ? goblin_user_coupon.updateState=UPDATE goblin_user_coupon SET state = ? , used_for = ? ,updated_at = ? where ucoupon_id = ?
#-------- NFT ------- #-------- NFT -------
goblin_nft_order.update.close=UPDATE goblin_nft_order SET status = ?, updated_at = ?, cancel_time = ?, cancel_reason = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_nft_order.update.close=UPDATE goblin_nft_order SET status = ?, updated_at = ?, cancel_time = ?, cancel_reason = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
\ No newline at end of file
#---- 兑换码操作
goblin_activity.code.admin=UPDATE goblin_nft_ex_code SET admin_uid = ? where code = ?
\ No newline at end of file
...@@ -42,6 +42,7 @@ import java.util.regex.Pattern; ...@@ -42,6 +42,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
import static com.liquidnet.commons.lang.util.DateUtil.now;
@Component @Component
public class GoblinMongoUtils { public class GoblinMongoUtils {
...@@ -88,14 +89,14 @@ public class GoblinMongoUtils { ...@@ -88,14 +89,14 @@ public class GoblinMongoUtils {
LocalDateTime createdAtBegin = createDt.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime createdAtBegin = createDt.withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime createdAtEnd = createDt.withHour(23).withMinute(59).withSecond(59).withNano(999); LocalDateTime createdAtEnd = createDt.withHour(23).withMinute(59).withSecond(59).withNano(999);
criteria = criteria.and("aboutStartDate").gte(createdAtBegin).lte(createdAtEnd); criteria = criteria.and("aboutStartDate").gte(createdAtBegin);
} }
if (StringUtils.isNotBlank(goblinGoodsAnticipateValueParam.getAboutEndDate())) { if (StringUtils.isNotBlank(goblinGoodsAnticipateValueParam.getAboutEndDate())) {
LocalDateTime createDt = DateUtil.Formatter.yyyyMMddHHmmss.parse(goblinGoodsAnticipateValueParam.getAboutEndDate()); LocalDateTime createDt = DateUtil.Formatter.yyyyMMddHHmmss.parse(goblinGoodsAnticipateValueParam.getAboutEndDate());
LocalDateTime createdAtBegin = createDt.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime createdAtBegin = createDt.withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime createdAtEnd = createDt.withHour(23).withMinute(59).withSecond(59).withNano(999); LocalDateTime createdAtEnd = createDt.withHour(23).withMinute(59).withSecond(59).withNano(999);
criteria = criteria.and("aboutEndDate").gte(createdAtBegin).lte(createdAtEnd); criteria = criteria.and("aboutEndDate").lte(createdAtEnd);
} }
Query query = Query.query(criteria); Query query = Query.query(criteria);
//查询总数 //查询总数
...@@ -1552,7 +1553,11 @@ public class GoblinMongoUtils { ...@@ -1552,7 +1553,11 @@ public class GoblinMongoUtils {
criteria.and("name").regex(pattern); criteria.and("name").regex(pattern);
} }
if (StringUtils.isNotBlank(filterParam.getShelvesStatus())) { if (StringUtils.isNotBlank(filterParam.getShelvesStatus())) {
criteria.and("shelvesStatus").is(filterParam.getShelvesStatus()); if ("4".equals(filterParam.getShelvesStatus())){
criteria.and("shelvesStatus").is("3").and("saleStartTime").gte(now());
}else {
criteria.and("shelvesStatus").is(filterParam.getShelvesStatus());
}
} }
Query query = Query.query(criteria); Query query = Query.query(criteria);
......
...@@ -56,9 +56,9 @@ public class GoblinNftExCodeController { ...@@ -56,9 +56,9 @@ public class GoblinNftExCodeController {
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@ApiOperation(value = "excel空投批量发送") @ApiOperation(value = "excel空投批量发送")
@PostMapping("addAirdrops") @PostMapping("addAirdrops/{activityId}/{adminUid}")
public ResponseDto<Boolean> addAirdrops(MultipartFile file,@RequestBody GoblinNftExCodeParam goblinNftExCodeParam) { public ResponseDto<Boolean> addAirdrops(MultipartFile file,@PathVariable("activityId")String activityId,@PathVariable("adminUid") String adminUid) {
return iGoblinNftExCodeService.addAirdrops(file,goblinNftExCodeParam); return iGoblinNftExCodeService.addAirdrops(file,activityId,adminUid);
} }
......
...@@ -106,10 +106,9 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -106,10 +106,9 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
StringBuffer skuIds = new StringBuffer(); StringBuffer skuIds = new StringBuffer();
StringBuffer acticityIds = new StringBuffer(); StringBuffer acticityIds = new StringBuffer();
for (GoblinNftExCode gnc : goblinNftExCodes) { for (GoblinNftExCode gnc : goblinNftExCodes) {
skuIds.append(gnc.getSkuId()).append(",");
if (StringUtil.isNotBlank(gnc.getBoxSkuId())) { if (StringUtil.isNotBlank(gnc.getBoxSkuId())) {
skuIds.append(gnc.getBoxSkuId()).append(","); skuIds.append(gnc.getBoxSkuId()).append(",");
} else {
skuIds.append(gnc.getSkuId()).append(",");
} }
acticityIds.append(gnc.getActivityId()).append(","); acticityIds.append(gnc.getActivityId()).append(",");
} }
...@@ -123,15 +122,18 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -123,15 +122,18 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
for (GoblinNftExCode gnc : goblinNftExCodes) { for (GoblinNftExCode gnc : goblinNftExCodes) {
GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc); GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc);
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) { for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getBoxSkuId().equals(goblinGoodsSku.getSkuId())) { if (goblinNftExCodeVo.getSkuId().equals(goblinGoodsSku.getSkuId())) {
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName()); goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName());
break; }
} else {
if (StringUtil.isBlank(gnc.getBoxSkuId()) && gnc.getSkuId().equals(goblinGoodsSku.getSkuId())) { if (gnc.getState().equals(2)) {
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName()); if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getBoxSkuId().equals(goblinGoodsSku.getSkuId())) {
break; goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName());
} else if (StringUtil.isBlank(gnc.getBoxSkuId()) && gnc.getSkuId().equals(goblinGoodsSku.getSkuId())){
goblinNftExCodeVo.setResultSkuName(goblinGoodsSku.getName());
} }
} }
} }
goblinNftExCodeArrayList.add(goblinNftExCodeVo); goblinNftExCodeArrayList.add(goblinNftExCodeVo);
} }
...@@ -374,7 +376,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -374,7 +376,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
} }
@Override @Override
public ResponseDto<Boolean> addAirdrops(MultipartFile file, GoblinNftExCodeParam goblinNftExCodeParam) { public ResponseDto<Boolean> addAirdrops(MultipartFile file, String activityId, String adminUid) {
try { try {
// 手机号集合 // 手机号集合
StringBuffer phonestr = new StringBuffer(); StringBuffer phonestr = new StringBuffer();
...@@ -395,14 +397,14 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -395,14 +397,14 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
List<AdamUserInfoDto> adamUserMappers = adamUserMapper.selectByPhones(phonestr.toString()); List<AdamUserInfoDto> adamUserMappers = adamUserMapper.selectByPhones(phonestr.toString());
// 根据活动id获取可用兑换码 // 根据活动id获取可用兑换码
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(goblinNftExCodeParam.getActivityId()); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
if (goblinNftExCodes.size() < adamUserMappers.size()) { if (goblinNftExCodes.size() < adamUserMappers.size()) {
return ResponseDto.failure("可用兑换码数量不足!"); return ResponseDto.failure("可用兑换码数量不足!");
} }
// 页条数 // 页条数
int pageSize = 2; 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;
...@@ -412,22 +414,39 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -412,22 +414,39 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
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);
List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(goblinNftExCodeParam.getActivityId()); List<GoblinNftExCode> goblinNftExCodeList = goblinNftExCodeMapper.selectCodeAvailableByActivityId(activityId);
for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) { for (GoblinNftExCode goblinNftExCode : goblinNftExCodeList) {
codes.append(goblinNftExCode.getCode()).append(","); codes.append(goblinNftExCode.getCode()).append(",");
} }
JSONObject jsonObject = new JSONObject(); HashMap<String, String> hashMap = CollectionUtil.mapStringString();
codes.deleteCharAt(codes.length() - 1); codes.deleteCharAt(codes.length() - 1);
userIds.deleteCharAt(userIds.length() - 1); userIds.deleteCharAt(userIds.length() - 1);
jsonObject.put("codes", codes); hashMap.put("codes", codes.toString());
jsonObject.put("userIds", userIds); hashMap.put("userIds", userIds.toString());
jsonObject.put("adminUid",goblinNftExCodeParam.getAdminUid()); hashMap.put("adminUid", adminUid);
queueUtils.sendMssPhoneCodeRedis(MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getKey(), jsonObject.toJSONString()); queueUtils.sendMssPhoneCodeRedis(hashMap);
userIdList.clear(); userIdList.clear();
i++; i++;
} }
} }
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();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -92,7 +92,6 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -92,7 +92,6 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
goblinNftExSku.setExStopTime(goblinNftExCodeTask.getExStopTime()); goblinNftExSku.setExStopTime(goblinNftExCodeTask.getExStopTime());
goblinNftExSku.setCreatedAt(now); goblinNftExSku.setCreatedAt(now);
goblinNftExSkus.add(goblinNftExSku); goblinNftExSkus.add(goblinNftExSku);
updTaskIds.append(goblinNftExCodeTask.getTaskId()).append(","); updTaskIds.append(goblinNftExCodeTask.getTaskId()).append(",");
switch (goblinNftExCodeTask.getUnbox()) { switch (goblinNftExCodeTask.getUnbox()) {
...@@ -131,34 +130,8 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -131,34 +130,8 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
goblinNftExCodes.add(goblinNftExCode); goblinNftExCodes.add(goblinNftExCode);
} }
if (goblinNftExCodeTaskHashMap.get(goblinNftExCodeTask.getSkuId()) == null) {
goblinNftExCodeTaskHashMap.put(goblinNftExCodeTaskRelation.getSkuId(), goblinNftExCodeTask);
} else {
GoblinNftExCodeTask nftExCodeTask = goblinNftExCodeTaskHashMap.get(goblinNftExCodeTask.getSkuId());
LocalDateTime exStartTime = nftExCodeTask.getExStartTime();
LocalDateTime exStopTime = nftExCodeTask.getExStopTime();
// 时间比较
boolean bolNotUn = false;
// 时间比较
if (goblinNftExCodeTask.getExStartTime().isBefore(exStartTime)) {
nftExCodeTask.setExStartTime(goblinNftExCodeTask.getExStartTime());
bolNotUn = true;
}
if (goblinNftExCodeTask.getExStopTime().isAfter(exStopTime)) {
nftExCodeTask.setExStopTime(goblinNftExCodeTask.getExStopTime());
bolNotUn = true;
}
if (bolNotUn) {
goblinNftExCodeTaskHashMap.put(goblinNftExCodeTask.getSkuId(), nftExCodeTask);
}
}
} }
} }
break; break;
default: default:
...@@ -194,30 +167,11 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -194,30 +167,11 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
// redis 存储 // redis 存储
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum); goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
} }
}
GoblinNftExCodeTask nftExCodeTask = goblinNftExCodeTaskHashMap.get(goblinNftExCodeTask.getSkuId()); GoblinNftExCodeTask nftExCodeTask = goblinNftExCodeTaskHashMap.get(goblinNftExCodeTask.getSkuId());
if (nftExCodeTask == null) { if (nftExCodeTask == null) {
goblinNftExCodeTaskHashMap.put(goblinNftExCodeTask.getSkuId(), goblinNftExCodeTask); goblinNftExCodeTaskHashMap.put(goblinNftExCodeTask.getSkuId(), goblinNftExCodeTask);
} else {
GoblinNftExCodeTask nftExCodeTaskCurrent = goblinNftExCodeTaskHashMap.get(goblinNftExCodeTask.getSkuId());
LocalDateTime exStartTime = nftExCodeTaskCurrent.getExStartTime();
LocalDateTime exStopTime = nftExCodeTaskCurrent.getExStopTime();
boolean bolNotUn = false;
// 时间比较
if (goblinNftExCodeTask.getExStartTime().isBefore(exStartTime)) {
nftExCodeTaskCurrent.setExStartTime(goblinNftExCodeTask.getExStartTime());
bolNotUn = true;
}
if (goblinNftExCodeTask.getExStopTime().isAfter(exStopTime)) {
nftExCodeTaskCurrent.setExStopTime(goblinNftExCodeTask.getExStopTime());
bolNotUn = true;
}
if (bolNotUn) {
goblinNftExCodeTaskHashMap.put(goblinNftExCodeTask.getSkuId(), nftExCodeTaskCurrent);
}
}
} }
} }
...@@ -236,8 +190,8 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -236,8 +190,8 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
Boolean bolTime = false; Boolean bolTime = false;
if (!StringUtil.isEmpty(goblinNftExSkuVo)) { if (!StringUtil.isEmpty(goblinNftExSkuVo)) {
// redis存储 单个sku的开始和结束时间 // redis存储 单个sku的开始和结束时间
LocalDateTime rdExStartTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); // "2019-06-26 19:00:00"; LocalDateTime rdExStartTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime rdExStopTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStopTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); // "2019-06-26 19:00:00"; LocalDateTime rdExStopTime = LocalDateTime.parse(goblinNftExSkuVo.getRdStopTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 时间比对 // 时间比对
if (exStartTime.isBefore(rdExStartTime)) { if (exStartTime.isBefore(rdExStartTime)) {
...@@ -250,12 +204,16 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi ...@@ -250,12 +204,16 @@ public class GoblinNftExCodeTaskServiceImpl implements IGoblinNftExCodeTaskServi
goblinNftExSku.setRdStopTime(exStopTime.toString()); goblinNftExSku.setRdStopTime(exStopTime.toString());
bolTime = true; bolTime = true;
} }
}else { } else {
bolTime = true; bolTime = true;
goblinNftExSku.setExStartTime(exStartTime);
goblinNftExSku.setExStopTime(exStopTime);
goblinNftExSku.setRdStartTime(exStartTime.toString());
goblinNftExSku.setRdStopTime(exStopTime.toString());
} }
if (bolTime){ if (bolTime) {
goblinRedisUtils.addSkuTime(key, goblinNftExSku); goblinRedisUtils.addSkuTime(key, goblinNftExSku);
} }
} }
......
...@@ -249,7 +249,8 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -249,7 +249,8 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// sku ---> 库存 // sku ---> 库存
HashMap<String, Integer> stockMap = CollectionUtil.mapStringInteger(); HashMap<String, Integer> stockMap = CollectionUtil.mapStringInteger();
getStock(exStock, hitRatioCount, mapMap, stockMap,countStockNumber); ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
return stockMap; return stockMap;
} }
...@@ -261,19 +262,28 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -261,19 +262,28 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map<String, Map<String, Object>> mapMap = new HashMap<>(); Map<String, Map<String, Object>> mapMap = new HashMap<>();
Map<String, Object> objectMap = new HashMap<>(); Map<String, Object> objectMap = new HashMap<>();
objectMap.put("hitRatio", 20); objectMap.put("hitRatio", 30);
objectMap.put("stock", 3); objectMap.put("stock", 1000);
mapMap.put("1", objectMap); mapMap.put("1", objectMap);
Map<String, Object> objectMap1 = new HashMap<>(); Map<String, Object> objectMap1 = new HashMap<>();
objectMap1.put("hitRatio", 20); objectMap1.put("hitRatio", 30);
objectMap1.put("stock", 100); objectMap1.put("stock", 1000);
mapMap.put("2", objectMap1); mapMap.put("2", objectMap1);
Map<String, Object> objectMap2 = new HashMap<>(); Map<String, Object> objectMap2 = new HashMap<>();
objectMap2.put("hitRatio", 20); objectMap2.put("hitRatio", 30);
objectMap2.put("stock", 2); objectMap2.put("stock", 1000);
mapMap.put("3", objectMap2); mapMap.put("3", objectMap2);
Map<String, Object> objectMap3 = new HashMap<>();
objectMap3.put("hitRatio", 10);
objectMap3.put("stock", 1000);
mapMap.put("4", objectMap3);
Map<String, Integer> stockMap = new HashMap<>(); Map<String, Integer> stockMap = new HashMap<>();
getStock(20, new BigDecimal(60), mapMap, stockMap,15); ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(51, new BigDecimal(100), mapMap, stockMap, 1032, eliminateSkuIdList);
for (String key : stockMap.keySet()) { for (String key : stockMap.keySet()) {
System.out.println("skuId" + key + "***********数量" + stockMap.get(key)); System.out.println("skuId" + key + "***********数量" + stockMap.get(key));
} }
...@@ -288,7 +298,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -288,7 +298,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
* @param mapMap * @param mapMap
* @return * @return
*/ */
private static void getStock(Integer exStock, BigDecimal hitRatioCount, Map<String, Map<String, Object>> mapMap, Map<String, Integer> stockMap,Integer countStockNumber) { private static void getStock(Integer exStock, BigDecimal hitRatioCount, Map<String, Map<String, Object>> mapMap, Map<String, Integer> stockMap, Integer countStockNumber, ArrayList<String> eliminateSkuIdList) {
if (exStock <= 0 || countStockNumber == 0) { if (exStock <= 0 || countStockNumber == 0) {
return; return;
} }
...@@ -360,11 +370,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -360,11 +370,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
for (String key : mapMap.keySet()) { for (String key : mapMap.keySet()) {
Object hitRatio = mapMap.get(key).get("hitRatio"); Object hitRatio = mapMap.get(key).get("hitRatio");
Object stock = mapMap.get(key).get("stock"); Object stock = mapMap.get(key).get("stock");
if (Integer.valueOf(stock.toString()) <= 0) { if (Integer.valueOf(stock.toString()) <= 0 && !eliminateSkuIdList.contains(key)) {
eliminateSkuIdList.add(key);
hitRatioCount = hitRatioCount.subtract(new BigDecimal(hitRatio.toString())); hitRatioCount = hitRatioCount.subtract(new BigDecimal(hitRatio.toString()));
} }
} }
getStock(exStock, hitRatioCount, mapMap, stockMap,countStockNumber); getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
} }
} }
......
...@@ -8,6 +8,7 @@ import org.springframework.data.redis.connection.stream.StreamRecords; ...@@ -8,6 +8,7 @@ import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
@Component @Component
public class QueueUtils { public class QueueUtils {
...@@ -70,10 +71,8 @@ public class QueueUtils { ...@@ -70,10 +71,8 @@ public class QueueUtils {
* *
* @param * @param
*/ */
public void sendMssPhoneCodeRedis(String streamKey, String jsonMsg) { public void sendMssPhoneCodeRedis(Map<String,String> map) {
HashMap<String, String> map = CollectionUtil.mapStringString(); redisDataSourceUtil.getRedisGoblinUtil().getStringRedisTemplate().opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(MQConst.GoblinQueue.GOBLIN_PHONE_CODE_OPERA.getKey()));
map.put(MQConst.QUEUE_MESSAGE_KEY, jsonMsg);
redisDataSourceUtil.getRedisGoblinUtil().getStringRedisTemplate().opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey));
} }
} }
...@@ -3,4 +3,4 @@ goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at = ...@@ -3,4 +3,4 @@ goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at =
goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
# ------------------------????---------------------------- # ------------------------????----------------------------
kylin_camera_record.insert=INSERT INTO kylin_camera_record (camera_record_id, camera_id, person_num) VALUES (?,?,?) kylin_camera_record.insert=INSERT INTO kylin_camera_record (camera_record_id, camera_id, person_num) VALUES (?,?,?)
\ No newline at end of file
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