gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java
@@ -84,9 +84,9 @@ } @ApiOperation("订单状态数量") @PostMapping(value = "/jhy/order/orderStatusCnt") public JsonResult<Map<Integer, Integer>> orderStatusCnt(HttpServletRequest request) { return JsonResult.success(jhyOrderService.orderStatusCount(getUserId(request))); @PostMapping(value = "/jhy/order/orderStatusCnt/{type}") public JsonResult<Map<Integer, Integer>> orderStatusCnt(@PathVariable("type") Integer type, HttpServletRequest request) { return JsonResult.success(jhyOrderService.orderStatusCount(type, getUserId(request))); } } gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderItemsMapper.java
@@ -12,4 +12,6 @@ List<JhyOrderItems> selectOrderItems(@Param("orderId") Long orderId); BigDecimal selectOrderScoreByOrderId(@Param("orderId") Long orderId); int deleteItemsByOrderId(@Param("orderId") Long orderId); } gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java
@@ -15,5 +15,5 @@ List<JhyOrderListVo> selectJhyOrderList(@Param("record") JhyOrderListDto jhyOrderListDto); List<JhyStatusCountVo> selectOrderStatusCount(@Param("userId") String userId); List<JhyStatusCountVo> selectOrderStatusCount(@Param("type") Integer type, @Param("userId") String userId); } gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -136,6 +136,8 @@ JhyOrderDetailsVo detailsVo = new JhyOrderDetailsVo(); BeanUtil.copyProperties(order, detailsVo); detailsVo.setLongitude(order.getLongitude()); detailsVo.setLatitude(order.getLatitude()); detailsVo.setAddress(order.getArea() + order.getAddress()); detailsVo.setTotalPrice(total); detailsVo.setItems(items); @@ -146,6 +148,10 @@ JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId); if (jhyInfo == null || !JhyInfo.CHECK_PASS.equals(jhyInfo.getStatus())) { throw new RestException(-3, "不是集货员"); } if (JhyInfo.IS_JHY_N.equals(jhyInfo.getIsJhy())) { throw new RestException(-3, "暂无法抢单"); } JhyOrder order = jhyOrderMapper.selectByPrimaryKey(orderId); @@ -181,14 +187,23 @@ throw new RestException(-3, "不是集物员"); } jhyOrderItemsMapper.deleteItemsByOrderId(confirmDto.getOrderId()); BigDecimal totalScore = BigDecimal.ZERO; for (JhyOrderConfirmItemsDto item : confirmDto.getItems()) { JhyOrderItems orderItem = jhyOrderItemsMapper.selectByPrimaryKey(item.getId()); BigDecimal weight = StrUtil.isNotBlank(item.getWeight()) ? new BigDecimal(item.getWeight()) : BigDecimal.ZERO; BigDecimal total = orderItem.getPrice().multiply(BigDecimal.valueOf(40)).multiply(weight); orderItem.setScore(total.setScale(0, BigDecimal.ROUND_DOWN).toString()); orderItem.setWeight(weight); jhyOrderItemsMapper.updateByPrimaryKey(orderItem); SysEnvironmentalInfo environmentalInfo = environmentalInfoMapper.selectByPrimaryKey(item.getId()); JhyOrderItems orderItems = new JhyOrderItems(); orderItems.setOrderId(confirmDto.getOrderId()); orderItems.setPicture(environmentalInfo.getPicture()); orderItems.setItemType(item.getId()); orderItems.setTitle(environmentalInfo.getTitle()); orderItems.setPrice(new BigDecimal(environmentalInfo.getPrice())); BigDecimal total = orderItems.getPrice().multiply(BigDecimal.valueOf(40)).multiply(weight); orderItems.setScore(total.setScale(0, BigDecimal.ROUND_DOWN).toString()); orderItems.setWeight(weight); jhyOrderItemsMapper.insert(orderItems); totalScore = totalScore.add(total); } @@ -237,8 +252,8 @@ distribService.distribRecord(order.getId(), order.getUserId()); } public Map<Integer, Integer> orderStatusCount(String userId) { List<JhyStatusCountVo> count = jhyOrderMapper.selectOrderStatusCount(userId); public Map<Integer, Integer> orderStatusCount(Integer type, String userId) { List<JhyStatusCountVo> count = jhyOrderMapper.selectOrderStatusCount(type, userId); Map<Integer, Integer> map = new HashMap<>(); for (int i = 1; i < 6; i++) { gc-order/src/main/java/com/xzx/gc/order/vo/JhyOrderDetailsVo.java
@@ -30,4 +30,10 @@ @ApiModelProperty(value = "明细") private List<JhyOrderItems> items; @ApiModelProperty(value = "经度") private String longitude; @ApiModelProperty(value = "纬度") private String latitude; } gc-order/src/main/resources/mapper/order/JhyOrderItemsMapper.xml
@@ -13,4 +13,9 @@ where order_id=#{orderId} group by order_id </select> <delete id="deleteItemsByOrderId"> delete from xzx_jhy_order_items where order_id=#{orderId} </delete> </mapper> gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml
@@ -48,13 +48,27 @@ select status, count(1) cnt from xzx_jhy_order where status=1 from xzx_jhy_order <where> status=1 <if test="type == 2"> and user_id=#{userId} </if> </where> group by status union all select status, count(1) cnt from xzx_jhy_order where user_id=#{userId} <where> <if test="type == 1"> and jhy_id=#{userId} </if> <if test="type == 2" > and user_id=#{userId} </if> </where> group by status </select> </mapper>