This commit is contained in:
潘晓云
2022-04-22 18:11:01 +08:00
parent acc78ad635
commit cbbdd6b069
8 changed files with 430 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form';
import { NzModalService } from 'ng-zorro-antd/modal';
import { FreightAccountService } from '../../services/freight-account.service';
import { CwcBankCardManagementBindComponent } from '../bank-card-management/bind/bind.component';
import { CwcAccountManagementWithdrawDepositComponent } from './withdraw-deposit/withdraw-deposit.component';
@Component({
selector: 'app-platform-account',
@ -192,12 +193,18 @@ export class PlatformAccountComponent implements OnInit {
})
},
{
text: '绑定银行卡',
click: item => this.bindBankcard(item)
text: '提现',
click: item => this.withdraw(item),
iif: (_record) => _record.bankType !== '1'
},
// {
// text: '绑定银行卡',
// click: item => this.bindBankcard(item)
// },
{
text: '查看银行卡',
click: item => this.viewBankcard(item)
click: item => this.viewBankcard(item),
iif: (_record) => _record.bankType !== '1'
},
]
}
@ -239,4 +246,25 @@ export class PlatformAccountComponent implements OnInit {
exportList() {
this.service.exportStart({ ...this.sf.value, pageSize: -1 }, this.service.$api_get_exportPlatformAccountBalanceByOperator,);
}
// 提现
withdraw(record: any) {
const modalRef = this.modal.create({
nzTitle: '提现',
nzWidth: '35%',
nzContent: CwcAccountManagementWithdrawDepositComponent,
nzMaskClosable: false,
nzComponentParams: {
record
},
nzFooter: null
});
modalRef.afterClose.subscribe(res => {
if (res) {
// this.getSummary();
// this.withdrawTable.refresh();
}
})
}
}

View File

@ -0,0 +1,39 @@
<sf #sf mode="edit" [schema]="schema" [ui]="ui" button="none" autocomplete="off">
<ng-template sf-template="availableBalance" let-me>
<div *ngIf=" me.formProperty.value === null || me.formProperty.value === undefined ">-</div>
<div *ngIf=" me.formProperty.value >= 0 " class="text-red-dark">{{me.formProperty.value | currency}}</div>
</ng-template>
<ng-template sf-template="bankId" let-me let-ui="ui" let-schema="schema">
<nz-radio-group *ngIf="bankCardList.length >0" [ngModel]="me.formProperty.value" class="pay-way-group "
(ngModelChange)="checkBankCard($event)">
<div class=" band-card mb-xs" *ngFor="let item of bankCardList">
<label [nzValue]="item.id" nz-radio ngModel class="pay-way-label">
<img class="mr-sm" [src]="'./assets/images/wallet.svg'" width="26" height="26" />
<span class="mr-sm"> {{ item.bankName}}</span>
<span>{{item.bankCardNumber}}</span>
</label>
</div>
</nz-radio-group>
<div> <a (click)="toAddBankPage()" class="text-blue-dark">+添加银行卡 </a></div>
</ng-template>
<ng-template sf-template="amount" let-me>
<nz-input-number nz-input type="number" [nzMax]="balanceObj?.allBalance" [nzMin]="1" placeholder="请输入提现金额"
[ngModel]="me.formProperty.value" class="input-row" (ngModelChange)="me.setValue($event)" autocomplete="off"
[nzPrecision]="2"></nz-input-number>
<a (click)="allWithdrawal()">全部提现</a>
</ng-template>
<ng-template sf-template="payPsd" let-me>
<input maxlength="6" class="input-row iconfont icon-yuandian" id="psd" [type]="'text'" autocomplete="off" nz-input
placeholder="请输入支付密码" [ngModel]="me.formProperty.value" (ngModelChange)="changePsd($event)"
(keydown)="keydown($event)" (mouseup)="setFocus()" #psd />
<a (click)="toForgetPsdPage()">忘记密码?</a>
</ng-template>
<div class="modal-footer">
<button nz-button type="button" (click)="close(false)">取 消</button>
<button nz-button type="submit" nzType="primary" (click)="save(sf?.value)" [disabled]="!sf.valid"
[nzLoading]="service.http.loading">
</button>
</div>
</sf>

View File

@ -0,0 +1,37 @@
:host {
.bank-card-select-content {
padding: 5px;
border: 1px solid #ccc;
.band-card-row {
display: flex;
align-items: center;
}
}
.pay-way-group {
width: 100%;
margin-bottom: 5px;
.bank-card-row {
display: flex;
align-items: center;
}
.band-card {
border: 1px solid #e8e8e8;
.pay-way-label {
width: 100%;
padding: 6px 10px;
}
}
}
.input-row {
width: 70%;
margin-right: 8px;
}
}

