fix(订单中心):机库查询设备任务等逻辑优化
This commit is contained in:
+27
-1
@@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -133,6 +134,7 @@ public class OrderController {
|
||||
public PageResult<Map> listInfoByUser(@RequestParam Map<String, Object> params) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
params.put("userId", user.getId());
|
||||
String fileType = MapUtils.getString(params, "fileType");
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
@@ -144,7 +146,8 @@ public class OrderController {
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
List<OrderFile> list = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||
|
||||
List<OrderFile> list = orderFileService.getOrderFileByOrderNoAndFileType(order.getOrderNo(),fileType);
|
||||
List<Map<String,String>> resultList = new ArrayList<>();
|
||||
if (!list.isEmpty()){
|
||||
for (OrderFile orderFile : list){
|
||||
@@ -350,6 +353,21 @@ public class OrderController {
|
||||
return Result.failed("未查询到订单数据");
|
||||
}
|
||||
|
||||
@Operation(summary = "根据设备状态更新订单正在服务中状态")
|
||||
@AuditLog(operation = "'下发任务更新订单正在服务中状态:' + #orderNo")
|
||||
@PutMapping("/device/status")
|
||||
public Result<String> updateOrderStatusDoingFromDevice(@RequestBody Map payload) {
|
||||
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
||||
Assert.notNull(order,"订单数据不能为空");
|
||||
if (order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
||||
order.setOrderStatus(OrderStatus.DOING.getId());
|
||||
if (orderService.updateOrder(order)){
|
||||
return Result.succeed("更新成功");
|
||||
}
|
||||
}
|
||||
return Result.failed("未查询到订单数据");
|
||||
}
|
||||
|
||||
@Operation(summary = "机库更新订单完成状态")
|
||||
@AuditLog(operation = "'机库更新订单完成状态:' + #payload")
|
||||
@PutMapping("/update")
|
||||
@@ -428,6 +446,14 @@ public class OrderController {
|
||||
return Result.succeed(order.getDeviceSn(),"获取成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取订单状态")
|
||||
@GetMapping("/status/{orderNo}")
|
||||
public String getOrderStatusByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
Assert.notNull(order,"订单数据不存在");
|
||||
return order.getOrderStatus().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分的价格转换为元的str,方便前端显示
|
||||
* @param str
|
||||
|
||||
+2
-1
@@ -161,7 +161,8 @@ public class OrderFileController {
|
||||
}
|
||||
if (orderFileService.save(orderFile)){
|
||||
// 机库上报订单素材,更新订单状态为素材上传中,如果订单为设备执行中则更新,否则说明状态已更新
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())){
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.PAID.getId())) {
|
||||
order.setOrderStatus(OrderStatus.UPLOADING.getId());
|
||||
orderService.updateOrder(order);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface OrderFileMapper extends SuperMapper<OrderFile> {
|
||||
int insertOrderFile(OrderFile orderFile);
|
||||
// 根据订单编号查询文件资源信息
|
||||
List<OrderFile> getOrderFileByOrderNo(@Param("orderNo") String orderNo);
|
||||
|
||||
List<OrderFile> getOrderFileByOrderNoAndFileType(@Param("orderNo") String orderNo, @Param("fileType") String contentType);
|
||||
// 文件ID查询文件
|
||||
OrderFile getFileByFileId(@Param("fileId") String fileId);
|
||||
// 查询所有处于排队状态的订单,用于后续按顺序处理(可根据业务需求添加排序等逻辑)
|
||||
|
||||
+7
@@ -44,6 +44,13 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||
*/
|
||||
List<OrderFile> getOrderFileByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 订单编号查询订单文件资源
|
||||
* @param orderNo
|
||||
* @return
|
||||
*/
|
||||
List<OrderFile> getOrderFileByOrderNoAndFileType(String orderNo,String contentType);
|
||||
|
||||
/**
|
||||
* 用户ID查询订单文件资源
|
||||
* @param userId
|
||||
|
||||
+6
@@ -56,6 +56,12 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
||||
return baseMapper.getOrderFileByOrderNo(orderNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderFile> getOrderFileByOrderNoAndFileType(String orderNo, String fileType) {
|
||||
return baseMapper.getOrderFileByOrderNoAndFileType(orderNo, fileType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderFile> getOrderFileByUserId(Long userId) {
|
||||
return baseMapper.getOrderFilesByUserId(userId);
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
SELECT * FROM order_files WHERE order_no = #{orderNo}
|
||||
</select>
|
||||
|
||||
<select id="getOrderFileByOrderNoAndFileType" resultType="com.central.order.model.OrderFile">
|
||||
SELECT * FROM order_files WHERE order_no = #{orderNo} and file_type = #{fileType}
|
||||
</select>
|
||||
|
||||
<select id="getFileByFileId" resultType="com.central.order.model.OrderFile">
|
||||
SELECT * FROM order_files WHERE file_id = #{fileId}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user