| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.SQLOutput; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setError(e.toString()+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | orderId = "NG"+formattedDate+formattedNumber; |
| | | |
| | | }else if(dateType.equals("year")){ |
| | | Integer maxOrderId = orderMapper.selectMaxOrderIdByYear(); |
| | | String formattedNumber = String.format("%06d", maxOrderId+1); |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | orderId = "NG"+formattedDate+formattedNumber; |
| | | } |
| | | |
| | | return orderId; |
| | |
| | | |
| | | Map<String,Object> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Object>>(){}); |
| | | int finalI = i; |
| | | |
| | | if(otherColumns!=null){ |
| | | otherColumns.values().removeIf(value -> value == null || value.equals("")); |
| | | OrderDetails.get(i).setOtherColumns(JSON.toJSONString(otherColumns)); |
| | | |
| | | otherColumns.forEach((key, value) ->{ |
| | | if(value!=null && key.contains("M")) { |
| | | |
| | | if(value!=null && !value.equals("") && key.contains("M")) { |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | if (orderOtherMoney.getColumn().equals(key)) { |
| | | orderOtherMoney.setQuantity(orderOtherMoney.getQuantity()+(Double.parseDouble((String) value) * OrderDetails.get(finalI).getQuantity())); |
| | | orderOtherMoney.setQuantity( |
| | | orderOtherMoney.getQuantity()+(Double.parseDouble((String) value) * OrderDetails.get(finalI).getQuantity())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | }else if(OrderDetails.get(i).getOtherColumns()==null){ |
| | | }else{ |
| | | OrderDetails.get(i).setOtherColumns("{}"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | double money = 0; |
| | | for (OrderDetail orderDetail : OrderDetails) { |
| | | orderDetail = updateOrderMoneyComputed(orderDetail,order.getCalculateType()); |
| | | money+= orderDetail.getGrossAmount(); |
| | | BigDecimal getGrossAmount= BigDecimal.valueOf(orderDetail.getGrossAmount()); |
| | | money+=getGrossAmount.doubleValue(); |
| | | } |
| | | Log log = new Log(); |
| | | log.setOperator(order.getCreator()); |
| | | log.setOperatorId(order.getCreatorId()); |
| | | log.setContent(jsonObject.toString()); |
| | | log.setFunction("updateOrderMoney金额重置:"+order.getOrderId()); |
| | | |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){ |
| | | orderOtherMoney.setMoney((orderOtherMoney.getQuantity()*orderOtherMoney.getPrice())); |
| | |
| | | .eq("`column`",orderOtherMoney.getColumn())); |
| | | }); |
| | | order.setMoney(money+orderOtherMoneyMapper.selectGrossAmount(order.getOrderId())); |
| | | order.setOtherMoney(orderOtherMoneyMapper.selectGrossAmount(order.getOrderId())); |
| | | orderMapper.updateMoney(order); |
| | | orderDetailMapper.updateOrderMoney(OrderDetails); |
| | | logService.saveLog(log); |
| | | return false; |
| | | } |
| | | |
| | | private OrderDetail updateOrderMoneyComputed(OrderDetail orderDetail, Integer calculateType) { |
| | | BigDecimal getPrice= BigDecimal.valueOf(orderDetail.getPrice()); |
| | | BigDecimal getQuantity= BigDecimal.valueOf(orderDetail.getQuantity()); |
| | | BigDecimal getComputeGrossArea= BigDecimal.valueOf(orderDetail.getComputeGrossArea()); |
| | | if (calculateType == 3) { |
| | | orderDetail.setGrossAmount(orderDetail.getPrice() * orderDetail.getQuantity()); |
| | | orderDetail.setGrossAmount(getPrice.multiply(getQuantity).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | } else { |
| | | orderDetail.setGrossAmount(orderDetail.getComputeGrossArea() * orderDetail.getPrice()); |
| | | orderDetail.setGrossAmount(getPrice.multiply(getComputeGrossArea).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | return orderDetail; |
| | | } |
| | |
| | | return orderDetailMapper.exportOrderReport(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderSummaryReport(Integer pageNum, Integer pageSize, List<String> selectDate, Order order) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderSummaryReport(offset, pageSize, startDate, endDate, order)); |
| | | map.put("total",orderDetailMapper.getOrderSummaryReportTotal(offset, pageSize, startDate, endDate, order,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | // map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail)); |
| | | return map; |
| | | } |
| | | |
| | | public List<Order> exportOrderSummary(List<LocalDate> dates) { |
| | | return orderDetailMapper.exportOrderSummary(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderProductSummary(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |