pull/1/head
袁野 4 years ago
parent 5138fd8416
commit 352d7839f2
  1. 87
      src/app/admin/agent/agent-edit/agent-edit.component.html
  2. 6
      src/app/admin/agent/agent-edit/agent-edit.component.scss
  3. 122
      src/app/admin/agent/agent-edit/agent-edit.component.ts
  4. 172
      src/app/admin/agent/agent-list/agent-list.component.html
  5. 4
      src/app/admin/agent/agent-list/agent-list.component.scss
  6. 191
      src/app/admin/agent/agent-list/agent-list.component.ts
  7. 16
      src/app/admin/agent/agent-routing.module.ts
  8. 29
      src/app/admin/agent/agent.module.ts
  9. 1
      src/app/admin/coupon/coupon-list/coupon-list.component.ts
  10. 1
      src/app/admin/discount/discount-coupon/discount-coupon.component.html
  11. 0
      src/app/admin/discount/discount-coupon/discount-coupon.component.scss
  12. 25
      src/app/admin/discount/discount-coupon/discount-coupon.component.spec.ts
  13. 15
      src/app/admin/discount/discount-coupon/discount-coupon.component.ts
  14. 22
      src/app/admin/discount/discount-detail/discount-detail.component.html
  15. 0
      src/app/admin/discount/discount-detail/discount-detail.component.scss
  16. 25
      src/app/admin/discount/discount-detail/discount-detail.component.spec.ts
  17. 54
      src/app/admin/discount/discount-detail/discount-detail.component.ts
  18. 108
      src/app/admin/discount/discount-edit/discount-edit.component.html
  19. 6
      src/app/admin/discount/discount-edit/discount-edit.component.scss
  20. 161
      src/app/admin/discount/discount-edit/discount-edit.component.ts
  21. 252
      src/app/admin/discount/discount-list/discount-list.component.html
  22. 4
      src/app/admin/discount/discount-list/discount-list.component.scss
  23. 251
      src/app/admin/discount/discount-list/discount-list.component.ts
  24. 21
      src/app/admin/discount/discount-routing.module.ts
  25. 31
      src/app/admin/discount/discount.module.ts
  26. 2
      src/app/admin/merchant/merchant-edit/merchant-edit.component.ts
  27. 20
      src/app/app-common.module.ts
  28. 10
      src/app/app-routing.module.ts
  29. 19
      src/app/pipes/discount-status.pipe.ts
  30. 19
      src/app/pipes/discount-type.pipe.ts
  31. 2
      src/app/pipes/index.ts
  32. 106
      src/app/services/agent.service.ts
  33. 119
      src/app/services/discount.service.ts
  34. 2
      src/app/services/icon.service.ts

@ -0,0 +1,87 @@
<!-- start 面包屑 -->
<nz-breadcrumb>
<nz-breadcrumb-item>
系统管理
</nz-breadcrumb-item>
<nz-breadcrumb-item>
增加公司
</nz-breadcrumb-item>
</nz-breadcrumb>
<!-- end 面包屑 -->
<div class="inner-content">
<div nz-row>
<div nz-col nzSpan="2"></div>
<div nz-col nzSpan="20">
<form nz-form [formGroup]="validateForm" >
<div nz-row [nzGutter]="24">
<nz-divider nzText="账号信息"></nz-divider>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'loginName'" nzRequired>用户名</nz-form-label>
<nz-form-control nzErrorTip="请输入用户名!">
<input nz-input placeholder="请输入用户名..." [formControlName]="'loginName'" id="'loginName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label>
<nz-form-control nzErrorTip="请输入登录密码!">
<nz-input-group [nzSuffix]="suffixTemplate">
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" />
</nz-input-group>
<ng-template #suffixTemplate>
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i>
</ng-template>
</nz-form-control>
</nz-form-item>
</div>
<nz-divider nzText="代理商信息"></nz-divider>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'agentName'" nzRequired>代理商名称</nz-form-label>
<nz-form-control nzErrorTip="请输入代理商名称!">
<input nz-input placeholder="请输入代理商名称..." [formControlName]="'agentName'" id="'agentName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'agentAddress'" nzRequired>代理商地址</nz-form-label>
<nz-form-control nzErrorTip="请输入代理商地址!">
<input nz-input placeholder="请输入代理商地址..." [formControlName]="'agentAddress'" id="'agentAddress'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'agentUser'" nzRequired>联系人</nz-form-label>
<nz-form-control nzErrorTip="请输入联系人!">
<input nz-input placeholder="请输入联系人..." [formControlName]="'agentUser'" id="'agentUser'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'agentPhone'" nzRequired>联系方式</nz-form-label>
<nz-form-control nzErrorTip="请输入联系方式!">
<input nz-input placeholder="请输入联系方式..." [formControlName]="'agentPhone'" id="'agentPhone'" />
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row>
<div nz-col [nzSpan]="24" class="search-area">
<button nz-button (click)="resetForm()">重置</button>
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button>
</div>
</div>
</form>
</div>
<div nz-col nzSpan="2"></div>
</div>
</div>

@ -0,0 +1,6 @@
button {
margin-left: 8px;
}
:host ::ng-deep .ant-upload {
background-color: #ffffff;
}

