|
@@ -1,6 +1,7 @@
|
|
|
package com.fdage.controller.app;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.fdage.base.dto.OrderAppReqDto;
|
|
|
import com.fdage.base.entity.TmOrder;
|
|
|
import com.fdage.base.entity.TmUser;
|
|
|
import com.fdage.base.service.impl.TmOrderServiceImpl;
|
|
@@ -14,11 +15,10 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -57,4 +57,52 @@ public class AppOrderController extends BaseController {
|
|
|
resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/getOne")
|
|
|
+ @ApiOperation(value = "根据Id获取单个订单详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "query", required = true, dataType = "String")
|
|
|
+ })
|
|
|
+ public Result<TmOrder> getOneById(@RequestParam(name = "orderId") String orderId){
|
|
|
+ if(StringUtils.isBlank(orderId)){
|
|
|
+ return Result.failure("订单ID缺失");
|
|
|
+ }
|
|
|
+ TmOrder tmOrder = tmOrderService.getById(orderId);
|
|
|
+ if(null == tmOrder){
|
|
|
+ return Result.failure("订单不存在");
|
|
|
+ }
|
|
|
+ return Result.success(tmOrder);
|
|
|
+ }
|
|
|
+ @PostMapping("/addNew")
|
|
|
+ @ApiOperation(value = "创建订单")
|
|
|
+ public Result<TmOrder> addNew(@RequestBody OrderAppReqDto orderAppReqDto){
|
|
|
+
|
|
|
+ if(null == orderAppReqDto){
|
|
|
+ return Result.failure("入参缺失");
|
|
|
+ }
|
|
|
+ if(null == orderAppReqDto.getReservePersonNum()){
|
|
|
+ return Result.failure("用餐人数缺失");
|
|
|
+ }
|
|
|
+ if(null == orderAppReqDto.getReserveDate()){
|
|
|
+ return Result.failure("用餐日期缺失");
|
|
|
+ }
|
|
|
+ if(null == orderAppReqDto.getReserveTime()){
|
|
|
+ return Result.failure("用餐到店时间缺失");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(orderAppReqDto.getReserveUserPhone())){
|
|
|
+ return Result.failure("联系人手机号缺失");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(orderAppReqDto.getMsgCode())){
|
|
|
+ return Result.failure("短信验证码缺失");
|
|
|
+ }
|
|
|
+ //校验短信验证码
|
|
|
+ String redisCOde = (String) redisTemplate.opsForValue().get(orderAppReqDto.getReserveUserPhone());
|
|
|
+ if(!StringUtils.equals(redisCOde , orderAppReqDto.getMsgCode())){
|
|
|
+ return Result.failure("验证码非法或者已经过了有效期");
|
|
|
+ }
|
|
|
+ TmOrder newOrder = new TmOrder();
|
|
|
+ BeanUtils.copyProperties(orderAppReqDto , newOrder);
|
|
|
+ newOrder = tmOrderService.addNew(newOrder);
|
|
|
+ return Result.success(newOrder);
|
|
|
+ }
|
|
|
+
|
|
|
}
|