| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.dto.sd.OrderDTO; |
| | | import com.example.erp.dto.sd.OrderSearchDTO; |
| | | import com.example.erp.entity.sd.*; |
| | |
| | | private final WorkOrderMapper workOrderMapper; |
| | | private final FlowCardMapper flowCardMapper; |
| | | |
| | | private final BasicOtherMoneyMapper basicOtherMoneyMapper; |
| | | |
| | | private final OrderProcessDetailMapper orderProcessDetailMapper; |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService, WorkOrderMapper workOrderMapper, FlowCardMapper flowCardMapper) { |
| | | |
| | | private final DeliveryService deliveryService; |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService, WorkOrderMapper workOrderMapper, FlowCardMapper flowCardMapper, BasicOtherMoneyMapper basicOtherMoneyMapper,DeliveryService deliveryService) { |
| | | this.orderMapper = orderMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | |
| | | this.logService = logService; |
| | | this.workOrderMapper = workOrderMapper; |
| | | this.flowCardMapper = flowCardMapper; |
| | | this.basicOtherMoneyMapper = basicOtherMoneyMapper; |
| | | this.deliveryService = deliveryService; |
| | | } |
| | | |
| | | public boolean saveOrder(Map<String,Object> orderMap) throws Exception { |
| | |
| | | List<OrderDetail> orderDetails = orderDetailMapper.selectList(new QueryWrapper<OrderDetail>().eq("order_id",id)); |
| | | List<OrderOtherMoney> orderOtherMoneyList = orderOtherMoneyMapper.findById(id); |
| | | List<Map<String,String>> orderFileList = orderMapper.selectOrderFileList(id); |
| | | Integer deliveryCount = orderMapper.selectDeliveryStateConut(id); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("order",order); |
| | | map.put("orderDetails",orderDetails); |
| | | map.put("orderOtherMoneyList",orderOtherMoneyList); |
| | | map.put("orderFile",orderFileList); |
| | | map.put("deliveryCount",deliveryCount); |
| | | return map; |
| | | } |
| | | //订单审核 |
| | |
| | | |
| | | public boolean updateOrderMoney(Map<String, Object> map) { |
| | | JSONObject jsonObject = new JSONObject(map); |
| | | int type = Integer.parseInt(jsonObject.get("type").toString()); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("order")), Order.class); |
| | | List<OrderDetail> OrderDetails = JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("detail")), OrderDetail.class); |
| | | List<OrderOtherMoney> orderOtherMoneyList = JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("otherMoney")), OrderOtherMoney.class); |
| | |
| | | log.setContent(jsonObject.toString()); |
| | | log.setFunction("updateOrderMoney金额重置:"+order.getOrderId()); |
| | | |
| | | |
| | | //删除其他金额明细表 |
| | | orderOtherMoneyMapper.delete(new LambdaQueryWrapper<OrderOtherMoney>().eq(OrderOtherMoney::getOrderId, order.getOrderId())); |
| | | List<OrderOtherMoney> orderOtherMoneyLists=orderOtherMoneyList; |
| | | |
| | | double money = 0; |
| | | for (OrderDetail orderDetail : OrderDetails) { |
| | | if(type==1){ |
| | | deliveryService.updateDeliveryMoney(orderDetail,order); |
| | | } |
| | | orderDetail = updateOrderMoneyComputed(orderDetail,order.getCalculateType()); |
| | | BigDecimal getGrossAmount= BigDecimal.valueOf(orderDetail.getGrossAmount()); |
| | | money+=getGrossAmount.doubleValue(); |
| | |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | List<OrderDetail> orderDetailList = orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail,model,scope); |
| | | List<BasicOtherMoney> basicOtherMoneyList=basicOtherMoneyMapper.selectList(new QueryWrapper<BasicOtherMoney>()); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | for (OrderDetail detail : orderDetailList) { |
| | | String otherColumnsStr = detail.getOtherColumns(); |
| | | if (otherColumnsStr == null || otherColumnsStr.trim().isEmpty()||otherColumnsStr.equals("{}")) { |
| | | continue; // 跳过空值 |
| | | } |
| | | try { |
| | | // 解析为Map(也可解析为自定义实体类,如OtherColumnsDTO) |
| | | Map<String, Object> otherColumnsJson = objectMapper.readValue(otherColumnsStr, Map.class); |
| | | |
| | | detail.setOtherColumnsJson(otherColumnsJson); |
| | | } catch (JsonProcessingException e) { |
| | | System.err.println("解析otherColumns失败,数据:" + otherColumnsStr + ",错误:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail,model,scope)); |
| | | map.put("data",orderDetailList); |
| | | map.put("title",basicOtherMoneyList); |
| | | map.put("total",orderDetailMapper.getOrderReportTotal(offset, pageSize, startDate, endDate, orderDetail,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | |
| | | map.put("data",processList); |
| | | return map; |
| | | } |
| | | |
| | | public Result sizeCheck(String orderId) { |
| | | |
| | | return Result.success( |
| | | orderMapper.update(null, |
| | | new UpdateWrapper<Order>().set("size_check",1).eq("order_id",orderId)) |
| | | ); |
| | | } |
| | | } |