From 2297e936ec2fa7c873c7ffa9ad1db7e84c0fc673 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 22 Aug 2023 10:52:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon-use/coupon-use.component.html | 120 +++++++--- .../coupon-use/coupon-use.component.scss | 6 + .../coupon-use/coupon-use.component.ts | 210 +++++++----------- src/app/app-routing.module.ts | 2 +- src/app/services/coupon.service.ts | 15 +- src/app/services/discount.service.ts | 36 +++ 6 files changed, 229 insertions(+), 160 deletions(-) diff --git a/src/app/admin/statistics/coupon-use/coupon-use.component.html b/src/app/admin/statistics/coupon-use/coupon-use.component.html index 9e5761d..3f652a8 100644 --- a/src/app/admin/statistics/coupon-use/coupon-use.component.html +++ b/src/app/admin/statistics/coupon-use/coupon-use.component.html @@ -3,23 +3,23 @@
-
+
业务类型 - - + +
- 卡券销售面值 + 面值 - + @@ -27,38 +27,100 @@
+ +
+
+
+
+
+
+

+ 汇总: + 总数量 {{countObject.batchNum}}、 + 使用数量 {{countObject.useNum}}、 + 使用金额 {{countObject.usePrice}} 元、 + 使用率 {{countObject.useRate}} % +

