Commit 1f21abc0 by gonglei

修改保证金支付流程

1 parent 1b931ec5
......@@ -8,8 +8,10 @@ import com.github.binarywang.wxpay.service.WxPayService;
import com.glsx.usedcar.export.DepositBean;
import com.glsx.usedcar.export.ExcelExporter;
import com.glsx.usedcar.export.WithdrawBean;
import com.glsx.usedcar.module.auction.entity.AuctionOrder;
import com.glsx.usedcar.module.auction.entity.AuctionVehicle;
import com.glsx.usedcar.module.auction.entity.AuctionVehicle_;
import com.glsx.usedcar.module.auction.service.AuctionOrderService;
import com.glsx.usedcar.module.finance.domain.DepositStat;
import com.glsx.usedcar.module.finance.entity.Deposit;
import com.glsx.usedcar.module.finance.entity.DepositRule;
......@@ -52,7 +54,7 @@ public class DepositController {
private WithdrawService withdrawService;
@Resource
private WxPayService wxService;
private AuctionOrderService auctionOrderService;
@Resource
private TransactionService transactionService;
......@@ -79,6 +81,16 @@ public class DepositController {
return depositService.pageDeposit(pagination);
}
@PostMapping("pageDepositFetchOrder")
public Page<Deposit> pageDepositFetchOrder(@RequestBody Pagination<Deposit> pagination) {
Page<Deposit> depositPage = pageDeposit(pagination);
for (Deposit deposit : depositPage) {
AuctionOrder auctionOrder = auctionOrderService.getAuctionOrderByAccountAndAuctionVehicle(deposit.getAccount(), deposit.getAuctionVehicle());
deposit.setAuctionOrder(auctionOrder);
}
return depositPage;
}
/**
* 根据id查询保证金规则
......@@ -160,7 +172,7 @@ public class DepositController {
@GetMapping("getDepositStat")
public DepositStat getDepositStat() {
DepositStat depositStat = depositService.getDepositStat();
depositStat.setUnauditedWithdrawAmount(withdrawService.getUnauditedWithdrawAmount());
// depositStat.setUnauditedWithdrawAmount(withdrawService.getUnauditedWithdrawAmount());
return depositStat;
}
......
......@@ -1468,7 +1468,7 @@
"code": "finance_withdraw",
"name": "提现审核",
"type": "MENU",
"enabled": true,
"enabled": false,
"value": "/finance/withdraw",
"children": [
{
......
......@@ -68,9 +68,9 @@ spring:
data:
redis:
database: 6
host: 120.237.107.125
port: 16379
password: Ml1234..
host: localhost
port: 6379
password:
# 连接超时时间 单位 ms(毫秒)
timeout: 3000ms
jedis:
......
......@@ -3,7 +3,9 @@ package com.glsx.usedcar.module.auction.dao;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.analysis.domain.IndexValue;
import com.glsx.usedcar.module.analysis.domain.ProfitRadioProjection;
import com.glsx.usedcar.module.auction.entity.Auction;
import com.glsx.usedcar.module.auction.entity.AuctionOrder;
import com.glsx.usedcar.module.vehicle.entity.Vehicle;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
......@@ -29,6 +31,8 @@ public interface AuctionOrderDao extends BaseRepository<AuctionOrder, Integer>,
@EntityGraph(attributePaths = {"vehicle", "account", "auction"})
AuctionOrder findByOrderId(int orderId);
AuctionOrder findTopByAccountAndVehicleAndAuction(Account account, Vehicle vehicle, Auction auction);
AuctionOrder findTopByVehicle_VehicleIdOrderByCreateTimeDesc(int vehicleId);
AuctionOrder findTopByVehicle_VehicleIdAndAccount_AccountIdAndOrderStateOrderByCreateTimeDesc(int vehicleId, int accountId, AuctionOrder.OrderState orderState);
......
......@@ -102,17 +102,21 @@ public abstract class AbstractAuctionService {
}
}
public WxPayRefundV3Result refund(Deposit deposit ) throws WxPayException {
WxPayRefundV3Request request=new WxPayRefundV3Request();
public WxPayRefundV3Result refund(Deposit deposit) 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) (deposit.getTransaction().getAmount() * 100));
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");
request.setNotifyUrl(notifyUrl + "/refund");
return this.wxService.refundV3(request);
}
......
......@@ -96,6 +96,9 @@ public class AuctionOrderService extends AbstractAuctionService {
return auctionOrderDao.sumOrderPriceByAuctionId(auctionId, AuctionOrder.OrderState.CANCELED).orElse(0.0);
}
public AuctionOrder getAuctionOrderByAccountAndAuctionVehicle(Account account, AuctionVehicle auctionVehicle) {
return auctionOrderDao.findTopByAccountAndVehicleAndAuction(account,auctionVehicle.getVehicle(),auctionVehicle.getAuction());
}
/**
* 分页查询
*
......
......@@ -31,12 +31,15 @@ public interface DepositDao extends BaseRepository<Deposit, Integer>, JpaSpecifi
@EntityGraph(attributePaths = {"account"})
List<Deposit> findByAuctionVehicleAndDepositState(AuctionVehicle auctionVehicle, Deposit.DepositState depositState);
@Query("SELECT SUM(d.amount) FROM Deposit d")
@Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.paymentTime is not null")
Optional<Double> sumAll();
@Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.depositState =?1")
@Query("SELECT SUM(ts.amount) FROM Deposit d left join d.transaction ts where d.depositState =?1 and d.paymentTime is not null")
Optional<Double> sumByDepositState(Deposit.DepositState depositState);
@Query("SELECT SUM(d.amount) FROM Deposit d where d.depositState =?1 and d.paymentTime is not null")
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")
Deposit findByAccountAndVehicleAndAuction(int accountId, int vehicleId, int auctionId);
......
......@@ -11,6 +11,11 @@ public class DepositStat {
* 总金额
*/
private double totalAmount;
/**
* 可用金额
*/
private double depositAmount;
/**
* 冻结金额
*/
......
package com.glsx.usedcar.module.finance.entity;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.auction.entity.AuctionOrder;
import com.glsx.usedcar.module.auction.entity.AuctionVehicle;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
......@@ -100,6 +101,12 @@ public class Deposit extends AuditingTimeEntity {
@Column(nullable = false, length = 32)
private DepositState depositState;
/**
* 关联的订单
*/
@Transient
private AuctionOrder auctionOrder;
public enum DepositState {
/**
* 冻结中
......
......@@ -190,10 +190,13 @@ public class DepositService {
public DepositStat getDepositStat() {
DepositStat depositStat = new DepositStat();
Optional<Double> totalAmount = accountDao.sumAllSurplus();
// Optional<Double> totalAmount = accountDao.sumAllSurplus();
Optional<Double> totalAmount = depositDao.sumAll( );
Optional<Double> depositAmount = depositDao.sumAccountByDepositState(Deposit.DepositState.FREEZE);
Optional<Double> freezeAmount = depositDao.sumByDepositState(Deposit.DepositState.FREEZE);
depositStat.setTotalAmount(totalAmount.orElse(0.0));
depositStat.setFreezeAmount(freezeAmount.orElse(0.0));
depositStat.setTotalAmount(Math.abs(totalAmount.orElse(0.0)));
depositStat.setDepositAmount(depositAmount.orElse(0.0));
depositStat.setFreezeAmount(Math.abs(freezeAmount.orElse(0.0)));
return depositStat;
}
......
......@@ -96,6 +96,14 @@ export class DepositController{
static PAGE_DEPOSIT = 'depositRule/pageDeposit';
/**
*/
static pageDepositFetchOrder(axios:AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Deposit>>> {
return axios.post('depositRule/pageDepositFetchOrder', pagination);
}
static PAGE_DEPOSIT_FETCH_ORDER = 'depositRule/pageDepositFetchOrder';
/**
* 分页查询保证金规则
* @param pagination
* @return Page
......
......@@ -7,18 +7,18 @@
</a-col>
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="当前可用总额" :value="depositStat.totalAmount+depositStat.freezeAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
<a-statistic title="当前可用总额" :value="depositStat.depositAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
</a-col>
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="当前冻结总额" :value="-depositStat.freezeAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
<a-statistic title="当前冻结总额" :value="depositStat.freezeAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
</a-col>
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="待处理提现总额" :value="depositStat.unauditedWithdrawAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
<!-- <a-card class="stat-card">-->
<!-- <a-statistic title="待处理提现总额" :value="depositStat.unauditedWithdrawAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>-->
<!-- </a-card>-->
</a-col>
</a-row>
<!--查询栏-->
......
<template>
<a-row v-sec="'deposit_2'" :gutter="16" v-if="depositStat">
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="平台保证金总额" :value="depositStat.totalAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
</a-col>
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="当前可用总额" :value="depositStat.depositAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
</a-col>
<a-col :span="6">
<a-card class="stat-card">
<a-statistic title="当前冻结总额" :value="depositStat.freezeAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>
</a-card>
</a-col>
<a-col :span="6">
<!-- <a-card class="stat-card">-->
<!-- <a-statistic title="待处理提现总额" :value="depositStat.unauditedWithdrawAmount" :precision="0" prefix="¥" suffix="元"></a-statistic>-->
<!-- </a-card>-->
</a-col>
</a-row>
<!--查询栏-->
<m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm" @onSearch="pageReload" @onReset="pageReset" :simpleFieldNum="4"/>
<div class="table-operations">
......@@ -29,7 +51,9 @@
<router-link v-sec="'deposit_11'" :to="{ path:'/auction/view',query:{auctionId: record.auctionVehicle.auction.auctionId}}">
<a-button type="link" size="small">场次详情</a-button>
</router-link>
<a-button type="link" size="small">退款</a-button>
<template v-if="record.depositState==='FREEZE'&&(record.auctionOrder)">
<a-button type="link" size="small" @click="confirmRefund(record)">退款</a-button>
</template>
</template>
<template v-if="column.key === 'transactionType'">
{{ $t('enum.transaction.transactionType.' + record.transaction.transactionType) }}
......@@ -37,6 +61,9 @@
<template v-if="column.key === 'depositState'">
<deposit-state-tag :deposit-state="record.depositState"></deposit-state-tag>
</template>
<template v-if="column.key === 'orderState'">
<auction-order-state-tag v-if="record.auctionOrder" :order-state="record.auctionOrder.orderState"></auction-order-state-tag>
</template>
</template>
<!--交易明细列表end-->
......@@ -56,14 +83,18 @@ import {ExportUtil} from "@/common/ExportUtil";
import {createVNode} from "vue";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
import {AuctionOrderController} from "@/api/AuctionOrderController";
import AuctionOrderStateTag from "@/views/auction/order/AuctionOrderStateTag.vue";
@Component({
components: {DepositStateTag}
components: {AuctionOrderStateTag, DepositStateTag}
})
export default class DepositRefundPage extends PaginationComponent<Deposit> {
exporting = false;
@Security.Getter hasPrivilege;
/**
* 表格列配置
*/
......@@ -90,11 +121,11 @@ export default class DepositRefundPage extends PaginationComponent<Deposit> {
}
}
},
// {title: '交易类型', dataIndex: ['transaction', 'transactionType'], key: 'transactionType', align: 'center', width: 120, resizable: true, ellipsis: true, sorter: true},
{title: '车源号', dataIndex: ['auctionVehicle', 'vehicle', 'baseInfo', 'sourceNo'], key: 'sourceNo', resizable: true, ellipsis: true, sorter: true},
{title: '关联信息', dataIndex: ['auctionVehicle', 'vehicle', 'baseInfo', 'carTypeName'], key: 'carTypeName', resizable: true, ellipsis: true, sorter: true},
{title: '关联订单信息', dataIndex: ['auctionOrder', 'orderCode'], key: 'orderCode',width: 140, resizable: true, ellipsis: true, sorter: true},
{title: '关联订单状态', dataIndex: ['auctionOrder', 'orderState'], key: 'orderState',width: 140, resizable: true, ellipsis: true, sorter: true},
{
title: '冻结金额', dataIndex: ['transaction', 'amount'], key: 'amount', align: 'right', width: 140, resizable: true, ellipsis: true, sorter: true,
customRender: ({text, record, index, column}) => {
......@@ -108,6 +139,7 @@ export default class DepositRefundPage extends PaginationComponent<Deposit> {
}
},
{title: '冻结时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170, resizable: true, ellipsis: true, sorter: true},
{title: '退款时间', dataIndex: 'refundTime', key: 'refundTime', align: 'center', width: 170, resizable: true, ellipsis: true, sorter: true},
{
title: '冻结状态', dataIndex: 'depositState', key: 'depositState', align: 'center', fixed: 'right', width: 110, resizable: true, ellipsis: true, sorter: true,
},
......@@ -120,7 +152,7 @@ export default class DepositRefundPage extends PaginationComponent<Deposit> {
* 初始化配置
*/
created(): void {
this.init(this.axios, DepositController.PAGE_DEPOSIT);
this.init(this.axios, DepositController.PAGE_DEPOSIT_FETCH_ORDER);
this.buildQueryForm({
account: [null, {label: '用户姓名', field: 'account.accountName', operator: Operator.like}],
mobile: [null, {label: '手机号', field: 'account.mobile', operator: Operator.like}],
......@@ -175,11 +207,11 @@ export default class DepositRefundPage extends PaginationComponent<Deposit> {
Modal.confirm({
title: '提示',
icon: createVNode(ExclamationCircleOutlined),
content: `保证金冻结金额为 ¥${deposit.transaction.amount},退款金额为 ¥${deposit.amount},您确定将此保证金退款吗?`,
content: `当前保证金冻结金额为 ¥${-deposit.transaction.amount},退款金额为 ¥${deposit.amount},您确定将此保证金退款吗?`,
onOk() {
DepositController.refund(that.axios, deposit.depositId).then(response => {
message.success('退款操作成功,请等待支付平台回调');
message.success('退款操作成功,请等待支付平台回调,大约10秒左右退款到账。');
that.pageRefresh();
});
},
onCancel() {
......
......@@ -6,15 +6,15 @@
<!-- 账户余额区域 -->
<view class="balance-section">
<view class="balance-label">我的钱包
<view class="withdraw-button" @click="withdraw">提现
<uni-icons type="right" size="12" style="padding-bottom: 4px;" color="#185EFE"></uni-icons>
</view>
<!-- <view class="withdraw-button" @click="withdraw">提现-->
<!-- <uni-icons type="right" size="12" style="padding-bottom: 4px;" color="#185EFE"></uni-icons>-->
<!-- </view>-->
</view>
<view class="balance-surplus">
<view>
<view class="stat-label">账户余额(元)
<text class="recharge" @click="recharge">充值</text>
<!-- <text class="recharge" @click="recharge">充值</text>-->
</view>
<view class="balance-amount">{{ $filters.formatNumber(transactionStat?.surplus ?? 0) }}</view>
</view>
......@@ -35,11 +35,10 @@
<view class="stat-value">{{ transactionStat?.debt ?? 0 }}</view>
</view>
<view class="stat-item">
<view class="stat-label">提现中</view>
<view class="stat-value">{{ transactionStat?.withdraw ?? 0 }}</view>
</view>
<!-- <view class="stat-item">-->
<!-- <view class="stat-label">提现中</view>-->
<!-- <view class="stat-value">{{ transactionStat?.withdraw ?? 0 }}</view>-->
<!-- </view>-->
<view class="stat-item">
<view class="stat-label">已支出</view>
<view class="stat-value">{{ transactionStat?.expenses ?? 0 }}</view>
......@@ -54,7 +53,7 @@
<view class="tab-item" :class="{active:activeTab==='SPENDING'}" @click="switchTab('SPENDING')">支出明细</view>
<view class="tab-item" :class="{active:activeTab==='FREEZE'}" @click="switchTab('FREEZE')">冻结明细</view>
<view class="tab-item" :class="{active:activeTab==='UNFREEZE'}" @click="switchTab('UNFREEZE')">解冻明细</view>
<view class="tab-item" :class="{active:activeTab==='RECHARGE'}" @click="switchTab('RECHARGE')">充值记录</view>
<!-- <view class="tab-item" :class="{active:activeTab==='RECHARGE'}" @click="switchTab('RECHARGE')">充值记录</view>-->
</view>
......
......@@ -99,12 +99,12 @@
</view>
<text class="tool-name">我的收藏</text>
</view>
<view class="tool-item" @click="navigateTo('/module/deposit/WithdrawConfirmPage')">
<view class="tool-icon">
<image src="/static/images/profile/withdraw.png" mode="aspectFill" class="tools-image"/>
</view>
<text class="tool-name">确认提现</text>
</view>
<!-- <view class="tool-item" @click="navigateTo('/module/deposit/WithdrawConfirmPage')">-->
<!-- <view class="tool-icon">-->
<!-- <image src="/static/images/profile/withdraw.png" mode="aspectFill" class="tools-image"/>-->
<!-- </view>-->
<!-- <text class="tool-name">确认提现</text>-->
<!-- </view>-->
<view class="tool-item" @click="navigateTo('/module/order/BidPage')">
<view class="tool-icon">
<image src="/static/images/profile/bid.png" mode="aspectFill" class="tools-image"/>
......
import {Dayjs} from 'dayjs';
import {AuditingEntity,AuditingTimeEntity} from 'autumn-vue/lib/core/orm/AuditingEntity';
import {AuditingEntity, AuditingTimeEntity} from 'autumn-vue/lib/core/orm/AuditingEntity';
// region 前端扩展导入包
// endregion
/**
*/
/**
*/
export class DepositStat {
/**
* 总金额
*/
* 总金额
*/
totalAmount: number;
/**
* 可用金额
*/
depositAmount: number;
/**
* 冻结金额
*/
* 冻结金额
*/
freezeAmount: number;
/**
* 待审核提现金额
*/
* 待审核提现金额
*/
unauditedWithdrawAmount: number;
// region 前端扩展定义属性及方法区
......
......@@ -3,6 +3,7 @@ import {AuditingEntity,AuditingTimeEntity} from 'autumn-vue/lib/core/orm/Auditin
import {AuctionVehicle} from '../../auction/entity/AuctionVehicle';
import {Account} from '../../account/entity/Account';
import {Transaction} from './Transaction';
import {AuctionOrder} from "../../auction/entity/AuctionOrder";
// region 前端扩展导入包
// endregion
......@@ -37,6 +38,8 @@ export class Deposit extends AuditingTimeEntity {
*/
depositState: Deposit_DepositState;
auctionOrder:AuctionOrder;
// region 前端扩展定义属性及方法区
// endregion
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!