@ -0,0 +1,122 @@
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {environment} from '../../../../environments/environment';
import {CompanyService} from '../../../services/company.service';
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {ValidatorsService} from '../../../services/validators.service';
import {AgentService} from '../../../services/agent.service';
@Component({
selector: 'app-agent-edit',
templateUrl: './agent-edit.component.html',
styleUrls: ['./agent-edit.component.scss']
})
export class AgentEditComponent implements OnInit {
validateForm!: FormGroup;
data: any;
editFlag = false;
id: number;
passwordVisible = false;
logoFile = [];
WEB_SERVE_URL = environment.baseUrl;
userId: number;
time;
constructor(
private fb: FormBuilder,
private agent: AgentService,
private message: NzMessageService, // 信息提示
private activatedRoute: ActivatedRoute,
) {
}
ngOnInit(): void {
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.agentId != null) {
this.editFlag = true;
this.id = queryParams.agentId;
this.getDetails(queryParams.agentId);
}
});
this.validateForm = this.fb.group({
loginName: [null, [Validators.required, ValidatorsService.maxLength(20)]],
password: [null, [Validators.required]],
agentName: [null, [Validators.required]],
agentUser: [null, [Validators.required, ValidatorsService.maxLength(50)]],
agentPhone: [null, [Validators.required, ValidatorsService.maxLength(50)]],
agentAddress: [null, [Validators.required, ValidatorsService.maxLength(80)]],
secUser: {},
});
}
// 返回
getBack() {
history.back();
}
// 重置
public resetForm(): void {
this.validateForm.reset();
}
// 课程保存
public getSave(): void {
// tslint:disable-next-line:forin
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
if (this.validateForm.controls[i].errors != null) {
this.message.error('必填项不能为空');
return;
}
}
this.validateForm.value['secUser']['loginName'] = this.validateForm.value.loginName;
this.validateForm.value['secUser']['password'] = this.validateForm.value.password;
if (this.logoFile.length !== 0) {
if (this.logoFile[0]['response'] != null) {
this.validateForm.value.logo = this.logoFile[0]['response']['return_data'][0];
} else {
this.validateForm.value.logo = this.logoFile[0].name;
}
}
if (this.editFlag) {
this.validateForm.value.id = this.id;
this.agent.updateAgent(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功');
} else {
this.message.create('error', '修改失败');
}
});
} else {
this.agent.insertAgent(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('添加成功');
} else {
this.message.create('error', data['return_msg']);
}
});
}
}
public getDetails(id) {
this.agent.findByAgentId(id, data => {
console.log(data);
if (data['return_code'] === '000000') {
data['return_data'].loginName = data['return_data'].secUser.loginName;
data['return_data'].password = data['return_data'].secUser.password;
this.validateForm.patchValue(data['return_data']);
} else {
this.message.create('error', data['return_msg']);
}
});
}
}

