Commit bdc5fc9e by 吕明尚

Merge branch 'dev' into test

parents 135c8c96 f22103c7
...@@ -124,6 +124,9 @@ public class RedisTask { ...@@ -124,6 +124,9 @@ public class RedisTask {
@Autowired @Autowired
private JobErrorLogService jobErrorLogService; private JobErrorLogService jobErrorLogService;
@Autowired
private PointActivitiesService pointActivitiesService;
//15分钟的常量 //15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15; final long FIFTEEN_MINUTES = 60 * 15;
...@@ -945,6 +948,31 @@ public class RedisTask { ...@@ -945,6 +948,31 @@ public class RedisTask {
} }
@XxlJob("AutoResetPointActivity")
public void AutoResetPointActivity() {
logger.debug("AutoResetPointActivity:月初自动重置集点活动开始");
List<PointActivities> pointActivitiesList = pointActivitiesService.list(new LambdaQueryWrapper<PointActivities>()
.eq(PointActivities::getIsReceive, YesNoEnum.yes.getIndex())
.eq(PointActivities::getCouponReceived, YesNoEnum.yes.getIndex())
);
if (CollectionUtils.isEmpty(pointActivitiesList)) {
return;
}
List<PointActivities> updateList = new ArrayList<>();
pointActivitiesList.stream().forEach(item -> {
item.setPoints(YesNoEnum.no.getIndex());
item.setLastConsumptionTime(null);
item.setIsReceive(YesNoEnum.no.getIndex());
item.setCouponReceived(YesNoEnum.no.getIndex());
item.setReceivedDate(null);
item.setCouponExpirationDate(null);
updateList.add(item);
});
pointActivitiesService.updateBatchById(updateList);
logger.debug("AutoResetPointActivity:月初自动重置集点活动结束");
}
private void addNewConsumer(SOrder sorder) { private void addNewConsumer(SOrder sorder) {
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, sorder.getConsumerId())); ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, sorder.getConsumerId()));
//新增用户为普通会员 //新增用户为普通会员
......
...@@ -60,6 +60,12 @@ public class PointActivities extends BaseEntity { ...@@ -60,6 +60,12 @@ public class PointActivities extends BaseEntity {
private Date lastConsumptionTime; private Date lastConsumptionTime;
/** /**
* 当前活动月份
*/
@Excel(name = "当前活动月份")
private Integer currentMonth;
/**
* 是否可领取 * 是否可领取
*/ */
@Excel(name = "是否可领取") @Excel(name = "是否可领取")
......
...@@ -63,6 +63,12 @@ public class PointActivitiesVo extends BaseEntity { ...@@ -63,6 +63,12 @@ public class PointActivitiesVo extends BaseEntity {
private Date lastConsumptionTime; private Date lastConsumptionTime;
/** /**
* 当前活动月份
*/
@Excel(name = "当前活动月份")
private Integer currentMonth;
/**
* 是否可领取 * 是否可领取
*/ */
@Excel(name = "是否可领取", dictType = "store_is_use_coupon") @Excel(name = "是否可领取", dictType = "store_is_use_coupon")
......
...@@ -76,6 +76,8 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon> ...@@ -76,6 +76,8 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
int give(SConsumerCoupon sConsumerCoupon); int give(SConsumerCoupon sConsumerCoupon);
public Integer give(Long consumerId, Long couponId, Integer giveDay);
SConsumerCoupon queryById(Long couponId); SConsumerCoupon queryById(Long couponId);
List<SConsumerCoupon> queryByIds(List<Long> couponIds); List<SConsumerCoupon> queryByIds(List<Long> couponIds);
......
...@@ -2,6 +2,7 @@ package share.system.service; ...@@ -2,6 +2,7 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.PointActivities; import share.system.domain.PointActivities;
import share.system.domain.SOrder;
import share.system.domain.vo.PointActivitiesVo; import share.system.domain.vo.PointActivitiesVo;
import java.util.List; import java.util.List;
...@@ -60,4 +61,8 @@ public interface PointActivitiesService extends IService<PointActivities> { ...@@ -60,4 +61,8 @@ public interface PointActivitiesService extends IService<PointActivities> {
* @return 结果 * @return 结果
*/ */
public int deletePointActivitiesById(Long id); public int deletePointActivitiesById(Long id);
public void joinPointActivities(SOrder sOrder);
public void receivePointActivities(Long id);
} }
...@@ -13,10 +13,13 @@ import share.system.domain.SConsumer; ...@@ -13,10 +13,13 @@ import share.system.domain.SConsumer;
import share.system.domain.SOrder; import share.system.domain.SOrder;
import share.system.domain.vo.PointActivitiesVo; import share.system.domain.vo.PointActivitiesVo;
import share.system.mapper.PointActivitiesMapper; import share.system.mapper.PointActivitiesMapper;
import share.system.service.ISConsumerCouponService;
import share.system.service.PointActivitiesConfService; import share.system.service.PointActivitiesConfService;
import share.system.service.PointActivitiesService; import share.system.service.PointActivitiesService;
import share.system.service.SConsumerService; import share.system.service.SConsumerService;
import java.time.LocalDate;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -33,6 +36,8 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe ...@@ -33,6 +36,8 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
private SConsumerService sConsumerService; private SConsumerService sConsumerService;
@Autowired @Autowired
private PointActivitiesConfService pointActivitiesConfService; private PointActivitiesConfService pointActivitiesConfService;
@Autowired
private ISConsumerCouponService sConsumerCouponService;
/** /**
* 查询用户集点活动 * 查询用户集点活动
...@@ -81,6 +86,7 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe ...@@ -81,6 +86,7 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
} }
//参与集点活动 //参与集点活动
@Override
public void joinPointActivities(SOrder sOrder) { public void joinPointActivities(SOrder sOrder) {
SConsumer user = sConsumerService.getInfo(); SConsumer user = sConsumerService.getInfo();
PointActivitiesConf pointActivitiesConf = pointActivitiesConfService.list().get(0); PointActivitiesConf pointActivitiesConf = pointActivitiesConfService.list().get(0);
...@@ -91,6 +97,7 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe ...@@ -91,6 +97,7 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
if (oldPointActivities.getPoints().equals(pointActivitiesConf.getPointsRequired())) { if (oldPointActivities.getPoints().equals(pointActivitiesConf.getPointsRequired())) {
oldPointActivities.setIsReceive(YesNoEnum.yes.getIndex()); oldPointActivities.setIsReceive(YesNoEnum.yes.getIndex());
} }
updateById(oldPointActivities);
} else { } else {
PointActivities pointActivities = new PointActivities(); PointActivities pointActivities = new PointActivities();
pointActivities.setConsumerId(user.getId()); pointActivities.setConsumerId(user.getId());
...@@ -100,10 +107,40 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe ...@@ -100,10 +107,40 @@ public class PointActivitiesServiceImpl extends ServiceImpl<PointActivitiesMappe
pointActivities.setLastConsumptionTime(sOrder.getPayTime()); pointActivities.setLastConsumptionTime(sOrder.getPayTime());
pointActivities.setIsReceive(YesNoEnum.no.getIndex()); pointActivities.setIsReceive(YesNoEnum.no.getIndex());
pointActivities.setCouponReceived(YesNoEnum.no.getIndex()); pointActivities.setCouponReceived(YesNoEnum.no.getIndex());
LocalDate currentDate = LocalDate.now();
pointActivities.setCurrentMonth(currentDate.getMonthValue());
save(pointActivities); save(pointActivities);
} }
} }
//领取集点活动
@Override
public void receivePointActivities(Long id) {
PointActivities pointActivities = pointActivitiesMapper.selectById(id);
PointActivitiesConf activitiesConf = pointActivitiesConfService.getById(pointActivities.getConfId());
//领取的时间小于领取期限(最后的时间加领取的期限)
if (DateUtils.addDays(pointActivities.getLastConsumptionTime(), activitiesConf.getCollectionDeadline()).compareTo(new Date()) < 0
&& pointActivities.getPoints().equals(activitiesConf.getPointsRequired())) {
if (pointActivities.getCurrentMonth().compareTo(LocalDate.now().getMonthValue()) == 0) {
pointActivities.setCouponReceived(YesNoEnum.yes.getIndex());
pointActivities.setReceivedDate(new Date());
sConsumerCouponService.give(pointActivities.getConsumerId(), activitiesConf.getCouponId(), activitiesConf.getCouponDuration());
pointActivities.setCouponExpirationDate(DateUtils.addDays(pointActivities.getReceivedDate(), activitiesConf.getCouponDuration()));
pointActivitiesMapper.updateById(pointActivities);
} else {
PointActivities newPointActivities = new PointActivities();
newPointActivities.setConsumerId(pointActivities.getConsumerId());
newPointActivities.setConfId(pointActivities.getConfId());
newPointActivities.setCouponId(activitiesConf.getCouponId());
newPointActivities.setPoints(YesNoEnum.no.getIndex());
newPointActivities.setCurrentMonth(LocalDate.now().getMonthValue());
pointActivitiesMapper.insert(newPointActivities);
}
} else {
throw new RuntimeException("领取时间超过领取期限");
}
}
/** /**
* 批量删除用户集点活动 * 批量删除用户集点活动
* *
......
...@@ -550,6 +550,40 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe ...@@ -550,6 +550,40 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
} }
@Override @Override
public Integer give(Long consumerId, Long couponId, Integer giveDay) {
SCoupon sCoupon = sCouponService.selectSCouponById(couponId);
//创建优惠卷领取记录
SConsumerCoupon newSConsumerCoupon = new SConsumerCoupon();
newSConsumerCoupon.setCouponId(sCoupon.getId());
newSConsumerCoupon.setConsumerId(consumerId);
newSConsumerCoupon.setName(sCoupon.getName());
newSConsumerCoupon.setStoreType(sCoupon.getStoreType());
newSConsumerCoupon.setRoomType(sCoupon.getRoomType());
newSConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
newSConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
newSConsumerCoupon.setCouponType(sCoupon.getCouponType());
newSConsumerCoupon.setMinPrice(new BigDecimal(0.00));
newSConsumerCoupon.setWeeks(sCoupon.getWeeks());
newSConsumerCoupon.setStoreIds(sCoupon.getStoreIds());
newSConsumerCoupon.setOriginalPrice(sCoupon.getOriginalPrice());
newSConsumerCoupon.setCouponPayPrice(sCoupon.getCouponPayPrice());
newSConsumerCoupon.setSalePrice(sCoupon.getSalePrice());
newSConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
newSConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
newSConsumerCoupon.setDuration(sCoupon.getDuration());
newSConsumerCoupon.setOrderType(sCoupon.getOrderType());
newSConsumerCoupon.setPackIds(sCoupon.getPackIds());
newSConsumerCoupon.setSourceType(SourceTypeEnum.GIVE.getCode());
newSConsumerCoupon.setPlatformType(sCoupon.getPlatformType());
newSConsumerCoupon.setStartDate(sCoupon.getStartDate());
newSConsumerCoupon.setEndDate(DateUtils.addDays(new Date(), giveDay));
newSConsumerCoupon.setRemark(sCoupon.getRemark());
newSConsumerCoupon.setCreateTime(new Date());
return baseMapper.insert(newSConsumerCoupon);
}
@Override
public SConsumerCoupon queryById(Long couponId) { public SConsumerCoupon queryById(Long couponId) {
return baseMapper.queryById(couponId); return baseMapper.queryById(couponId);
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result property="couponId" column="coupon_id"/> <result property="couponId" column="coupon_id"/>
<result property="couponName" column="coupon_name"/> <result property="couponName" column="coupon_name"/>
<result property="points" column="points"/> <result property="points" column="points"/>
<result property="currentMonth" column="current_month"/>
<result property="lastConsumptionTime" column="last_consumption_time"/> <result property="lastConsumptionTime" column="last_consumption_time"/>
<result property="isReceive" column="is_receive"/> <result property="isReceive" column="is_receive"/>
<result property="couponReceived" column="coupon_received"/> <result property="couponReceived" column="coupon_received"/>
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
conf_id, conf_id,
coupon_id, coupon_id,
points, points,
current_month,
last_consumption_time, last_consumption_time,
is_receive, is_receive,
coupon_received, coupon_received,
...@@ -57,20 +59,21 @@ ...@@ -57,20 +59,21 @@
c.phone as 'phone', c.phone as 'phone',
p.conf_id, p.conf_id,
c2.name as 'conf_name', c2.name as 'conf_name',
p. coupon_id, p.coupon_id,
c1.name as 'coupon_name', c1.name as 'coupon_name',
p.points, p.points,
p. last_consumption_time, p.current_month,
p.last_consumption_time,
p.is_receive, p.is_receive,
p.coupon_received, p.coupon_received,
p.received_date, p.received_date,
p. coupon_expiration_date, p.coupon_expiration_date,
p.is_delete, p.is_delete,
p. create_by, p.create_by,
p. create_time, p.create_time,
p. update_by, p.update_by,
p. update_time, p.update_time,
p. remark p.remark
from s_point_activities p left join s_consumer c on p.consumer_id = c.id from s_point_activities p left join s_consumer c on p.consumer_id = c.id
left join s_coupon c1 on p.coupon_id = c1.id left join s_coupon c1 on p.coupon_id = c1.id
left join s_point_activities_conf c2 on p.conf_id = c2.id left join s_point_activities_conf c2 on p.conf_id = c2.id
...@@ -82,6 +85,7 @@ ...@@ -82,6 +85,7 @@
<if test="confId != null ">and p.conf_id = #{confId}</if> <if test="confId != null ">and p.conf_id = #{confId}</if>
<if test="couponId != null ">and p.coupon_id = #{couponId}</if> <if test="couponId != null ">and p.coupon_id = #{couponId}</if>
<if test="points != null ">and p.points = #{points}</if> <if test="points != null ">and p.points = #{points}</if>
<if test="currentMonth != null">and p.current_month = #{currentMonth}</if>
<if test="lastConsumptionTime != null ">and p.last_consumption_time = #{lastConsumptionTime}</if> <if test="lastConsumptionTime != null ">and p.last_consumption_time = #{lastConsumptionTime}</if>
<if test="isReceive != null ">and p.is_receive = #{isReceive}</if> <if test="isReceive != null ">and p.is_receive = #{isReceive}</if>
<if test="couponReceived != null ">and p.coupon_received = #{couponReceived}</if> <if test="couponReceived != null ">and p.coupon_received = #{couponReceived}</if>
...@@ -89,6 +93,7 @@ ...@@ -89,6 +93,7 @@
<if test="couponExpirationDate != null ">and p.coupon_expiration_date = #{couponExpirationDate}</if> <if test="couponExpirationDate != null ">and p.coupon_expiration_date = #{couponExpirationDate}</if>
<if test="isDelete != null ">and p.is_delete = #{isDelete}</if> <if test="isDelete != null ">and p.is_delete = #{isDelete}</if>
</where> </where>
order by p.current_month desc
</select> </select>
<select id="selectPointActivitiesById" parameterType="Long" resultMap="PointActivitiesResult"> <select id="selectPointActivitiesById" parameterType="Long" resultMap="PointActivitiesResult">
...@@ -103,6 +108,7 @@ ...@@ -103,6 +108,7 @@
<if test="confId != null">conf_id,</if> <if test="confId != null">conf_id,</if>
<if test="couponId != null">coupon_id,</if> <if test="couponId != null">coupon_id,</if>
<if test="points != null">points,</if> <if test="points != null">points,</if>
<if test="currentMonth != null">current_month,</if>
<if test="lastConsumptionTime != null">last_consumption_time,</if> <if test="lastConsumptionTime != null">last_consumption_time,</if>
<if test="isReceive != null">is_receive,</if> <if test="isReceive != null">is_receive,</if>
<if test="couponReceived != null">coupon_received,</if> <if test="couponReceived != null">coupon_received,</if>
...@@ -120,6 +126,7 @@ ...@@ -120,6 +126,7 @@
<if test="confId != null">#{confId},</if> <if test="confId != null">#{confId},</if>
<if test="couponId != null">#{couponId},</if> <if test="couponId != null">#{couponId},</if>
<if test="points != null">#{points},</if> <if test="points != null">#{points},</if>
<if test="currentMonth != null">#{currentMonth},</if>
<if test="lastConsumptionTime != null">#{lastConsumptionTime},</if> <if test="lastConsumptionTime != null">#{lastConsumptionTime},</if>
<if test="isReceive != null">#{isReceive},</if> <if test="isReceive != null">#{isReceive},</if>
<if test="couponReceived != null">#{couponReceived},</if> <if test="couponReceived != null">#{couponReceived},</if>
...@@ -141,6 +148,7 @@ ...@@ -141,6 +148,7 @@
<if test="confId != null">conf_id = #{confId},</if> <if test="confId != null">conf_id = #{confId},</if>
<if test="couponId != null">coupon_id = #{couponId},</if> <if test="couponId != null">coupon_id = #{couponId},</if>
<if test="points != null">points = #{points},</if> <if test="points != null">points = #{points},</if>
<if test="currentMonth != null">current_month = #{currentMonth},</if>
<if test="lastConsumptionTime != null">last_consumption_time = #{lastConsumptionTime},</if> <if test="lastConsumptionTime != null">last_consumption_time = #{lastConsumptionTime},</if>
<if test="isReceive != null">is_receive = #{isReceive},</if> <if test="isReceive != null">is_receive = #{isReceive},</if>
<if test="couponReceived != null">coupon_received = #{couponReceived},</if> <if test="couponReceived != null">coupon_received = #{couponReceived},</if>
......
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