View File

@ -0,0 +1,24 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { CwcAccountManagementWithdrawDepositComponent } from './withdraw-deposit.component';
describe('CwcAccountManagementWithdrawDepositComponent', () => {
let component: CwcAccountManagementWithdrawDepositComponent;
let fixture: ComponentFixture<CwcAccountManagementWithdrawDepositComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [CwcAccountManagementWithdrawDepositComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CwcAccountManagementWithdrawDepositComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,288 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { cacheConf } from '@conf/cache.conf';
import { STColumn, STComponent } from '@delon/abc/st';
import { SFComponent, SFSchema, SFSelectWidgetSchema, SFUISchema } from '@delon/form';
import { EACacheService, EAEnvironmentService, ShipperBaseService } from '@shared';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { BankCardManagementService } from '../../../services/bank-card-management.service';
@Component({
selector: 'app-cwc-withdraw-deposit',
templateUrl: './withdraw-deposit.component.html',
styleUrls: ['./withdraw-deposit.component.less']
})
export class CwcAccountManagementWithdrawDepositComponent implements OnInit {
accountBalance = 0;
minWithdrawAmount = 0;
minWithdrawFee: any = 0;
code = '';
bankList: Array<any> = [];
bankAccount = '';
count = 0;
interval$: any;
ui: SFUISchema = {};
i: any;
schema: SFSchema = {};
totalGJ: any = 0.0;
cacFee: any = 0;
columns: STColumn[] = [];
totalBalance = 200;
bankCardList: Array<any> = [];
cardNo = '';
accountDetail: any = {};
networkTransporterId = '';
networkTransporterName = '';
balanceObj: any = {
allBalance: 99999999
};
@ViewChild('st', { static: false }) st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
@ViewChild('psd') psd!: ElementRef;
record: any;
bankType = '2';
constructor(
public service: BankCardManagementService,
private modal: NzModalRef,
private shipperSrv: ShipperBaseService,
public eaCacheSrv: EACacheService,
public envSrv: EAEnvironmentService,
public router: Router
) {
this.networkTransporterId = this.eaCacheSrv.get(cacheConf.env)?.networkTransporterId;
}
ngOnInit() {
this.initSF();
this.getBankList();
this.getProjectBalanceDetail();
}
/**
* 初始化查询表单
*/
initSF() {
this.schema = {
properties: {
ltdName: {
title: '网络货运人',
type: 'string',
default: this.record?.ltdName,
ui: {
widget: 'text',
}
},
bankType: {
title: '银行',
type: 'string',
default: this.bankType,
enum: [
{ label: '浦发银行', value: '2' }
],
ui: {
widget: 'select',
containsAllLabel: false,
showRequired: true,
change: (value: any) => {
// if (value && this.sf?.value?.ltdId) {
// const parmas = { bankType: value, ltdId: this.sf.getValue('/ltdId') };
// this.getProjectBalanceDetail(parmas);
// }
}
} as SFSelectWidgetSchema
},
availableBalance: { title: '可提现余额', type: 'string', ui: { showRequired: false, widget: 'custom' } },
bankId: {
title: '提现至',
type: 'string',
ui: {
showRequired: true, widget: 'custom'
},
},
amount: {
title: '提现金额',
type: 'string',
ui: {
showRequired: true,
widget: 'custom',
validator: (val) => {
if (!val && val !== 0) {
return [{ keyword: 'required', message: '必填项' }];
} else if (val > this.balanceObj.allBalance) {
return [{ keyword: 'required', message: '提现金额超过可提现余额' }];
}
return [];
}
},
},
payPsd: {
title: '支付密码',
type: 'string',
minLength: 6,
maxLength: 6,
ui: { widget: 'custom' },
},
payPassword: {
title: '',
type: 'string',
ui: {
hidden: true
}
}
},
autocomplete: 'off',
required: ['bankType', 'payPsd']
};
this.ui = {
'*': { spanLabelFixed: 100, grid: { span: 18, gutter: 2 } },
$addBankCard1: {
grid: { span: 24 }
},
$addBankCard2: {
grid: { span: 24 }
}
};
}
save(value: any) {
if (this.sf.valid) {
const { amount, bankId, bankType, ltdName, payPassword } = value;
if (amount > this.balanceObj?.allBalance) {
this.service.msgSrv.warning('提现金额超过可提现余额!');
return;
}
const params = {
amount,
bankId,
bankType,
ltdId: this.record.ltdId,
ltdName,
payPassword
};
this.service.request(this.service.$api_apply_withdraw, { ...params })
.subscribe(res => {
if (res) {
this.service.msgSrv.success('提现成功!');
this.close(true);
}
})
}
}
close(flag: boolean) {
this.modal.destroy(flag);
}
toAddBankPage() {
window.open(`/#/financial-management/bank-card-management/index?ltdId=${this.record?.ltdId}&ltdName=${this.record?.ltdName}`);
}
/**
* 全部提现
*/
allWithdrawal() {
if (!this.sf.getValue('/availableBalance')) {
this.sf.setValue('/amount', '');
return;
}
this.sf.setValue('/amount', this.balanceObj?.allBalance);
}
/**
* 跳转至忘记密码页
*/
toForgetPsdPage() {
window.open('/#/account/edit-paypassword');
}
/**
* 切换银行卡
*/
checkBankCard(e: any) {
this.sf.setValue('/bankId', e);
}
getBankList() {
this.service.request(this.service.$api_bank_card_list, { accountType: '3', roleId: this.record?.ltdId }).subscribe((res) => {
if (res) {
this.bankCardList = res;
}
});
}
/**
* 获取项目账户余额
*/
getProjectBalanceDetail(params = {}) {
this.service.request(this.service.$api_get_account_available_balance, { bankType: this.bankType, ltdId: this.record?.ltdId }).subscribe(res => {
if (res) {
this.balanceObj = res;
this.sf.setValue('/availableBalance', res?.allBalance);
// this.sf.getProperty('/amount')?.updateValueAndValidity();
}
})
}
keydown(e: any) {
if (e.keyCode == 37 || e.keyCode == 39) e.preventDefault();
if (e.keyCode === 8) {
// const payPswVal = this.sf.getValue('/password');
// this.sf.setValue('/password', payPswVal.substr(0, payPswVal.length - 1));
}
}
clickInput(e: any) {
this.psd.nativeElement.focus();
}
changePsd(val: any) {
this.sf.setValue('/payPsd', val);
if (val || val !== '') {
const last = val.substr(val.length - 1);
const password = this.sf.getValue('/payPassword');
const start = this.psd?.nativeElement.selectionStart;
if (last !== '•') {
this.sf.setValue('/payPassword', start !== 1 ? (password + last) : last);
} else {
this.sf.setValue('/payPassword', password.substr(0, val.length));
}
const payPswVal = this.sf.getValue('/payPsd');
this.sf.setValue('/payPsd', payPswVal.replace(/./g, "•"));
} else {
this.sf.setValue('/payPassword', '');
}
}
/**
* 设置光标聚焦
*/
setFocus() {
const len = this.psd?.nativeElement.value.length;
this.setSelectionRange(this.psd?.nativeElement, len, len); //将光标定位到文本最后
}
/**
* 设置光标位置
* @param input dom元素
* @param selectionStart 起始位置
* @param selectionEnd 结束位置
*/
setSelectionRange(input: ElementRef | any, selectionStart: number, selectionEnd: number) {
if (input?.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
}

View File

@ -39,6 +39,7 @@ import { AbnormalGoldDetailComponent } from './components/abnormal-gold/abnormal
import { CwcBankCardManagementIndexComponent } from './components/bank-card-management/index/index.component';
import { CwcBankCardManagementBindComponent } from './components/bank-card-management/bind/bind.component';
import { CwcBankCardManagementAddComponent } from './components/bank-card-management/add/add.component';
import { CwcAccountManagementWithdrawDepositComponent } from './components/platform-account/withdraw-deposit/withdraw-deposit.component';
const ROUTESCOMPONENTS = [
FreightAccountComponent,
@ -74,7 +75,8 @@ const ROUTESCOMPONENTS = [
AbnormalGoldDetailComponent,
CwcBankCardManagementIndexComponent,
CwcBankCardManagementBindComponent,
CwcBankCardManagementAddComponent
CwcBankCardManagementAddComponent,
CwcAccountManagementWithdrawDepositComponent
];
const NOTROUTECOMPONENTS = [DriverAccountDetailComponent, FreightAccountDetailComponent, ClearingModalComponent];

View File

@ -8,6 +8,8 @@ export class BankCardManagementService extends BaseService {
$api_bank_card_list = `/api/fcc/bankInfoOBC/list/myBankInfo`; // 获取银行卡列表
$api_bank_card_del = `/api/fcc/bankInfoOBC/delete`; // 删除银行卡
$api_bank_card_add = `/api/fcc/bankInfoOBC/save`;//新增银行卡
$api_get_account_available_balance = `/api/fcc/accountBalance/getWithdrawalAccountBalanceOperator`; //平台可提现金额查询
$api_apply_withdraw = `/api/fcc/refundApplicationOBC/addAgreeRefund`; // 提现申请
constructor(public injector: Injector) {
super(injector);
}