Commit c7cea86e by 吕明尚

增加自动增加房间标签定时任务

parent 29341e77
...@@ -78,6 +78,12 @@ public class RedisTask { ...@@ -78,6 +78,12 @@ public class RedisTask {
@Autowired @Autowired
private TiktokService tiktokService; private TiktokService tiktokService;
@Autowired
private LabelService labelService;
@Autowired
private RoomLabelService roomLabelService;
//15分钟的常量 //15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15; final long FIFTEEN_MINUTES = 60 * 15;
...@@ -437,4 +443,49 @@ public class RedisTask { ...@@ -437,4 +443,49 @@ public class RedisTask {
}); });
} }
public void AutoAddRoomLabel() {
List<RoomLabel> roomLabelList = roomLabelService.list();
//获取roomLabelList中的roomId,去重
List<Long> roomIds = roomLabelList.stream().map(RoomLabel::getRoomId).distinct().collect(Collectors.toList());
List<SRoom> roomList = new ArrayList<>();
if (!CollectionUtils.isEmpty(roomIds)) {
LambdaQueryWrapper<SRoom> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.notIn(SRoom::getId, roomIds);
roomList = roomService.list(queryWrapper);
} else {
roomList = roomService.list();
}
if (CollectionUtils.isEmpty(roomList)) {
return;
}
List<RoomLabel> roomLabels = new ArrayList<>();
List<Label> labelList = labelService.list();
roomList.stream().forEach(room -> {
labelList.stream().forEach(label -> {
RoomLabel roomLabel = new RoomLabel();
roomLabel.setRoomId(room.getId());
roomLabel.setStoreId(room.getStoreId());
roomLabel.setLabelId(label.getId());
if (label.getType().equals(0L) && Integer.valueOf(label.getDuration()) >= 4 && Integer.valueOf(label.getDuration()) < 8) {
roomLabel.setPromotionDuration("4");
if (room.getPrice().equals(new BigDecimal("20"))) {
roomLabel.setPromotionAmount(new BigDecimal("49.90"));
} else if (room.getPrice().equals(new BigDecimal("25"))) {
roomLabel.setPromotionAmount(new BigDecimal("63.80"));
} else if (room.getPrice().equals(new BigDecimal("30"))) {
roomLabel.setPromotionAmount(new BigDecimal("83.80"));
}
} else if (label.getType().equals(0L) && Integer.parseInt(label.getDuration()) >= 8) {
roomLabel.setPromotionDuration("8");
roomLabel.setPromotionAmount(new BigDecimal("138"));
} else {
roomLabel.setPromotionDuration(String.valueOf(YesNoEnum.no.getIndex()));
roomLabel.setPromotionAmount(new BigDecimal("0"));
}
roomLabels.add(roomLabel);
});
});
if (!CollectionUtils.isEmpty(roomLabels)) roomLabelService.saveBatch(roomLabels);
}
} }
package share.system.domain; package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
...@@ -23,6 +25,7 @@ public class RoomLabel extends BaseEntity { ...@@ -23,6 +25,7 @@ public class RoomLabel extends BaseEntity {
/** /**
* ID * ID
*/ */
@TableId(type = IdType.AUTO)
private Long id; private Long id;
/** /**
......
...@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where 1=1 and coupon_type = #{couponType} where 1=1 and coupon_type = #{couponType}
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="startDate != null">and start_date &lt;= #{startDate}</if> <if test="startDate != null">and start_date &lt;= #{startDate}</if>
<if test="endDate == null">and end_date >= NOW()</if> <!-- <if test="endDate == null">and end_date >= NOW()</if> -->
<if test="endDate != null">and end_date >= #{endDate}</if> <if test="endDate != null">and end_date >= #{endDate}</if>
<if test="orderType != null">and order_type = #{orderType}</if> <if test="orderType != null">and order_type = #{orderType}</if>
<if test="packIds != null">and pack_ids = #{packIds}</if> <if test="packIds != null">and pack_ids = #{packIds}</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