@ -0,0 +1,172 @@
<!-- 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="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">名称</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="agentName"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">电话</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="agentPhone"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">代理商状态</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-select nzShowSearch nzAllowClear formControlName="status" nzPlaceHolder="请选择代理商状态">
<nz-option nzLabel="禁用" nzValue="0"></nz-option>
<nz-option nzLabel="正常" nzValue="1"></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>
<div class="operating-button">
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/agent/agent-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button>
</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="80px">代理商名称</th>
<th nzWidth="80px">代理商地址</th>
<th nzWidth="80px">联系人</th>
<th nzWidth="70px">联系方式</th>
<th nzWidth="100px">创建时间</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.agentName}}</td>
<td>{{data.agentAddress}}</td>
<td>{{data.agentUser}}</td>
<td>{{data.agentPhone}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight="0px" class="table-td-operation">
<a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a>
<!-- <nz-divider nzType="vertical"></nz-divider>-->
<!-- <a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="公司详情"></i></a>-->
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getDiscount(data.id)"><i nz-icon nzType="api" nzTheme="outline" nz-tooltip="绑定优惠券"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getDiscountList(data.id)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="优惠券列表"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)='getForbiddenUser(data.id , data.status)'><i nz-icon nzType="{{data.status === 1 ? 'stop': 'check-circle'}}" nzTheme="outline" nz-tooltip="{{data.status === 1 ? '禁用': '启用'}}"></i></a>
</td>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" nzTitle="分配优惠券" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form nz-form [formGroup]="validateForm" class="login-form">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>优惠券</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请选择优惠券!">
<nz-select nzShowSearch nzAllowClear formControlName="discountId" nzPlaceHolder="请选择优惠券">
<nz-option *ngFor="let item of discountList" nzLabel="{{item.discountName}}" nzValue="{{item.id}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>分配优惠券数量</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="分配优惠券数量!">
<input [type]="'number'" nz-input formControlName="stockCount"/>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
<nz-modal [(nzVisible)]="isVisibleDiscount" nzWidth="1000" nzTitle="分配优惠券列表" (nzOnCancel)="handleCancelDiscount()" (nzOnOk)="handleCancelDiscount()">
<nz-table
class="table"
#ajaxTableDiscount
nzShowSizeChanger
[nzFrontPagination]="false"
[nzData]="requestDataDiscount"
[nzLoading]="loadingDiscount"
[nzTotal]="totalDiscount"
[(nzPageIndex)]="pageNumDiscount"
[(nzPageSize)]="pageSizeDiscount"
[nzScroll]="{ x: '1200px' }"
(nzPageIndexChange)="getRequestDiscount(false)"
(nzPageSizeChange)="getRequestDiscount(false)">
<thead nzSingleSort>
<tr>
<th nzWidth="80px">优惠券KEY</th>
<th nzWidth="80px">优惠券名称</th>
<th nzWidth="80px">优惠券类型</th>
<th nzWidth="70px">优惠内容</th>
<th nzWidth="70px">有效天数</th>
<th nzWidth="100px">截止日期</th>
<th nzWidth="100px">库存数量</th>
<th nzRight nzWidth="100px">二维码</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of ajaxTableDiscount.data; let i = index">
<td>{{data['highDiscount'].discountKey}}</td>
<td>{{data['highDiscount'].discountName}}</td>
<td>{{data['highDiscount'].discountType | discountType}}</td>
<td>
<span *ngIf="data['highDiscount'].discountType === 1">
满{{data['highDiscount'].discountCondition}}抵扣{{data['highDiscount'].discountPrice}}
</span>
<span *ngIf="data['highDiscount'].discountType === 2">
抵扣{{data['highDiscount'].discountPrice}}
</span>
<span *ngIf="data['highDiscount'].discountType === 3">
{{data['highDiscount'].discountPrice}}折
</span>
</td>
<td>{{data['highDiscount'].effectiveDay}}</td>
<td>{{data['highDiscount'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.stockCount}}</td>
<td nzRight>
<img class="head_img" src="{{WEB_SERVE_URL + data.qrCode}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt="">
</td>
</tbody>
</nz-table>
</nz-modal>

@ -0,0 +1,4 @@
.head_img {
height: 80px;
width: 80px;
}

@ -0,0 +1,191 @@
import {Component, OnInit} from '@angular/core';
import {environment} from '../../../../environments/environment';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {CompanyService} from '../../../services/company.service';
import {IconService} from '../../../services/icon.service';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {CommonsService} from '../../../services/commons.service';
import {AgentService} from '../../../services/agent.service';
import {DiscountService} from '../../../services/discount.service';
@Component({
selector: 'app-agent-list',
templateUrl: './agent-list.component.html',
styleUrls: ['./agent-list.component.scss']
})
export class AgentListComponent implements OnInit {
WEB_SERVE_URL = environment.imageUrl;
searchForm: FormGroup; // 搜索框
validateForm: FormGroup; // 搜索框
requestData = []; // 列表数据
discountList = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
isVisible = false;
isVisibleDiscount = false;
id: number;
requestDataDiscount = []; // 列表数据
totalDiscount: number; // 页码
pageNumDiscount = 1; // 页码
pageSizeDiscount = 10; // 条码
loadingDiscount = true;
constructor(
private form: FormBuilder,
private agent: AgentService,
private discount: DiscountService,
private iconService: IconService,
private message: NzMessageService,
private router: Router,
private common: CommonsService
) {
}
ngOnInit(): void {
this.init();
}
public init(): void {
this.searchForm = this.form.group({
agentName: [null],
agentPhone: [null],
status: [null],
});
this.validateForm = this.form.group({
discountId: [null, [Validators.required]],
stockCount: [null, [Validators.required]],
});
this.getRequest(true, this.searchForm.value);
}
// 查询列表
public getRequest(reset: boolean = false, whereObject: object) {
this.loading = false;
if (reset) {
this.pageNum = 1;
}
whereObject['pageNum'] = this.pageNum;
whereObject['pageSize'] = this.pageSize;
this.agent.getListAgent(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();
}
public getForbiddenUser(id, status: any): void {
const message = (status === 1 ? '是否禁用当前代理商' : '是否启用当前代理商');
this.common.showConfirm(message, data => {
if (data) {
this.agent.editStatus(id, dataUser => {
this.getRequest(false, this.searchForm.value);
});
}
});
}
// 修改
public getEdit(id: number): void {
this.router.navigate(['/admin/agent/agent-edit'], {
queryParams: {
agentId: id
}
}).then(r => console.log(r));
}
// 查看详情
public getDetail(id: number): void {
this.router.navigate(['/admin/company/company-detail'], {
queryParams: {
companyId: id
}
}).then(r => console.log(r));
}
// 绑定优惠券
public getDiscount(id: number): void {
this.id = id;
const whereObject = {};
whereObject['pageNum'] = 1;
whereObject['pageSize'] = 10000;
this.discount.getDiscountList(whereObject, data => {
if (data['return_code'] === '000000') {
this.discountList = data['return_data'].list;
} else {
this.message.error(data['return_msg']);
}
});
this.isVisible = true;
}
handleOk(): void {
// tslint:disable-next-line:forin
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
if (this.validateForm.controls[i].errors != null) {
this.message.error('必填项不能为空');
return;
}
}
this.validateForm.value['agentId'] = this.id;
this.agent.insertDiscountAgent(this.validateForm.value , data => {
if (data['return_code'] === '000000') {
console.log(data);
this.isVisible = false;
} else {
this.message.error(data['return_msg']);
}
});
}
handleCancel(): void {
this.isVisible = false;
}
public getDiscountList(id: number): void {
this.id = id;
this.isVisibleDiscount = true;
this.getRequestDiscount(true);
}
handleCancelDiscount() {
this.isVisibleDiscount = false;
}
// 查询列表
public getRequestDiscount(reset: boolean = false) {
const whereObject = {};
this.loadingDiscount = false;
if (reset) {
this.pageNumDiscount = 1;
}
whereObject['pageNum'] = this.pageNumDiscount;
whereObject['pageSize'] = this.pageSizeDiscount;
whereObject['agentId'] = this.id;
this.agent.getDiscountAgentList(whereObject, data => {
if (data['return_code'] === '000000') {
this.requestDataDiscount = data['return_data'].list;
this.totalDiscount = data['return_data'].total;
} else {
this.message.error(data['return_msg']);
}
});
}
}

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {AgentListComponent} from './agent-list/agent-list.component';
import {AgentEditComponent} from './agent-edit/agent-edit.component';
const routes: Routes = [
{ path: 'agent-list', component: AgentListComponent },
{ path: 'agent-edit', component: AgentEditComponent},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AgentRoutingModule { }

@ -0,0 +1,29 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AgentRoutingModule } from './agent-routing.module';
import { AgentListComponent } from './agent-list/agent-list.component';
import { AgentEditComponent } from './agent-edit/agent-edit.component';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {SeparateModule} from '../../common/separate/separate.module';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module';
import {RegionSelectorModule} from '../../common/region-selector/region-selector.module';
import {AppCommonModule} from '../../app-common.module';
@NgModule({
declarations: [AgentListComponent, AgentEditComponent],
imports: [
CommonModule,
AgentRoutingModule,
NgZorroAntdModule,
SeparateModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule,
RegionSelectorModule,
AppCommonModule
]
})
export class AgentModule { }

@ -1,6 +1,5 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms'; import {FormBuilder, FormGroup} from '@angular/forms';
import {MerchantStoreService} from '../../../services/merchant-store.service';
import {IconService} from '../../../services/icon.service'; import {IconService} from '../../../services/icon.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DiscountCouponComponent } from './discount-coupon.component';
describe('DiscountCouponComponent', () => {
let component: DiscountCouponComponent;
let fixture: ComponentFixture<DiscountCouponComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DiscountCouponComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DiscountCouponComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-discount-coupon',
templateUrl: './discount-coupon.component.html',
styleUrls: ['./discount-coupon.component.scss']
})
export class DiscountCouponComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

@ -0,0 +1,22 @@
<nz-table #rowSelectionTable nzShowSizeChanger [nzData]="listOfData" >
<thead>
<tr>
<th
[(nzChecked)]="checked"
[nzIndeterminate]="indeterminate"
(nzCheckedChange)="onAllChecked($event)"
></th>
<th>Name</th>
<th>Age</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of rowSelectionTable.data">
<td [nzChecked]="setOfCheckedId.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td>
<td>{{ data.name }}</td>
<td>{{ data.age }}</td>
<td>{{ data.address }}</td>
</tr>
</tbody>
</nz-table>

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DiscountDetailComponent } from './discount-detail.component';
describe('DiscountDetailComponent', () => {
let component: DiscountDetailComponent;
let fixture: ComponentFixture<DiscountDetailComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DiscountDetailComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DiscountDetailComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,54 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-discount-detail',
templateUrl: './discount-detail.component.html',
styleUrls: ['./discount-detail.component.scss']
})
export class DiscountDetailComponent implements OnInit {
constructor() { }
checked = false;
indeterminate = false;
listOfData = [];
setOfCheckedId = new Set<number>();
updateCheckedSet(id: number, checked: boolean): void {
if (checked) {
this.setOfCheckedId.add(id);
} else {
this.setOfCheckedId.delete(id);
}
}
onItemChecked(id: number, checked: boolean): void {
this.updateCheckedSet(id, checked);
this.refreshCheckedStatus();
}
onAllChecked(value: boolean): void {
this.listOfData.forEach(item => this.updateCheckedSet(item.id, value));
this.refreshCheckedStatus();
}
refreshCheckedStatus(): void {
this.checked = this.listOfData.every(item => this.setOfCheckedId.has(item.id));
this.indeterminate = this.listOfData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked;
}
ngOnInit(): void {
this.listOfData = new Array(200).fill(0).map((_, index) => {
return {
id: index,
name: `Edward King ${index}`,
age: 32,
address: `London, Park Lane no. ${index}`
};
});
this.refreshCheckedStatus();
}
}

@ -0,0 +1,108 @@
<!-- start 面包屑 -->
<nz-breadcrumb>
<nz-breadcrumb-item>
<a (click)="getBack()">卡券管理</a>
</nz-breadcrumb-item>
<nz-breadcrumb-item>
编辑卡券
</nz-breadcrumb-item>
</nz-breadcrumb>
<!-- end 面包屑 -->
<nz-content class="inner-content">
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'discountName'" nzRequired>优惠券名称</nz-form-label>
<nz-form-control nzErrorTip="请输入优惠券名称!">
<input nz-input placeholder="请输入优惠券名称..." [formControlName]="'discountName'" id="'discountName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'discountType'" nzRequired>优惠券类型</nz-form-label>
<nz-form-control nzErrorTip="请选择优惠券类型!">
<nz-select nzPlaceHolder="请选择优惠券类型" [formControlName]="'discountType'">
<nz-option nzValue="1" nzLabel="满减"></nz-option>
<nz-option nzValue="2" nzLabel="抵扣"></nz-option>
<nz-option nzValue="3" nzLabel="折扣"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8" *ngIf="validateForm.value.discountType === '1'">
<nz-form-item>
<nz-form-label [nzFor]="'discountCondition'" nzRequired>满减条件价格</nz-form-label>
<nz-form-control nzErrorTip="请输入满减条件价格!">
<input nz-input [type]="'number'" placeholder="请输入满减条件价格..." [formControlName]="'discountCondition'" id="'discountCondition'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'discountPrice'" nzRequired>{{validateForm.value.discountType === '3' ? '折扣' : '抵扣价格'}}</nz-form-label>
<nz-form-control nzErrorTip="{{validateForm.value.discountType === '3' ? '请输入折扣' : '请输入抵扣价格'}}">
<input nz-input [type]="'number'" placeholder="{{validateForm.value.discountType === '3' ? '请输入折扣...' : '请输入抵扣价格...'}}" [formControlName]="'discountPrice'" id="'discountPrice'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<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]="8">
<nz-form-item>
<nz-form-label [nzFor]="'effectiveDay'" nzRequired>领取有效天数</nz-form-label>
<nz-form-control nzErrorTip="请输入领取有效天数!">
<nz-input-number [formControlName]="'effectiveDay'" [nzMin]="1" [nzMax]="100" [nzStep]="1"></nz-input-number>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label nzRequired>优惠券图片</nz-form-label>
<nz-form-control>
<nz-upload
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile"
nzListType="picture-card"
[(nzFileList)]="discountImg"
[nzShowButton]="discountImg.length < 1"
[nzPreview]="handlePreview"
>
<i nz-icon nzType="plus"></i>
<div class="ant-upload-text">上传图片</div>
</nz-upload>
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false">
<ng-template #modalContent>
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" />
</ng-template>
</nz-modal>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row>
<div nz-col [nzSpan]="24" class="search-area">
<button nz-button (click)="resetForm()">重置</button>
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button>
</div>
</div>
</form>
</nz-content>

@ -0,0 +1,6 @@
button {
margin-left: 8px;
}
:host ::ng-deep .ant-upload {
background-color: #ffffff;
}

@ -0,0 +1,161 @@
import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {environment} from '../../../../environments/environment';
import {CommonsService} from '../../../services/commons.service';
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {DiscountService} from '../../../services/discount.service';
function getBase64(file: File): Promise<string | ArrayBuffer | null> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
@Component({
selector: 'app-discount-edit',
templateUrl: './discount-edit.component.html',
styleUrls: ['./discount-edit.component.scss']
})
export class DiscountEditComponent implements OnInit {
validateForm!: FormGroup;
data: any;
editFlag = false;
id: number;
discountImg = [];
WEB_SERVE_URL = environment.baseUrl;
previewImage: string | undefined = '';
previewVisible = false;
constructor(
private fb: FormBuilder,
private discount: DiscountService,
private common: CommonsService,
private message: NzMessageService, // 信息提示
private activatedRoute: ActivatedRoute,
) {
}
ngOnInit(): void {
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.discountId != null) {
this.editFlag = true;
this.id = queryParams.discountId;
this.getDetails(queryParams.discountId);
}
});
this.validateForm = this.fb.group({
discountName: [null, [Validators.required]],
discountCondition: [null],
discountType: [null, [Validators.required]],
discountPrice: [null, [Validators.required]],
salesEndTime: [null, [Validators.required]],
effectiveDay: [1, [Validators.required]],
status: [null],
createTime: [null],
secUser: {},
});
}
// 返回
getBack() {
history.back();
}
// 重置
public resetForm(): void {
this.validateForm.reset();
}
// 保存
public getSave(): void {
// tslint:disable-next-line:forin
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
if (this.validateForm.controls[i].errors != null) {
this.message.error('必填项不能为空');
return;
}
}
if (this.discountImg.length !== 0) {
if (this.discountImg[0]['response'] != null) {
this.validateForm.value.discountImg = this.discountImg[0]['response']['return_data'][0];
} else {
this.validateForm.value.discountImg = this.discountImg[0].name;
}
} else {
this.message.error('请上传卡券图片');
return;
}
if (this.editFlag) {
this.common.showConfirm('是否确定修改,确定将下架', dataR => {
if (dataR) {
this.validateForm.value.id = this.id;
this.discount.updateDiscount(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功,卡券已下架!');
} else {
this.message.error(data['return_msg']);
}
});
}
});
} else {
this.discount.insertDiscount(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('添加成功');
} else {
this.message.error(data['return_msg']);
}
});
}
}
// 图片查看
handlePreview = async (file: NzUploadFile) => {
if (!file.url && !file.preview) {
// tslint:disable-next-line:no-non-null-assertion
file.preview = await getBase64(file.originFileObj!);
}
this.previewImage = file.url || file.preview;
this.previewVisible = true;
}
public getDetails(id) {
this.discount.getDiscountById(id, data => {
if (data['return_code'] === '000000') {
data['return_data']['discountType'] = String(data['return_data']['discountType']);
if (data['return_data']['discountImg'] != null && data['return_data']['discountImg'] !== '') {
const discountImg = String(data['return_data']['discountImg']);
const couponArray = [];
couponArray.push(
{
uid: 1,
name: discountImg,
status: 'done',
url: environment.imageUrl + discountImg
});
this.discountImg = couponArray;
}
this.validateForm.patchValue(data['return_data']);
} else {
this.message.create('error', data['return_msg']);
}
});
}
}

