Commit 5c9384a3 by huluobin

闲时折扣

parent 5d964a5e
...@@ -55,6 +55,7 @@ import java.math.BigDecimal; ...@@ -55,6 +55,7 @@ import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -1000,29 +1001,28 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper, ...@@ -1000,29 +1001,28 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
.collect(Collectors.toList()); .collect(Collectors.toList());
//设置从服务的时间为主服务时间 因为主服务的时间已经包括的从服务的时间 //设置从服务的时间为主服务时间 因为主服务的时间已经包括的从服务的时间
subScheduleServeCommandList subScheduleServeCommandList.forEach(scheduleServeCommand -> {
.forEach(scheduleServeCommand -> { ScheduleServeCommand mainScheduleServeCommand = mainScheduleServeCommandList.stream()
ScheduleServeCommand mainScheduleServeCommand = mainScheduleServeCommandList.stream() .filter(var -> var.getServeId().equals(scheduleServeCommand.getMainServeId()))
.filter(var -> var.getServeId().equals(scheduleServeCommand.getMainServeId())) .findAny()
.findAny() .orElseThrow(NullPointerException::new);
.orElseThrow(NullPointerException::new);
//设置辅助服务美甲师为主服务美甲师
//设置辅助服务美甲师为主服务美甲师 scheduleServeCommand.setTechnicianId(mainScheduleServeCommand.getTechnicianId());
scheduleServeCommand.setTechnicianId(mainScheduleServeCommand.getTechnicianId()); scheduleServeCommand.setTechnicianIds(mainScheduleServeCommand.getTechnicianIds());
scheduleServeCommand.setTechnicianIds(mainScheduleServeCommand.getTechnicianIds()); scheduleServeCommand.setStartTime(mainScheduleServeCommand.getStartTime());
scheduleServeCommand.setStartTime(mainScheduleServeCommand.getStartTime()); scheduleServeCommand.setEndTime(mainScheduleServeCommand.getEndTime());
scheduleServeCommand.setEndTime(mainScheduleServeCommand.getEndTime());
//如果主服务已经开单 并且更新 同步主服务的开始时间
//如果主服务已经开单 并且更新 同步主服务的开始时间 ScheduleServe mainScheduleServe = scheduleServeMapper.selectById(mainScheduleServeCommand.getId());
ScheduleServe mainScheduleServe = scheduleServeMapper.selectById(mainScheduleServeCommand.getId()); if (mainScheduleServe != null && mainScheduleServe.getActualStartTime() != null) {
if (mainScheduleServe != null && mainScheduleServe.getActualStartTime() != null) { scheduleServeCommand.setActualStartTime(mainScheduleServe.getActualStartTime());
scheduleServeCommand.setActualStartTime(mainScheduleServe.getActualStartTime()); }
} //如果主服务已经结单 不能再添加辅助服务
//如果主服务已经结单 不能再添加辅助服务 if (mainScheduleServe != null && mainScheduleServe.getStatus() == 3) {
if (mainScheduleServe != null && mainScheduleServe.getStatus() == 3) { throw new RRException("不能再为已完成的服务添加辅助服务");
throw new RRException("不能再为已完成的服务添加辅助服务"); }
} });
});
ScheduleManage scheduleManage = scheduleManageMapper.selectById(cmd.getId()); ScheduleManage scheduleManage = scheduleManageMapper.selectById(cmd.getId());
StoreManage storeManage = storeManageMapper.selectById(cmd.getDepartmentId()); StoreManage storeManage = storeManageMapper.selectById(cmd.getDepartmentId());
...@@ -1081,11 +1081,17 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper, ...@@ -1081,11 +1081,17 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//预约结束时间 //预约结束时间
scheduleServe.setEndTime(scheduleServeCommand.getEndTime()); scheduleServe.setEndTime(scheduleServeCommand.getEndTime());
if (scheduleServe.getLeisureDiscountConfigId() != null) {
this.backLeisureDiscountConfig(scheduleServe);
}
//闲时折扣 //闲时折扣
if (scheduleServeCommand.getLeisureDiscountConfigId() != null) { if (scheduleServeCommand.getLeisureDiscountConfigId() != null) {
scheduleServe.setLeisureDiscountConfigId(scheduleServeCommand.getLeisureDiscountConfigId()); scheduleServe.setLeisureDiscountConfigId(scheduleServeCommand.getLeisureDiscountConfigId());
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId()); // LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
scheduleServe.setDiscountRate(leisureDiscountConfig.getDiscountRate()); // scheduleServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
} }
if (scheduleServeCommand.getActualStartTime() != null) { if (scheduleServeCommand.getActualStartTime() != null) {
scheduleServe.setActualStartTime(scheduleServeCommand.getActualStartTime()); scheduleServe.setActualStartTime(scheduleServeCommand.getActualStartTime());
...@@ -1171,6 +1177,21 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper, ...@@ -1171,6 +1177,21 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//计算价格 //计算价格
scheduleServe.calcPriceAndTimeLength(); 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; return scheduleServe;
}) })
//多个美甲师id拆分 //多个美甲师id拆分
......
...@@ -132,6 +132,7 @@ public class ScheduleServe implements Serializable { ...@@ -132,6 +132,7 @@ public class ScheduleServe implements Serializable {
@ApiModelProperty("售后说明") @ApiModelProperty("售后说明")
private String explain; private String explain;
@TableField(strategy = FieldStrategy.IGNORED)
private Integer leisureDiscountConfigId; private Integer leisureDiscountConfigId;
...@@ -185,6 +186,7 @@ public class ScheduleServe implements Serializable { ...@@ -185,6 +186,7 @@ public class ScheduleServe implements Serializable {
private Integer producePromotionTimeId; private Integer producePromotionTimeId;
@TableField(strategy = FieldStrategy.IGNORED)
private BigDecimal leisurePrice; private BigDecimal leisurePrice;
@ApiModelProperty("是否自带款式 1-是 2-否") @ApiModelProperty("是否自带款式 1-是 2-否")
......
...@@ -2,6 +2,11 @@ package com.gogirl.infrastructure.mapper.market.discount; ...@@ -2,6 +2,11 @@ package com.gogirl.infrastructure.mapper.market.discount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.market.discount.LeisureDiscountConfigLimit; 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> * <p>
...@@ -16,4 +21,11 @@ public interface LeisureDiscountConfigLimitMapper extends BaseMapper<LeisureDisc ...@@ -16,4 +21,11 @@ public interface LeisureDiscountConfigLimitMapper extends BaseMapper<LeisureDisc
void syncWeekConfigLimit(); void syncWeekConfigLimit();
LeisureDiscountConfigLimit selectConfigLimit(String date, Integer leisureDiscountConfigId); 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 @@ ...@@ -16,4 +16,37 @@
where t1.date = #{date} where t1.date = #{date}
and t1.leisure_discount_config_id = #{leisureDiscountConfigId} and t1.leisure_discount_config_id = #{leisureDiscountConfigId}
</select> </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> </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