| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | /** |
| | |
| | | * @return 订单详情 |
| | | */ |
| | | @Override |
| | | public R orderDetail(Long orderId) { |
| | | |
| | | public R orderDetail(Long orderId,String phone) { |
| | | ComShopFlowerOrderPageVO orderVO = new ComShopFlowerOrderPageVO(); |
| | | // 查询订单信息 |
| | | ComShopFlowerOrderDO shopOrderDO = this.baseMapper.selectById(orderId); |
| | | ComShopFlowerOrderDO shopOrderDO = null; |
| | | if (StrUtil.isEmpty(phone)){ |
| | | // 查询订单信息 |
| | | shopOrderDO = this.baseMapper.selectById(orderId); |
| | | }else { |
| | | //查询自提点信息 |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = convenientElevatingPointDAO.selectOne(new LambdaQueryWrapper<ConvenientElevatingPointDO>().eq(ConvenientElevatingPointDO::getWechatAccount, phone)); |
| | | if (isNull(convenientElevatingPointDO)){ |
| | | return R.fail("自提点不存在"); |
| | | } |
| | | Long pointDOId = convenientElevatingPointDO.getId(); |
| | | shopOrderDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopFlowerOrderDO>().eq(ComShopFlowerOrderDO::getId, orderId).eq(ComShopFlowerOrderDO::getPointId, pointDOId)); |
| | | } |
| | | |
| | | |
| | | if (shopOrderDO == null) { |
| | | return R.fail("未查询到订单"); |
| | | } |
| | |
| | | orderVO.setRefundAmount(comShopFlowerRefundOrderDO.getRefundAmount()); |
| | | } |
| | | |
| | | //如果状态时取消状态,更新时间为去取消时间 |
| | | if (shopOrderDO.getStatus() == ComShopFlowerOrderDO.status.yqx){ |
| | | orderVO.setCancelTime(shopOrderDO.getUpdateAt()); |
| | | } |
| | | |
| | | return R.ok(orderVO); |
| | | } |
| | | |
| | |
| | | //退款 |
| | | String refundNo = WXPayUtil.generateNonceStr(); |
| | | try { |
| | | String refundStr = WxPayUtils.refund(appid, mchId, shopOrderDO.getWxTardeNo(), shopOrderDO.getPayAmount(), |
| | | String refundStr = WxPayUtils.refund(appid, mchId, shopOrderDO.getOrderNo(), shopOrderDO.getPayAmount(), |
| | | shopOrderDO.getPayAmount(), refundNo, isTest); |
| | | log.info("退款请求接口返回参数:{}", refundStr); |
| | | Map<String, String> mapResult = WXPayUtil.xmlToMap(refundStr); |
| | |
| | | } catch (Exception e) { |
| | | log.error("申请退款失败," + e.getMessage()); |
| | | e.printStackTrace(); |
| | | return R.fail("取消订单失败"); |
| | | } |
| | | if (this.baseMapper.updateById(shopOrderDO) > 0) { |
| | | // 添加订单操作记录 |
| | |
| | | if (comShopOrderDO == null) { |
| | | return R.fail("订单不存在"); |
| | | } |
| | | if (!(comShopOrderDO.getStatus() == 1) || !(comShopOrderDO.getDeliveryStatus() == 1)) { |
| | | if (!(comShopOrderDO.getStatus() == 8) || !(comShopOrderDO.getDeliveryStatus() == 1)) { |
| | | return R.fail("订单发货失败,订单状态不允许发货"); |
| | | } |
| | | |
| | |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | public R selectOrderLineChart(Long storeId, Integer type) { |
| | | if (1 == type) { |
| | | //近15天的订单量 |
| | | int days = 15; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | } else if (2 == type) { |
| | | //近30天的订单量 |
| | | int days = 30; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | } else { |
| | | //今年所有月份订单量 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectCountOrderMonthByStoreId(storeId); |
| | | Map<String, Integer> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | List<String> yearMonths = DateUtils.getYearMonths(); |
| | | for (String yearMonth : yearMonths) { |
| | | if (!retMap.containsKey(yearMonth)) { |
| | | retMap.put(yearMonth, 0); |
| | | public R selectOrderLineChart(Long storeId, Integer type,Integer tab) { |
| | | if (tab == 1){ |
| | | if (1 == type) { |
| | | //近15天的订单量 |
| | | int days = 15; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | } else if (2 == type) { |
| | | //近30天的订单量 |
| | | int days = 30; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | } else { |
| | | //今年所有月份订单量 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectCountOrderMonthByStoreId(storeId); |
| | | Map<String, Integer> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | List<String> yearMonths = DateUtils.getYearMonths(); |
| | | for (String yearMonth : yearMonths) { |
| | | if (!retMap.containsKey(yearMonth)) { |
| | | retMap.put(yearMonth, 0); |
| | | } |
| | | } |
| | | return R.ok(retMap); |
| | | } |
| | | return R.ok(retMap); |
| | | }else if (2==tab){ |
| | | if (1 == type) { |
| | | //近15天的营收 |
| | | int days = 15; |
| | | return getSumByStoreIdAndDays(storeId, days); |
| | | } else if (2 == type) { |
| | | //近30天的营收 |
| | | int days = 30; |
| | | return getSumByStoreIdAndDays(storeId, days); |
| | | } else { |
| | | //今年所有月份订单量 |
| | | List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectOrderSumMonthByStoreId(storeId); |
| | | Map<String, BigDecimal> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum)); |
| | | List<String> yearMonths = DateUtils.getYearMonths(); |
| | | for (String yearMonth : yearMonths) { |
| | | if (!retMap.containsKey(yearMonth)) { |
| | | retMap.put(yearMonth, BigDecimal.ZERO); |
| | | } |
| | | } |
| | | return R.ok(retMap); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | private R getCountByStoreIdAndDays(Long storeId, int days) { |
| | |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | private R getSumByStoreIdAndDays(Long storeId, int days) { |
| | | List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdNumVOS = this.baseMapper.selectOrderSumPayDayByStoreId(storeId, days); |
| | | Map<String, BigDecimal> retMap = comShopOrderStoreIdNumVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum)); |
| | | List<String> beforeDays = DateUtils.getBeforeDays(days); |
| | | for (String beforeDay : beforeDays) { |
| | | if (!retMap.containsKey(beforeDay)) { |
| | | retMap.put(beforeDay, BigDecimal.ZERO); |
| | | } |
| | | } |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | @Override |
| | | public R pageOrderByDeliveryNo(PageComFlowerOrderListDTO pageComFlowerOrderListDTO) { |
| | | Page page = new Page(pageComFlowerOrderListDTO.getPageNum(), pageComFlowerOrderListDTO.getPageSize()); |