@ -0,0 +1,252 @@
<!-- 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="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">优惠券KYE</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="discountKey"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">优惠券名称</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="discountName"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">优惠券类型</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-select nzShowSearch nzAllowClear formControlName="discountType" nzPlaceHolder="请选择优惠券类型">
<nz-option nzLabel="满减" nzValue="1"></nz-option>
<nz-option nzLabel="抵扣" nzValue="2"></nz-option>
<nz-option nzLabel="折扣" nzValue="3"></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>
<div class="operating-button">
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/discount/discount-edit']"><i nz-icon
nzType="plus"
nzTheme="outline"></i>添加
</button>
</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="80px">优惠券KEY</th>
<th nzWidth="80px">优惠券名称</th>
<th nzWidth="80px">优惠券类型</th>
<th nzWidth="70px">优惠内容</th>
<th nzWidth="70px">有效天数</th>
<th nzWidth="100px">截止日期</th>
<th nzWidth="100px">创建时间</th>
<th nzWidth="100px">状态</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.discountKey}}</td>
<td>{{data.discountName}}</td>
<td>{{data.discountType | discountType}}</td>
<td>
<span *ngIf="data.discountType === 1">
满{{data.discountCondition}}抵扣{{data.discountPrice}}
</span>
<span *ngIf="data.discountType === 2">
抵扣{{data.discountPrice}}
</span>
<span *ngIf="data.discountType === 3">
{{data.discountPrice}}折
</span>
</td>
<td>{{data.effectiveDay}}</td>
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.createTime}}</td>
<td>{{data.status | discountStatus}}</td>
<td nzRight="0px" class="table-td-operation">
<!-- <a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a>-->
<!-- <nz-divider nzType="vertical"></nz-divider>-->
<a (click)="getCoupon(this.searchFormCoupon.value , data.id)"><i nz-icon nzType="money-collect" nzTheme="outline" nz-tooltip="绑定卡券"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getCouponList(data.id)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="查询绑定列表"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)='getForbiddenUser(data.id , data.status)'><i nz-icon
nzType="{{data.status === 2 ? 'arrow-down': 'arrow-up'}}"
nzTheme="outline"
nz-tooltip="{{data.status === 2 ? '下架': '上架'}}"></i></a>
</td>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" nzTitle="绑定卡券" nzWidth="1100" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<div class="inner-content">
<form nz-form [formGroup]="searchFormCoupon" (ngSubmit)="getCoupon(searchFormCoupon.value , this.discountId)">
<div nz-row>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">卡券名称</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="couponName"/>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">商户</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-select nzShowSearch nzAllowClear formControlName="merchantId" nzPlaceHolder="请选择商户">
<nz-option *ngFor="let item of optionList" nzLabel="{{item.merchantName}}" nzValue="{{item.id}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">卡券类型</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-select [formControlName]="'couponType'">
<nz-option nzValue="1" nzLabel="内部卷"></nz-option>
<nz-option nzValue="2" 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)="resetCouponForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button>
</div>
</div>
</form>
</div>
<div class="inner-content">
<nz-table
class="table"
#couponTable
nzShowSizeChanger
[nzFrontPagination]="false"
[nzData]="requestCouponData"
[nzLoading]="loadingCoupon"
[nzScroll]="{ x: '1200px' , y: '340px' }"
>
<thead nzSingleSort>
<tr>
<th
nzWidth="50px"
nzLeft
[(nzChecked)]="checked"
[nzIndeterminate]="indeterminate"
(nzCheckedChange)="onAllChecked($event)"
></th>
<th nzWidth="150px">卡券编号</th>
<th nzWidth="160px">卡券名称</th>
<th nzWidth="100px">销售价格</th>
<th nzWidth="100px">有效库存</th>
<th nzWidth="100px">卡券类型</th>
<th nzWidth="120px">卡券状态</th>
<th nzWidth="150px">销售截止时间</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of couponTable.data; let i = index">
<td nzLeft [nzChecked]="setOfCheckedId.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td>
<td>{{data.couponKey}}</td>
<td>{{data.couponName}}</td>
<td>¥{{data.salesPrice}}</td>
<td>{{data.stockCount}}</td>
<td>{{data.couponType === 1 ? '内部卷' : '外部卷'}}</td>
<td>{{data.status | couponStatus}}</td>
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
</tbody>
</nz-table>
</div>
</nz-modal>
<nz-modal [(nzVisible)]="isVisibleList" nzTitle="绑定卡券列表" nzWidth="1100" (nzOnCancel)="handleCancelList()" (nzOnOk)="handleCancelList()">
<div class="inner-content">
<nz-table
class="table"
#discountCouponTable
nzShowSizeChanger
[nzFrontPagination]="false"
[nzData]="discountCoupon"
[nzLoading]="loadingDiscountCoupon"
[nzScroll]="{ x: '1200px' , y: '340px' }"
>
<thead nzSingleSort>
<tr>
<th nzWidth="150px">卡券编号</th>
<th nzWidth="160px">卡券名称</th>
<th nzWidth="100px">销售价格</th>
<th nzWidth="100px">有效库存</th>
<th nzWidth="100px">卡券类型</th>
<th nzWidth="120px">卡券状态</th>
<th nzWidth="150px">销售截止时间</th>
<th nzWidth="150px">绑定时间</th>
<th nzRight nzWidth="60px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of discountCouponTable.data; let i = index">
<td>{{data['highCoupon'].couponKey}}</td>
<td>{{data['highCoupon'].couponName}}</td>
<td>¥{{data['highCoupon'].salesPrice}}</td>
<td>{{data['highCoupon'].stockCount}}</td>
<td>{{data['highCoupon'].couponType === 1 ? '内部卷' : '外部卷'}}</td>
<td>{{data['highCoupon'].status | couponStatus}}</td>
<td>{{data['highCoupon'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight><a (click)="showDeleteConfirmDelete(data.id)">删除</a></td>
</tbody>
</nz-table>
</div>
</nz-modal>

@ -0,0 +1,4 @@
.head_img {
height: 60px;
width: 60px;
}

@ -0,0 +1,251 @@
import { Component, OnInit } from '@angular/core';
import {environment} from '../../../../environments/environment';
import {FormBuilder, FormGroup} from '@angular/forms';
import {AgentService} from '../../../services/agent.service';
import {IconService} from '../../../services/icon.service';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {CommonsService} from '../../../services/commons.service';
import {DiscountService} from '../../../services/discount.service';
import {CouponService} from '../../../services/coupon.service';
import {MerchantService} from '../../../services/merchant.service';
@Component({
selector: 'app-discount-list',
templateUrl: './discount-list.component.html',
styleUrls: ['./discount-list.component.scss']
})
export class DiscountListComponent implements OnInit {
WEB_SERVE_URL = environment.imageUrl;
searchForm: FormGroup; // 搜索框
searchFormCoupon: FormGroup; // 搜索框
requestData = []; // 列表数据
couponData = []; // 列表数据
optionList = []; // 列表数据
discountCoupon = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
isVisible = false;
isVisibleList = false;
couponList: any;
requestCouponData = []; // 列表数据
loadingCoupon = true;
loadingDiscountCoupon = true;
discountId: number;
RelByDiscountId: number;
setOfCheckedId = new Set<number>();
checked = false;
indeterminate = false;
updateCheckedSet(id: number, checked: boolean): void {
if (checked) {
this.setOfCheckedId.add(id);
} else {
this.setOfCheckedId.delete(id);
}
}
onItemChecked(id: number, checked: boolean): void {
this.updateCheckedSet(id, checked);
this.refreshCheckedStatus();
}
onAllChecked(value: boolean): void {
this.requestCouponData.forEach(item => this.updateCheckedSet(item.id, value));
this.refreshCheckedStatus();
}
refreshCheckedStatus(): void {
this.checked = this.requestCouponData.every(item => this.setOfCheckedId.has(item.id));
this.indeterminate = this.requestCouponData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked;
}
constructor(
private form: FormBuilder,
private discount: DiscountService,
private iconService: IconService,
private merchant: MerchantService,
private message: NzMessageService,
private router: Router,
private common: CommonsService,
private coupon: CouponService
) {
}
ngOnInit(): void {
this.init();
const whereObject = {};
whereObject['pageNum'] = 1;
whereObject['pageSize'] = 30000;
this.merchant.getMerchantList(whereObject , data => {
if (data['return_code'] === '000000' ) {
this.optionList = data['return_data'].list;
}
});
}
public init(): void {
this.searchForm = this.form.group({
discountKey: [null],
discountName: [null],
discountType: [null],
});
this.searchFormCoupon = this.form.group({
merchantId: [null],
couponName: [null],
couponType: [null],
status: [2],
});
this.getRequest(true, this.searchForm.value);
}
// 查询列表
public getRequest(reset: boolean = false, whereObject: object) {
this.loading = false;
if (reset) {
this.pageNum = 1;
}
whereObject['pageNum'] = this.pageNum;
whereObject['pageSize'] = this.pageSize;
this.discount.getDiscountList(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();
}
public getForbiddenUser(id, status: any): void {
const message = (status === 2 ? '是否下架当前优惠券' : '是否上架当前优惠券');
const s = status === 2 ? 3 : 2;
this.common.showConfirm(message, data => {
if (data) {
this.discount.editStatus(id, s , dataUser => {
if (dataUser['return_code'] === '000000') {
this.message.success(dataUser['return_data']);
} else {
this.message.error(dataUser['return_msg']);
}
this.getRequest(false , this.searchForm.value);
});
}
});
}
// 修改
public getEdit(id: number): void {
this.router.navigate(['/admin/discount/discount-detail'], {
queryParams: {
discountId: id
}
}).then(r => console.log(r));
}
// 查看详情
public getDetail(id: number): void {
this.router.navigate(['/admin/company/company-detail'], {
queryParams: {
companyId: id
}
}).then(r => console.log(r));
}
// 绑定卡券
public getCoupon(whereObject: object , id: number): void {
this.isVisible = true;
this.discountId = id;
whereObject['pageNum'] = 1;
whereObject['pageSize'] = 30000;
this.coupon.getCouponList(whereObject, data => {
if (data['return_code'] === '000000') {
this.loadingCoupon = false;
this.requestCouponData = data['return_data'].list;
} else {
this.message.error(data['return_msg']);
}
});
}
handleOk(): void {
const couponIdStr = [];
this.setOfCheckedId.forEach(item => couponIdStr.push(item));
const params = {
discountId : this.discountId,
couponIdStr : couponIdStr.join(',')
};
this.discount.insertDiscountCoupon(params , data => {
if (data['return_code'] === '000000') {
this.message.success(data['return_data']);
} else {
this.message.error(data['return_msg']);
}
});
this.isVisible = false;
}
handleCancel(): void {
this.isVisible = false;
}
// 重置
public resetCouponForm(): void {
this.searchFormCoupon.reset();
}
public getCouponList(id: number): void {
this.RelByDiscountId = id;
this.getRelByDiscount(id);
this.isVisibleList = true;
}
getRelByDiscount(id: number): void {
this.loadingDiscountCoupon = true;
this.discount.getRelByDiscount(id , data => {
if (data['return_code'] === '000000') {
this.loadingDiscountCoupon = false;
this.discountCoupon = data['return_data'];
} else {
this.message.error(data['return_msg']);
}
});
}
handleCancelList(): void {
this.isVisibleList = false;
}
showDeleteConfirmDelete(id: number): void {
this.common.showConfirm('是否确定删除!' , dataR => {
if (dataR) {
this.discount.delete(id, data => {
if (data['return_code'] === '000000') {
this.getRelByDiscount(this.RelByDiscountId);
this.message.success(data['return_data']);
} else {
this.message.error(data['return_msg']);
}
});
}
});
}
}

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {DiscountListComponent} from './discount-list/discount-list.component';
import {DiscountEditComponent} from './discount-edit/discount-edit.component';
import {DiscountDetailComponent} from './discount-detail/discount-detail.component';
import {DiscountCouponComponent} from './discount-coupon/discount-coupon.component';
const routes: Routes = [
{ path: 'discount-list', component: DiscountListComponent },
{ path: 'discount-edit', component: DiscountEditComponent },
{ path: 'discount-detail', component: DiscountDetailComponent },
{ path: 'discount-coupon', component: DiscountCouponComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DiscountRoutingModule { }

@ -0,0 +1,31 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DiscountRoutingModule } from './discount-routing.module';
import { DiscountListComponent } from './discount-list/discount-list.component';
import { DiscountEditComponent } from './discount-edit/discount-edit.component';
import { DiscountDetailComponent } from './discount-detail/discount-detail.component';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {SeparateModule} from '../../common/separate/separate.module';
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 { DiscountCouponComponent } from './discount-coupon/discount-coupon.component';
@NgModule({
declarations: [DiscountListComponent, DiscountEditComponent, DiscountDetailComponent, DiscountCouponComponent],
imports: [
CommonModule,
DiscountRoutingModule,
NgZorroAntdModule,
SeparateModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule,
RichtextModule,
AppCommonModule
]
})
export class DiscountModule { }

@ -51,7 +51,7 @@ export class MerchantEditComponent implements OnInit {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], loginTelephone: [null, [Validators.required, ValidatorsService.mobile]],
password: [null, [Validators.required, ValidatorsService.minLength(6)]], password: [null, [Validators.required, ValidatorsService.minLength(6)]],
merchantName: [null, [Validators.required, ValidatorsService.pwdLength(2, 12)]], merchantName: [null, [Validators.required, ValidatorsService.pwdLength(2, 5)]],
telephone: [null, [Validators.required]], telephone: [null, [Validators.required]],
address: [null, [Validators.required]], address: [null, [Validators.required]],
bankName: [null], bankName: [null],

@ -16,11 +16,14 @@ import {
CouponStatusPipe, CouponStatusPipe,
CouponCodePipe, CouponCodePipe,
AuditTypePipe, AuditTypePipe,
AuditStatusPipe AuditStatusPipe,
PaymodelPipe,
PaytypePipe,
DiscountTypePipe,
OrderCouponStatusPipe,
DiscountStatusPipe
} from './pipes'; } from './pipes';
import { OrderCouponStatusPipe } from './pipes/order/order-coupon-status.pipe';
import { PaymodelPipe } from './pipes/paymodel.pipe';
import { PaytypePipe } from './pipes/paytype.pipe';
const PIPES = [ const PIPES = [
TimesPipe, TimesPipe,
@ -31,6 +34,10 @@ const PIPES = [
AuditTypePipe, AuditTypePipe,
AuditStatusPipe, AuditStatusPipe,
OrderCouponStatusPipe, OrderCouponStatusPipe,
PaymodelPipe,
PaytypePipe,
DiscountTypePipe,
DiscountStatusPipe
]; ];
@ -44,14 +51,11 @@ const PIPES = [
], ],
declarations: [ declarations: [
...PIPES, ...PIPES,
PaymodelPipe,
PaytypePipe,
], ],
exports: [ exports: [
...PIPES, ...PIPES,
PaymodelPipe,
PaytypePipe,
], ],
}) })

