diff --git a/src/app/admin/agent/agent-edit/agent-edit.component.html b/src/app/admin/agent/agent-edit/agent-edit.component.html new file mode 100644 index 0000000..a49418f --- /dev/null +++ b/src/app/admin/agent/agent-edit/agent-edit.component.html @@ -0,0 +1,87 @@ + + + + 系统管理 + + + 增加公司 + + + + +
+ +
+
+
+
+
+ +
+ + 用户名 + + + + +
+
+ + 登录密码 + + + + + + + + + +
+ + +
+ + 代理商名称 + + + + +
+
+ + 代理商地址 + + + + +
+
+ + 联系人 + + + + +
+
+ + 联系方式 + + + + +
+ +
+
+
+ + +
+
+
+
+
+
+
diff --git a/src/app/admin/agent/agent-edit/agent-edit.component.scss b/src/app/admin/agent/agent-edit/agent-edit.component.scss new file mode 100644 index 0000000..ac60fb8 --- /dev/null +++ b/src/app/admin/agent/agent-edit/agent-edit.component.scss @@ -0,0 +1,6 @@ +button { + margin-left: 8px; +} +:host ::ng-deep .ant-upload { + background-color: #ffffff; +} diff --git a/src/app/admin/agent/agent-edit/agent-edit.component.ts b/src/app/admin/agent/agent-edit/agent-edit.component.ts new file mode 100644 index 0000000..ec899e6 --- /dev/null +++ b/src/app/admin/agent/agent-edit/agent-edit.component.ts @@ -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']); + } + }); + } + +} diff --git a/src/app/admin/agent/agent-list/agent-list.component.html b/src/app/admin/agent/agent-list/agent-list.component.html new file mode 100644 index 0000000..a1df3dd --- /dev/null +++ b/src/app/admin/agent/agent-list/agent-list.component.html @@ -0,0 +1,172 @@ + + + + + +
+
+
+ +
+ + 名称 + + + + +
+
+ + 电话 + + + + +
+
+ + 代理商状态 + + + + + + + +
+ +
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 代理商名称 + 代理商地址 + 联系人 + 联系方式 + 创建时间 + 操作 + + + + + {{i+1}} + {{data.agentName}} + {{data.agentAddress}} + {{data.agentUser}} + {{data.agentPhone}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + + + + + + + + + + + + + + +
+ + +
+ + 优惠券 + + + + + + + + 分配优惠券数量 + + + + +
+
+ + + + + + 优惠券KEY + 优惠券名称 + 优惠券类型 + 优惠内容 + 有效天数 + 截止日期 + 库存数量 + 二维码 + + + + + {{data['highDiscount'].discountKey}} + {{data['highDiscount'].discountName}} + {{data['highDiscount'].discountType | discountType}} + + + 满{{data['highDiscount'].discountCondition}}抵扣{{data['highDiscount'].discountPrice}} + + + 抵扣{{data['highDiscount'].discountPrice}} + + + {{data['highDiscount'].discountPrice}}折 + + + {{data['highDiscount'].effectiveDay}} + {{data['highDiscount'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.stockCount}} + + + + + + diff --git a/src/app/admin/agent/agent-list/agent-list.component.scss b/src/app/admin/agent/agent-list/agent-list.component.scss new file mode 100644 index 0000000..ebfbfbd --- /dev/null +++ b/src/app/admin/agent/agent-list/agent-list.component.scss @@ -0,0 +1,4 @@ +.head_img { + height: 80px; + width: 80px; +} diff --git a/src/app/admin/agent/agent-list/agent-list.component.ts b/src/app/admin/agent/agent-list/agent-list.component.ts new file mode 100644 index 0000000..5053c3b --- /dev/null +++ b/src/app/admin/agent/agent-list/agent-list.component.ts @@ -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']); + } + }); + } +} + diff --git a/src/app/admin/agent/agent-routing.module.ts b/src/app/admin/agent/agent-routing.module.ts new file mode 100644 index 0000000..4004a2b --- /dev/null +++ b/src/app/admin/agent/agent-routing.module.ts @@ -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 { } diff --git a/src/app/admin/agent/agent.module.ts b/src/app/admin/agent/agent.module.ts new file mode 100644 index 0000000..c3c7363 --- /dev/null +++ b/src/app/admin/agent/agent.module.ts @@ -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 { } diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.ts b/src/app/admin/coupon/coupon-list/coupon-list.component.ts index e010336..fdbcf43 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.ts +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.ts @@ -1,6 +1,5 @@ import {Component, OnInit} from '@angular/core'; import {FormBuilder, FormGroup} from '@angular/forms'; -import {MerchantStoreService} from '../../../services/merchant-store.service'; import {IconService} from '../../../services/icon.service'; import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute, Router} from '@angular/router'; diff --git a/src/app/admin/discount/discount-coupon/discount-coupon.component.html b/src/app/admin/discount/discount-coupon/discount-coupon.component.html new file mode 100644 index 0000000..0f7c14f --- /dev/null +++ b/src/app/admin/discount/discount-coupon/discount-coupon.component.html @@ -0,0 +1 @@ +

discount-coupon works!

diff --git a/src/app/admin/discount/discount-coupon/discount-coupon.component.scss b/src/app/admin/discount/discount-coupon/discount-coupon.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/discount/discount-coupon/discount-coupon.component.spec.ts b/src/app/admin/discount/discount-coupon/discount-coupon.component.spec.ts new file mode 100644 index 0000000..dc88035 --- /dev/null +++ b/src/app/admin/discount/discount-coupon/discount-coupon.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DiscountCouponComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DiscountCouponComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/discount/discount-coupon/discount-coupon.component.ts b/src/app/admin/discount/discount-coupon/discount-coupon.component.ts new file mode 100644 index 0000000..7318406 --- /dev/null +++ b/src/app/admin/discount/discount-coupon/discount-coupon.component.ts @@ -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 { + } + +} diff --git a/src/app/admin/discount/discount-detail/discount-detail.component.html b/src/app/admin/discount/discount-detail/discount-detail.component.html new file mode 100644 index 0000000..ac197e7 --- /dev/null +++ b/src/app/admin/discount/discount-detail/discount-detail.component.html @@ -0,0 +1,22 @@ + + + + + Name + Age + Address + + + + + + {{ data.name }} + {{ data.age }} + {{ data.address }} + + + diff --git a/src/app/admin/discount/discount-detail/discount-detail.component.scss b/src/app/admin/discount/discount-detail/discount-detail.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/discount/discount-detail/discount-detail.component.spec.ts b/src/app/admin/discount/discount-detail/discount-detail.component.spec.ts new file mode 100644 index 0000000..7d040d3 --- /dev/null +++ b/src/app/admin/discount/discount-detail/discount-detail.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DiscountDetailComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DiscountDetailComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/discount/discount-detail/discount-detail.component.ts b/src/app/admin/discount/discount-detail/discount-detail.component.ts new file mode 100644 index 0000000..a5c4147 --- /dev/null +++ b/src/app/admin/discount/discount-detail/discount-detail.component.ts @@ -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(); + + 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(); + + } +} diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.html b/src/app/admin/discount/discount-edit/discount-edit.component.html new file mode 100644 index 0000000..34080ef --- /dev/null +++ b/src/app/admin/discount/discount-edit/discount-edit.component.html @@ -0,0 +1,108 @@ + + + + 卡券管理 + + + 编辑卡券 + + + + + +
+
+
+ + 优惠券名称 + + + + +
+
+ + 优惠券类型 + + + + + + + + +
+ +
+ + 满减条件价格 + + + + +
+ +
+ + {{validateForm.value.discountType === '3' ? '折扣' : '抵扣价格'}} + + + + +
+ +
+ + 截止日期 + + + + +
+ +
+ + 领取有效天数 + + + + +
+
+ + 优惠券图片 + + + +
上传图片
+
+ + + + + +
+
+
+ + + +
+
+
+ + +
+
+
+ +
diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.scss b/src/app/admin/discount/discount-edit/discount-edit.component.scss new file mode 100644 index 0000000..ac60fb8 --- /dev/null +++ b/src/app/admin/discount/discount-edit/discount-edit.component.scss @@ -0,0 +1,6 @@ +button { + margin-left: 8px; +} +:host ::ng-deep .ant-upload { + background-color: #ffffff; +} diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.ts b/src/app/admin/discount/discount-edit/discount-edit.component.ts new file mode 100644 index 0000000..eac1253 --- /dev/null +++ b/src/app/admin/discount/discount-edit/discount-edit.component.ts @@ -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 { + 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']); + } + }); + } + + +} diff --git a/src/app/admin/discount/discount-list/discount-list.component.html b/src/app/admin/discount/discount-list/discount-list.component.html new file mode 100644 index 0000000..a5dee49 --- /dev/null +++ b/src/app/admin/discount/discount-list/discount-list.component.html @@ -0,0 +1,252 @@ + + + + + +
+
+
+ +
+ + 优惠券KYE + + + + +
+
+ + 优惠券名称 + + + + +
+
+ + 优惠券类型 + + + + + + + + +
+ +
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 优惠券KEY + 优惠券名称 + 优惠券类型 + 优惠内容 + 有效天数 + 截止日期 + 创建时间 + 状态 + 操作 + + + + + {{i + 1}} + {{data.discountKey}} + {{data.discountName}} + {{data.discountType | discountType}} + + + 满{{data.discountCondition}}抵扣{{data.discountPrice}} + + + 抵扣{{data.discountPrice}} + + + {{data.discountPrice}}折 + + + {{data.effectiveDay}} + {{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.createTime}} + {{data.status | discountStatus}} + + + + + + + + + + + +
+ + + +
+
+
+ +
+ + 卡券名称 + + + + +
+
+ + 商户 + + + + + + +
+
+ + 卡券类型 + + + + + + + +
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + 卡券编号 + 卡券名称 + 销售价格 + 有效库存 + 卡券类型 + 卡券状态 + 销售截止时间 + + + + + + {{data.couponKey}} + {{data.couponName}} + ¥{{data.salesPrice}} + {{data.stockCount}} + {{data.couponType === 1 ? '内部卷' : '外部卷'}} + {{data.status | couponStatus}} + {{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + + +
+
+ + +
+ + + + 卡券编号 + 卡券名称 + 销售价格 + 有效库存 + 卡券类型 + 卡券状态 + 销售截止时间 + 绑定时间 + 操作 + + + + + {{data['highCoupon'].couponKey}} + {{data['highCoupon'].couponName}} + ¥{{data['highCoupon'].salesPrice}} + {{data['highCoupon'].stockCount}} + {{data['highCoupon'].couponType === 1 ? '内部卷' : '外部卷'}} + {{data['highCoupon'].status | couponStatus}} + {{data['highCoupon'].salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + 删除 + + +
+
diff --git a/src/app/admin/discount/discount-list/discount-list.component.scss b/src/app/admin/discount/discount-list/discount-list.component.scss new file mode 100644 index 0000000..8bee3fb --- /dev/null +++ b/src/app/admin/discount/discount-list/discount-list.component.scss @@ -0,0 +1,4 @@ +.head_img { + height: 60px; + width: 60px; +} diff --git a/src/app/admin/discount/discount-list/discount-list.component.ts b/src/app/admin/discount/discount-list/discount-list.component.ts new file mode 100644 index 0000000..3cc9200 --- /dev/null +++ b/src/app/admin/discount/discount-list/discount-list.component.ts @@ -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(); + 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']); + } + }); + } + }); + } + + +} + diff --git a/src/app/admin/discount/discount-routing.module.ts b/src/app/admin/discount/discount-routing.module.ts new file mode 100644 index 0000000..ade5001 --- /dev/null +++ b/src/app/admin/discount/discount-routing.module.ts @@ -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 { } diff --git a/src/app/admin/discount/discount.module.ts b/src/app/admin/discount/discount.module.ts new file mode 100644 index 0000000..a483d7f --- /dev/null +++ b/src/app/admin/discount/discount.module.ts @@ -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 { } diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts index dd91d47..f835243 100644 --- a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts @@ -51,7 +51,7 @@ export class MerchantEditComponent implements OnInit { this.validateForm = this.fb.group({ loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], 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]], address: [null, [Validators.required]], bankName: [null], diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts index 876a79e..a3b12f4 100644 --- a/src/app/app-common.module.ts +++ b/src/app/app-common.module.ts @@ -16,11 +16,14 @@ import { CouponStatusPipe, CouponCodePipe, AuditTypePipe, - AuditStatusPipe + AuditStatusPipe, + PaymodelPipe, + PaytypePipe, + DiscountTypePipe, + OrderCouponStatusPipe, + DiscountStatusPipe } 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 = [ TimesPipe, @@ -31,6 +34,10 @@ const PIPES = [ AuditTypePipe, AuditStatusPipe, OrderCouponStatusPipe, + PaymodelPipe, + PaytypePipe, + DiscountTypePipe, + DiscountStatusPipe ]; @@ -44,14 +51,11 @@ const PIPES = [ ], declarations: [ ...PIPES, - PaymodelPipe, - PaytypePipe, + ], exports: [ ...PIPES, - PaymodelPipe, - PaytypePipe, ], }) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d9efb45..9ac20b3 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -61,11 +61,21 @@ const routes: Routes = [ loadChildren: () => import('./admin/order/order.module').then(m => m.OrderModule), canActivate: [InitGuardService] }, + { + path: 'discount', + loadChildren: () => import('./admin/discount/discount.module').then(m => m.DiscountModule), + canActivate: [InitGuardService] + }, { path: 'system', loadChildren: () => import('./admin/system/system.module').then(m => m.SystemModule), canActivate: [InitGuardService] }, + { + path: 'agent', + loadChildren: () => import('./admin/agent/agent.module').then(m => m.AgentModule), + canActivate: [InitGuardService] + }, { path: 'cms', loadChildren: () => import('./admin/cms/cms.module').then(m => m.CmsModule), diff --git a/src/app/pipes/discount-status.pipe.ts b/src/app/pipes/discount-status.pipe.ts new file mode 100644 index 0000000..1e69943 --- /dev/null +++ b/src/app/pipes/discount-status.pipe.ts @@ -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 '已下架'; + } + } + +} diff --git a/src/app/pipes/discount-type.pipe.ts b/src/app/pipes/discount-type.pipe.ts new file mode 100644 index 0000000..4845a4c --- /dev/null +++ b/src/app/pipes/discount-type.pipe.ts @@ -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 '折扣'; + } + } + +} diff --git a/src/app/pipes/index.ts b/src/app/pipes/index.ts index 7c734a5..98a80b9 100644 --- a/src/app/pipes/index.ts +++ b/src/app/pipes/index.ts @@ -8,3 +8,5 @@ export * from './audit-type.pipe'; export * from './order/order-coupon-status.pipe'; export * from './paymodel.pipe'; export * from './paytype.pipe'; +export * from './discount-type.pipe'; +export * from './discount-status.pipe'; diff --git a/src/app/services/agent.service.ts b/src/app/services/agent.service.ts new file mode 100644 index 0000000..863e116 --- /dev/null +++ b/src/app/services/agent.service.ts @@ -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); + }); + } + +} diff --git a/src/app/services/discount.service.ts b/src/app/services/discount.service.ts new file mode 100644 index 0000000..98ef801 --- /dev/null +++ b/src/app/services/discount.service.ts @@ -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); + }); + } +} diff --git a/src/app/services/icon.service.ts b/src/app/services/icon.service.ts index e9882fc..86ff7ce 100644 --- a/src/app/services/icon.service.ts +++ b/src/app/services/icon.service.ts @@ -12,7 +12,7 @@ export class IconService { constructor(private iconService: NzIconService) { this.iconService.fetchFromIconfont({ - scriptUrl: 'https://at.alicdn.com/t/font_2424521_9lbh3xk0u0h.js' + scriptUrl: 'https://at.alicdn.com/t/font_2424521_irl9t133o8k.js' }); } }