pull/1/head
袁野 4 years ago
parent 64d89bcde7
commit 0a2b69f11a
  1. 7
      src/app/admin/coupon/coupon-edit/coupon-edit.component.html
  2. 31
      src/app/admin/coupon/coupon-edit/coupon-edit.component.ts
  3. 4
      src/app/admin/coupon/coupon-list/coupon-list.component.html
  4. 11
      src/app/admin/coupon/coupon-list/coupon-list.component.ts
  5. 2
      src/app/admin/coupon/coupon-routing.module.ts
  6. 3
      src/app/admin/coupon/coupon.module.ts
  7. 168
      src/app/admin/coupon/sales-code-list/sales-code-list.component.html
  8. 0
      src/app/admin/coupon/sales-code-list/sales-code-list.component.scss
  9. 153
      src/app/admin/coupon/sales-code-list/sales-code-list.component.ts
  10. 2
      src/app/app-common.module.ts
  11. 21
      src/app/pipes/coupon-code.pipe.ts
  12. 1
      src/app/pipes/index.ts
  13. 24
      src/app/services/coupon.service.ts
  14. 2
      src/app/services/icon.service.ts

@ -90,8 +90,7 @@
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>截止日期</nz-form-label>
<nz-form-control nzErrorTip="请选择销售截止日期!">
<nz-date-picker
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
nzFormat="yyyy-MM-dd"
[formControlName]="'salesEndTime'"
></nz-date-picker>
</nz-form-control>
@ -118,10 +117,10 @@
<div nz-col [nzSpan]="16" *ngIf="validateForm.value.isPresent">
<nz-form-item>
<nz-form-label [nzFor]="'handselCouponList'" nzRequired>选择卡券</nz-form-label>
<nz-form-label [nzFor]="'handselCouponId'" nzRequired>选择卡券</nz-form-label>
<nz-form-control nzErrorTip="请选择卡券!">
<nz-select
[formControlName]="'handselCouponList'"
[formControlName]="'handselCouponId'"
(nzScrollToBottom)="loadMoreCoupon()"
(nzOnSearch)="searchCoupon($event)"
nzShowSearch

