2023-08-18 10:15:56 +08:00
|
|
|
package com.jsowell.api.uniapp;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
|
|
|
|
import com.jsowell.common.core.controller.BaseController;
|
|
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
|
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
|
|
|
|
import com.jsowell.pile.domain.OrderPileOccupy;
|
|
|
|
|
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
|
|
|
|
|
import com.jsowell.pile.service.OrderPileOccupyService;
|
|
|
|
|
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 占桩订单controller
|
2023-08-18 09:27:22 +08:00
|
|
|
*
|
2023-08-18 10:15:56 +08:00
|
|
|
* @author Lemon
|
2023-08-18 09:27:22 +08:00
|
|
|
* @Date 2023/8/18 8:55
|
2023-08-18 10:15:56 +08:00
|
|
|
*/
|
|
|
|
|
@Anonymous
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/uniapp/occupyOrder")
|
|
|
|
|
public class OccupyOrderController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private OrderPileOccupyService orderPileOccupyService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询站点占桩费率
|
|
|
|
|
* @param stationId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/getStationOccupyFee/{stationId}")
|
|
|
|
|
public RestApiResponse<?> getStationOccupyFee(@PathVariable("stationId") String stationId) {
|
|
|
|
|
logger.info("查询站点占桩费率 params:{}", stationId);
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("查询站点占桩费率 error,", e);
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询站点占桩费率 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成占桩订单
|
|
|
|
|
* https://api.jsowellcloud.com/uniapp/occupyOrder/generateOccupyOrder
|
|
|
|
|
* @param request
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/generateOccupyOrder")
|
|
|
|
|
public RestApiResponse<?> generateOccupyOrder(HttpServletRequest request, @RequestBody GenerateOccupyOrderDTO dto) {
|
|
|
|
|
logger.info("生成占桩订单 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
// 获取memberId
|
|
|
|
|
String memberId = getMemberIdByAuthorization(request);
|
|
|
|
|
if (StringUtils.isEmpty(memberId)) {
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
|
|
|
|
}
|
|
|
|
|
dto.setMemberId(memberId);
|
|
|
|
|
String occupyOrderCode = orderPileOccupyService.generateOccupyPileOrder(dto);
|
|
|
|
|
if (StringUtils.isNotBlank(occupyOrderCode)) {
|
|
|
|
|
response = new RestApiResponse<>(ImmutableMap.of("occupyOrderCode", occupyOrderCode));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("生成占桩订单 error,", e);
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("生成占桩订单 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询占桩订单列表页
|
|
|
|
|
@GetMapping("/getOccupyOrderInfo")
|
|
|
|
|
public RestApiResponse<?> getOccupyOrderInfo(HttpServletRequest request) {
|
|
|
|
|
// 获取memberId
|
|
|
|
|
String memberId = getMemberIdByAuthorization(request);
|
|
|
|
|
if (StringUtils.isEmpty(memberId)) {
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询占桩订单列表页 memberId:{}", memberId);
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
List<OrderPileOccupyVO> orderInfoList = orderPileOccupyService.getOccupyOrderInfo(memberId);
|
|
|
|
|
response = new RestApiResponse<>(orderInfoList);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("查询占桩订单列表页 error, ", e);
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询占桩订单列表页 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询占桩订单详情页
|
2023-08-18 09:27:22 +08:00
|
|
|
}
|