Commit c885468c by wuwenlong

create order bugfix;

parent 9d57fc19
......@@ -2,6 +2,7 @@ package share.system.service;
import java.util.List;
import share.system.domain.SConsumptionRecords;
import share.system.domain.SOrder;
import share.system.domain.vo.SConsumptionRecordsVo;
/**
......@@ -37,6 +38,13 @@ public interface ISConsumptionRecordsService
public int insertSConsumptionRecords(SConsumptionRecords sConsumptionRecords);
/**
* 新增消费记录
*
* @param sOrder 消费记录
* @return 结果
*/
public int insertSConsumptionRecords(SOrder sOrder);
/**
* 修改消费记录
*
* @param sConsumptionRecords 消费记录
......
......@@ -6,6 +6,9 @@ import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import share.common.enums.ConsumeNameEnum;
import share.common.enums.PayTypeEnum;
import share.common.enums.SignEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -103,6 +106,19 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
return sConsumptionRecordsMapper.insertSConsumptionRecords(sConsumptionRecords);
}
@Override
public int insertSConsumptionRecords(SOrder sOrder) {
SConsumptionRecords sConsumptionRecords = new SConsumptionRecords();
sConsumptionRecords.setConsumerId(sOrder.getConsumerId());
sConsumptionRecords.setOrderId(sOrder.getId());
sConsumptionRecords.setName(ConsumeNameEnum.CONSUME.getValue());
sConsumptionRecords.setPrice(sOrder.getPayPrice());
sConsumptionRecords.setPayType(PayTypeEnum.WECHAT.getName());
sConsumptionRecords.setSign(SignEnum.BURDEN.getValue());
sConsumptionRecords.setCreateTime(DateUtils.getNowDate());
return sConsumptionRecordsMapper.insertSConsumptionRecords(sConsumptionRecords);
}
/**
* 修改消费记录
*
......
......@@ -312,18 +312,19 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
checkOrderDate(request);
//校验订单套餐
checkOrderPack(request, user);
SConsumerCoupon byId = null;
if (Objects.nonNull(request.getCouponId()) && request.getCouponId() != 0) {
SConsumerCoupon byId = consumerCouponService.getById(request.getCouponId());
byId = consumerCouponService.getById(request.getCouponId());
if (Objects.nonNull(byId)) {
if (byId.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
if (StringUtils.isNotEmpty(byId.getCouponCode())) {
qpService.prepare(byId.getCouponCode(), sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.ORDER.getCode());
}
} else {
throw new BaseException("优惠券不存在!");
throw new BaseException("优惠券已使用!");
}
} else {
throw new BaseException("优惠券已使用!");
throw new BaseException("优惠券不存在!");
}
}
OrderPayResultResponse response = new OrderPayResultResponse();
......@@ -342,37 +343,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
save(sOrder);
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
if (Objects.nonNull(request.getCouponId()) && request.getCouponId() != 0) {
SConsumerCoupon byId = consumerCouponService.getById(request.getCouponId());
if (StringUtils.isNotEmpty(byId.getCouponCode())) {
if (byId.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
if (Objects.nonNull(byId)) {
if (StringUtils.isNotEmpty(byId.getCouponCode())) {
//验劵
qpService.consume(byId.getCouponCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.ORDER.getCode());
}
} else {
throw new BaseException("优惠券已使用!");
}
}
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(request.getCouponId());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
}
SConsumptionRecords sConsumptionRecords = new SConsumptionRecords();
sConsumptionRecords.setConsumerId(sOrder.getConsumerId());
sConsumptionRecords.setOrderId(sOrder.getId());
sConsumptionRecords.setName(ConsumeNameEnum.CONSUME.getValue());
sConsumptionRecords.setPrice(sOrder.getPayPrice());
sConsumptionRecords.setPayType(PayTypeEnum.WECHAT.getName());
sConsumptionRecords.setSign(SignEnum.BURDEN.getValue());
sConsumptionRecordsService.insertSConsumptionRecords(sConsumptionRecords);
sConsumptionRecordsService.insertSConsumptionRecords(sOrder);
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
redisUtils.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
}
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
......@@ -385,12 +374,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_SUCCESS.getCode(),
cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
SRoom sRoom = roomService.getById(sOrder.getRoomId());
// //通知保洁人员
// sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> {
// // 循环发送短信提示门店保洁打扫卫生
// smsService.sendSmsCleanRecordsStopRemind(item.getPhone(), sStore, sRoom);
// });
}
}
Map<String, String> map = new HashMap<>();
......@@ -398,7 +381,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
redisUtils.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo());
}
return response;
......@@ -1128,6 +1110,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
BigDecimal duration = new BigDecimal(consumerCoupon.getDuration());
if (duration.compareTo(timeLong) >= 0) {
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setCouponFee(priceResponse.getTotalFee());
} else {
BigDecimal unitPrice = priceResponse.getTotalFee().divide(timeLong);
priceResponse.setPayFee(unitPrice.multiply(timeLong.subtract(duration)));
......
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