From cdcaaf07e1ec7e701a9c287fc3ac537646cd6867 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 9 Jun 2022 14:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=87=AA=E5=BB=BA=E7=AB=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=88=B0=E8=AF=9D=E8=B4=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api-merchants-routing.module.ts | 14 + .../api-merchants/api-merchants.module.ts | 29 ++ .../api-merchants/list/list.component.html | 297 +++++++++++ .../api-merchants/list/list.component.scss | 0 .../api-merchants/list/list.component.ts | 465 ++++++++++++++++++ .../api-product/api-product-routing.module.ts | 14 + .../admin/api-product/api-product.module.ts | 29 ++ .../api-product/list/list.component.html | 195 ++++++++ .../api-product/list/list.component.scss | 0 .../admin/api-product/list/list.component.ts | 233 +++++++++ src/app/pipes/apiMerchant/source-type.pipe.ts | 18 + src/app/services/api-merchants.service.ts | 170 +++++++ src/app/services/api-product.service.ts | 97 ++++ 13 files changed, 1561 insertions(+) create mode 100644 src/app/admin/api-merchants/api-merchants-routing.module.ts create mode 100644 src/app/admin/api-merchants/api-merchants.module.ts create mode 100644 src/app/admin/api-merchants/list/list.component.html create mode 100644 src/app/admin/api-merchants/list/list.component.scss create mode 100644 src/app/admin/api-merchants/list/list.component.ts create mode 100644 src/app/admin/api-product/api-product-routing.module.ts create mode 100644 src/app/admin/api-product/api-product.module.ts create mode 100644 src/app/admin/api-product/list/list.component.html create mode 100644 src/app/admin/api-product/list/list.component.scss create mode 100644 src/app/admin/api-product/list/list.component.ts create mode 100644 src/app/pipes/apiMerchant/source-type.pipe.ts create mode 100644 src/app/services/api-merchants.service.ts create mode 100644 src/app/services/api-product.service.ts diff --git a/src/app/admin/api-merchants/api-merchants-routing.module.ts b/src/app/admin/api-merchants/api-merchants-routing.module.ts new file mode 100644 index 0000000..3c26cf0 --- /dev/null +++ b/src/app/admin/api-merchants/api-merchants-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import {ListComponent} from './list/list.component'; + + +const routes: Routes = [ + { path: 'list', component: ListComponent }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class ApiMerchantsRoutingModule { } diff --git a/src/app/admin/api-merchants/api-merchants.module.ts b/src/app/admin/api-merchants/api-merchants.module.ts new file mode 100644 index 0000000..9359ec3 --- /dev/null +++ b/src/app/admin/api-merchants/api-merchants.module.ts @@ -0,0 +1,29 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; + +import {ApiMerchantsRoutingModule} from './api-merchants-routing.module'; +import {ListComponent} from './list/list.component'; +import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {SeparateModule} from '../../common/separate/separate.module'; +import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; +import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; +import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; +import {AppCommonModule} from '../../app-common.module'; + + +@NgModule({ + declarations: [ListComponent], + imports: [ + CommonModule, + ApiMerchantsRoutingModule, + NgZorroAntdModule, + SeparateModule, + ReactiveFormsModule, + FormsModule, + BreadcrumbModule, + RegionSelectorModule, + AppCommonModule + ] +}) +export class ApiMerchantsModule { +} diff --git a/src/app/admin/api-merchants/list/list.component.html b/src/app/admin/api-merchants/list/list.component.html new file mode 100644 index 0000000..0ed4161 --- /dev/null +++ b/src/app/admin/api-merchants/list/list.component.html @@ -0,0 +1,297 @@ + + + + + +
+
+
+ +
+ + 商户名称 + + + + +
+
+ + 商户号 + + + + +
+
+ + 商户电话 + + + + +
+ +
+ + 状态 + + + + + + + +
+
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ + +
+ + + + 编号 + 商户名称 + 联系人 + 电话 + 商户号 + 商户KEY + 操作人员 + 创建时间 + 帐户余额 + 状态 + 操作 + + + + + {{i + 1}} + {{data.merchantName}} + {{data.userName }} + {{data.phone }} + {{data.mchId }} + {{data.apiKey }} + {{data.operatorName }} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + ¥{{data.amounts}} + {{data.status== 100? '正常':'禁用'}} + + 编辑 + + 更多操作 + + + + + + +
+ + +
+ + 商户名称 + + + + + + 商户联系人 + + + + + + 商户电话 + + + + +
+
+ + +
+ + 部门 + + + + + + + + 充值金额¥ + + + + + + 验证码 + + + + + + + + 验证码已发送!5分钟内有效 + + +
+ +
+
+
+ + + + + + 类型 + 交易金额 + 变更前金额 + 变更后金额 + 来源类型 + 来源内容 + 操作人 + 记录时间 + + + + + {{data.amountType | companyAmountRecordType}} + ¥{{data.amount}} + ¥{{data.beforeAmount}} + ¥{{data.afterAmount}} + {{data.sourceType | sourceType}} + {{data.sourceContent}} + {{data.operatorName}} + {{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}} + + + + + + +
+ + 选择产品 + + + + + + + + 折扣比例 + + + + + +
+
+ + + + + + + + 编号 + 充值金额 + 折扣金额 + 运营商 + 充值类型 + 创建时间 + 状态 + 操作 + + + + + {{i + 1}} + {{data.rechargePrice}} + {{data.discountPrice}} + {{data.operatorType | rechargePrice}} + {{data.phoneRechargeType== 1? '快充':'慢充'}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.configStatus== 101? '正常':'下架中'}} + + 编辑 + {{data.configStatus === 101 ? '下线': '上线'}} + + + + + + + + + + 折扣比例 + + + + + diff --git a/src/app/admin/api-merchants/list/list.component.scss b/src/app/admin/api-merchants/list/list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/api-merchants/list/list.component.ts b/src/app/admin/api-merchants/list/list.component.ts new file mode 100644 index 0000000..95d1caf --- /dev/null +++ b/src/app/admin/api-merchants/list/list.component.ts @@ -0,0 +1,465 @@ +import {Component, OnInit} from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; +import {CouponService} from '../../../services/coupon.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {Router} from '_@angular_router@9.0.7@@angular/router'; +import {CommonsService} from '../../../services/commons.service'; +import {ApiMerchantsService} from '../../../services/api-merchants.service'; +import {ApiProductService} from '../../../services/api-product.service'; + + +@Component({ + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit { + + WEB_SERVE_URL = environment.imageUrl; + searchForm: FormGroup; // 搜索框 + validateForm: FormGroup; // 添加框 + requestData = []; // 列表数据 + priceArray = []; // 价格数据 + platformArray = []; // 充值平台数据 + + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + isVisible = false; + visible = false; + configVisible = false; + editConfigVisible = false; + visibleConfigProduct = false; + id: number; + edit = false; + payPrice; + isVisibleGoods = false; + realPrice = 0; + + rechargeModal = false; + rechargeForm: FormGroup; + configValidateForm: FormGroup; + rechargeParam: any = {}; + smsCodeBtnName = '获取验证码'; + smsCodeBtnLoading = false; + submitRechargeBtnLoading = false; + countdownTime; + + merchantArray = []; + merchRechargeData = []; + merchantId: number; + configProductId: number; + productArray = []; + productConfigArray = []; + discount; + formatterPercent = (value: number): string => `${value == null ? 0 : value} %`; + parserPercent = (value: string): string => value.replace(' %', ''); + + constructor( + private form: FormBuilder, + private apiMerchants: ApiMerchantsService, + private apiProduct: ApiProductService, + private coupon: CouponService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + this.getInitData(); + } + + // 获取初始化数据 + private getInitData(): void { + // 获取价格数据 + this.common.getDictionary('RECHARGE_AMOUNT ', data => { + this.priceArray = data['return_data']; + }); + // 获取充值平台 + this.common.getDictionary('RECHARGE_PLATFORM ', data => { + this.platformArray = data['return_data']; + }); + } + + public init(): void { + this.rechargeForm = this.form.group({ + merchantId: [null, [Validators.required]], + amount: [null, [Validators.required]], + smsCode: [null, [Validators.required]], + }); + this.searchForm = this.form.group({ + merchantName: [null], + mchId: [null], + phone: [null], + status: [null], + }); + this.validateForm = this.form.group({ + merchantName: [null, [Validators.required]], + userName: [null, [Validators.required]], + phone: [null, [Validators.required]], + }); + this.configValidateForm = this.form.group({ + productIds: [null, [Validators.required]], + discount: [null, [Validators.required]], + }); + + this.getRequest(true, this.searchForm.value); + this.apiMerchants.getListApiMerchantByAll(data => { + if (data['return_code'] === '000000') { + this.merchantArray = data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + this.apiProduct.getAvailableApiProductByList(data => { + if (data['return_code'] === '000000') { + this.productArray = data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.apiMerchants.getListApiMerchant(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + // 修改 + public getEdit(id?: number): void { + if (id != null) { + this.id = id; + this.edit = true; + this.apiMerchants.findById(id, data => { + this.validateForm.patchValue(data['return_data']); + this.isVisible = true; + }); + } else { + this.validateForm.reset(); + this.isVisible = true; + this.edit = false; + } + } + + handleOk(): void { + + // tslint:disable-next-line:forin + for (const i in this.validateForm.controls) { + this.validateForm.controls[i].markAsDirty(); + this.validateForm.controls[i].updateValueAndValidity(); + if (this.validateForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + const wait = this.message.loading('提交中..', {nzDuration: 0}).messageId; + if (this.edit) { + this.validateForm.value['id'] = this.id; + this.apiMerchants.updateMerchant(this.validateForm.value, data => { + this.message.remove(wait); + if (data['return_code'] === '000000') { + this.message.success('修改成功'); + this.getRequest(false, this.searchForm.value); + this.validateForm.reset(); + this.isVisible = false; + } else { + this.message.error(data['return_msg']); + } + }); + } else { + this.apiMerchants.insertMerchant(this.validateForm.value, data => { + this.message.remove(wait); + if (data['return_code'] === '000000') { + this.message.success('添加成功'); + this.getRequest(false, this.searchForm.value); + this.isVisible = false; + this.validateForm.reset(); + } else { + this.message.error(data['return_msg']); + } + }); + } + + } + + handleCancel(): void { + this.validateForm.reset(); + this.isVisible = false; + } + + + public getForbiddenUser(idPost, status: any): void { + + let statusPost; + let message; + + switch (status) { + case 101: + statusPost = 100; + message = '是否上线'; + break; + case 100: + statusPost = 101; + message = '是否禁用'; + break; + } + + this.common.showConfirm(message, item => { + if (item) { + this.apiMerchants.editMerchantsStatus({ + id: idPost, + status: statusPost + }, data => { + if (data['return_code'] === '000000') { + this.message.success('提交成功'); + this.getRequest(false, this.searchForm.value); + } else { + this.message.error(data['return_msg']); + } + }); + } + }); + } + + public getEditConfigProductStatus(idPost, status: any): void { + + let statusPost; + let message; + + switch (status) { + case 102: + statusPost = 101; + message = '是否上线'; + break; + case 101: + statusPost = 102; + message = '是否禁用'; + break; + } + + this.common.showConfirm(message, item => { + if (item) { + this.apiMerchants.editConfigApiProductByStatus({ + id: idPost, + status: statusPost + }, data => { + if (data['return_code'] === '000000') { + this.message.success('提交成功'); + this.getListMerchProduct(this.merchantId); + } else { + this.message.error(data['return_msg']); + } + }); + } + }); + } + + /** + * 展示充值模态框 + */ + showRechargeModal() { + this.rechargeModal = true; + } + + /** + * 发送验证码 + */ + sendSmsCode() { + this.rechargeForm.controls.merchantId.enable(); + this.rechargeForm.controls.amount.enable(); + + if (this.rechargeForm.value.merchantId == null) { + this.message.error('请选择充值商户'); + return; + } + this.rechargeParam['merchantId'] = this.rechargeForm.value['merchantId']; + this.rechargeParam['amount'] = this.rechargeForm.value['amount']; + + this.rechargeForm.controls.merchantId.disable(); + this.rechargeForm.controls.amount.disable(); + this.common.sendRechargeSmsCode('18090580471', this.rechargeParam['merchantId'], this.rechargeParam['amount'], data => { + if (data['return_code'] === '000000') { + this.getVerifyCodeCountdown(); + } else { + this.message.error(data['return_msg']); + this.rechargeForm.controls.merchantId.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); + } + + /** + * 提交充值 + */ + submitRecharge() { + this.submitRechargeBtnLoading = true; + // tslint:disable-next-line:forin + for (const i in this.rechargeForm.controls) { + this.rechargeForm.controls[i].markAsDirty(); + this.rechargeForm.controls[i].updateValueAndValidity(); + } + this.rechargeParam.smsCode = this.rechargeForm.value['smsCode']; + if (this.rechargeForm.status == null || this.rechargeForm.status !== 'VALID') { + this.message.error('请填写所有必填项'); + this.submitRechargeBtnLoading = false; + return; + } + this.apiMerchants.recharge(this.rechargeParam, data => { + if (data['return_code'] === '000000') { + this.message.success('充值成功'); + + this.rechargeForm.controls.merchantId.enable(); + this.rechargeForm.controls.amount.enable(); + this.rechargeForm = this.form.group({ + merchantId: [null, [Validators.required]], + amount: [null, [Validators.required]], + smsCode: [null, [Validators.required]], + }); + + this.rechargeModal = false; + this.smsCodeBtnLoading = false; + this.getRequest(false, this.searchForm.value); + } else { + this.message.error(data['return_msg']); + } + this.submitRechargeBtnLoading = false; + }); + } + + + // 请求商户充值记录 + public getMerchRechargeData(id: number): void { + this.visible = true; + this.apiMerchants.getMerchRechargeData(id, data => { + if (data['return_code'] === '000000') { + this.merchRechargeData = data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 配置产品 + public configProduct(id: number): void { + this.merchantId = id; + this.configVisible = true; + } + + // 提交配置产品 + handleOkConfig(): void { + // tslint:disable-next-line:forin + for (const i in this.configValidateForm.controls) { + this.configValidateForm.controls[i].markAsDirty(); + this.configValidateForm.controls[i].updateValueAndValidity(); + console.log(this.configValidateForm.controls[i]); + if (this.configValidateForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + this.configValidateForm.value['merchantsId'] = this.merchantId; + this.apiMerchants.configApiProduct(this.configValidateForm.value , data => { + if (data['return_code'] === '000000') { + this.configVisible = false; + this.message.success('提交成功'); + } else { + this.message.error(data['return_msg']); + } + }); + } + + public showConfigProduct(id: number) { + this.visibleConfigProduct = true; + this.merchantId = id; + this.getListMerchProduct(id); + + } + + public getListMerchProduct(id: number): void { + this.apiProduct.getListMerchProduct(id , data => { + if (data['return_code'] === '000000') { + this.productConfigArray = data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + } + + + // 修改商品 + public getEditConfigProduct(id: number) { + this.configProductId = id; + this.apiMerchants.findConfigProduct(id , data => { + if (data['return_code'] === '000000') { + this.discount = data['return_data']['discount']; + } else { + this.message.error(data['return_msg']); + } + }); + this.editConfigVisible = true; + } + + handleOkConfigEdit() { + if (this.discount == null) { + this.message.error('请输入折扣比例'); + } + + const prams = { + discount: this.discount, + id: this.configProductId + }; + this.apiMerchants.updateConfigApiProduct(prams , data => { + if (data['return_code'] === '000000') { + this.editConfigVisible = false; + this.getListMerchProduct(this.merchantId); + } else { + this.message.error(data['return_msg']); + } + }); + } + +} diff --git a/src/app/admin/api-product/api-product-routing.module.ts b/src/app/admin/api-product/api-product-routing.module.ts new file mode 100644 index 0000000..84c2e99 --- /dev/null +++ b/src/app/admin/api-product/api-product-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import {ListComponent} from './list/list.component'; + + +const routes: Routes = [ + { path: 'list', component: ListComponent }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class ApiProductRoutingModule { } diff --git a/src/app/admin/api-product/api-product.module.ts b/src/app/admin/api-product/api-product.module.ts new file mode 100644 index 0000000..794ec96 --- /dev/null +++ b/src/app/admin/api-product/api-product.module.ts @@ -0,0 +1,29 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; + +import {ApiProductRoutingModule} from './api-product-routing.module'; +import {ListComponent} from './list/list.component'; +import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {SeparateModule} from '../../common/separate/separate.module'; +import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; +import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; +import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; +import {AppCommonModule} from '../../app-common.module'; + + +@NgModule({ + declarations: [ListComponent], + imports: [ + CommonModule, + ApiProductRoutingModule, + NgZorroAntdModule, + SeparateModule, + ReactiveFormsModule, + FormsModule, + BreadcrumbModule, + RegionSelectorModule, + AppCommonModule + ] +}) +export class ApiProductModule { +} diff --git a/src/app/admin/api-product/list/list.component.html b/src/app/admin/api-product/list/list.component.html new file mode 100644 index 0000000..7baf522 --- /dev/null +++ b/src/app/admin/api-product/list/list.component.html @@ -0,0 +1,195 @@ + + + + + +
+
+
+ +
+ + 运营商 + + + + + + + + +
+
+ + 充值平台 + + + + + + + +
+
+ + 话费充值类型 + + + + + + + +
+
+ + 状态 + + + + + + + +
+
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 充值金额 + 运营商 + 充值类型 + 充值平台 + 商品ID + 创建时间 + 状态 + 操作 + + + + + {{i + 1}} + {{data.rechargePrice}} + {{data.operatorType | rechargePrice}} + {{data.phoneRechargeType== 1? '快充':'慢充'}} + {{data.rechargePlatform | rechargePlatform}} + {{data.goodsId == null ? '暂未配置' : data.goodsId}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.status== 101? '上线':'编辑中'}} + + 编辑 + {{data.status === 101 ? '下线': '上线'}} + 删除 + + + +
+ + +
+ + 充值金额 + + + + + + + + + 充值金额 + + + + + + 运营商 + + + + + + + + + + + 充值平台 + + + + + + + + 充值类型 + + + + + + + + + 商品编号 + + + + + + 排序 + + + + +
+
diff --git a/src/app/admin/api-product/list/list.component.scss b/src/app/admin/api-product/list/list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/api-product/list/list.component.ts b/src/app/admin/api-product/list/list.component.ts new file mode 100644 index 0000000..b58d9c2 --- /dev/null +++ b/src/app/admin/api-product/list/list.component.ts @@ -0,0 +1,233 @@ +import { Component, OnInit } from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; +import {RechargeService} from '../../../services/recharge.service'; +import {DiscountService} from '../../../services/discount.service'; +import {CouponService} from '../../../services/coupon.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {Router} from '_@angular_router@9.0.7@@angular/router'; +import {CommonsService} from '../../../services/commons.service'; +import {ApiProductService} from '../../../services/api-product.service'; + +@Component({ + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit { + + WEB_SERVE_URL = environment.imageUrl; + searchForm: FormGroup; // 搜索框 + validateForm: FormGroup; // 添加框 + requestData = []; // 列表数据 + priceArray = []; // 价格数据 + platformArray = []; // 充值平台数据 + + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + isVisible = false; + visible = false; + id: number; + edit = false; + payPrice; + isVisibleGoods = false; + realPrice = 0; + + constructor( + private form: FormBuilder, + private recharge: RechargeService, + private discount: DiscountService, + private apiProduct: ApiProductService, + private coupon: CouponService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + this.getInitData(); + } + + // 获取初始化数据 + private getInitData(): void { + // 获取价格数据 + this.common.getDictionary('RECHARGE_AMOUNT ', data => { + this.priceArray = data['return_data']; + }); + // 获取充值平台 + this.common.getDictionary('RECHARGE_PLATFORM ', data => { + this.platformArray = data['return_data']; + }); + } + + public init(): void { + this.searchForm = this.form.group({ + operatorType : [null], + rechargePlatform: [null], + phoneRechargeType: [null], + status: [null], + }); + this.validateForm = this.form.group({ + operatorType: [null, [Validators.required]], + prices: [null, [Validators.required]], + phoneRechargeType: [null, [Validators.required]], + rechargePlatform: [null, [Validators.required]], + rechargePrice: [null], + sort: [null], + productId: [null], + }); + + + this.getRequest(true, this.searchForm.value); + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.apiProduct.getListApiProduct(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + // 修改 + public getEdit(id?: number): void { + if (id != null) { + this.id = id; + this.edit = true; + this.apiProduct.findById(id, data => { + data['return_data']['rechargePlatform'] = data['return_data']['rechargePlatform'].substring(1 , data['return_data']['rechargePlatform'].length - 1).split('-'); + data['return_data']['prices'] = ['1']; + this.validateForm.patchValue(data['return_data']); + this.isVisible = true; + }); + } else { + this.validateForm.reset(); + this.isVisible = true; + this.edit = false; + } + } + + handleOk(): void { + console.log(this.validateForm.value); + const wait = this.message.loading('提交中..', { nzDuration: 0 }).messageId; + // tslint:disable-next-line:forin + for (const i in this.validateForm.controls) { + this.validateForm.controls[i].markAsDirty(); + this.validateForm.controls[i].updateValueAndValidity(); + if (this.validateForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + + if (this.edit) { + this.validateForm.value['id'] = this.id; + this.apiProduct.updateProduct(this.validateForm.value, data => { + this.message.remove(wait); + if (data['return_code'] === '000000') { + this.message.success('修改成功'); + this.getRequest(false, this.searchForm.value); + this.validateForm.reset(); + this.isVisible = false; + } else { + this.message.error(data['return_msg']); + } + }); + } else { + this.apiProduct.insertProduct(this.validateForm.value, data => { + this.message.remove(wait); + if (data['return_code'] === '000000') { + this.message.success('添加成功'); + this.getRequest(false, this.searchForm.value); + this.isVisible = false; + this.validateForm.reset(); + } else { + this.message.error(data['return_msg']); + } + }); + } + + } + + handleCancel(): void { + this.validateForm.reset(); + this.isVisible = false; + } + + + public getForbiddenUser(idPost, status: any): void { + + let statusPost; + let message; + + switch (status) { + case 101: + statusPost = 102; + message = '是否下线'; + break; + case 102: + statusPost = 101; + message = '是否上线'; + break; + } + + this.common.showConfirm(message, item => { + if (item) { + this.apiProduct.editProductStatus( { + id: idPost, + status: statusPost + }, data => { + if (data['return_code'] === '000000') { + this.message.success('提交成功'); + this.getRequest(false, this.searchForm.value); + } else { + this.message.error(data['return_msg']); + } + }); + } + }); + } + + public getForbiddenUserD(idPost): void { + + this.common.showConfirm('是否删除', item => { + if (item) { + this.recharge.editPriceStatus({ + id: idPost, + status: 0 + }, data => { + if (data['return_code'] === '000000') { + this.message.success('删除成功'); + this.getRequest(false, this.searchForm.value); + } else { + this.message.error(data['return_msg']); + } + }); + } + }); + } + + +} diff --git a/src/app/pipes/apiMerchant/source-type.pipe.ts b/src/app/pipes/apiMerchant/source-type.pipe.ts new file mode 100644 index 0000000..02497a8 --- /dev/null +++ b/src/app/pipes/apiMerchant/source-type.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'sourceType' +}) +export class SourceTypePipe implements PipeTransform { + + transform(value: number): string { + switch (value) { + case 1: + return '金额充值'; + case 2: + return '订单退款'; + case 3: + return '话费消费'; + } + } +} diff --git a/src/app/services/api-merchants.service.ts b/src/app/services/api-merchants.service.ts new file mode 100644 index 0000000..ef33a31 --- /dev/null +++ b/src/app/services/api-merchants.service.ts @@ -0,0 +1,170 @@ +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 ApiMerchantsService { + + constructor( + private http: HttpClient, + private common: CommonsService + ) { } + + + /** + * 查询列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getListApiMerchant(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'apiMerchants/getListApiMerchant?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public updateMerchant(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiMerchants/updateMerchant', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 新增 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public insertMerchant(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiMerchants/insertMerchant', params).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public editMerchantsStatus(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiMerchants/editMerchantsStatus', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param id id + * @param callBack 回调 + */ + public findById(id: number, callBack) { + this.http.get(environment.baseUrl + 'apiMerchants/findById?id=' + id).subscribe(data => { + callBack(data); + }); + } + + + /** + * @Author Sum1Dream + * @methodName getListApiMerchantByAll + * @Description // 查询所有正常商户 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public getListApiMerchantByAll(callBack) { + this.http.get(environment.baseUrl + 'apiMerchants/getListApiMerchantByAll').subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName + * @Description // 商户充值 + * @Date 14:28 2022/6/8 + * @Param + */ + public recharge(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiMerchants/recharge', params).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName getMerchRechargeData + * @Description // 查询商户充值数据 + * @Date 15:19 2022/6/8 + * @Param id + */ + public getMerchRechargeData(id: number, callBack) { + this.http.get(environment.baseUrl + 'apiMerchants/getMerchRechargeData?merchantId=' + id).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName configApiProduct + * @Description // 提交配置产品 + * @Date 18:00 2022/6/8 + * @Param + */ + public configApiProduct(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/configApiProduct', params).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public editConfigApiProductByStatus(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/editConfigApiProductByStatus', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param id id + * @param callBack 回调 + */ + public findConfigProduct(id: number, callBack) { + this.http.get(environment.baseUrl + 'apiProduct/findConfigProduct?id=' + id).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public updateConfigApiProduct(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/updateConfigApiProduct', params).subscribe(data => { + callBack(data); + }); + } +} diff --git a/src/app/services/api-product.service.ts b/src/app/services/api-product.service.ts new file mode 100644 index 0000000..df06e59 --- /dev/null +++ b/src/app/services/api-product.service.ts @@ -0,0 +1,97 @@ +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 ApiProductService { + + constructor( + private http: HttpClient, + private common: CommonsService + ) { } + + + /** + * 查询列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getListApiProduct(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'apiProduct/getListApiProduct?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public updateProduct(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/updateProduct', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 新增 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public insertProduct(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/insertProduct', params).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName editPriceStatus + * @Description // 修改价格状态 + * @Date 15:03 2021/8/12 + * @Param mod + **/ + public editProductStatus(params: object, callBack) { + this.http.post(environment.baseUrl + 'apiProduct/editProductStatus', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param id id + * @param callBack 回调 + */ + public findById(id: number, callBack) { + this.http.get(environment.baseUrl + 'apiProduct/findById?id=' + id).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param callBack 回调 + */ + public getAvailableApiProductByList(callBack) { + this.http.get(environment.baseUrl + 'apiProduct/getAvailableApiProductByList').subscribe(data => { + callBack(data); + }); + } + + public getListMerchProduct(id: number, callBack) { + this.http.get(environment.baseUrl + 'apiMerchants/getListMerchProduct?merchantId=' + id).subscribe(data => { + callBack(data); + }); + } + +}