Merge pull request 'zhangli-test' (#5) from zhangli-test into main
Reviewed-on: #5
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
package com.sczx.pay.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class OrderMain {
|
||||
private Long orderId;
|
||||
private String orderNo;
|
||||
private String orderStatus;
|
||||
private Integer overdueDays;
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
public Long getOrderId() {
|
||||
return orderId;
|
||||
@ -25,4 +29,20 @@ public class OrderMain {
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public Integer getOverdueDays() {
|
||||
return overdueDays;
|
||||
}
|
||||
|
||||
public void setOverdueDays(Integer overdueDays) {
|
||||
this.overdueDays = overdueDays;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderAmount() {
|
||||
return orderAmount;
|
||||
}
|
||||
|
||||
public void setOrderAmount(BigDecimal orderAmount) {
|
||||
this.orderAmount = orderAmount;
|
||||
}
|
||||
}
|
||||
|
||||
29
src/main/java/com/sczx/pay/entity/OrderSub.java
Normal file
29
src/main/java/com/sczx/pay/entity/OrderSub.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.sczx.pay.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class OrderSub {
|
||||
|
||||
@ApiModelProperty("子订单ID(主键)")
|
||||
private Long suborderId;
|
||||
|
||||
@ApiModelProperty("关联的订单ID(外键)")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("子订单编号")
|
||||
private String suborderNo;
|
||||
|
||||
@ApiModelProperty("子订单类型(首租、续租、逾期、押金、租电等)")
|
||||
private String suborderType;
|
||||
|
||||
@ApiModelProperty("订单金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@ApiModelProperty("还车时间,租车子订单")
|
||||
private LocalDateTime returnTime;
|
||||
}
|
||||
@ -1,12 +1,14 @@
|
||||
package com.sczx.pay.mapper;
|
||||
|
||||
import com.sczx.pay.entity.OrderMain;
|
||||
import com.sczx.pay.entity.OrderSub;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Mapper
|
||||
@ -36,6 +38,11 @@ public interface OrderPayMapper {
|
||||
int updateOrderStatus(@Param("outTradeNo") String outTradeNo,
|
||||
@Param("orderStatus") String orderStatus);
|
||||
|
||||
@Update("UPDATE zc_order_main SET order_status = #{orderStatus} , end_rent_time = #{returnTime}, overdue_days = #{overdueDays}, order_amount = #{orderAmount}" +
|
||||
"WHERE order_no = #{outTradeNo}")
|
||||
int updateOrderStatusAndEndRentTime(@Param("outTradeNo") String outTradeNo,@Param("returnTime") LocalDateTime returnTime,@Param("overdueDays") Integer overdueDays,@Param("orderAmount") BigDecimal orderAmount,
|
||||
@Param("orderStatus") String orderStatus);
|
||||
|
||||
@Update("update zc_order_main as om,zc_order_sub as os set os.transaction_id = #{paymentId},os.pay_status = #{payStatus}" +
|
||||
" where om.order_id = os.order_id and om.order_no = #{outTradeNo} and suborder_type = 'DEPOSIT'")
|
||||
int updateRefundOrderStatus(@Param("outTradeNo") String outTradeNo,
|
||||
@ -43,7 +50,7 @@ public interface OrderPayMapper {
|
||||
@Param("transactionId") String transactionId);
|
||||
|
||||
|
||||
@Select("select order_id,order_no,order_status from zc_order_main " +
|
||||
@Select("select order_id,order_no,order_status,overdue_days, orderAmount from zc_order_main " +
|
||||
"where order_id in (select order_id from zc_order_sub " +
|
||||
"where payment_id = #{paymentId} and del_flag = '0')")
|
||||
OrderMain getOrderStatusByOrderNo(@Param("paymentId") String paymentId);
|
||||
@ -60,5 +67,7 @@ public interface OrderPayMapper {
|
||||
@Select("select suborder_id from zc_order_sub where payment_id = #{paymentId} and suborder_type = 'RENTBATTEY' limit 1")
|
||||
Long getSubOrderIdByTradeNo(@Param("paymentId") String paymentId);
|
||||
|
||||
@Select("select * from zc_order_sub where payment_id = #{paymentId} order by suborder_id desc limit 1")
|
||||
OrderSub getSubOrderByTradeNo(@Param("paymentId") String paymentId);
|
||||
|
||||
}
|
||||
|
||||
@ -418,7 +418,8 @@ public class WechatPayService {
|
||||
logger.info("调用subOrder接口结果: {}", result);
|
||||
}
|
||||
}else if (OrderStatus.equals("RERENT_WAIT_PAY")){
|
||||
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"RENT_ING");
|
||||
OrderSub orderSub = orderPayMapper.getSubOrderByTradeNo(outTradeNo);
|
||||
orderPayMapper.updateOrderStatusAndEndRentTime(orderMain.getOrderNo(),orderSub.getReturnTime(),orderMain.getOverdueDays(),orderMain.getOrderAmount().add(orderSub.getAmount()),"RENT_ING");
|
||||
}
|
||||
orderPayMapper.updateSubOrderPaymentStatus(outTradeNo,"WX_PAY",PayStatus.SUCCESS.getCode(),transactionId);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import com.sczx.pay.config.AlipayConf;
|
||||
import com.sczx.pay.dto.ali.rent.AlipayRentPayReq;
|
||||
import com.sczx.pay.dto.ali.rent.AlipayRentPayResponse;
|
||||
import com.sczx.pay.entity.OrderMain;
|
||||
import com.sczx.pay.entity.OrderSub;
|
||||
import com.sczx.pay.entity.PayStatus;
|
||||
import com.sczx.pay.entity.PaymentRecord;
|
||||
import com.sczx.pay.mapper.OrderPayMapper;
|
||||
@ -154,7 +155,8 @@ public class AlipayRentServiceImpl implements AlipayRentService {
|
||||
if(OrderStatus.equals("WAIT_PAY")){
|
||||
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"WAIT_PICK");
|
||||
}else if (OrderStatus.equals("RERENT_WAIT_PAY")){
|
||||
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"RENT_ING");
|
||||
OrderSub orderSub = orderPayMapper.getSubOrderByTradeNo(outTradeNo);
|
||||
orderPayMapper.updateOrderStatusAndEndRentTime(orderMain.getOrderNo(),orderSub.getReturnTime(),orderMain.getOverdueDays(),orderMain.getOrderAmount().add(orderSub.getAmount()),"RENT_ING");
|
||||
}
|
||||
orderPayMapper.updateSubOrderPaymentStatus(outTradeNo,"ZFB_PAY", PayStatus.SUCCESS.getCode(),tradeNo);
|
||||
return true;
|
||||
|
||||
@ -9,10 +9,7 @@ import com.alipay.api.request.*;
|
||||
import com.alipay.api.response.*;
|
||||
import com.sczx.pay.config.AlipayConf;
|
||||
import com.sczx.pay.dto.*;
|
||||
import com.sczx.pay.entity.OrderMain;
|
||||
import com.sczx.pay.entity.PayStatus;
|
||||
import com.sczx.pay.entity.PaymentRecord;
|
||||
import com.sczx.pay.entity.RefundRecord;
|
||||
import com.sczx.pay.entity.*;
|
||||
import com.sczx.pay.mapper.OrderPayMapper;
|
||||
import com.sczx.pay.mapper.PaymentRecordMapper;
|
||||
import com.sczx.pay.mapper.RefundRecordMapper;
|
||||
@ -333,7 +330,8 @@ public class AlipayServiceImpl implements AlipayService {
|
||||
if(OrderStatus.equals("WAIT_PAY")){
|
||||
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"WAIT_PICK");
|
||||
}else if (OrderStatus.equals("RERENT_WAIT_PAY")){
|
||||
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"RENT_ING");
|
||||
OrderSub orderSub = orderPayMapper.getSubOrderByTradeNo(outTradeNo);
|
||||
orderPayMapper.updateOrderStatusAndEndRentTime(orderMain.getOrderNo(),orderSub.getReturnTime(),orderMain.getOverdueDays(),orderMain.getOrderAmount().add(orderSub.getAmount()),"RENT_ING");
|
||||
}
|
||||
orderPayMapper.updateSubOrderPaymentStatus(outTradeNo,"ZFB_PAY", PayStatus.SUCCESS.getCode(),tradeNo);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user