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

Commit 98ec262f authored by wanglele's avatar wanglele

兑换码sku--->时间

parent 33d5203e
...@@ -292,6 +292,11 @@ public class GoblinRedisConst { ...@@ -292,6 +292,11 @@ public class GoblinRedisConst {
*/ */
public static final String ACTIVITY_SKU_CODE = PREFIX.concat("activity:sku:code:"); public static final String ACTIVITY_SKU_CODE = PREFIX.concat("activity:sku:code:");
/**
* 兑换码sku时间
*/
public static final String ACTIVITY_SKU_TIME = PREFIX.concat("activity:sku:time");
/** /**
* 是否购买过技术数字藏品 * 是否购买过技术数字藏品
*/ */
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<where> <where>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
<bind name="likeTitle" value="'%' + title + '%'"/> <bind name="likeTitle" value="'%' + title + '%'"/>
and title like #{likeTitle,jdbcType=VARCHAR} and title like #{likeTitle}
</if> </if>
<if test="startTime != null"> <if test="startTime != null">
and created_at &gt; #{startTime,jdbcType=TIMESTAMP} and created_at &gt; #{startTime,jdbcType=TIMESTAMP}
......
...@@ -5,7 +5,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; ...@@ -5,7 +5,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExActivityVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftExActivityVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftSkuVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftSkuVo;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.param.GoblinNftExActivityParam; import com.liquidnet.service.goblin.param.GoblinNftExActivityParam;
import com.liquidnet.service.goblin.service.IGoblinNftExActivityService; import com.liquidnet.service.goblin.service.IGoblinNftExActivityService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -15,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
...@@ -39,14 +37,14 @@ public class GoblinNftExActivityController { ...@@ -39,14 +37,14 @@ public class GoblinNftExActivityController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "添加nft兑换活动") @ApiOperation(value = "添加nft兑换活动")
@PostMapping("add") @PostMapping("add")
public ResponseDto<String> add(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam){ public ResponseDto<String> add(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam) {
return ResponseDto.success(iGoblinNftExActivityService.add(goblinNftExActivityParam)); return ResponseDto.success(iGoblinNftExActivityService.add(goblinNftExActivityParam));
} }
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@ApiOperation(value = "活动列表") @ApiOperation(value = "活动列表")
@PostMapping("pageList") @PostMapping("pageList")
public ResponseDto<PageInfo<GoblinNftExActivityVo>> pageList(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam){ public ResponseDto<PageInfo<GoblinNftExActivityVo>> pageList(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam) {
return ResponseDto.success(iGoblinNftExActivityService.pageList(goblinNftExActivityParam)); return ResponseDto.success(iGoblinNftExActivityService.pageList(goblinNftExActivityParam));
} }
...@@ -54,16 +52,14 @@ public class GoblinNftExActivityController { ...@@ -54,16 +52,14 @@ public class GoblinNftExActivityController {
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation(value = "根据nft兑换活动获取绑定商品") @ApiOperation(value = "根据nft兑换活动获取绑定商品")
@PostMapping("selectNftSkuByActivityId/{activityId}") @PostMapping("selectNftSkuByActivityId/{activityId}")
public ResponseDto<List<GoblinNftSkuVo>> selectNftSkuByActivityId(@PathVariable("activityId")String activityId){ public ResponseDto<List<GoblinNftSkuVo>> selectNftSkuByActivityId(@PathVariable("activityId") String activityId) {
return ResponseDto.success(iGoblinNftExActivityService.selectNftSkuByActivityId(activityId)); return ResponseDto.success(iGoblinNftExActivityService.selectNftSkuByActivityId(activityId));
} }
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@ApiOperation(value = "excel导出") @ApiOperation(value = "excel导出")
@PostMapping("excel") @PostMapping("excel")
public void excel(HttpServletResponse httpServletResponse,@RequestBody GoblinNftExActivityParam goblinNftExActivityParam){ public void excel(HttpServletResponse httpServletResponse, @RequestBody GoblinNftExActivityParam goblinNftExActivityParam) {
iGoblinNftExActivityService.excel(httpServletResponse,goblinNftExActivityParam); iGoblinNftExActivityService.excel(httpServletResponse, goblinNftExActivityParam);
} }
} }
package com.liquidnet.service.platform.service.impl.goblin; package com.liquidnet.service.platform.service.impl.goblin;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.commons.lang.util.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil; import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo; import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExSkuVo;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku; import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import com.liquidnet.service.goblin.entity.GoblinNftExCode; import com.liquidnet.service.goblin.entity.GoblinNftExCode;
import com.liquidnet.service.goblin.entity.GoblinNftExSku; import com.liquidnet.service.goblin.entity.GoblinNftExSku;
...@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
/** /**
...@@ -87,6 +91,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -87,6 +91,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// 构建对象 // 构建对象
long startr = System.currentTimeMillis(); long startr = System.currentTimeMillis();
Map<String, GoblinNftExSkuParam> goblinNftExSkuParamMap = new HashMap<>();
for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) { for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) {
GoblinNftExSku goblinNftExSku = new GoblinNftExSku(); GoblinNftExSku goblinNftExSku = new GoblinNftExSku();
...@@ -132,7 +139,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -132,7 +139,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
goblinNftExCodeVo.setExStopTime(goblinNftExSkuParam.getExStopTime()); goblinNftExCodeVo.setExStopTime(goblinNftExSkuParam.getExStopTime());
goblinNftExCodeVo.setStoreId(goblinNftExSkuParam.getStoreId()); goblinNftExCodeVo.setStoreId(goblinNftExSkuParam.getStoreId());
goblinNftExCodeVo.setSpuId(goblinNftExSkuParam.getSpuId()); goblinNftExCodeVo.setSpuId(goblinNftExSkuParam.getSpuId());
// LocalDateTime exStartTime = goblinNftExSkuParam.getExStartTime(); // LocalDateTime exStartTime = goblinNftExSkuParam.getExStartTime();
LocalDateTime exStopTime = goblinNftExSkuParam.getExStopTime(); LocalDateTime exStopTime = goblinNftExSkuParam.getExStopTime();
...@@ -142,6 +149,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -142,6 +149,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// redis 存储 // redis 存储
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum); goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
} }
goblinNftExSkuParamMap.put(key, goblinNftExSkuParam);
} }
break; break;
...@@ -186,22 +196,81 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -186,22 +196,81 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum); goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
// goblinNftExCodeArrayList.add(GoblinNftExCodeVo.getNew().copy(goblinNftExCode)); // goblinNftExCodeArrayList.add(GoblinNftExCodeVo.getNew().copy(goblinNftExCode));
} }
GoblinNftExSkuParam value = goblinNftExSkuParamMap.get(goblinNftExSkuParam.getSkuId());
if (value == null) {
goblinNftExSkuParamMap.put(goblinNftExSkuParam.getSkuId(), goblinNftExSkuParam);
}
goblinNftExSkus.add(goblinNftExSku); goblinNftExSkus.add(goblinNftExSku);
// goblinNftExSkuArrayList.add(GoblinNftExSkuVo.getNew().copy(goblinNftExSku)); // goblinNftExSkuArrayList.add(GoblinNftExSkuVo.getNew().copy(goblinNftExSku));
} }
} }
log.debug("RDM耗时:ms" , System.currentTimeMillis() - startr);
for (String key : goblinNftExSkuParamMap.keySet()) {
Object object = goblinRedisUtils.getSkuTime(key);
GoblinNftExSkuParam goblinNftExSkuParam = goblinNftExSkuParamMap.get(key);
LocalDateTime exStartTime = goblinNftExSkuParam.getExStartTime(); // "2022-06-26 19:00:00";
LocalDateTime exStopTime = goblinNftExSkuParam.getExStopTime(); // "2024-06-26 19:00:00";
if (!StringUtil.isEmpty(object)) {
GoblinNftExSkuVo goblinNftExSkuVo = JSON.parseObject(object.toString(), GoblinNftExSkuVo.class);
// redis存储 单个sku的开始和结束时间
LocalDateTime rdExStartTime = goblinNftExSkuVo.getExStartTime(); // "2019-06-26 19:00:00";
LocalDateTime rdExStopTime = goblinNftExSkuVo.getExStopTime(); // "2023-06-26 19:00:00";
// 时间比对
if (!rdExStartTime.isAfter(exStartTime)) {
exStartTime = rdExStartTime;
}
if (rdExStopTime.isAfter(exStopTime)) {
exStopTime = rdExStopTime;
}
}
GoblinNftExSkuVo goblinNftExSkuVo = GoblinNftExSkuVo.getNew();
goblinNftExSkuVo.setExStartTime(exStartTime);
goblinNftExSkuVo.setExStopTime(exStopTime);
// goblinNftExSkus.addSkuTime(key);
}
log.debug("RDM耗时:ms", System.currentTimeMillis() - startr);
// 数据库操作 // 数据库操作
long startm = System.currentTimeMillis(); long startm = System.currentTimeMillis();
goblinNftExSkuMapper.addGoblinNftExSkus(goblinNftExSkus); goblinNftExSkuMapper.addGoblinNftExSkus(goblinNftExSkus);
goblinNftExCodeMapper.addGoblinNftExCodes(goblinNftExCodes); goblinNftExCodeMapper.addGoblinNftExCodes(goblinNftExCodes);
log.debug("MSQ耗时:ms" , System.currentTimeMillis() - startm); log.debug("MSQ耗时:ms", System.currentTimeMillis() - startm);
return true; return true;
} }
public static void main(String[] args) {
String time1 = "2019-06-26 19:00:00";
String time2 = "2022-06-26 19:00:00";
String time3 = "2023-06-26 19:00:00";
String time4 = "2024-06-26 19:00:00";
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime localDateTime = LocalDateTime.parse(time1, dtf2);
LocalDateTime localDateTime2 = LocalDateTime.parse(time2, dtf2);
LocalDateTime localDateTime3 = LocalDateTime.parse(time3, dtf2);
LocalDateTime localDateTime4 = LocalDateTime.parse(time4, dtf2);
System.out.println(localDateTime.isAfter(localDateTime2)); // 当time1小于当前时间是返回false
System.out.println(localDateTime3.isAfter(localDateTime4));
}
/** /**
* 获取每个sku的兑换码生成数量 * 获取每个sku的兑换码生成数量
* *
...@@ -245,5 +314,4 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -245,5 +314,4 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
} }
} }
...@@ -9,10 +9,7 @@ import com.liquidnet.service.base.constant.MQConst; ...@@ -9,10 +9,7 @@ import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinRedisConst; import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.GoblinQueueBizIntegralDto; import com.liquidnet.service.goblin.dto.GoblinQueueBizIntegralDto;
import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto; import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku; import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -233,6 +230,16 @@ public class GoblinRedisUtils { ...@@ -233,6 +230,16 @@ public class GoblinRedisUtils {
getRedis().del(code); getRedis().del(code);
} }
/**
* 获取sku时间
* @param skuId
* @return
*/
public Object getSkuTime(String skuId) {
String key = GoblinRedisConst.ACTIVITY_SKU_TIME.concat(skuId);
return getRedis().get(key);
}
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
......
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