From c402154474b5bf897ec9c59155fb4d85e5871ef4 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 01 Dec 2021 11:10:38 +0800 Subject: [PATCH] fix jhy/queryOrderList.json --- gc-shop/src/main/java/com/xzx/gc/shop/service/JhyService.java | 121 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 115 insertions(+), 6 deletions(-) diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/JhyService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/JhyService.java index dcf4277..671a7db 100644 --- a/gc-shop/src/main/java/com/xzx/gc/shop/service/JhyService.java +++ b/gc-shop/src/main/java/com/xzx/gc/shop/service/JhyService.java @@ -6,16 +6,18 @@ import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.rabbitmq.client.Address; +import com.xzx.gc.common.constant.Constants; +import com.xzx.gc.common.exception.RestException; import com.xzx.gc.common.utils.StringUtils; -import com.xzx.gc.entity.JhyOrder; -import com.xzx.gc.entity.JhyOrderItems; -import com.xzx.gc.entity.ScoreOrderDetails; +import com.xzx.gc.entity.*; +import com.xzx.gc.shop.dto.AssignJhyOrderDto; import com.xzx.gc.shop.dto.CancelJhyOrderDto; import com.xzx.gc.shop.dto.QueryJhyOrderListDto; -import com.xzx.gc.shop.mapper.JhyOrderItemsMapper; -import com.xzx.gc.shop.mapper.JhyOrderMapper; +import com.xzx.gc.shop.mapper.*; import com.xzx.gc.shop.vo.*; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import tk.mybatis.mapper.entity.Example; @@ -37,6 +39,12 @@ @Resource JhyOrderItemsMapper jhyOrderItemsMapper; + @Autowired + private OrderInfoMapper orderInfoMapper; + + @Autowired + private ScoreOrderMapper scoreOrderMapper; + public Map<String, Object> queryOrderList(QueryJhyOrderListDto model) { PageHelper.startPage(model.getPage(), model.getLimit()); String accountPhone = model.getAccount(); @@ -44,12 +52,44 @@ String name = model.getAccount(); model.setAccount(name); model.setAccountPhone(accountPhone); + List<Integer> status = new ArrayList<>(); + if(CollUtil.isEmpty(model.getStatus())){ + status.add(1); + status.add(2); + status.add(3); + status.add(4); + status.add(5); + status.add(6); + model.setStatus(status); + } + List<QueryJhyOrderListVo> maps = jhyOrderMapper.queryOrderList(model); if(CollUtil.isNotEmpty(maps)){ for(QueryJhyOrderListVo queryJhyOrderListVo : maps){ Long id = queryJhyOrderListVo.getId(); List<JhyOrderItemsVo> jhyOrderItemsVos = jhyOrderItemsMapper.selectByOrderId(id); queryJhyOrderListVo.setJhyOrderItemsVos(jhyOrderItemsVos); +// +// String orderAddr = queryJhyOrderListVo.getArea() + queryJhyOrderListVo.getAddress(); +// Long userId = queryJhyOrderListVo.getUserId(); +// List<AddressInfo> addressInfos = jhyOrderMapper.selectAddRessInfoByUserId(userId); +// if(CollUtil.isNotEmpty(addressInfos)){ +// for(AddressInfo addressInfo : addressInfos){ +// StringBuffer address = new StringBuffer(); +// address.append(addressInfo.getDetailAddress()); +// if (StrUtil.isNotBlank(addressInfo.getTagName())) { +// address.append(StrUtil.isNotBlank(addressInfo.getHouseName()) ? addressInfo.getHouseName() : ""); +// if (Constants.ADDRESS_TYPE_HOME.equals(addressInfo.getTagName())) { +// address.append(StrUtil.isNotBlank(addressInfo.getHouseNumber()) ? addressInfo.getHouseNumber() : ""); +// address.append(StrUtil.isNotBlank(addressInfo.getUnitName()) ? addressInfo.getUnitName() : ""); +// } +// } +// if (orderAddr.equals(addressInfo.getAddressArea() + address)) { +// queryJhyOrderListVo.setUnitName(addressInfo.getUnitName()); +// queryJhyOrderListVo.setHouseNumber(addressInfo.getHouseNumber()); +// } +// } +// } } } // if(CollUtil.isNotEmpty(maps)){ @@ -77,7 +117,7 @@ List<JhyOrderItemsVo> jhyOrderItemsList = jhyOrderItemsMapper.selectJhyOrderItemListByOrderId(id); if(CollUtil.isNotEmpty(jhyOrderItemsList)){ for(JhyOrderItemsVo jhyOrderItemsVo : jhyOrderItemsList){ - BigDecimal multiply = jhyOrderItemsVo.getPrice().multiply(new BigDecimal(40)); + BigDecimal multiply = jhyOrderItemsVo.getPrice().multiply(new BigDecimal(50)); jhyOrderItemsVo.setPrice(multiply); jhyOrderItemsVo.setAllPrice(new BigDecimal(StrUtil.isEmpty(jhyOrderItemsVo.getScore())?"0":jhyOrderItemsVo.getScore()).setScale( 2, BigDecimal.ROUND_DOWN )); } @@ -91,6 +131,75 @@ Long id = model.getId(); JhyOrder jhyOrder = jhyOrderMapper.selectByPrimaryKey(id); jhyOrder.setStatus(JhyOrder.ORDER_STATUS_CANCEL); + jhyOrder.setJhyId(""); jhyOrderMapper.updateByPrimaryKey(jhyOrder); } + + public StatisticsVo orderStatistics(String userId) { + // 骑手订单 + List<Map<String, Object>> qsAllData = orderInfoMapper.selectOrderTitleStatistics(null); + List<Map<String, Object>> qsUserData = orderInfoMapper.selectOrderTitleStatistics(userId); + + // 集物员订单 + List<Map<String, Object>> jhyAllData = jhyOrderMapper.selectJhyOrderTitleStatistics(null); + List<Map<String, Object>> jhyUserData = jhyOrderMapper.selectJhyOrderTitleStatistics(userId); + + BigDecimal allCarbon = totalData(qsAllData).add(totalData(jhyAllData)); + BigDecimal userCarbon = totalData(qsUserData).add(totalData(jhyUserData)); + + Integer qsAllCnt = orderInfoMapper.selectOrderCnt(null); + Integer qsUserCnt = orderInfoMapper.selectOrderCnt(userId); + + Integer jhyAllCnt = jhyOrderMapper.selectJhyOrderCnt(null); + Integer jhyUserCnt = jhyOrderMapper.selectJhyOrderCnt(userId); + + Integer allCnt = scoreOrderMapper.selectScoreOrderCnt(null); + Integer userCnt = scoreOrderMapper.selectScoreOrderCnt(userId); + BigDecimal score = jhyOrderMapper.selectTotalScoreHasGet(userId); + + StatisticsVo result = new StatisticsVo(); + result.setTotalReduceCarbon(allCarbon.divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_DOWN)); + result.setReduceCarbon(userCarbon.setScale(2, BigDecimal.ROUND_DOWN)); + + result.setOrderCnt(qsUserCnt + jhyUserCnt + userCnt); + result.setTotalOrderCnt(qsAllCnt + jhyAllCnt + allCnt); + + result.setTotalBuyCnt(allCnt); + result.setScore(score); + return result; + } + + private BigDecimal totalData(List<Map<String, Object>> data) { + Map<String, BigDecimal> type = new HashMap<>(); + type.put("金属", BigDecimal.valueOf(0.02)); + type.put("纸类", BigDecimal.valueOf(1.5)); + type.put("塑料", BigDecimal.valueOf(0.61)); + type.put("衣服", BigDecimal.valueOf(1.63)); + + if (CollUtil.isEmpty(data)) { + return BigDecimal.ZERO; + } + + BigDecimal total = BigDecimal.ZERO; + for (Map<String, Object> map : data) { + String title = (String) map.get("title"); + BigDecimal value = type.get(title); + if (value == null) { + continue; + } + + BigDecimal weight = new BigDecimal(map.get("weight").toString()); + total = total.add(weight.multiply(value)); + } + + return total; + } + + public void assignJhyOrder(AssignJhyOrderDto model,String userId) { + Long orderId = model.getOrderId(); + JhyOrder order = jhyOrderMapper.selectByPrimaryKey(orderId); + order.setJhyId(userId); + order.setStatus(JhyOrder.ORDER_STATUS_IMG); + jhyOrderMapper.updateByPrimaryKey(order); + } } -- Gitblit v1.9.1