订单api
This commit is contained in:
parent
51c5623345
commit
df9235dc10
@ -4,8 +4,10 @@ import com.cdzy.common.model.EbikeUserFaultreportDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportQueryDto;
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -35,4 +37,28 @@ public interface OrdersFeignClient {
|
||||
*/
|
||||
@PostMapping("ebikeUserFaultreport/list")
|
||||
JsonResult<?> getUserReportList(@RequestBody EbikeUserFaultreportQueryDto queryParam);
|
||||
|
||||
/**
|
||||
* 订单支付完成
|
||||
* @param queryParam 支付信息
|
||||
* @return @ {@code 200} 成功,{@code 500} 失败
|
||||
*/
|
||||
@PostMapping("userOrders/payment")
|
||||
JsonResult<?> payment(@RequestBody EbikeUserFaultreportQueryDto queryParam);
|
||||
|
||||
/**
|
||||
* 订单发起退款
|
||||
* @param orderId 订单ID
|
||||
* @return @ {@code 200} 成功,{@code 500} 失败
|
||||
*/
|
||||
@GetMapping("userOrders/refund")
|
||||
JsonResult<?> refund(@RequestParam("orderId")Long orderId);
|
||||
|
||||
/**
|
||||
* 订单退款完成
|
||||
* @param orderId 订单ID
|
||||
* @return @ {@code 200} 成功,{@code 500} 失败
|
||||
*/
|
||||
@GetMapping("userOrders/doneRefund")
|
||||
JsonResult<?> doneRefund(@RequestParam("orderId")Long orderId);
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.ebike.feign.model.res;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author attiya
|
||||
* @since 2025-04-24
|
||||
*/
|
||||
@Data
|
||||
public class ResFeignOrderPaymentDto {
|
||||
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 支付方式:wechat/alipay/balance
|
||||
*/
|
||||
private String paymentMethod;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
private LocalDateTime paymentTime;
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.PageParam;
|
||||
import com.cdzy.orders.model.dto.req.ReqBikeDto;
|
||||
import com.cdzy.orders.model.dto.req.ReqOrderDto;
|
||||
import com.ebike.feign.model.res.ResFeignOrderPaymentDto;
|
||||
import com.cdzy.orders.model.dto.res.RspBikeDto;
|
||||
import com.cdzy.orders.model.entity.UserOrders;
|
||||
import com.cdzy.orders.service.UserOrdersService;
|
||||
@ -106,6 +107,43 @@ public class EbikeUserOrdersController {
|
||||
return JsonResult.success(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付。
|
||||
*
|
||||
* @param paymentDto 支付信息
|
||||
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||
*/
|
||||
@PostMapping("payment")
|
||||
public JsonResult<?> payment(@RequestBody @Validated ResFeignOrderPaymentDto paymentDto) {
|
||||
userOrdersService.payment(paymentDto);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款。
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||
*/
|
||||
@GetMapping("refund")
|
||||
public JsonResult<?> refund(@RequestParam("orderId")Long orderId) {
|
||||
userOrdersService.refund(orderId);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款完成。
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||
*/
|
||||
@GetMapping("doneRefund")
|
||||
public JsonResult<?> doneRefund(@RequestParam("orderId")Long orderId) {
|
||||
userOrdersService.doneRefund(orderId);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查车辆是否在运营区内。
|
||||
*
|
||||
|
||||
@ -21,6 +21,11 @@ public interface OrderStatus {
|
||||
*/
|
||||
int PENDING_PAYMENT = 2;
|
||||
|
||||
/**
|
||||
* 已支付
|
||||
*/
|
||||
int PAID = 3;
|
||||
|
||||
/**
|
||||
* 退款中
|
||||
*/
|
||||
|
||||
@ -2,6 +2,7 @@ package com.cdzy.orders.service;
|
||||
|
||||
import com.cdzy.orders.model.dto.req.ReqBikeDto;
|
||||
import com.cdzy.orders.model.dto.req.ReqOrderDto;
|
||||
import com.ebike.feign.model.res.ResFeignOrderPaymentDto;
|
||||
import com.cdzy.orders.model.dto.res.RspBikeDto;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.orders.model.entity.UserOrders;
|
||||
@ -72,4 +73,22 @@ public interface UserOrdersService extends IService<UserOrders> {
|
||||
* @return true/false
|
||||
*/
|
||||
boolean checkBikeInParking(String bikeCode);
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
* @param paymentDto 支付信息
|
||||
*/
|
||||
void payment(ResFeignOrderPaymentDto paymentDto);
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
void refund(Long orderId);
|
||||
|
||||
/**
|
||||
* 订单退款完成
|
||||
* @param orderId 订单ID
|
||||
*/
|
||||
void doneRefund(Long orderId);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.cdzy.orders.enums.OrderType;
|
||||
import com.cdzy.orders.mapper.UserOrdersMapper;
|
||||
import com.cdzy.orders.model.dto.req.ReqBikeDto;
|
||||
import com.cdzy.orders.model.dto.req.ReqOrderDto;
|
||||
import com.ebike.feign.model.res.ResFeignOrderPaymentDto;
|
||||
import com.cdzy.orders.model.dto.res.RedisPoint;
|
||||
import com.cdzy.orders.model.dto.res.RspBikeDto;
|
||||
import com.cdzy.orders.model.entity.UserOrders;
|
||||
@ -274,6 +275,36 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
||||
return redisUtil.isPointInParking(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOrgId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refund(Long orderId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(USER_ORDERS.ORDER_ID.eq(orderId))
|
||||
.where(USER_ORDERS.STATUS.eq(OrderStatus.PAID));
|
||||
UserOrders userOrders = this.mapper.selectOneByQuery(queryWrapper);
|
||||
userOrders.setStatus(OrderStatus.REFUNDING);
|
||||
this.mapper.update(userOrders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneRefund(Long orderId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(USER_ORDERS.ORDER_ID.eq(orderId))
|
||||
.where(USER_ORDERS.STATUS.eq(OrderStatus.REFUNDING));
|
||||
UserOrders userOrders = this.mapper.selectOneByQuery(queryWrapper);
|
||||
userOrders.setStatus(OrderStatus.REFUNDED);
|
||||
this.mapper.update(userOrders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void payment(ResFeignOrderPaymentDto paymentDto) {
|
||||
UserOrders userOrders = this.mapper.selectOneById(paymentDto.getOrderId());
|
||||
userOrders.setStatus(OrderStatus.PAID);
|
||||
userOrders.setPaymentTime(paymentDto.getPaymentTime());
|
||||
userOrders.setPaymentMethod(paymentDto.getPaymentMethod());
|
||||
this.mapper.update(userOrders);
|
||||
|
||||
}
|
||||
|
||||
boolean bikeInOperation(double lng, double lat, Long orgId, Long regionId) {
|
||||
return redisUtil.isPointInOperation(lng, lat, orgId, regionId);
|
||||
}
|
||||
@ -281,6 +312,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
||||
|
||||
/**
|
||||
* 计算费用
|
||||
*
|
||||
* @param feignEbikeSysRcostsetDto 计费规则
|
||||
* @param resGpsDto 定位信息
|
||||
* @param regionDto 运营区域信息
|
||||
@ -321,6 +353,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
||||
|
||||
/**
|
||||
* 按照特殊时间段计费
|
||||
*
|
||||
* @param totalAmount 当前金额(时间段计费前
|
||||
* @param minutes (骑行总分钟
|
||||
* @param userOrders 订单信息
|
||||
@ -333,6 +366,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
||||
|
||||
/**
|
||||
* 按照时间段计费
|
||||
*
|
||||
* @param totalAmount 当前金额(时间段计费前
|
||||
* @param minutes (骑行总分钟
|
||||
* @param userOrders 订单信息
|
||||
@ -345,6 +379,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
||||
|
||||
/**
|
||||
* 按照时间段计费(默认
|
||||
*
|
||||
* @param totalAmount 当前金额(时间段计费前
|
||||
* @param minutes (骑行总分钟
|
||||
* @param feignEbikeSysRcostsetDto 计费规则
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user