|
|
@ -8,7 +8,8 @@ import {ApiProductService} from '../../../services/api-product.service'; |
|
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
|
|
import {NzMessageService} from 'ng-zorro-antd'; |
|
|
|
import {NzMessageService} from 'ng-zorro-antd'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
|
|
|
|
import {HttpClient} from '@angular/common/http'; |
|
|
|
|
|
|
|
import { map, filter, scan , take } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-list', |
|
|
|
selector: 'app-list', |
|
|
@ -36,9 +37,9 @@ export class ListComponent implements OnInit { |
|
|
|
id: number; |
|
|
|
id: number; |
|
|
|
edit = false; |
|
|
|
edit = false; |
|
|
|
payPrice; |
|
|
|
payPrice; |
|
|
|
isVisibleGoods = false; |
|
|
|
isVisibleIpAddress = false; |
|
|
|
realPrice = 0; |
|
|
|
realPrice = 0; |
|
|
|
|
|
|
|
mchId: string; |
|
|
|
rechargeModal = false; |
|
|
|
rechargeModal = false; |
|
|
|
rechargeForm: FormGroup; |
|
|
|
rechargeForm: FormGroup; |
|
|
|
configValidateForm: FormGroup; |
|
|
|
configValidateForm: FormGroup; |
|
|
@ -55,6 +56,10 @@ export class ListComponent implements OnInit { |
|
|
|
productArray = []; |
|
|
|
productArray = []; |
|
|
|
productConfigArray = []; |
|
|
|
productConfigArray = []; |
|
|
|
discount; |
|
|
|
discount; |
|
|
|
|
|
|
|
ipAddress: string; |
|
|
|
|
|
|
|
isSpinning = false; |
|
|
|
|
|
|
|
isVisibleConfig = false; |
|
|
|
|
|
|
|
checkOptions = []; |
|
|
|
formatterPercent = (value: number): string => `${value == null ? 0 : value} %`; |
|
|
|
formatterPercent = (value: number): string => `${value == null ? 0 : value} %`; |
|
|
|
parserPercent = (value: string): string => value.replace(' %', ''); |
|
|
|
parserPercent = (value: string): string => value.replace(' %', ''); |
|
|
|
|
|
|
|
|
|
|
@ -65,6 +70,7 @@ export class ListComponent implements OnInit { |
|
|
|
private coupon: CouponService, |
|
|
|
private coupon: CouponService, |
|
|
|
private iconService: IconService, |
|
|
|
private iconService: IconService, |
|
|
|
private message: NzMessageService, |
|
|
|
private message: NzMessageService, |
|
|
|
|
|
|
|
private http: HttpClient, |
|
|
|
private router: Router, |
|
|
|
private router: Router, |
|
|
|
private common: CommonsService |
|
|
|
private common: CommonsService |
|
|
|
) { |
|
|
|
) { |
|
|
@ -85,6 +91,14 @@ export class ListComponent implements OnInit { |
|
|
|
this.common.getDictionary('RECHARGE_PLATFORM ', data => { |
|
|
|
this.common.getDictionary('RECHARGE_PLATFORM ', data => { |
|
|
|
this.platformArray = data['return_data']; |
|
|
|
this.platformArray = data['return_data']; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 获取可用接口数据
|
|
|
|
|
|
|
|
this.common.getDictionary('API_PRODUCT_CONFIG ', data => { |
|
|
|
|
|
|
|
for (const i of data['return_data']) { |
|
|
|
|
|
|
|
this.checkOptions.push({ |
|
|
|
|
|
|
|
label: i['codeName'], value: i['codeValue'] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public init(): void { |
|
|
|
public init(): void { |
|
|
@ -99,32 +113,41 @@ export class ListComponent implements OnInit { |
|
|
|
phone: [null], |
|
|
|
phone: [null], |
|
|
|
status: [null], |
|
|
|
status: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.validateForm = this.form.group({ |
|
|
|
this.initApiMerchantsPostFrom(false); |
|
|
|
merchantName: [null, [Validators.required]], |
|
|
|
|
|
|
|
userName: [null, [Validators.required]], |
|
|
|
|
|
|
|
phone: [null, [Validators.required]], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.configValidateForm = this.form.group({ |
|
|
|
this.configValidateForm = this.form.group({ |
|
|
|
productIds: [null, [Validators.required]], |
|
|
|
productIds: [null, [Validators.required]], |
|
|
|
discount: [null, [Validators.required]], |
|
|
|
discount: [null, [Validators.required]], |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.apiMerchants.getListApiMerchantByAll(data => { |
|
|
|
this.apiProduct.getAvailableApiProductByList(data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
this.merchantArray = data['return_data']; |
|
|
|
this.productArray = data['return_data']; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.error(data['return_msg']); |
|
|
|
this.message.error(data['return_msg']); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.apiProduct.getAvailableApiProductByList(data => { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 出现可用商户列表
|
|
|
|
|
|
|
|
public getListApiMerchantByAll(): void { |
|
|
|
|
|
|
|
this.apiMerchants.getListApiMerchantByAll(data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
this.productArray = data['return_data']; |
|
|
|
this.merchantArray = data['return_data']; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.error(data['return_msg']); |
|
|
|
this.message.error(data['return_msg']); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化商户提交报表
|
|
|
|
|
|
|
|
public initApiMerchantsPostFrom(edit: boolean): void { |
|
|
|
|
|
|
|
this.validateForm = this.form.group({ |
|
|
|
|
|
|
|
merchantName: [null, [Validators.required]], |
|
|
|
|
|
|
|
userName: [null, [Validators.required]], |
|
|
|
|
|
|
|
phone: [{ value: null , disabled: edit}, [Validators.required]], |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询列表
|
|
|
|
// 查询列表
|
|
|
@ -156,11 +179,13 @@ export class ListComponent implements OnInit { |
|
|
|
if (id != null) { |
|
|
|
if (id != null) { |
|
|
|
this.id = id; |
|
|
|
this.id = id; |
|
|
|
this.edit = true; |
|
|
|
this.edit = true; |
|
|
|
|
|
|
|
this.initApiMerchantsPostFrom(true); |
|
|
|
this.apiMerchants.findById(id, data => { |
|
|
|
this.apiMerchants.findById(id, data => { |
|
|
|
this.validateForm.patchValue(data['return_data']); |
|
|
|
this.validateForm.patchValue(data['return_data']); |
|
|
|
this.isVisible = true; |
|
|
|
this.isVisible = true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
this.initApiMerchantsPostFrom(false); |
|
|
|
this.validateForm.reset(); |
|
|
|
this.validateForm.reset(); |
|
|
|
this.isVisible = true; |
|
|
|
this.isVisible = true; |
|
|
|
this.edit = false; |
|
|
|
this.edit = false; |
|
|
@ -284,6 +309,7 @@ export class ListComponent implements OnInit { |
|
|
|
* 展示充值模态框 |
|
|
|
* 展示充值模态框 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
showRechargeModal() { |
|
|
|
showRechargeModal() { |
|
|
|
|
|
|
|
this.getListApiMerchantByAll(); |
|
|
|
this.rechargeModal = true; |
|
|
|
this.rechargeModal = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -468,4 +494,79 @@ export class ListComponent implements OnInit { |
|
|
|
this.configValidateForm.reset(); |
|
|
|
this.configValidateForm.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 打开配置ip地址
|
|
|
|
|
|
|
|
public configIp(mchId: string): void { |
|
|
|
|
|
|
|
this.mchId = mchId; |
|
|
|
|
|
|
|
this.apiMerchants.findByMchId( mchId , data => { |
|
|
|
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.ipAddress = data['return_data']['ipAddress']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.isVisibleIpAddress = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提交配置
|
|
|
|
|
|
|
|
public handleOkConfigIp(): void { |
|
|
|
|
|
|
|
this.isSpinning = true; |
|
|
|
|
|
|
|
this.apiMerchants.editApiIpAddress({ |
|
|
|
|
|
|
|
mchId: this.mchId, |
|
|
|
|
|
|
|
ipAddress: this.ipAddress |
|
|
|
|
|
|
|
} , data => { |
|
|
|
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.isSpinning = false; |
|
|
|
|
|
|
|
this.message.success('配置成功'); |
|
|
|
|
|
|
|
this.isVisibleIpAddress = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(data['return_msg']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 打开配置产品弹框
|
|
|
|
|
|
|
|
public configApiProduct(mchId: string): void { |
|
|
|
|
|
|
|
this.mchId = mchId; |
|
|
|
|
|
|
|
this.apiMerchants.getSecConfigList(mchId , data => { |
|
|
|
|
|
|
|
console.log(data); |
|
|
|
|
|
|
|
const returnData = data['return_data']; |
|
|
|
|
|
|
|
if (data['return_data'].length > 0) { |
|
|
|
|
|
|
|
for (const i of this.checkOptions) { |
|
|
|
|
|
|
|
if (returnData.filter(item => item['codeType'] === i['value']).length > 0) { |
|
|
|
|
|
|
|
i['checked'] = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
i['checked'] = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.isVisibleConfig = true; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 配置产品
|
|
|
|
|
|
|
|
public handleOkConfigProduct(): void { |
|
|
|
|
|
|
|
const data = []; |
|
|
|
|
|
|
|
for (const i of this.checkOptions) { |
|
|
|
|
|
|
|
if (i['checked']) { |
|
|
|
|
|
|
|
data.push(i['value']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(data); |
|
|
|
|
|
|
|
const postData = { |
|
|
|
|
|
|
|
mchId: this.mchId, |
|
|
|
|
|
|
|
configProduct: data.join(',') |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.isSpinning = true; |
|
|
|
|
|
|
|
this.apiMerchants.configMerchant(postData , res => { |
|
|
|
|
|
|
|
if (res['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.isSpinning = false; |
|
|
|
|
|
|
|
this.message.success('配置成功'); |
|
|
|
|
|
|
|
this.isVisibleConfig = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(res['return_msg']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|