|
@@ -1,11 +1,8 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.common.constant.MassageConstants;
|
|
import com.ylx.common.constant.MassageConstants;
|
|
|
import com.ylx.common.core.domain.R;
|
|
import com.ylx.common.core.domain.R;
|
|
@@ -13,8 +10,9 @@ import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.massage.domain.*;
|
|
import com.ylx.massage.domain.*;
|
|
|
import com.ylx.massage.domain.dto.ProductOrderCreateRequest;
|
|
import com.ylx.massage.domain.dto.ProductOrderCreateRequest;
|
|
|
import com.ylx.massage.domain.dto.ProductOrderPayRequest;
|
|
import com.ylx.massage.domain.dto.ProductOrderPayRequest;
|
|
|
|
|
+import com.ylx.massage.domain.vo.ProductOrderDetailVo;
|
|
|
|
|
+import com.ylx.massage.domain.vo.ProductOrderListVo;
|
|
|
import com.ylx.massage.enums.BillTypeEnum;
|
|
import com.ylx.massage.enums.BillTypeEnum;
|
|
|
-import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
|
|
import com.ylx.massage.enums.ProductOrderStatusEnum;
|
|
import com.ylx.massage.enums.ProductOrderStatusEnum;
|
|
|
import com.ylx.massage.mapper.ProductMapper;
|
|
import com.ylx.massage.mapper.ProductMapper;
|
|
|
import com.ylx.massage.mapper.ProductOrderInfoMapper;
|
|
import com.ylx.massage.mapper.ProductOrderInfoMapper;
|
|
@@ -24,8 +22,11 @@ import com.ylx.massage.service.TConsumptionLogService;
|
|
|
import com.ylx.massage.service.TRechargeService;
|
|
import com.ylx.massage.service.TRechargeService;
|
|
|
import com.ylx.massage.service.TWxUserService;
|
|
import com.ylx.massage.service.TWxUserService;
|
|
|
import com.ylx.massage.utils.OrderNumberGenerator;
|
|
import com.ylx.massage.utils.OrderNumberGenerator;
|
|
|
-import com.ylx.massage.utils.Sendvoice;
|
|
|
|
|
|
|
+import com.ylx.product.domain.ProductOrderAddress;
|
|
|
|
|
+import com.ylx.product.domain.vo.ProductOrderAddressVo;
|
|
|
|
|
+import com.ylx.product.service.IProductOrderAddressService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Date;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商品订单信息Service实现类
|
|
* 商品订单信息Service实现类
|
|
@@ -63,6 +63,9 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
@Resource
|
|
@Resource
|
|
|
private TConsumptionLogService consumptionLogService;
|
|
private TConsumptionLogService consumptionLogService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IProductOrderAddressService productOrderAddressService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建商品订单
|
|
* 创建商品订单
|
|
@@ -289,4 +292,57 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
//更新订单表
|
|
//更新订单表
|
|
|
updateById(productOrderInfo);
|
|
updateById(productOrderInfo);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询用户商品订单列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param page 分页参数
|
|
|
|
|
+ * @param openId 用户openId
|
|
|
|
|
+ * @return Page<ProductOrderListVo> 订单分页列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Page<ProductOrderListVo> getProductOrderList(Page<ProductOrderListVo> page, String openId) {
|
|
|
|
|
+ //判断openId是否为空
|
|
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
|
|
+ throw new ServiceException("用户openId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<ProductOrderListVo> result = productOrderInfoMapper.selectProductOrderListByOpenId(page, openId);
|
|
|
|
|
+ // 设置订单状态名称
|
|
|
|
|
+ for (ProductOrderListVo vo : result.getRecords()) {
|
|
|
|
|
+ vo.setOrderStatusName(ProductOrderStatusEnum.getDescByCode(vo.getOrderStatus()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询订单详情
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param orderNo 订单编号
|
|
|
|
|
+ * @param openId 用户openId
|
|
|
|
|
+ * @return ProductOrderDetailVo 订单详情
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ProductOrderDetailVo getProductOrderDetail(String orderNo, String openId) {
|
|
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
|
|
+ throw new ServiceException("用户openId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(orderNo)) {
|
|
|
|
|
+ throw new ServiceException("订单编号不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ ProductOrderDetailVo detail = productOrderInfoMapper.selectProductOrderDetailByOrderNoAndOpenId(orderNo, openId);
|
|
|
|
|
+ if (detail == null) {
|
|
|
|
|
+ throw new ServiceException("订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据地址ID查询地址信息
|
|
|
|
|
+ ProductOrderAddress address = productOrderAddressService.getById(detail.getAddressId());
|
|
|
|
|
+ if (address == null) {
|
|
|
|
|
+ throw new ServiceException("地址不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ //设置收货人姓名和手机号
|
|
|
|
|
+ detail.setReceiverName(address.getReceiverName());
|
|
|
|
|
+ detail.setReceiverPhone(address.getReceiverPhone());
|
|
|
|
|
+ detail.setAddressName(address.getFullAddress());
|
|
|
|
|
+ detail.setOrderStatusName(ProductOrderStatusEnum.getDescByCode(detail.getOrderStatus()));
|
|
|
|
|
+ return detail;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|