From b38d26efe3b1623414bca2c22a4fc1831585d1d3 Mon Sep 17 00:00:00 2001
From: hurui <177768073@qq.com>
Date: Thu, 14 Apr 2022 17:07:50 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=85=AC=E5=8F=B8=E8=B4=A6?=
=?UTF-8?q?=E6=88=B7=E5=85=85=E5=80=BC=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../company-amount-record.component.html | 159 ++++++++++++
.../company-amount-record.component.scss | 3 +
.../company-amount-record.component.spec.ts | 25 ++
.../company-amount-record.component.ts | 235 ++++++++++++++++++
.../company-amount-routing.module.ts | 13 +
.../company-amount/company-amount.module.ts | 26 ++
src/app/app-common.module.ts | 5 +-
src/app/app-routing.module.ts | 5 +
src/app/app.module.ts | 2 +-
.../company-amount-record-source-type.pipe.ts | 17 ++
.../company-amount-record-type.pipe.ts | 17 ++
src/app/pipes/index.ts | 2 +
src/app/services/company-account.service.ts | 62 +++++
13 files changed, 568 insertions(+), 3 deletions(-)
create mode 100644 src/app/admin/company-amount/company-amount-record/company-amount-record.component.html
create mode 100644 src/app/admin/company-amount/company-amount-record/company-amount-record.component.scss
create mode 100644 src/app/admin/company-amount/company-amount-record/company-amount-record.component.spec.ts
create mode 100644 src/app/admin/company-amount/company-amount-record/company-amount-record.component.ts
create mode 100644 src/app/admin/company-amount/company-amount-routing.module.ts
create mode 100644 src/app/admin/company-amount/company-amount.module.ts
create mode 100644 src/app/pipes/company-amount/company-amount-record-source-type.pipe.ts
create mode 100644 src/app/pipes/company-amount/company-amount-record-type.pipe.ts
create mode 100644 src/app/services/company-account.service.ts
diff --git a/src/app/admin/company-amount/company-amount-record/company-amount-record.component.html b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.html
new file mode 100644
index 0000000..f919059
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.html
@@ -0,0 +1,159 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
共计 {{dataObject.total?dataObject.total:0}} 条数据
+
+
+
+
+
+
+
+
+ 部门 |
+ 类型 |
+ 交易金额 |
+ 变更前金额 |
+ 变更后金额 |
+ 来源类型 |
+ 来源内容 |
+ 操作人 |
+ 记录时间 |
+
+
+
+
+
+ {{data.orgName}} |
+ {{data.type | companyAmountRecordType}} |
+ ¥{{data.amount}} |
+ ¥{{data.beforeAmount}} |
+ ¥{{data.afterAmount}} |
+ {{data.sourceType | companyAmountRecordSourceType}} |
+ {{data.sourceContent}} |
+ {{data.opUserName}} |
+ {{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}} |
+
+
+
+
+
+
+
+
+
diff --git a/src/app/admin/company-amount/company-amount-record/company-amount-record.component.scss b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.scss
new file mode 100644
index 0000000..690993b
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.scss
@@ -0,0 +1,3 @@
+.table-td-operation a {
+ padding: 0px 5px;
+}
diff --git a/src/app/admin/company-amount/company-amount-record/company-amount-record.component.spec.ts b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.spec.ts
new file mode 100644
index 0000000..0084531
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CompanyAmountRecordComponent } from './company-amount-record.component';
+
+describe('CompanyAmountRecordComponent', () => {
+ let component: CompanyAmountRecordComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ CompanyAmountRecordComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CompanyAmountRecordComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/admin/company-amount/company-amount-record/company-amount-record.component.ts b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.ts
new file mode 100644
index 0000000..257550c
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount-record/company-amount-record.component.ts
@@ -0,0 +1,235 @@
+import { Component, OnInit } from '@angular/core';
+import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms';
+import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd';
+import {OrganizationService} from '../../../services/organization.service';
+import {LocalStorageService} from '../../../services/local-storage.service';
+import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace';
+import {CompanyAccountService} from '../../../services/company-account.service';
+
+@Component({
+ selector: 'app-company-amount-record',
+ templateUrl: './company-amount-record.component.html',
+ styleUrls: ['./company-amount-record.component.scss']
+})
+export class CompanyAmountRecordComponent implements OnInit {
+ roleType;
+ adminFlag;
+
+ dataObject: any = {};
+ tableLoading = true;
+ searchForm: FormGroup;
+ pageNum: number;
+ whereObject: any = {};
+
+ rechargeModal = false;
+ rechargeForm: FormGroup;
+ rechargeParam = {
+ phone: null,
+ orgId: null,
+ amount: null,
+ smsCode: null,
+ };
+ submitRechargeBtnLoading = false;
+
+ smsCodeBtnName = '获取验证码';
+ smsCodeBtnLoading = false;
+ countdownTime;
+
+ orgArray = [];
+ accountObject = {
+ amounts: 0
+ };
+
+ constructor(private modal: NzModalService,
+ private message: NzMessageService,
+ private store: LocalStorageService,
+ private companyAccountService: CompanyAccountService,
+ private organizationService: OrganizationService,
+ private form: FormBuilder) {
+ this.roleType = Number(this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType);
+ this.adminFlag = Number(this.store.get(ADMIN_INFO_OBJECT)['secUser'].adminFlag);
+ }
+
+ ngOnInit(): void {
+ this.searchForm = this.form.group({
+ orgId: [null],
+ type: [null],
+ sourceType: [null],
+ createTime: [null],
+ createTimeS: [null],
+ createTimeE: [null],
+ });
+
+ this.rechargeForm = this.form.group({
+ orgId: [null, [Validators.required]],
+ amount: [null, [Validators.required]],
+ smsCode: [null, [Validators.required]],
+ });
+
+ if (this.roleType === 5 && this.adminFlag === 1) {
+ this.organizationService.getOrganizationList(this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['id'], data => {
+ this.orgArray = data['return_data'];
+ });
+ }
+
+ if (this.roleType === 5 && this.adminFlag === 0) {
+ this.companyAccountService.getAccount(data => {
+ this.accountObject = data['return_data'];
+ });
+ }
+
+ this.requestData(1);
+ }
+
+ /**
+ * 请求数据
+ */
+ requestData(pageNum) {
+ this.tableLoading = true;
+ this.whereObject['pageNum'] = pageNum;
+ this.whereObject['pageSize'] = 10;
+ this.companyAccountService.getAmountRecordList(this.whereObject, data => {
+ if (data['return_code'] === '000000') {
+ this.dataObject = data['return_data'];
+ } else {
+ this.modal.error(data['return_msg']);
+ }
+ this.tableLoading = false;
+ });
+ }
+
+ /**
+ * 搜索
+ * @param whereObject 条件
+ */
+ search(whereObject: object) {
+ this.whereObject = whereObject;
+ if (this.searchForm.value.createTime != null) {
+ this.searchForm.value.createTimeS = new Date(this.searchForm.value.createTime[0]).getTime();
+ this.searchForm.value.createTimeE = new Date(this.searchForm.value.createTime[1]).getTime();
+ } else {
+ this.searchForm.value.createTimeS = null;
+ this.searchForm.value.createTimeE = null;
+ }
+ this.requestData(1);
+ }
+
+ /**
+ * 重置
+ */
+ resetForm(): void {
+ this.searchForm.reset();
+ }
+
+ /**
+ * 展示充值模态框
+ */
+ showRechargeModal() {
+ this.rechargeModal = true;
+ }
+
+ /**
+ * 关闭充值模态框
+ */
+ closeRechargeModal() {
+ this.rechargeModal = false;
+ }
+
+ /**
+ * 提交充值
+ */
+ submitRecharge() {
+ this.submitRechargeBtnLoading = true;
+ for (const i in this.rechargeForm.controls) {
+ this.rechargeForm.controls[i].markAsDirty();
+ this.rechargeForm.controls[i].updateValueAndValidity();
+ }
+ if (this.rechargeForm.status == null || this.rechargeForm.status !== 'VALID') {
+ this.modal.warning({
+ nzTitle: '提示',
+ nzContent: '请填写所有必填项',
+ });
+ this.submitRechargeBtnLoading = false;
+ return;
+ }
+
+ this.rechargeParam.smsCode = this.rechargeForm.value['smsCode'];
+ this.companyAccountService.recharge(this.rechargeParam, data => {
+ if (data['return_code'] === '000000') {
+ this.modal.success({
+ nzTitle: '提示',
+ nzContent: '充值成功',
+ });
+
+ this.rechargeForm.controls.orgId.enable();
+ this.rechargeForm.controls.amount.enable();
+ this.rechargeForm = this.form.group({
+ orgId: [null, [Validators.required]],
+ amount: [null, [Validators.required]],
+ smsCode: [null, [Validators.required]],
+ });
+
+ this.closeRechargeModal();
+ this.requestData(this.whereObject['pageNum']);
+ } else {
+ this.modal.error({
+ nzTitle: '提示',
+ nzContent: data['return_msg'],
+ });
+ }
+ this.submitRechargeBtnLoading = false;
+ });
+ }
+
+ /**
+ * 发送验证码
+ */
+ sendSmsCode() {
+ if (this.rechargeForm.value.orgId == null) {
+ this.modal.warning({
+ nzTitle: '提示',
+ nzContent: '请选择部门',
+ });
+ return;
+ }
+
+ this.rechargeParam.phone = '17726395120';
+ this.rechargeParam.orgId = this.rechargeForm.value['orgId'];
+ this.rechargeParam.amount = this.rechargeForm.value['amount'];
+
+ this.rechargeForm.controls.orgId.disable();
+ this.rechargeForm.controls.amount.disable();
+
+ this.companyAccountService.sendRechargeSmsCode('17726395120', this.rechargeParam.orgId, this.rechargeParam.amount, data => {
+ if (data['return_code'] === '000000') {
+ this.getVerifyCodeCountdown();
+ } else {
+ this.modal.error({
+ nzTitle: '提示',
+ nzContent: data['return_msg'],
+ });
+ this.rechargeForm.controls.orgId.enable();
+ this.rechargeForm.controls.amount.enable();
+ }
+ });
+ }
+
+ /**
+ * 获取验证码倒计时
+ */
+ getVerifyCodeCountdown() {
+ let countdownSecond = 60; // 倒计时60秒
+ this.countdownTime = setInterval(() => {
+ if (countdownSecond <= 1) {
+ this.smsCodeBtnName = '获取验证码';
+ this.smsCodeBtnLoading = false;
+ clearInterval(this.countdownTime);
+ } else {
+ countdownSecond--;
+ this.smsCodeBtnName = String(countdownSecond);
+ this.smsCodeBtnLoading = true;
+ }
+ }, 1000);
+ }
+}
+
diff --git a/src/app/admin/company-amount/company-amount-routing.module.ts b/src/app/admin/company-amount/company-amount-routing.module.ts
new file mode 100644
index 0000000..0702a44
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount-routing.module.ts
@@ -0,0 +1,13 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+import {CompanyAmountRecordComponent} from './company-amount-record/company-amount-record.component';
+
+const routes: Routes = [
+ { path: 'list', component: CompanyAmountRecordComponent },
+];
+
+@NgModule({
+ imports: [RouterModule.forChild(routes)],
+ exports: [RouterModule]
+})
+export class CompanyAmountRoutingModule { }
diff --git a/src/app/admin/company-amount/company-amount.module.ts b/src/app/admin/company-amount/company-amount.module.ts
new file mode 100644
index 0000000..1b1b140
--- /dev/null
+++ b/src/app/admin/company-amount/company-amount.module.ts
@@ -0,0 +1,26 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+
+import { CompanyAmountRoutingModule } from './company-amount-routing.module';
+import { CompanyAmountRecordComponent } from './company-amount-record/company-amount-record.component';
+import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd';
+import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms';
+import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module';
+import {AppCommonModule} from '../../app-common.module';
+import {NgxEchartsModule} from '_ngx-echarts@4.2.2@ngx-echarts';
+
+
+@NgModule({
+ declarations: [CompanyAmountRecordComponent],
+ imports: [
+ CommonModule,
+ CompanyAmountRoutingModule,
+ NgZorroAntdModule,
+ ReactiveFormsModule,
+ FormsModule,
+ BreadcrumbModule,
+ AppCommonModule,
+ NgxEchartsModule,
+ ]
+})
+export class CompanyAmountModule { }
diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts
index d654cac..c4f89b3 100644
--- a/src/app/app-common.module.ts
+++ b/src/app/app-common.module.ts
@@ -37,7 +37,7 @@ import {
DiscountPackageStatusPipe,
PriceShowPipe,
ShowTypePipe,
- EnergyTypePipe
+ EnergyTypePipe, CompanyAmountRecordTypePipe, CompanyAmountRecordSourceTypePipe
} from './pipes';
@@ -74,7 +74,8 @@ const PIPES = [
ShowTypePipe,
PriceShowPipe,
EnergyTypePipe,
-
+ CompanyAmountRecordTypePipe,
+ CompanyAmountRecordSourceTypePipe,
];
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 4d44c15..93a09e7 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -102,6 +102,11 @@ const routes: Routes = [
loadChildren: () => import('./admin/tuanyou-agent/tuanyou-agent.module').then(m => m.TuanyouAgentModule),
canActivate: [InitGuardService]
},
+ {
+ path: 'company-amount',
+ loadChildren: () => import('./admin/company-amount/company-amount.module').then(m => m.CompanyAmountModule),
+ canActivate: [InitGuardService]
+ },
],
},
];
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 020d7f2..98d4ac3 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -23,7 +23,7 @@ registerLocaleData(zh);
@NgModule({
declarations: [
- AppComponent
+ AppComponent,
],
imports: [
BrowserModule,
diff --git a/src/app/pipes/company-amount/company-amount-record-source-type.pipe.ts b/src/app/pipes/company-amount/company-amount-record-source-type.pipe.ts
new file mode 100644
index 0000000..e09f987
--- /dev/null
+++ b/src/app/pipes/company-amount/company-amount-record-source-type.pipe.ts
@@ -0,0 +1,17 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'companyAmountRecordSourceType'
+})
+export class CompanyAmountRecordSourceTypePipe implements PipeTransform {
+
+ transform(value: number): string {
+ switch (value) {
+ case 1:
+ return '金额充值';
+ case 2:
+ return '油卡充值';
+ }
+ }
+
+}
diff --git a/src/app/pipes/company-amount/company-amount-record-type.pipe.ts b/src/app/pipes/company-amount/company-amount-record-type.pipe.ts
new file mode 100644
index 0000000..9b9a347
--- /dev/null
+++ b/src/app/pipes/company-amount/company-amount-record-type.pipe.ts
@@ -0,0 +1,17 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'companyAmountRecordType'
+})
+export class CompanyAmountRecordTypePipe implements PipeTransform {
+
+ transform(value: number): string {
+ switch (value) {
+ case 1:
+ return '进账';
+ case 2:
+ return '出账';
+ }
+ }
+
+}
diff --git a/src/app/pipes/index.ts b/src/app/pipes/index.ts
index 3649206..b0811b5 100644
--- a/src/app/pipes/index.ts
+++ b/src/app/pipes/index.ts
@@ -26,3 +26,5 @@ export * from './discount-package-status.pipe';
export * from './show-type.pipe';
export * from './price-show.pipe';
export * from './index/energy-type.pipe';
+export * from './company-amount/company-amount-record-type.pipe';
+export * from './company-amount/company-amount-record-source-type.pipe';
diff --git a/src/app/services/company-account.service.ts b/src/app/services/company-account.service.ts
new file mode 100644
index 0000000..36b68df
--- /dev/null
+++ b/src/app/services/company-account.service.ts
@@ -0,0 +1,62 @@
+import { Injectable } from '@angular/core';
+import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http';
+import {CommonsService} from './commons.service';
+import {environment} from '../../environments/environment';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class CompanyAccountService {
+
+ constructor(
+ private http: HttpClient,
+ private common: CommonsService
+ ) { }
+
+ /**
+ * 余额充值
+ *
+ * @param paramsObject 参数对象
+ * @param callBack 回调
+ */
+ public recharge(paramsObject: object, callBack) {
+ this.http.post(environment.baseUrl + 'companyAccount/recharge', paramsObject).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 查询余额
+ *
+ * @param callBack 回调
+ */
+ public getAccount( callBack) {
+ this.http.get(environment.baseUrl + 'companyAccount/getAccount').subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 发送充值短信验证码
+ *
+ * @param phone 手机号
+ * @param callBack 回调
+ */
+ public sendRechargeSmsCode(phone: string, orgId: number, price: string, callBack) {
+ this.http.get(environment.baseUrl + 'sendSms/sendRechargeSmsCode?phone=' + phone + '&orgId=' + orgId + '&price=' + price).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 查询余额记录列表
+ *
+ * @param paramsObject 参数对象
+ * @param callBack 回调
+ */
+ public getAmountRecordList(paramsObject: object, callBack) {
+ this.http.get(environment.baseUrl + 'companyAccount/getAccountRecordList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
+ callBack(data);
+ });
+ }
+}