Commit 5c9384a3 by huluobin

闲时折扣

parent 5d964a5e
......@@ -55,6 +55,7 @@ import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.ExecutionException;
......@@ -1000,8 +1001,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
.collect(Collectors.toList());
//设置从服务的时间为主服务时间 因为主服务的时间已经包括的从服务的时间
subScheduleServeCommandList
.forEach(scheduleServeCommand -> {
subScheduleServeCommandList.forEach(scheduleServeCommand -> {
ScheduleServeCommand mainScheduleServeCommand = mainScheduleServeCommandList.stream()
.filter(var -> var.getServeId().equals(scheduleServeCommand.getMainServeId()))
.findAny()
......@@ -1081,11 +1081,17 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//预约结束时间
scheduleServe.setEndTime(scheduleServeCommand.getEndTime());
if (scheduleServe.getLeisureDiscountConfigId() != null) {
this.backLeisureDiscountConfig(scheduleServe);
}
//闲时折扣
if (scheduleServeCommand.getLeisureDiscountConfigId() != null) {
scheduleServe.setLeisureDiscountConfigId(scheduleServeCommand.getLeisureDiscountConfigId());
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
scheduleServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
// LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
// scheduleServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
}
if (scheduleServeCommand.getActualStartTime() != null) {
scheduleServe.setActualStartTime(scheduleServeCommand.getActualStartTime());
......@@ -1171,6 +1177,21 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//计算价格
scheduleServe.calcPriceAndTimeLength();
if (scheduleServe.getLeisureDiscountConfigId() != null) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(scheduleServe.getStartTime().toInstant(), ZoneId.systemDefault());
LeisureScheduleServeResp leisureScheduleServeResp = leisureDiscountConfigLimitMapper.selectOneLeisureDiscountConfig(scheduleServe.getLeisureDiscountConfigId(),
scheduleServe.getServeId(),
localDateTime.toLocalTime(),
localDateTime.toLocalDate());
if (leisureScheduleServeResp != null) {
scheduleServe.setDiscountRate(leisureScheduleServeResp.getDiscountRate());
}
else{
scheduleServe.setLeisurePrice(null);
scheduleServe.setLeisureDiscountConfigId(null);
}
}
return scheduleServe;
})
//多个美甲师id拆分
......
......@@ -132,6 +132,7 @@ public class ScheduleServe implements Serializable {
@ApiModelProperty("售后说明")
private String explain;
@TableField(strategy = FieldStrategy.IGNORED)
private Integer leisureDiscountConfigId;
......@@ -185,6 +186,7 @@ public class ScheduleServe implements Serializable {
private Integer producePromotionTimeId;
@TableField(strategy = FieldStrategy.IGNORED)
private BigDecimal leisurePrice;
@ApiModelProperty("是否自带款式 1-是 2-否")
......
......@@ -2,6 +2,11 @@ package com.gogirl.infrastructure.mapper.market.discount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.market.discount.LeisureDiscountConfigLimit;
import com.gogirl.shared.product.LeisureScheduleServeResp;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.time.LocalTime;
/**
* <p>
......@@ -16,4 +21,11 @@ public interface LeisureDiscountConfigLimitMapper extends BaseMapper<LeisureDisc
void syncWeekConfigLimit();
LeisureDiscountConfigLimit selectConfigLimit(String date, Integer leisureDiscountConfigId);
LeisureScheduleServeResp selectOneLeisureDiscountConfig(@Param("leisureDiscountConfigId") Integer leisureDiscountConfigId,
@Param("serveId") Integer serveId,
@Param("time") LocalTime time,
@Param("date") LocalDate date)
}
......@@ -16,4 +16,37 @@
where t1.date = #{date}
and t1.leisure_discount_config_id = #{leisureDiscountConfigId}
</select>
<select id="selectOneLeisureDiscountConfig"
resultType="com.gogirl.shared.product.LeisureScheduleServeResp">
SELECT t1.id as leisure_discount_config_id,
t1.discount_rate,
t1.department_id,
t5.time_node,
t7.week_date,
t6.id as serve_id,
t6.`name` as serve_name,
t8.`name` as department_name,
t8.latitude,
t8.longitude
from leisure_discount_config t1
LEFT JOIN leisure_discount_config_week t2 on t1.id = t2.leisure_discount_config_id
LEFT JOIN leisure_discount_config_service t3 on t1.id = t3.leisure_discount_config_id
LEFT JOIN time_node t5 on t1.start_time &lt;= t5.time_node and t1.end_time &gt;= t5.time_node
LEFT JOIN base_serve t6 on t3.service_id = t6.id
LEFT JOIN week_config t7 on t2.`week` = t7.`week`
LEFT JOIN store_manage t8 on t1.department_id = t8.id
LEFT JOIN leisure_discount_config_limit t9
on t1.id = t9.leisure_discount_config_id and t9.left_times > 0 and
t7.week_date = t9.date
where t1.is_enabled = 1
and t2.id is not null
and t3.id is not null
and t9.id is not null
and t1.id = #{leisureDiscountConfigId}
and t3.service_id = #{serveId}
and t5.time_node = #{time}
and t7.week_date = #{date}
limit 1
</select>
</mapper>
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