+
+ + + + 批次 + 名称 + 编码区间 + 制作时间 + 过期时间 + 批次数量 + 使用数量 + 使用率 + 操作 + + + + + {{ data.batchIdentifier }} + {{ data.discountName }} + {{ data.codeStart + ' - ' + data.codeEnd}} + {{ data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{ data.mailTime | date: 'yyyy-MM-dd'}} + {{ data.batchNum }} + {{ data.useNum }} + {{ data.useRate + '%' }} + + + 操作列表 + + + +
    +
  • 批次调整
  • +
+
+ + + +
+
+ + + + +
- 状态 + 数量调整 - - - - + - -
- 销售起止时间 - - + + -
-
+ + + +
- 销售结束时间 + 过期时间 - + -
-
- -
- - - -
-
-
+ + + + + + +
+
+
diff --git a/src/app/admin/statistics/coupon-use/coupon-use.component.scss b/src/app/admin/statistics/coupon-use/coupon-use.component.scss index e69de29..9bc1176 100644 --- a/src/app/admin/statistics/coupon-use/coupon-use.component.scss +++ b/src/app/admin/statistics/coupon-use/coupon-use.component.scss @@ -0,0 +1,6 @@ +nz-date-picker { + width: 100%; +} +nz-input-number { + width: 100%; +} diff --git a/src/app/admin/statistics/coupon-use/coupon-use.component.ts b/src/app/admin/statistics/coupon-use/coupon-use.component.ts index 7684dd6..98935a5 100644 --- a/src/app/admin/statistics/coupon-use/coupon-use.component.ts +++ b/src/app/admin/statistics/coupon-use/coupon-use.component.ts @@ -1,6 +1,8 @@ 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 {DiscountService} from '../../../services/discount.service'; +import {NzModalService} from 'ng-zorro-antd'; @Component({ selector: 'app-coupon-use', @@ -8,147 +10,61 @@ import {CouponService} from '../../../services/coupon.service'; styleUrls: ['./coupon-use.component.scss'] }) export class CouponUseComponent implements OnInit { - - dataObject: {}; - couponSourceArray = [ - { codeValue: 4, codeName: '贵州中石化'}, - { codeValue: 5, codeName: '重庆中石油'}, - ] - statusArray = [ - { codeValue: 20, codeName: '未使用'}, - { codeValue: 40, codeName: '已使用'}, + tableLoading = true; + countObject: any = { + batchNum: 0, + useNum: 0, + usePrice: 0, + useRate: 0, + }; + dataObject: any = {}; + usingRangeArray = [ + { codeValue: 10, codeName: '贵州中石化'}, + { codeValue: 8, codeName: '重庆中石油'}, ] salesPriceArray = []; searchForm: FormGroup; whereObject: any = {}; + pageNum = 1; + pageSize = 10; + + modifyModal = false; + batchObject = {}; + modifyForm: FormGroup; constructor(private form: FormBuilder, - private couponService: CouponService) { } + private modal: NzModalService, + private couponService: CouponService, + private discountService: DiscountService, + ) { } 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({ - couponSource: [String(this.couponSourceArray[0].codeValue)], - salesPrice: ['null'], - status: ['null'], - salesTimeS: [salesTimeS.getTime()], - salesTimeE: [salesTimeE.getTime()], + usingRange: [String(this.usingRangeArray[0].codeValue)], + price: ['null'], + }); + this.modifyForm = this.form.group({ + batchIdentifier: [null, [Validators.required]], + mailTime: [null], + batchNum: [null], }); - this.getCouponSalesPrice(); } getData() { + this.tableLoading = true; const param = this.searchForm.value; - if (this.searchForm.controls['salesPrice'].value == 'null') { - param['salesPrice'] = null; - } - if (this.searchForm.controls['status'].value == 'null') { - param['status'] = null; + if (this.searchForm.controls['price'].value == 'null') { + param['price'] = null; } - this.couponService.useCouponStatistics(param, response => { - let returnData = response['return_data']; - var dataArray = []; - for (let obj of returnData['salesPriceList']) { - dataArray.push({ - value: obj['count'], - name: obj['salesPrice'] + '【' + (obj['status']===20?'未使用':'已使用') + '】', - }); - } - 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['pageNum'] = this.pageNum; + param['pageSize'] = this.pageSize; + this.couponService.getCount(param,response => { + this.countObject = response['return_data']; + }); + this.couponService.getBatchUseCount(param, response => { + this.dataObject = response['return_data']; + this.tableLoading = false; }); - - } - - - /** - * 搜索 - * @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() { 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']) { 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.closeModifyModal(); + } else { + this.modal.error({ + nzTitle: '提示', + nzContent: data['return_msg'], + }); + } }); } + + closeModifyModal() { + this.modifyForm.reset(); + this.modifyModal = false; + } + } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 8ac3f1f..d9b1cde 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,5 +1,5 @@ import {NgModule} from '@angular/core'; -import {Routes, RouterModule, RouteReuseStrategy} from '@angular/router'; +import {Routes, RouterModule} from '@angular/router'; import {NavigationComponent} from './admin/navigation/navigation.component'; import {InitGuardService} from './services/init-guard.service'; diff --git a/src/app/services/coupon.service.ts b/src/app/services/coupon.service.ts index ba2bd36..5d5c177 100644 --- a/src/app/services/coupon.service.ts +++ b/src/app/services/coupon.service.ts @@ -187,8 +187,19 @@ export class CouponService { * @param id 用户id * @param callBack 返回参数 */ - public useCouponStatistics(params: object, callBack) { - this.http.get(environment.baseUrl + 'couponStatistics/useCouponStatistics?' + this.common.getWhereCondition(params)).subscribe(data => { + public getBatchUseCount(params: object, callBack) { + this.http.get(environment.baseUrl + 'discountAgentRel/getBatchUseCount?' + this.common.getWhereCondition(params)).subscribe(data => { + callBack(data); + }); + } + /** + * 使用卡券统计 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public getCount(params: object, callBack) { + this.http.get(environment.baseUrl + 'discountAgentRel/getCount?' + this.common.getWhereCondition(params)).subscribe(data => { callBack(data); }); } diff --git a/src/app/services/discount.service.ts b/src/app/services/discount.service.ts index dd5e92b..b6eed05 100644 --- a/src/app/services/discount.service.ts +++ b/src/app/services/discount.service.ts @@ -140,4 +140,40 @@ export class DiscountService { callBack(data); }); } + + /** + * 批次补充 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public replenish(param: object, callBack) { + this.http.post(environment.baseUrl + 'discountAgentBatch/replenish', param).subscribe(data => { + callBack(data); + }); + } + + /** + * 查询批次详情 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public getBatchDetail(batchIdentifier: string, callBack) { + this.http.get(environment.baseUrl + 'discountAgentBatch/getBatchDetail?batchIdentifier=' + batchIdentifier ).subscribe(data => { + callBack(data); + }); + } + + /** + * 查询批次详情 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public getDiscountPrice(usingRange: number, callBack) { + this.http.get(environment.baseUrl + 'discount/getDiscountPrice?usingRange=' + usingRange ).subscribe(data => { + callBack(data); + }); + } }