优化抽奖部分
This commit is contained in:
parent
e9a7f6a223
commit
65930df950
@ -58,7 +58,7 @@ public class LuckController {
|
||||
if(luck.getFinish().intValue() == 0){//活动未结束
|
||||
luckDetailInfoReq.setId(luckId);
|
||||
luckDetailInfoReq.setName(luck.getName());
|
||||
List<LuckGoods> luckGoods = luckGoodsService.getByLuckId(luckId);
|
||||
List<LuckGoods> luckGoods = luckGoodsService.getNoFinishByLuckId(luckId);
|
||||
if(luckGoods.size() > 0){
|
||||
List<LuckGoodsReq> luckGoodsReqs = new ArrayList<>();
|
||||
for (LuckGoods luckGood:luckGoods
|
||||
@ -71,7 +71,7 @@ public class LuckController {
|
||||
luckGoodsReqs.add(luckGoodsReq);
|
||||
}
|
||||
luckDetailInfoReq.setLuckGoodsReqs(luckGoodsReqs);
|
||||
List<LuckRecord> luckRecords = luckRecordService.selectLuckRecordByLuckId(String.valueOf(luckId));
|
||||
List<LuckRecord> luckRecords = luckRecordService.selectNoGoodLuckRecordByLuckId(String.valueOf(luckId));
|
||||
if(luckRecords.size() > 0){
|
||||
List<LuckRecordReq> luckRecordReqList = new ArrayList<>();
|
||||
for (LuckRecord luckRecord:luckRecords
|
||||
@ -130,11 +130,14 @@ public class LuckController {
|
||||
luckId = luckRecordReq.getLuckId();
|
||||
luckRecordService.updateLuckRecordByReqWithId(luckRecordReq);
|
||||
}
|
||||
int count0 = luckRecordService.selectCountRecordByLuckId(luckId);
|
||||
|
||||
int count = luckRecordService.selectCountGoodLuckRecordByLuckId(luckId);
|
||||
|
||||
int count1 = luckGoodsService.selectNumGoodLuckRecordByLuckId(luckId);
|
||||
if(count < count1){
|
||||
if(count < count1 && count != count0){
|
||||
//获取未中奖人列表
|
||||
|
||||
return getLuck(luckId);
|
||||
}else{
|
||||
//设置中将结束
|
||||
|
||||
@ -36,4 +36,6 @@ public interface LuckGoodsMapper extends BaseMapper<LuckGoods> {
|
||||
List<LuckGoods> getByLuckId(@Param("luckId") Long luckId);
|
||||
|
||||
int selectNumGoodLuckRecordByLuckId(@Param("luckId") Long luckId);
|
||||
|
||||
List<LuckGoods> getNoFinishByLuckId(Long luckId);
|
||||
}
|
||||
@ -43,4 +43,8 @@ public interface LuckRecordMapper extends BaseMapper<LuckRecord> {
|
||||
List<LuckRecord> selectGoodLuckRecordByLuckId(String luckId);
|
||||
|
||||
int selectCountGoodLuckRecordByLuckId(@Param("luckId") Long luckId);
|
||||
|
||||
List<LuckRecord> selectNoGoodLuckRecordByLuckId(String luckId);
|
||||
|
||||
int selectCountRecordByLuckId(Long luckId);
|
||||
}
|
||||
@ -34,6 +34,8 @@ public class LuckGoods implements java.io.Serializable {
|
||||
private String remark;
|
||||
//数量
|
||||
private Integer counts;
|
||||
|
||||
private Integer isFinish;
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
@ -169,6 +171,14 @@ public class LuckGoods implements java.io.Serializable {
|
||||
this.counts = counts;
|
||||
}
|
||||
|
||||
public Integer getIsFinish() {
|
||||
return isFinish;
|
||||
}
|
||||
|
||||
public void setIsFinish(Integer isFinish) {
|
||||
this.isFinish = isFinish;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LuckGoods{" +
|
||||
@ -181,6 +191,7 @@ public class LuckGoods implements java.io.Serializable {
|
||||
",weight=" + weight +
|
||||
",remark=" + remark +
|
||||
",counts=" + counts +
|
||||
",isFinish=" + isFinish +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -36,4 +36,6 @@ public interface LuckGoodsService extends IService<LuckGoods> {
|
||||
|
||||
//获取奖品总数
|
||||
int selectNumGoodLuckRecordByLuckId(Long luckId);
|
||||
|
||||
List<LuckGoods> getNoFinishByLuckId(Long luckId);
|
||||
}
|
||||
@ -42,4 +42,8 @@ public interface LuckRecordService extends IService<LuckRecord> {
|
||||
List<LuckRecord> selectGoodLuckRecordByLuckId(String valueOf);
|
||||
//获取中奖人数
|
||||
int selectCountGoodLuckRecordByLuckId(Long luckId);
|
||||
//获取为未奖人数
|
||||
List<LuckRecord> selectNoGoodLuckRecordByLuckId(String valueOf);
|
||||
//获取参与人数
|
||||
int selectCountRecordByLuckId(Long luckId);
|
||||
}
|
||||
@ -70,4 +70,9 @@ public class LuckGoodsServiceImpl extends ServiceImpl<LuckGoodsMapper, LuckGoods
|
||||
return luckGoodsMapper.selectNumGoodLuckRecordByLuckId(luckId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LuckGoods> getNoFinishByLuckId(Long luckId){
|
||||
return luckGoodsMapper.getNoFinishByLuckId(luckId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -86,5 +86,15 @@ public class LuckRecordServiceImpl extends ServiceImpl<LuckRecordMapper, LuckRec
|
||||
return luckRecordMapper.selectCountGoodLuckRecordByLuckId(luckId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LuckRecord> selectNoGoodLuckRecordByLuckId(String luckId){
|
||||
return luckRecordMapper.selectNoGoodLuckRecordByLuckId(luckId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCountRecordByLuckId(Long luckId){
|
||||
return luckRecordMapper.selectCountRecordByLuckId(luckId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@ spring:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://rm-bp1xhc66ruz72t68p.mysql.rds.aliyuncs.com:3306/lz_manger?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
username: lz_manger
|
||||
password: N8zfBwhOC
|
||||
url: jdbc:mysql://172.16.157.238:3306/lz_management?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
username: ldd_biz
|
||||
password: Hello1234
|
||||
initial-size: 10
|
||||
max-active: 100
|
||||
min-idle: 10
|
||||
|
||||
@ -13,12 +13,13 @@
|
||||
<result column="weight" property="weight"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="counts" property="counts"/>
|
||||
<result column="is_finish" property="isFinish"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, luck_id AS luckId, name AS name, weight AS weight, remark AS remark, counts AS counts
|
||||
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, luck_id AS luckId, name AS name, weight AS weight, remark AS remark, counts AS counts, is_finish as isFinish
|
||||
</sql>
|
||||
|
||||
|
||||
@ -36,6 +37,7 @@
|
||||
<if test="weight != null">weight, </if>
|
||||
<if test="remark != null">remark, </if>
|
||||
<if test="counts != null">counts, </if>
|
||||
<if test="isFinish != null">is_finish, </if>
|
||||
is_delete,
|
||||
gmt_create,
|
||||
gmt_modified
|
||||
@ -45,6 +47,7 @@
|
||||
<if test="weight != null">#{ weight}, </if>
|
||||
<if test="remark != null">#{ remark}, </if>
|
||||
<if test="counts != null">#{ counts}, </if>
|
||||
<if test="isFinish != null">#{ isFinish}, </if>
|
||||
0,
|
||||
now(),
|
||||
now()
|
||||
@ -62,7 +65,8 @@
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="weight != null">weight = #{weight},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="counts != null">counts = #{counts}</if>
|
||||
<if test="counts != null">counts = #{counts}</if>
|
||||
<if test="isFinish != null">is_finish = #{isFinish}</if>
|
||||
</trim>
|
||||
,gmt_modified = now()
|
||||
where id = #{id}
|
||||
@ -79,7 +83,8 @@
|
||||
name = #{name},
|
||||
weight = #{weight},
|
||||
remark = #{remark},
|
||||
counts = #{counts}
|
||||
counts = #{counts},
|
||||
is_finish = #{isFinish},
|
||||
,gmt_modified = now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -96,5 +101,9 @@
|
||||
<select id="selectNumGoodLuckRecordByLuckId" parameterType="java.lang.Long" resultType="integer">
|
||||
select sum(counts) from luck_goods where luck_id=#{luckId} and is_delete = 0
|
||||
</select>
|
||||
|
||||
<select id="getNoFinishByLuckId" resultType="LuckGoods" >
|
||||
select * from luck_goods where luck_id=#{luckId} and is_delete = 0 and is_finish=0 order by weight desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@ -137,5 +137,13 @@
|
||||
select count(1) from luck_record where luck_id=#{luckId} and is_delete = 0 and is_luck=1
|
||||
</select>
|
||||
|
||||
<select id="selectNoGoodLuckRecordByLuckId" resultType="LuckRecord" >
|
||||
select * from luck_record where luck_id=#{luckId}and is_delete = 0 and is_luck=0 order by is_luck desc
|
||||
</select>
|
||||
|
||||
<select id="selectCountRecordByLuckId" parameterType="java.lang.Long" resultType="integer">
|
||||
select count(1) from luck_record where luck_id=#{luckId} and is_delete = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user