| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.core.annotation.LoginRequired; |
| | | import com.doumee.core.annotation.LoginShopRequired; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.dao.business.model.Areas; |
| | | import com.doumee.dao.business.model.Banner; |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.dao.dto.CalculateLocalPriceDTO; |
| | | import com.doumee.dao.dto.CalculateRemotePriceDTO; |
| | | import com.doumee.dao.vo.AccountResponse; |
| | | import com.doumee.dao.vo.PriceCalculateVO; |
| | | import com.doumee.service.business.AreasService; |
| | | import com.doumee.service.business.BannerService; |
| | | import com.doumee.service.business.CategoryService; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.dto.CancelOrderDTO; |
| | | import com.doumee.dao.dto.CreateOrderDTO; |
| | | import com.doumee.dao.dto.DriverVerifyDTO; |
| | | import com.doumee.dao.dto.ShopVerifyDTO; |
| | | import com.doumee.dao.dto.MyOrderDTO; |
| | | import com.doumee.dao.vo.MyOrderDetailVO; |
| | | import com.doumee.dao.vo.MyOrderVO; |
| | | import com.doumee.dao.vo.OverdueFeeVO; |
| | | import com.doumee.dao.vo.PayResponse; |
| | | import com.doumee.service.business.OrdersService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * 订单接口 |
| | | * |
| | | * @Author : Rk |
| | | * @create 2025/7/15 15:49 |
| | | */ |
| | | @Api(tags = "配置类接口") |
| | | @Api(tags = "订单接口") |
| | | @Trace(exclude = true) |
| | | @RestController |
| | | @RequestMapping("/web/config") |
| | | @RequestMapping("/web/order") |
| | | @Slf4j |
| | | public class ConfigApi extends ApiController{ |
| | | |
| | | @Autowired |
| | | private CategoryService categoryService; |
| | | |
| | | @Autowired |
| | | private AreasService areasService; |
| | | |
| | | @Autowired |
| | | private BannerService bannerService; |
| | | public class OrdersApi extends ApiController { |
| | | |
| | | @Autowired |
| | | private OrdersService ordersService; |
| | | |
| | | @ApiOperation(value = "获取分类列表", notes = "小程序端") |
| | | @GetMapping("/getCategoryList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "type", value = "类型:1=车辆类型;2=物品分类;3=物品等级;4=物品尺寸;", required = true) |
| | | }) |
| | | public ApiResponse<List<Category>> getCategoryList(@RequestParam Integer type) { |
| | | return ApiResponse.success("操作成功",categoryService.getCategoryList(type)); |
| | | } |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | @ApiOperation(value = "获取开放城市列表", notes = "返回已开放城市,含首字母,按首字母排序") |
| | | @GetMapping("/getOpenCityList") |
| | | public ApiResponse<List<Areas>> getOpenCityList() { |
| | | return ApiResponse.success("操作成功", areasService.getOpenCityList()); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取轮播图列表", notes = "根据位置返回轮播图,含图片全路径") |
| | | @GetMapping("/getBannerList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "position", value = "位置:0=会员端首页轮播;1=司机APP引导页;", required = true) |
| | | }) |
| | | public ApiResponse<List<Banner>> getBannerList(@RequestParam Integer position) { |
| | | return ApiResponse.success("操作成功", bannerService.findListByPosition(position)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取城市已开通物品尺寸", notes = "根据城市主键查询已开通的物品尺寸(category type=4)") |
| | | @GetMapping("/getCitySizeList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "cityId", value = "城市主键", required = true) |
| | | }) |
| | | public ApiResponse<List<Category>> getCitySizeList(@RequestParam Integer cityId) { |
| | | return ApiResponse.success("操作成功", categoryService.getCitySizeList(cityId)); |
| | | @LoginRequired |
| | | @ApiOperation(value = "创建订单", notes = "创建就地/异地寄存订单,返回微信支付参数") |
| | | @PostMapping("/create") |
| | | public ApiResponse<PayResponse> createOrder(@RequestBody @Valid CreateOrderDTO dto) { |
| | | PayResponse payResponse = ordersService.createOrder(dto, getMemberId()); |
| | | if (Objects.nonNull(payResponse) && StringUtils.isNotBlank(payResponse.getLockKey())) { |
| | | redisTemplate.delete(payResponse.getLockKey()); |
| | | } |
| | | return ApiResponse.success("操作成功", payResponse); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "计算保价费用", notes = "根据报价金额计算保价费用") |
| | | @GetMapping("/calculateInsuranceFee") |
| | | @ApiOperation(value = "继续支付", notes = "待支付订单重新唤起微信支付") |
| | | @PostMapping("/continuePay/{orderId}") |
| | | public ApiResponse<PayResponse> continuePay(@PathVariable Integer orderId) { |
| | | return ApiResponse.success("操作成功", ordersService.continuePay(orderId, getMemberId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "会员订单分页", notes = "小程序端,按状态筛选") |
| | | @PostMapping("/myPage") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "BigDecimal", name = "declaredValue", value = "报价金额", required = true), |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), |
| | | }) |
| | | public ApiResponse<PageData<MyOrderVO>> myPage(@RequestBody @Validated PageWrap<MyOrderDTO> pageWrap) { |
| | | return ApiResponse.success("查询成功", ordersService.findMyOrderPage(pageWrap, getMemberId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "会员订单详情", notes = "小程序端,查询当前会员的订单详情") |
| | | @GetMapping("/detail/{orderId}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "orderId", value = "订单主键", required = true), |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true) |
| | | }) |
| | | public ApiResponse<BigDecimal> calculateInsuranceFee(@RequestParam BigDecimal declaredValue) { |
| | | return ApiResponse.success("操作成功", ordersService.calculateInsuranceFee(declaredValue)); |
| | | public ApiResponse<MyOrderDetailVO> detail(@PathVariable Integer orderId) { |
| | | return ApiResponse.success("查询成功", ordersService.findMyOrderDetail(orderId, getMemberId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "计算就地存取预估费用", notes = "根据城市、天数、物品类型和数量计算就地存取预估费用") |
| | | @PostMapping("/calculateLocalPrice") |
| | | public ApiResponse<PriceCalculateVO> calculateLocalPrice(@RequestBody @Valid CalculateLocalPriceDTO dto) { |
| | | return ApiResponse.success("操作成功", ordersService.calculateLocalPrice(dto)); |
| | | @ApiOperation(value = "会员取消订单", notes = "仅异地寄存订单可取消") |
| | | @PostMapping("/cancel") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true) |
| | | }) |
| | | public ApiResponse cancel(@RequestBody @Validated CancelOrderDTO dto) { |
| | | ordersService.cancelOrder(dto.getOrderId(), getMemberId(), dto.getCancelReason()); |
| | | return ApiResponse.success("操作成功"); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "计算异地存取预估费用", notes = "根据距离、物品类型和数量计算异地存取预估费用") |
| | | @PostMapping("/calculateRemotePrice") |
| | | public ApiResponse<PriceCalculateVO> calculateRemotePrice(@RequestBody @Valid CalculateRemotePriceDTO dto) { |
| | | return ApiResponse.success("操作成功", ordersService.calculateRemotePrice(dto)); |
| | | @ApiOperation(value = "查询超时费用", notes = "查询订单逾期天数和逾期费用") |
| | | @GetMapping("/overdueFee/{orderId}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "orderId", value = "订单主键", required = true), |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true) |
| | | }) |
| | | public ApiResponse<OverdueFeeVO> overdueFee(@PathVariable Integer orderId) { |
| | | return ApiResponse.success("查询成功", ordersService.calculateOverdueFee(orderId)); |
| | | } |
| | | |
| | | @LoginShopRequired |
| | | @ApiOperation(value = "门店核销收件", notes = "门店通过核销码确认收件/取件") |
| | | @PostMapping("/shopVerify") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "门店token值", required = true) |
| | | }) |
| | | public ApiResponse shopVerify(@RequestBody @Validated ShopVerifyDTO dto) { |
| | | ordersService.shopVerifyOrder(dto.getVerifyCode(), getShopId(), dto.getImages(), dto.getRemark()); |
| | | return ApiResponse.success("核销成功"); |
| | | } |
| | | |
| | | @LoginShopRequired |
| | | @ApiOperation(value = "核销司机码", notes = "异地寄存且有取件门店的订单,通过司机核销码确认到店") |
| | | @PostMapping("/driverVerify") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true) |
| | | }) |
| | | public ApiResponse driverVerify(@RequestBody @Validated DriverVerifyDTO dto) { |
| | | ordersService.driverVerifyOrder(dto.getVerifyCode(), dto.getImages(), dto.getRemark(), getShopId()); |
| | | return ApiResponse.success("核销成功"); |
| | | } |
| | | |
| | | @LoginShopRequired |
| | | @ApiOperation(value = "门店订单详情", notes = "门店端查询订单详情,支持订单主键或核销码查询") |
| | | @GetMapping("/shopDetail") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "门店token值", required = true), |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "orderId", value = "订单主键"), |
| | | @ApiImplicitParam(paramType = "query", dataType = "String", name = "verifyCode", value = "核销码") |
| | | }) |
| | | public ApiResponse<MyOrderDetailVO> shopDetail(@RequestParam(required = false) Integer orderId, |
| | | @RequestParam(required = false) String verifyCode) { |
| | | return ApiResponse.success("查询成功", ordersService.findShopOrderDetail(orderId, verifyCode)); |
| | | } |
| | | |
| | | |