|  |  | 
 |  |  | import com.core.annotations.ManagerAuth; | 
 |  |  | import com.core.common.*; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.entity.DocType; | 
 |  |  | import com.zy.asrs.entity.Order; | 
 |  |  | import com.zy.asrs.entity.OrderDetl; | 
 |  |  | import com.zy.asrs.entity.param.OrderDomainParam; | 
 |  |  | import com.zy.asrs.service.DocTypeService; | 
 |  |  | import com.zy.asrs.service.OrderDetlService; | 
 |  |  | import com.zy.asrs.service.OrderService; | 
 |  |  | import com.zy.common.model.DetlDto; | 
 |  |  | 
 |  |  |     private OrderDetlService orderDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private SnowflakeIdWorker snowflakeIdWorker; | 
 |  |  |     @Autowired | 
 |  |  |     private DocTypeService docTypeService; | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/nav/list/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  | 
 |  |  |         if (!Cools.isEmpty(orderNo)) { | 
 |  |  |             wrapper.like("order_no", orderNo); | 
 |  |  |         } | 
 |  |  |         wrapper.le("settle", 2).eq("doc_type", 1).eq("status", 1); | 
 |  |  |         wrapper.le("settle", 2).eq("status", 1); | 
 |  |  |         wrapper.orderBy("create_time", false); | 
 |  |  |         List<Order> orders = orderService.selectList(wrapper); | 
 |  |  |         // 保留出库单 | 
 |  |  |         if (!Cools.isEmpty(orders)) { | 
 |  |  |             Iterator<Order> iterator = orders.iterator(); | 
 |  |  |             while (iterator.hasNext()) { | 
 |  |  |                 Order order = iterator.next(); | 
 |  |  |                 if (order.getDocType() != null) { | 
 |  |  |                     DocType docType = docTypeService.selectById(order.getDocType()); | 
 |  |  |                     if (docType != null) { | 
 |  |  |                         if (docType.getPakout() == 0) { | 
 |  |  |                             iterator.remove(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok().add(orders); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         excludeTrash(param); | 
 |  |  |         convert(param, wrapper); | 
 |  |  |         if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { | 
 |  |  |             wrapper.orderBy("create_time", false); | 
 |  |  |             wrapper.orderBy("settle").orderBy("create_time", false); | 
 |  |  |         } | 
 |  |  |         wrapper.eq("status", 1); | 
 |  |  |         return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper)); | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/update/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R update(Order order){ | 
 |  |  |         if (Cools.isEmpty(order) || null == order.getId()){ | 
 |  |  |             return R.error(); | 
 |  |  |         } | 
 |  |  |         order.setUpdateBy(getUserId()); | 
 |  |  |         order.setUpdateTime(new Date()); | 
 |  |  |         if (!orderService.updateById(order)) { | 
 |  |  |             throw new CoolException("修改订单失败"); | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/order/delete/auth") | 
 |  |  |     @ManagerAuth(memo = "手动删除订单") | 
 |  |  |     @Transactional | 
 |  |  |     public R delete(@RequestParam Long orderId){ | 
 |  |  |         Order order = orderService.selectById(orderId); | 
 |  |  |         if (order != null) { | 
 |  |  |             order.setStatus(0); | 
 |  |  |         } | 
 |  |  |         if (!orderService.updateById(order)) { | 
 |  |  |             throw new CoolException("删除订单失败"); | 
 |  |  |         } | 
 |  |  |         orderDetlService.modifyStatus(orderId, 0); | 
 |  |  |         orderService.remove(orderId); | 
 |  |  | //        Order order = orderService.selectById(orderId); | 
 |  |  | //        if (order != null) { | 
 |  |  | //            order.setStatus(0); | 
 |  |  | //        } | 
 |  |  | //        if (!orderService.updateById(order)) { | 
 |  |  | //            throw new CoolException("删除订单失败"); | 
 |  |  | //        } | 
 |  |  | //        orderDetlService.modifyStatus(orderId, 0); | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  |