订单多车辆
This commit is contained in:
parent
cc0d20ddc1
commit
045666041b
|
@ -214,6 +214,6 @@ public class SecurityUtils
|
|||
* @return
|
||||
*/
|
||||
public static boolean isSysAdmin() {
|
||||
return hasAnyRole(RoleConstants.ADMIN);
|
||||
return isAdmin() || hasAnyRole(RoleConstants.ADMIN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,14 @@ package com.ruoyi.bst.areaSub.utils;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.areaSub.domain.AreaSubVO;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import com.ruoyi.bst.areaSub.domain.AreaSubVO;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class AreaSubUtil {
|
||||
|
||||
|
@ -20,6 +23,9 @@ public class AreaSubUtil {
|
|||
* @return 最近的区域
|
||||
*/
|
||||
public static AreaSubVO getInAreaSub(List<AreaSubVO> areaSubList, BigDecimal longitude, BigDecimal latitude, BigDecimal areaError) {
|
||||
if (CollectionUtils.isEmptyElement(areaSubList)) {
|
||||
return null;
|
||||
}
|
||||
double tolerance = 0; // 误差距离
|
||||
if (areaError != null) {
|
||||
tolerance = areaError.doubleValue();
|
||||
|
|
|
@ -41,7 +41,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bd.iot_status,
|
||||
bd.is_sound,
|
||||
bd.deleted,
|
||||
bd.order_id,
|
||||
bd.last_online_time,
|
||||
bd.order_device_id,
|
||||
mch.nick_name as mch_name,
|
||||
|
@ -99,14 +98,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.deleted == null "> and bd.deleted = false</if>
|
||||
<if test="query.eqSn != null and query.eqSn != ''"> and bd.sn = #{query.eqSn}</if>
|
||||
<if test="query.eqMac != null and query.eqMac != ''"> and bd.mac = #{query.eqMac}</if>
|
||||
<if test="query.orderId != null"> and bd.order_id = #{query.orderId}</if>
|
||||
<if test="query.orderId != null"> and bod.order_id = #{query.orderId}</if>
|
||||
<if test="query.areaUserId != null"> and basu.user_id = #{query.areaUserId}</if>
|
||||
<if test="query.areaAgentId != null"> and basu.agent_id = #{query.areaAgentId}</if>
|
||||
<if test="query.areaUserName != null and query.areaUserName != ''"> and basu.nick_name like concat('%', #{query.areaUserName}, '%')</if>
|
||||
<if test="query.areaAgentName != null and query.areaAgentName != ''"> and basua.nick_name like concat('%', #{query.areaAgentName}, '%')</if>
|
||||
<if test="query.orderNo != null and query.orderNo != ''"> and bo.no like concat('%', #{query.orderNo}, '%')</if>
|
||||
<if test="query.suitId != null">
|
||||
find_in_set(#{query.suitId}, bm.suit_ids)
|
||||
and find_in_set(#{query.suitId}, bm.suit_ids)
|
||||
</if>
|
||||
<if test="query.ids != null and query.ids.size() > 0">
|
||||
and bd.id in
|
||||
|
@ -317,7 +316,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<update id="clearCurrentOrderDevice">
|
||||
update bst_device
|
||||
update bst_device
|
||||
set order_device_id = null
|
||||
where id = #{id} and order_device_id = #{orderDeviceId}
|
||||
</update>
|
||||
|
|
|
@ -36,6 +36,9 @@ public class LocationLogConverterImpl implements LocationLogConverter {
|
|||
|
||||
// 查询设备信息
|
||||
DeviceVO device = deviceService.selectSimpleByMacForLocationLog(msg.getDevName());
|
||||
if (device == null) {
|
||||
return null;
|
||||
}
|
||||
// 转为设备信息
|
||||
IotDeviceSysInfo sys = IotUtil.toSysInfo(msg.getValue());
|
||||
// 设置设备信息
|
||||
|
@ -54,7 +57,7 @@ public class LocationLogConverterImpl implements LocationLogConverter {
|
|||
po.setLatitude(device.getLatitude());
|
||||
po.setAt(DateUtils.toLocalDateTime(msg.getAt()));
|
||||
po.setDeviceId(device.getId());
|
||||
po.setOrderId(device.getOrderId());
|
||||
po.setOrderId(device.getOrderId());
|
||||
return po;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,4 +195,8 @@ public class Order extends BaseEntity
|
|||
@ApiModelProperty("运营区是否开启还车审核")
|
||||
private Boolean areaReturnVerify;
|
||||
|
||||
@Excel(name = "审核备注")
|
||||
@ApiModelProperty("审核备注")
|
||||
private String verifyRemark;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.ruoyi.bst.order.domain;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDeviceVO;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -54,4 +56,6 @@ public class OrderVO extends Order {
|
|||
@ApiModelProperty("用户手机号")
|
||||
private String userPhone;
|
||||
|
||||
@ApiModelProperty("订单设备列表")
|
||||
private List<OrderDeviceVO> orderDeviceList;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.ruoyi.bst.area.domain.AreaVO;
|
|||
import com.ruoyi.bst.areaSub.domain.AreaSubVO;
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderChangeDeviceDTO;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderInParkingVO;
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDevice;
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDeviceVO;
|
||||
|
@ -14,6 +15,8 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class OrderChangeBO {
|
||||
// 原始参数
|
||||
private OrderChangeDeviceDTO dto;
|
||||
|
||||
// 订单
|
||||
private OrderVO order;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.bst.order.domain.dto;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderVerifyDTO {
|
||||
|
||||
@ApiModelProperty("订单ID")
|
||||
@NotNull(message = "订单ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("是否通过")
|
||||
@NotNull(message = "是否通过不能为空")
|
||||
private Boolean pass;
|
||||
|
||||
@ApiModelProperty("审核备注")
|
||||
@Size(max = 200, message = "审核备注不能超过200个字符")
|
||||
private String remark;
|
||||
}
|
|
@ -14,8 +14,9 @@ public enum OrderStatus {
|
|||
WAIT_PAY("WAIT_PAY", "待支付"),
|
||||
PROCESSING("PROCESSING", "进行中"),
|
||||
FINISHED("FINISHED", "已结束"),
|
||||
CANCELED("CANCELED", "已取消"),
|
||||
CANCELD("CANCELD", "已取消"),
|
||||
WAIT_VERIFY("WAIT_VERIFY", "待审核"),
|
||||
REJECTED("REJECTED", "已驳回"),
|
||||
REFUNDED("REFUNDED", "已退款");
|
||||
|
||||
private final String code;
|
||||
|
@ -56,4 +57,9 @@ public enum OrderStatus {
|
|||
public static List<String> canCancelPay() {
|
||||
return CollectionUtils.map(OrderStatus::getCode, WAIT_PAY);
|
||||
}
|
||||
|
||||
// 可以审核的订单状态
|
||||
public static List<String> canVerify() {
|
||||
return CollectionUtils.map(OrderStatus::getCode, WAIT_VERIFY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bo.end_reason,
|
||||
bo.order_device_id,
|
||||
bo.area_return_verify,
|
||||
bo.verify_remark,
|
||||
ba.name as area_name,
|
||||
su.nick_name as user_name,
|
||||
su.phonenumber as user_phone,
|
||||
|
@ -107,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.endReason != null and query.endReason != ''"> and bo.end_reason like concat('%', #{query.endReason}, '%')</if>
|
||||
<if test="query.orderDeviceId != null "> and bo.order_device_id = #{query.orderDeviceId}</if>
|
||||
<if test="query.areaReturnVerify != null "> and bo.area_return_verify = #{query.areaReturnVerify}</if>
|
||||
<if test="query.verifyRemark != null and query.verifyRemark != ''"> and bo.verify_remark like concat('%', #{query.verifyRemark}, '%')</if>
|
||||
<if test="query.createDateRange != null and query.createDateRange.size() > 1">
|
||||
and date(bo.create_time) >= #{query.createDateRange[0]}
|
||||
and date(bo.create_time) <= #{query.createDateRange[1]}
|
||||
|
@ -175,6 +177,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="endReason != null">end_reason,</if>
|
||||
<if test="orderDeviceId != null">order_device_id,</if>
|
||||
<if test="areaReturnVerify != null">area_return_verify,</if>
|
||||
<if test="verifyRemark != null">verify_remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="no != null and no != ''">#{no},</if>
|
||||
|
@ -218,6 +221,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="endReason != null">#{endReason},</if>
|
||||
<if test="orderDeviceId != null">#{orderDeviceId},</if>
|
||||
<if test="areaReturnVerify != null">#{areaReturnVerify},</if>
|
||||
<if test="verifyRemark != null">#{verifyRemark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -271,6 +275,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.endReason != null">end_reason = #{data.endReason},</if>
|
||||
<if test="data.orderDeviceId != null">order_device_id = #{data.orderDeviceId},</if>
|
||||
<if test="data.areaReturnVerify != null">area_return_verify = #{data.areaReturnVerify},</if>
|
||||
<if test="data.verifyRemark != null">verify_remark = #{data.verifyRemark},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteOrderById" parameterType="Long">
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.bst.order.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
|
||||
public interface OrderAssembler {
|
||||
|
||||
/**
|
||||
* 组装订单设备列表
|
||||
*/
|
||||
void assembleOrderDeviceList(List<OrderVO> list);
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.ruoyi.bst.order.domain.dto.OrderCreateDTO;
|
|||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderPayDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderFeeVO;
|
||||
import com.ruoyi.bst.pay.domain.vo.DoPayVO;
|
||||
|
||||
|
@ -176,4 +177,11 @@ public interface OrderService
|
|||
* @return 结果
|
||||
*/
|
||||
public int changeDevice(OrderChangeDeviceDTO dto);
|
||||
|
||||
/**
|
||||
* 还车审核
|
||||
* @param dto 审核DTO
|
||||
* @return 结果
|
||||
*/
|
||||
public int verify(OrderVerifyDTO dto);
|
||||
}
|
||||
|
|
|
@ -83,4 +83,11 @@ public interface OrderValidator {
|
|||
*/
|
||||
void canUseDevice(DeviceVO device, OrderVO order);
|
||||
|
||||
/**
|
||||
* 校验并设置图片
|
||||
* @param order 订单
|
||||
* @param picture 图片
|
||||
*/
|
||||
void checkReturnPicture(OrderVO order, String picture);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.ruoyi.bst.order.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
import com.ruoyi.bst.order.service.OrderAssembler;
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDeviceQuery;
|
||||
import com.ruoyi.bst.orderDevice.domain.OrderDeviceVO;
|
||||
import com.ruoyi.bst.orderDevice.service.OrderDeviceService;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
||||
@Service
|
||||
public class OrderAssemblerImpl implements OrderAssembler {
|
||||
|
||||
@Autowired
|
||||
private OrderDeviceService orderDeviceService;
|
||||
|
||||
@Override
|
||||
public void assembleOrderDeviceList(List<OrderVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> orderIds = CollectionUtils.map(list, OrderVO::getId);
|
||||
OrderDeviceQuery query = new OrderDeviceQuery();
|
||||
query.setOrderIds(orderIds);
|
||||
List<OrderDeviceVO> orderDeviceList = orderDeviceService.selectOrderDeviceList(query);
|
||||
|
||||
for (OrderVO order : list) {
|
||||
List<OrderDeviceVO> result = orderDeviceList.stream()
|
||||
.filter(item -> Objects.equal(item.getOrderId(), order.getId()))
|
||||
.collect(Collectors.toList());
|
||||
order.setOrderDeviceList(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -366,9 +366,11 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
OrderDeviceVO oldOrderDevice = orderDeviceService.selectOrderDeviceById(order.getOrderDeviceId());
|
||||
ServiceUtil.assertion(oldOrderDevice == null, "ID为%s的订单当前没有设备正在使用", dto.getOrderId());
|
||||
ServiceUtil.assertion(Objects.equals(oldOrderDevice.getDeviceId(), newDevice.getId()), "新旧车辆相同,无法换车");
|
||||
oldOrderDevice.setFinishPicture(dto.getFaultPicture());
|
||||
bo.setOldOrderDevice(oldOrderDevice);
|
||||
|
||||
// 校验图片
|
||||
orderValidator.checkReturnPicture(order, dto.getFaultPicture());
|
||||
|
||||
// 查询运营区
|
||||
AreaVO area = areaService.selectAreaById(order.getAreaId());
|
||||
ServiceUtil.assertion(area == null, "ID为%s的运营区不存在", order.getAreaId());
|
||||
|
@ -376,7 +378,6 @@ public class OrderConverterImpl implements OrderConverter{
|
|||
|
||||
// 查询运营区子区域列表
|
||||
List<AreaSubVO> areaSubs = areaSubService.selectParkingAreaByAreaId(area.getId());
|
||||
ServiceUtil.assertion(areaSubs == null || areaSubs.isEmpty(), "ID为%s的运营区子区域列表不存在", area.getId());
|
||||
bo.setAreaSubs(areaSubs);
|
||||
|
||||
// 查询旧设备
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.ruoyi.bst.order.domain.dto.OrderCreateDTO;
|
|||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderPayDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderReturnMode;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderReturnType;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
||||
|
@ -132,7 +133,7 @@ public class OrderServiceImpl implements OrderService
|
|||
|
||||
@Autowired
|
||||
private OrderDeviceConverter orderDeviceConverter;
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
|
@ -317,7 +318,7 @@ public class OrderServiceImpl implements OrderService
|
|||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 更新订单状态
|
||||
Order data = new Order();
|
||||
data.setStatus(OrderStatus.CANCELED.getCode());
|
||||
data.setStatus(OrderStatus.CANCELD.getCode());
|
||||
data.setCancelRemark(remark);
|
||||
OrderQuery query = new OrderQuery();
|
||||
query.setId(id);
|
||||
|
@ -399,7 +400,7 @@ public class OrderServiceImpl implements OrderService
|
|||
// 还车类型
|
||||
order.setReturnType(ignoreInParking ? OrderReturnType.AUXILIARY.getCode() : OrderReturnType.NORMAL.getCode());
|
||||
// 根据是否需要审核,设置订单状态
|
||||
if (area.getReturnVerify() != null && area.getReturnVerify() && !ignoreInParking) {
|
||||
if (order.getAreaReturnVerify() != null && order.getAreaReturnVerify() && !ignoreInParking) {
|
||||
// 更新订单状态为待审核
|
||||
order.setStatus(OrderStatus.WAIT_VERIFY.getCode());
|
||||
} else {
|
||||
|
@ -424,14 +425,17 @@ public class OrderServiceImpl implements OrderService
|
|||
|
||||
// 当订单状态为已完成时,处理订单完成操作
|
||||
if (OrderStatus.FINISHED.getCode().equals(order.getStatus())) {
|
||||
boolean after = this.handleAfterOrderEnd(order.getId());
|
||||
ServiceUtil.assertion(!after, "ID为%s的订单完成处理失败", order.getId());
|
||||
int refund = this.refundRemainAmount(order.getId());
|
||||
ServiceUtil.assertion(refund != 1, "ID为%s的订单退还剩余金额失败", order.getId());
|
||||
|
||||
// 预分成
|
||||
boolean bonus = bonusService.prepayByBst(BonusBstType.ORDER, order.getId());
|
||||
ServiceUtil.assertion(!bonus, "ID为%s的订单预分成失败", order.getId());
|
||||
}
|
||||
|
||||
// 结束订单设备
|
||||
OrderDeviceVO orderDevice = bo.getOrderDevice();
|
||||
orderDevice.setFinishPicture(dto.getPicture());
|
||||
int finish = orderDeviceService.finish(orderDevice);
|
||||
int finish = orderDeviceService.finish(orderDevice, dto.getPicture());
|
||||
ServiceUtil.assertion(finish != 1, "结束ID为%s的订单设备失败", orderDevice.getId());
|
||||
|
||||
// 设备上锁(必须放最后,因为会操作设备)
|
||||
|
@ -444,31 +448,22 @@ public class OrderServiceImpl implements OrderService
|
|||
return result == null ? 0 : 1;
|
||||
}
|
||||
|
||||
// 订单完成处理
|
||||
private boolean handleAfterOrderEnd(Long orderId) {
|
||||
if (orderId == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 退还剩余金额
|
||||
private int refundRemainAmount(Long orderId) {
|
||||
// 查询订单
|
||||
OrderVO order = this.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 订单剩余金额退款
|
||||
BigDecimal refund = MathUtils.subtractDecimal(order.getPayAmount(), order.getTotalFee());
|
||||
if (refund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (refund != null && refund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
String reason = "【自动退款】订单剩余金额退款" + order.getNo();
|
||||
int rows = this.refund(order, refund, reason, null, "系统");
|
||||
ServiceUtil.assertion(rows != 1, "ID为%s的订单退款失败", order.getId());
|
||||
return this.refund(order, refund, reason, null, "系统");
|
||||
}
|
||||
|
||||
// 预分成
|
||||
boolean bonus = bonusService.prepayByBst(BonusBstType.ORDER, orderId);
|
||||
ServiceUtil.assertion(!bonus, "ID为%s的订单预分成失败", order.getId());
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -530,9 +525,6 @@ public class OrderServiceImpl implements OrderService
|
|||
|
||||
// 查询还车点
|
||||
List<AreaSubVO> areaSubs = areaSubService.selectParkingAreaByAreaId(area.getId());
|
||||
if (areaSubs == null || areaSubs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取是否在停车点内
|
||||
OrderInParkingVO inParkingVO = OrderUtil.getInParkingVO(area, areaSubs, device, dto.getLon(), dto.getLat());
|
||||
|
@ -596,7 +588,7 @@ public class OrderServiceImpl implements OrderService
|
|||
// 操作数据库
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 结束当前订单设备
|
||||
int finish = orderDeviceService.finish(oldOrderDevice);
|
||||
int finish = orderDeviceService.finish(oldOrderDevice, dto.getFaultPicture());
|
||||
ServiceUtil.assertion(finish != 1, "结束当前订单设备失败");
|
||||
|
||||
// 创建故障信息
|
||||
|
@ -628,4 +620,40 @@ public class OrderServiceImpl implements OrderService
|
|||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int verify(OrderVerifyDTO dto) {
|
||||
// 查询订单
|
||||
OrderVO order = this.selectOrderById(dto.getId());
|
||||
ServiceUtil.assertion(order == null, "ID为%s的订单不存在", dto.getId());
|
||||
ServiceUtil.assertion(!OrderStatus.canVerify().contains(order.getStatus()), "ID为%s的订单当前状态不允许审核", dto.getId());
|
||||
|
||||
// 更新订单状态
|
||||
boolean pass = dto.getPass() != null && dto.getPass();
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 更新订单状态
|
||||
Order data = new Order();
|
||||
data.setStatus(pass ? OrderStatus.FINISHED.getCode() : OrderStatus.REJECTED.getCode());
|
||||
data.setVerifyRemark(dto.getRemark());
|
||||
OrderQuery query = new OrderQuery();
|
||||
query.setId(dto.getId());
|
||||
query.setStatusList(OrderStatus.canVerify());
|
||||
int rows = orderMapper.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(rows != 1, "ID为%s的订单审核失败", dto.getId());
|
||||
|
||||
// 若审核通过,则退还剩余金额
|
||||
if (pass && rows > 0) {
|
||||
int refund = this.refundRemainAmount(order.getId());
|
||||
ServiceUtil.assertion(refund != 1, "ID为%s的订单退还剩余金额失败", order.getId());
|
||||
}
|
||||
|
||||
// 预分成
|
||||
boolean bonus = bonusService.prepayByBst(BonusBstType.ORDER, order.getId());
|
||||
ServiceUtil.assertion(!bonus, "ID为%s的订单预分成失败", order.getId());
|
||||
|
||||
return rows;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.ruoyi.bst.order.domain.bo.OrderCreateBO;
|
|||
import com.ruoyi.bst.order.domain.bo.OrderEndBO;
|
||||
import com.ruoyi.bst.order.domain.bo.OrderPayBO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderCreateDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderPayDTO;
|
||||
import com.ruoyi.bst.order.domain.enums.OrderStatus;
|
||||
import com.ruoyi.bst.order.domain.vo.OrderInParkingVO;
|
||||
|
@ -29,6 +30,7 @@ import com.ruoyi.common.constants.ServiceCode;
|
|||
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
||||
@Service
|
||||
|
@ -128,8 +130,13 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
// 还车校验
|
||||
OrderInParkingVO inParkingVO = bo.getInParkingVO();
|
||||
if (!ignoreInParking) {
|
||||
// 还车图片
|
||||
OrderEndDTO dto = bo.getDto();
|
||||
this.checkReturnPicture(order, dto.getPicture());
|
||||
// 停车区校验
|
||||
this.checkInParking(area, inParkingVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,8 +180,16 @@ public class OrderValidatorImpl implements OrderValidator{
|
|||
DeviceQuery query = OrderUtil.toChangeDeviceQuery(order);
|
||||
List<DeviceVO> list = deviceService.selectDeviceList(query);
|
||||
ServiceUtil.assertion(CollectionUtils.isEmptyElement(list), "ID为%s的车辆当前状态不可使用", device.getId());
|
||||
ServiceUtil.assertion(!CollectionUtils.map(list, DeviceVO::getId).contains(device.getId()), "ID为%s的车辆不可在当前订单上使用,请结束订单后重试", device.getId());
|
||||
ServiceUtil.assertion(!CollectionUtils.map(list, DeviceVO::getId).contains(device.getId()), "ID为%s的车辆不可在当前订单上使用", device.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkReturnPicture(OrderVO order, String picture) {
|
||||
ServiceUtil.assertion(order == null, "参数错误,订单不存在");
|
||||
ServiceUtil.assertion(order != null
|
||||
&& order.getAreaReturnVerify() != null
|
||||
&& order.getAreaReturnVerify()
|
||||
&& StringUtils.isBlank(picture), "请上传还车图片");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,7 @@ public class OrderDeviceQuery extends OrderDeviceVO {
|
|||
|
||||
@ApiModelProperty("状态列表")
|
||||
private List<String> statusList;
|
||||
|
||||
@ApiModelProperty("订单ID列表")
|
||||
private List<Long> orderIds;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="query.orderIds != null and query.orderIds.size() > 0">
|
||||
and bod.order_id in
|
||||
<foreach item="item" collection="query.orderIds" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public interface OrderDeviceService
|
|||
* @param orderDevice 订单设备
|
||||
* @return 结果
|
||||
*/
|
||||
public int finish(OrderDeviceVO orderDevice);
|
||||
public int finish(OrderDeviceVO orderDevice, String picture);
|
||||
|
||||
/**
|
||||
* 开始订单设备
|
||||
|
|
|
@ -180,7 +180,7 @@ public class OrderDeviceServiceImpl implements OrderDeviceService
|
|||
}
|
||||
|
||||
@Override
|
||||
public int finish(OrderDeviceVO orderDevice) {
|
||||
public int finish(OrderDeviceVO orderDevice, String picture) {
|
||||
ServiceUtil.assertion(orderDevice == null, "订单设备不能为空");
|
||||
ServiceUtil.assertion(!OrderDeviceStatus.canFinish().contains(orderDevice.getStatus()), "订单设备状态不允许结束");
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class OrderDeviceServiceImpl implements OrderDeviceService
|
|||
OrderDevice data = new OrderDevice();
|
||||
data.setStatus(OrderDeviceStatus.FINISHED.getCode());
|
||||
data.setEndTime(LocalDateTime.now());
|
||||
data.setFinishPicture(orderDevice.getFinishPicture());
|
||||
data.setFinishPicture(picture);
|
||||
OrderDeviceQuery query = new OrderDeviceQuery();
|
||||
query.setId(orderDevice.getId());
|
||||
query.setStatusList(OrderDeviceStatus.canFinish());
|
||||
|
|
|
@ -53,9 +53,10 @@ public class ReceiveController {
|
|||
@PostMapping(value = "/receive")
|
||||
@Anonymous
|
||||
public ResponseEntity<String> receive(HttpServletRequest request){
|
||||
String body = HttpUtils.getBody(request);
|
||||
log.info("receive方法接收到参数:: body:{}", body);
|
||||
// 异步处理,直接返回成功
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
String body = HttpUtils.getBody(request);
|
||||
ObjBody obj = IotUtil.resolveBody(body, false);
|
||||
if (obj != null){
|
||||
Object msg = obj.getMsg();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -13,12 +14,15 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.bst.order.domain.OrderQuery;
|
||||
import com.ruoyi.bst.order.domain.OrderVO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderEndDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderRefundDTO;
|
||||
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
||||
import com.ruoyi.bst.order.service.OrderAssembler;
|
||||
import com.ruoyi.bst.order.service.OrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
|
@ -41,6 +45,9 @@ public class OrderController extends BaseController
|
|||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private OrderAssembler orderAssembler;
|
||||
|
||||
/**
|
||||
* 查询订单列表
|
||||
*/
|
||||
|
@ -52,6 +59,7 @@ public class OrderController extends BaseController
|
|||
startOrderBy();
|
||||
query.setScope(true);
|
||||
List<OrderVO> list = orderService.selectOrderList(query);
|
||||
orderAssembler.assembleOrderDeviceList(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -74,9 +82,14 @@ public class OrderController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:order:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean assembleOrderDeviceList)
|
||||
{
|
||||
return success(orderService.selectOrderById(id, true));
|
||||
OrderVO order = orderService.selectOrderById(id, true);
|
||||
if (assembleOrderDeviceList) {
|
||||
orderAssembler.assembleOrderDeviceList(Collections.singletonList(order));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,4 +121,17 @@ public class OrderController extends BaseController
|
|||
return toAjax(orderService.refund(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 还车审核
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:order:verify')")
|
||||
@PutMapping("/verify")
|
||||
public AjaxResult verify(@RequestBody @Validated OrderVerifyDTO dto) {
|
||||
// 查询订单
|
||||
OrderVO order = orderService.selectOrderById(dto.getId(), true);
|
||||
ServiceUtil.assertion(order == null, "订单不存在");
|
||||
|
||||
return toAjax(orderService.verify(dto));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -134,8 +134,8 @@ iot:
|
|||
# 推送消息token
|
||||
token: tVpNdGKrAFHfKZNgpIWQfZukrcYHNfFM
|
||||
# 产品ID
|
||||
# productId: 796mCwPk0F
|
||||
productId: 6zGfj7p1C2
|
||||
productId: 796mCwPk0F
|
||||
# productId: 6zGfj7p1C2
|
||||
|
||||
# 实名认证
|
||||
realName:
|
||||
|
|
Loading…
Reference in New Issue
Block a user