提交代码

dev
胡锐 1 year ago
parent e4928d5fc2
commit 2297e936ec
  1. 120
      src/app/admin/statistics/coupon-use/coupon-use.component.html
  2. 6
      src/app/admin/statistics/coupon-use/coupon-use.component.scss
  3. 210
      src/app/admin/statistics/coupon-use/coupon-use.component.ts
  4. 2
      src/app/app-routing.module.ts
  5. 15
      src/app/services/coupon.service.ts
  6. 36
      src/app/services/discount.service.ts

@ -3,23 +3,23 @@
<!-- end 面包屑 --> <!-- end 面包屑 -->
<div class="inner-content"> <div class="inner-content">
<form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)"> <form nz-form [formGroup]="searchForm" (ngSubmit)="getData()">
<div nz-row> <div nz-row>
<div nz-col nzSpan="8"> <div nz-col nzSpan="8">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">业务类型</nz-form-label> <nz-form-label [nzSpan]="8">业务类型</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select ngModel="4" formControlName="couponSource" (ngModelChange)="getCouponSalesPrice()"> <nz-select ngModel="10" formControlName="usingRange" (ngModelChange)="getCouponSalesPrice()">
<nz-option *ngFor="let item of couponSourceArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> <nz-option *ngFor="let item of usingRangeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
<div nz-col nzSpan="8"> <div nz-col nzSpan="8">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">卡券销售面值</nz-form-label> <nz-form-label [nzSpan]="8">面值</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select formControlName="salesPrice"> <nz-select formControlName="price">
<nz-option nzValue="null" nzLabel="全部" ></nz-option> <nz-option nzValue="null" nzLabel="全部" ></nz-option>
<nz-option *ngFor="let item of salesPriceArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}" ></nz-option> <nz-option *ngFor="let item of salesPriceArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}" ></nz-option>
</nz-select> </nz-select>
@ -27,38 +27,100 @@
</nz-form-item> </nz-form-item>
</div> </div>
<div nz-col nzSpan="8"> <div nz-col nzSpan="8">
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>筛选</button>
</div>
</div>
</form>
</div>
<div class="inner-content">
<article nz-typography>
<p>
<span nz-typography nzType="warning"><strong>汇总:</strong></span>
总数量 <span nz-typography nzType="warning"><strong>{{countObject.batchNum}}</strong></span>
使用数量 <span nz-typography nzType="warning"><strong>{{countObject.useNum}}</strong></span>
使用金额 <span nz-typography nzType="warning"><strong>{{countObject.usePrice}}</strong></span> 元、
使用率 <span nz-typography nzType="warning"><strong>{{countObject.useRate}}</strong></span> %
</p>
</article>
<nz-table #basicTable
nzBordered
[nzFrontPagination]="false"
[nzData]="dataObject.list"
[nzTotal]="dataObject.total"
[nzLoading]="tableLoading"
(nzPageIndexChange)="pageIndexChange($event)"
[nzScroll]="{ x: '900px'}"
>
<thead>
<tr>
<th nzWidth="60px">批次</th>
<th nzWidth="120px">名称</th>
<th nzWidth="110px">编码区间</th>
<th nzWidth="100px">制作时间</th>
<th nzWidth="80px">过期时间</th>
<th nzWidth="60px">批次数量</th>
<th nzWidth="60px">使用数量</th>
<th nzWidth="50px">使用率</th>
<th nzWidth="70px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{ data.batchIdentifier }}</td>
<td>{{ data.discountName }}</td>
<td>{{ data.codeStart + ' - ' + data.codeEnd}}</td>
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td><span *ngIf="data.mailTime != null">{{ data.mailTime | date: 'yyyy-MM-dd'}}</span></td>
<td>{{ data.batchNum }}</td>
<td>{{ data.useNum }}</td>
<td>{{ data.useRate + '%' }}</td>
<td>
<a nz-dropdown [nzDropdownMenu]="menu">
操作列表
<i nz-icon nzType="down"></i>
</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item (click)="openModifyModal(data.batchIdentifier)">批次调整</li>
</ul>
</nz-dropdown-menu>
</td>
</tr>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="modifyModal" nzTitle="批次调整" [nzBodyStyle]="{ padding: '2px'}" (nzOnCancel)="closeModifyModal()" [nzFooter]="null">
<nz-tabset [nzSize]="'small'" [nzTabBarStyle]="{ padding : '0px 0px 10px 10px' }" >
<nz-tab nzTitle="批次数量">
<form nz-form [formGroup]="modifyForm" (ngSubmit)="submitModify()">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">状态</nz-form-label> <nz-form-label [nzSpan]="6" nzRequired>数量调整</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select formControlName="status"> <nz-input-number formControlName="batchNum"></nz-input-number>
<nz-option nzValue="null" nzLabel="全部"></nz-option>
<nz-option *ngFor="let item of statusArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div>
<div nz-col nzSpan="8">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">销售起止时间</nz-form-label> <nz-form-control style="text-align: center;" >
<nz-form-control [nzSpan]="14"> <button nz-button nzType="primary" style="width:150px;">提交</button>
<nz-date-picker formControlName="salesTimeS" style="width: 100%;"></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </form>
<div nz-col nzSpan="8"> </nz-tab>
<nz-tab nzTitle="过期时间">
<form nz-form [formGroup]="modifyForm" (ngSubmit)="submitModify()">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="8">销售结束时间</nz-form-label> <nz-form-label [nzSpan]="6" nzRequired>过期时间</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-date-picker formControlName="salesTimeE" style="width: 100%;"></nz-date-picker> <nz-date-picker formControlName="mailTime"></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> <nz-form-item>
<div nz-col nzSpan="8"> <nz-form-control style="text-align: center;" >
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>筛选</button> <button nz-button nzType="primary" style="width:150px;" sh>提交</button>
</div> </nz-form-control>
</div> </nz-form-item>
</form> </form>
</div> </nz-tab>
<div class="inner-content"> </nz-tabset>
<div echarts [options]="dataObject"></div> </nz-modal>
</div>

@ -0,0 +1,6 @@
nz-date-picker {
width: 100%;
}
nz-input-number {
width: 100%;
}

@ -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;
}
} }

@ -1,5 +1,5 @@
import {NgModule} from '@angular/core'; 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 {NavigationComponent} from './admin/navigation/navigation.component';
import {InitGuardService} from './services/init-guard.service'; import {InitGuardService} from './services/init-guard.service';

@ -187,8 +187,19 @@ export class CouponService {
* @param id id * @param id id
* @param callBack * @param callBack
*/ */
public useCouponStatistics(params: object, callBack) { public getBatchUseCount(params: object, callBack) {
this.http.get(environment.baseUrl + 'couponStatistics/useCouponStatistics?' + this.common.getWhereCondition(params)).subscribe(data => { 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); callBack(data);
}); });
} }

@ -140,4 +140,40 @@ export class DiscountService {
callBack(data); 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);
});
}
} }

Loading…
Cancel
Save