@ -61,11 +61,21 @@ const routes: Routes = [
loadChildren: () => import('./admin/order/order.module').then(m => m.OrderModule), loadChildren: () => import('./admin/order/order.module').then(m => m.OrderModule),
canActivate: [InitGuardService] canActivate: [InitGuardService]
}, },
{
path: 'discount',
loadChildren: () => import('./admin/discount/discount.module').then(m => m.DiscountModule),
canActivate: [InitGuardService]
},
{ {
path: 'system', path: 'system',
loadChildren: () => import('./admin/system/system.module').then(m => m.SystemModule), loadChildren: () => import('./admin/system/system.module').then(m => m.SystemModule),
canActivate: [InitGuardService] canActivate: [InitGuardService]
}, },
{
path: 'agent',
loadChildren: () => import('./admin/agent/agent.module').then(m => m.AgentModule),
canActivate: [InitGuardService]
},
{ {
path: 'cms', path: 'cms',
loadChildren: () => import('./admin/cms/cms.module').then(m => m.CmsModule), loadChildren: () => import('./admin/cms/cms.module').then(m => m.CmsModule),

@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'discountStatus'
})
export class DiscountStatusPipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 1:
return '编辑中';
case 2:
return '已上架';
case 3:
return '已下架';
}
}
}

@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'discountType'
})
export class DiscountTypePipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 1:
return '满减';
case 2:
return '抵扣';
case 3:
return '折扣';
}
}
}

