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

Commit 98ec262f authored by wanglele's avatar wanglele

兑换码sku--->时间

parent 33d5203e
......@@ -292,6 +292,11 @@ public class GoblinRedisConst {
*/
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 @@
<where>
<if test="title != null and title != ''">
<bind name="likeTitle" value="'%' + title + '%'"/>
and title like #{likeTitle,jdbcType=VARCHAR}
and title like #{likeTitle}
</if>
<if test="startTime != null">
and created_at &gt; #{startTime,jdbcType=TIMESTAMP}
......
......@@ -5,7 +5,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExActivityVo;
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.service.IGoblinNftExActivityService;
import io.swagger.annotations.Api;
......@@ -15,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
......@@ -39,14 +37,14 @@ public class GoblinNftExActivityController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "添加nft兑换活动")
@PostMapping("add")
public ResponseDto<String> add(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam){
public ResponseDto<String> add(@Valid @RequestBody GoblinNftExActivityParam goblinNftExActivityParam) {
return ResponseDto.success(iGoblinNftExActivityService.add(goblinNftExActivityParam));
}
@ApiOperationSupport(order = 2)
@ApiOperation(value = "活动列表")
@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));
}
......@@ -54,16 +52,14 @@ public class GoblinNftExActivityController {
@ApiOperationSupport(order = 3)
@ApiOperation(value = "根据nft兑换活动获取绑定商品")
@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));
}
@ApiOperationSupport(order = 4)
@ApiOperation(value = "excel导出")
@PostMapping("excel")
public void excel(HttpServletResponse httpServletResponse,@RequestBody GoblinNftExActivityParam goblinNftExActivityParam){
iGoblinNftExActivityService.excel(httpServletResponse,goblinNftExActivityParam);
public void excel(HttpServletResponse httpServletResponse, @RequestBody GoblinNftExActivityParam goblinNftExActivityParam) {
iGoblinNftExActivityService.excel(httpServletResponse, goblinNftExActivityParam);
}
}
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.StringUtil;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
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.GoblinNftExCode;
import com.liquidnet.service.goblin.entity.GoblinNftExSku;
......@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
......@@ -87,6 +91,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// 构建对象
long startr = System.currentTimeMillis();
Map<String, GoblinNftExSkuParam> goblinNftExSkuParamMap = new HashMap<>();
for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) {
GoblinNftExSku goblinNftExSku = new GoblinNftExSku();
......@@ -142,6 +149,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// redis 存储
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
}
goblinNftExSkuParamMap.put(key, goblinNftExSkuParam);
}
break;
......@@ -186,22 +196,81 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
// goblinNftExCodeArrayList.add(GoblinNftExCodeVo.getNew().copy(goblinNftExCode));
}
GoblinNftExSkuParam value = goblinNftExSkuParamMap.get(goblinNftExSkuParam.getSkuId());
if (value == null) {
goblinNftExSkuParamMap.put(goblinNftExSkuParam.getSkuId(), goblinNftExSkuParam);
}
goblinNftExSkus.add(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();
goblinNftExSkuMapper.addGoblinNftExSkus(goblinNftExSkus);
goblinNftExCodeMapper.addGoblinNftExCodes(goblinNftExCodes);
log.debug("MSQ耗时:ms" , System.currentTimeMillis() - startm);
log.debug("MSQ耗时:ms", System.currentTimeMillis() - startm);
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的兑换码生成数量
*
......@@ -245,5 +314,4 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
}
}
......@@ -9,10 +9,7 @@ import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.GoblinQueueBizIntegralDto;
import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
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.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -233,6 +230,16 @@ public class GoblinRedisUtils {
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