Commit 1fe04e2a by gonglei

加入前端代码

1 parent 9e22a3b3
Showing 25 changed files with 402 additions and 606 deletions
...@@ -112,21 +112,21 @@ public class DepositRefundBean { ...@@ -112,21 +112,21 @@ public class DepositRefundBean {
BaseInfo baseInfo = deposit.getAuctionVehicle().getVehicle().getBaseInfo(); BaseInfo baseInfo = deposit.getAuctionVehicle().getVehicle().getBaseInfo();
this.sourceNo = baseInfo.getSourceNo(); this.sourceNo = baseInfo.getSourceNo();
this.carTypeName = baseInfo.getCarSeriesName() + " "+baseInfo.getCarTypeName(); this.carTypeName = baseInfo.getCarSeriesName() + " "+baseInfo.getCarTypeName();
this.outTradeNo = deposit.getOutTradeNo(); // this.outTradeNo = deposit.getOutTradeNo();
this.transactionId = deposit.getTransactionId(); // this.transactionId = deposit.getTransactionId();
this.transactionAmount = Math.abs(deposit.getTransaction().getAmount()); // this.transactionAmount = Math.abs(deposit.getTransaction().getAmount());
this.paymentState = Objects.nonNull(deposit.getPaymentTime()) ? "已支付" : "已关闭"; // this.paymentState = Objects.nonNull(deposit.getPaymentTime()) ? "已支付" : "已关闭";
this.paymentTime = deposit.getPaymentTime(); // this.paymentTime = deposit.getPaymentTime();
this.paymentType = "微信支付"; // this.paymentType = "微信支付";
this.orderState = Objects.nonNull(deposit.getAuctionOrder()) ? "是" : "否"; // this.orderState = Objects.nonNull(deposit.getAuctionOrder()) ? "是" : "否";
this.refundType = deposit.getRefundType(); // this.refundType = deposit.getRefundType();
this.refundAmount = Objects.nonNull(deposit.getRefundSuccessTime()) ? deposit.getAmount() : 0; // this.refundAmount = Objects.nonNull(deposit.getRefundSuccessTime()) ? deposit.getAmount() : 0;
this.outRefundNo = deposit.getOutRefundNo(); // this.outRefundNo = deposit.getOutRefundNo();
this.refundTime = deposit.getRefundTime(); // this.refundTime = deposit.getRefundTime();
this.refundSuccessTime = deposit.getRefundSuccessTime(); // this.refundSuccessTime = deposit.getRefundSuccessTime();
this.refundState = deposit.getRefundState(); // this.refundState = deposit.getRefundState();
this.refundRemark = deposit.getRefundRemark(); // this.refundRemark = deposit.getRefundRemark();
this.refundOperator = deposit.getRefundOperator(); // this.refundOperator = deposit.getRefundOperator();
} }
......
...@@ -85,7 +85,7 @@ public class DepositController { ...@@ -85,7 +85,7 @@ public class DepositController {
@PostMapping("pageDepositFetchOrder") @PostMapping("pageDepositFetchOrder")
public Page<Deposit> pageDepositFetchOrder(@RequestBody Pagination<Deposit> pagination) { public Page<Deposit> pageDepositFetchOrder(@RequestBody Pagination<Deposit> pagination) {
pagination.addCondition((root, query, builder) -> root.get(Deposit_.paymentTime).isNotNull()); // pagination.addCondition((root, query, builder) -> root.get(Deposit_.paymentTime).isNotNull());
Page<Deposit> depositPage = pageDeposit(pagination); Page<Deposit> depositPage = pageDeposit(pagination);
for (Deposit deposit : depositPage) { for (Deposit deposit : depositPage) {
AuctionOrder auctionOrder = auctionOrderService.getAuctionOrderByAccountAndAuctionVehicle(deposit.getAccount(), deposit.getAuctionVehicle()); AuctionOrder auctionOrder = auctionOrderService.getAuctionOrderByAccountAndAuctionVehicle(deposit.getAccount(), deposit.getAuctionVehicle());
...@@ -210,19 +210,5 @@ public class DepositController { ...@@ -210,19 +210,5 @@ public class DepositController {
return depositService.getFreezeAmountByAccount(accountId); return depositService.getFreezeAmountByAccount(accountId);
} }
/**
* <pre>
* 微信支付-申请退款
* 详见 https://pay.weixin.qq.com/doc/v3/merchant/4012791862
* </pre>
*
* @param deposit 请求对象
* @return 退款操作结果
*/
@PostMapping("refund")
public Deposit refund(@RequestBody Deposit deposit, Authentication authentication) throws WxPayException {
User user = (User) authentication.getPrincipal();
Deposit depositDb = depositService.updateDepositRefundRemark(deposit.getDepositId(), deposit.getRefundRemark(), user);
return depositDb;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -40,28 +40,14 @@ public class RechargeController { ...@@ -40,28 +40,14 @@ public class RechargeController {
return transactionService.pageRecharge(pagination); return transactionService.pageRecharge(pagination);
} }
@GetMapping("getRechargeCountByAuditState")
public Map<?, Long> getRechargeCountByAuditState() {
return transactionService.getRechargeCountByAuditState();
}
@GetMapping("getRechargesByAccountId") // @GetMapping("getRechargesByAccountId")
public List<Recharge> getRechargesByAccountId(@RequestParam int accountId) { // public List<Recharge> getRechargesByAccountId(@RequestParam int accountId) {
List<Recharge> recharges = transactionService.getRechargesByAccountId(accountId, AuditState.REJECTED); // List<Recharge> recharges = transactionService.getRechargesByAccountId(accountId, AuditState.REJECTED);
return recharges; // return recharges;
} // }
/**
* 修改提现申请
*
* @param approveHistory
* @return
*/
@PostMapping("auditRecharge")
public Recharge auditRecharge(@Valid @RequestBody ApproveHistory approveHistory, Authentication authentication) throws WxPayException, FieldException {
approveHistory.setUser((User) authentication.getPrincipal());
return transactionService.auditRecharge(approveHistory);
}
@GetMapping("getRechargeById") @GetMapping("getRechargeById")
public Recharge getRechargeById(@RequestParam int rechargeId) { public Recharge getRechargeById(@RequestParam int rechargeId) {
......
...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.summerframework.core.exception.FieldException;
import org.summerframework.orm.paging.Pagination; import org.summerframework.orm.paging.Pagination;
import java.io.IOException; import java.io.IOException;
...@@ -85,7 +86,7 @@ public class WithdrawController { ...@@ -85,7 +86,7 @@ public class WithdrawController {
* @return * @return
*/ */
@PostMapping("auditWithdraw") @PostMapping("auditWithdraw")
public Withdraw auditWithdraw(@Valid @RequestBody ApproveHistory approveHistory, Authentication authentication) throws WxPayException { public Withdraw auditWithdraw(@Valid @RequestBody ApproveHistory approveHistory, Authentication authentication) throws WxPayException, FieldException {
approveHistory.setUser((User) authentication.getPrincipal()); approveHistory.setUser((User) authentication.getPrincipal());
return withdrawService.auditWithdraw(approveHistory); return withdrawService.auditWithdraw(approveHistory);
} }
......
...@@ -1458,7 +1458,7 @@ ...@@ -1458,7 +1458,7 @@
"code": "deposit_refund", "code": "deposit_refund",
"name": "微信支付流水管理", "name": "微信支付流水管理",
"type": "MENU", "type": "MENU",
"enabled": true, "enabled": false,
"value": "/finance/deposit/refund", "value": "/finance/deposit/refund",
"children": [ "children": [
{ {
...@@ -1479,7 +1479,7 @@ ...@@ -1479,7 +1479,7 @@
"code": "finance_withdraw", "code": "finance_withdraw",
"name": "提现审核", "name": "提现审核",
"type": "MENU", "type": "MENU",
"enabled": false, "enabled": true,
"value": "/finance/withdraw", "value": "/finance/withdraw",
"children": [ "children": [
{ {
...@@ -1554,7 +1554,7 @@ ...@@ -1554,7 +1554,7 @@
"code": "finance_recharge", "code": "finance_recharge",
"name": "提现审核", "name": "提现审核",
"type": "MENU", "type": "MENU",
"enabled": true, "enabled": false,
"value": "/finance/recharge", "value": "/finance/recharge",
"children": [ "children": [
{ {
......
package com.glsx.usedcar.web.api.finance;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.finance.entity.Deposit;
import com.glsx.usedcar.module.finance.entity.Recharge;
import com.glsx.usedcar.module.finance.entity.Transaction;
import com.glsx.usedcar.module.finance.entity.Transaction_;
import com.glsx.usedcar.module.finance.service.DepositService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
import org.summerframework.core.exception.FieldException;
import org.summerframework.orm.paging.Pagination;
import org.summerframework.orm.paging.SortOrder;
import static com.glsx.usedcar.web.WebConstants.LOGIN_ACCOUNT;
@Slf4j
@RestController
@RequestMapping("/api/deposit")
public class DepositController {
@Resource
private DepositService depositService;
@Resource
private WxPayService wxService;
@Value("${wx.pay.notifyUrl}")
private String notifyUrl;
/**
* 保证金支付接口
* @param aucvehId
* @param account
* @return
* @throws WxPayException
* @throws FieldException
*/
@PostMapping("addDeposit")
public WxPayUnifiedOrderV3Result.JsapiResult addDeposit(@RequestParam int aucvehId, @RequestAttribute(LOGIN_ACCOUNT) Account account) throws WxPayException, FieldException {
Deposit deposit = depositService.addDeposit(aucvehId,account.getAccountId() );
WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request();
request.setDescription("保证金");
request.setOutTradeNo(deposit.getOutTradeNo());
request.setNotifyUrl(notifyUrl);
request.setSupportFapiao(false);
WxPayUnifiedOrderV3Request.Amount amount = new WxPayUnifiedOrderV3Request.Amount();
amount.setCurrency("CNY");
amount.setTotal((int) (deposit.getAmount() * 100));
request.setAmount(amount);
WxPayUnifiedOrderV3Request.Payer payer = new WxPayUnifiedOrderV3Request.Payer();
payer.setOpenid(deposit.getAccount().getOpenId());
request.setPayer(payer);
request.setAttach("deposit");
WxPayUnifiedOrderV3Result.JsapiResult result = wxService.createOrderV3(TradeTypeEnum.JSAPI, request);
return result;
}
}
...@@ -70,18 +70,7 @@ public class RechargeController { ...@@ -70,18 +70,7 @@ public class RechargeController {
return transactionService.pageRecharge(pagination); return transactionService.pageRecharge(pagination);
} }
/**
* 提交充值退款申请
*
* @param rechargeId
* @param account
* @return
* @throws FieldException
*/
@PostMapping("refundRecharge")
public Recharge refundRecharge(@RequestParam long rechargeId, @RequestAttribute(LOGIN_ACCOUNT) Account account) throws FieldException {
return transactionService.refundRecharge(rechargeId);
}
// /** // /**
......
...@@ -69,10 +69,7 @@ public class WxpayController { ...@@ -69,10 +69,7 @@ public class WxpayController {
if ("recharge".equals(attach)) { if ("recharge".equals(attach)) {
// 充值成功通知 // 充值成功通知
transactionService.notifyRecharge(outTradeNo, openid, transactionId); transactionService.notifyRecharge(outTradeNo, openid, transactionId);
} else if ("deposit".equals(attach)) { } else if ("order".equals(attach)) {
// 保证金支付成功通知
transactionService.notifyDeposit(outTradeNo, openid, transactionId);
} else if ("order".equals(attach)) {
// 车款支付成功通知 // 车款支付成功通知
transactionService.notifyAuctionOrder(outTradeNo, decryptRes.getAmount().getTotal() * 100, transactionId); transactionService.notifyAuctionOrder(outTradeNo, decryptRes.getAmount().getTotal() * 100, transactionId);
} }
...@@ -115,7 +112,7 @@ public class WxpayController { ...@@ -115,7 +112,7 @@ public class WxpayController {
log.info("回调退款OutRefundNo:"+decryptRes.getOutRefundNo()); log.info("回调退款OutRefundNo:"+decryptRes.getOutRefundNo());
// 根据自己业务场景需要构造返回对象 // 根据自己业务场景需要构造返回对象
if (WxPayConstants.RefundStatus.SUCCESS.equals(decryptRes.getRefundStatus())) { if (WxPayConstants.RefundStatus.SUCCESS.equals(decryptRes.getRefundStatus())) {
transactionService.notifyDepositRefund(decryptRes); transactionService.notifyRechargeRefund(decryptRes);
//成功返回200/204,body无需有内容 //成功返回200/204,body无需有内容
return ResponseEntity.status(200).body(""); return ResponseEntity.status(200).body("");
} else { } else {
......
...@@ -46,11 +46,6 @@ public abstract class AbstractAuctionService { ...@@ -46,11 +46,6 @@ public abstract class AbstractAuctionService {
@Resource @Resource
protected MessagesenderProperties messagesenderProperties; protected MessagesenderProperties messagesenderProperties;
@Resource
protected WxPayService wxService;
@Value("${wx.pay.notifyUrl}")
protected String notifyUrl;
/** /**
* 通过订单查询用户的保证金 * 通过订单查询用户的保证金
...@@ -85,45 +80,24 @@ public abstract class AbstractAuctionService { ...@@ -85,45 +80,24 @@ public abstract class AbstractAuctionService {
if (Objects.nonNull(deposit)) { if (Objects.nonNull(deposit)) {
// 解冻保证金 // 解冻保证金
if (deposit.getDepositState() == Deposit.DepositState.FREEZE) { if (deposit.getDepositState() == Deposit.DepositState.FREEZE) {
try { // try {
refund(deposit, "自动退款"); // refund(deposit, "自动退款");
} catch (WxPayException e) { // } catch (WxPayException e) {
e.printStackTrace(); // e.printStackTrace();
}
// deposit.setDepositState(Deposit.DepositState.UNFREEZE);
// // 计算应该从保证金中扣除多少金额,扣除来源于违约金
// double depositDeduct = deposit.getAmount() + deposit.getTransaction().getAmount();
// if (depositDeduct < 0) {
// account.setSurplus(account.getSurplus() + depositDeduct);
// } // }
// Transaction transaction = new Transaction(account, transactionName, Transaction.TransactionType.UNFREEZE, deposit.getAmount(), account.getSurplus()); deposit.setDepositState(Deposit.DepositState.UNFREEZE);
// transactionDao.save(transaction); // 计算应该从保证金中扣除多少金额,扣除来源于违约金
double depositDeduct = deposit.getAmount() + deposit.getTransaction().getAmount();
if (depositDeduct < 0) {
account.setSurplus(account.getSurplus() + depositDeduct);
}
Transaction transaction = new Transaction(account, transactionName, Transaction.TransactionType.UNFREEZE, deposit.getAmount(), account.getSurplus());
transactionDao.save(transaction);
} }
} }
} }
public WxPayRefundV3Result refund(Deposit deposit, String refundType) throws WxPayException {
if (!StringUtils.hasText(deposit.getOutTradeNo())) {
throw new WxPayException("退款订单号为空,此订单未支付,不能进行退款操作");
}
WxPayRefundV3Request request = new WxPayRefundV3Request();
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
amount.setCurrency("CNY");
amount.setTotal((int) (Math.abs(deposit.getTransaction().getAmount()) * 100));
amount.setRefund((int) (deposit.getAmount() * 100));
request.setAmount(amount);
request.setOutTradeNo(deposit.getOutTradeNo());
request.setOutRefundNo(deposit.getOutTradeNo());
request.setTransactionId(deposit.getTransactionId());
request.setNotifyUrl(notifyUrl + "/refund");
WxPayRefundV3Result wxPayRefundV3Result = this.wxService.refundV3(request);
deposit.setRefundTime(LocalDateTime.now());
deposit.setOutRefundNo(wxPayRefundV3Result.getOutRefundNo());
deposit.setRefundType(refundType);
deposit.setRefundState(Deposit.RefundState.REFUNDING);
return wxPayRefundV3Result;
}
/** /**
* 发送通知消息 * 发送通知消息
......
...@@ -124,25 +124,24 @@ public class BidService { ...@@ -124,25 +124,24 @@ public class BidService {
Deposit deposit = depositDao.findByAccountAndAuctionVehicle(account, auctionVehicle); Deposit deposit = depositDao.findByAccountAndAuctionVehicle(account, auctionVehicle);
// 用户没有交过保证金,需要先交保证金 // 用户没有交过保证金,需要先交保证金
if (Objects.isNull(deposit)||Objects.isNull(deposit.getPaymentTime())) { if (Objects.isNull(deposit)) {
//需要交的保证金 //需要交的保证金
int depositAmount = auctionVehicle.getAuction().getDeposit(); int depositAmount = auctionVehicle.getAuction().getDeposit();
throw new FieldException("depositAmount", depositAmount, "参与本车竞拍需缴纳保证金¥" + depositAmount);
// 查询已经交过的冻结的保证金 // 查询已经交过的冻结的保证金
// double freezeAmount = Math.abs(depositDao.sumFreezeByAccountId(accountId, Deposit.DepositState.FREEZE).orElse(0.0)); double freezeAmount = Math.abs(depositDao.sumFreezeByAccountId(accountId, Deposit.DepositState.FREEZE).orElse(0.0));
// // 申请提现中的金额 // 申请提现中的金额
// double unauditWithdrawAmount = withdrawDao.sumWithdrawByAccountAuditState(account.getAccountId(), AuditState.UNAUDITED).orElse(0.0); double unauditWithdrawAmount = withdrawDao.sumWithdrawByAccountAuditState(account.getAccountId(), AuditState.UNAUDITED).orElse(0.0);
// if ((account.getSurplus() - freezeAmount - unauditWithdrawAmount) < depositAmount) { if ((account.getSurplus() - freezeAmount - unauditWithdrawAmount) < depositAmount) {
// throw new FieldException("depositAmount", depositAmount, "参与本车竞拍需缴纳保证金¥" + depositAmount); throw new FieldException("depositAmount", depositAmount, "参与本车竞拍需缴纳保证金¥" + depositAmount);
// } }
// //记录交易记录 //记录交易记录
// Transaction transaction = new Transaction(account, "参拍场次:" + auctionVehicle.getAuction().getAuctionName(), Transaction.TransactionType.FREEZE, -depositAmount, account.getSurplus()); Transaction transaction = new Transaction(account, "参拍场次:" + auctionVehicle.getAuction().getAuctionName(), Transaction.TransactionType.FREEZE, -depositAmount, account.getSurplus());
// transaction = transactionDao.save(transaction); transaction = transactionDao.save(transaction);
// //创建保证金记录 //创建保证金记录
// deposit = new Deposit(account, auctionVehicle, transaction); deposit = new Deposit(account, auctionVehicle, transaction);
// deposit.setAmount(depositAmount); deposit.setAmount(depositAmount);
// depositDao.save(deposit); depositDao.save(deposit);
} }
// 最低出价 // 最低出价
......
...@@ -18,10 +18,6 @@ public interface DepositDao extends BaseRepository<Deposit, Integer>, JpaSpecifi ...@@ -18,10 +18,6 @@ public interface DepositDao extends BaseRepository<Deposit, Integer>, JpaSpecifi
@EntityGraph(attributePaths = {"account", "auctionVehicle", "auctionVehicle.auction", "auctionVehicle.vehicle", "transaction"}) @EntityGraph(attributePaths = {"account", "auctionVehicle", "auctionVehicle.auction", "auctionVehicle.vehicle", "transaction"})
Deposit findByDepositId(int depositId); Deposit findByDepositId(int depositId);
@EntityGraph(attributePaths = {"account" })
Optional<Deposit> findTopByOutTradeNoAndAccount_OpenId(String outTradeNo, String openId);
Optional<Deposit> findTopByOutTradeNoAndTransactionId(String outTradeNo, String transactionId);
Deposit findByAccountAndAuctionVehicle(Account account, AuctionVehicle auctionVehicle); Deposit findByAccountAndAuctionVehicle(Account account, AuctionVehicle auctionVehicle);
...@@ -35,13 +31,13 @@ public interface DepositDao extends BaseRepository<Deposit, Integer>, JpaSpecifi ...@@ -35,13 +31,13 @@ public interface DepositDao extends BaseRepository<Deposit, Integer>, JpaSpecifi
@EntityGraph(attributePaths = {"account"}) @EntityGraph(attributePaths = {"account"})
List<Deposit> findByAuctionVehicleAndDepositState(AuctionVehicle auctionVehicle, Deposit.DepositState depositState); List<Deposit> findByAuctionVehicleAndDepositState(AuctionVehicle auctionVehicle, Deposit.DepositState depositState);
@Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.paymentTime is not null") @Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts ")
Optional<Double> sumAll(); Optional<Double> sumAll();
@Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.depositState =?1 and d.paymentTime is not null") @Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.depositState =?1 ")
Optional<Double> sumByDepositState(Deposit.DepositState depositState); Optional<Double> sumByDepositState(Deposit.DepositState depositState);
@Query("SELECT SUM(d.amount) FROM Deposit d where d.depositState =?1 and d.paymentTime is not null") @Query("SELECT SUM(d.amount) FROM Deposit d where d.depositState =?1 ")
Optional<Double> sumAccountByDepositState(Deposit.DepositState depositState); Optional<Double> sumAccountByDepositState(Deposit.DepositState depositState);
@Query("select d from Deposit d left join fetch d.transaction left join d.auctionVehicle av where d.account.accountId =?1 and av.vehicle.vehicleId =?2 and av.auction.auctionId =?3") @Query("select d from Deposit d left join fetch d.transaction left join d.auctionVehicle av where d.account.accountId =?1 and av.vehicle.vehicleId =?2 and av.auction.auctionId =?3")
......
package com.glsx.usedcar.module.finance.dao; package com.glsx.usedcar.module.finance.dao;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.finance.entity.Deposit; import com.glsx.usedcar.module.finance.entity.Deposit;
import com.glsx.usedcar.module.finance.entity.Recharge; import com.glsx.usedcar.module.finance.entity.Recharge;
import com.glsx.usedcar.module.finance.entity.Withdraw; import com.glsx.usedcar.module.finance.entity.Withdraw;
...@@ -9,6 +10,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -9,6 +10,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.summerframework.orm.BaseRepository; import org.summerframework.orm.BaseRepository;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -17,10 +19,10 @@ public interface RechargeDao extends BaseRepository<Recharge, Long>, JpaSpecific ...@@ -17,10 +19,10 @@ public interface RechargeDao extends BaseRepository<Recharge, Long>, JpaSpecific
@EntityGraph(attributePaths = {"account"}) @EntityGraph(attributePaths = {"account"})
Optional<Recharge> findTopByOutTradeNoAndOpenId(String outTradeNo, String openId); Optional<Recharge> findTopByOutTradeNoAndOpenId(String outTradeNo, String openId);
List<Recharge> findByAccount_AccountIdAndAuditStateOrderByCreateTimeDesc(int accountId, AuditState auditState);
Optional<Recharge> findTopByOutTradeNoAndTransactionId(String outTradeNo, String transactionId); Optional<Recharge> findTopByOutTradeNoAndTransactionId(String outTradeNo, String transactionId);
@EntityGraph(attributePaths = {"account"}) @EntityGraph(attributePaths = {"account"})
Optional<Recharge> findByRechargeId(long rechargeId); Optional<Recharge> findByRechargeId(long rechargeId);
List<Recharge> findByAccountAndPaymentTimeNotNullAndOutTradeNoNotNullAndPaymentTimeAfterAndRefundableAmountGreaterThanOrderByPaymentTimeAsc(Account account, LocalDateTime paymentTime, double refundableAmount);
} }
package com.glsx.usedcar.module.finance.dao;
import com.glsx.usedcar.module.finance.entity.Recharge;
import com.glsx.usedcar.module.finance.entity.Refund;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.summerframework.orm.BaseRepository;
import java.util.Optional;
public interface RefundDao extends BaseRepository<Refund, Long>, JpaSpecificationExecutor<Refund> {
@EntityGraph(attributePaths = {"recharge"})
Optional<Refund> findTopByRecharge_OutTradeNoAndRecharge_TransactionIdAndOutRefundNo(String outTradeNo, String transactionId, String outRefundNo);
}
...@@ -69,64 +69,64 @@ public class Deposit extends AuditingTimeEntity { ...@@ -69,64 +69,64 @@ public class Deposit extends AuditingTimeEntity {
@Column(nullable = false) @Column(nullable = false)
private double amount; private double amount;
/** // /**
* 商户订单号 // * 商户订单号
*/ // */
@Column(unique = true, nullable = false) // @Column(unique = true, nullable = false)
private String outTradeNo; // private String outTradeNo;
//
@Column // @Column
private LocalDateTime paymentTime; // private LocalDateTime paymentTime;
//
//
/** // /**
* 退款备注 // * 退款备注
*/ // */
@Column // @Column
private String refundRemark; // private String refundRemark;
//
/** // /**
* 微信支付订单号 // * 微信支付订单号
*/ // */
@Column(name = "WXTRANSACTION_ID") // @Column(name = "WXTRANSACTION_ID")
private String transactionId; // private String transactionId;
//
/** // /**
* 微信退款订单号 // * 微信退款订单号
*/ // */
@Column // @Column
private String outRefundNo; // private String outRefundNo;
//
/** // /**
* 退款时间 // * 退款时间
*/ // */
@Column // @Column
private LocalDateTime refundTime; // private LocalDateTime refundTime;
//
/** // /**
* 退款成功时间 // * 退款成功时间
*/ // */
@Column // @Column
private LocalDateTime refundSuccessTime; // private LocalDateTime refundSuccessTime;
//
/** // /**
* 退款类型 // * 退款类型
*/ // */
@Column // @Column
private String refundType; // private String refundType;
//
/** // /**
* 退款操作人 // * 退款操作人
*/ // */
@Column // @Column
private String refundOperator; // private String refundOperator;
//
/** // /**
* 退款状态 // * 退款状态
*/ // */
@Enumerated(EnumType.STRING) // @Enumerated(EnumType.STRING)
@Column(nullable = false, length = 32) // @Column(nullable = false, length = 32)
private RefundState refundState; // private RefundState refundState;
/** /**
* 保证金状态 * 保证金状态
...@@ -173,7 +173,6 @@ public class Deposit extends AuditingTimeEntity { ...@@ -173,7 +173,6 @@ public class Deposit extends AuditingTimeEntity {
this.auctionVehicle = auctionVehicle; this.auctionVehicle = auctionVehicle;
this.transaction = transaction; this.transaction = transaction;
this.depositState = DepositState.FREEZE; this.depositState = DepositState.FREEZE;
this.refundState = RefundState.UNREFUND;
} }
......
...@@ -13,6 +13,8 @@ import org.springframework.data.annotation.CreatedDate; ...@@ -13,6 +13,8 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;
import static jakarta.persistence.GenerationType.IDENTITY; import static jakarta.persistence.GenerationType.IDENTITY;
...@@ -43,11 +45,19 @@ public class Recharge implements java.io.Serializable { ...@@ -43,11 +45,19 @@ public class Recharge implements java.io.Serializable {
@Column(nullable = false, length = 64) @Column(nullable = false, length = 64)
private String openId; private String openId;
/**
* 充值金额
*/
@Column(nullable = false) @Column(nullable = false)
private double amount; private double amount;
/** /**
* 可退款金额
*/
@Column(nullable = false)
private double refundableAmount;
/**
* 付款类型 * 付款类型
*/ */
@NotNull @NotNull
...@@ -59,6 +69,9 @@ public class Recharge implements java.io.Serializable { ...@@ -59,6 +69,9 @@ public class Recharge implements java.io.Serializable {
@Column @Column
private LocalDateTime createTime; private LocalDateTime createTime;
/**
* 支付成功时间
*/
@Column @Column
private LocalDateTime paymentTime; private LocalDateTime paymentTime;
...@@ -69,59 +82,21 @@ public class Recharge implements java.io.Serializable { ...@@ -69,59 +82,21 @@ public class Recharge implements java.io.Serializable {
private String transactionId; private String transactionId;
/** // /**
* 退款时间 // * 退款状态
*/ // */
@Column // @Enumerated(EnumType.STRING)
private LocalDateTime refundTime; // @Column(nullable = false, length = 32)
// private Deposit.RefundState refundState;
/**
* 退款成功时间
*/
@Column
private LocalDateTime refundSuccessTime;
/**
* 微信退款订单号
*/
@Column
private String outRefundNo;
/**
* 退款状态
*/
@Enumerated(EnumType.STRING)
@Column(nullable = false, length = 32)
private Deposit.RefundState refundState;
/**
* 审核时间
*/
@Column(nullable = false)
private LocalDateTime auditTime;
/** /**
* 审核备注 * 退款记录
*/ */
@Column @OneToMany(cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY, mappedBy = "recharge")
private String auditRemark; private Set<Refund> refunds = new HashSet<>();
/**
* 驳回原因
*/
@Column
private String rejectReason;
/**
* 审核状态
*/
@Enumerated(EnumType.STRING)
@Column(nullable = false, length = 32)
private AuditState auditState;
public Recharge(Account account, String openId, double amount) { public Recharge(Account account, String openId, double amount) {
......
package com.glsx.usedcar.module.finance.entity;
import com.glsx.usedcar.module.account.entity.Account;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;
import static jakarta.persistence.GenerationType.IDENTITY;
/**
* 退款
*/
@Entity
@DynamicInsert
@DynamicUpdate
@Table
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
@NoArgsConstructor
public class Refund implements java.io.Serializable {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(unique = true, nullable = false)
private long refundId;
@NotNull
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "RECHARGE_ID", nullable = false)})
private Recharge recharge;
@NotNull
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "WITHDRAW_ID", nullable = false)})
private Withdraw withdraw;
/**
* 微信退款订单号
*/
@Column
private String outRefundNo;
/**
* 退款金额
*/
@Column
private double refundAmount;
/**
* 退款时间
*/
@Column
private LocalDateTime refundTime;
/**
* 退款成功时间
*/
@Column
private LocalDateTime refundSuccessTime;
public Refund(Withdraw withdraw, Recharge recharge, String outRefundNo, double refundAmount, LocalDateTime refundTime) {
this.withdraw = withdraw;
this.recharge = recharge;
this.outRefundNo = outRefundNo;
this.refundAmount = refundAmount;
this.refundTime = refundTime;
}
}
...@@ -69,14 +69,6 @@ public class DepositService extends AbstractAuctionService { ...@@ -69,14 +69,6 @@ public class DepositService extends AbstractAuctionService {
return depositDao.findByDepositId(depositId); return depositDao.findByDepositId(depositId);
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Deposit updateDepositRefundRemark(int depositId, String refundRemark, User user) throws WxPayException {
Deposit depositDb = depositDao.findByDepositId(depositId);
depositDb.setRefundRemark(refundRemark);
depositDb.setRefundOperator(user.getRealName());
refund(depositDb,"手动退款");
return depositDb;
}
/** /**
* 分页查询 * 分页查询
...@@ -106,38 +98,6 @@ public class DepositService extends AbstractAuctionService { ...@@ -106,38 +98,6 @@ public class DepositService extends AbstractAuctionService {
return depositDao.sumFreezeByAccountId(accountId, Deposit.DepositState.FREEZE).orElse(0.0); return depositDao.sumFreezeByAccountId(accountId, Deposit.DepositState.FREEZE).orElse(0.0);
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Deposit addDeposit(int aucvehId, int accountId) throws FieldException {
AuctionVehicle auctionVehicle = auctionVehicleDao.findTopByAucvehId(aucvehId);
if (auctionVehicle.getAuctionState() != AuctionVehicle.AuctionState.AUCTIONING) {
throw new FieldException("aucvehId", aucvehId, "该车辆已结束竞标");
}
Account account = accountDao.findById(accountId).orElseThrow(() -> new ObjectNotFoundException(accountId, Account.class.getSimpleName()));
if (!account.isEnabled()) {
throw new FieldException("accountId", accountId, "你已被禁止竞价");
}
Deposit deposit = depositDao.findByAccountAndAuctionVehicle(account, auctionVehicle);
if (Objects.nonNull(deposit)) {
if (!StringUtils.hasText(deposit.getOutTradeNo())) {
// 修补历史数据
deposit.setOutTradeNo(CoderGenerator.generateCode(8));
}
return deposit;
}
// double freezeAmount = Math.abs(depositDao.sumFreezeByAccountId(accountId, Deposit.DepositState.FREEZE).orElse(0.0));
// 申请提现中的金额
int depositAmount = auctionVehicle.getAuction().getDeposit();
//记录交易记录
Transaction transaction = new Transaction(account, "参拍场次:" + auctionVehicle.getAuction().getAuctionName(), Transaction.TransactionType.FREEZE, -depositAmount, account.getSurplus());
transaction = transactionDao.save(transaction);
//创建保证金记录
deposit = new Deposit(account, auctionVehicle, transaction);
deposit.setOutTradeNo(CoderGenerator.generateCode(8));
deposit.setAmount(depositAmount);
return depositDao.save(deposit);
}
/** /**
* 修改保证金规则 * 修改保证金规则
......
...@@ -15,10 +15,7 @@ import com.glsx.usedcar.module.auction.entity.AuctionOrder; ...@@ -15,10 +15,7 @@ import com.glsx.usedcar.module.auction.entity.AuctionOrder;
import com.glsx.usedcar.module.auction.service.AbstractAuctionService; import com.glsx.usedcar.module.auction.service.AbstractAuctionService;
import com.glsx.usedcar.module.business.entity.NoticeTemplate; import com.glsx.usedcar.module.business.entity.NoticeTemplate;
import com.glsx.usedcar.module.business.service.NoticeField; import com.glsx.usedcar.module.business.service.NoticeField;
import com.glsx.usedcar.module.finance.dao.DepositDao; import com.glsx.usedcar.module.finance.dao.*;
import com.glsx.usedcar.module.finance.dao.OrderTransactionDao;
import com.glsx.usedcar.module.finance.dao.RechargeDao;
import com.glsx.usedcar.module.finance.dao.TransactionDao;
import com.glsx.usedcar.module.finance.domain.OrderTransactionAmountStat; import com.glsx.usedcar.module.finance.domain.OrderTransactionAmountStat;
import com.glsx.usedcar.module.finance.domain.OrderTransactionStat; import com.glsx.usedcar.module.finance.domain.OrderTransactionStat;
import com.glsx.usedcar.module.finance.entity.*; import com.glsx.usedcar.module.finance.entity.*;
...@@ -73,6 +70,8 @@ public class TransactionService extends AbstractAuctionService { ...@@ -73,6 +70,8 @@ public class TransactionService extends AbstractAuctionService {
@Resource @Resource
private RechargeDao rechargeDao; private RechargeDao rechargeDao;
@Resource @Resource
private RefundDao refundDao;
@Resource
private GscInvoker gscInvoker; private GscInvoker gscInvoker;
@Resource @Resource
private GscApiInvoker gscApiInvoker; private GscApiInvoker gscApiInvoker;
...@@ -243,18 +242,6 @@ public class TransactionService extends AbstractAuctionService { ...@@ -243,18 +242,6 @@ public class TransactionService extends AbstractAuctionService {
return rechargeDao.save(recharge); return rechargeDao.save(recharge);
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Recharge refundRecharge(long rechargeId) throws FieldException {
Recharge recharge = rechargeDao.findByRechargeId(rechargeId).orElseThrow();
if (recharge.getRefundState() != Deposit.RefundState.UNREFUND) {
throw new FieldException("refundState", recharge, "订单已退款,不能再次退款");
}
if (recharge.getAccount().getSurplus() < recharge.getAmount()) {
throw new FieldException("amount", recharge, "账户余额不足,无法退款");
}
recharge.setAuditState(AuditState.UNAUDITED);
return recharge;
}
/** /**
* 充值结果通知 * 充值结果通知
...@@ -279,20 +266,6 @@ public class TransactionService extends AbstractAuctionService { ...@@ -279,20 +266,6 @@ public class TransactionService extends AbstractAuctionService {
} }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void notifyDeposit(String outTradeNo, String openId, String transactionId) {
Optional<Deposit> depositOptional = depositDao.findTopByOutTradeNoAndAccount_OpenId(outTradeNo, openId);
if (depositOptional.isPresent()) {
Deposit deposit = depositOptional.get();
deposit.setPaymentTime(LocalDateTime.now());
deposit.setTransactionId(transactionId);
double amount = deposit.getAmount();
// Account account = deposit.getAccount();
// account.setSurplus(account.getSurplus() + amount);
}
}
/** /**
* 订单支付结果通知 * 订单支付结果通知
* *
...@@ -323,35 +296,24 @@ public class TransactionService extends AbstractAuctionService { ...@@ -323,35 +296,24 @@ public class TransactionService extends AbstractAuctionService {
} }
} }
/**
* 退款回调
*
* @param decryptRes
*/
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void notifyDepositRefund(WxPayRefundNotifyV3Result.DecryptNotifyResult decryptRes) { public void notifyRechargeRefund(WxPayRefundNotifyV3Result.DecryptNotifyResult decryptRes) {
Optional<Deposit> depositOptional = depositDao.findTopByOutTradeNoAndTransactionId(decryptRes.getOutTradeNo(), decryptRes.getTransactionId()); Optional<Refund> refundOptional = refundDao.findTopByRecharge_OutTradeNoAndRecharge_TransactionIdAndOutRefundNo(decryptRes.getOutTradeNo(), decryptRes.getTransactionId(), decryptRes.getOutRefundNo());
if (depositOptional.isPresent()) { if (refundOptional.isPresent()) {
Deposit deposit = depositOptional.get(); Refund refund = refundOptional.get();
if (deposit.getDepositState() == Deposit.DepositState.FREEZE) { Recharge recharge = refund.getRecharge();
deposit.setDepositState(Deposit.DepositState.UNFREEZE); refund.setRefundSuccessTime(DateTimeUtils.attemptParseLocalDateTime(decryptRes.getSuccessTime()));
deposit.setRefundSuccessTime(DateTimeUtils.attemptParseLocalDateTime(decryptRes.getSuccessTime())); double refundAmount = refund.getRefundAmount();
deposit.setRefundState(Deposit.RefundState.REFUNDED); Account account = recharge.getAccount();
Account account = deposit.getAccount(); account.setSurplus(account.getSurplus() - refundAmount);
Transaction transaction = new Transaction(account, "保证金退款", Transaction.TransactionType.UNFREEZE, deposit.getAmount(), account.getSurplus()); recharge.setRefundableAmount(recharge.getRefundableAmount() - refundAmount);
transaction.setDeposit(deposit); Transaction transaction = new Transaction(account, "提现", Transaction.TransactionType.WITHDRAW, recharge.getAmount(), account.getSurplus());
transactionDao.save(transaction); transactionDao.save(transaction);
}
}
Optional<Recharge> rechargeOptional = rechargeDao.findTopByOutTradeNoAndTransactionId(decryptRes.getOutTradeNo(), decryptRes.getTransactionId());
if (rechargeOptional.isPresent()) {
Recharge recharge = rechargeOptional.get();
if (recharge.getRefundState() != Deposit.RefundState.REFUNDED) {
recharge.setRefundSuccessTime(DateTimeUtils.attemptParseLocalDateTime(decryptRes.getSuccessTime()));
recharge.setRefundState(Deposit.RefundState.REFUNDED);
Account account = recharge.getAccount();
account.setSurplus(account.getSurplus() - recharge.getAmount());
Transaction transaction = new Transaction(account, "提现", Transaction.TransactionType.WITHDRAW, recharge.getAmount(), account.getSurplus());
transactionDao.save(transaction);
}
} }
} }
...@@ -391,46 +353,4 @@ public class TransactionService extends AbstractAuctionService { ...@@ -391,46 +353,4 @@ public class TransactionService extends AbstractAuctionService {
return orderTransaction; return orderTransaction;
} }
public Map<?, Long> getRechargeCountByAuditState() {
return rechargeDao.countAndGroupBy((Specification<Recharge>) (root, query, criteriaBuilder) -> criteriaBuilder.isNotNull(root.get(Recharge_.auditState)), Withdraw_.auditState);
}
public List<Recharge> getRechargesByAccountId(int accountId, AuditState auditState) {
return rechargeDao.findByAccount_AccountIdAndAuditStateOrderByCreateTimeDesc(accountId, auditState);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Recharge auditRecharge(ApproveHistory approveHistory) throws WxPayException, FieldException {
Recharge recharge = rechargeDao.findById((long) approveHistory.getApproveId()).orElseThrow(() -> new ObjectNotFoundException(approveHistory.getApproveId(), Withdraw.class.getSimpleName()));
if (approveHistory.getApproveResult() == AuditState.AUDITED && recharge.getAuditState() != AuditState.AUDITED) {
if (!StringUtils.hasText(recharge.getOutTradeNo())) {
throw new WxPayException("退款订单号为空,此订单未支付,不能进行退款操作");
}
if (recharge.getAccount().getSurplus() < recharge.getAmount()) {
throw new FieldException("amount", recharge, "账户余额不足,无法退款");
}
WxPayRefundV3Request request = new WxPayRefundV3Request();
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
amount.setCurrency("CNY");
amount.setTotal((int) (Math.abs(recharge.getAmount()) * 100));
amount.setRefund((int) (recharge.getAmount() * 100));
request.setAmount(amount);
request.setOutTradeNo(recharge.getOutTradeNo());
request.setOutRefundNo(recharge.getOutTradeNo());
request.setTransactionId(recharge.getTransactionId());
request.setNotifyUrl(notifyUrl + "/refund");
WxPayRefundV3Result wxPayRefundV3Result = this.wxService.refundV3(request);
recharge.setRefundTime(LocalDateTime.now());
recharge.setOutRefundNo(wxPayRefundV3Result.getOutRefundNo());
recharge.setRefundState(Deposit.RefundState.REFUNDING);
}
recharge.setRejectReason(approveHistory.getRejectReason());
recharge.setAuditTime(LocalDateTime.now());
recharge.setAuditState(approveHistory.getApproveResult());
recharge.setAuditRemark(approveHistory.getRemark());
approveHistory.setApproveType(ApproveHistory.ApproveType.WITHDRAW);
approveHistoryDao.save(approveHistory);
return recharge;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -57,8 +57,6 @@ ...@@ -57,8 +57,6 @@
"less-loader": "^6.0.0", "less-loader": "^6.0.0",
"typescript": "~4.5.2", "typescript": "~4.5.2",
"vite": "^5.3.3", "vite": "^5.3.3",
"vite-plugin-electron": "^0.28.7",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-svg-loader": "^5.1.0" "vite-svg-loader": "^5.1.0"
}, },
"optionalDependencies": { "optionalDependencies": {
...@@ -69,7 +67,8 @@ ...@@ -69,7 +67,8 @@
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"axios": "~1.7.6", "axios": "~1.7.6",
"dayjs": "^1.10.7" "dayjs": "^1.10.7",
"vue-facing-decorator": "^3.0.4"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/eslint-plugin": "^5.4.0",
...@@ -9966,28 +9965,6 @@ ...@@ -9966,28 +9965,6 @@
} }
} }
}, },
"node_modules/vite-plugin-electron": {
"version": "0.28.8",
"resolved": "https://registry.npmmirror.com/vite-plugin-electron/-/vite-plugin-electron-0.28.8.tgz",
"integrity": "sha512-ir+B21oSGK9j23OEvt4EXyco9xDCaF6OGFe0V/8Zc0yL2+HMyQ6mmNQEIhXsEsZCSfIowBpwQBeHH4wVsfraeg==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"vite-plugin-electron-renderer": "*"
},
"peerDependenciesMeta": {
"vite-plugin-electron-renderer": {
"optional": true
}
}
},
"node_modules/vite-plugin-electron-renderer": {
"version": "0.14.6",
"resolved": "https://registry.npmmirror.com/vite-plugin-electron-renderer/-/vite-plugin-electron-renderer-0.14.6.tgz",
"integrity": "sha512-oqkWFa7kQIkvHXG7+Mnl1RTroA4sP0yesKatmAy0gjZC4VwUqlvF9IvOpHd1fpLWsqYX/eZlVxlhULNtaQ78Jw==",
"dev": true,
"license": "MIT"
},
"node_modules/vite-svg-loader": { "node_modules/vite-svg-loader": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmmirror.com/vite-svg-loader/-/vite-svg-loader-5.1.0.tgz", "resolved": "https://registry.npmmirror.com/vite-svg-loader/-/vite-svg-loader-5.1.0.tgz",
......
...@@ -34,45 +34,6 @@ export class Deposit extends AuditingTimeEntity { ...@@ -34,45 +34,6 @@ export class Deposit extends AuditingTimeEntity {
*/ */
amount: number; amount: number;
/** /**
* 商户订单号
*/
outTradeNo: string;
/**
*/
paymentTime: Dayjs | string;
/**
* 退款备注
*/
refundRemark: string;
/**
* 微信支付订单号
*/
transactionId: string;
/**
* 微信退款订单号
*/
outRefundNo: string;
/**
* 退款时间
*/
refundTime: Dayjs | string;
/**
* 退款成功时间
*/
refundSuccessTime: Dayjs | string;
/**
* 退款类型
*/
refundType: string;
/**
* 退款操作人
*/
refundOperator: string;
/**
* 退款状态
*/
refundState: Deposit_RefundState;
/**
* 保证金状态 * 保证金状态
*/ */
depositState: Deposit_DepositState; depositState: Deposit_DepositState;
...@@ -86,6 +47,13 @@ export class Deposit extends AuditingTimeEntity { ...@@ -86,6 +47,13 @@ export class Deposit extends AuditingTimeEntity {
} }
/** /**
* FREEZE 冻结中
* UNFREEZE 已解冻
*/
export type Deposit_DepositState = 'FREEZE'|'UNFREEZE';
export const DEPOSIT_DEPOSIT_STATES = ['FREEZE','UNFREEZE'];
/**
* UNREFUND 未退款 * UNREFUND 未退款
* REFUNDING 退款中 * REFUNDING 退款中
* REFUNDED 已退款 * REFUNDED 已退款
...@@ -93,10 +61,3 @@ export class Deposit extends AuditingTimeEntity { ...@@ -93,10 +61,3 @@ export class Deposit extends AuditingTimeEntity {
export type Deposit_RefundState = 'UNREFUND'|'REFUNDING'|'REFUNDED'; export type Deposit_RefundState = 'UNREFUND'|'REFUNDING'|'REFUNDED';
export const DEPOSIT_REFUND_STATES = ['UNREFUND','REFUNDING','REFUNDED']; export const DEPOSIT_REFUND_STATES = ['UNREFUND','REFUNDING','REFUNDED'];
/**
* FREEZE 冻结中
* UNFREEZE 已解冻
*/
export type Deposit_DepositState = 'FREEZE'|'UNFREEZE';
export const DEPOSIT_DEPOSIT_STATES = ['FREEZE','UNFREEZE'];
import {Dayjs} from 'dayjs'; import {Dayjs} from 'dayjs';
import {AuditingEntity,AuditingTimeEntity} from 'autumn-vue/lib/core/orm/AuditingEntity'; import {AuditingEntity,AuditingTimeEntity} from 'autumn-vue/lib/core/orm/AuditingEntity';
import {Refund} from './Refund';
import {Account} from '../../account/entity/Account'; import {Account} from '../../account/entity/Account';
import {Deposit} from './Deposit';
import {AuditState} from '../../enum_types';
// region 前端扩展导入包 // region 前端扩展导入包
import {Deposit_RefundState} from './Deposit'; import {Deposit_RefundState} from './Deposit';
// endregion // endregion
...@@ -23,9 +22,14 @@ export class Recharge { ...@@ -23,9 +22,14 @@ export class Recharge {
*/ */
openId: string; openId: string;
/** /**
* 充值金额
*/ */
amount: number; amount: number;
/** /**
* 可退款金额
*/
refundableAmount: number;
/**
* 付款类型 * 付款类型
*/ */
rechargeType: Recharge_RechargeType; rechargeType: Recharge_RechargeType;
...@@ -33,6 +37,7 @@ export class Recharge { ...@@ -33,6 +37,7 @@ export class Recharge {
*/ */
createTime: Dayjs | string; createTime: Dayjs | string;
/** /**
* 支付成功时间
*/ */
paymentTime: Dayjs | string; paymentTime: Dayjs | string;
/** /**
...@@ -40,37 +45,9 @@ export class Recharge { ...@@ -40,37 +45,9 @@ export class Recharge {
*/ */
transactionId: string; transactionId: string;
/** /**
* 退款时间 * 退款记录
*/
refundTime: Dayjs | string;
/**
* 退款成功时间
*/
refundSuccessTime: Dayjs | string;
/**
* 微信退款订单号
*/
outRefundNo: string;
/**
* 退款状态
*/
refundState: Deposit_RefundState;
/**
* 审核时间
*/
auditTime: Dayjs | string;
/**
* 审核备注
*/
auditRemark: string;
/**
* 驳回原因
*/
rejectReason: string;
/**
* 审核状态
*/ */
auditState: AuditState; refunds: Refund[];
// region 前端扩展定义属性及方法区 // region 前端扩展定义属性及方法区
// endregion // endregion
......
import {Dayjs} from 'dayjs';
import {AuditingEntity,AuditingTimeEntity} from 'autumn-vue/lib/core/orm/AuditingEntity';
import {Withdraw} from './Withdraw';
import {Recharge} from './Recharge';
// region 前端扩展导入包
// endregion
/**
* 退款
*/
export class Refund {
/**
*/
refundId: number;
/**
*/
recharge: Recharge;
/**
*/
withdraw: Withdraw;
/**
* 微信退款订单号
*/
outRefundNo: string;
/**
* 退款金额
*/
refundAmount: number;
/**
* 退款时间
*/
refundTime: Dayjs | string;
/**
* 退款成功时间
*/
refundSuccessTime: Dayjs | string;
// region 前端扩展定义属性及方法区
// endregion
}
...@@ -2251,6 +2251,36 @@ ...@@ -2251,6 +2251,36 @@
<UniqueConstraints/> <UniqueConstraints/>
<SchTrHis/> <SchTrHis/>
</Tbl> </Tbl>
<Tbl UsSo="1" nm="refund">
<Cm>退款</Cm>
<TblOpts/>
<Pk ClNs="REFUND_ID" nm="pkrefund"/>
<Cl au="1" df="" nm="REFUND_ID" nu="0">
<DT arr="0" ds="Integer" en="" id="4" ln="null" sc="null" sg="1" un="0"/>
<Cm>REFUND_ID</Cm>
</Cl>
<Cl au="0" df="" nm="NAME" nu="0">
<DT arr="0" ds="VarChar" en="" id="12" ln="128" sc="null" sg="1" un="0"/>
</Cl>
<Cl au="0" df="" nm="CREATE_BY" nu="0">
<DT arr="0" ds="VarChar" en="" id="12" ln="64" sc="null" sg="1" un="0"/>
<Cm>创建人</Cm>
</Cl>
<Cl au="0" df="" nm="UPDATE_BY" nu="0">
<DT arr="0" ds="VarChar" en="" id="12" ln="64" sc="null" sg="1" un="0"/>
<Cm>修改人</Cm>
</Cl>
<Cl au="0" df="" nm="CREATE_TIME" nu="0">
<DT arr="0" ds="DateTime" en="" id="700" ln="null" sc="null" sg="1" un="0"/>
<Cm>创建时间</Cm>
</Cl>
<Cl au="0" df="" nm="UPDATE_TIME" nu="1">
<DT arr="0" ds="DateTime" en="" id="700" ln="null" sc="null" sg="1" un="0"/>
<Cm>修改时间</Cm>
</Cl>
<UniqueConstraints/>
<SchTrHis/>
</Tbl>
<Tbl UsSo="1" nm="release_order"> <Tbl UsSo="1" nm="release_order">
<Cm>解押订单</Cm> <Cm>解押订单</Cm>
<TblOpts>ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='解押订单'</TblOpts> <TblOpts>ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='解押订单'</TblOpts>
...@@ -3568,6 +3598,7 @@ ...@@ -3568,6 +3598,7 @@
<TbGl bkCl="#6699ff64" h="338" sch="schemaA" tbl="deposit" w="551" x="169" y="116"/> <TbGl bkCl="#6699ff64" h="338" sch="schemaA" tbl="deposit" w="551" x="169" y="116"/>
<TbGl bkCl="#6699ff64" h="306" sch="schemaA" tbl="recharge" w="499" x="69" y="840"/> <TbGl bkCl="#6699ff64" h="306" sch="schemaA" tbl="recharge" w="499" x="69" y="840"/>
<TbGl bkCl="#6699ff64" h="274" sch="schemaA" tbl="user_info" w="393" x="858" y="1274"/> <TbGl bkCl="#6699ff64" h="274" sch="schemaA" tbl="user_info" w="393" x="858" y="1274"/>
<TbGl bkCl="#6699ff64" h="130" sch="schemaA" tbl="refund" w="352" x="282" y="1275"/>
<FkGl bearing="NORTH" bkCl="#00000064" childEdge="NORTH" childOffset="0" lineCount="1" midLineOffset="" nm="schemaA.withdraw.fk_withdraw_account" parentEdge="SOUTH" parentOffset="250"/> <FkGl bearing="NORTH" bkCl="#00000064" childEdge="NORTH" childOffset="0" lineCount="1" midLineOffset="" nm="schemaA.withdraw.fk_withdraw_account" parentEdge="SOUTH" parentOffset="250"/>
<FkGl bearing="NORTH_EAST" bkCl="#00000064" childEdge="EAST" childOffset="16" lineCount="2" midLineOffset="" nm="schemaA.recharge.fk_recharge_account" parentEdge="SOUTH" parentOffset="43"/> <FkGl bearing="NORTH_EAST" bkCl="#00000064" childEdge="EAST" childOffset="16" lineCount="2" midLineOffset="" nm="schemaA.recharge.fk_recharge_account" parentEdge="SOUTH" parentOffset="43"/>
<FkGl bearing="SOUTH_EAST" bkCl="#00000064" childEdge="SOUTH" childOffset="0" lineCount="2" midLineOffset="" nm="schemaA.deposit.fk_deposit_transaction" parentEdge="WEST" parentOffset="20"/> <FkGl bearing="SOUTH_EAST" bkCl="#00000064" childEdge="SOUTH" childOffset="0" lineCount="2" midLineOffset="" nm="schemaA.deposit.fk_deposit_transaction" parentEdge="WEST" parentOffset="20"/>
...@@ -4762,6 +4793,9 @@ ...@@ -4762,6 +4793,9 @@
<Rnm nNm="REFUND_STATE" oNm="REFUND_STATE"/> <Rnm nNm="REFUND_STATE" oNm="REFUND_STATE"/>
<Rnm nNm="REFUND_STATE" oNm="REFUND_STATE"/> <Rnm nNm="REFUND_STATE" oNm="REFUND_STATE"/>
</RnmCh> </RnmCh>
<RnmCh ObjCls="Column" ParCls="Table" ParNme="refund" SupCls="Schema" SupNme="schemaA">
<Rnm nNm="REFUND_ID" oNm="ID"/>
</RnmCh>
</RnmMgr> </RnmMgr>
<BasicOptionMgr> <BasicOptionMgr>
<Name>dbDocOptionMgr</Name> <Name>dbDocOptionMgr</Name>
...@@ -4787,7 +4821,6 @@ ...@@ -4787,7 +4821,6 @@
<TreePath>aus.Schemas</TreePath> <TreePath>aus.Schemas</TreePath>
<TreePath>aus.Diagrams</TreePath> <TreePath>aus.Diagrams</TreePath>
<TreePath>数据埋点</TreePath> <TreePath>数据埋点</TreePath>
<TreePath>保证金</TreePath>
<TreePath>合同管理</TreePath> <TreePath>合同管理</TreePath>
<TreePath>车辆场地管理</TreePath> <TreePath>车辆场地管理</TreePath>
<TreePath>schemaA.Tables</TreePath> <TreePath>schemaA.Tables</TreePath>
......
...@@ -110,55 +110,55 @@ ALTER TABLE account ...@@ -110,55 +110,55 @@ ALTER TABLE account
/******************** Update Table: deposit ************************/ /******************** Update Table: deposit ************************/
# 2025-12-30 # 2025-12-30
ALTER TABLE deposit ADD OUT_TRADE_NO VARCHAR(128) NULL after ORDER_CODE;
ALTER TABLE deposit ADD PAYMENT_TIME DATETIME
COMMENT '支付时间' NULL after OUT_TRADE_NO;
ALTER TABLE deposit ADD WXTRANSACTION_ID VARCHAR(64)
COMMENT '微信支付TRANSACTION_ID' NULL after PAYMENT_TIME;
ALTER TABLE deposit ADD REFUND_TIME DATETIME
COMMENT '退款时间' NULL after WXTRANSACTION_ID;
ALTER TABLE deposit ADD REFUND_SUCCESS_TIME DATETIME
COMMENT '退款成功时间' NULL after REFUND_TIME;
ALTER TABLE deposit ADD REFUND_REMARK VARCHAR(1024)
COMMENT '退款备注' NULL after REFUND_SUCCESS_TIME;
ALTER TABLE deposit ADD OUT_REFUND_NO VARCHAR(64)
COMMENT '微信退款订单号' NULL after REFUND_REMARK;
ALTER TABLE deposit ADD REFUND_TYPE VARCHAR(64)
COMMENT '退款类型' NULL after OUT_REFUND_NO;
ALTER TABLE deposit ADD REFUND_OPERATOR VARCHAR(64)
COMMENT '退款操作人' NULL after REFUND_TYPE;
ALTER TABLE deposit ADD REFUND_STATE VARCHAR(32) DEFAULT 'UNREFUND'
COMMENT '退款状态' NULL after REFUND_OPERATOR;
ALTER TABLE recharge ADD REFUND_TIME DATETIME
COMMENT '退款时间' NULL after RECHARGE_TYPE;
ALTER TABLE recharge ADD REFUND_SUCCESS_TIME DATETIME
COMMENT '退款成功时间' NULL after REFUND_TIME;
ALTER TABLE recharge ADD OUT_REFUND_NO VARCHAR(64)
COMMENT '微信退款订单号' NULL after REFUND_SUCCESS_TIME;
ALTER TABLE recharge ADD REFUND_STATE VARCHAR(32) DEFAULT 'UNREFUND'
COMMENT '退款状态' NULL after OUT_REFUND_NO;
ALTER TABLE recharge ADD AUDIT_TIME DATETIME
COMMENT '审核时间' NULL after REFUND_STATE;
ALTER TABLE recharge ADD AUDIT_REMARK VARCHAR(1024)
COMMENT '审核备注' NULL after AUDIT_TIME;
ALTER TABLE recharge ADD AUDIT_STATE VARCHAR(32)
COMMENT '审核状态' NULL after AUDIT_REMARK;
ALTER TABLE recharge ADD REJECT_REASON VARCHAR(255)
COMMENT '驳回原因' NULL after AUDIT_STATE;
\ No newline at end of file \ No newline at end of file
# ALTER TABLE deposit ADD OUT_TRADE_NO VARCHAR(128) NULL after ORDER_CODE;
#
# ALTER TABLE deposit ADD PAYMENT_TIME DATETIME
# COMMENT '支付时间' NULL after OUT_TRADE_NO;
#
# ALTER TABLE deposit ADD WXTRANSACTION_ID VARCHAR(64)
# COMMENT '微信支付TRANSACTION_ID' NULL after PAYMENT_TIME;
#
# ALTER TABLE deposit ADD REFUND_TIME DATETIME
# COMMENT '退款时间' NULL after WXTRANSACTION_ID;
#
# ALTER TABLE deposit ADD REFUND_SUCCESS_TIME DATETIME
# COMMENT '退款成功时间' NULL after REFUND_TIME;
#
# ALTER TABLE deposit ADD REFUND_REMARK VARCHAR(1024)
# COMMENT '退款备注' NULL after REFUND_SUCCESS_TIME;
#
# ALTER TABLE deposit ADD OUT_REFUND_NO VARCHAR(64)
# COMMENT '微信退款订单号' NULL after REFUND_REMARK;
#
# ALTER TABLE deposit ADD REFUND_TYPE VARCHAR(64)
# COMMENT '退款类型' NULL after OUT_REFUND_NO;
#
# ALTER TABLE deposit ADD REFUND_OPERATOR VARCHAR(64)
# COMMENT '退款操作人' NULL after REFUND_TYPE;
#
# ALTER TABLE deposit ADD REFUND_STATE VARCHAR(32) DEFAULT 'UNREFUND'
# COMMENT '退款状态' NULL after REFUND_OPERATOR;
#
# ALTER TABLE recharge ADD REFUND_TIME DATETIME
# COMMENT '退款时间' NULL after RECHARGE_TYPE;
#
# ALTER TABLE recharge ADD REFUND_SUCCESS_TIME DATETIME
# COMMENT '退款成功时间' NULL after REFUND_TIME;
#
# ALTER TABLE recharge ADD OUT_REFUND_NO VARCHAR(64)
# COMMENT '微信退款订单号' NULL after REFUND_SUCCESS_TIME;
#
# ALTER TABLE recharge ADD REFUND_STATE VARCHAR(32) DEFAULT 'UNREFUND'
# COMMENT '退款状态' NULL after OUT_REFUND_NO;
#
# ALTER TABLE recharge ADD AUDIT_TIME DATETIME
# COMMENT '审核时间' NULL after REFUND_STATE;
#
# ALTER TABLE recharge ADD AUDIT_REMARK VARCHAR(1024)
# COMMENT '审核备注' NULL after AUDIT_TIME;
#
# ALTER TABLE recharge ADD AUDIT_STATE VARCHAR(32)
# COMMENT '审核状态' NULL after AUDIT_REMARK;
#
# ALTER TABLE recharge ADD REJECT_REASON VARCHAR(255)
# COMMENT '驳回原因' NULL after AUDIT_STATE;
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!