| | |
| | | // 店铺id |
| | | Long storeId = 0L; |
| | | // 生成订单号 |
| | | String orderNo = OrderNoUtils.NextOrderNo(userId); |
| | | String orderNo = OrderNoUtils.NextOrderNoFlower(userId); |
| | | // 配送方式 |
| | | Integer deliveryType = 1; |
| | | // 订单总金额 |
| | |
| | | return R.fail("该规格库存不足,无法下单"); |
| | | } |
| | | orderGoodsDO.setGoodsAttrId(goodsAttrDO.getId()); |
| | | orderGoodsDO.setGoodsAttrPrice(goodsAttrDO.getPrice()); |
| | | orderGoodsDO.setGoodsAttrPrice(createGoodsDTO.getPrice()); |
| | | orderGoodsDO.setPrice(goodsAttrDO.getPrice()); |
| | | orderGoodsDO.setCollatePrice(goodsAttrDO.getCollatePrice()); |
| | | orderGoodsDO.setFreeShippingPrice(goodsAttrDO.getFreeShippingPrice()); |
| | |
| | | orderGoodsDOList.add(orderGoodsDO); |
| | | // 将商品金额计算到订单总金额 |
| | | orderTotal = orderTotal |
| | | .add(orderGoodsDO.getGoodsAttrPrice().multiply(BigDecimal.valueOf(orderGoodsDO.getAmount()))); |
| | | .add(createGoodsDTO.getPrice().multiply(BigDecimal.valueOf(createGoodsDTO.getNum()))); |
| | | } |
| | | } |
| | | // 如果是购物车提交,需要将购物车内商品移除 |
| | | /*if (orderCreateDTO.getSubmitType().equals(ComShopOrderCreateDTO.submitType.cart)) { |
| | | comShopCartDAO.deleteBatchIds(orderCreateDTO.getCartIds()); |
| | | }*/ |
| | | // 创建订单信息 |
| | | ComShopFlowerOrderDO shopOrderDO = new ComShopFlowerOrderDO(); |
| | | shopOrderDO.setOrderNo(orderNo); |
| | |
| | | BeanUtils.copyProperties(convenientMerchantDO, shopStoreVO); |
| | | } |
| | | orderVo.setConvenientMerchantVO(shopStoreVO); |
| | | //已完成、已退款才有评论 TODO |
| | | // if (ComShopFlowerOrderDO.status.ywc == shopOrderDO.getStatus() || ComShopFlowerOrderDO.status.ytk == shopOrderDO.getStatus()) { |
| | | ComShopFlowerEvaluateVO comShopFlowerEvaluateVO = comShopFlowerEvaluateDAO.selectByOrderNo(orderVo.getOrderNo()); |
| | | if (nonNull(comShopFlowerEvaluateVO)) { |
| | | orderVo.setComShopFlowerEvaluateVO(comShopFlowerEvaluateVO); |
| | | } |
| | | // } |
| | | }); |
| | | } |
| | | return R.ok(orderPageVOIPage); |
| | |
| | | } |
| | | BeanUtils.copyProperties(shopOrderDO, orderVO); |
| | | orderVO.setOrderTotal(shopOrderDO.getTotalAmount()); |
| | | |
| | | orderVO.setOrderId(orderId); |
| | | ConvenientMerchantVO shopStoreVO = new ConvenientMerchantVO(); |
| | | // 查询店铺信息 |
| | | ConvenientMerchantDO shopStoreDO = convenientMerchantDAO.selectById(shopOrderDO.getStoreId()); |
| | |
| | | BeanUtils.copyProperties(convenientElevatingPointDO, convenientElevatingPointVO); |
| | | orderVO.setConvenientElevatingPointVO(convenientElevatingPointVO); |
| | | } |
| | | //已完成、已退款才有评论 |
| | | if (ComShopFlowerOrderDO.status.ywc == shopOrderDO.getStatus() || ComShopFlowerOrderDO.status.ytk == shopOrderDO.getStatus()) { |
| | | //已完成、已退款才有评论 TODO |
| | | // if (ComShopFlowerOrderDO.status.ywc == shopOrderDO.getStatus() || ComShopFlowerOrderDO.status.ytk == shopOrderDO.getStatus()) { |
| | | ComShopFlowerEvaluateVO comShopFlowerEvaluateVO = comShopFlowerEvaluateDAO.selectByOrderNo(shopOrderDO.getOrderNo()); |
| | | if (nonNull(comShopFlowerEvaluateVO)) { |
| | | orderVO.setComShopFlowerEvaluateVO(comShopFlowerEvaluateVO); |
| | | } |
| | | // } |
| | | //设置退款金额 |
| | | ComShopFlowerRefundOrderDO comShopFlowerRefundOrderDO = comShopFlowerRefundOrderDAO.selectOne(new LambdaQueryWrapper<ComShopFlowerRefundOrderDO>().eq(ComShopFlowerRefundOrderDO::getOrderId, shopOrderDO.getOrderNo())); |
| | | if (nonNull(comShopFlowerRefundOrderDO)){ |
| | | orderVO.setRefundAmount(comShopFlowerRefundOrderDO.getRefundAmount()); |
| | | } |
| | | |
| | | |
| | | return R.ok(orderVO); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计用户订单数量 |
| | | * |
| | | * @param userId 用户id |
| | | * @return 统计结果 |
| | | */ |
| | | @Override |
| | | public R orderStatistics(Long userId) { |
| | | /*OrderStatisticsVO orderStatisticsVO = new OrderStatisticsVO(); |
| | | // 待付款订单数 |
| | | Integer paymentNum = 0; |
| | | // 待发货订单数 |
| | | Integer deliverNum = 0; |
| | | // 待收货订单数 |
| | | Integer receivingNum = 0; |
| | | List<ComShopOrderDO> shopOrderList = this.baseMapper.selectList(new QueryWrapper<ComShopOrderDO>() |
| | | .eq("user_id", userId).eq("delete_status", ComShopOrderDO.deleteStatus.no)); |
| | | if (!shopOrderList.isEmpty()) { |
| | | for (ComShopOrderDO orderDO : shopOrderList) { |
| | | if (orderDO.getStatus().equals(ComShopOrderDO.status.dfk)) { |
| | | paymentNum++; |
| | | } else if (orderDO.getStatus().equals(ComShopOrderDO.status.dfh)) { |
| | | deliverNum++; |
| | | } else if (orderDO.getStatus().equals(ComShopOrderDO.status.dsh)) { |
| | | receivingNum++; |
| | | } |
| | | } |
| | | } |
| | | orderStatisticsVO.setPaymentNum(paymentNum); |
| | | orderStatisticsVO.setDeliverNum(deliverNum); |
| | | orderStatisticsVO.setReceivingNum(receivingNum); |
| | | return R.ok(orderStatisticsVO);*/ |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 订单发货 |
| | |
| | | if (!(comShopOrderDO.getStatus() == 2) || !(comShopOrderDO.getDeliveryStatus() == 1)) { |
| | | return R.fail("当前订单不能配送"); |
| | | } |
| | | /*ComShopStoreDO storeDO = comShopStoreDAO.selectById(comShopOrderDO.getStoreId()); |
| | | if (storeDO.getDeliveryType() != 1) { |
| | | return R.fail("该商家不支持通过商家配送"); |
| | | }*/ |
| | | |
| | | comShopOrderDO.setDeliveryStatus(4); |
| | | comShopOrderDO.setDeliveryType(1); |
| | | comShopOrderDO.setStatus(3); |
| | |
| | | return R.fail("订单还未发货"); |
| | | } |
| | | // comShopOrderDO.setStatus(4); |
| | | comShopOrderDO.setDeliveryStatus(5); |
| | | comShopOrderDO.setDeliveryStatus(2); |
| | | int updated = comShopFlowerOrderDAO.updateById(comShopOrderDO); |
| | | if (updated == 1) { |
| | | // 创建订单操作记录 |
| | |
| | | return R.fail("操作失败!"); |
| | | } |
| | | |
| | | @Override |
| | | public R shopOrderExportData(ComShopOrderExportDTO comShopOrderExportDTO) { |
| | | // Page page = new Page(); |
| | | // page.setSize(10000); |
| | | // page.setCurrent(1); |
| | | // IPage<ExcelShopOrderDTO> excelShopOrderDTO = comShopOrderDAO.selectOrderExport(page, comShopOrderExportDTO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R shopOrderFundsExportData(ComShopFundsExportDTO comShopFundsExportDTO) { |
| | | // Page page = new Page(); |
| | | // page.setSize(10000); |
| | | // page.setCurrent(1); |
| | | // IPage<ExcelShopFundsDTO> excelShopFundsDTO = comShopOrderDAO.selectFundsExport(page, comShopFundsExportDTO); |
| | | return R.ok(null); |
| | | } |
| | | |
| | | @Override |
| | | public R getFundsStat(Long userId) { |
| | | /* ComShopFundsVO comShopFundsVO = comShopOrderDAO.queryStatis(userId); |
| | | if (comShopFundsVO == null) { |
| | | comShopFundsVO = new ComShopFundsVO(); |
| | | comShopFundsVO.setMonthTotal(new BigDecimal(0)); |
| | | comShopFundsVO.setTodayTotal(new BigDecimal(0)); |
| | | comShopFundsVO.setWeekTotal(new BigDecimal(0)); |
| | | }*/ |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R pageShopFunds(PageComShopFundsSearchDTO pageComShopFundsSearchDTO) { |
| | | /*Long pageNum = pageComShopFundsSearchDTO.getPageNum(); |
| | | Long pageSize = pageComShopFundsSearchDTO.getPageSize(); |
| | | Page page = new Page(); |
| | | if (pageNum == null || 0 == pageNum.longValue()) { |
| | | pageNum = 1l; |
| | | } |
| | | if (pageSize == null || 0 == pageSize.longValue()) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setCurrent(pageNum); |
| | | page.setSize(pageSize); |
| | | IPage<ComShopFundsOrderVO> comShopFundsOrderVOIPage = |
| | | comShopOrderDAO.pageShopFunds(page, pageComShopFundsSearchDTO);*/ |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R pageShopOrder(PageComShopOrderSearchDTO pageComShopOrderSearchDTO) { |
| | |
| | | |
| | | IPage<ComShopOrderSearchVO> ipage = this.baseMapper.pageOrderBy(page, pageComShopOrderSearchDTO); |
| | | return R.ok(ipage); |
| | | } |
| | | |
| | | @Override |
| | | public R capitalDetailByStore(Long id) { |
| | | /*if (id == null) { |
| | | R.fail("订单号不能为空!"); |
| | | } |
| | | CapitalDetailVO vo = this.baseMapper.capitalDetailByStore(id);*/ |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | log.error("未查询到支付订单,订单回调失败,订单号:" + wxPayNotifyOrderDTO.getOrderTradeNo()); |
| | | return; |
| | | } |
| | | shopOrderDO.setStatus(ComShopFlowerOrderDO.status.ddps); |
| | | if (ComShopFlowerOrderDO.deliveryType.store == shopOrderDO.getDeliveryType()){ |
| | | shopOrderDO.setStatus(ComShopFlowerOrderDO.status.ddps); |
| | | }else { |
| | | shopOrderDO.setStatus(ComShopFlowerOrderDO.status.dfh); |
| | | } |
| | | |
| | | shopOrderDO.setPayType(ComShopFlowerOrderDO.payType.wx); |
| | | shopOrderDO.setPayStatus(ComShopFlowerOrderDO.payStatus.yes); |
| | | shopOrderDO.setPayAmount(BigDecimal.valueOf(Double.valueOf(wxPayNotifyOrderDTO.getCashFee()) / 100)); |
| | |
| | | |
| | | Page page = new Page(pageComFlowerOrderListDTO.getPageNum(), pageComFlowerOrderListDTO.getPageSize()); |
| | | |
| | | IPage<ComShopFlowerOrderStoreListVO> ipage = this.baseMapper.pageOrderByStoreId(page, pageComFlowerOrderListDTO); |
| | | return R.ok(ipage); |
| | | IPage<ComShopFlowerOrderStoreListVO> orderPageVOIPage = this.baseMapper.pageOrderByStoreId(page, pageComFlowerOrderListDTO); |
| | | |
| | | if (!orderPageVOIPage.getRecords().isEmpty()) { |
| | | orderPageVOIPage.getRecords().forEach(orderVo -> { |
| | | if (null!=orderVo.getPointId()){ |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = convenientElevatingPointDAO.selectById(orderVo.getPointId()); |
| | | ConvenientElevatingPointVO convenientElevatingPointVO = new ConvenientElevatingPointVO(); |
| | | BeanUtils.copyProperties(convenientElevatingPointDO,convenientElevatingPointVO); |
| | | orderVo.setConvenientElevatingPointVO(convenientElevatingPointVO); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(orderPageVOIPage); |
| | | } |
| | | |
| | | @Override |
| | | public R selectCountByDeliveryType(Integer deliveryType,Long userId) { |
| | | public R selectCountByDeliveryType(Integer deliveryType, Long userId) { |
| | | //1.等待配送 2.配送中 3.待收货 4.待评价 5.已完成 6.已取消 7.已退款 8.总订单 |
| | | String[] statusStr = {"ddps","psz","dsh","dpj","ywc","yqx","ytk"}; |
| | | String[] statusStr = {"ddps", "psz", "dsh", "dpj", "ywc", "yqx", "ytk"}; |
| | | ConvenientMerchantVO convenientMerchantVO = convenientMerchantDAO.selectMerchantByUserId(userId); |
| | | List<ComShopOrderCountVO> comShopOrderCountVOS = this.baseMapper.selectCountByDeliveryType(deliveryType,convenientMerchantVO.getId()); |
| | | List<ComShopOrderCountVO> comShopOrderCountVOS = this.baseMapper.selectCountByDeliveryType(deliveryType, convenientMerchantVO.getId()); |
| | | Map<Integer, Integer> collect = comShopOrderCountVOS.stream().collect(Collectors.toMap(ComShopOrderCountVO::getStatus, ComShopOrderCountVO::getAmount)); |
| | | Map<String,Integer> retMap = new HashMap<>(); |
| | | Map<String, Integer> retMap = new HashMap<>(); |
| | | int amountTotal = 0; |
| | | for (int i = 0; i < statusStr.length; i++) { |
| | | if (collect.containsKey(i)) { |
| | | Integer amount = collect.get(i); |
| | | amountTotal = amountTotal + amount; |
| | | retMap.put(statusStr[i],amount); |
| | | }else { |
| | | retMap.put(statusStr[i],0); |
| | | retMap.put(statusStr[i], amount); |
| | | } else { |
| | | retMap.put(statusStr[i], 0); |
| | | } |
| | | } |
| | | retMap.put("zdd",amountTotal); |
| | | retMap.put("zdd", amountTotal); |
| | | |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | @Override |
| | | public R selectCountByUserId(Long userId){ |
| | | public R selectCountByUserId(Long userId) { |
| | | ConvenientMerchantVO convenientMerchantVO = convenientMerchantDAO.selectMerchantByUserId(userId); |
| | | Long storeId = convenientMerchantVO.getId(); |
| | | Map<String,Object> retMap = new HashMap<>(); |
| | | Map<String, Object> retMap = new HashMap<>(); |
| | | //查询我的店铺订单量 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectCountByStoreId(storeId, null); |
| | | Map<String, Integer> zddlMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | retMap.put("zddl",zddlMap); |
| | | retMap.put("zddl", zddlMap); |
| | | //查询我的店铺拼单订单 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS1 = this.baseMapper.selectCountByStoreId(storeId, ComShopFlowerOrderDO.deliveryType.store); |
| | | Map<String, Integer> pdddMap = comShopOrderStoreIdCountVOS1.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | retMap.put("pddd",pdddMap); |
| | | retMap.put("pddd", pdddMap); |
| | | //查询我的店铺快递订单 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS2 = this.baseMapper.selectCountByStoreId(storeId, ComShopFlowerOrderDO.deliveryType.express); |
| | | Map<String, Integer> kdddMap = comShopOrderStoreIdCountVOS2.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | retMap.put("kddd",kdddMap); |
| | | retMap.put("kddd", kdddMap); |
| | | |
| | | //拼单订单各状态 |
| | | R r = this.selectCountByDeliveryType(ComShopFlowerOrderDO.deliveryType.store,userId); |
| | | retMap.put("pdddStatus",r.getData()); |
| | | R r = this.selectCountByDeliveryType(ComShopFlowerOrderDO.deliveryType.store, userId); |
| | | retMap.put("pdddStatus", r.getData()); |
| | | |
| | | //快递订单各状态 |
| | | R r1 = this.selectCountByDeliveryType(ComShopFlowerOrderDO.deliveryType.express,userId); |
| | | retMap.put("kdddStatus",r1.getData()); |
| | | R r1 = this.selectCountByDeliveryType(ComShopFlowerOrderDO.deliveryType.express, userId); |
| | | retMap.put("kdddStatus", r1.getData()); |
| | | //营业额 |
| | | List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS3 = this.baseMapper.selectSumAmountByStoreId(storeId); |
| | | Map<String, Integer> yyeMap = comShopOrderStoreIdCountVOS3.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); |
| | | retMap.put("yye",yyeMap); |
| | | retMap.put("yye", yyeMap); |
| | | //在售商品 |
| | | Integer countSale = comShopFlowerGoodsDAO.selectCountSaleByStoreId(storeId); |
| | | retMap.put("countSale",countSale); |
| | | retMap.put("countSale", countSale); |
| | | //退款申请 |
| | | Integer refundOrder = comShopFlowerRefundOrderDAO.selectCountByStoreId(storeId); |
| | | retMap.put("refundOrder",refundOrder); |
| | | retMap.put("refundOrder", refundOrder); |
| | | |
| | | return R.ok(retMap); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 获取商家的营业额和可结算金额 |
| | | * |
| | | * @param storeId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getQuota(Long storeId){ |
| | | public R getQuota(Long storeId) { |
| | | //营业额 |
| | | BigDecimal turnover = this.baseMapper.selectTurnover(storeId); |
| | | //可结算 |
| | | BigDecimal settlement = this.baseMapper.selectSettlement(storeId); |
| | | |
| | | Map<String,Object> retMap = new HashMap<>(); |
| | | retMap.put("turnover",turnover); |
| | | retMap.put("settlement",settlement); |
| | | Map<String, Object> retMap = new HashMap<>(); |
| | | retMap.put("turnover", turnover); |
| | | retMap.put("settlement", settlement); |
| | | return R.ok(retMap); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R selectSumOrderAndAmountByStoreId(Long storeId){ |
| | | public R selectSumOrderAndAmountByStoreId(Long storeId) { |
| | | List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectSumOrderAndAmountByStoreId(storeId); |
| | | Map<String, Object> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum)); |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | public R selectOrderLineChart(Long storeId,Integer type){ |
| | | |
| | | if (1==type){ |
| | | public R selectOrderLineChart(Long storeId, Integer type) { |
| | | if (1 == type) { |
| | | //近15天的订单量 |
| | | int days = 15; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | }else if (2 ==type){ |
| | | } else if (2 == type) { |
| | | //近30天的订单量 |
| | | int days = 30; |
| | | return getCountByStoreIdAndDays(storeId, days); |
| | | }else { |
| | | } 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(); |
| | | } |
| | | |
| | | private R getCountByStoreIdAndDays(Long storeId, int days) { |
| | |
| | | } |
| | | return R.ok(retMap); |
| | | } |
| | | |
| | | |
| | | } |