Commit b560c24b by 吕明尚

订单管理系统增加作废订单接口

parent 47c1c8b2
......@@ -14,6 +14,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.SOrder;
import share.system.domain.vo.SOrderDto;
import share.system.request.OrderRefundRequest;
import share.system.service.ISOrderService;
import share.common.utils.poi.ExcelUtil;
......@@ -121,4 +122,14 @@ public class SOrderController extends BaseController
public AjaxResult<Boolean> refund(@Validated OrderRefundRequest request) {
return toAjax(sOrderService.refundAudit(request));
}
/**
* 人工修改订单
*/
// @PreAuthorize("hasAuthority('system:order:modify')")
@PutMapping(value = "/modify")
public AjaxResult<Boolean> modifyOrder(@RequestBody SOrderDto sOrderDto) {
return toAjax(sOrderService.modifyOrder(sOrderDto));
}
}
package share.system.domain.vo;
import lombok.Data;
@Data
public class SOrderDto {
//订单滨海
private String orderNo;
//是否消劵
private Integer isReverseconsume;
//备注
private String remark;
}
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SOrder;
import share.system.domain.vo.OrderVo;
import share.system.domain.vo.SOrderDto;
import share.system.domain.vo.SOrderVo;
import share.system.request.CreateOrderRequest;
import share.system.request.OrderComputedPriceRequest;
......@@ -188,4 +189,5 @@ public interface ISOrderService extends IService<SOrder>
boolean isRefund(SOrder order, SConsumerCoupon coupon);
int modifyOrder(SOrderDto sOrderDto);
}
......@@ -34,6 +34,7 @@ import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.*;
import share.system.domain.vo.*;
......@@ -104,6 +105,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
private ISCleanRecordsService cleanRecordsService;
private final static Long FIVE = 5l;
/**
* 查询订单
......@@ -235,6 +238,50 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return Boolean.FALSE;
}
@Override
public int modifyOrder(SOrderDto sOrderDto) {
SOrder sOrder = baseMapper.selectOne(new LambdaQueryWrapper<SOrder>().eq(SOrder::getOrderNo, sOrderDto.getOrderNo()));
if (ObjectUtil.isEmpty(sOrder)) {
throw new BaseException("订单不存在");
}
if (OrderStatusEnum.INUSE.getCode().equals(sOrder.getStatus())) {
//订单为以开始,修改房间状态
SRoom sRoom = new SRoom();
sRoom.setId(sOrder.getRoomId());
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
if (ObjectUtil.isNotEmpty(sOrder.getArrivalTime())) {
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.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");
//延时5秒断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE);
}
}
//当前时间加90分钟
Date date = DateUtils.addMinutes(new Date(), 90);
sOrder.setPreStartDate(date);
sOrder.setPreEndDate(date);
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
if (ObjectUtil.isNotEmpty(sOrder.getCouponId())) {
SConsumerCoupon sConsumerCoupon = consumerCouponService.selectSConsumerCouponById(sOrder.getCouponId());
if (sOrderDto.getIsReverseconsume().equals(YesNoEnum.yes.getIndex())) {
sConsumerCoupon.setUseStatus(CouponStatusEnum.EXPIRED.getValue());
} else {
sConsumerCoupon.setUseStatus(CouponStatusEnum.NORMAL.getValue());
}
consumerCouponService.updateById(sConsumerCoupon);
sOrder.setCouponId(null);
}
sOrder.setUpdateBy(SecurityUtils.getUsername());
//年月日时分秒
sOrder.setRemark(sOrderDto.getRemark());
sOrder.setUpdateTime(new Date());
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrderDto.getOrderNo());
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrderDto.getOrderNo());
return baseMapper.updateSOrder(sOrder);
}
/**
* 新增订单
*
......
......@@ -225,7 +225,7 @@
<if test="consumerPhone != null">consumer_phone = #{consumerPhone},</if>
<if test="packId != null">pack_id = #{packId},</if>
<if test="packPrice != null">pack_price = #{packPrice},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="couponId != ''">coupon_id = #{couponId},</if>
<if test="couponPrice != null">coupon_price = #{couponPrice},</if>
<if test="totalPrice != null">total_price = #{totalPrice},</if>
<if test="payPrice != null">pay_price = #{payPrice},</if>
......
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