Commit 13162f3c by huluobin

闲时折扣

parent 688812e4
......@@ -470,6 +470,16 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
return bool;
}
private void backLeisureDiscountConfig(String date, ScheduleServe scheduleServe) {
if (scheduleServe.getLeisureDiscountConfigId() != null) {
LeisureDiscountConfigLimit leisureDiscountConfigLimit = leisureDiscountConfigLimitMapper.selectConfigLimit(date, scheduleServe.getLeisureDiscountConfigId());
if (leisureDiscountConfigLimit != null) {
leisureDiscountConfigLimit.setLeftTimes(leisureDiscountConfigLimit.getLeftTimes() + 1);
leisureDiscountConfigLimitMapper.updateById(leisureDiscountConfigLimit);
}
}
}
@Override
public void cancelSchedule(CancelScheduleCommand cmd) {
......@@ -484,13 +494,10 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
scheduleManage.setStatus(ScheduleManage.STATUS_CANCEL_SCHEDULED);
List<ScheduleServe> scheduleServeList = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, scheduleManage.getId()));
scheduleServeList.forEach(scheduleServe -> {
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
if (leisureDiscountConfig != null) {
leisureDiscountConfig.setLeftTimes(leisureDiscountConfig.getLeftTimes() + 1);
leisureDiscountConfigMapper.updateById(leisureDiscountConfig);
}
});
String date = new SimpleDateFormat("yyyy-MM-dd").format(scheduleManage.getScheduledTime() != null ? scheduleManage.getScheduledTime() : scheduleManage.getArriveTime());
scheduleServeList.forEach(scheduleServe -> this.backLeisureDiscountConfig(date, scheduleServe));
scheduleManageMapper.updateById(scheduleManage);
......@@ -686,7 +693,6 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
}
}
@Override
public List<Map<String, Object>> queryReservableTime(String startDate, Integer lengthTime, Integer departmentId, Integer orderId, Boolean needRemoveOldServe) {
if (startDate == null || lengthTime == null) {
......@@ -927,15 +933,9 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
oldScheduleServeList = Lists.newArrayList();
}
String date = new SimpleDateFormat("yyyy-MM-dd").format(scheduleManage.getScheduledTime() != null ? scheduleManage.getScheduledTime() : scheduleManage.getArriveTime());
oldScheduleServeList.forEach(scheduleServe -> {
if (scheduleServe.getLeisureDiscountConfigId() != null) {
LeisureDiscountConfigLimit leisureDiscountConfigLimit = leisureDiscountConfigLimitMapper.selectConfigLimit(date, scheduleServe.getLeisureDiscountConfigId());
if (leisureDiscountConfigLimit != null) {
leisureDiscountConfigLimit.setLeftTimes(leisureDiscountConfigLimit.getLeftTimes() + 1);
leisureDiscountConfigLimitMapper.updateById(leisureDiscountConfigLimit);
}
}
});
oldScheduleServeList.forEach(scheduleServe -> this.backLeisureDiscountConfig(date, scheduleServe));
scheduleManage.getListScheduleServer().forEach(scheduleServe -> {
if (scheduleServe.getLeisureDiscountConfigId() != null) {
......@@ -951,7 +951,6 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
});
}
/**
* 参数补全
*
......@@ -1439,22 +1438,6 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
return 3;
}
private void addLeisureTechServe(List<LeisureTechServe> leisureTechServeList, Integer technicianId, Integer serveId) {
leisureTechServeList.stream()
.filter(leisureTechServe -> leisureTechServe.getServeId().equals(serveId))
.findAny()
.map(leisureTechServe -> leisureTechServe.getTechnicianIdList().add(technicianId))
.orElseGet(() -> {
LeisureTechServe leisureTechServe = new LeisureTechServe();
leisureTechServe.setServeId(serveId);
Set<Integer> set = new HashSet<>();
set.add(technicianId);
leisureTechServe.setTechnicianIdList(set);
leisureTechServeList.add(leisureTechServe);
return null;
});
}
/**
* 店铺短码-服务短码(s)-美甲师短码-时间-4位最大单号
*
......
......@@ -4,7 +4,6 @@ package com.gogirl.application.product.serve.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.product.serve.BaseServeService;
import com.gogirl.domain.market.discount.LeisureDiscountConfig;
import com.gogirl.domain.product.serve.BaseServe;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseServeMapper;
......@@ -30,16 +29,7 @@ public class BaseServeServiceImpl extends ServiceImpl<BaseServeMapper, BaseServe
@Override
public BaseServe getAggregate(Integer id, LocalDateTime date, Integer departmentId) {
BaseServe baseServe = baseServeMapper.selectById(id);
if (date != null) {
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectLeisureDiscount(id,
date.toLocalTime().toString(),
date.getDayOfWeek().getValue(),
departmentId);
if (leisureDiscountConfig != null)
baseServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
}
return baseServe;
return baseServeMapper.selectById(id);
}
}
......@@ -2,71 +2,17 @@ package com.gogirl.infrastructure.mapper.market.discount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.market.discount.LeisureDiscountConfig;
import com.gogirl.domain.product.serve.BaseServe;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface LeisureDiscountConfigMapper extends BaseMapper<LeisureDiscountConfig> {
/**
* 获取店铺对应星期数的打折服务列表
*
* @param departmentId 店铺id
* @param week 周几
* @return 服务列表
*/
List<BaseServe> selectByDepartmentId(@Param("departmentId") Integer departmentId, @Param("week") int week);
/**
* 获取折扣最低的闲时折扣
*
* @return discount
*/
LeisureDiscountConfig queryMinDiscount();
/**
* 获取时间,服务,周几对应的折扣
*
* @param time 时间形如'10:00'
* @param serviceId 服务id
* @param weekday 周几
* @return 折扣列表
*/
LeisureDiscountConfig selectLeisureDiscount(@Param("serviceId") Integer serviceId,
@Param("time") String time,
@Param("weekday") int weekday,
@Param("departmentId") int departmentId);
/**
* 获取店铺id,星期数,时间段形如'10:00'对应的折扣列表 忽略剩余次数条件
*
* @param departmentId 店铺Id
* @param finalWeekday 星期几
* @param time 时间形如
* @return list
*/
List<BaseServe> selectByDepartmentIdAndWeekAndDateTime(@Param("departmentId") Integer departmentId, @Param("week") int finalWeekday, @Param("time") String time);
/**
* 获取店铺id,星期数对应的折扣列表 忽略剩余次数条件
*
* @param departmentId 店铺Id
* @param weekday 星期几
* @return list
*/
List<LeisureDiscountConfig> selectByDepartmentIdAndWeekIgnoreLimit(@Param("departmentId") Integer departmentId, @Param("week") int weekday);
/**
* 获取时间,服务,周几对应的折扣列表
*
* @param time 时间形如'10:00'
* @param serveId 服务id
* @param weekday 周几
* @return 折扣列表
*/
List<LeisureDiscountConfig> selectIsLeisureTime(@Param("time") String time, @Param("serveId") Integer serveId, @Param("week") int weekday);
}
......@@ -2,31 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigMapper">
<select id="selectIsLeisureTime" resultType="com.gogirl.domain.market.discount.LeisureDiscountConfig">
select *
from leisure_discount_config t1
left join leisure_discount_config_service t2 on t1.id = t2.leisure_discount_config_id
left join leisure_discount_config_week t4 on t1.id = t4.leisure_discount_config_id
where t1.start_time &lt;= #{time}
and t1.end_time &gt;= #{time}
and t2.service_id = #{serveId}
and t1.is_enabled = 1
and t1.left_times &gt; 0
and t4.week = #{week}
</select>
<select id="selectByDepartmentId" resultType="com.gogirl.domain.product.serve.BaseServe">
select t3.*
from leisure_discount_config t1
left join leisure_discount_config_service t2 on t1.id = t2.leisure_discount_config_id
left join leisure_discount_config_week t4 on t1.id = t4.leisure_discount_config_id
left join base_serve t3 on t2.service_id = t3.id
where t1.department_id = #{departmentId}
and t1.left_times &gt; 0
and t1.is_enabled = 1
and t3.id is not null
and t4.week = #{week}
</select>
<select id="queryMinDiscount" resultType="com.gogirl.domain.market.discount.LeisureDiscountConfig">
select *
......@@ -37,44 +13,5 @@
limit 1
</select>
<select id="selectLeisureDiscount" resultType="com.gogirl.domain.market.discount.LeisureDiscountConfig">
SELECT *
from leisure_discount_config t1
LEFT JOIN leisure_discount_config_service t2 on t1.id = t2.leisure_discount_config_id
LEFT JOIN leisure_discount_config_week t3 on t1.id = t3.leisure_discount_config_id
where t2.service_id = #{serviceId}
and t1.start_time &lt;= #{time}
and t1.end_time &gt;= #{time}
and t1.is_enabled = 1
and t3.week = #{weekday}
and t1.left_times &gt; 0
and t1.department_id = #{departmentId}
limit 1
</select>
<select id="selectByDepartmentIdAndWeekAndDateTime" resultType="com.gogirl.domain.product.serve.BaseServe">
select t3.*
from leisure_discount_config t1
left join leisure_discount_config_service t2 on t1.id = t2.leisure_discount_config_id
left join leisure_discount_config_week t4 on t1.id = t4.leisure_discount_config_id
left join base_serve t3 on t2.service_id = t3.id
where t1.department_id = #{departmentId}
and t1.is_enabled = 1
and t3.id is not null
and t4.week = #{week}
and t1.start_time &lt;= #{time}
and t1.end_time &gt;= #{time}
and t1.left_times &gt; 0
</select>
<select id="selectByDepartmentIdAndWeekIgnoreLimit"
resultType="com.gogirl.domain.market.discount.LeisureDiscountConfig">
select *
from leisure_discount_config t1
left join leisure_discount_config_week t2 on t1.id = t2.leisure_discount_config_id
where t1.department_id
and t2.week = #{week}
and t1.is_enabled = 1
</select>
</mapper>
\ No newline at end of file
</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