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

Commit 68332867 authored by wanglele's avatar wanglele

兑换码相关

parent f33a0d5d
...@@ -297,6 +297,13 @@ public class GoblinRedisConst { ...@@ -297,6 +297,13 @@ public class GoblinRedisConst {
/**
* 活动兑换码
*/
public static final String ACTIVITY_SKU_CODE = PREFIX.concat("activity:sku:code:");
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
} }
...@@ -78,6 +78,9 @@ public class GoblinNftExActivityVo implements Serializable,Cloneable { ...@@ -78,6 +78,9 @@ public class GoblinNftExActivityVo implements Serializable,Cloneable {
this.setTitle(goblinNftExActivity.getTitle()); this.setTitle(goblinNftExActivity.getTitle());
this.setCreatedAt(goblinNftExActivity.getCreatedAt()); this.setCreatedAt(goblinNftExActivity.getCreatedAt());
this.setUpdatedAt(goblinNftExActivity.getUpdatedAt()); this.setUpdatedAt(goblinNftExActivity.getUpdatedAt());
this.setCountNumber(goblinNftExActivity.getCountNumber());
this.setUseNumber(goblinNftExActivity.getUseNumber());
this.setUnUseNumber(goblinNftExActivity.getUnUseNumber());
return this; return this;
} }
......
...@@ -113,6 +113,15 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable { ...@@ -113,6 +113,15 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable {
*/ */
private LocalDateTime exStopTime; private LocalDateTime exStopTime;
/**
* sku名称
*/
private String skuName;
private static final GoblinNftExCodeVo obj = new GoblinNftExCodeVo(); private static final GoblinNftExCodeVo obj = new GoblinNftExCodeVo();
......
...@@ -41,6 +41,16 @@ public class GoblinNftExSkuVo { ...@@ -41,6 +41,16 @@ public class GoblinNftExSkuVo {
*/ */
private String skuId; private String skuId;
/**
* 是否盲盒 0:否 1:是
*/
private String unBox;
/**
* 店铺id
*/
private String storeId;
/** /**
* 兑换库存 * 兑换库存
...@@ -91,6 +101,8 @@ public class GoblinNftExSkuVo { ...@@ -91,6 +101,8 @@ public class GoblinNftExSkuVo {
this.setActivityId(goblinNftExSku.getActivityId()); this.setActivityId(goblinNftExSku.getActivityId());
this.setSpuId(goblinNftExSku.getSpuId()); this.setSpuId(goblinNftExSku.getSpuId());
this.setSkuId(goblinNftExSku.getSkuId()); this.setSkuId(goblinNftExSku.getSkuId());
this.setUnBox(goblinNftExSku.getUnBox());
this.setStoreId(goblinNftExSku.getStoreId());
this.setExStock(goblinNftExSku.getExStock()); this.setExStock(goblinNftExSku.getExStock());
this.setExLimit(goblinNftExSku.getExLimit()); this.setExLimit(goblinNftExSku.getExLimit());
this.setExStartTime(goblinNftExSku.getExStartTime()); this.setExStartTime(goblinNftExSku.getExStartTime());
......
...@@ -29,6 +29,9 @@ public class GoblinNftExSkuParam { ...@@ -29,6 +29,9 @@ public class GoblinNftExSkuParam {
@NotBlank(message = "款式id不可为空") @NotBlank(message = "款式id不可为空")
private String skuId; private String skuId;
@ApiModelProperty(position = 13,required = true,value = "是否盲盒 0:否 1:是")
private String unbox;
@ApiModelProperty(position = 13,required = true,value = "兑换库存数量") @ApiModelProperty(position = 13,required = true,value = "兑换库存数量")
@NotBlank(message = "兑换库存数量不可为空") @NotBlank(message = "兑换库存数量不可为空")
private Integer exStock; private Integer exStock;
......
package com.liquidnet.service.goblin.service; package com.liquidnet.service.goblin.service;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExActivityVo;
import com.liquidnet.service.goblin.param.GoblinNftExActivityParam; import com.liquidnet.service.goblin.param.GoblinNftExActivityParam;
public interface IGoblinNftExActivityService { public interface IGoblinNftExActivityService {
...@@ -16,5 +18,5 @@ public interface IGoblinNftExActivityService { ...@@ -16,5 +18,5 @@ public interface IGoblinNftExActivityService {
* @param goblinNftExActivityParam * @param goblinNftExActivityParam
* @return * @return
*/ */
Object pageList(GoblinNftExActivityParam goblinNftExActivityParam); PageInfo<GoblinNftExActivityVo> pageList(GoblinNftExActivityParam goblinNftExActivityParam);
} }
package com.liquidnet.service.goblin.service; package com.liquidnet.service.goblin.service;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.param.GoblinNftExCodeParam; import com.liquidnet.service.goblin.param.GoblinNftExCodeParam;
public interface IGoblinNftExCodeService { public interface IGoblinNftExCodeService {
...@@ -7,7 +9,12 @@ public interface IGoblinNftExCodeService { ...@@ -7,7 +9,12 @@ public interface IGoblinNftExCodeService {
/** /**
* 获取兑换码 * 获取兑换码
*/ */
Object selectCodePageList(GoblinNftExCodeParam goblinNftExCodeParam); PageInfo<GoblinNftExCodeVo> selectCodePageList(GoblinNftExCodeParam goblinNftExCodeParam);
/**
* 兑换码主动失效
* @param codeIds
* @return
*/
Boolean defDrivLoseCode(String codeIds);
} }
...@@ -149,4 +149,38 @@ public class IDGenerator { ...@@ -149,4 +149,38 @@ public class IDGenerator {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(getWriteOffCode()); System.out.println(getWriteOffCode());
} }
/**
* 获取兑换码
* @param num 次数
* @param sec 单次巡管
* @param bol 是否添加特殊字符
* @return
*/
public static String createCode(int num,int sec,boolean bol) {
//
StringBuffer str = new StringBuffer();
for (int k=0;k<num;k++) {
for(int i=0;i < sec;i++){
int intVal=(int)(Math.random()*58+65);
System.out.println(intVal);
if(intVal >= 91 && intVal <= 122){
i--;
}
if(intVal < 91 || intVal > 122){
if(intVal%2==0){
str.append((char)intVal);
}else{
str.append((int)(Math.random()*10));
}
}
}
if(bol){
str.append("-");
}
}
return str.toString()+"CH";
}
} }
...@@ -47,6 +47,11 @@ public class GoblinNftExCode implements Serializable, Cloneable { ...@@ -47,6 +47,11 @@ public class GoblinNftExCode implements Serializable, Cloneable {
*/ */
private String skuId; private String skuId;
/**
* 盲盒款式id
*/
private String boxSkuId;
/** /**
* 兑换码状态 1 未兑换 2 已兑换 * 兑换码状态 1 未兑换 2 已兑换
...@@ -88,7 +93,6 @@ public class GoblinNftExCode implements Serializable, Cloneable { ...@@ -88,7 +93,6 @@ public class GoblinNftExCode implements Serializable, Cloneable {
private Integer isDrivi; private Integer isDrivi;
private String sktName; private String sktName;
private static final GoblinNftExCode obj = new GoblinNftExCode(); private static final GoblinNftExCode obj = new GoblinNftExCode();
public static GoblinNftExCode getNew() { public static GoblinNftExCode getNew() {
......
...@@ -40,6 +40,11 @@ public class GoblinNftExSku { ...@@ -40,6 +40,11 @@ public class GoblinNftExSku {
*/ */
private String skuId; private String skuId;
/**
* 是否盲盒 0:否 1:是
*/
private String unBox;
/** /**
* 兑换库存 * 兑换库存
...@@ -51,6 +56,10 @@ public class GoblinNftExSku { ...@@ -51,6 +56,10 @@ public class GoblinNftExSku {
*/ */
private Integer exLimit; private Integer exLimit;
/**
* 店铺id
*/
private String storeId;
/** /**
* 兑换生效开始时间 * 兑换生效开始时间
......
...@@ -32,4 +32,11 @@ public interface GoblinGoodsSkuMapper extends BaseMapper<GoblinGoodsSku> { ...@@ -32,4 +32,11 @@ public interface GoblinGoodsSkuMapper extends BaseMapper<GoblinGoodsSku> {
* @return * @return
*/ */
List<GoblinGoodsSku> selectByIds(@Param("skuIds") String skuIds); List<GoblinGoodsSku> selectByIds(@Param("skuIds") String skuIds);
/**
* 根据spuIds获取spu下的sku
* @param spuIds
* @return
*/
List<GoblinGoodsSku> selectBySpuIds(@Param("spuIds") String spuIds);
} }
...@@ -40,4 +40,18 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> { ...@@ -40,4 +40,18 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> {
* @return * @return
*/ */
List<GoblinNftExCode> selectGoblinNftCode(GoblinNftExCode goblinNftExCode); List<GoblinNftExCode> selectGoblinNftCode(GoblinNftExCode goblinNftExCode);
/**
* 根据codeIds 获取
* @param codeIds
* @return
*/
List<GoblinNftExCode> selectByIds(@Param("codeIds") String codeIds);
/**
* 批量修改
* @param goblinNftExCodes
* @return
*/
int updateCodes(@Param("goblinNftExCodes") List<GoblinNftExCode> goblinNftExCodes);
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper">
<resultMap id="BaseResult" type="com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo"> <resultMap id="BaseResult" type="com.liquidnet.service.goblin.entity.GoblinGoodsSku">
<result column="sku_id" property="skuId"/> <result column="sku_id" property="skuId" jdbcType="VARCHAR"/>
<result column="name" property="name"/> <result column="name" property="name" jdbcType="VARCHAR"/>
<result column="hit_ratio" property="hitRatio" jdbcType="DECIMAL"/>
</resultMap> </resultMap>
<select id="selectSkuLikeName" resultMap="BaseResult"> <select id="selectSkuLikeName" resultMap="BaseResult">
...@@ -17,7 +18,16 @@ ...@@ -17,7 +18,16 @@
select sku_id,name from goblin_goods_sku where select sku_id,name from goblin_goods_sku where
sku_id in sku_id in
<foreach collection="skuIds" item="skuId" open="(" separator="," close=")"> <foreach collection="skuIds" item="skuId" open="(" separator="," close=")">
#{skuId} #{skuId,jdbcType=VARCHAR}
</foreach> </foreach>
</select> </select>
<select id="selectBySpuIds" resultMap="BaseResult">
select sku_id,hit_ratio from goblin_goods_sku where
spu_id in
<foreach collection="spuIds.split(',')" item="spuId" open="(" separator="," close=")">
#{spuId,jdbcType=VARCHAR}
</foreach>
</select>
</mapper> </mapper>
...@@ -2,56 +2,51 @@ ...@@ -2,56 +2,51 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExActivityMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExActivityMapper">
<resultMap id="BaseResult" type="com.liquidnet.service.goblin.dto.vo.GoblinNftExActivity"> <resultMap id="BaseResult" type="com.liquidnet.service.goblin.entity.GoblinNftExActivity">
<result column="activity_id" property="activityId"/> <result column="activity_id" property="activityId" jdbcType="VARCHAR"/>
<result column="title" property="title"/> <result column="title" property="title" jdbcType="VARCHAR"/>
<result column="created_at" property="createdAt"/> <result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
<result column="updated_at" property="updatedAt"/> <result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id="selectPageList" resultType="BaseResult"> <select id="selectPageList" resultMap="BaseResult">
select activity_id,title,created_at from goblin_nft_ex_activity select activity_id,title,created_at from goblin_nft_ex_activity
<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} and title like #{likeTitle,jdbcType=VARCHAR}
</if> </if>
<if test="startTime != null"> <if test="startTime != null">
and created_at &gt; ${startTime} and created_at &gt; #{startTime,jdbcType=TIMESTAMP}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
and created_at &lt; ${endTime} and created_at &lt; #{endTime,jdbcType=TIMESTAMP}
</if> </if>
</where> </where>
</select> </select>
<insert id="addGoblinNftExActivity" parameterType="com.liquidnet.service.goblin.dto.vo.GoblinNftExActivity"> <insert id="addGoblinNftExActivity" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExActivity">
insert into goblin_nft_ex_activity insert into goblin_nft_ex_activity
( (
<if test="activityId != null and activityId != null"> <if test="activityId != null and activityId != null">
activity_id, activity_id,
</if> </if>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
title, title,
</if> </if>
<if test="createdAt != null"> <if test="createdAt != null">
created_at, created_at
</if> </if>
<if test="updatedAt != null">
updated_at
</if>
) values( ) values(
<if test="activityId != null and activityId != null"> <if test="activityId != null and activityId != null">
#{activityId}, #{activityId,jdbcType=VARCHAR},
</if> </if>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
#{title}, #{title,jdbcType=VARCHAR},
</if> </if>
<if test="createdAt != null"> <if test="createdAt != null">
#{createdAt}, #{createdAt,jdbcType=TIMESTAMP}
</if> </if>
<if test="updatedAt != null"> )
#{updatedAt}
</if>)
</insert> </insert>
</mapper> </mapper>
...@@ -2,19 +2,28 @@ ...@@ -2,19 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper">
<resultMap id="BeseResult" type="com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo"> <resultMap id="BeseResult" type="com.liquidnet.service.goblin.entity.GoblinNftExCode">
<result column="code_id" property="codeId"/> <result column="code_id" property="codeId" jdbcType="VARCHAR"/>
<result column="activity_id" property="activityId"/> <result column="activity_id" property="activityId" jdbcType="VARCHAR"/>
<result column="code" property="code"/> <result column="code" property="code" jdbcType="VARCHAR"/>
<result column="sku_id" property="skuId"/> <result column="sku_id" property="skuId" jdbcType="VARCHAR"/>
<result column="state" property="state"/> <result column="box_sku_id" property="boxSkuId" jdbcType="VARCHAR"/>
<result column="redeem_uid" property="redeemUid"/> <result column="state" property="state" jdbcType="INTEGER" />
<result column="redeem_at" property="redeemAt"/> <result column="redeem_uid" property="redeemUid" jdbcType="VARCHAR"/>
<result column="admin_uid" property="adminUid"/> <result column="redeem_at" property="redeemAt" jdbcType="TIMESTAMP"/>
<result column="created_at" property="createdAt"/> <result column="admin_uid" property="adminUid" jdbcType="VARCHAR"/>
<result column="updated_at" property="updatedAt"/> <result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id="selectByIds" resultMap="BeseResult">
select code_id,activity_id,state from goblin_nft_ex_code
where code_id in
<foreach collection="codeIds.split(',')" item="codeId" open="(" separator="," close=")">
#{codeId,jdbcType=VARCHAR}
</foreach>
</select>
<insert id="addGoblinNftExCodes"> <insert id="addGoblinNftExCodes">
insert into goblin_nft_ex_code (code_id,activity_id,code,sku_id,state,created_at) insert into goblin_nft_ex_code (code_id,activity_id,code,sku_id,state,created_at)
values values
...@@ -30,26 +39,36 @@ ...@@ -30,26 +39,36 @@
</foreach> </foreach>
</insert> </insert>
<select id="selectGoblinNftCode" parameterType="com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo" <update id="updateCodes">
<foreach collection="goblinNftExCodes" item="goblinNftExCode" open="" close="" separator=";" >
update goblin_nft_ex_code
<set>
state = #{goblinNftExCode.state} and updated_at = #{goblinNftExCode.updatedAt}
</set>
where code_id = #{goblinNftExCode.codeId}
</foreach>
</update>
<select id="selectGoblinNftCode" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultMap="BeseResult"> resultMap="BeseResult">
select code_id,code,sku_id from goblin_nft_ex_code select code_id,code,sku_id from goblin_nft_ex_code
<where> <where>
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and code = #{code} and code = #{code,jdbcType=VARCHAR}
</if> </if>
<if test="activityId != null and activityId != null"> <if test="activityId != null and activityId != null">
and activity_id = #{activityId} and activity_id = #{activityId,jdbcType=VARCHAR}
</if> </if>
<if test="state != null"> <if test="state != null">
and state = #{state} and state = #{state,jdbcType=INTEGER}
</if> </if>
<if test="redeemUid != null and redeemUid != ''"> <if test="redeemUid != null and redeemUid != ''">
and redeem_uid = #{redeemUid} and redeem_uid = #{redeemUid,jdbcType=VARCHAR}
</if> </if>
<if test="skuId != null and skuId != ''"> <if test="skuId != null and skuId != ''">
and sku_id in and sku_id in
<foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")"> <foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")">
#{sId} #{sId,jdbcType=VARCHAR}
</foreach> </foreach>
</if> </if>
<if test="isDrivi != null"> <if test="isDrivi != null">
...@@ -68,8 +87,8 @@ ...@@ -68,8 +87,8 @@
<select id="selectByActivityIds" resultMap="BeseResult"> <select id="selectByActivityIds" resultMap="BeseResult">
select code_id,activity_id,state from goblin_nft_ex_code where select code_id,activity_id,state from goblin_nft_ex_code where
activity_id in activity_id in
<foreach collection="activityIds" item="activityId" open="(" close=")" separator=","> <foreach collection="activityIds.split(',')" item="activityId" open="(" close=")" separator=",">
#{activityId} #{activityId,jdbcType=VARCHAR}
</foreach> </foreach>
</select> </select>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper">
<resultMap id="BaseResult" type=""> <resultMap id="BaseResult" type="com.liquidnet.service.goblin.entity.GoblinNftExSku">
<result column="activity_id" property="activityId"/> <result column="activity_id" property="activityId" jdbcType="VARCHAR"/>
<result column="sku_id" property="skuId"/> <result column="sku_id" property="skuId" jdbcType="VARCHAR"/>
<result column="ex_start_time" property="exStartTime"/> <result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="ex_stop_time" property="exStopTime"/> <result column="unbox" property="unbox" jdbcType="VARCHAR"/>
<result column="ex_stock" property="exStock" jdbcType="INTEGER"/>
<result column="ex_limit" property="exLimit" jdbcType="INTEGER"/>
<result column="ex_start_time" property="exStartTime" jdbcType="TIMESTAMP"/>
<result column="ex_stop_time" property="exStopTime" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id=""> <select id="selectGoblinNftExSkuByActivityIds" resultMap="BaseResult">
select activity_id,sku_id,unbox,store_id,ex_start_time,ex_stop_time from goblin_nft_ex_sku where
activity_id in
<foreach collection="activityIds.split(',')" item="activityId" open="(" separator="," close=")" >
#{activityId,jdbcType=VARCHAR}
</foreach>
</select> </select>
</mapper> </mapper>
package com.liquidnet.service.platform.controller.goblin.activity; package com.liquidnet.service.platform.controller.goblin.activity;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.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;
...@@ -35,14 +37,14 @@ public class GoblinNftExActivityController { ...@@ -35,14 +37,14 @@ public class GoblinNftExActivityController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "添加nft兑换活动") @ApiOperation(value = "添加nft兑换活动")
@PostMapping("add") @PostMapping("add")
public ResponseDto<Object> 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<Object> 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));
} }
......
package com.liquidnet.service.platform.controller.goblin.code; package com.liquidnet.service.platform.controller.goblin.code;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.param.GoblinNftExCodeParam; import com.liquidnet.service.goblin.param.GoblinNftExCodeParam;
import com.liquidnet.service.goblin.service.IGoblinNftExCodeService; import com.liquidnet.service.goblin.service.IGoblinNftExCodeService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -9,10 +11,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -9,10 +11,7 @@ import io.swagger.annotations.ApiOperation;
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.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @Author: wll * @Author: wll
...@@ -33,10 +32,18 @@ public class GoblinNftExCodeController { ...@@ -33,10 +32,18 @@ public class GoblinNftExCodeController {
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "根据nft兑换活动获取兑换码") @ApiOperation(value = "根据nft兑换活动获取兑换码")
@PostMapping("selectCodePageList") @PostMapping("selectCodePageList")
public ResponseDto<Object> selectCodePageList(@RequestBody GoblinNftExCodeParam goblinNftExCodeParam){ public ResponseDto<PageInfo<GoblinNftExCodeVo>> selectCodePageList(@RequestBody GoblinNftExCodeParam goblinNftExCodeParam){
return ResponseDto.success(iGoblinNftExCodeService.selectCodePageList(goblinNftExCodeParam)); return ResponseDto.success(iGoblinNftExCodeService.selectCodePageList(goblinNftExCodeParam));
} }
@ApiOperationSupport(order = 1)
@ApiOperation(value = "兑换码主动失效")
@PostMapping("defDrivLoseCodes/{codeIds}")
public ResponseDto<Boolean> defDrivLoseCode(@PathVariable("codeIds")String codeIds){
return ResponseDto.success(iGoblinNftExCodeService.defDrivLoseCode(codeIds));
}
......
...@@ -12,12 +12,14 @@ import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper; ...@@ -12,12 +12,14 @@ import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper;
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 com.liquidnet.service.platform.utils.GoblinRedisUtils; import com.liquidnet.service.platform.utils.GoblinRedisUtils;
import com.liquidnet.service.platform.utils.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -51,7 +53,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ ...@@ -51,7 +53,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ
} }
@Override @Override
public Object pageList(GoblinNftExActivityParam goblinNftExActivityParam) { public PageInfo<GoblinNftExActivityVo> pageList(GoblinNftExActivityParam goblinNftExActivityParam) {
PageHelper.startPage(goblinNftExActivityParam.getPageNum(),20,true); PageHelper.startPage(goblinNftExActivityParam.getPageNum(),20,true);
...@@ -69,6 +71,8 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ ...@@ -69,6 +71,8 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ
activityIds.append(GoblinNftExActivity.getActivityId()).append(","); activityIds.append(GoblinNftExActivity.getActivityId()).append(",");
} }
ArrayList<GoblinNftExActivityVo> goblinNftExActivityArrayList = ObjectUtil.getGoblinNftExActivityArrayList();
if (StringUtil.isNotBlank(activityIds)){ if (StringUtil.isNotBlank(activityIds)){
activityIds.deleteCharAt(activityIds.length()-1); activityIds.deleteCharAt(activityIds.length()-1);
...@@ -96,10 +100,11 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ ...@@ -96,10 +100,11 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServ
goblinNftExActivity.setCountNumber(countNumber); goblinNftExActivity.setCountNumber(countNumber);
goblinNftExActivity.setUseNumber(useNumber); goblinNftExActivity.setUseNumber(useNumber);
goblinNftExActivity.setUnUseNumber(unUseNumber); goblinNftExActivity.setUnUseNumber(unUseNumber);
goblinNftExActivityArrayList.add(GoblinNftExActivityVo.getNew().copy(goblinNftExActivity));
} }
} }
PageInfo<GoblinNftExActivity> pageInfo = new PageInfo<GoblinNftExActivity>(goblinNftExActivities); PageInfo<GoblinNftExActivityVo> pageInfo = new PageInfo<>(goblinNftExActivityArrayList);
return pageInfo; return pageInfo;
} }
} }
...@@ -3,18 +3,27 @@ package com.liquidnet.service.platform.service.impl.goblin; ...@@ -3,18 +3,27 @@ package com.liquidnet.service.platform.service.impl.goblin;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.StringUtil; import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo;
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.mapper.GoblinGoodsSkuMapper; import com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper; import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper; import com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper;
import com.liquidnet.service.goblin.param.GoblinNftExCodeParam; import com.liquidnet.service.goblin.param.GoblinNftExCodeParam;
import com.liquidnet.service.goblin.service.IGoblinNftExCodeService; import com.liquidnet.service.goblin.service.IGoblinNftExCodeService;
import com.liquidnet.service.platform.utils.GoblinRedisUtils;
import com.liquidnet.service.platform.utils.ObjectUtil;
import com.sun.org.apache.xpath.internal.operations.Bool;
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.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author: wll * @Author: wll
...@@ -31,9 +40,11 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -31,9 +40,11 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
private GoblinNftExCodeMapper goblinNftExCodeMapper; private GoblinNftExCodeMapper goblinNftExCodeMapper;
@Autowired @Autowired
private GoblinNftExSkuMapper goblinNftExSkuMapper; private GoblinNftExSkuMapper goblinNftExSkuMapper;
@Autowired
private GoblinRedisUtils goblinRedisUtils;
@Override @Override
public Object selectCodePageList(GoblinNftExCodeParam goblinNftExCodeParam) { public PageInfo<GoblinNftExCodeVo> selectCodePageList(GoblinNftExCodeParam goblinNftExCodeParam) {
// 入参 // 入参
GoblinNftExCode goblinNftExCode = GoblinNftExCode.getNew(); GoblinNftExCode goblinNftExCode = GoblinNftExCode.getNew();
...@@ -47,7 +58,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -47,7 +58,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
String skuName = goblinNftExCodeParam.getSkuName(); String skuName = goblinNftExCodeParam.getSkuName();
List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectSkuLikeName(skuName); List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectSkuLikeName(skuName);
if (goblinGoodsSkus.size() <= 0){ if (goblinGoodsSkus.size() <= 0){
return new PageHelper(); return new PageInfo<>();
} }
StringBuffer skuIds = new StringBuffer(); StringBuffer skuIds = new StringBuffer();
for (GoblinGoodsSku goblinGoodsSku:goblinGoodsSkus) { for (GoblinGoodsSku goblinGoodsSku:goblinGoodsSkus) {
...@@ -70,23 +81,72 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -70,23 +81,72 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
List<GoblinGoodsSku> goblinNftExCodeList = goblinGoodsSkuMapper.selectByIds(skuIds.toString()); List<GoblinGoodsSku> goblinNftExCodeList = goblinGoodsSkuMapper.selectByIds(skuIds.toString());
// 获取对象实例
ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList();
for (GoblinNftExCode gnc: goblinNftExCodes) { for (GoblinNftExCode gnc: goblinNftExCodes) {
for (GoblinGoodsSku goblinGoodsSku: goblinNftExCodeList) { for (GoblinGoodsSku goblinGoodsSku: goblinNftExCodeList) {
if (gnc.getSkuId().equals(goblinGoodsSku.getSkuId())){ if (gnc.getSkuId().equals(goblinGoodsSku.getSkuId())){
gnc.setSktName(goblinGoodsSku.getName()); GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc);
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName());
goblinNftExCodeArrayList.add(goblinNftExCodeVo);
break; break;
} }
} }
} }
// 根据活动ids 获取兑换活动和sku的关联 // 根据活动ids 获取兑换活动和sku的关联
List<GoblinNftExSku> goblinNftExSkus = goblinNftExSkuMapper.selectGoblinNftExSkuByActivityIds(acticityIds.toString());
Map<String,List<GoblinNftExSku>> map = new HashMap<>();
for (GoblinNftExSku goblinNftExSku: goblinNftExSkus) {
if (map.get(goblinNftExSku.getActivityId()) == null){
map.put(goblinNftExSku.getActivityId(),new ArrayList<>());
}
map.get(goblinNftExSku.getActivityId()).add(goblinNftExSku);
}
for (GoblinNftExCodeVo gnc: goblinNftExCodeArrayList) {
List<GoblinNftExSku> goblinNftExSkuList = map.get(gnc.getActivityId());
for (GoblinNftExSku goblinNftExSku: goblinNftExSkuList) {
if (gnc.getSkuId().equals(goblinNftExSku.getSkuId())){
gnc.setExStartTime(goblinNftExSku.getExStartTime());
gnc.setExStopTime(goblinNftExSku.getExStopTime());
break;
}
}
}
PageInfo<GoblinNftExCode> pageInfo = new PageInfo<>(goblinNftExCodes);
return null; PageInfo<GoblinNftExCodeVo> pageInfo = new PageInfo<>(goblinNftExCodeArrayList);
return pageInfo;
} }
@Override
public Boolean defDrivLoseCode(String codeIds) {
LocalDateTime now = LocalDateTime.now();
// 获取兑换码
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectByIds(codeIds);
List<String> codes = new ArrayList<>();
for (GoblinNftExCode goblinNftExCode: goblinNftExCodes) {
// redis 主动失效
codes.add(goblinNftExCode.getCode());
goblinNftExCode.setState(3);
goblinNftExCode.setUpdatedAt(now);
}
goblinRedisUtils.removeCodes(codes);
// 批量修改
goblinNftExCodeMapper.updateCodes(goblinNftExCodes);
return true;
}
} }
...@@ -2,26 +2,26 @@ package com.liquidnet.service.platform.service.impl.goblin; ...@@ -2,26 +2,26 @@ package com.liquidnet.service.platform.service.impl.goblin;
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.GoblinNftExActivityVo;
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.GoblinNftExCode; import com.liquidnet.service.goblin.entity.GoblinNftExCode;
import com.liquidnet.service.goblin.entity.GoblinNftExSku; import com.liquidnet.service.goblin.entity.GoblinNftExSku;
import com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper; import com.liquidnet.service.goblin.mapper.GoblinNftExCodeMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper; import com.liquidnet.service.goblin.mapper.GoblinNftExSkuMapper;
import com.liquidnet.service.goblin.param.GoblinNftExSkuParam; import com.liquidnet.service.goblin.param.GoblinNftExSkuParam;
import com.liquidnet.service.goblin.service.IGoblinNftExSkuService; import com.liquidnet.service.goblin.service.IGoblinNftExSkuService;
import com.liquidnet.service.platform.utils.GoblinRedisUtils; import com.liquidnet.service.platform.utils.GoblinRedisUtils;
import com.liquidnet.service.platform.utils.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* @Author: wll * @Author: wll
...@@ -39,6 +39,8 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -39,6 +39,8 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
private GoblinNftExSkuMapper goblinNftExSkuMapper; private GoblinNftExSkuMapper goblinNftExSkuMapper;
@Autowired @Autowired
private GoblinRedisUtils goblinRedisUtils; private GoblinRedisUtils goblinRedisUtils;
@Autowired
private GoblinGoodsSkuMapper goblinGoodsSkuMapper;
@Transactional @Transactional
...@@ -50,75 +52,150 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -50,75 +52,150 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
/* ArrayList<GoblinNftExSkuVo> goblinNftExSkuArrayList = ObjectUtil.getGoblinNftExSkuArrayList(); /* ArrayList<GoblinNftExSkuVo> goblinNftExSkuArrayList = ObjectUtil.getGoblinNftExSkuArrayList();
ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList();*/ ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList();*/
Boolean bol = false;
String spuId = "";
for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) {
if (goblinNftExSkuParam.getUnbox().equals("1")) {
bol = true;
spuId = goblinNftExSkuParam.getSpuId();
break;
}
}
Map<String, BigDecimal> map = new HashMap<>();
if (bol) {
// 获取spu下所有sku
List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySpuIds(spuId);
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (goblinGoodsSku.getUnbox().equals("1")) {
continue;
}
map.put(goblinGoodsSku.getSkuId(), goblinGoodsSku.getHitRatio());
}
}
List<GoblinNftExSku> goblinNftExSkus = new ArrayList<>(); List<GoblinNftExSku> goblinNftExSkus = new ArrayList<>();
List<GoblinNftExCode> goblinNftExCodes = new ArrayList<>(); List<GoblinNftExCode> goblinNftExCodes = new ArrayList<>();
String activityId = "";
// 构建对象 // 构建对象
for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) { for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) {
if (StringUtil.isBlank(activityId)) {
activityId = goblinNftExSkuParam.getActivityId();
}
GoblinNftExSku goblinNftExSku = new GoblinNftExSku(); GoblinNftExSku goblinNftExSku = new GoblinNftExSku();
BeanUtils.copyProperties(goblinNftExSkuParam, goblinNftExSku); BeanUtils.copyProperties(goblinNftExSkuParam, goblinNftExSku);
goblinNftExSku.setCreatedAt(now); goblinNftExSku.setCreatedAt(now);
// 构建兑换码数量
for (int i = 0; i < goblinNftExSkuParam.getExStock(); i++) {
GoblinNftExCode goblinNftExCode = GoblinNftExCode.getNew(); // 盲盒 概率
goblinNftExCode.setCodeId(IDGenerator.nextSnowId()); switch (goblinNftExSkuParam.getUnbox()) {
goblinNftExCode.setActivityId(goblinNftExSkuParam.getActivityId()); case "1":
// 获取code码 // sku ---> 库存
// 样例 2978-6496-9269-0694-XX Map<String, Integer> skuMap = getSkuHitRatio(goblinNftExSkuParam.getExStock(), map);
for (String key : skuMap.keySet()) {
goblinNftExCode.setCode(""); Integer stockNum = skuMap.get(key);
goblinNftExCode.setSkuId(goblinNftExSkuParam.getSkuId()); for (int i = 0; i < stockNum; i++) {
goblinNftExCode.setState(1); GoblinNftExCode goblinNftExCode = GoblinNftExCode.getNew();
goblinNftExCode.setCreatedAt(now); goblinNftExCode.setCodeId(IDGenerator.nextSnowId());
goblinNftExCodes.add(goblinNftExCode); goblinNftExCode.setActivityId(goblinNftExSkuParam.getActivityId());
// goblinNftExCodeArrayList.add(GoblinNftExCodeVo.getNew().copy(goblinNftExCode));
// 获取兑换码ZA
// 样例 2978-6496-9269-0694-XX
String code = IDGenerator.createCode(3, 4, true);
goblinNftExCode.setCode(code);
goblinNftExCode.setBoxSkuId(key);
goblinNftExCode.setState(1);
goblinNftExCode.setCreatedAt(now);
goblinNftExCodes.add(goblinNftExCode);
GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(goblinNftExCode);
// 赋值额外属性
goblinNftExCodeVo.setExLimit(goblinNftExSkuParam.getExLimit());
goblinNftExCodeVo.setExStartTime(goblinNftExSkuParam.getExStartTime());
goblinNftExCodeVo.setExStopTime(goblinNftExSkuParam.getExStopTime());
LocalDateTime exStartTime = goblinNftExSkuParam.getExStartTime();
LocalDateTime exStopTime = goblinNftExSkuParam.getExStopTime();
// 时间差 以秒表示
long millisNum = Duration.between(exStartTime, exStopTime).toMillis();
// redis 存储
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
}
}
break;
default:
// 构建兑换码数量
for (int i = 0; i < goblinNftExSkuParam.getExStock(); i++) {
GoblinNftExCode goblinNftExCode = GoblinNftExCode.getNew();
goblinNftExCode.setCodeId(IDGenerator.nextSnowId());
goblinNftExCode.setActivityId(goblinNftExSkuParam.getActivityId());
// 获取兑换码ZA
// 样例 2978-6496-9269-0694-XX
String code = IDGenerator.createCode(3, 4, true);
goblinNftExCode.setCode(code);
goblinNftExCode.setSkuId(goblinNftExSkuParam.getSkuId());
goblinNftExCode.setState(1);
goblinNftExCode.setCreatedAt(now);
goblinNftExCodes.add(goblinNftExCode);
GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(goblinNftExCode);
// 赋值额外属性
goblinNftExCodeVo.setExLimit(goblinNftExSkuParam.getExLimit());
goblinNftExCodeVo.setExStartTime(goblinNftExSkuParam.getExStartTime());
goblinNftExCodeVo.setExStopTime(goblinNftExSkuParam.getExStopTime());
LocalDateTime exStartTime = goblinNftExSkuParam.getExStartTime();
LocalDateTime exStopTime = goblinNftExSkuParam.getExStopTime();
// 时间差 以秒表示
long millisNum = Duration.between(exStartTime, exStopTime).toMillis();
// redis 存储
goblinRedisUtils.addCode(code, goblinNftExCodeVo, millisNum);
// goblinNftExCodeArrayList.add(GoblinNftExCodeVo.getNew().copy(goblinNftExCode));
}
goblinNftExSkus.add(goblinNftExSku);
// goblinNftExSkuArrayList.add(GoblinNftExSkuVo.getNew().copy(goblinNftExSku));
} }
goblinNftExSkus.add(goblinNftExSku);
// goblinNftExSkuArrayList.add(GoblinNftExSkuVo.getNew().copy(goblinNftExSku));
} }
// 数据库操作
goblinNftExSkuMapper.addGoblinNftExSkus(goblinNftExSkus); goblinNftExSkuMapper.addGoblinNftExSkus(goblinNftExSkus);
goblinNftExCodeMapper.addGoblinNftExCodes(goblinNftExCodes); goblinNftExCodeMapper.addGoblinNftExCodes(goblinNftExCodes);
return true; return true;
} }
/** /**
* 获取每个sku的
* *
* @function 生成num位的随机字符串(数字、大写字母随机混排) * @param exStock
* @param num * @param map
* @return * @return
*/ */
public static String createBigSmallLetterStrOrNumberRadom(int num) { private Map<String, Integer> getSkuHitRatio(Integer exStock, Map<String, BigDecimal> map) {
StringBuffer str = new StringBuffer();
for (int k=0;k<num;k++) {
for(int i=0;i < 4;i++){
int intVal=(int)(Math.random()*58+65);
if(intVal >= 91 && intVal <= 96){
i--;
}
if(intVal < 91 || intVal > 96){
if(intVal%2==0){
str.append((char)intVal);
}else{
str.append((int)(Math.random()*10));
}
}
}
str.append("-");
}
return str.toString()+"CH"; // sku ---> 次数
} Map<String, Integer> skuNumMap = new HashMap<>();
public static void main(String[] args) { for (String key : map.keySet()) {
System.out.println(createBigSmallLetterStrOrNumberRadom(3)); // 概率
BigDecimal hitNum = map.get(key).divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
Integer stock = hitNum.multiply(BigDecimal.valueOf(exStock)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
skuNumMap.put(key, stock);
}
return skuNumMap;
} }
} }
...@@ -9,6 +9,7 @@ import com.liquidnet.service.base.constant.MQConst; ...@@ -9,6 +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.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo; import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -181,6 +182,28 @@ public class GoblinRedisUtils { ...@@ -181,6 +182,28 @@ public class GoblinRedisUtils {
} }
} }
/**
* 添加code码 添加过期时间
* @param code
* @param goblinNftExCodeVo
* @param millisNum
* @return
*/
public boolean addCode(String code, GoblinNftExCodeVo goblinNftExCodeVo, long millisNum) {
String key = GoblinRedisConst.ACTIVITY_SKU_CODE.concat(code);
return getRedis().set(key,goblinNftExCodeVo,millisNum);
}
/**
* redis codes主动失效
* @param codes
*/
public void removeCodes(List<String> codes) {
getRedis().delList(codes);
}
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
......
...@@ -68,9 +68,9 @@ public class ObjectUtil { ...@@ -68,9 +68,9 @@ public class ObjectUtil {
private static final ArrayList<KylinOrderCoupons> kylinOrderCouponsArrayList = new ArrayList<>(); private static final ArrayList<KylinOrderCoupons> kylinOrderCouponsArrayList = new ArrayList<>();
private static final ArrayList<KylinApiCameraDevicesVo> kylinApiCameraDevicesVoArrayList = new ArrayList<>(); private static final ArrayList<KylinApiCameraDevicesVo> kylinApiCameraDevicesVoArrayList = new ArrayList<>();
private static final ArrayList<SellDataOneVO> sellDataOneVOArrayList = new ArrayList<>(); private static final ArrayList<SellDataOneVO> sellDataOneVOArrayList = new ArrayList<>();
private static final ArrayList<GoblinNftExActivityVo> GOBLIN_NFT_EX_ACTIVITY_VO_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<GoblinNftExActivityVo> goblinNftExActivityVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinNftExCodeVo> GOBLIN_NFT_EX_CODE_VO_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<GoblinNftExCodeVo> goblinNftExCodeVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinNftExSkuVo> GOBLIN_NFT_EX_SKU_VO_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<GoblinNftExSkuVo> goblinNftExSkuVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreMarketDto> goblinStoreMarketDtoArrayList = new ArrayList<>(); private static final ArrayList<GoblinStoreMarketDto> goblinStoreMarketDtoArrayList = new ArrayList<>();
...@@ -150,15 +150,15 @@ public class ObjectUtil { ...@@ -150,15 +150,15 @@ public class ObjectUtil {
} }
public static ArrayList<GoblinNftExActivityVo> getGoblinNftExActivityArrayList(){ public static ArrayList<GoblinNftExActivityVo> getGoblinNftExActivityArrayList(){
return (ArrayList<GoblinNftExActivityVo>) GOBLIN_NFT_EX_ACTIVITY_VO_ARRAY_LIST.clone(); return (ArrayList<GoblinNftExActivityVo>) goblinNftExActivityVoArrayList.clone();
} }
public static ArrayList<GoblinNftExCodeVo> getGoblinNftExCodeArrayList(){ public static ArrayList<GoblinNftExCodeVo> getGoblinNftExCodeArrayList(){
return (ArrayList<GoblinNftExCodeVo>) GOBLIN_NFT_EX_CODE_VO_ARRAY_LIST.clone(); return (ArrayList<GoblinNftExCodeVo>) goblinNftExCodeVoArrayList.clone();
} }
public static ArrayList<GoblinNftExSkuVo> getGoblinNftExSkuArrayList(){ public static ArrayList<GoblinNftExSkuVo> getGoblinNftExSkuArrayList(){
return (ArrayList<GoblinNftExSkuVo>) GOBLIN_NFT_EX_SKU_VO_ARRAY_LIST.clone(); return (ArrayList<GoblinNftExSkuVo>) goblinNftExSkuVoArrayList.clone();
} }
......
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