@ -6,6 +6,7 @@ import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {CouponService} from '../../../services/coupon.service';
import {IconService} from '../../../services/icon.service';
import {CommonsService} from '../../../services/commons.service';
function getBase64(file: File): Promise<string | ArrayBuffer | null> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -37,6 +38,7 @@ export class CouponEditComponent implements OnInit {
isLoading = false;
pageNum = 1;
pageSize = 10;
pageSizeCoupon = 10;
merchantName: string;
optionListCoupon: string[] = [];
isLoadingCoupon = false;
@ -47,6 +49,7 @@ export class CouponEditComponent implements OnInit {
private fb: FormBuilder,
private merchant: MerchantService,
private coupon: CouponService,
private common: CommonsService,
private message: NzMessageService, // 信息提示
private activatedRoute: ActivatedRoute,
) {
@ -59,7 +62,9 @@ export class CouponEditComponent implements OnInit {
this.id = queryParams.couponId;
this.getDetails(queryParams.couponId);
this.pageSize = 10000;
this.pageSizeCoupon = 10000;
this.loadMore();
this.loadMoreCoupon();
}
});
this.validateForm = this.fb.group({
@ -74,7 +79,7 @@ export class CouponEditComponent implements OnInit {
salesCount: [null, [Validators.required]],
merchantId: [null, [Validators.required]],
isPresent: [false, [Validators.required]],
handselCouponList: [null],
handselCouponId: [null],
status: [null],
couponKey: [null],
createTime: [null],
@ -126,7 +131,7 @@ export class CouponEditComponent implements OnInit {
this.isLoadingCoupon = true;
const paramsObject = {
pageNum: this.pageNumCoupon,
pageSize: 10,
pageSize: this.pageSizeCoupon,
merchantName: this.merchantName,
};
this.getCouponList(paramsObject);
@ -140,7 +145,7 @@ export class CouponEditComponent implements OnInit {
this.pageNumCoupon = 1;
const paramsObject = {
pageNum: this.pageNumCoupon,
pageSize: 10,
pageSize: this.pageSizeCoupon,
merchantName: e,
};
this.getCouponList(paramsObject);
@ -210,14 +215,18 @@ export class CouponEditComponent implements OnInit {
this.validateForm.value.couponCarouselImg = couponCarouselImg.join(',');
this.validateForm.value.couponDesc = this.content;
if (this.editFlag) {
this.validateForm.value.id = this.id;
this.coupon.updateCoupon(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功');
} else {
this.message.create('error', '修改失败');
}
this.common.showConfirm('是否确定修改,确定将下架' , dataR => {
if (dataR) {
this.validateForm.value.id = this.id;
this.coupon.updateCoupon(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功,卡券已下架!');
} else {
this.message.create('error', '修改失败');
}
});
}
});
} else {

@ -107,7 +107,7 @@
<th nzWidth="100px">卡券状态</th>
<th nzWidth="120px">销售截止时间</th>
<th nzWidth="120px">创建时间</th>
<th nzWidth="100px" nzRight="0px">操作</th>
<th nzWidth="120px" nzRight="0px">操作</th>
</tr>
</thead>
<tbody>
@ -128,6 +128,8 @@
<nz-divider *ngIf="data.status === 2" nzType="vertical"></nz-divider>
<a *ngIf="data.status === 2" (click)="disableMerchant(data.id)"> <i nz-icon [nzIconfont]="'icon-xiajia'" nz-tooltip="下架"></i></a>
<nz-divider *ngIf="data.status !== 101" nzType="vertical"></nz-divider>
<a (click)="getList(data.id , data.couponName , data.couponType)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="销售码列表"></i></a>
<nz-divider *ngIf="data.status !== 101" nzType="vertical"></nz-divider>
<a *ngIf="data.status !== 101" (click)="getDelete(data.id)"><i nz-icon nzType="delete" nzTheme="outline" nz-tooltip="删除"></i></a>
</td>
</tbody>

@ -193,4 +193,15 @@ export class CouponListComponent implements OnInit {
});
}
// 查看门店列表
public getList(id: number , couponName: string , couponType: number): void {
this.router.navigate(['/admin/coupon/salesCode-list'], {
queryParams: {
couponId: id,
name: couponName,
type: couponType,
}
}).then(r => console.log(r));
}
}

@ -3,12 +3,14 @@ import { Routes, RouterModule } from '@angular/router';
import {CouponListComponent} from './coupon-list/coupon-list.component';
import {CouponEditComponent} from './coupon-edit/coupon-edit.component';
import {CouponDetailComponent} from './coupon-detail/coupon-detail.component';
import {SalesCodeListComponent} from './sales-code-list/sales-code-list.component';
const routes: Routes = [
{ path: 'coupon-list', component: CouponListComponent },
{ path: 'coupon-edit', component: CouponEditComponent },
{ path: 'coupon-detail', component: CouponDetailComponent },
{ path: 'salesCode-list', component: SalesCodeListComponent },
];
@NgModule({

@ -11,9 +11,10 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module';
import {RichtextModule} from '../../common/richtext/richtext.module';
import {AppCommonModule} from '../../app-common.module';
import { SalesCodeListComponent } from './sales-code-list/sales-code-list.component';
@NgModule({
declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent],
declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent, SalesCodeListComponent],
imports: [
CommonModule,
CouponRoutingModule,

@ -0,0 +1,168 @@
<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->
<div class="inner-content">
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
<div nz-row>
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">消费码KEY</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="salesCode"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">消费码状态</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-select formControlName="status">
<nz-option nzValue="1" nzLabel="待销售"></nz-option>
<nz-option nzValue="2" nzLabel="待使用"></nz-option>
<nz-option nzValue="3" nzLabel="已使用"></nz-option>
<nz-option nzValue="4" nzLabel="已过期"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row>
<div nz-col nzSpan="24" class="search-button">
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button>
<button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload"
nzTheme="outline"></i>重置
</button>
</div>
</div>
</form>
</div>
<div class="inner-content">
<span>共计 {{total}} 条数据</span>
<span *ngIf="id != null" style="margin-left: 30px;;">
卡券名称:
<span style="font-weight: bold; font-size: 20px">{{name}}({{type === 1 ? '内部卷' : '外部卷'}})</span>
</span>
<div class="operating-button">
<button *ngIf="type === 1" nz-button nzType="primary" class="right-btn" (click)="showModal()"><i nz-icon
nzType="import"
nzTheme="outline"></i>生成消费码
</button>
<nz-upload
*ngIf="type === 2"
[nzAccept]="'.xls,.xlsx'"
nzAction="{{WEB_SERVE_URL}}coupon/importStock?couponId={{id}}"
[nzHeaders]="{ authorization: 'authorization-text' }"
(nzChange)="handleChange($event)"
[nzShowUploadList]="false"
>
<button nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>导入消费码</button>
</nz-upload>
</div>
<nz-table
class="table"
#ajaxTable
nzShowSizeChanger
[nzFrontPagination]="false"
[nzData]="requestData"
[nzLoading]="loading"
[nzTotal]="total"
[(nzPageIndex)]="pageNum"
[(nzPageSize)]="pageSize"
[nzScroll]="{ x: '1200px' }"
(nzPageIndexChange)="getRequest(false , searchForm.value)"
(nzPageSizeChange)="getRequest(false , searchForm.value)">
<thead nzSingleSort>
<tr>
<th nzWidth="50px">编号</th>
<th nzWidth="180px">消费码</th>
<th nzWidth="70px">订单ID</th>
<th nzWidth="120px">领取时间</th>
<th nzWidth="120px">消费时间</th>
<th nzWidth="120px">销售截止时间</th>
<th nzWidth="120px">使用截止时间</th>
<th nzWidth="120px">创建时间</th>
<th nzWidth="80px" nzRight="0px">状态</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of ajaxTable.data; let i = index">
<td>{{i + 1}}</td>
<td>{{data.salesCode}}</td>
<td>{{data.orderId == null ? '暂无' : data.orderId}}</td>
<td>{{data.receiveTime == null ? '未领取' : data.receiveTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.consumeTime == null ? '未消费' : data.consumeTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.useEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight="0px">{{data.status | couponCode}}</td>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" nzTitle="生成消费码" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<ng-container>
<form nz-form [formGroup]="codeForm">
<div nz-row>
<div nz-col nzSpan="24">
<nz-form-item>
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>销售截止日期</nz-form-label>
<nz-form-control nzErrorTip="请选择销售截止日期!">
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'salesEndTime'"
></nz-date-picker>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="24">
<nz-form-item>
<nz-form-label [nzFor]="'useEndTime'" nzRequired>使用截止日期</nz-form-label>
<nz-form-control nzErrorTip="请选择使用截止日期!">
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'useEndTime'"
></nz-date-picker>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="12">
<nz-form-item>
<nz-form-label [nzFor]="'generateNum'" nzRequired>消费码数量</nz-form-label>
<nz-form-control nzErrorTip="请输入消费码!">
<input nz-input placeholder="请输入消费码 ..." [formControlName]="'generateNum'" />
</nz-form-control>
</nz-form-item>
</div>
</div>
</form>
</ng-container>
</nz-modal>
<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="handleCancelError()" nzWidth="900px" [nzFooter]="null">
<nz-table #errorStudentTable [nzData]="importErrorStudentArray">
<thead>
<tr>
<th nzWidth="80px">序号</th>
<th nzWidth="150px">销售码</th>
<th nzWidth="150px">销售截止时间</th>
<th nzWidth="150px">使用截止时间</th>
<th nzWidth="300px">原因</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of errorStudentTable.data;let i = index">
<td>{{ i + 1}}</td>
<td>{{data.salesCode}}</td>
<td>{{data.salesEndTime}}</td>
<td>{{data.useEndTime}}</td>
<td>{{data.errorMessage}}</td>
</tr>
</tbody>
</nz-table>
</nz-modal>

@ -0,0 +1,153 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd';
import {CouponService} from '../../../services/coupon.service';
import {environment} from '../../../../environments/environment';
@Component({
selector: 'app-sales-code-list',
templateUrl: './sales-code-list.component.html',
styleUrls: ['./sales-code-list.component.scss']
})
export class SalesCodeListComponent implements OnInit {
searchForm: FormGroup; // 搜索框
codeForm: FormGroup; // 搜索框
requestData = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
id = null;
name: string;
type: number;
isVisible = false;
WEB_SERVE_URL = environment.baseUrl;
importErrorStudentArray = [];
errorStudentVisible = false;
constructor(
private form: FormBuilder,
private activatedRoute: ActivatedRoute,
private message: NzMessageService,
private modal: NzModalService,
private coupon: CouponService
) {
}
ngOnInit(): void {
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.couponId != null) {
this.id = queryParams.couponId;
this.name = queryParams.name;
this.type = Number(queryParams.type);
this.searchForm = this.form.group({
status: [null],
salesCode: [null],
});
this.getRequest(true, this.searchForm.value);
}
});
this.codeForm = this.form.group({
salesEndTime: [null, [Validators.required]],
useEndTime: [null, [Validators.required]],
generateNum: [null, [Validators.required]],
});
}
// 查询列表
public getRequest(reset: boolean = false, whereObject: object) {
this.loading = false;
if (reset) {
this.pageNum = 1;
}
whereObject['couponId'] = this.id;
whereObject['pageNum'] = this.pageNum;
whereObject['pageSize'] = this.pageSize;
this.coupon.getCouponCodeList(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();
}
showModal(): void {
this.isVisible = true;
}
handleOk(): void {
// tslint:disable-next-line:forin
for (const i in this.codeForm.controls) {
this.codeForm.controls[i].markAsDirty();
this.codeForm.controls[i].updateValueAndValidity();
if (this.codeForm.controls[i].errors != null) {
this.message.error('必填项不能为空');
return;
}
}
this.codeForm.value['couponId'] = this.id;
this.coupon.writeStock(this.codeForm.value , data => {
if (data['return_code'] === '000000') {
this.getRequest(true, this.searchForm.value);
this.message.success('生成成功');
} else {
this.message.create('error', '生成失败');
}
});
this.isVisible = false;
}
handleCancel(): void {
console.log('Button cancel clicked!');
this.isVisible = false;
}
handleCancelError(): void {
this.errorStudentVisible = false;
}
handleChange(info: NzUploadChangeParam): void {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
if (info.file.response.return_code === '000000') {
this.loading = false;
if (info.file.response.return_data == null || info.file.response.return_data.length === 0) {
this.message.success('导入成功');
this.getRequest(true, this.searchForm.value);
} else {
this.modal.warning({
nzTitle: '提示',
nzOkText: '查看失败数据',
nzContent: '只有部分数据导入成功',
nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data)
});
}
} else {
this.loading = false;
this.message.error(info.file.response.return_msg);
}
} else if (info.file.status === 'error') {
this.message.error('上传错误');
}
}
// 打开模态框
showErrorStudentModal(data: []) {
this.getRequest(true, this.searchForm.value);
this.importErrorStudentArray = data['errorData'];
this.errorStudentVisible = true;
}
}

@ -12,6 +12,7 @@ import {NgxNeditorModule} from '@notadd/ngx-neditor';
import {TimesPipe , TextareaPipe} from './pipes';
import { SystemPipe } from './pipes/system.pipe';
import { CouponStatusPipe } from './pipes/coupon-status.pipe';
import { CouponCodePipe } from './pipes/coupon-code.pipe';
@ -21,6 +22,7 @@ const PIPES = [
TextareaPipe,
SystemPipe,
CouponStatusPipe,
CouponCodePipe,
];

@ -0,0 +1,21 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'couponCode'
})
export class CouponCodePipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 1:
return '待销售';
case 2:
return '待使用';
case 3:
return '已使用';
case 4:
return '已过期';
}
}
}

@ -2,3 +2,4 @@ export * from './commons/times.pipe';
export * from './commons/textarea.pipe';
export * from './system.pipe';
export * from './coupon-status.pipe';
export * from './coupon-code.pipe';

@ -24,6 +24,18 @@ export class CouponService {
});
}
/**
*
*
* @param paramsObject
* @param callBack
*/
public getCouponCodeList(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'couponCode/getCouponCodeList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
/**
*
*
@ -87,6 +99,18 @@ export class CouponService {
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public writeStock(params: object, callBack) {
this.http.post(environment.baseUrl + 'coupon/writeStock', params).subscribe(data => {
callBack(data);
});
}
}

@ -12,7 +12,7 @@ export class IconService {
constructor(private iconService: NzIconService) {
this.iconService.fetchFromIconfont({
scriptUrl: 'https://at.alicdn.com/t/font_2424521_elodxcgd21v.js'
scriptUrl: 'https://at.alicdn.com/t/font_2424521_2fwfzlplp0d.js'
});
}
}

Loading…
Cancel
Save