|
|
@ -1,6 +1,8 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import {FormBuilder, FormGroup} from '@angular/forms'; |
|
|
|
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
import {CouponService} from '../../../services/coupon.service'; |
|
|
|
|
|
|
|
import {DiscountService} from '../../../services/discount.service'; |
|
|
|
|
|
|
|
import {NzModalService} from 'ng-zorro-antd'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-coupon-use', |
|
|
|
selector: 'app-coupon-use', |
|
|
@ -8,147 +10,61 @@ import {CouponService} from '../../../services/coupon.service'; |
|
|
|
styleUrls: ['./coupon-use.component.scss'] |
|
|
|
styleUrls: ['./coupon-use.component.scss'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class CouponUseComponent implements OnInit { |
|
|
|
export class CouponUseComponent implements OnInit { |
|
|
|
|
|
|
|
tableLoading = true; |
|
|
|
dataObject: {}; |
|
|
|
countObject: any = { |
|
|
|
couponSourceArray = [ |
|
|
|
batchNum: 0, |
|
|
|
{ codeValue: 4, codeName: '贵州中石化'}, |
|
|
|
useNum: 0, |
|
|
|
{ codeValue: 5, codeName: '重庆中石油'}, |
|
|
|
usePrice: 0, |
|
|
|
] |
|
|
|
useRate: 0, |
|
|
|
statusArray = [ |
|
|
|
}; |
|
|
|
{ codeValue: 20, codeName: '未使用'}, |
|
|
|
dataObject: any = {}; |
|
|
|
{ codeValue: 40, codeName: '已使用'}, |
|
|
|
usingRangeArray = [ |
|
|
|
|
|
|
|
{ codeValue: 10, codeName: '贵州中石化'}, |
|
|
|
|
|
|
|
{ codeValue: 8, codeName: '重庆中石油'}, |
|
|
|
] |
|
|
|
] |
|
|
|
salesPriceArray = []; |
|
|
|
salesPriceArray = []; |
|
|
|
searchForm: FormGroup; |
|
|
|
searchForm: FormGroup; |
|
|
|
whereObject: any = {}; |
|
|
|
whereObject: any = {}; |
|
|
|
|
|
|
|
pageNum = 1; |
|
|
|
|
|
|
|
pageSize = 10; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modifyModal = false; |
|
|
|
|
|
|
|
batchObject = {}; |
|
|
|
|
|
|
|
modifyForm: FormGroup; |
|
|
|
constructor(private form: FormBuilder, |
|
|
|
constructor(private form: FormBuilder, |
|
|
|
private couponService: CouponService) { } |
|
|
|
private modal: NzModalService, |
|
|
|
|
|
|
|
private couponService: CouponService, |
|
|
|
|
|
|
|
private discountService: DiscountService, |
|
|
|
|
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
let salesTimeS = new Date(); |
|
|
|
|
|
|
|
salesTimeS.setDate(salesTimeS.getDate() - 7) |
|
|
|
|
|
|
|
salesTimeS.setHours(0); |
|
|
|
|
|
|
|
salesTimeS.setMinutes(0); |
|
|
|
|
|
|
|
salesTimeS.setSeconds(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let salesTimeE = new Date(); |
|
|
|
|
|
|
|
salesTimeE.setHours(23); |
|
|
|
|
|
|
|
salesTimeE.setMinutes(59); |
|
|
|
|
|
|
|
salesTimeE.setSeconds(59); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.searchForm = this.form.group({ |
|
|
|
this.searchForm = this.form.group({ |
|
|
|
couponSource: [String(this.couponSourceArray[0].codeValue)], |
|
|
|
usingRange: [String(this.usingRangeArray[0].codeValue)], |
|
|
|
salesPrice: ['null'], |
|
|
|
price: ['null'], |
|
|
|
status: ['null'], |
|
|
|
}); |
|
|
|
salesTimeS: [salesTimeS.getTime()], |
|
|
|
this.modifyForm = this.form.group({ |
|
|
|
salesTimeE: [salesTimeE.getTime()], |
|
|
|
batchIdentifier: [null, [Validators.required]], |
|
|
|
|
|
|
|
mailTime: [null], |
|
|
|
|
|
|
|
batchNum: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.getCouponSalesPrice(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getData() { |
|
|
|
getData() { |
|
|
|
|
|
|
|
this.tableLoading = true; |
|
|
|
const param = this.searchForm.value; |
|
|
|
const param = this.searchForm.value; |
|
|
|
if (this.searchForm.controls['salesPrice'].value == 'null') { |
|
|
|
if (this.searchForm.controls['price'].value == 'null') { |
|
|
|
param['salesPrice'] = null; |
|
|
|
param['price'] = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.searchForm.controls['status'].value == 'null') { |
|
|
|
|
|
|
|
param['status'] = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.couponService.useCouponStatistics(param, response => { |
|
|
|
param['pageNum'] = this.pageNum; |
|
|
|
let returnData = response['return_data']; |
|
|
|
param['pageSize'] = this.pageSize; |
|
|
|
var dataArray = []; |
|
|
|
this.couponService.getCount(param,response => { |
|
|
|
for (let obj of returnData['salesPriceList']) { |
|
|
|
this.countObject = response['return_data']; |
|
|
|
dataArray.push({ |
|
|
|
}); |
|
|
|
value: obj['count'], |
|
|
|
this.couponService.getBatchUseCount(param, response => { |
|
|
|
name: obj['salesPrice'] + '【' + (obj['status']===20?'未使用':'已使用') + '】', |
|
|
|
this.dataObject = response['return_data']; |
|
|
|
}); |
|
|
|
this.tableLoading = false; |
|
|
|
} |
|
|
|
|
|
|
|
this.dataObject = { |
|
|
|
|
|
|
|
title: { |
|
|
|
|
|
|
|
text: this.couponSourceArray.find(o => o.codeValue == this.searchForm.controls['couponSource']['value']).codeName, |
|
|
|
|
|
|
|
left: 'center' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tooltip: { |
|
|
|
|
|
|
|
trigger: 'item' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
legend: { |
|
|
|
|
|
|
|
orient: 'vertical', |
|
|
|
|
|
|
|
left: 'left' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
series: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: '', |
|
|
|
|
|
|
|
type: 'pie', |
|
|
|
|
|
|
|
radius: '50%', |
|
|
|
|
|
|
|
data: dataArray, |
|
|
|
|
|
|
|
emphasis: { |
|
|
|
|
|
|
|
itemStyle: { |
|
|
|
|
|
|
|
shadowBlur: 10, |
|
|
|
|
|
|
|
shadowOffsetX: 0, |
|
|
|
|
|
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/*label: { |
|
|
|
|
|
|
|
formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ', |
|
|
|
|
|
|
|
backgroundColor: '#F6F8FC', |
|
|
|
|
|
|
|
borderColor: '#8C8D8E', |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
borderRadius: 4, |
|
|
|
|
|
|
|
rich: { |
|
|
|
|
|
|
|
a: { |
|
|
|
|
|
|
|
color: '#6E7079', |
|
|
|
|
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
align: 'center' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
hr: { |
|
|
|
|
|
|
|
borderColor: '#8C8D8E', |
|
|
|
|
|
|
|
width: '100%', |
|
|
|
|
|
|
|
borderWidth: 1, |
|
|
|
|
|
|
|
height: 0 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
b: { |
|
|
|
|
|
|
|
color: '#4C5058', |
|
|
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
|
|
fontWeight: 'bold', |
|
|
|
|
|
|
|
lineHeight: 33 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
per: { |
|
|
|
|
|
|
|
color: '#fff', |
|
|
|
|
|
|
|
backgroundColor: '#4C5058', |
|
|
|
|
|
|
|
padding: [3, 4], |
|
|
|
|
|
|
|
borderRadius: 4 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
},*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 搜索 |
|
|
|
|
|
|
|
* @param whereObject 条件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
search(whereObject: object) { |
|
|
|
|
|
|
|
if (this.searchForm.controls['salesTimeS'].value != null) { |
|
|
|
|
|
|
|
this.searchForm.controls['salesTimeS'].setValue(new Date(this.searchForm.controls['salesTimeS'].value).getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (this.searchForm.controls['salesTimeE'].value != null) { |
|
|
|
|
|
|
|
this.searchForm.controls['salesTimeE'].setValue(new Date(this.searchForm.controls['salesTimeE'].value).getTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 重置 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
resetForm(): void { |
|
|
|
|
|
|
|
this.searchForm.reset(); |
|
|
|
|
|
|
|
this.searchForm.controls['couponSource'].setValue(String(this.couponSourceArray[0].codeValue)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -156,12 +72,50 @@ export class CouponUseComponent implements OnInit { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getCouponSalesPrice() { |
|
|
|
getCouponSalesPrice() { |
|
|
|
this.salesPriceArray = []; |
|
|
|
this.salesPriceArray = []; |
|
|
|
this.couponService.getCouponSalesPrice({couponSource : this.searchForm.controls['couponSource'].value}, data => { |
|
|
|
this.discountService.getDiscountPrice(this.searchForm.controls['usingRange'].value, data => { |
|
|
|
for (let obj of data['return_data']) { |
|
|
|
for (let obj of data['return_data']) { |
|
|
|
this.salesPriceArray.push({ codeValue: obj, codeName: obj}); |
|
|
|
this.salesPriceArray.push({ codeValue: obj, codeName: obj}); |
|
|
|
} |
|
|
|
} |
|
|
|
this.searchForm.controls['salesPrice'].setValue('null'); |
|
|
|
this.searchForm.controls['price'].setValue('null'); |
|
|
|
|
|
|
|
this.getData(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pageIndexChange(pageNum: number) { |
|
|
|
|
|
|
|
this.pageNum = pageNum; |
|
|
|
|
|
|
|
this.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openModifyModal(batchIdentifier: string) { |
|
|
|
|
|
|
|
this.discountService.getBatchDetail(batchIdentifier, data => { |
|
|
|
|
|
|
|
this.batchObject = data['return_data']; |
|
|
|
|
|
|
|
this.modifyForm.controls['batchIdentifier'].setValue(this.batchObject['batchIdentifier']); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.modifyModal = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submitModify() { |
|
|
|
|
|
|
|
this.discountService.replenish(this.modifyForm.value, data => { |
|
|
|
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.modal.success({ |
|
|
|
|
|
|
|
nzTitle: '提示', |
|
|
|
|
|
|
|
nzContent: '提交成功', |
|
|
|
|
|
|
|
}); |
|
|
|
this.getData(); |
|
|
|
this.getData(); |
|
|
|
|
|
|
|
this.closeModifyModal(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.modal.error({ |
|
|
|
|
|
|
|
nzTitle: '提示', |
|
|
|
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeModifyModal() { |
|
|
|
|
|
|
|
this.modifyForm.reset(); |
|
|
|
|
|
|
|
this.modifyModal = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|