Commit 4f715c7b by huluobin

update

parent 8c9fbe03
......@@ -83,7 +83,9 @@ public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustom
.collect(Collectors.toList()));
} else {
canUserServeIds.retainAll(orderServeList.stream()
.filter(orderServe -> orderServe.getBindCoupon() == 2)
.filter(orderServe -> {
return orderServe.getBindCoupon() == 2;
})
.filter(orderServe -> {
if (orderServe.getProduceId() != null) {
return orderServe.getProduceCurrentPrice().compareTo(orderServe.getProduceBargainPrice()) > -1;
......
......@@ -308,17 +308,17 @@ public class MarketServiceImpl implements MarketService {
});
//2.闲时折扣结算
orderManage.getListOrderServer().forEach(orderServe -> {
//服务折扣金额等于闲时折扣金额
orderServe.setDiscountPrice(orderServe.getLeisureDiscountPrice());
//服务支付金额-闲时折扣金额
orderServe.setPayPrice(orderServe.getPayPrice().subtract(orderServe.getLeisureDiscountPrice()));
//总支付金额- 闲时折扣基恩
orderManage.setTotalPaymentAmount(orderManage.getTotalPaymentAmount().subtract(orderServe.getLeisureDiscountPrice()));
//总折扣金额 + = 闲时折扣金额
orderManage.setDiscountPrice(orderManage.getDiscountPrice().add(orderServe.getLeisureDiscountPrice()));
});
// //2.闲时折扣结算
// orderManage.getListOrderServer().forEach(orderServe -> {
// //服务折扣金额等于闲时折扣金额
// orderServe.setDiscountPrice(orderServe.getLeisureDiscountPrice());
// //服务支付金额-闲时折扣金额
// orderServe.setPayPrice(orderServe.getPayPrice().subtract(orderServe.getLeisureDiscountPrice()));
// //总支付金额- 闲时折扣基恩
// orderManage.setTotalPaymentAmount(orderManage.getTotalPaymentAmount().subtract(orderServe.getLeisureDiscountPrice()));
// //总折扣金额 + = 闲时折扣金额
// orderManage.setDiscountPrice(orderManage.getDiscountPrice().add(orderServe.getLeisureDiscountPrice()));
// });
//3.次卡
......
......@@ -163,8 +163,8 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
//服务价格
.price(baseServe.getPrice())
.payPrice(baseServe.getPrice())
.achievement(baseServe.getPrice())
.leisureDiscountPrice(BigDecimal.ZERO);
.achievement(baseServe.getPrice());
// .leisureDiscountPrice(BigDecimal.ZERO);
//款式信息
if (orderServeParam.getProduceId() != null) {
......@@ -223,7 +223,7 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
builder.serveChangePrice(orderServeParam.getServeChangePrice());
}
OrderServe orderServe = builder.build();
orderServe.setPayPrice(orderServe.getPrice().add(orderServe.getServeChangePrice().subtract(orderServe.getDiscountPrice())));
orderServe.calcPrice();
orderServeMapper.insert(orderServe);
}
......@@ -233,7 +233,6 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
OrderServe orderServe = orderServeMapper.selectById(orderServeParam.getId());
//服务改价
orderServe.setServeChangePrice(orderServeParam.getServeChangePrice());
//服务id
......@@ -309,8 +308,7 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
orderServe.setCommentStatus(orderServeParam.getCommentStatus());
//订单服务备注
orderServe.setRemark(orderServeParam.getRemark());
//订单服务支付金额
orderServe.setPayPrice(orderServe.getPrice().add(orderServe.getServeChangePrice().subtract(orderServe.getDiscountPrice())));
orderServe.calcPrice();
orderServeMapper.updateById(orderServe);
}
});
......
......@@ -28,7 +28,6 @@ import com.gogirl.dto.LeisureScheduleServe;
import com.gogirl.dto.LeisureScheduleServeQuery;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.CloneUtil;
import com.gogirl.infrastructure.common.util.DateUtils;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.config.GogirlProperties;
......@@ -72,7 +71,7 @@ import static com.gogirl.domain.order.serve.OrderServe.COMMENT_STATUS_NO;
@Service
@AllArgsConstructor
@Slf4j
@Transactional
@Transactional(rollbackFor = Exception.class)
public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper, ScheduleManage> implements ScheduleManageService {
......@@ -1116,18 +1115,16 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
if (scheduleManage == null) {
scheduleManage = new ScheduleManage();
scheduleManage.setScheduledUser(cmd.getScheduledUser());
//获取预约号
String scheduleNo = this.getScheduleNo(storeManage.getId());
scheduleManage.setScheduledNo(scheduleNo);
}
scheduleManage.setDepartmentId(cmd.getDepartmentId());
scheduleManage.setArriveTime(cmd.getArriveTime());
scheduleManage.setDepartmentName(storeManage.getName());
//设置服务店铺姓名
//获取预约号
String scheduleNo = this.getScheduleNo(storeManage.getId());
if (scheduleManage.getScheduledNo() == null) {
scheduleManage.setScheduledNo(scheduleNo);
}
Customer customer = customerService.getById(scheduleManage.getScheduledUser());
//预约类型:小程序预约
......@@ -1170,8 +1167,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//预约结束时间
scheduleServe.setEndTime(scheduleServeCommand.getEndTime());
//闲时折扣
if (scheduleServeCommand.getLeisureDiscountConfigId() != null) {
scheduleServe.setLeisureDiscountConfigId(scheduleServeCommand.getLeisureDiscountConfigId());
if (scheduleServe.getLeisureDiscountConfigId() != null) {
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServe.getLeisureDiscountConfigId());
scheduleServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
}
......@@ -1203,7 +1200,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//款式现价
scheduleServe.setProduceCurrentPrice(baseProduce.getCurrentPrice());
//如果有款式就设置款式价格
scheduleServe.setPrice(baseProduce.getCurrentPrice());
// scheduleServe.setPrice(baseProduce.getCurrentPrice());
//款式时间
scheduleServe.setLengthTime(baseProduce.getServiceDuration());
......@@ -1213,18 +1210,18 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
scheduleServe.setProducePromotionTimeId(producePromotionTime.getId());
//活动价格
scheduleServe.setPromotionPrice(producePromotionTime.getPrice());
//价格活动价格
scheduleServe.setPrice(producePromotionTime.getPrice());
}
}
//如果是预约的服务
else {
//设置价格为服务价格
scheduleServe.setPrice(baseServe.getPrice());
scheduleServe.setLengthTime(baseServe.getServiceDuration());
}
//款式做法
scheduleServe.setExplain(baseServe.getExplain());
//计算价格
scheduleServe.calcPrice();
return scheduleServe;
})
//多个美甲师id拆分
......@@ -1385,8 +1382,6 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//订单服务折扣金额
orderManage.setChangePrice(orderManage.getChangePrice().add(orderServe.getServeChangePrice()));
int weekday = DateUtils.getWeek(orderServe.getStartTime());
//订单实际对应的折扣
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectById(scheduleServeVar.getLeisureDiscountConfigId());
......@@ -1396,12 +1391,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
//设置折扣属性
orderServe.setLeisureDiscountConfigId(leisureDiscountConfig.getId());
orderServe.setLeisureDiscountPrice(leisureDiscountPrice);
orderServe.setPayPrice(orderServe.getPayPrice().subtract(orderServe.getLeisureDiscountPrice()));
//设置订单属性
orderManage.setDiscountPrice(orderManage.getDiscountPrice().add(orderServe.getLeisureDiscountPrice()));
orderManage.setTotalPaymentAmount(orderManage.getTotalPaymentAmount().subtract(orderServe.getLeisureDiscountPrice()));
orderServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
//更新订单实际折扣的使用次数
leisureDiscountConfig.setLeftTimes(leisureDiscountConfig.getLeftTimes() - 1);
......
......@@ -30,6 +30,6 @@ public interface BaseServeService extends IService<BaseServe> {
* @param date
* @return
*/
BaseServe getAggregate(Integer id, LocalDateTime date);
BaseServe getAggregate(Integer id, LocalDateTime date,Integer departmentId);
}
......@@ -5,15 +5,12 @@ 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.common.util.DateUtils;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseServeMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.sql.Time;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@Service
......@@ -30,10 +27,13 @@ public class BaseServeServiceImpl extends ServiceImpl<BaseServeMapper, BaseServe
}
@Override
public BaseServe getAggregate(Integer id, LocalDateTime date) {
public BaseServe getAggregate(Integer id, LocalDateTime date, Integer departmentId) {
BaseServe baseServe = baseServeMapper.getAggregate(id);
if (date != null) {
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectLeisureDiscount(id, date.toLocalTime().toString(), date.getDayOfWeek().getValue());
LeisureDiscountConfig leisureDiscountConfig = leisureDiscountConfigMapper.selectLeisureDiscount(id,
date.toLocalTime().toString(),
date.getDayOfWeek().getValue(),
departmentId);
if (leisureDiscountConfig != null)
baseServe.setDiscountRate(leisureDiscountConfig.getDiscountRate());
}
......
......@@ -59,8 +59,8 @@ public class OrderServe implements Serializable {
private BigDecimal discountPrice = BigDecimal.ZERO;
@ApiModelProperty("支付金额")
private BigDecimal payPrice = BigDecimal.ZERO;
@ApiModelProperty("闲时折扣减免的金额")
private BigDecimal leisureDiscountPrice = BigDecimal.ZERO;
// @ApiModelProperty("闲时折扣减免的金额")
// private BigDecimal leisureDiscountPrice = BigDecimal.ZERO;
/**
* 预约服务vo
*/
......@@ -195,8 +195,44 @@ public class OrderServe implements Serializable {
private Integer producePromotionTimeId;
private BigDecimal discountRate;
private BigDecimal leisurePrice;
//
// @ApiModelProperty("各种活动价格最终确定的活动价格")
// private BigDecimal activityPrice;
public void addDiscountPrice(BigDecimal discountPrice) {
this.discountPrice = this.discountPrice.add(discountPrice);
this.payPrice = this.price.subtract(discountPrice);
}
public void calcPrice() {
if (produceId == null) {
if (discountRate == null) {
price = servePrice;
} else {
price = servePrice.multiply(BigDecimal.ONE.subtract(discountRate));
leisurePrice = price;
// leisureDiscountPrice = servePrice.multiply(discountRate);
}
} else {
leisurePrice = produceBargainPrice.multiply(BigDecimal.ONE.subtract(discountRate));
// leisureDiscountPrice = produceBargainPrice.multiply(discountRate);
//没有活动价格
if (promotionPrice == null) {
price = leisurePrice.min(produceCurrentPrice);
}
//有活动价
else {
price = leisurePrice.min(produceCurrentPrice).min(promotionPrice);
}
}
}
public Boolean isActivity() {
return price.equals(leisurePrice) ||
price.equals(promotionPrice) ||
(price.equals(produceCurrentPrice) && produceCurrentPrice.compareTo(produceBargainPrice) > -1);
}
}
\ No newline at end of file
......@@ -181,4 +181,35 @@ public class ScheduleServe implements Serializable {
private Integer producePromotionTimeId;
private BigDecimal leisurePrice;
public void calcPrice() {
if (produceId == null) {
if (discountRate == null) {
price = servePrice;
} else {
price = servePrice.multiply(BigDecimal.ONE.subtract(discountRate));
leisurePrice = price;
// leisureDiscountPrice = servePrice.multiply(discountRate);
}
} else {
leisurePrice = produceBargainPrice.multiply(BigDecimal.ONE.subtract(discountRate));
// leisureDiscountPrice = produceBargainPrice.multiply(discountRate);
//没有活动价格
if (promotionPrice == null) {
price = leisurePrice.min(produceCurrentPrice);
}
//有活动价
else {
price = leisurePrice.min(produceCurrentPrice).min(promotionPrice);
}
}
}
public Boolean isActivity() {
return price.equals(leisurePrice) ||
price.equals(promotionPrice) ||
(price.equals(produceCurrentPrice) && produceCurrentPrice.compareTo(produceBargainPrice) > -1);
}
}
......@@ -37,7 +37,8 @@ public interface LeisureDiscountConfigMapper extends BaseMapper<LeisureDiscountC
*/
LeisureDiscountConfig selectLeisureDiscount(@Param("serviceId") Integer serviceId,
@Param("time") String time,
@Param("weekday") int weekday);
@Param("weekday") int weekday,
@Param("departmentId") int departmentId);
/**
......
package com.gogirl.interfaces.product.serve;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gogirl.application.product.serve.BaseProduceService;
......@@ -17,13 +16,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cglib.core.Local;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -48,9 +44,10 @@ public class ServeController {
@GetMapping("/customer/serve/getServeDetail")
public JsonResult<BaseServe> getServeDetail(@RequestParam Integer id,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss",iso=DateTimeFormat.ISO.DATE_TIME) LocalDateTime date) {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss", iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime date,
@RequestParam Integer departmentId) {
BaseServe baseServe = baseServeService.getAggregate(id, date);
BaseServe baseServe = baseServeService.getAggregate(id, date, departmentId);
return JsonResult.success(baseServe);
}
......@@ -95,9 +92,11 @@ public class ServeController {
@ApiOperation(value = "查看服务详情")
@GetMapping("/technician/serve/getServeDetail")
public JsonResult<BaseServe> technicianGetServeDetail(@RequestParam Integer id,
@RequestParam(required = false) LocalDateTime date) {
BaseServe baseServe = baseServeService.getAggregate(id, date);
public JsonResult<BaseServe> techGetServeDetail(@RequestParam Integer id,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss", iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime date,
@RequestParam Integer departmentId) {
BaseServe baseServe = baseServeService.getAggregate(id, date, departmentId);
return JsonResult.success(baseServe);
}
......
......@@ -122,4 +122,14 @@ public class ScheduleServeDTO implements Serializable {
private Integer actualServeDuration;
private BigDecimal promotionPrice;
private Integer producePromotionTimeId;
private BigDecimal leisurePrice;
@ApiModelProperty("服务价格")
private BigDecimal price = BigDecimal.ZERO;
}
......@@ -106,8 +106,11 @@ public class OrderServeDTO {
@ApiModelProperty("订单详情服务美甲师")
private List<StoreTechnicianDTO> storeTechnicianDTOList;
private Integer actualServeDuration;
private Integer bindCoupon;
private BigDecimal discountRate;
private BigDecimal leisurePrice;
}
......@@ -49,6 +49,7 @@
and t1.is_enabled = 1
and t3.week = #{weekday}
and t1.left_times &gt; 0
and t1.department_id = #{departmentId}
limit 1
</select>
......
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