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

Commit 447afeb1 authored by wanglele's avatar wanglele

兑换活动增加uid

parent 2c6464b8
......@@ -13,16 +13,15 @@ public class PageInfoVo {
private Object list;
public PageInfoVo(){
}
public PageInfoVo(ArrayList<GoblinNftExActivityVo> goblinNftExActivityArrayList, int count,int num) {
this.list = goblinNftExActivityArrayList;
total= count;
this.total= count;
}
public PageInfoVo(ArrayList<GoblinNftExCodeVo> goblinNftExCodeVos,int count){
public PageInfoVo(ArrayList<GoblinNftExCodeVo> goblinNftExCodeVos,int count,String vio){
this.list = goblinNftExCodeVos;
total= count;
this.total= count;
}
}
package com.liquidnet.service.goblin.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.param.GoblinNftExSkuParam;
import java.util.List;
......@@ -9,5 +10,5 @@ public interface IGoblinNftExSkuService {
/**
* 新增nft兑换活动和sku的关联
*/
Boolean add(List<GoblinNftExSkuParam> goblinNftExSkuParams);
ResponseDto<Object> add(List<GoblinNftExSkuParam> goblinNftExSkuParams);
}
......@@ -48,11 +48,11 @@ public interface GoblinNftExActivityMapper extends BaseMapper<GoblinNftExActivit
* @param title
* @return
*/
GoblinNftExActivity selectByTitle(@Param("title") String title);
GoblinNftExActivity selectByTitle(@Param("title") String title,@Param("uid")String uid);
/**
* 获取
* @return
*/
int selectActivityCount();
int selectActivityCount(@Param("title") String title, @Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime,@Param("uid") String uid);
}
......@@ -24,7 +24,7 @@
</select>
<select id="selectBySkuIds" resultMap="BaseResult">
select sku_id,name,sku_pic,unbox from goblin_goods_sku where
select sku_id,name,sku_pic,hit_ratio,unbox,sku_type,status,shelves_status,sku_appear,del_flg,soldout_status,sale_start_time from goblin_goods_sku where
sku_id in
<foreach collection="skuIds.split(',')" item="skuId" open="(" separator="," close=")">
#{skuId,jdbcType=VARCHAR}
......
......@@ -13,7 +13,7 @@
<select id="selectByTitle" resultMap="BaseResult">
select activity_id, uid, title, created_at
from goblin_nft_ex_activity
where title = #{title}
where title = #{title} and uid = #{uid}
</select>
<select id="selectPageList" resultMap="BaseResult">
......@@ -33,6 +33,7 @@
and created_at &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</where>
order by created_at desc
</select>
<select id="selectByActivityId" resultMap="BaseResult">
......@@ -44,7 +45,21 @@
<select id="selectActivityCount" resultType="java.lang.Integer">
select count(0)
from goblin_nft_ex_activity
where uid = #{uid}
<where>
<if test="uid != null and uid != ''">
and uid = #{uid,jdbcType=VARCHAR}
</if>
<if test="title != null and title != ''">
<bind name="likeTitle" value="'%' + title + '%'"/>
and title like #{likeTitle}
</if>
<if test="startTime != null">
and created_at &gt; #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
and created_at &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</where>
</select>
<insert id="addGoblinNftExActivity" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExActivity">
......
......@@ -25,7 +25,9 @@
</select>
<select id="selectGoblinNftCodeByCode" resultMap="BeseResult">
select code_id, activity_id, code, box_sku_id,state from goblin_nft_ex_code where code = #{code}
select code_id, activity_id, code, box_sku_id, state
from goblin_nft_ex_code
where code = #{code}
</select>
<insert id="addGoblinNftExCodes">
......@@ -66,22 +68,35 @@
<select id="selectGoblinNftCode" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultMap="BeseResult">
select code_id,code,sku_id,box_sku_id,activity_id,state,redeem_uid,redeem_at,admin_uid,created_at from goblin_nft_ex_code
<where>
select
DISTINCT gnec.code,gnec.code_id,gnec.sku_id,gnec.box_sku_id,gnec.activity_id,gnec.state,gnec.redeem_uid,gnec.redeem_at,gnec.admin_uid,gnec.created_at
from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes on gnec.sku_id = gnes.sku_id
<if test="code != null and code != ''">
and code = #{code,jdbcType=VARCHAR}
and gnec.code = #{code,jdbcType=VARCHAR}
</if>
<if test="activityId != null and activityId != ''">
and activity_id = #{activityId,jdbcType=VARCHAR}
and gnec.activity_id = #{activityId,jdbcType=VARCHAR}
</if>
<if test="state != null">
and state = #{state,jdbcType=INTEGER}
<choose>
<when test="state == 1">
and gnec.sku_id = gnes.sku_id and (now() BETWEEN gnes.ex_start_time and gnes.ex_stop_time) and
gnec.state =1
</when>
<when test="state == 2">
and gnec.state = 2
</when>
<when test="state == 3">
and gnec.sku_id = gnes.sku_id and (((now() &gt; gnes.ex_stop_time) AND gnec.state = 1) ||
gnec.state = 3)
</when>
</choose>
</if>
<if test="redeemUid != null and redeemUid != ''">
and redeem_uid = #{redeemUid,jdbcType=VARCHAR}
and gnec.redeem_uid = #{redeemUid,jdbcType=VARCHAR}
</if>
<if test="skuId != null and skuId != ''">
and sku_id in
and gnec.sku_id in
<foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")">
#{sId,jdbcType=VARCHAR}
</foreach>
......@@ -89,34 +104,47 @@
<if test="isDrivi != null">
<choose>
<when test="isDrivi == 1">
and admin_uid = ''
and gnec.admin_uid = ''
</when>
<when test="isDrivi == 2">
and admin_uid != ''
and gnec.admin_uid != ''
</when>
</choose>
</if>
</where>
</select>
<select id="selectGoblinNftCodeCount" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultType="java.lang.Integer">
select count(0) from goblin_nft_ex_code
<where>
select count(DISTINCT gnec.code)
from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes
on
gnec.sku_id = gnes.sku_id
<if test="code != null and code != ''">
and code = #{code,jdbcType=VARCHAR}
and gnec.code = #{code,jdbcType=VARCHAR}
</if>
<if test="activityId != null and activityId != ''">
and activity_id = #{activityId,jdbcType=VARCHAR}
and gnec.activity_id = #{activityId,jdbcType=VARCHAR}
</if>
<if test="state != null">
and state = #{state,jdbcType=INTEGER}
<choose>
<when test="state == 1">
and gnec.sku_id = gnes.sku_id and (now() BETWEEN gnes.ex_start_time and gnes.ex_stop_time) and
gnec.state =1
</when>
<when test="state == 2">
and gnec.state = 2
</when>
<when test="state == 3">
and gnec.sku_id = gnes.sku_id and (((now() &gt; gnes.ex_stop_time) AND gnec.state = 1) ||
gnec.state = 3)
</when>
</choose>
</if>
<if test="redeemUid != null and redeemUid != ''">
and redeem_uid = #{redeemUid,jdbcType=VARCHAR}
and gnec.redeem_uid = #{redeemUid,jdbcType=VARCHAR}
</if>
<if test="skuId != null and skuId != ''">
and sku_id in
and gnec.sku_id in
<foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")">
#{sId,jdbcType=VARCHAR}
</foreach>
......@@ -124,14 +152,13 @@
<if test="isDrivi != null">
<choose>
<when test="isDrivi == 1">
and admin_uid = ''
and gnec.admin_uid = ''
</when>
<when test="isDrivi == 2">
and admin_uid != ''
and gnec.admin_uid != ''
</when>
</choose>
</if>
</where>
</select>
<select id="selectByActivityIds" resultMap="BeseResult">
......
......@@ -46,8 +46,6 @@
<foreach collection="activityIds.split(',')" item="activityId" open="(" separator="," close=")">
#{activityId}
</foreach>
group by activity_id
</select>
<insert id="addGoblinNftExCodeTasks">
......
......@@ -26,12 +26,11 @@ CREATE TABLE `goblin_nft_ex_code`
INDEX `idx_nft_redeem_uid`(`redeem_uid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'NFT兑换码表' ROW_FORMAT = Dynamic;
-- >>------------------------------------------------------------------------------------
DROP TABLE IF EXISTS `goblin_nft_ex_activity`;
CREATE TABLE `goblin_nft_ex_activity`
(
`mid` bigint(0) UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`activity_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '活动id',
`title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '活动标题',
`created_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
......@@ -40,6 +39,8 @@ CREATE TABLE `goblin_nft_ex_activity`
INDEX `idx_nft_activity_id`(`activity_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'NFT兑换活动表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `goblin_nft_ex_sku`;
CREATE TABLE `goblin_nft_ex_sku`
(
......
......@@ -55,7 +55,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
// 根据名称查询
String title = goblinNftExActivityParam.getTitle();
GoblinNftExActivity goblinNftExActivityShow = goblinNftExActivityMapper.selectByTitle(title);
GoblinNftExActivity goblinNftExActivityShow = goblinNftExActivityMapper.selectByTitle(title,goblinNftExActivityParam.getUid());
if (goblinNftExActivityShow != null) {
return ResponseDto.failure("活动名称已存在!");
}
......@@ -86,8 +86,9 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
List<GoblinNftExActivity> goblinNftExActivities = goblinNftExActivityMapper.selectPageList(goblinNftExActivityParam.getTitle(), goblinNftExActivityParam.getStartTime(),
goblinNftExActivityParam.getEndTime(), goblinNftExActivityParam.getUid());
//
int count = goblinNftExActivityMapper.selectActivityCount();
// 获取活动数量
int count = goblinNftExActivityMapper.selectActivityCount(goblinNftExActivityParam.getTitle(), goblinNftExActivityParam.getStartTime(),
goblinNftExActivityParam.getEndTime(), goblinNftExActivityParam.getUid());
log.debug("#MYS耗时:{}ms", System.currentTimeMillis() - s);
......@@ -236,6 +237,7 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
* 获取分页nft兑换活动数据
*/
long s = System.currentTimeMillis();
PageHelper.startPage(goblinNftExActivityParam.getPageNum(), 20, true);
List<GoblinNftExActivity> goblinNftExActivities = goblinNftExActivityMapper.selectPageList(goblinNftExActivityParam.getTitle(), goblinNftExActivityParam.getStartTime(),
goblinNftExActivityParam.getEndTime(), goblinNftExActivityParam.getUid());
log.debug("#MYS耗时:{}ms", System.currentTimeMillis() - s);
......@@ -286,7 +288,6 @@ public class GoblinNftExActivityServiceImpl implements IGoblinNftExActivityServi
log.error("导出excel失败!");
}
}
......
......@@ -108,33 +108,29 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
} else {
skuIds.append(gnc.getBoxSkuId()).append(",");
}
acticityIds.append(gnc.getActivityId()).append(",");
}
// 获取返回对象实例
ArrayList<GoblinNftExCodeVo> goblinNftExCodeArrayList = ObjectUtil.getGoblinNftExCodeArrayList();
if (StringUtil.isNotBlank(skuIds)) {
// 批量查询
List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySkuIds(skuIds.toString());
for (GoblinNftExCode gnc : goblinNftExCodes) {
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew().copy(gnc);
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getBoxSkuId().equals(goblinGoodsSku.getSkuId())) {
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName());
goblinNftExCodeArrayList.add(goblinNftExCodeVo);
break;
} else {
if (gnc.getSkuId().equals(goblinGoodsSku.getSkuId())) {
goblinNftExCodeVo.setSkuName(goblinGoodsSku.getName());
goblinNftExCodeArrayList.add(goblinNftExCodeVo);
break;
}
}
}
goblinNftExCodeArrayList.add(goblinNftExCodeVo);
}
}
......@@ -158,7 +154,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
if (StringUtil.isNotBlank(gnc.getBoxSkuId()) && gnc.getSkuId().equals(goblinNftExSku.getSkuId())) {
gnc.setExStartTime(goblinNftExSku.getExStartTime());
gnc.setExStopTime(goblinNftExSku.getExStopTime());
if (now.isBefore(goblinNftExSku.getExStartTime()) || now.isAfter(goblinNftExSku.getExStopTime())) {
if (now.isAfter(goblinNftExSku.getExStopTime())) {
gnc.setState(3);
}
break;
......@@ -166,7 +162,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
if (gnc.getSkuId().equals(goblinNftExSku.getSkuId())) {
gnc.setExStartTime(goblinNftExSku.getExStartTime());
gnc.setExStopTime(goblinNftExSku.getExStopTime());
if (now.isBefore(goblinNftExSku.getExStartTime()) || now.isAfter(goblinNftExSku.getExStopTime())) {
if (now.isAfter(goblinNftExSku.getExStopTime())) {
gnc.setState(3);
}
break;
......@@ -175,7 +171,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
}
}
PageInfoVo pageInfo = new PageInfoVo(goblinNftExCodeArrayList, count);
PageInfoVo pageInfo = new PageInfoVo(goblinNftExCodeArrayList, count,"");
return pageInfo;
}
......@@ -213,11 +209,11 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
goblinRedisUtils.removeCode(goblinNftExCode.getCode());
}
if (skuMap.size() > 0) {
/* if (skuMap.size() > 0) {
for (String key : skuMap.keySet()) {
// goblinRedisUtils.incrSkuStock(null, key, skuMap.get(key));
}
}
}*/
// 批量修改
goblinNftExCodeMapper.updateCodes(goblinNftExCodes);
return true;
......
......@@ -10,6 +10,7 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.GoblinQueueBizIntegralDto;
import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto;
import com.liquidnet.service.goblin.dto.vo.*;
......@@ -116,6 +117,9 @@ public class GoblinRedisUtils {
return (int) getRedis().incr(rk, stock);
}
// 获取sku库存
// 减少库存
public int decrSkuStock(String marketPre, String skuId, Integer stock){
String rk = GoblinRedisConst.REAL_STOCK_SKU;
......@@ -225,7 +229,7 @@ public class GoblinRedisUtils {
public int getSkuAllStatusStock(GoblinGoodsSku info) {
if (
info != null
&& LocalDateTime.now().isAfter(info.getSaleStartTime())
// && LocalDateTime.now().isAfter(info.getSaleStartTime())
&& (null == info.getSoldoutStatus() || info.getSoldoutStatus().equals("0"))
&& (null == info.getHitRatio() || info.getHitRatio().compareTo(BigDecimal.ZERO) > 0)
) {// 可以返回库存
......@@ -237,7 +241,6 @@ public class GoblinRedisUtils {
}
}
/**
* redis codes主动失效
* @param code
......@@ -272,6 +275,26 @@ public class GoblinRedisUtils {
return getRedis().set(key,goblinNftExSkuVo);
}
/**
* 获取sku库存
* @param skuId
* @return
*/
public int getSkuStock(String skuId) {
String rk = GoblinRedisConst.REAL_STOCK_SKU.concat(skuId);
Object obj = getRedis().get(rk);
if (obj == null) {
return 0;
} else {
return (int) obj;
}
}
// 获取sku配置库存
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
......
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