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

Commit 64fb9b10 authored by wanglele's avatar wanglele

兑换码相关

parent fd28c9f5
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
<artifactId>liquidnet-service-goblin-do</artifactId> <artifactId>liquidnet-service-goblin-do</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package com.liquidnet.service.goblin.dto.vo; package com.liquidnet.service.goblin.dto.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinGoods; import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.entity.GoblinNftExActivity; import com.liquidnet.service.goblin.entity.GoblinNftExActivity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -20,6 +25,8 @@ import java.util.List; ...@@ -20,6 +25,8 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@HeadRowHeight(value = 20)//设置表头行高
@ColumnWidth(value = 15)//设置表头行宽
public class GoblinNftExActivityVo implements Serializable,Cloneable { public class GoblinNftExActivityVo implements Serializable,Cloneable {
...@@ -38,36 +45,43 @@ public class GoblinNftExActivityVo implements Serializable,Cloneable { ...@@ -38,36 +45,43 @@ public class GoblinNftExActivityVo implements Serializable,Cloneable {
/** /**
* 活动标题 * 活动标题
*/ */
@ExcelProperty(value = "活动标题", index = 0)//”0“表示excel中的第一列
@ApiModelProperty(position = 11,required = true,value ="活动标题") @ApiModelProperty(position = 11,required = true,value ="活动标题")
private String title; private String title;
/** /**
* 创建时间 * 创建时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 12,required = true,value ="创建时间") @ApiModelProperty(position = 12,required = true,value ="创建时间")
@ExcelProperty(value = "时间", index = 1)//”0“表示excel中的第一列
private LocalDateTime createdAt; private LocalDateTime createdAt;
/** /**
* 更新时间 * 更新时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 13,required = true,value ="更新时间") @ApiModelProperty(position = 13,required = true,value ="更新时间")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
/** /**
* 总数量 * 总数量
*/ */
@ExcelProperty(value = "优惠券总数量", index = 2)//”0“表示excel中的第一列
@ApiModelProperty(position = 14,required = true,value ="总数量") @ApiModelProperty(position = 14,required = true,value ="总数量")
private Integer countNumber; private Integer countNumber;
/** /**
* 使用数量 * 使用数量
*/ */
@ExcelProperty(value = "优惠券使用数量", index = 3)//”0“表示excel中的第一列
@ApiModelProperty(position = 15,required = true,value ="使用数量") @ApiModelProperty(position = 15,required = true,value ="使用数量")
private Integer useNumber; private Integer useNumber;
/** /**
* 未使用数量 * 未使用数量
*/ */
@ExcelProperty(value = "兑换码未使用数量", index = 4)//”0“表示excel中的第一列
@ApiModelProperty(position = 16,required = true,value ="未使用数量") @ApiModelProperty(position = 16,required = true,value ="未使用数量")
private Integer unUseNumber; private Integer unUseNumber;
......
...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.dto.vo; ...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.dto.vo;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinNftExCode; import com.liquidnet.service.goblin.entity.GoblinNftExCode;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -93,6 +95,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable { ...@@ -93,6 +95,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable {
/** /**
* 兑换时间 * 兑换时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 20,required = true,value ="兑换时间") @ApiModelProperty(position = 20,required = true,value ="兑换时间")
private LocalDateTime redeemAt; private LocalDateTime redeemAt;
...@@ -120,6 +123,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable { ...@@ -120,6 +123,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable {
/** /**
* 兑换生效开始时间 * 兑换生效开始时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 24,required = true,value ="兑换生效开始时间") @ApiModelProperty(position = 24,required = true,value ="兑换生效开始时间")
private LocalDateTime exStartTime; private LocalDateTime exStartTime;
...@@ -127,6 +131,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable { ...@@ -127,6 +131,7 @@ public class GoblinNftExCodeVo implements Serializable, Cloneable {
/** /**
* 兑换生效结束时间 * 兑换生效结束时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 25,required = true,value ="兑换生效结束时间") @ApiModelProperty(position = 25,required = true,value ="兑换生效结束时间")
private LocalDateTime exStopTime; private LocalDateTime exStopTime;
......
...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.dto.vo; ...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.dto.vo;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinNftExSku; import com.liquidnet.service.goblin.entity.GoblinNftExSku;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -74,6 +76,7 @@ public class GoblinNftExSkuVo { ...@@ -74,6 +76,7 @@ public class GoblinNftExSkuVo {
/** /**
* 兑换生效开始时间 * 兑换生效开始时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 17,required = true,value ="兑换生效开始时间") @ApiModelProperty(position = 17,required = true,value ="兑换生效开始时间")
private LocalDateTime exStartTime; private LocalDateTime exStartTime;
...@@ -81,18 +84,21 @@ public class GoblinNftExSkuVo { ...@@ -81,18 +84,21 @@ public class GoblinNftExSkuVo {
/** /**
* 兑换生效结束时间 * 兑换生效结束时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 18,required = true,value ="兑换生效结束时间") @ApiModelProperty(position = 18,required = true,value ="兑换生效结束时间")
private LocalDateTime exStopTime; private LocalDateTime exStopTime;
/** /**
* 创建时间 * 创建时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 19,required = true,value ="创建时间") @ApiModelProperty(position = 19,required = true,value ="创建时间")
private LocalDateTime createdAt; private LocalDateTime createdAt;
/** /**
* 修改时间 * 修改时间
*/ */
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 20,required = true,value ="修改时间") @ApiModelProperty(position = 20,required = true,value ="修改时间")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
...@@ -113,7 +119,7 @@ public class GoblinNftExSkuVo { ...@@ -113,7 +119,7 @@ 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.setUnBox(goblinNftExSku.getUnbox());
this.setStoreId(goblinNftExSku.getStoreId()); this.setStoreId(goblinNftExSku.getStoreId());
this.setExStock(goblinNftExSku.getExStock()); this.setExStock(goblinNftExSku.getExStock());
this.setExLimit(goblinNftExSku.getExLimit()); this.setExLimit(goblinNftExSku.getExLimit());
......
package com.liquidnet.service.goblin.param; package com.liquidnet.service.goblin.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -19,9 +21,11 @@ public class GoblinNftExActivityParam implements Serializable { ...@@ -19,9 +21,11 @@ public class GoblinNftExActivityParam implements Serializable {
@ApiModelProperty(position = 11,required = true,value = "活动标题" ,example = "草莓音乐节") @ApiModelProperty(position = 11,required = true,value = "活动标题" ,example = "草莓音乐节")
private String title; private String title;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 12,required = false,value = "开始时间") @ApiModelProperty(position = 12,required = false,value = "开始时间")
private LocalDateTime startTime; private LocalDateTime startTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(position = 13,required = false,value = "结束时间") @ApiModelProperty(position = 13,required = false,value = "结束时间")
private LocalDateTime endTime; private LocalDateTime endTime;
......
...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* @Author: wll * @Author: wll
* @Description: * @Description:
...@@ -11,7 +13,7 @@ import lombok.Data; ...@@ -11,7 +13,7 @@ import lombok.Data;
*/ */
@ApiModel(value = "GoblinNftExCodeParam",description = "查询方法入参") @ApiModel(value = "GoblinNftExCodeParam",description = "查询方法入参")
@Data @Data
public class GoblinNftExCodeParam { public class GoblinNftExCodeParam implements Serializable {
@ApiModelProperty(position = 10,required = true,value = "活动id") @ApiModelProperty(position = 10,required = true,value = "活动id")
private String activityId; private String activityId;
......
package com.liquidnet.service.goblin.param; package com.liquidnet.service.goblin.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
...@@ -14,11 +17,11 @@ import java.time.LocalDateTime; ...@@ -14,11 +17,11 @@ import java.time.LocalDateTime;
@ApiModel(value = "GoblinNftExActivityParam", description = "添加方法入参") @ApiModel(value = "GoblinNftExActivityParam", description = "添加方法入参")
@Data @Data
public class GoblinNftExSkuParam { public class GoblinNftExSkuParam implements Serializable {
@ApiModelProperty(position = 10, required = true, value = "nft兑换活动id") @ApiModelProperty(position = 10, required = true, value = "nft兑换活动id")
@NotBlank(message = "nft兑换活动id不可为空") // @NotBlank(message = "nft兑换活动id不可为空")
private String activityId; private String activityId;
@ApiModelProperty(position = 11,required = true,value = "店铺id") @ApiModelProperty(position = 11,required = true,value = "店铺id")
...@@ -26,31 +29,33 @@ public class GoblinNftExSkuParam { ...@@ -26,31 +29,33 @@ public class GoblinNftExSkuParam {
@ApiModelProperty(position = 12,required = true,value = "商品id") @ApiModelProperty(position = 12,required = true,value = "商品id")
@NotBlank(message = "商品id不可为空") // @NotBlank(message = "商品id不可为空")
private String spuId; private String spuId;
@ApiModelProperty(position = 13,required = true,value = "款式id") @ApiModelProperty(position = 13,required = true,value = "款式id")
@NotBlank(message = "款式id不可为空") // @NotBlank(message = "款式id不可为空")
private String skuId; private String skuId;
@ApiModelProperty(position = 14,required = true,value = "是否盲盒 0:否 1:是") @ApiModelProperty(position = 14,required = true,value = "是否盲盒 0:否 1:是")
@NotBlank(message = "是否盲盒 0:否 1:是") // @NotBlank(message = "是否盲盒 0:否 1:是")
private String unbox; private String unbox;
@ApiModelProperty(position = 15,required = true,value = "兑换库存数量") @ApiModelProperty(position = 15,required = true,value = "兑换库存数量")
@NotBlank(message = "兑换库存数量不可为空") // @NotBlank(message = "兑换库存数量不可为空")
private Integer exStock; private Integer exStock;
@ApiModelProperty(position = 16,required = true,value = "兑换限购数量") @ApiModelProperty(position = 16,required = true,value = "兑换限购数量")
@NotBlank(message = "兑换限购数量不可为空") // @NotBlank(message = "兑换限购数量不可为空")
private Integer exLimit; private Integer exLimit;
@ApiModelProperty(position = 17,required = true,value = "兑换生效开始时间") @ApiModelProperty(position = 17,required = true,value = "兑换生效开始时间")
@NotBlank(message = "兑换生效开始时间不可为空") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
// @NotBlank(message = "兑换生效开始时间不可为空")
private LocalDateTime exStartTime; private LocalDateTime exStartTime;
@ApiModelProperty(position = 18,required = true,value = "兑换生效结束时间") @ApiModelProperty(position = 18,required = true,value = "兑换生效结束时间")
@NotBlank(message = "兑换生效结束时间不可为空") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
// @NotBlank(message = "兑换生效结束时间不可为空")
private LocalDateTime exStopTime; private LocalDateTime exStopTime;
......
...@@ -5,12 +5,14 @@ import com.liquidnet.service.goblin.dto.vo.GoblinNftExActivityVo; ...@@ -5,12 +5,14 @@ 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.param.GoblinNftExActivityParam; import com.liquidnet.service.goblin.param.GoblinNftExActivityParam;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
public interface IGoblinNftExActivityService { public interface IGoblinNftExActivityService {
/** /**
* 新增nft活动 * 新增nft活动
*
* @param goblinNftExActivityParam * @param goblinNftExActivityParam
* @return * @return
*/ */
...@@ -18,6 +20,7 @@ public interface IGoblinNftExActivityService { ...@@ -18,6 +20,7 @@ public interface IGoblinNftExActivityService {
/** /**
* 分页查询 * 分页查询
*
* @param goblinNftExActivityParam * @param goblinNftExActivityParam
* @return * @return
*/ */
...@@ -25,8 +28,17 @@ public interface IGoblinNftExActivityService { ...@@ -25,8 +28,17 @@ public interface IGoblinNftExActivityService {
/** /**
* 根据活动id获取活动下商品 * 根据活动id获取活动下商品
*
* @param activityId * @param activityId
* @return * @return
*/ */
List<GoblinNftSkuVo> selectNftSkuByActivityId(String activityId); List<GoblinNftSkuVo> selectNftSkuByActivityId(String activityId);
/**
* excel导出
*
* @param httpServletResponse
* @param goblinNftExActivityParam
*/
void excel(HttpServletResponse httpServletResponse, GoblinNftExActivityParam goblinNftExActivityParam);
} }
...@@ -164,7 +164,6 @@ public class IDGenerator { ...@@ -164,7 +164,6 @@ public class IDGenerator {
for (int k=0;k<num;k++) { for (int k=0;k<num;k++) {
for(int i=0;i < sec;i++){ for(int i=0;i < sec;i++){
int intVal=(int)(Math.random()*58+65); int intVal=(int)(Math.random()*58+65);
System.out.println(intVal);
if(intVal >= 91 && intVal <= 122){ if(intVal >= 91 && intVal <= 122){
i--; i--;
} }
......
...@@ -43,7 +43,7 @@ public class GoblinNftExSku { ...@@ -43,7 +43,7 @@ public class GoblinNftExSku {
/** /**
* 是否盲盒 0:否 1:是 * 是否盲盒 0:否 1:是
*/ */
private String unBox; private String unbox;
/** /**
......
...@@ -38,8 +38,8 @@ public interface GoblinNftExActivityMapper extends BaseMapper<GoblinNftExActivit ...@@ -38,8 +38,8 @@ public interface GoblinNftExActivityMapper extends BaseMapper<GoblinNftExActivit
/** /**
* 根据活动ids 获取活动 * 根据活动ids 获取活动
* @param activityIds * @param activityId
* @return * @return
*/ */
GoblinNftExActivity selectByActivityIds(@Param("activityIds") String activityIds); GoblinNftExActivity selectByActivityId(@Param("activityId") String activityId);
} }
...@@ -54,4 +54,9 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> { ...@@ -54,4 +54,9 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> {
* @return * @return
*/ */
int updateCodes(@Param("goblinNftExCodes") List<GoblinNftExCode> goblinNftExCodes); int updateCodes(@Param("goblinNftExCodes") List<GoblinNftExCode> goblinNftExCodes);
/*
* 根据code获取兑换码信息
*/
GoblinNftExCode selectGoblinNftCodeByCode(@Param("code") String code);
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<resultMap id="BaseResult" type="com.liquidnet.service.goblin.entity.GoblinGoodsSku"> <resultMap id="BaseResult" type="com.liquidnet.service.goblin.entity.GoblinGoodsSku">
<result column="sku_id" property="skuId" jdbcType="VARCHAR"/> <result column="sku_id" property="skuId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/> <result column="name" property="name" jdbcType="VARCHAR"/>
<result column="unbox" property="unbox" jdbcType="VARCHAR"/>
<result column="hit_ratio" property="hitRatio" jdbcType="DECIMAL"/> <result column="hit_ratio" property="hitRatio" jdbcType="DECIMAL"/>
</resultMap> </resultMap>
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
</select> </select>
<select id="selectBySkuIds" resultMap="BaseResult"> <select id="selectBySkuIds" resultMap="BaseResult">
select sku_id,name from goblin_goods_sku where select sku_id,name,sku_pic from goblin_goods_sku where
sku_id in sku_id in
<foreach collection="skuIds.split(',')" item="skuId" open="(" separator="," close=")"> <foreach collection="skuIds.split(',')" item="skuId" open="(" separator="," close=")">
#{skuId,jdbcType=VARCHAR} #{skuId,jdbcType=VARCHAR}
...@@ -23,7 +24,7 @@ ...@@ -23,7 +24,7 @@
</select> </select>
<select id="selectBySpuIds" resultMap="BaseResult"> <select id="selectBySpuIds" resultMap="BaseResult">
select sku_id,hit_ratio from goblin_goods_sku where select sku_id,hit_ratio,unbox from goblin_goods_sku where
spu_id in spu_id in
<foreach collection="spuIds.split(',')" item="spuId" open="(" separator="," close=")"> <foreach collection="spuIds.split(',')" item="spuId" open="(" separator="," close=")">
#{spuId,jdbcType=VARCHAR} #{spuId,jdbcType=VARCHAR}
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
</where> </where>
</select> </select>
<select id="selectByActivityIds" resultMap="BaseResult"> <select id="selectByActivityId" resultMap="BaseResult">
select activity_id,title,created_at from goblin_nft_ex_activity where activity_id in select activity_id,title,created_at from goblin_nft_ex_activity where activity_id = #{activityId}
<foreach collection="activityIds.split(',')" item="activityId" open="(" separator="," close=")">
#{activityId}
</foreach>
</select> </select>
<insert id="addGoblinNftExActivity" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExActivity"> <insert id="addGoblinNftExActivity" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExActivity">
......
...@@ -24,17 +24,22 @@ ...@@ -24,17 +24,22 @@
</foreach> </foreach>
</select> </select>
<select id="selectGoblinNftCodeByCode" resultMap="BeseResult">
select code_id,activity_id,code,box_sku_id
</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,box_sku_id,state,created_at)
values values
<foreach collection="goblinNftExCodeVos" item="goblinNftExCodeVo" separator=","> <foreach collection="goblinNftExCodes" item="goblinNftExCode" separator=",">
( (
#{codeId}, #{goblinNftExCode.codeId},
#{activityId}, #{goblinNftExCode.activityId},
#{code}, #{goblinNftExCode.code},
#{skuId}, #{goblinNftExCode.skuId},
#{state}, #{goblinNftExCode.boxSkuId},
#{createdAt} #{goblinNftExCode.state},
#{goblinNftExCode.createdAt}
) )
</foreach> </foreach>
</insert> </insert>
...@@ -51,7 +56,7 @@ ...@@ -51,7 +56,7 @@
<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 code_id,code,sku_id from goblin_nft_ex_code select code_id,code,sku_id,activity_id,state,redeem_uid,redeem_at,admin_uid,created_at from goblin_nft_ex_code
<where> <where>
<if test="code != null and code != ''"> <if test="code != null and code != ''">
and code = #{code,jdbcType=VARCHAR} and code = #{code,jdbcType=VARCHAR}
...@@ -85,7 +90,7 @@ ...@@ -85,7 +90,7 @@
</select> </select>
<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,sku_id,box_sku_id,activity_id,state from goblin_nft_ex_code where
activity_id in activity_id in
<foreach collection="activityIds.split(',')" item="activityId" open="(" close=")" separator=","> <foreach collection="activityIds.split(',')" item="activityId" open="(" close=")" separator=",">
#{activityId,jdbcType=VARCHAR} #{activityId,jdbcType=VARCHAR}
......
...@@ -5,11 +5,14 @@ ...@@ -5,11 +5,14 @@
<result column="activity_id" property="activityId" jdbcType="VARCHAR"/> <result column="activity_id" property="activityId" jdbcType="VARCHAR"/>
<result column="sku_id" property="skuId" jdbcType="VARCHAR"/> <result column="sku_id" property="skuId" jdbcType="VARCHAR"/>
<result column="store_id" property="storeId" jdbcType="VARCHAR"/> <result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="spu_id" property="spuId" jdbcType="VARCHAR"/>
<result column="unbox" property="unbox" jdbcType="VARCHAR"/> <result column="unbox" property="unbox" jdbcType="VARCHAR"/>
<result column="ex_stock" property="exStock" jdbcType="INTEGER"/> <result column="ex_stock" property="exStock" jdbcType="INTEGER"/>
<result column="ex_limit" property="exLimit" jdbcType="INTEGER"/> <result column="ex_limit" property="exLimit" jdbcType="INTEGER"/>
<result column="ex_start_time" property="exStartTime" jdbcType="TIMESTAMP"/> <result column="ex_start_time" property="exStartTime" jdbcType="TIMESTAMP"/>
<result column="ex_stop_time" property="exStopTime" jdbcType="TIMESTAMP"/> <result column="ex_stop_time" property="exStopTime" jdbcType="TIMESTAMP"/>
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id="selectGoblinNftExSkuByActivityIds" resultMap="BaseResult"> <select id="selectGoblinNftExSkuByActivityIds" resultMap="BaseResult">
...@@ -19,4 +22,23 @@ ...@@ -19,4 +22,23 @@
#{activityId,jdbcType=VARCHAR} #{activityId,jdbcType=VARCHAR}
</foreach> </foreach>
</select> </select>
<insert id="addGoblinNftExSkus">
insert into goblin_nft_ex_sku (activity_id,spu_id,sku_id,store_id,unbox,ex_stock,ex_limit,ex_start_time,ex_stop_time,created_at)
values
<foreach collection="goblinNftExSkus" item="goblinNftExSku" separator=",">
(
#{goblinNftExSku.activityId},
#{goblinNftExSku.spuId},
#{goblinNftExSku.skuId},
#{goblinNftExSku.storeId},
#{goblinNftExSku.unbox},
#{goblinNftExSku.exStock},
#{goblinNftExSku.exLimit},
#{goblinNftExSku.exStartTime},
#{goblinNftExSku.exStopTime},
#{goblinNftExSku.createdAt}
)
</foreach>
</insert>
</mapper> </mapper>
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<properties> <properties>
<bitwalker.version>1.19</bitwalker.version> <bitwalker.version>1.19</bitwalker.version>
<easyexcel.version>3.0.5</easyexcel.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -113,7 +114,10 @@ ...@@ -113,7 +114,10 @@
<artifactId>aliyun-java-sdk-facebody</artifactId> <artifactId>aliyun-java-sdk-facebody</artifactId>
<version>1.2.27</version> <version>1.2.27</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency> <dependency>
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
......
...@@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,8 @@ 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.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
...@@ -56,5 +58,12 @@ public class GoblinNftExActivityController { ...@@ -56,5 +58,12 @@ public class GoblinNftExActivityController {
return ResponseDto.success(iGoblinNftExActivityService.selectNftSkuByActivityId(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);
}
} }
package com.liquidnet.service.platform.service.impl.goblin; package com.liquidnet.service.platform.service.impl.goblin;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
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.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
...@@ -15,10 +19,15 @@ import com.liquidnet.service.goblin.service.IGoblinNftExActivityService; ...@@ -15,10 +19,15 @@ 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 com.liquidnet.service.platform.utils.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
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 javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
...@@ -118,7 +127,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi ...@@ -118,7 +127,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
ArrayList<GoblinNftSkuVo> goblinNftSkuVoArrayList = ObjectUtil.getGoblinNftSkuVoArrayList(); ArrayList<GoblinNftSkuVo> goblinNftSkuVoArrayList = ObjectUtil.getGoblinNftSkuVoArrayList();
// 获取兑换活动 // 获取兑换活动
GoblinNftExActivity goblinNftExActivity = goblinNftExActivityMapper.selectByActivityIds(activityId); GoblinNftExActivity goblinNftExActivity = goblinNftExActivityMapper.selectByActivityId(activityId);
if (goblinNftExActivity == null) { if (goblinNftExActivity == null) {
return goblinNftSkuVoArrayList; return goblinNftSkuVoArrayList;
} }
...@@ -147,10 +156,17 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi ...@@ -147,10 +156,17 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
Map<String, List<GoblinNftExCode>> codeMap = new HashMap<>(); Map<String, List<GoblinNftExCode>> codeMap = new HashMap<>();
for (GoblinNftExCode goblinNftExCode : goblinNftExCodes) { for (GoblinNftExCode goblinNftExCode : goblinNftExCodes) {
if (StringUtil.isNotBlank(goblinNftExCode.getSkuId())){
if (codeMap.get(goblinNftExCode.getSkuId()) == null) { if (codeMap.get(goblinNftExCode.getSkuId()) == null) {
codeMap.put(goblinNftExCode.getSkuId(), new ArrayList<>()); codeMap.put(goblinNftExCode.getSkuId(), new ArrayList<>());
} }
codeMap.get(goblinNftExCode.getSkuId()).add(goblinNftExCode); codeMap.get(goblinNftExCode.getSkuId()).add(goblinNftExCode);
}else if (StringUtil.isNotBlank(goblinNftExCode.getBoxSkuId())){
if (codeMap.get(goblinNftExCode.getSkuId()) == null) {
codeMap.put(goblinNftExCode.getSkuId(), new ArrayList<>());
}
codeMap.get(goblinNftExCode.getSkuId()).add(goblinNftExCode);
}
} }
...@@ -192,4 +208,99 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi ...@@ -192,4 +208,99 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
return goblinNftSkuVoArrayList; return goblinNftSkuVoArrayList;
} }
@Override
public void excel(HttpServletResponse httpServletResponse, GoblinNftExActivityParam goblinNftExActivityParam) {
/*
* 获取分页nft兑换活动数据
*/
long s = System.currentTimeMillis();
List<GoblinNftExActivity> goblinNftExActivities = goblinNftExActivityMapper.selectPageList(goblinNftExActivityParam.getTitle(), goblinNftExActivityParam.getStartTime(),
goblinNftExActivityParam.getEndTime());
log.debug("#MYS耗时:{}ms", System.currentTimeMillis() - s);
StringBuffer activityIds = new StringBuffer();
for (GoblinNftExActivity GoblinNftExActivity : goblinNftExActivities) {
activityIds.append(GoblinNftExActivity.getActivityId()).append(",");
}
ArrayList<GoblinNftExActivityVo> goblinNftExActivityArrayList = ObjectUtil.getGoblinNftExActivityArrayList();
if (StringUtil.isNotBlank(activityIds)) {
activityIds.deleteCharAt(activityIds.length() - 1);
long k = System.currentTimeMillis();
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectByActivityIds(activityIds.toString());
log.debug("#MYS耗时:{}ms", System.currentTimeMillis() - k);
for (GoblinNftExActivity goblinNftExActivity : goblinNftExActivities) {
Integer countNumber = 0;
Integer useNumber = 0;
Integer unUseNumber = 0;
for (GoblinNftExCode goblinNftExCode : goblinNftExCodes) {
if (goblinNftExActivity.getActivityId().equals(goblinNftExCode.getActivityId())) {
countNumber++;
switch (goblinNftExCode.getState()) {
case 2:
useNumber++;
break;
default:
unUseNumber++;
}
}
}
goblinNftExActivity.setCountNumber(countNumber);
goblinNftExActivity.setUseNumber(useNumber);
goblinNftExActivity.setUnUseNumber(unUseNumber);
goblinNftExActivityArrayList.add(GoblinNftExActivityVo.getNew().copy(goblinNftExActivity));
}
}
try{
writeExcel(httpServletResponse,goblinNftExActivityArrayList,"活动excel","sheet1",GoblinNftExActivityVo.class);
}catch (Exception e){
log.error("导出excel失败!");
}
}
/**
* 导出
*
* @param response
* @param data
* @param fileName
* @param sheetName
* @param clazz
* @throws Exception
*/
public static void writeExcel(HttpServletResponse response, List<? extends Object> data, String fileName,
String sheetName, Class clazz) throws Exception {
// 表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
// 内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
// 设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy =
new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(getOutputStream(fileName, response), clazz).excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
.registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
fileName = URLEncoder.encode(fileName, "UTF-8");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + "-" + LocalDate.now() + ".xlsx");
return response.getOutputStream();
}
} }
...@@ -53,39 +53,42 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -53,39 +53,42 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
goblinNftExCode.setState(goblinNftExCodeParam.getState()); goblinNftExCode.setState(goblinNftExCodeParam.getState());
goblinNftExCode.setRedeemUid(goblinNftExCodeParam.getUserId()); goblinNftExCode.setRedeemUid(goblinNftExCodeParam.getUserId());
goblinNftExCode.setIsDrivi(goblinNftExCodeParam.getIsDrivi()); goblinNftExCode.setIsDrivi(goblinNftExCodeParam.getIsDrivi());
if (StringUtil.isNotBlank(goblinNftExCodeParam.getSkuName())){ if (StringUtil.isNotBlank(goblinNftExCodeParam.getSkuName())) {
// 根据藏品名称获取 skuIds // 根据藏品名称获取 skuIds
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 PageInfo<>(); return new PageInfo<>();
} }
StringBuffer skuIds = new StringBuffer(); StringBuffer skuIds = new StringBuffer();
for (GoblinGoodsSku goblinGoodsSku:goblinGoodsSkus) { for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
skuIds.append(goblinGoodsSku.getSkuId()).append(","); skuIds.append(goblinGoodsSku.getSkuId()).append(",");
} }
goblinNftExCode.setSkuId(skuIds.deleteCharAt(skuIds.length()-1).toString()); goblinNftExCode.setSkuId(skuIds.deleteCharAt(skuIds.length() - 1).toString());
} }
PageHelper.startPage(goblinNftExCodeParam.getPageNum(),20,true); PageHelper.startPage(goblinNftExCodeParam.getPageNum(), 20, true);
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCode(goblinNftExCode); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCode(goblinNftExCode);
StringBuffer skuIds = new StringBuffer(); StringBuffer skuIds = new StringBuffer();
StringBuffer acticityIds = new StringBuffer(); StringBuffer acticityIds = new StringBuffer();
for (GoblinNftExCode gnc: goblinNftExCodes) { for (GoblinNftExCode gnc : goblinNftExCodes) {
if (gnc.getState().equals(2)) {
skuIds.append(gnc.getSkuId()).append(","); skuIds.append(gnc.getSkuId()).append(",");
}
acticityIds.append(gnc.getActivityId()).append(","); acticityIds.append(gnc.getActivityId()).append(",");
} }
// 批量查询 // 获取返回对象实例
List<GoblinGoodsSku> goblinNftExCodeList = goblinGoodsSkuMapper.selectBySkuIds(skuIds.toString()); ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList();
// 获取对象实例 if (StringUtil.isNotBlank(skuIds)) {
ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList(); // 批量查询
for (GoblinNftExCode gnc: goblinNftExCodes) { List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySkuIds(skuIds.toString());
for (GoblinGoodsSku goblinGoodsSku: goblinNftExCodeList) { for (GoblinNftExCode gnc : goblinNftExCodes) {
if (gnc.getSkuId().equals(goblinGoodsSku.getSkuId())){ for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (gnc.getSkuId().equals(goblinGoodsSku.getSkuId())) {
GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc); GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc);
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName()); goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName());
goblinNftExCodeArrayList.add(goblinNftExCodeVo); goblinNftExCodeArrayList.add(goblinNftExCodeVo);
...@@ -93,25 +96,25 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -93,25 +96,25 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
} }
} }
} }
}
// 根据活动ids 获取兑换活动和sku的关联 // 根据活动ids 获取兑换活动和sku的关联
List<GoblinNftExSku> goblinNftExSkus = goblinNftExSkuMapper.selectGoblinNftExSkuByActivityIds(acticityIds.toString()); List<GoblinNftExSku> goblinNftExSkus = goblinNftExSkuMapper.selectGoblinNftExSkuByActivityIds(acticityIds.toString());
Map<String,List<GoblinNftExSku>> map = new HashMap<>(); Map<String, List<GoblinNftExSku>> map = new HashMap<>();
for (GoblinNftExSku goblinNftExSku: goblinNftExSkus) { for (GoblinNftExSku goblinNftExSku : goblinNftExSkus) {
if (map.get(goblinNftExSku.getActivityId()) == null){ if (map.get(goblinNftExSku.getActivityId()) == null) {
map.put(goblinNftExSku.getActivityId(),new ArrayList<>()); map.put(goblinNftExSku.getActivityId(), new ArrayList<>());
} }
map.get(goblinNftExSku.getActivityId()).add(goblinNftExSku); map.get(goblinNftExSku.getActivityId()).add(goblinNftExSku);
} }
for (GoblinNftExCodeVo gnc : goblinNftExCodeArrayList) {
for (GoblinNftExCodeVo gnc: goblinNftExCodeArrayList) {
List<GoblinNftExSku> goblinNftExSkuList = map.get(gnc.getActivityId()); List<GoblinNftExSku> goblinNftExSkuList = map.get(gnc.getActivityId());
for (GoblinNftExSku goblinNftExSku: goblinNftExSkuList) { for (GoblinNftExSku goblinNftExSku : goblinNftExSkuList) {
if (gnc.getSkuId().equals(goblinNftExSku.getSkuId())){ if (gnc.getSkuId().equals(goblinNftExSku.getSkuId())) {
gnc.setExStartTime(goblinNftExSku.getExStartTime()); gnc.setExStartTime(goblinNftExSku.getExStartTime());
gnc.setExStopTime(goblinNftExSku.getExStopTime()); gnc.setExStopTime(goblinNftExSku.getExStopTime());
break; break;
...@@ -120,7 +123,6 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -120,7 +123,6 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
} }
PageInfo<GoblinNftExCodeVo> pageInfo = new PageInfo<>(goblinNftExCodeArrayList); PageInfo<GoblinNftExCodeVo> pageInfo = new PageInfo<>(goblinNftExCodeArrayList);
return pageInfo; return pageInfo;
...@@ -135,16 +137,41 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -135,16 +137,41 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectByIds(codeIds); List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectByIds(codeIds);
List<String> codes = new ArrayList<>(); List<String> codes = new ArrayList<>();
for (GoblinNftExCode goblinNftExCode: goblinNftExCodes) { Map<String, Integer> skuMap = new HashMap<>();
for (GoblinNftExCode goblinNftExCode : goblinNftExCodes) {
// redis 主动失效 // redis 主动失效
codes.add(goblinNftExCode.getCode()); codes.add(goblinNftExCode.getCode());
goblinNftExCode.setState(3); goblinNftExCode.setState(3);
goblinNftExCode.setUpdatedAt(now); goblinNftExCode.setUpdatedAt(now);
String skuId = "";
if (StringUtil.isNotBlank(goblinNftExCode.getSkuId())) {
skuId = goblinNftExCode.getSkuId();
} else if (StringUtil.isNotBlank(goblinNftExCode.getBoxSkuId())) {
skuId = goblinNftExCode.getBoxSkuId();
} }
if (StringUtil.isNotBlank(skuId)) {
if (skuMap.get(skuId) == null) {
skuMap.put(skuId, 0);
}
Integer number = skuMap.get(skuId);
skuMap.put(skuId, number + 1);
}
}
if (skuMap.size() > 0) {
for (String key : skuMap.keySet()) {
goblinRedisUtils.incrSkuStock(null,key,skuMap.get(key));
}
}
goblinRedisUtils.removeCodes(codes); goblinRedisUtils.removeCodes(codes);
// 批量修改 // 批量修改
goblinNftExCodeMapper.updateCodes(goblinNftExCodes); goblinNftExCodeMapper.updateCodes(goblinNftExCodes);
return true; return true;
} }
...@@ -152,6 +179,9 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService { ...@@ -152,6 +179,9 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
public Boolean addAirdrop(GoblinNftExCodeParam goblinNftExCodeParam) { public Boolean addAirdrop(GoblinNftExCodeParam goblinNftExCodeParam) {
String code = goblinNftExCodeParam.getCode(); String code = goblinNftExCodeParam.getCode();
String phone = goblinNftExCodeParam.getPhone(); String phone = goblinNftExCodeParam.getPhone();
// 根据兑换code查询兑换码信息
GoblinNftExCode goblinNftExCode = goblinNftExCodeMapper.selectGoblinNftCodeByCode(code);
return null; return null;
} }
......
...@@ -72,9 +72,11 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -72,9 +72,11 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
if (goblinGoodsSku.getUnbox().equals("1")) { if (goblinGoodsSku.getUnbox().equals("1")) {
continue; continue;
} }
if (goblinGoodsSku.getHitRatio() != null){
map.put(goblinGoodsSku.getSkuId(), goblinGoodsSku.getHitRatio()); 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<>();
...@@ -98,9 +100,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -98,9 +100,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Integer stockNum = skuMap.get(key); Integer stockNum = skuMap.get(key);
// 根据sku减库存 // 根据sku减库存
int stock = goblinRedisUtils.decrSkuStock("", key, stockNum); int stock = goblinRedisUtils.decrSkuStock(null, key, stockNum);
if (stock < 0) { if (stock < 0) {
goblinRedisUtils.incrSkuStock("",key,stockNum); goblinRedisUtils.incrSkuStock(null,key,stockNum);
} }
...@@ -140,9 +142,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -140,9 +142,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
default: default:
// 根据sku减库存 // 根据sku减库存
int stock = goblinRedisUtils.decrSkuStock("", goblinNftExSkuParam.getSkuId(), goblinNftExSkuParam.getExStock()); int stock = goblinRedisUtils.decrSkuStock(null, goblinNftExSkuParam.getSkuId(), goblinNftExSkuParam.getExStock());
if (stock < 0) { if (stock < 0) {
goblinRedisUtils.incrSkuStock("",goblinNftExSkuParam.getSkuId(),goblinNftExSkuParam.getExStock()); goblinRedisUtils.incrSkuStock(null,goblinNftExSkuParam.getSkuId(),goblinNftExSkuParam.getExStock());
} }
// 构建兑换码数量 // 构建兑换码数量
...@@ -191,7 +193,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -191,7 +193,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
} }
/** /**
* 获取每个sku的 * 获取每个sku的兑换码生成数量
* *
* @param exStock * @param exStock
* @param map * @param map
...@@ -203,6 +205,10 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService { ...@@ -203,6 +205,10 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map<String, Integer> skuNumMap = new HashMap<>(); Map<String, Integer> skuNumMap = new HashMap<>();
for (String key : map.keySet()) { for (String key : map.keySet()) {
if (map.get(key)==null){
System.out.println(map.get(key));
}
// 概率 // 概率
BigDecimal hitNum = map.get(key).divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP); 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(); Integer stock = hitNum.multiply(BigDecimal.valueOf(exStock)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
......
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