|
@@ -2,20 +2,20 @@ package com.ylx.massage.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
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.ylx.common.constant.MassageConstants;
|
|
|
+import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.uuid.IdUtils;
|
|
|
import com.ylx.massage.domain.*;
|
|
|
import com.ylx.massage.enums.JsStatusEnum;
|
|
|
import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
import com.ylx.massage.mapper.TOrderMapper;
|
|
|
-import com.ylx.massage.service.TJsService;
|
|
|
-import com.ylx.massage.service.TOrderService;
|
|
|
-import com.ylx.massage.service.TWxUserService;
|
|
|
-import com.ylx.massage.service.TXiangmuService;
|
|
|
+import com.ylx.massage.service.*;
|
|
|
+import com.ylx.massage.utils.OrderNumberGenerator;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -41,9 +41,15 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Resource
|
|
|
private TXiangmuService xiangmuService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OrderNumberGenerator generator;
|
|
|
+
|
|
|
@Resource
|
|
|
private TJsService jsService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TAddressService addressService;
|
|
|
+
|
|
|
// @Resource
|
|
|
// private TInfoService infoService;
|
|
|
|
|
@@ -53,12 +59,30 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
* @param order
|
|
|
*/
|
|
|
@Override
|
|
|
- public String addOrder(TOrder order) {
|
|
|
- String cId = IdUtils.fastSimpleUUID();
|
|
|
- order.setcId(cId);
|
|
|
+ public TOrder addOrder(TOrder order) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(order.getcJsId())){
|
|
|
+ throw new ServiceException("请选择技师");
|
|
|
+ }
|
|
|
+ if(order.getcGoods().isEmpty()){
|
|
|
+ throw new ServiceException("请选择项目");
|
|
|
+ }
|
|
|
+ //获取用户默认地址
|
|
|
+ TAddress address = addressService.getByOpenId(order.getcOpenId());
|
|
|
+ if(address == null){
|
|
|
+ throw new ServiceException("请先添加地址");
|
|
|
+ }
|
|
|
+
|
|
|
+ order.setcAddress(address.getAddress());
|
|
|
+ order.setcPhone(address.getPhone());
|
|
|
+ order.setcName(address.getUserName());
|
|
|
+ order.setAtlasAdd(address.getAtlasAdd());
|
|
|
+
|
|
|
+ order.setOrderNo(generator.generateNextOrderNumber(OrderNumberGenerator.KEY_PREFIX));
|
|
|
order.setnStatus(OrderStatusEnum.WAIT_PAY.getCode());
|
|
|
order.setDtCreateTime(LocalDateTime.now());
|
|
|
- return save(order) ? cId : null;
|
|
|
+ save(order);
|
|
|
+ return order;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -195,7 +219,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
public Boolean cancle(TOrder order) {
|
|
|
// 获取订单信息
|
|
|
// 根据orderid查询订单信息
|
|
|
- TOrder orderNew = getById(order.getcId());
|
|
|
+ TOrder orderNew = gettOrder(order);
|
|
|
//待接单
|
|
|
if (Objects.equals(orderNew.getnStatus(), OrderStatusEnum.WAIT_JD.getCode())) {
|
|
|
TWxUser user = wxUserService.getById(orderNew.getcOpenId());
|
|
@@ -238,6 +262,13 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private TOrder gettOrder(TOrder order) {
|
|
|
+ LambdaUpdateWrapper<TOrder> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ objectLambdaUpdateWrapper.eq(TOrder::getOrderNo, order.getOrderNo());
|
|
|
+ return this.getOne(objectLambdaUpdateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<TOrder> getAll(Page<TOrder> page, TOrder param) {
|