@ -8,3 +8,5 @@ export * from './audit-type.pipe';
export * from './order/order-coupon-status.pipe'; export * from './order/order-coupon-status.pipe';
export * from './paymodel.pipe'; export * from './paymodel.pipe';
export * from './paytype.pipe'; export * from './paytype.pipe';
export * from './discount-type.pipe';
export * from './discount-status.pipe';

@ -0,0 +1,106 @@
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {CommonsService} from './commons.service';
import {environment} from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class AgentService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param paramsObject
* @param callBack
*/
public getListAgent(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'highAgent/getListAgent?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public insertAgent(params: object, callBack) {
this.http.post(environment.baseUrl + 'highAgent/insertAgent', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public updateAgent(params: object, callBack) {
this.http.post(environment.baseUrl + 'highAgent/updateAgent', params).subscribe(data => {
callBack(data);
});
}
/**
* id查询详情
*
* @param agentId id
* @param callBack
*/
public findByAgentId(agentId: number, callBack) {
this.http.get(environment.baseUrl + 'highAgent/findByAgentId?agentId=' + agentId).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param status status
* @param callBack
*/
public editStatus(id: number, callBack) {
this.http.get(environment.baseUrl + 'highAgent/forbiddenUser?agentId=' + id ).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public insertDiscountAgent(params: object, callBack) {
this.http.post(environment.baseUrl + 'discountAgentRel/insertDiscountAgent', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param paramsObject
* @param callBack
*/
public getDiscountAgentList(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'discountAgentRel/getDiscountAgentList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
}

@ -0,0 +1,119 @@
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {CommonsService} from './commons.service';
import {environment} from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class DiscountService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param paramsObject
* @param callBack
*/
public getDiscountList(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'discount/getDiscountList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public insertDiscount(params: object, callBack) {
this.http.post(environment.baseUrl + 'discount/insertDiscount', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public updateDiscount(params: object, callBack) {
this.http.post(environment.baseUrl + 'discount/updateDiscount', params).subscribe(data => {
callBack(data);
});
}
/**
* id查询详情
*
* @param id id
* @param callBack
*/
public getDiscountById(id: number, callBack) {
this.http.get(environment.baseUrl + 'discount/getDiscountById?id=' + id).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param status status
* @param callBack
*/
public editStatus(id: number, status: number, callBack) {
this.http.get(environment.baseUrl + 'discount/updateDiscountStatus?discountId=' + id + '&status=' + status ).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public insertDiscountCoupon(params: object, callBack) {
this.http.post(environment.baseUrl + 'discountCoupon/insertDiscountCoupon', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param callBack
*/
public getRelByDiscount(id: number, callBack) {
this.http.get(environment.baseUrl + 'discountCoupon/getRelByDiscount?discountId=' + id ).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param callBack
*/
public delete(id: number, callBack) {
this.http.get(environment.baseUrl + 'discountCoupon/delete?id=' + id ).subscribe(data => {
callBack(data);
});
}
}

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

Loading…
Cancel
Save