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);
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="37px" height="37px" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1 0 0 1 -250 -1415 )">
<path d="M 36.7711265146484 32.4772667802734 C 36.7711265146484 32.9871513320313 36.6840265712891 33.4632383457031 36.5095749414063 33.9059977138672 C 36.3351233115234 34.3487235302734 36.0869917275391 34.7377021601562 35.7651802314453 35.0731854726562 C 35.4431505019531 35.4085848427734 35.0674240185547 35.6701699677734 34.6381098349609 35.8578233955078 C 34.2089718925781 36.0456950566406 33.7394480478516 36.1395175712891 33.2295215039062 36 L 4.01191774316406 36 C 3.5022345859375 36.1395175712891 3.01918165625 36.0456866582031 2.56307780078125 35.8578233955078 C 2.10705788769531 35.6701699677734 1.704667625 35.4085764023437 1.355814671875 35.0731770742187 C 1.00687781835938 34.7377357539063 0.731872662109376 34.3487235302734 0.530841195312501 33.9059977138672 C 0.329515993164063 33.4632299472656 0.228920516601563 32.9871933242188 0.228920516601563 32.4772667802734 L 0.228920516601563 12.3950340996094 C 0.228920516601563 11.3756761835938 0.584294604492188 10.5103671953125 1.29534495605469 9.79936719238281 C 2.00638690917969 9.08845113183594 2.87165394726562 8.73278330859375 3.89117970605469 9 L 33.108909359375 9 C 34.1284770683594 8.73278330859375 34.9937441484375 9.08845113183594 35.7047105576172 9.79936719238281 C 36.4157944609375 10.5104091455078 36.7711265986328 11.3756761835938 36.7711265986328 12.3950340996094 L 36.7711265986328 17.8684397255859 L 27.6356715341797 17.8684397255859 C 26.6160618330078 17.8684397255859 25.7507528447266 18.2171247939453 25.0397948339844 18.9147131640625 C 24.3287948730469 19.6122595839844 23.9733787929688 20.4708376025391 23.9733787929688 21.4904473037109 C 24.0002523652344 22.1879937236328 24.1478304228516 22.8051291777344 24.4161465595703 23.3417195009766 C 24.6306735595703 23.7978989003906 24.9862574824219 24.2137091523438 25.4825626005859 24.5892761914062 C 25.9789516191406 24.9647928818359 26.6967245419922 25.1527064931641 27.6357135263672 25.1527064931641 L 36.7711685068359 25.1527064931641 L 36.7711685068359 32.4772584238281 Z M 28.9638153896484 2.41440425097656 L 31.2978887314453 7 L 13.0266849931641 7 C 14.4755669277344 6.13046097558594 15.8438197050781 5.40599903320313 17.1317119492188 4.70845261328125 C 18.2585641542969 4.11814873925781 19.3720886689453 3.52785326367188 20.4721512441406 2.93759133984375 C 21.5720879267578 2.34749730078125 22.4306659453125 1.89131790136719 23.0478853837891 1.569288171875 C 23.9868743261719 1.05956306445312 24.8252678339844 0.824725619140625 25.5631413671875 0.86496883203125 C 26.3008135058594 0.905262393554688 26.9247135234375 1.0326894921875 27.4343127382813 1.247258484375 C 28.0246585625 1.54240624316406 28.5345012060547 1.93138487304687 28.9638153896484 2.41440425097656 Z M 25.8246509482422 21.4904976523437 C 25.8246509482422 20.9808144951172 25.999102578125 20.5515087099609 26.3478296386719 20.2026473583984 C 26.6967245419922 19.8539202978516 27.1259967753906 19.6795106181641 27.6356799326172 19.6795106181641 C 28.1452791474609 19.6795106181641 28.574668875 19.8539202978516 28.9234798359375 20.2026473583984 C 29.2722152529297 20.5515422617187 29.4466585263672 20.9808144951172 29.4466585263672 21.4904976523437 C 29.4466585263672 22.0001388173828 29.2722068964844 22.4361756142578 28.9234798359375 22.7984905068359 C 28.5746604765625 23.1606375566406 28.1453126992187 23.3417698076172 27.6356799326172 23.3417698076172 C 27.1259967753906 23.3417698076172 26.6966909902344 23.1606291582031 26.3478296386719 22.7984905068359 C 25.9990942216797 22.4361756142578 25.8246509482422 22.0001388173828 25.8246509482422 21.4904976523437 Z " fill-rule="nonzero" fill="#fac20c" stroke="none" transform="matrix(1 0 0 1 250 1415 )" />
</g>
</svg>