| | |
| | | import cn.lili.modules.goods.entity.dos.Goods; |
| | | import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; |
| | | import cn.lili.modules.goods.service.GoodsService; |
| | | import cn.lili.modules.lmk.domain.vo.OrderCountVO; |
| | | import cn.lili.modules.lmk.enums.general.AdminRoleEnum; |
| | | import cn.lili.modules.member.entity.dos.Member; |
| | | import cn.lili.modules.member.entity.dto.MemberAddressDTO; |
| | |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.rocketmq.spring.core.RocketMQTemplate; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import cn.lili.modules.permission.entity.dos.Role; |
| | | /** |
| | |
| | | @Autowired |
| | | private AdminUserService adminUserService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<Object,Object> redisTemplate; |
| | | |
| | | private final static String LOCK_ORDER_NO_MQ="lock_order_no_mq:"; |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void intoDB(TradeDTO tradeDTO) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OrderCountVO countByIdOrder(String id) { |
| | | OrderSearchParams orderSearchParams = new OrderSearchParams(); |
| | | |
| | | orderSearchParams.setOrderStatus(OrderStatusEnum.COMPLETED.name()); |
| | | orderSearchParams.setMemberId(id); |
| | | QueryWrapper queryWrapper = orderSearchParams.queryWrapper(); |
| | | queryWrapper.groupBy("o.id"); |
| | | queryWrapper.orderByDesc("o.id"); |
| | | List<OrderSimpleVO> list = this.baseMapper.queryByParamsCount(queryWrapper); |
| | | OrderCountVO orderCountVO = new OrderCountVO(); |
| | | orderCountVO.setOrderNumCount(0); |
| | | orderCountVO.setOrderPriceCount(BigDecimal.ZERO); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return orderCountVO; |
| | | }else { |
| | | for (OrderSimpleVO vo : list) { |
| | | if (vo == null) { |
| | | System.out.println("出现空元素"); |
| | | continue; // 跳过null元素,或根据业务处理 |
| | | } |
| | | orderCountVO.setOrderNumCount(orderCountVO.getOrderNumCount() + 1); |
| | | |
| | | // 金额累加:用BigDecimal处理,避免精度问题 |
| | | BigDecimal flowPrice = vo.getFlowPrice() != null ? |
| | | BigDecimal.valueOf(vo.getFlowPrice()) : BigDecimal.ZERO; |
| | | |
| | | // 用BigDecimal的add方法累加 |
| | | BigDecimal totalPrice = orderCountVO.getOrderPriceCount().add(flowPrice); |
| | | orderCountVO.setOrderPriceCount(totalPrice); |
| | | |
| | | } |
| | | } |
| | | return orderCountVO; |
| | | } |
| | | @Override |
| | | public IPage<OrderSimpleVO> queryByParams(OrderSearchParams orderSearchParams,Boolean needHide) { |
| | | QueryWrapper queryWrapper = orderSearchParams.queryWrapper(); |
| | | queryWrapper.groupBy("o.id"); |
| | |
| | | } |
| | | } |
| | | |
| | | for (OrderSimpleVO vo : page.getRecords()){ |
| | | Member member = memberMapperMapper.selectById(vo.getMemberId()); |
| | | if (member != null){ |
| | | vo.setNickName(member.getNickName()); |
| | | } |
| | | } |
| | | return page; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public IPage<OrderSimpleXcxVO> queryByXcxParams(OrderSearchXcxParams orderSearchParams) { |
| | | QueryWrapper queryWrapper = orderSearchParams.queryWrapper(); |
| | |
| | | vo.setConsigneeMobile(CommonUtil.maskMobile(vo.getConsigneeMobile())); |
| | | } |
| | | } |
| | | |
| | | |
| | | XSSFWorkbook workbook = initOrderExportData(orderExportDTOS); |
| | | try { |
| | | // 设置响应头 |
| | |
| | | @Override |
| | | @Transactional |
| | | public String sendMqMessage(String snNo) { |
| | | //限制30秒只能请求一次避免出现重新提交问题 |
| | | Boolean b = redisTemplate.opsForValue().setIfAbsent(LOCK_ORDER_NO_MQ + snNo, snNo,30, TimeUnit.SECONDS); |
| | | if ( Boolean.FALSE.equals(b)){ |
| | | throw new ServiceException("请在30秒后重试"); |
| | | } |
| | | Order order = this.getBySn(snNo); |
| | | if (order == null) { |
| | | throw new ServiceException(ResultCode.ORDER_NOT_EXIST); |
| | |
| | | throw new ServiceException(ResultCode.ORDER_CAN_NOT_CANCEL); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | // 创建表头 |
| | | Row header = sheet.createRow(0); |
| | | String[] headers = {"主订单编号", "子订单编号", "选购商品", "商品数量", "商品ID", "商品单价", "订单应付金额", |
| | | "运费", "优惠总金额", "平台优惠", "商家优惠", "商家改价", "支付方式", "收件人", "收件人手机号", |
| | | "运费", "优惠总金额", "平台优惠", "商家优惠", "商家改价", "支付方式","买家名称", "收件人", "收件人手机号", |
| | | "省", "市", "区", "街道", "详细地址", "买家留言", "订单提交时间", "支付完成时间", "来源", |
| | | "订单状态", "订单类型", "售后状态", "取消原因", "发货时间", "完成时间", "店铺"}; |
| | | |
| | |
| | | row.createCell(10).setCellValue(dto.getStoreMarketingCost()!=null?dto.getStoreMarketingCost():0); |
| | | row.createCell(11).setCellValue(dto.getUpdatePrice()!=null?dto.getUpdatePrice():0); |
| | | row.createCell(12).setCellValue(dto.getPaymentMethod()); |
| | | row.createCell(13).setCellValue(dto.getConsigneeName()); |
| | | row.createCell(14).setCellValue(dto.getConsigneeMobile()); |
| | | row.createCell(15).setCellValue(dto.getProvince()); |
| | | row.createCell(16).setCellValue(dto.getCity()); |
| | | row.createCell(17).setCellValue(dto.getDistrict()); |
| | | row.createCell(18).setCellValue(dto.getStreet()); |
| | | row.createCell(19).setCellValue(dto.getConsigneeDetail()); |
| | | row.createCell(20).setCellValue(dto.getRemark()); |
| | | row.createCell(21).setCellValue(dto.getCreateTime()); |
| | | row.createCell(22).setCellValue(dto.getPaymentTime()); |
| | | row.createCell(23).setCellValue(dto.getClientType()); |
| | | row.createCell(24).setCellValue(dto.getOrderStatus()); |
| | | row.createCell(25).setCellValue(dto.getOrderType()); |
| | | row.createCell(26).setCellValue(dto.getAfterSaleStatus()); |
| | | row.createCell(27).setCellValue(dto.getCancelReason()); |
| | | row.createCell(28).setCellValue(dto.getLogisticsTime()); |
| | | row.createCell(29).setCellValue(dto.getCompleteTime()); |
| | | row.createCell(30).setCellValue(dto.getStoreName()); |
| | | |
| | | row.createCell(13).setCellValue(dto.getNickName()); |
| | | |
| | | row.createCell(14).setCellValue(dto.getConsigneeName()); |
| | | row.createCell(15).setCellValue(dto.getConsigneeMobile()); |
| | | row.createCell(16).setCellValue(dto.getProvince()); |
| | | row.createCell(17).setCellValue(dto.getCity()); |
| | | row.createCell(18).setCellValue(dto.getDistrict()); |
| | | row.createCell(19).setCellValue(dto.getStreet()); |
| | | row.createCell(20).setCellValue(dto.getConsigneeDetail()); |
| | | row.createCell(21).setCellValue(dto.getRemark()); |
| | | row.createCell(22).setCellValue(dto.getCreateTime()); |
| | | row.createCell(23).setCellValue(dto.getPaymentTime()); |
| | | row.createCell(24).setCellValue(dto.getClientType()); |
| | | row.createCell(25).setCellValue(dto.getOrderStatus()); |
| | | row.createCell(26).setCellValue(dto.getOrderType()); |
| | | row.createCell(27).setCellValue(dto.getAfterSaleStatus()); |
| | | row.createCell(28).setCellValue(dto.getCancelReason()); |
| | | row.createCell(29).setCellValue(dto.getLogisticsTime()); |
| | | row.createCell(30).setCellValue(dto.getCompleteTime()); |
| | | row.createCell(31).setCellValue(dto.getStoreName()); |
| | | } |
| | | |
| | | //修改列宽 |