diff --git a/src/app/admin/audit/refund-audit/refund-audit.component.ts b/src/app/admin/audit/refund-audit/refund-audit.component.ts index f741b8c..cd299d9 100644 --- a/src/app/admin/audit/refund-audit/refund-audit.component.ts +++ b/src/app/admin/audit/refund-audit/refund-audit.component.ts @@ -116,7 +116,6 @@ export class RefundAuditComponent implements OnInit { if (refundSource === 1) { this.recharge.getOrderById(id , data => { if (data['return_code'] === '000000') { - console.log(data); this.data = data['return_data']; } else { this.message.error(data['return_msg']); diff --git a/src/app/admin/discount/discount-edit/discount-edit.component.ts b/src/app/admin/discount/discount-edit/discount-edit.component.ts index 8a8d5d6..18c6f28 100644 --- a/src/app/admin/discount/discount-edit/discount-edit.component.ts +++ b/src/app/admin/discount/discount-edit/discount-edit.component.ts @@ -33,6 +33,7 @@ export class DiscountEditComponent implements OnInit { WEB_SERVE_URL = environment.baseUrl; previewImage: string | undefined = ''; previewVisible = false; + wx: WebSocket; constructor( private fb: FormBuilder, diff --git a/src/app/admin/gz-sinopec/gz-sinopec-routing.module.ts b/src/app/admin/gz-sinopec/gz-sinopec-routing.module.ts new file mode 100644 index 0000000..3995936 --- /dev/null +++ b/src/app/admin/gz-sinopec/gz-sinopec-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import {OfflineAssignComponent} from './offline-assign/offline-assign.component'; +import {UseOrderComponent} from './use-order/use-order.component'; + +const routes: Routes = [ + { path: 'offline-assign-list', component: OfflineAssignComponent }, + { path: 'use-order-list', component: UseOrderComponent }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class GzSinopecRoutingModule { } diff --git a/src/app/admin/gz-sinopec/gz-sinopec.module.ts b/src/app/admin/gz-sinopec/gz-sinopec.module.ts new file mode 100644 index 0000000..514a618 --- /dev/null +++ b/src/app/admin/gz-sinopec/gz-sinopec.module.ts @@ -0,0 +1,24 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { GzSinopecRoutingModule } from './gz-sinopec-routing.module'; +import { OfflineAssignComponent } from './offline-assign/offline-assign.component'; +import { UseOrderComponent } from './use-order/use-order.component'; +import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; +import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; +import {AppCommonModule} from '../../app-common.module'; +import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; + +@NgModule({ + declarations: [OfflineAssignComponent, UseOrderComponent], + imports: [ + CommonModule, + GzSinopecRoutingModule, + NgZorroAntdModule, + ReactiveFormsModule, + FormsModule, + BreadcrumbModule, + AppCommonModule, + ] +}) +export class GzSinopecModule { } diff --git a/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.html b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.html new file mode 100644 index 0000000..e72913f --- /dev/null +++ b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.html @@ -0,0 +1,92 @@ + + + + + +
+
+
+
+ + 卡券名称 + + + + +
+ +
+ + 使用状态 + + + + + + + +
+ +
+ + 分发时间 + + + + +
+
+ +
+
+ + +
+
+
+
+ +
+ 共计 {{dataObject.total?dataObject.total:0}} 条数据 +
+ +
+ + + + + + 序号 + 卡卷名称 + 卡券金额 + 分发时间 + 分发手机号 + 状态 + + + + + + {{i + 1}} + {{data.couponName}} + ¥{{data.salesPrice}} + {{data.salesTime | date : 'yyyy-MM-dd HH:mm:ss'}} + {{data.convertUserPhone}} + {{data.status == 2?'待使用':'已使用'}} + + + + +
diff --git a/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.scss b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.spec.ts b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.spec.ts new file mode 100644 index 0000000..1e4bb30 --- /dev/null +++ b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OfflineAssignComponent } from './offline-assign.component'; + +describe('OfflineAssignComponent', () => { + let component: OfflineAssignComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OfflineAssignComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OfflineAssignComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.ts b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.ts new file mode 100644 index 0000000..65c2475 --- /dev/null +++ b/src/app/admin/gz-sinopec/offline-assign/offline-assign.component.ts @@ -0,0 +1,91 @@ +import { Component, OnInit } from '@angular/core'; +import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms'; +import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {TyAgentService} from '../../../services/ty-agent.service'; +import {CouponService} from "../../../services/coupon.service"; +import {environment} from "../../../../environments/environment"; + +@Component({ + selector: 'app-offline-assign', + templateUrl: './offline-assign.component.html', + styleUrls: ['./offline-assign.component.scss'] +}) +export class OfflineAssignComponent implements OnInit { + FILE_URL = environment.imageUrl; + + dataObject: any = {}; + tableLoading = true; + searchForm: FormGroup; + pageNum: number; + whereObject: any = {}; + + constructor(private modal: NzModalService, + private message: NzMessageService, + private couponService: CouponService, + private form: FormBuilder) { } + + ngOnInit(): void { + this.searchForm = this.form.group({ + couponName: [null], + status: [null], + assignTimeArray: [null], + }); + this.requestData(1); + } + + /** + * 请求数据 + */ + requestData(pageNum) { + this.tableLoading = true; + this.whereObject['pageNum'] = pageNum; + this.whereObject['pageSize'] = 10; + this.couponService.getGzSinopecAssignList(this.whereObject, data => { + if (data['return_code'] === '000000') { + this.dataObject = data['return_data']; + } else { + this.modal.error(data['return_msg']); + } + this.tableLoading = false; + }); + } + + /** + * 搜索 + * @param whereObject 条件 + */ + search(whereObject: object) { + if (whereObject['assignTimeArray'] != null && whereObject['assignTimeArray'].length > 0) { + whereObject['assignTimeS'] = new Date(whereObject['assignTimeArray'][0]).getTime(); + whereObject['assignTimeE'] = new Date(whereObject['assignTimeArray'][1]).getTime(); + } else { + whereObject['assignTimeS'] = null; + whereObject['assignTimeE'] = null; + } + this.whereObject = whereObject; + this.requestData(1); + } + + /** + * 重置 + */ + resetForm(): void { + this.searchForm.reset(); + } + + /** + * 导出数据 + */ + excelData() { + this.couponService.importGzSinopecAssign(this.whereObject, data => { + if (data['return_code'] === '000000') { + window.location.href = this.FILE_URL + 'temporary/' + data['return_data']; + } else { + this.modal.error({ + nzTitle: '提示', + nzContent: data['return_msg'] + }); + } + }); + } +} diff --git a/src/app/admin/gz-sinopec/use-order/use-order.component.html b/src/app/admin/gz-sinopec/use-order/use-order.component.html new file mode 100644 index 0000000..0be41f9 --- /dev/null +++ b/src/app/admin/gz-sinopec/use-order/use-order.component.html @@ -0,0 +1,80 @@ + + + + + +
+
+
+
+ + 卡券名称 + + + + +
+ +
+ + 分发时间 + + + + +
+
+ +
+
+ + +
+
+
+
+ +
+ 共计 {{dataObject.total?dataObject.total:0}} 条数据 +
+ +
+ + + + + + 序号 + 卡卷名称 + 卡券金额 + 分发时间 + 分发手机号 + 状态 + + + + + + {{i + 1}} + {{data.couponName}} + ¥{{data.salesPrice}} + {{data.salesTime | date : 'yyyy-MM-dd HH:mm:ss'}} + {{data.convertUserPhone}} + {{data.status == 2?'待使用':'已使用'}} + + + + +
diff --git a/src/app/admin/gz-sinopec/use-order/use-order.component.scss b/src/app/admin/gz-sinopec/use-order/use-order.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/gz-sinopec/use-order/use-order.component.spec.ts b/src/app/admin/gz-sinopec/use-order/use-order.component.spec.ts new file mode 100644 index 0000000..08b561e --- /dev/null +++ b/src/app/admin/gz-sinopec/use-order/use-order.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UseOrderComponent } from './use-order.component'; + +describe('UseOrderComponent', () => { + let component: UseOrderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ UseOrderComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(UseOrderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/gz-sinopec/use-order/use-order.component.ts b/src/app/admin/gz-sinopec/use-order/use-order.component.ts new file mode 100644 index 0000000..eb77271 --- /dev/null +++ b/src/app/admin/gz-sinopec/use-order/use-order.component.ts @@ -0,0 +1,91 @@ +import { Component, OnInit } from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms'; +import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {CouponService} from '../../../services/coupon.service'; + +@Component({ + selector: 'app-use-order', + templateUrl: './use-order.component.html', + styleUrls: ['./use-order.component.scss'] +}) +export class UseOrderComponent implements OnInit { + FILE_URL = environment.imageUrl; + + dataObject: any = {}; + tableLoading = true; + searchForm: FormGroup; + pageNum: number; + whereObject: any = {}; + + constructor(private modal: NzModalService, + private message: NzMessageService, + private couponService: CouponService, + private form: FormBuilder) { } + + ngOnInit(): void { + this.searchForm = this.form.group({ + couponName: [null], + status: [null], + assignTimeArray: [null], + }); + this.requestData(1); + } + + /** + * 请求数据 + */ + requestData(pageNum) { + this.tableLoading = true; + this.whereObject['status'] = 2; + this.whereObject['pageNum'] = pageNum; + this.whereObject['pageSize'] = 10; + this.couponService.getGzSinopecAssignList(this.whereObject, data => { + if (data['return_code'] === '000000') { + this.dataObject = data['return_data']; + } else { + this.modal.error(data['return_msg']); + } + this.tableLoading = false; + }); + } + + /** + * 搜索 + * @param whereObject 条件 + */ + search(whereObject: object) { + if (whereObject['assignTimeArray'] != null && whereObject['assignTimeArray'].length > 0) { + whereObject['assignTimeS'] = new Date(whereObject['assignTimeArray'][0]).getTime(); + whereObject['assignTimeE'] = new Date(whereObject['assignTimeArray'][1]).getTime(); + } else { + whereObject['assignTimeS'] = null; + whereObject['assignTimeE'] = null; + } + this.whereObject = whereObject; + this.requestData(1); + } + + /** + * 重置 + */ + resetForm(): void { + this.searchForm.reset(); + } + + /** + * 导出数据 + */ + excelData() { + this.couponService.importGzSinopecAssign(this.whereObject, data => { + if (data['return_code'] === '000000') { + window.location.href = this.FILE_URL + 'temporary/' + data['return_data']; + } else { + this.modal.error({ + nzTitle: '提示', + nzContent: data['return_msg'] + }); + } + }); + } +} diff --git a/src/app/admin/index/index-routing.module.ts b/src/app/admin/index/index-routing.module.ts index 5f8bf62..74da3ab 100644 --- a/src/app/admin/index/index-routing.module.ts +++ b/src/app/admin/index/index-routing.module.ts @@ -1,10 +1,12 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import {IndexComponent} from './index/index.component'; +import {TestComponent} from './test/test.component'; const routes: Routes = [ - { path: '', component: IndexComponent } + { path: '', component: IndexComponent }, + { path: 'test', component: TestComponent } ]; @NgModule({ diff --git a/src/app/admin/index/index.module.ts b/src/app/admin/index/index.module.ts index 5a685a4..a9c8c0c 100644 --- a/src/app/admin/index/index.module.ts +++ b/src/app/admin/index/index.module.ts @@ -12,10 +12,11 @@ import {RichtextModule} from '../../common/richtext/richtext.module'; import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; import {AppCommonModule} from '../../app-common.module'; +import { TestComponent } from './test/test.component'; @NgModule({ - declarations: [IndexComponent], + declarations: [IndexComponent, TestComponent], imports: [ CommonModule, SystemRoutingModule, diff --git a/src/app/admin/index/index/index.component.html b/src/app/admin/index/index/index.component.html index b6be464..4618094 100644 --- a/src/app/admin/index/index/index.component.html +++ b/src/app/admin/index/index/index.component.html @@ -7,9 +7,65 @@ +
+
+ + + + 记录 + + +
+


+ + + + + + + + + + + + + + + + + + + + + + +


+ + + + + + + + + + + + + + + + + + + + + + + +
-
@@ -126,7 +182,6 @@ -
@@ -139,3 +194,28 @@
+ + + + + + 编号 + 类型 + 交易金额 + 变更前金额 + 变更后金额 + 内容 + + + + + {{i+1}} + {{data.type == 1 ? '进账': '出账'}} + {{'¥' + data.amount}} + {{'¥' + data.beforeAmount}} + {{'¥' + data.afterAmount}} + {{data.sourceContent}} + + + + diff --git a/src/app/admin/index/index/index.component.ts b/src/app/admin/index/index/index.component.ts index c1cc6f1..4f38c5c 100644 --- a/src/app/admin/index/index/index.component.ts +++ b/src/app/admin/index/index/index.component.ts @@ -4,6 +4,7 @@ import {LocalStorageService} from '../../../services/local-storage.service'; import {IndexService} from '../../../services/index.service'; import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; import {environment} from '../../../../environments/environment'; +import {Router} from '_@angular_router@9.0.7@@angular/router'; @Component({ @@ -17,6 +18,7 @@ export class IndexComponent implements OnInit { loading = true; isVisible = false; isVisibleAdd = false; + isVisibleOil = false; balance: number; price: number; code = 60; @@ -24,29 +26,38 @@ export class IndexComponent implements OnInit { countData: any = {}; data: any = {}; orderData = {}; - balanceData = {}; + balanceData = { + amounts: 0 + }; rechargeData = {}; + gasCountData: any = { + history: {}, + today: {}, + }; + recordList = []; tyBalance; - + webSocket: WebSocket; + adminInfoObject: {}; constructor( private store: LocalStorageService, // 数据缓存 private message: NzMessageService, // 信息提示 + private router: Router, private index: IndexService ) { } ngOnInit(): void { + this.adminInfoObject = this.store.get(ADMIN_INFO_OBJECT); this.roleType = this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType; if (this.roleType === 1) { this.getIndexCount(); this.getLineCount(); this.queryCompanyAccountInfo2JD(); } - if (this.store.get(ADMIN_INFO_OBJECT)['highAgent'] != null) { this.code = this.store.get(ADMIN_INFO_OBJECT)['highAgent'].id; } - if (this.store.get(ADMIN_INFO_OBJECT)['bsCompany'].id === 3) { + if (this.store.get(ADMIN_INFO_OBJECT)['bsCompany'] != null && this.store.get(ADMIN_INFO_OBJECT)['bsCompany'].id === 3) { this.code = 60; this.getHLTBalance(); this.orderByIndex(); @@ -55,6 +66,12 @@ export class IndexComponent implements OnInit { this.HLTOrderByList(); } + if (this.store.get(ADMIN_INFO_OBJECT)['merchantStore'] != null) { + if (this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].type === 1) { + this.getGasStatistical(); + this.getGasAccount(); + } + } } // 查询余额 @@ -230,4 +247,52 @@ export class IndexComponent implements OnInit { }); } + // 查询油站预存余额 + public getGasAccount(): void { + this.index.getAccount(data => { + if (data['return_code'] === '000000') { + this.balanceData = data['return_data']; + this.loading = false; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 查询加油站统计 + public getGasStatistical(): void { + this.index.getGasStatistical(data => { + if (data['return_code'] === '000000') { + this.gasCountData = data['return_data']; + this.getGasAccountRecord(); + this.loading = false; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 查询预存账户油站记录 + public getGasAccountRecord(): void { + const paramsObject = { + pageNum: 1, + pageSize: 10000 + }; + this.index.getAccountRecordList(paramsObject, data => { + if (data['return_code'] === '000000') { + this.recordList = data['return_data'].list; + } else { + this.message.error(data['return_msg']); + } + }); + } + + public edit(ids) { + this.router.navigate(['/admin/index/test'], { + queryParams: { + id: ids + } + }).then(r => console.log(r)); + } } + diff --git a/src/app/admin/index/test/test.component.html b/src/app/admin/index/test/test.component.html new file mode 100644 index 0000000..559660c --- /dev/null +++ b/src/app/admin/index/test/test.component.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/admin/index/test/test.component.scss b/src/app/admin/index/test/test.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/index/test/test.component.ts b/src/app/admin/index/test/test.component.ts new file mode 100644 index 0000000..69f906f --- /dev/null +++ b/src/app/admin/index/test/test.component.ts @@ -0,0 +1,71 @@ +import { Component, OnInit } from '@angular/core'; +import {ActivatedRoute} from '_@angular_router@9.0.7@@angular/router'; +import {Params} from '@angular/router'; +import {WebsocketService} from '../../../services/websocket.service'; + +export enum SEND_TYPE { + ALL = 'all', + SINGLE = 'single' +} +@Component({ + selector: 'app-test', + templateUrl: './test.component.html', + styleUrls: ['./test.component.scss'] +}) +export class TestComponent implements OnInit { + + messages = []; // 消息列表 + message; // 发送的消息内容 + error: any; // 异常信息 + completed = false; // 发送完成 + type = SEND_TYPE.ALL; // 默认类型发送给所有人 + users = []; // 登陆的用户 + sendToUser; // 需要发送消息的用户 + currentUser; // 当前用户 + + constructor( + private webSocketService: WebsocketService, + private activatedRoute: ActivatedRoute + ) { + + this.activatedRoute.queryParams.subscribe(queryParams => { + console.log(queryParams.id); + this.currentUser = queryParams.id; + }); + } + + ngOnInit(): void { + console.log(this.currentUser); + // 连接websocket + // this.webSocketService.connect(`ws://139.159.177.244:9302/brest/WebSocket/` + this.currentUser); + // 接收消息 + this.webSocketService.messageSubject.subscribe( + data => { + // 如果是用户登陆,则添加到登陆列表中 + if (data.users) { + this.users = data.users; + } else { + // 否则添加到消息列表 + this.messages.push(data.msg); + } + }, + err => this.error = err, + () => this.completed = true + ); + } + + // send() { + // // 创建消息对象 + // const msg = { + // msg: this.message, // 消息内容 + // type: this.type === SEND_TYPE.ALL ? SEND_TYPE.ALL : SEND_TYPE.SINGLE, // 类型 + // to: this.type === SEND_TYPE.SINGLE ? this.sendToUser : undefined // 要发送的对象 + // }; + // // 发送 + // this.webSocketService.sendMessage(JSON.stringify(msg)); + // // 发送完成,情况message内容 + // this.message = ''; + // } + + +} diff --git a/src/app/admin/merchant-store/merchant-store-routing.module.ts b/src/app/admin/merchant-store/merchant-store-routing.module.ts index d2468cb..7f0d1b4 100644 --- a/src/app/admin/merchant-store/merchant-store-routing.module.ts +++ b/src/app/admin/merchant-store/merchant-store-routing.module.ts @@ -3,12 +3,16 @@ import { Routes, RouterModule } from '@angular/router'; import {StoreListComponent} from './store-list/store-list.component'; import {StoreEditComponent} from './store-edit/store-edit.component'; import {StoreDetailComponent} from './store-detail/store-detail.component'; +import {OliComponent} from './oli/oli.component'; +import {OliGunComponent} from './oli-gun/oli-gun.component'; const routes: Routes = [ { path: 'store-list', component: StoreListComponent }, { path: 'store-edit', component: StoreEditComponent }, { path: 'store-detail', component: StoreDetailComponent }, + { path: 'oil', component: OliComponent }, + { path: 'oil_gun', component: OliGunComponent }, ]; @NgModule({ diff --git a/src/app/admin/merchant-store/merchant-store.module.ts b/src/app/admin/merchant-store/merchant-store.module.ts index 3603174..e7b5e11 100644 --- a/src/app/admin/merchant-store/merchant-store.module.ts +++ b/src/app/admin/merchant-store/merchant-store.module.ts @@ -9,18 +9,22 @@ 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 { OliComponent } from './oli/oli.component'; +import { OliGunComponent } from './oli-gun/oli-gun.component'; +import {AppCommonModule} from "../../app-common.module"; @NgModule({ - declarations: [StoreListComponent, StoreEditComponent, StoreDetailComponent], - imports: [ - CommonModule, - MerchantStoreRoutingModule, - NgZorroAntdModule, - SeparateModule, - ReactiveFormsModule, - FormsModule, - BreadcrumbModule - ] + declarations: [StoreListComponent, StoreEditComponent, StoreDetailComponent, OliComponent, OliGunComponent], + imports: [ + CommonModule, + MerchantStoreRoutingModule, + NgZorroAntdModule, + SeparateModule, + ReactiveFormsModule, + FormsModule, + BreadcrumbModule, + AppCommonModule + ] }) export class MerchantStoreModule { } diff --git a/src/app/admin/merchant-store/oli-gun/oli-gun.component.html b/src/app/admin/merchant-store/oli-gun/oli-gun.component.html new file mode 100644 index 0000000..396d8da --- /dev/null +++ b/src/app/admin/merchant-store/oli-gun/oli-gun.component.html @@ -0,0 +1 @@ +

oli-gun works!

diff --git a/src/app/admin/merchant-store/oli-gun/oli-gun.component.scss b/src/app/admin/merchant-store/oli-gun/oli-gun.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/merchant-store/oli-gun/oli-gun.component.spec.ts b/src/app/admin/merchant-store/oli-gun/oli-gun.component.spec.ts new file mode 100644 index 0000000..358df11 --- /dev/null +++ b/src/app/admin/merchant-store/oli-gun/oli-gun.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OliGunComponent } from './oli-gun.component'; + +describe('OliGunComponent', () => { + let component: OliGunComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OliGunComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OliGunComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/merchant-store/oli-gun/oli-gun.component.ts b/src/app/admin/merchant-store/oli-gun/oli-gun.component.ts new file mode 100644 index 0000000..664f9f6 --- /dev/null +++ b/src/app/admin/merchant-store/oli-gun/oli-gun.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-oli-gun', + templateUrl: './oli-gun.component.html', + styleUrls: ['./oli-gun.component.scss'] +}) +export class OliGunComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/admin/merchant-store/oli/oli.component.html b/src/app/admin/merchant-store/oli/oli.component.html new file mode 100644 index 0000000..fb3e56c --- /dev/null +++ b/src/app/admin/merchant-store/oli/oli.component.html @@ -0,0 +1,149 @@ + + + + + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + + 编号 + 油品类型 + 油品 + 国标价 + 油站价 + 优惠价 + 优惠幅度 + 操作 + + + + + {{i + 1}} + {{data.oilTypeName}} + {{data.oilNoName}} + {{data.priceOfficial == null ? '暂无' : '¥' + data.priceOfficial}} + {{data.priceGun == null ? '暂无' : '¥' + data.priceGun}} + {{data.priceVip == null ? '暂无' : '¥' + data.priceVip}} + {{data.preferentialMargin == null ? '暂无' : '¥' + data.preferentialMargin}} + + 查看油枪 + + 配置油枪 + + 删除 + + + +
+ + +
+
+ + 油品 + + + + + + +
+
+ + +
+ + + + + + 序号 + 油枪号 + 油号类型 + 油号 + 操作 + + + + + {{ i + 1}} + {{data.gunNo}} + {{data.oilTypeName}} + {{data.oilNo}} + + 删除 + + + + + + + +
+
+ + 油枪号 + + + + +
+
+
+ diff --git a/src/app/admin/merchant-store/oli/oli.component.scss b/src/app/admin/merchant-store/oli/oli.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/merchant-store/oli/oli.component.ts b/src/app/admin/merchant-store/oli/oli.component.ts new file mode 100644 index 0000000..d07563e --- /dev/null +++ b/src/app/admin/merchant-store/oli/oli.component.ts @@ -0,0 +1,213 @@ +import {Component, OnInit} from '@angular/core'; +import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; +import {environment} from '../../../../environments/environment'; +import {MerchantStoreService} from '../../../services/merchant-store.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {ActivatedRoute, Router} from '_@angular_router@9.0.7@@angular/router'; +import {CommonsService} from '../../../services/commons.service'; +import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; +import {LocalStorageService} from '../../../services/local-storage.service'; + +@Component({ + selector: 'app-oli', + templateUrl: './oli.component.html', + styleUrls: ['./oli.component.scss'] +}) +export class OliComponent implements OnInit { + validateForm!: FormGroup; + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + id = null; + name: string; + WEB_SERVE_URL = environment.baseUrl; + isVisible = false; + oilGunVisible = false; + oilVisible = false; + gasOilType = []; + oilGunList = []; + oilNo; + gunNo; + formatterPercent = (value: number) => `¥ ${value == null ? 0 : value}`; + parserPercent = (value: string) => value.replace('¥ ', ''); + + constructor( + private form: FormBuilder, + private merchantStore: MerchantStoreService, + private iconService: IconService, + private message: NzMessageService, + private store: LocalStorageService, // 数据请求 + private router: Router, + private fb: FormBuilder, + private commonsService: CommonsService, + private modal: NzModalService, + private activatedRoute: ActivatedRoute, + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + this.validateForm = this.fb.group({ + storeId: [this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].id, [Validators.required]], + priceGun: [null, [Validators.required]], + preferentialMargin: [0], + + }); + } + + public init(): void { + this.commonsService.getDictionary('GAS_OIL_TYPE', data => { + this.gasOilType = data['return_data']; + }); + this.getRequest(true, {}); + } + + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['storeId'] = this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].id; + this.merchantStore.getOilPriceListByStore(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data']; + this.total = data['return_data'].length; + } else { + this.message.error(data['return_msg']); + } + }); + + + } + + + // 是否删除油品 + public getDelete(oilNo): void { + const message = '是否删除油品'; + this.common.showConfirm(message, data => { + if (data) { + this.merchantStore.delOilPrice({ + storeId: this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].id, + oilNo: oilNo + }, dataReturn => { + if (dataReturn['return_code'] === '000000') { + this.message.success('操作成功'); + this.getRequest(false, {}); + } else { + this.message.warning(dataReturn['return_msg']); + } + }); + } + }); + } + + // 编辑油品 + public editGasOilPrice(): void { + if (this.oilNo == null) { + this.message.error('请选择油品!'); + return; + } + + // 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.validateForm.value.preferentialMargin == null) { + this.validateForm.value.preferentialMargin = 0; + } + this.validateForm.value.oilNo = this.oilNo; + this.merchantStore.editGasOilPrice(this.validateForm.value, data => { + if (data['return_code'] === '000000') { + this.isVisible = false; + this.getRequest(true, {}); + this.message.success('编辑成功'); + } else { + this.message.warning(data['return_msg']); + } + }); + } + + // 获取油站油品价格 + public getOilPriceDetail(e): void { + const whereObject = { + storeId: this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].id, + oilNo: e + }; + this.merchantStore.getOilPriceDetail(whereObject, data => { + if (data['return_code'] === '000000') { + this.validateForm.patchValue(data['return_data']); + } else { + this.message.warning(data['return_msg']); + } + + }); + } + + // 配置油品油枪 + public getGunNoListByOilPrice(id): void { + this.id = id; + this.merchantStore.getGunNoListByOilPrice(id , data => { + if (data['return_code'] === '000000') { + this.oilGunList = data['return_data']; + this.oilGunVisible = true; + } else { + this.message.warning(data['return_msg']); + } + }); + } + + // 是否删除油枪列表 + public delGunNo(id): void { + const message = '是否删除油枪'; + this.common.showConfirm(message, data => { + if (data) { + this.merchantStore.delGunNo({ + gunNoId: id + }, dataReturn => { + if (dataReturn['return_code'] === '000000') { + this.message.success('操作成功'); + this.getGunNoListByOilPrice(this.id); + } else { + this.message.warning(dataReturn['return_msg']); + } + }); + } + }); + } + + // 配置油枪号 + public addGasOilPrice(): void { + if (this.gunNo == null) { + this.message.error('请输入油枪号'); + return; + } + this.merchantStore.addGasOilPrice({ + oilPriceId: this.id, + gunNo: this.gunNo + } , data => { + if (data['return_code'] === '000000') { + this.message.success('操作成功'); + this.oilVisible = false; + } else { + this.message.warning(data['return_msg']); + } + }); + } + + public getGasOilPrice(id): void { + this.id = id; + this.oilVisible = true; + } +} diff --git a/src/app/admin/merchant-store/store-detail/store-detail.component.html b/src/app/admin/merchant-store/store-detail/store-detail.component.html index 18ed2bc..98eaade 100644 --- a/src/app/admin/merchant-store/store-detail/store-detail.component.html +++ b/src/app/admin/merchant-store/store-detail/store-detail.component.html @@ -1,6 +1,17 @@ + + + + 门店管理 + + + 门店详情 + + + +
- {{data.telephone}} + {{data['secUser'].loginName}} {{data['storeKey']}} {{data.storeName}} {{data.address}} diff --git a/src/app/admin/merchant-store/store-detail/store-detail.component.ts b/src/app/admin/merchant-store/store-detail/store-detail.component.ts index 8f1ac20..6936d92 100644 --- a/src/app/admin/merchant-store/store-detail/store-detail.component.ts +++ b/src/app/admin/merchant-store/store-detail/store-detail.component.ts @@ -1,40 +1,47 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {MerchantStoreService} from '../../../services/merchant-store.service'; @Component({ - selector: 'app-store-detail', - templateUrl: './store-detail.component.html', - styleUrls: ['./store-detail.component.scss'] + selector: 'app-store-detail', + templateUrl: './store-detail.component.html', + styleUrls: ['./store-detail.component.scss'] }) export class StoreDetailComponent implements OnInit { - data: any = {}; - id: number; - constructor( - private merchantStore: MerchantStoreService, - private message: NzMessageService, // 信息提示 - private activatedRoute: ActivatedRoute, - ) { } - - ngOnInit(): void { - this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.storeId != null) { - this.id = queryParams.storeId; - this.getDetails(queryParams.storeId); - } - }); - } - - // 查询详情 - public getDetails(id: number) { - this.merchantStore.getMerchantStoreById(id , data => { - this.data = data['return_data']; - - }); - } - + data: any = {}; + id: number; + + constructor( + private merchantStore: MerchantStoreService, + private message: NzMessageService, // 信息提示 + private activatedRoute: ActivatedRoute, + ) { + } + + ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.storeId != null) { + this.id = queryParams.storeId; + this.getDetails(queryParams.storeId); + } + }); + } + + // 查询详情 + public getDetails(id: number) { + this.merchantStore.getMerchantStoreById(id, data => { + console.log(data); + this.data = data['return_data']; + + }); + } + + // 返回 + getBack() { + history.back(); + } } diff --git a/src/app/admin/merchant-store/store-edit/store-edit.component.html b/src/app/admin/merchant-store/store-edit/store-edit.component.html index 3e9f81c..5777f41 100644 --- a/src/app/admin/merchant-store/store-edit/store-edit.component.html +++ b/src/app/admin/merchant-store/store-edit/store-edit.component.html @@ -10,120 +10,173 @@ -
-
-
- - 登录手机号 - - - - -
-
- - 登录密码 - - - - - - - - - -
-
- - 门店编号 - - - - -
-
- - 门店LOGO - - - -
上传LOGO
-
- - - - - -
-
-
-
- - 门店名称 - - - - -
-
- - 地址维度 - - - - -
-
- - 地址经度 - - - - -
-
- - 门店地址 - - - - -
-
- - 设置定位 - -
-
- - - - - - - -
- -
- -
-
-
-
+
+
+
+ +
+ + +
+ + 门店名称 + + + + +
+
+ + 门店品牌 + + + + + + +
+
+ + 预存类型 + + + + + + + +
+
+ + 门店类型 + + + + + + +
+
+ + 联系人 + + + + +
+
+ + 联系电话 + + + + +
+
+ + 门店照片 + + + +
上传LOGO
+
+ + + + + +
+
+
+ +
+ + 打印机编号 + + + + +
+
+ + 打印机KEY + + + + +
+
+ + 打印机名称 + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + 门店地址 + + + + +
+
+ + 设置定位 + +
+
+ + + + + + + +
+ +
+ +
+
+
+
+
-
-
-
- - +
+
+ + +
-
- + +
+
+
diff --git a/src/app/admin/merchant-store/store-edit/store-edit.component.ts b/src/app/admin/merchant-store/store-edit/store-edit.component.ts index 372f5d0..32b53e4 100644 --- a/src/app/admin/merchant-store/store-edit/store-edit.component.ts +++ b/src/app/admin/merchant-store/store-edit/store-edit.component.ts @@ -6,6 +6,7 @@ import {NzMessageService, NzUploadFile} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {ValidatorsService} from '../../../services/validators.service'; import {MerchantStoreService} from '../../../services/merchant-store.service'; +import {CommonsService} from "../../../services/commons.service"; declare var AMap: any; // 一定要声明AMap,要不然报错找不到AMap declare var AMapUI: any; @@ -35,15 +36,16 @@ export class StoreEditComponent implements OnInit { WEB_SERVE_URL = environment.baseUrl; previewVisible = false; previewImage: string | undefined = ''; + brandData = []; constructor( private fb: FormBuilder, private merchantStore: MerchantStoreService, private message: NzMessageService, // 信息提示 + private commonsService: CommonsService, private activatedRoute: ActivatedRoute, ) { } - ngOnInit(): void { this.activatedRoute.queryParams.subscribe(queryParams => { if (queryParams.storeId != null) { @@ -55,19 +57,23 @@ export class StoreEditComponent implements OnInit { } }); this.validateForm = this.fb.group({ - telephone: [null, [Validators.required, ValidatorsService.mobile]], - password: [null, [Validators.required, ValidatorsService.minLength(6)]], - storeKey: [null, [Validators.required, ValidatorsService.maxLength(10)]], storeName: [null, [Validators.required]], address: [null, [Validators.required]], + contactName: [null, [Validators.required]], + prestoreType: [null, [Validators.required]], + telephone: [null, [Validators.required]], latitude: [29.553134, [Validators.required]], longitude: [106.565428, [Validators.required]], - status: [null], - companyId: [null], + deviceSn: [null], + deviceKey: [null], + deviceName: [null], regionId: [null], - merchantId: [null], - createTime: [null], - secUser: {}, + brandId: [null], + type: [null], + }); + + this.commonsService.getDictionary('MERCHANT_STORE_BRANCH', data => { + this.brandData = data['return_data']; }); } @@ -103,8 +109,6 @@ export class StoreEditComponent implements OnInit { return; } } - this.validateForm.value['secUser']['telephone'] = this.validateForm.value.telephone; - this.validateForm.value['secUser']['password'] = this.validateForm.value.password; if (this.logoFile.length !== 0) { if (this.logoFile[0]['response'] != null) { this.validateForm.value.storeLogo = this.logoFile[0]['response']['return_data'][0]; @@ -138,8 +142,9 @@ export class StoreEditComponent implements OnInit { public getDetails(id) { this.merchantStore.getMerchantStoreById(id, data => { if (data['return_code'] === '000000') { - data['return_data'].telephone = data['return_data'].secUser.loginName; - data['return_data'].password = data['return_data'].secUser.password; + console.log(data); + data['return_data']['brandId'] = String(data['return_data']['brandId']); + data['return_data']['type'] = String(data['return_data']['type']); if (data['return_data']['storeLogo'] != null && data['return_data']['storeLogo'] !== '') { const logo = String(data['return_data']['storeLogo']); const logoArray = []; @@ -164,7 +169,6 @@ export class StoreEditComponent implements OnInit { getMap() { // tslint:disable-next-line:variable-name AMapUI.loadUI(['misc/PositionPicker'], PositionPicker => { - console.log(this.validateForm.value); const map = new AMap.Map('container', { resizeEnable: true, scrollWheel: false, @@ -194,7 +198,6 @@ export class StoreEditComponent implements OnInit { map: map }); positionPicker.on('success', positionResult => { - console.log(positionResult); positionResult['latitude'] = positionResult.position.lat; positionResult['longitude'] = positionResult.position.lng; positionResult['regionId'] = positionResult.regeocode.addressComponent.adcode; diff --git a/src/app/admin/merchant-store/store-list/store-list.component.html b/src/app/admin/merchant-store/store-list/store-list.component.html index 836925b..5bcf915 100644 --- a/src/app/admin/merchant-store/store-list/store-list.component.html +++ b/src/app/admin/merchant-store/store-list/store-list.component.html @@ -75,7 +75,7 @@ 门店名称 门店电话 创建时间 - 操作 + 操作 @@ -87,11 +87,13 @@ {{data.telephone}} {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} - + 编辑 - + 详情 - + 增加余额 + + 删除 @@ -122,3 +124,16 @@ + + +
+
+ + 充值金额 + + + + +
+
+
diff --git a/src/app/admin/merchant-store/store-list/store-list.component.ts b/src/app/admin/merchant-store/store-list/store-list.component.ts index 336dd01..6adb50d 100644 --- a/src/app/admin/merchant-store/store-list/store-list.component.ts +++ b/src/app/admin/merchant-store/store-list/store-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {FormBuilder, FormGroup} from '@angular/forms'; import {IconService} from '../../../services/icon.service'; import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd'; @@ -6,170 +6,201 @@ import {ActivatedRoute, Router} from '@angular/router'; import {CommonsService} from '../../../services/commons.service'; import {MerchantStoreService} from '../../../services/merchant-store.service'; import {environment} from '../../../../environments/environment'; +import {IndexService} from '../../../services/index.service'; @Component({ - selector: 'app-store-list', - templateUrl: './store-list.component.html', - styleUrls: ['./store-list.component.scss'] + selector: 'app-store-list', + templateUrl: './store-list.component.html', + styleUrls: ['./store-list.component.scss'] }) export class StoreListComponent implements OnInit { - searchForm: FormGroup; // 搜索框 - requestData = []; // 列表数据 - total: number; // 页码 - pageNum = 1; // 页码 - pageSize = 10; // 条码 - loading = true; - id = null; - name: string; - WEB_SERVE_URL = environment.baseUrl; - importErrorStudentArray = []; - errorStudentVisible = false; - isSpinning = false; - - constructor( - private form: FormBuilder, - private merchantStore: MerchantStoreService, - private iconService: IconService, - private message: NzMessageService, - private router: Router, - private modal: NzModalService, - private activatedRoute: ActivatedRoute, - private common: CommonsService - ) { - } - - ngOnInit(): void { - this.init(); - - } - - public init(): void { - this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.merchantId != null) { - this.id = queryParams.merchantId; - this.name = queryParams.name; - } - }); - this.searchForm = this.form.group({ - storeName: [null], - telephone: [null], - }); - this.getRequest(true, this.searchForm.value); - } - - - // 查询列表 - public getRequest(reset: boolean = false, whereObject: object) { - - this.loading = false; - if (reset) { - this.pageNum = 1; + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + id = null; + storeId = null; + name: string; + price: string; + WEB_SERVE_URL = environment.baseUrl; + importErrorStudentArray = []; + errorStudentVisible = false; + isVisibleAdd = false; + isSpinning = false; + + constructor( + private form: FormBuilder, + private merchantStore: MerchantStoreService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private index: IndexService, + private modal: NzModalService, + private activatedRoute: ActivatedRoute, + private common: CommonsService + ) { } - whereObject['pageNum'] = this.pageNum; - whereObject['pageSize'] = this.pageSize; - if (this.id == null) { - this.merchantStore.getStoreListByMerchant(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']); + + ngOnInit(): void { + this.init(); + + } + + public init(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.merchantId != null) { + this.id = queryParams.merchantId; + this.name = queryParams.name; + } + }); + this.searchForm = this.form.group({ + storeName: [null], + telephone: [null], + }); + this.getRequest(true, this.searchForm.value); + } + + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; } - }); - } else { - whereObject['merchantId'] = this.id; - this.merchantStore.getStoreListByCompany(whereObject, data => { - if (data['return_code'] === '000000') { - this.requestData = data['return_data'].list; - this.total = data['return_data'].total; + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + if (this.id == null) { + this.merchantStore.getStoreListByMerchant(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']); + } + }); } else { - this.message.error(data['return_msg']); + whereObject['merchantId'] = this.id; + this.merchantStore.getStoreListByCompany(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 resetForm(): void { - this.searchForm.reset(); - } - - // 禁用门店 - public getDelete(id): void { - const message = '是否删除门店'; - this.common.showConfirm(message, data => { - if (data) { - this.merchantStore.deleteMerchantStore(id, dataReturn => { - if (dataReturn['return_code'] === '000000') { - this.message.success('操作成功'); - this.getRequest(false , this.searchForm.value); - } else { - this.message.warning(dataReturn['return_msg']); - } + // 禁用门店 + public getDelete(id): void { + const message = '是否删除门店'; + this.common.showConfirm(message, data => { + if (data) { + this.merchantStore.deleteMerchantStore(id, dataReturn => { + if (dataReturn['return_code'] === '000000') { + this.message.success('操作成功'); + this.getRequest(false, this.searchForm.value); + } else { + this.message.warning(dataReturn['return_msg']); + } + }); + } }); - } - }); - } - - // 修改 - public getEdit(id: number): void { - this.router.navigate(['/admin/merchantStore/store-edit'], { - queryParams: { - storeId: id - } - }).then(r => console.log(r)); - } - - // 查看详情 - public getDetail(id: number): void { - this.router.navigate(['/admin/merchantStore/store-detail'], { - queryParams: { - storeId: id - } - }).then(r => console.log(r)); - } - - handleCancelError(): void { - this.errorStudentVisible = false; - } - - handleChange(info: NzUploadChangeParam): void { - this.isSpinning = true; - if (info.file.status !== 'uploading') { - console.log(info.file, info.fileList); } - if (info.file.status === 'done') { - if (info.file.response.return_code === '000000') { - this.loading = false; - this.isSpinning = false; - if (info.file.response.return_data.errorTotal === 0) { - this.message.success('导入成功'); - this.getRequest(true, this.searchForm.value); - } else { - this.modal.warning({ - nzTitle: '提示', - nzOkText: '查看失败数据', - nzContent: '只有部分数据导入成功', - nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) - }); + + // 修改 + public getEdit(id: number): void { + this.router.navigate(['/admin/merchantStore/store-edit'], { + queryParams: { + storeId: id + } + }).then(r => console.log(r)); + } + + // 查看详情 + public getDetail(id: number): void { + this.router.navigate(['/admin/merchantStore/store-detail'], { + queryParams: { + storeId: id + } + }).then(r => console.log(r)); + } + + handleCancelError(): void { + this.errorStudentVisible = false; + } + + handleChange(info: NzUploadChangeParam): void { + this.isSpinning = true; + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); } - } else { - this.isSpinning = false; - this.loading = false; - this.message.error(info.file.response.return_msg); - } - } else if (info.file.status === 'error') { - this.message.error('上传错误'); + if (info.file.status === 'done') { + if (info.file.response.return_code === '000000') { + this.loading = false; + this.isSpinning = false; + if (info.file.response.return_data.errorTotal === 0) { + this.message.success('导入成功'); + this.getRequest(true, this.searchForm.value); + } else { + this.modal.warning({ + nzTitle: '提示', + nzOkText: '查看失败数据', + nzContent: '只有部分数据导入成功', + nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) + }); + } + } else { + this.isSpinning = false; + this.loading = false; + this.message.error(info.file.response.return_msg); + } + } else if (info.file.status === 'error') { + this.message.error('上传错误'); + } + } + + // 打开模态框 + showErrorStudentModal(data: []) { + this.getRequest(true, this.searchForm.value); + this.importErrorStudentArray = data['errorData']; + this.errorStudentVisible = true; + } + + // 增加余额 + public getRecharge(id): void { + this.storeId = id; + this.isVisibleAdd = true; + } + + + handleOk(): void { + if (this.price == null) { + this.message.error('请输入充值金额'); + return; + } + const paramsObject = { + storeId: this.storeId, + amount: this.price + }; + this.index.recharge(paramsObject, data => { + if (data['return_code'] === '000000') { + this.getRequest(false, this.searchForm.value); + this.isVisibleAdd = false; + } else { + this.message.error(data['return_msg']); + } + }); } - } - - // 打开模态框 - showErrorStudentModal(data: []) { - this.getRequest(true, this.searchForm.value); - this.importErrorStudentArray = data['errorData']; - this.errorStudentVisible = true; - } } diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.html b/src/app/admin/merchant/merchant-detail/merchant-detail.component.html index 31ec073..96dab30 100644 --- a/src/app/admin/merchant/merchant-detail/merchant-detail.component.html +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.html @@ -1,3 +1,14 @@ + + + + 商户管理 + + + 商户详情 + + + +
diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts index dd25626..279914c 100644 --- a/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts @@ -1,39 +1,46 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {MerchantService} from '../../../services/merchant.service'; import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {environment} from '../../../../environments/environment'; @Component({ - selector: 'app-merchant-detail', - templateUrl: './merchant-detail.component.html', - styleUrls: ['./merchant-detail.component.scss'] + selector: 'app-merchant-detail', + templateUrl: './merchant-detail.component.html', + styleUrls: ['./merchant-detail.component.scss'] }) export class MerchantDetailComponent implements OnInit { - data: any = {}; - id: number; - FILE_URL = environment.imageUrl; - constructor( - private merchant: MerchantService, - private message: NzMessageService, // 信息提示 - private activatedRoute: ActivatedRoute, - ) { } + data: any = {}; + id: number; + FILE_URL = environment.imageUrl; - ngOnInit(): void { - this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.merchantId != null) { - this.id = queryParams.merchantId; - this.getDetails(queryParams.merchantId); - } - }); - } + constructor( + private merchant: MerchantService, + private message: NzMessageService, // 信息提示 + private activatedRoute: ActivatedRoute, + ) { + } - // 查询详情 - public getDetails(id: number) { - this.merchant.getMerchantById(id , data => { - this.data = data['return_data']; - }); - } + ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.merchantId != null) { + this.id = queryParams.merchantId; + this.getDetails(queryParams.merchantId); + } + }); + } + + // 查询详情 + public getDetails(id: number) { + this.merchant.getMerchantById(id, data => { + this.data = data['return_data']; + }); + } + + // 返回 + getBack() { + history.back(); + } } diff --git a/src/app/admin/navigation/navigation.component.ts b/src/app/admin/navigation/navigation.component.ts index e583df5..3c7a236 100644 --- a/src/app/admin/navigation/navigation.component.ts +++ b/src/app/admin/navigation/navigation.component.ts @@ -1,6 +1,14 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {LocalStorageService} from '../../services/local-storage.service'; -import {DATA, ROUTENAME, MENUNAME, CHILDMENUNAME, INIT_FLAG, ADMIN_INFO_OBJECT, TOKEN} from '../../services/local-storage.namespace'; +import { + DATA, + ROUTENAME, + MENUNAME, + CHILDMENUNAME, + INIT_FLAG, + ADMIN_INFO_OBJECT, + TOKEN +} from '../../services/local-storage.namespace'; import {LoginService} from '../../services/login.service'; import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {Router} from '@angular/router'; @@ -12,164 +20,172 @@ import {Md5} from 'ts-md5'; import {environment} from '../../../environments/environment'; import {HttpClient} from '@angular/common/http'; import {CompanyTwoPwdService} from '../../services/company-two-pwd.service'; +import {WebsocketService} from '../../services/websocket.service'; @Component({ - selector: 'app-navigation', - templateUrl: './navigation.component.html', - styleUrls: ['./navigation.component.less'] + selector: 'app-navigation', + templateUrl: './navigation.component.html', + styleUrls: ['./navigation.component.less'], }) export class NavigationComponent implements OnInit { - visibleUpdatePwd = false; // 修改密码抽屉 - validateForm: FormGroup; // 定义表单 - passwordVisible = false; - - isCollapsed = false; - userInfo: any; - menuList: any; - routeName: string; - switchValue = false; - constructor( - private storage: LocalStorageService, - private loginService: LoginService, - private message: NzMessageService, - private commonsService: CommonsService, - private companyTwoPwdService: CompanyTwoPwdService, - private http: HttpClient, // http请求 - private iconService: IconService, - private modal: NzModalService, - private fb: FormBuilder, // 表单 - private router: Router, - ) { } - - ngOnInit(): void { - this.validateForm = this.fb.group({ - oldPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], - newPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], - checkNewPassword: [null, [Validators.required, this.checkPwd]], - }); - - this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME); - this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT); - this.commonsService.mappingSysNameOl('RECHARGE', data => { - this.switchValue = data['return_data']['codeValue'] === '1'; - }); - this.menuList = this.storage.getList(ADMIN_INFO_OBJECT)['menuList']; // 定义菜单数据 - } - - public activeLi(routeName): void { - this.routeName = routeName; - this.storage.set(ROUTENAME, routeName); - } - - // 菜单姓名 - public getRouteName(menuName , childMenuName): void { - this.storage.set(MENUNAME, menuName); - this.storage.set(CHILDMENUNAME, childMenuName); - } - - // 登出 - public loginOut(): void { - this.loginService.loginOut(data => { - if (data.return_code === '000000') { - this.storage.set(ADMIN_INFO_OBJECT, null); - this.storage.set(INIT_FLAG, false); - this.storage.set(TOKEN, null); - this.router.navigateByUrl('/adminLogin').then(); - } else { - this.message.warning(data.return_msg); - } - }); - } - - // 返回 - public getBack(): void { - history.back(); - } - - clickSwitch(): void { - this.switchValue = !this.switchValue; - this.commonsService.updateDictionary('RECHARGE' , this.switchValue === true ? '1' : '0' , data => { - if (data['return_code'] === '000000') { - this.message.success(data['return_data']); - } else { - this.message.error(data['return_msg']); - } - }); - } - - // 打开抽屉 - openUpdatePwd(): void { - this.visibleUpdatePwd = true; - } - - // 关闭抽屉 - closeUser(): void { - this.visibleUpdatePwd = false; - } - - // 提交表单 - submitForm(value): void { - // 表单验证 - // tslint:disable-next-line:forin - for (const i in this.validateForm.controls) { - this.validateForm.controls[i].markAsDirty(); - this.validateForm.controls[i].updateValueAndValidity(); + visibleUpdatePwd = false; // 修改密码抽屉 + validateForm: FormGroup; // 定义表单 + passwordVisible = false; + + isCollapsed = false; + userInfo: any; + menuList: any; + routeName: string; + switchValue = false; + + constructor( + private storage: LocalStorageService, + private loginService: LoginService, + private message: NzMessageService, + private commonsService: CommonsService, + private companyTwoPwdService: CompanyTwoPwdService, + private http: HttpClient, // http请求 + private iconService: IconService, + private webSocketService: WebsocketService, + private store: LocalStorageService, // 数据请求 + private modal: NzModalService, + private fb: FormBuilder, // 表单 + private router: Router, + ) { } - if (this.validateForm.status == null || this.validateForm.status !== 'VALID') { - this.modal.info({ - nzTitle: '提示', - nzContent: '请正确填写必填信息', - }); - return; + + ngOnInit(): void { + this.validateForm = this.fb.group({ + oldPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], + newPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], + checkNewPassword: [null, [Validators.required, this.checkPwd]], + }); + + this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME); + this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT); + this.commonsService.mappingSysNameOl('RECHARGE', data => { + this.switchValue = data['return_data']['codeValue'] === '1'; + }); + this.menuList = this.storage.getList(ADMIN_INFO_OBJECT)['menuList']; // 定义菜单数据 + + // 连接websocket + // this.webSocketService.connect(`wss://hsgcs.dctpay.com/msg/WebSocket/` + this.store.get(ADMIN_INFO_OBJECT)['merchantStore'].id); + } - const timeNum = new Date().getTime(); - const signStr = 'userId=' + this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id + '&newPassword=' + value.newPassword + '&nonceStr=' + timeNum; - // 定义请求数据 - const params = { - userId: this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id, - oldPassword: value.oldPassword, - newPassword: value.newPassword, - nonceStr: timeNum, - sign: String(Md5.hashStr(signStr)).toLocaleUpperCase(), - }; - this.http.post(environment.baseUrl + '/secUser/sendUserPass', params).subscribe(data => { - if (data['return_code'] === '000000') { - this.modal.success({ - nzTitle: '提示', - nzContent: '密码修改成功', - nzOkText: '重新登录', - nzOkType: 'primary', - nzOnOk: () => this.loginOut() + + public activeLi(routeName): void { + this.routeName = routeName; + this.storage.set(ROUTENAME, routeName); + } + + // 菜单姓名 + public getRouteName(menuName, childMenuName): void { + this.storage.set(MENUNAME, menuName); + this.storage.set(CHILDMENUNAME, childMenuName); + } + + // 登出 + public loginOut(): void { + this.loginService.loginOut(data => { + if (data.return_code === '000000') { + this.storage.set(ADMIN_INFO_OBJECT, null); + this.storage.set(INIT_FLAG, false); + this.storage.set(TOKEN, null); + this.router.navigateByUrl('/adminLogin').then(); + } else { + this.message.warning(data.return_msg); + } }); - } else { - this.modal.warning({ - nzTitle: '提示', - nzContent: data['return_msg'], - nzOkText: '取消', - nzOkType: 'primary', + } + + // 返回 + public getBack(): void { + history.back(); + } + + clickSwitch(): void { + this.switchValue = !this.switchValue; + this.commonsService.updateDictionary('RECHARGE', this.switchValue === true ? '1' : '0', data => { + if (data['return_code'] === '000000') { + this.message.success(data['return_data']); + } else { + this.message.error(data['return_msg']); + } }); - } - setTimeout(() => { - }, 1000); - }, error => { - this.message.create('error', `未知错误!`); - }); - } - - /** - * 新密码校验两次密码是否一致 - * @param control - */ - checkPwd = (control: FormControl): { [s: string]: boolean } => { - if (!control.value) { - return { required: true }; - } else if (control.value !== this.validateForm.controls.newPassword.value) { - return { confirm: true, error: true }; } - return {}; - } + // 打开抽屉 + openUpdatePwd(): void { + this.visibleUpdatePwd = true; + } + + // 关闭抽屉 + closeUser(): void { + this.visibleUpdatePwd = false; + } + + // 提交表单 + submitForm(value): 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.status == null || this.validateForm.status !== 'VALID') { + this.modal.info({ + nzTitle: '提示', + nzContent: '请正确填写必填信息', + }); + return; + } + const timeNum = new Date().getTime(); + const signStr = 'userId=' + this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id + '&newPassword=' + value.newPassword + '&nonceStr=' + timeNum; + // 定义请求数据 + const params = { + userId: this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id, + oldPassword: value.oldPassword, + newPassword: value.newPassword, + nonceStr: timeNum, + sign: String(Md5.hashStr(signStr)).toLocaleUpperCase(), + }; + this.http.post(environment.baseUrl + '/secUser/sendUserPass', params).subscribe(data => { + if (data['return_code'] === '000000') { + this.modal.success({ + nzTitle: '提示', + nzContent: '密码修改成功', + nzOkText: '重新登录', + nzOkType: 'primary', + nzOnOk: () => this.loginOut() + }); + } else { + this.modal.warning({ + nzTitle: '提示', + nzContent: data['return_msg'], + nzOkText: '取消', + nzOkType: 'primary', + }); + } + setTimeout(() => { + }, 1000); + }, error => { + this.message.create('error', `未知错误!`); + }); + } + + /** + * 新密码校验两次密码是否一致 + * @param control + */ + checkPwd = (control: FormControl): { [s: string]: boolean } => { + if (!control.value) { + return {required: true}; + } else if (control.value !== this.validateForm.controls.newPassword.value) { + return {confirm: true, error: true}; + } + return {}; + } } diff --git a/src/app/admin/order/oil-station-order/oil-station-order.component.html b/src/app/admin/order/oil-station-order/oil-station-order.component.html new file mode 100644 index 0000000..b295686 --- /dev/null +++ b/src/app/admin/order/oil-station-order/oil-station-order.component.html @@ -0,0 +1,155 @@ + + + + + +
+
+
+
+ + 订单号 + + + + +
+
+ + 状态 + + + + + + + + + + + +
+
+ + 创建时间 + + + + +
+
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + + 编号 + 订单号 + 油站名称 + 类型 + 油号 + 油枪号 + 油枪价 + 优惠价 + 加油升数 + 加油金额 + 支付金额 + 优惠金额 + 创建时间 + 状态 + 操作 + + + + + {{i + 1}} + {{data.orderNo}} + {{data.gasName}} + {{data.gasOilType == 1 ? '汽油': '柴油'}} + {{data.gasOilNo + "#"}} + {{data.gasGunNo + "号"}} + {{data.gasPriceGun}} + {{data.gasPricePreferences}} + {{data.gasOilLiters}} + {{data.totalPrice}} + {{data.payRealPrice}} + {{data.deductionPrice}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm:ss'}} + {{data.status | orderCouponStatus}} + + 详情 + + 退款 + + + +
+ + + + + 退款理由 + + + + + + + + + {{data['gasName']}} + {{data['gasAddress']}} + {{data['orderNo']}} + {{data['gasOilType'] == 1 ? '汽油': '柴油'}} + {{data['gasOilNo']}} + {{data['gasGunNo']}} + {{data['gasPriceGun']}} + {{data['gasPricePreferences']}} + {{data['gasOilLiters']}} + {{data['totalPrice']}} + {{data['payRealPrice']}} + {{data['deductionPrice']}} + {{data['gasDiscount']}} + {{data['gasOilSubsidy']}} + {{data['gasLitersPreferences']}} + {{data['createTime'] | date: 'yyyy-MM-dd HH:mm:ss'}} + {{data['status'] | rechargeStatus}} + {{data['refundPrice']}} + {{data['refundTime'] | date: 'yyyy-MM-dd HH:mm:ss'}} + {{data['refundContent']}} + + + diff --git a/src/app/admin/order/oil-station-order/oil-station-order.component.scss b/src/app/admin/order/oil-station-order/oil-station-order.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/order/oil-station-order/oil-station-order.component.ts b/src/app/admin/order/oil-station-order/oil-station-order.component.ts new file mode 100644 index 0000000..cbd0e9b --- /dev/null +++ b/src/app/admin/order/oil-station-order/oil-station-order.component.ts @@ -0,0 +1,152 @@ +import { Component, OnInit } from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms'; +import {OrderService} from '../../../services/order.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {Router} from '_@angular_router@9.0.7@@angular/router'; +import {CompanyService} from '../../../services/company.service'; +import {MerchantService} from '../../../services/merchant.service'; +import {LocalStorageService} from '../../../services/local-storage.service'; +import {CommonsService} from '../../../services/commons.service'; +import {WebsocketService} from '../../../services/websocket.service'; + +@Component({ + selector: 'app-oil-station-order', + templateUrl: './oil-station-order.component.html', + styleUrls: ['./oil-station-order.component.scss'] +}) +export class OilStationOrderComponent implements OnInit { + + WEB_SERVE_URL = environment.baseUrl; + FILE_URL = environment.imageUrl; + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + companyData = []; // 列表数据 + merchantData = []; // 列表数据 + data = {}; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + id: number; // 订单ID + isVisible = false; + isVisibleDetail = false; + refundContent: string; + roleType: number; + constructor( + private form: FormBuilder, + private order: OrderService, + private webSocketService: WebsocketService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private company: CompanyService, + private merchant: MerchantService, + private store: LocalStorageService, // 数据请求 + private common: CommonsService + ) { + } + + ngOnInit(): void { + this.init(); + // 接收消息 + this.webSocketService.messageSubject.subscribe( + data => { + console.log(data); + this.getRequest(true, this.searchForm.value); + }, + err => console.log(err) + ); + } + + public init(): void { + this.searchForm = this.form.group({ + orderNo: [null], + status: [null], + createTime: [null], + }); + this.getRequest(true, this.searchForm.value); + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + if (whereObject['createTime'] != null && whereObject['createTime'].length !== 0) { + whereObject['createTimeS'] = whereObject['createTime'][0].getTime(); + whereObject['createTimeE'] = whereObject['createTime'][1].getTime(); + } + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.order.getGasOrderListByOil(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + showModal(id): void { + this.id = id; + this.isVisible = true; + } + + handleOk(): void { + this.common.showConfirm('确认订单是否退款', item => { + if (item) { + const params = { + orderId: this.id , + refundContent: this.refundContent + }; + this.order.refuelingOrderRefund(params, data => { + if (data['return_code'] === '000000') { + this.getRequest(true, this.searchForm.value); + this.isVisible = false; + this.message.success('退款成功'); + } else { + this.message.error(data['return_msg']); + } + }); + } + }); + } + + handleCancel(): void { + this.isVisible = false; + } + + getDetail(orderNo: string): void { + this.order.getGasOrderDetail(orderNo , data => { + if (data['return_code'] === '000000') { + this.isVisibleDetail = true; + this.data = data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + } + + /** + * 导出订单 + */ + excelOrder() { + this.order.exportGasOrder(this.searchForm.value, data => { + if (data['return_code'] === '000000') { + window.location.href = this.FILE_URL + 'temporary/' + data['return_data']; + } else { + this.message.error(data['return_msg']); + } + }); + } +} diff --git a/src/app/admin/order/order-routing.module.ts b/src/app/admin/order/order-routing.module.ts index 67e635a..ddd9412 100644 --- a/src/app/admin/order/order-routing.module.ts +++ b/src/app/admin/order/order-routing.module.ts @@ -13,6 +13,7 @@ import {PreOrderComponent} from './pre-order/pre-order.component'; import {PackageRecordListComponent} from './package-record-list/package-record-list.component'; import {DiscountUseConditionListComponent} from './discount-use-condition-list/discount-use-condition-list.component'; import {DicountPackageOrderListComponent} from './dicount-package-order-list/dicount-package-order-list.component'; +import {OilStationOrderComponent} from './oil-station-order/oil-station-order.component'; const routes: Routes = [ @@ -29,6 +30,7 @@ const routes: Routes = [ { path: 'package-record-list', component: PackageRecordListComponent }, { path: 'discount-use-condition-list', component: DiscountUseConditionListComponent }, { path: 'discount-package-order-list', component: DicountPackageOrderListComponent}, + { path: 'oil_station_order', component: OilStationOrderComponent}, ]; @NgModule({ diff --git a/src/app/admin/order/order.module.ts b/src/app/admin/order/order.module.ts index c098c10..43accf7 100644 --- a/src/app/admin/order/order.module.ts +++ b/src/app/admin/order/order.module.ts @@ -22,9 +22,10 @@ import { PackageRecordListComponent } from './package-record-list/package-record import { DiscountUseConditionListComponent } from './discount-use-condition-list/discount-use-condition-list.component'; import {DicountPackageOrderListComponent} from "./dicount-package-order-list/dicount-package-order-list.component"; import {NzSpaceModule} from "_ng-zorro-antd@9.3.0@ng-zorro-antd/space"; +import { OilStationOrderComponent } from './oil-station-order/oil-station-order.component'; @NgModule({ - declarations: [OrderListComponent, OrderDetailComponent, OrderCouponsComponent, OrderCouponComponent , OrderTListComponent, OrderKListComponent , OrderCListComponent, OrderHListComponent, OrderAgentComponent, PreOrderComponent, PackageRecordListComponent, DiscountUseConditionListComponent, DicountPackageOrderListComponent], + declarations: [OrderListComponent, OrderDetailComponent, OrderCouponsComponent, OrderCouponComponent , OrderTListComponent, OrderKListComponent , OrderCListComponent, OrderHListComponent, OrderAgentComponent, PreOrderComponent, PackageRecordListComponent, DiscountUseConditionListComponent, DicountPackageOrderListComponent, OilStationOrderComponent], imports: [ CommonModule, OrderRoutingModule, diff --git a/src/app/admin/tuanyou-agent/order/ty-order-list/ty-order-list.component.html b/src/app/admin/tuanyou-agent/order/ty-order-list/ty-order-list.component.html index 6b8c0e3..2d2f6ca 100644 --- a/src/app/admin/tuanyou-agent/order/ty-order-list/ty-order-list.component.html +++ b/src/app/admin/tuanyou-agent/order/ty-order-list/ty-order-list.component.html @@ -108,6 +108,7 @@ 订单号 支付类型 加油金额 + 加油升数 优惠金额 实付金额 油号 @@ -129,6 +130,7 @@ {{data.orderNo}} {{data.payType}} {{data.totalPrice}}元 + {{data.oilLiters}}升 {{data.deductionPrice}}元 {{data.payRealPrice}}元 {{data.gasOilNo}} diff --git a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.component.html b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.component.html index ccc0bb2..282b88a 100644 --- a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.component.html +++ b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.component.html @@ -94,6 +94,8 @@
共计 {{dataObject.total?dataObject.total:0}} 条数据
+ + @@ -104,12 +106,15 @@ @@ -143,8 +148,8 @@ 操作列表
    -
  • 优惠配置
  • -
  • 暂无操作
  • +
  • 优惠配置
  • +
  • 油品配置
@@ -209,9 +214,7 @@
-
- {{item.oilNoName}} -
+
{{item.oilNoName}}
保存
+ + +
+
+ {{item.oilNoName}} +
+
+ + +
+
+ 正常销售中【点击暂停销售】 + 已暂停销售【点击恢复正常销售】 +
+
+
+ + +
+ + + 油品 + + + + + + + + + + 折扣 + + + + + + +
+ +
+
+
+ + +
+ + + 油品 + + + + + + + + + + 销售状态 + + + + + + + + +
+ +
+
+
+ diff --git a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts index 2f80e6e..b1bb110 100644 --- a/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts +++ b/src/app/admin/tuanyou-agent/petrol-station-manage/petrol-station-manage.ts @@ -4,11 +4,13 @@ import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-an import {TyAgentService} from '../../../services/ty-agent.service'; import {TyAgentOilStationService} from '../../../services/ty-agent-oil-station.service'; import {Validators} from '@angular/forms'; -import {OrganizationService} from "../../../services/organization.service"; -import {LocalStorageService} from "../../../services/local-storage.service"; +import {OrganizationService} from '../../../services/organization.service'; +import {LocalStorageService} from '../../../services/local-storage.service'; import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; -import {TySalesmanService} from "../../../services/ty-salesman.service"; -import {TyAgentPriceService} from "../../../services/ty-agent-price.service"; +import {TySalesmanService} from '../../../services/ty-salesman.service'; +import {TyAgentPriceService} from '../../../services/ty-agent-price.service'; +import {GasService} from '../../../services/gas.service'; +import {CommonsService} from '../../../services/commons.service'; @Component({ selector: 'app-petrol-station-manage', @@ -27,6 +29,7 @@ export class PetrolStationManageComponent implements OnInit { tableLoading = true; searchForm: FormGroup; pageNum: number; + pageSize = 10; whereObject: any = {}; allChecked = false; @@ -45,15 +48,27 @@ export class PetrolStationManageComponent implements OnInit { assignSalesmanModal = false; assignSalesmanForm: FormGroup; + batchDiscountConfigModal = false; + batchDiscountConfigForm: FormGroup; + + batchConfigOilNoModal = false; + batchConfigOilNoForm: FormGroup; + discountConfigModal = false; discountConfigData: PetrolStationManage[] = []; + oilConfigModal = false; + + oilNoArray = []; + formatterPercent = (value: number) => `${value} 折`; parserPercent = (value: string) => value.replace(' 折', ''); constructor(private modal: NzModalService, private message: NzMessageService, private tyAgentService: TyAgentService, + private commonsService: CommonsService, + private gasService: GasService, private tyAgentPriceService: TyAgentPriceService, private tySalesmanService: TySalesmanService, private organizationService: OrganizationService, @@ -84,6 +99,21 @@ export class PetrolStationManageComponent implements OnInit { this.assignSalesmanForm = this.form.group({ salesmanId: [null, [Validators.required]], }); + this.batchDiscountConfigForm = this.form.group({ + belongType: [null], + oilNo: [null, [Validators.required]], + priceRate: [100, [Validators.required]], + }); + this.batchConfigOilNoForm = this.form.group({ + status: [null, [Validators.required]], + oilNo: [null, [Validators.required]], + }); + + this.commonsService.getDictionary('GAS_OIL_TYPE', data => { + if (data['return_code'] === '000000') { + this.oilNoArray = data['return_data']; + } + }); this.requestData(1); } @@ -93,7 +123,7 @@ export class PetrolStationManageComponent implements OnInit { requestData(pageNum) { this.tableLoading = true; this.whereObject['pageNum'] = pageNum; - this.whereObject['pageSize'] = 10; + this.whereObject['pageSize'] = this.pageSize; this.tyAgentOilStationService.getOilStationList(this.whereObject, data => { if (data['return_code'] === '000000') { this.dataObject = data['return_data']; @@ -548,12 +578,80 @@ export class PetrolStationManageComponent implements OnInit { * 弹出优惠配置模态框 */ showDiscountConfigModal(oilStationId: number) { - this.tyAgentPriceService.getOilStationPrice(oilStationId, data => { + this.getOilStationPrice(oilStationId); + this.discountConfigModal = true; + } + + /** + * 关闭优惠配置模态框 + */ + closeDiscountConfigModal() { + this.discountConfigModal = false; + } + + /** + * 弹出批量优惠配置模态框 + */ + showBatchDiscountConfigModal() { + this.batchDiscountConfigModal = true; + } + + /** + * 关闭批量优惠配置模态框 + */ + closeBatchDiscountConfigModal() { + this.batchDiscountConfigModal = false; + } + + /** + * 批量设置优惠 + */ + submitBatchDiscountConfig() { + for (const i in this.batchDiscountConfigForm.controls) { + this.batchDiscountConfigForm.controls[i].markAsDirty(); + this.batchDiscountConfigForm.controls[i].updateValueAndValidity(); + } + if (this.batchDiscountConfigForm.status == null || this.batchDiscountConfigForm.status !== 'VALID') { + this.modal.warning({ + nzTitle: '提示', + nzContent: '有必填项未填写', + }); + this.loadingObject.spinning = false; + return; + } + if (this.checkedData.length === 0) { + this.modal.warning({ + nzTitle: '提示', + nzContent: '请勾选油站', + }); + return; + } + this.loadingObject.spinning = true; + this.loadingObject.msg = '处理中...'; + this.batchDiscountConfigModal = false; + + if (this.roleType === 5) { + this.batchDiscountConfigForm.value.belongType = 1; + } else { + this.batchDiscountConfigForm.value.belongType = 2; + } + const oilStationList = []; + for (const data of this.checkedData) { + oilStationList.push({ oilStationId: data['storeId'], oilStationName: data['storeName'], tyAgentOilStationId: data['tyAgentOilStationId'] }); + } + this.batchDiscountConfigForm.value['oilStationList'] = oilStationList; + this.tyAgentPriceService.batchConfigPrice(this.batchDiscountConfigForm.value, data => { + this.loadingObject.spinning = false; if (data['return_code'] === '000000') { - this.discountConfigData = data['return_data']; - this.discountConfigModal = true; + this.modal.success({ + nzTitle: '提示', + nzContent: '处理成功', + }); + this.checkedData = []; + this.requestData(this.whereObject['pageNum']); + this.closeBatchDiscountConfigModal(); } else { - this.modal.warning({ + this.modal.error({ nzTitle: '提示', nzContent: data['return_msg'], }); @@ -562,10 +660,67 @@ export class PetrolStationManageComponent implements OnInit { } /** - * 关闭优惠配置模态框 + * 弹出批量优惠配置模态框 */ - closeDiscountConfigModal() { - this.discountConfigModal = false; + showBatchConfigOilNoModal() { + this.batchConfigOilNoModal = true; + } + + /** + * 关闭批量优惠配置模态框 + */ + closeBatchConfigOilNoModal() { + this.batchConfigOilNoModal = false; + } + + /** + * 批量设置优惠 + */ + submitBatchConfigOilNo() { + for (const i in this.batchConfigOilNoForm.controls) { + this.batchConfigOilNoForm.controls[i].markAsDirty(); + this.batchConfigOilNoForm.controls[i].updateValueAndValidity(); + } + if (this.batchConfigOilNoForm.status == null || this.batchConfigOilNoForm.status !== 'VALID') { + this.modal.warning({ + nzTitle: '提示', + nzContent: '有必填项未填写', + }); + return; + } + if (this.checkedData.length === 0) { + this.modal.warning({ + nzTitle: '提示', + nzContent: '请勾选油站', + }); + return; + } + this.loadingObject.spinning = true; + this.loadingObject.msg = '处理中...'; + this.batchDiscountConfigModal = false; + + const oilStationList = []; + for (const data of this.checkedData) { + oilStationList.push({ oilStationId: data['storeId'] }); + } + this.batchConfigOilNoForm.value['oilStationList'] = oilStationList; + this.tyAgentPriceService.batchConfigOilNo(this.batchConfigOilNoForm.value, data => { + this.loadingObject.spinning = false; + if (data['return_code'] === '000000') { + this.modal.success({ + nzTitle: '提示', + nzContent: '处理成功', + }); + this.checkedData = []; + this.requestData(this.whereObject['pageNum']); + this.closeBatchConfigOilNoModal(); + } else { + this.modal.error({ + nzTitle: '提示', + nzContent: data['return_msg'], + }); + } + }); } /** @@ -578,6 +733,15 @@ export class PetrolStationManageComponent implements OnInit { nzContent: '没有配置优惠数据' }); } + if (this.roleType === 5) { + for (const data of this.discountConfigData) { + data['belongType'] = 1; + } + } else { + for (const data of this.discountConfigData) { + data['belongType'] = 2; + } + } this.tyAgentPriceService.editPrice(this.discountConfigData, data => { if (data['return_code'] === '000000') { this.modal.success({ @@ -595,6 +759,21 @@ export class PetrolStationManageComponent implements OnInit { }); } + /** + * 弹出油品配置模态框 + */ + showOilConfigModal(oilStationId: number) { + this.getOilStationPrice(oilStationId); + this.oilConfigModal = true; + } + + /** + * 关闭油品配置模态框 + */ + closeOilConfigModal() { + this.oilConfigModal = false; + } + /** * 全选 * @param data @@ -636,13 +815,91 @@ export class PetrolStationManageComponent implements OnInit { } } + /** + * 油品禁用提示 + */ + showOilDisabledConfirm(oilStationId: number, oilNo: string): void { + this.modal.confirm({ + nzTitle: '警告', + nzContent: '确定要暂停销售该油品吗', + nzOkText: '是', + nzCancelText: '否', + nzOkType: 'danger', + nzOnOk: () => this.submitOilDisabled(oilStationId, oilNo) + }); + } + + submitOilDisabled(oilStationId: number, oilNo: string) { + this.gasService.disabledOil({ storeId: oilStationId, oilNo }, data => { + if (data['return_code'] === '000000') { + this.modal.success({ + nzTitle: '提示', + nzContent: data['return_data'], + }); + this.getOilStationPrice(oilStationId); + } else { + this.modal.warning({ + nzTitle: '提示', + nzContent: data['return_msg'], + }); + } + }); + } + + /** + * 油品启用提示 + */ + showOilEnableConfirm(oilStationId: number, oilNo: string): void { + this.gasService.enableOil({ storeId: oilStationId, oilNo }, data => { + if (data['return_code'] === '000000') { + this.modal.success({ + nzTitle: '提示', + nzContent: data['return_data'], + }); + this.getOilStationPrice(oilStationId); + } else { + this.modal.warning({ + nzTitle: '提示', + nzContent: data['return_msg'], + }); + } + }); + } + + /** + * 查询油站价格 + * @param oilStationId + */ + getOilStationPrice(oilStationId: number) { + let belongType = 2; + if (this.roleType === 5) { + belongType = 1; + } + this.tyAgentPriceService.getOilStationPrice(belongType, oilStationId, data => { + if (data['return_code'] === '000000') { + this.discountConfigData = data['return_data']; + } else { + this.modal.warning({ + nzTitle: '提示', + nzContent: data['return_msg'], + }); + } + }); + } + + pageSizeChange(pageSize: number) { + this.pageSize = pageSize; + this.requestData(1); + } } export class PetrolStationManage { + belongType: number; oilStationId: number; lowPrice: number; oilNo: string; oilNoName: string; priceRate: number; + status: number; } diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts index 86b5820..43159ee 100644 --- a/src/app/app-common.module.ts +++ b/src/app/app-common.module.ts @@ -44,6 +44,7 @@ import { OilCardRecordTypePipe, OilCardRecordSourceTypePipe } from './pipes'; import {OilCardStatusPipe} from "./pipes/oil-card/oil-card-status.pipe"; +import { OilTypePipe } from './pipes/store/oil-type.pipe'; @@ -98,6 +99,7 @@ const PIPES = [ ], declarations: [ ...PIPES, + OilTypePipe, ], diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 85c3b33..74cf71a 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -112,6 +112,11 @@ const routes: Routes = [ loadChildren: () => import('./admin/oil-card/oil-card.module').then(m => m.OilCardModule), canActivate: [InitGuardService] }, + { + path: 'gz-sinopec', + loadChildren: () => import('./admin/gz-sinopec/gz-sinopec.module').then(m => m.GzSinopecModule), + canActivate: [InitGuardService] + }, ], }, ]; diff --git a/src/app/pipes/recharge-status.pipe.ts b/src/app/pipes/recharge-status.pipe.ts index 9a832e2..e659165 100644 --- a/src/app/pipes/recharge-status.pipe.ts +++ b/src/app/pipes/recharge-status.pipe.ts @@ -14,9 +14,9 @@ export class RechargeStatusPipe implements PipeTransform { case 3: return '已完成'; case 4: - return '已取消'; - case 5: return '已退款'; + case 5: + return '已取消'; case 6: return '退款中'; } diff --git a/src/app/pipes/store/oil-type.pipe.ts b/src/app/pipes/store/oil-type.pipe.ts new file mode 100644 index 0000000..e878379 --- /dev/null +++ b/src/app/pipes/store/oil-type.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'oilType' +}) +export class OilTypePipe implements PipeTransform { + + transform(value: number): string { + switch (value) { + case 1: + return '汽油'; + case 2: + return '柴油'; + case 3: + return '天然气'; + } + } +} diff --git a/src/app/services/coupon.service.ts b/src/app/services/coupon.service.ts index 70f41fd..f3a24af 100644 --- a/src/app/services/coupon.service.ts +++ b/src/app/services/coupon.service.ts @@ -132,5 +132,28 @@ export class CouponService { }); } + /** + * 查询贵州中石化分配列表 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public getGzSinopecAssignList(params: object, callBack) { + this.http.get(environment.baseUrl + 'couponCode/getGzSinopecAssignList?' + this.common.getWhereCondition(params)).subscribe(data => { + callBack(data); + }); + } + + /** + * 导出贵州中石化分配列表 + * + * @param id 用户id + * @param callBack 返回参数 + */ + public importGzSinopecAssign(params: object, callBack) { + this.http.get(environment.baseUrl + 'couponCode/importGzSinopecAssign?' + this.common.getWhereCondition(params)).subscribe(data => { + callBack(data); + }); + } } diff --git a/src/app/services/gas.service.ts b/src/app/services/gas.service.ts new file mode 100644 index 0000000..6dc73e5 --- /dev/null +++ b/src/app/services/gas.service.ts @@ -0,0 +1,39 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; +import {CommonsService} from './commons.service'; +import {environment} from "../../environments/environment"; + +@Injectable({ + providedIn: 'root' +}) +export class GasService { + + constructor( + private http: HttpClient, + private common: CommonsService + ) { } + + /** + * 禁用油品 + * + * @param param 参数对象 + * @param callBack 回调 + */ + public disabledOil(param: object, callBack) { + this.http.post(environment.baseUrl + 'highGas/disabledOil', param).subscribe(data => { + callBack(data); + }); + } + + /** + * 启用油品 + * + * @param param 参数对象 + * @param callBack 回调 + */ + public enableOil(param: object, callBack) { + this.http.post(environment.baseUrl + 'highGas/enableOil', param).subscribe(data => { + callBack(data); + }); + } +} diff --git a/src/app/services/index.service.ts b/src/app/services/index.service.ts index 3e22da1..9195faa 100644 --- a/src/app/services/index.service.ts +++ b/src/app/services/index.service.ts @@ -53,6 +53,19 @@ export class IndexService { }); } + /** + * @Author Sum1Dream + * @methodName addHLTBalance + * @Description // 新增余额 + * @Date 12:12 下午 2022/1/10 + * @Param + */ + public recharge(params: object, callBack) { + this.http.post(environment.baseUrl + 'merStoreAccount/recharge', params).subscribe(data => { + callBack(data); + }); + } + /** * @Author Sum1Dream * @methodName queryCompanyAccountInfo2JD @@ -124,5 +137,47 @@ export class IndexService { }); } + /** + * @Author Sum1Dream + * @methodName getAccount + * @Description // 查询门店账户 + * @Date 10:00 2022/5/18 + * @Param + */ + + public getAccount(callBack) { + this.http.get(environment.baseUrl + 'merStoreAccount/getAccount').subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName getGasStatistical + * @Description // 查询加油站统计 + * @Date 10:00 2022/5/18 + * @Param + */ + public getGasStatistical(callBack) { + this.http.post(environment.baseUrl + 'highGas/getGasStatistical', null).subscribe(data => { + callBack(data); + }); + } + + /** + * @Author Sum1Dream + * @methodName getAccountRecordList + * @Description // 查询门店账户流失记录 + * @Date 10:00 2022/5/18 + * @Param + */ + + public getAccountRecordList(paramsObject , callBack) { + this.http.get(environment.baseUrl + 'merStoreAccount/getAccountRecordList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + } diff --git a/src/app/services/merchant-store.service.ts b/src/app/services/merchant-store.service.ts index 8c3a479..5854d19 100644 --- a/src/app/services/merchant-store.service.ts +++ b/src/app/services/merchant-store.service.ts @@ -25,6 +25,18 @@ export class MerchantStoreService { }); } + /** + * 查询门店油品列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getOilPriceListByStore(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'gasOilPrice/getOilPriceListByStore?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + /** * 超级管理员查询门店列表 * @@ -88,5 +100,80 @@ export class MerchantStoreService { }); } + /** + * 查询油站油品详情 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getOilPriceDetail(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'gasOilPrice/getOilPriceDetail?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * 编辑油品 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public editGasOilPrice(params: object, callBack) { + this.http.post(environment.baseUrl + 'gasOilPrice/editGasOilPrice', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 删除油品 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public delOilPrice(params: object, callBack) { + console.log(params); + this.http.post(environment.baseUrl + 'gasOilPrice/delOilPrice', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 删除油枪 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public delGunNo(params: object, callBack) { + this.http.post(environment.baseUrl + 'gasOilGunNo/delGunNo', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 查询油站油品油枪 + * + * @param oilPriceId 对象 + * @param callBack 回调 + */ + public getGunNoListByOilPrice(oilPriceId: number, callBack) { + this.http.get(environment.baseUrl + 'gasOilGunNo/getGunNoListByOilPrice?oilPriceId=' + oilPriceId).subscribe(data => { + callBack(data); + }); + } + /** + * 配置油枪号 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public addGasOilPrice(params: object, callBack) { + this.http.post(environment.baseUrl + 'gasOilGunNo/addGasOilPrice', params).subscribe(data => { + callBack(data); + }); + } } diff --git a/src/app/services/order.service.ts b/src/app/services/order.service.ts index 977ba3b..fe68ecf 100644 --- a/src/app/services/order.service.ts +++ b/src/app/services/order.service.ts @@ -26,6 +26,18 @@ export class OrderService { }); } + /** + * 查询油站订单 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getGasOrderListByOil(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'highGas/getGasOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + /** * @Author Sum1Dream * @methodName getDiscountPackageList @@ -233,4 +245,15 @@ export class OrderService { }); } + public exportGasOrder(params: object , callBack) { + this.http.get(environment.baseUrl + 'highGas/exportGasOrder?' + this.common.getWhereCondition(params)).subscribe( data => { + callBack(data); + }); + } + + public getGasOrderDetail(orderNo: string , callBack) { + this.http.get(environment.baseUrl + 'highGas/getGasOrderDetail?orderNo=' + orderNo).subscribe( data => { + callBack(data); + }); + } } diff --git a/src/app/services/ty-agent-price.service.ts b/src/app/services/ty-agent-price.service.ts index 2b10df0..b358bae 100644 --- a/src/app/services/ty-agent-price.service.ts +++ b/src/app/services/ty-agent-price.service.ts @@ -24,14 +24,37 @@ export class TyAgentPriceService { }); } + /** + * 批量配置价格 + * @param paramObject 参数 + * @param callBack + */ + batchConfigPrice(paramObject: object, callBack) { + this.http.post(environment.baseUrl + 'tyAgentPrice/batchConfigPrice', paramObject).subscribe(data => { + callBack(data); + }); + } + + /** + * 批量配置油品 + * @param paramObject 参数 + * @param callBack + */ + batchConfigOilNo(paramObject: object, callBack) { + this.http.post(environment.baseUrl + 'tyAgentPrice/batchConfigOilNo', paramObject).subscribe(data => { + callBack(data); + }); + } + /** * 油站价格 * @param paramObject 参数 * @param callBack */ - getOilStationPrice(oilStationId: number, callBack) { - this.http.get(environment.baseUrl + 'tyAgentPrice/getOilStationPrice?oilStationId=' + oilStationId).subscribe(data => { + getOilStationPrice(belongType: number, oilStationId: number, callBack) { + this.http.get(environment.baseUrl + 'tyAgentPrice/getOilStationPrice?belongType=' + belongType + '&oilStationId=' + oilStationId).subscribe(data => { callBack(data); }); } + } diff --git a/src/app/services/websocket.service.ts b/src/app/services/websocket.service.ts new file mode 100644 index 0000000..80b6222 --- /dev/null +++ b/src/app/services/websocket.service.ts @@ -0,0 +1,239 @@ +import {Component, Injectable} from '@angular/core'; +import {interval, Subject} from 'rxjs'; +import {NzNotificationService} from 'ng-zorro-antd'; + +@Injectable({ + providedIn: 'root' +}) +export class WebsocketService { + + messageSubject; // subject对象,用于发送事件 + private url; // 默认请求的url + private webSocket: WebSocket; // websocket对象 + connectSuccess = false; // websocket 连接成功 + period = 60 * 1000 * 10; // 10分钟检查一次 + serverTimeoutSubscription = null; // 定时检测连接对象 + reconnectFlag = false; // 重连 + reconnectPeriod = 5 * 1000; // 重连失败,则5秒钟重连一次 + reconnectSubscription = null; // 重连订阅对象 + runTimeSubscription; // 记录运行连接subscription + runTimePeriod = 60 * 10000; // 记录运行连接时间 + + constructor(private notification: NzNotificationService) { + this.messageSubject = new Subject(); + console.log('开始心跳检测'); + // 进入程序就进行心跳检测,避免出现开始就连接中断,后续不重连 + this.heartCheckStart(); + this.calcRunTime(); + } + + /** + * 发送消息 + * @author Sum1Dream + * @date 2019/1/22 + * @param message 发送消息 + */ + sendMessage(message) { + this.webSocket.send(message); + } + + /** + * 创建新连接 + * @author Sum1Dream + * @date 2019/1/22 + * @param url 要连接的url + */ + connect(url) { + if (!!url) { + this.url = url; + } + // 创建websocket对象 + this.createWebSocket(); + } + + /** + * 创建连接 + * @author Sum1Dream + * @date 2019/1/22 + */ + createWebSocket() { + // 如果没有建立过连接,才建立连接并且添加时间监听 + this.webSocket = new WebSocket(this.url); + // 建立连接成功 + this.webSocket.onopen = (e) => this.onOpen(e); + // 接收到消息 + this.webSocket.onmessage = (e) => this.onMessage(e); + // 连接关闭 + this.webSocket.onclose = (e) => this.onClose(e); + // 异常 + this.webSocket.onerror = (e) => this.onError(e); + } + + /** + * 连接打开 + * @author Sum1Dream + * @date 2019/1/22 + * @param e 打开事件 + */ + onOpen(e) { + console.log('websocket 已连接'); + // 设置连接成功 + this.connectSuccess = true; + // 如果是重连中 + if (this.reconnectFlag) { + // 1.停止重连 + this.stopReconnect(); + // 2.重新开启心跳 + this.heartCheckStart(); + // 3.重新开始计算运行时间 + this.calcRunTime(); + } + } + + /** + * 接受到消息 + * @author Sum1Dream + * @date 2019/1/22 + * @param event 接受消息事件 + */ + onMessage(event) { + const data = JSON.parse(event.data); + // 将接受到的消息发布出去 + // console.log('接收到消息时间', new Date().getTime()); + this.notification.success( + data['order']['gasName'] + '加油订单', + '

订单号:' + data['order']['orderNo'] + '

' + + '

加油金额:' + data['order']['totalPrice'] + '

' + + '

油号:' + data['order']['gasOilNo'] + '

' + + '

油枪号:' + data['order']['gasGunNo'] + '

' + ); + const audio = new Audio(); + audio.src = data['voice']; + audio.load(); + audio.play().then(r => console.log(r)); + this.messageSubject.next(true); + } + + /** + * 连接关闭 + * @author Sum1Dream + * @date 2019/1/22 + */ + private onClose(e) { + console.log('连接关闭', e); + this.connectSuccess = false; + this.webSocket.close(); + // 关闭时开始重连 + this.reconnect(); + this.stopRunTime(); + // throw new Error('webSocket connection closed:)'); + } + + /** + * 连接异常 + * @author Sum1Dream + * @date 2019/1/22 + */ + private onError(e) { + // 出现异常时一定会进onClose,所以只在onClose做一次重连动作 + console.log('连接异常', e); + this.connectSuccess = false; + // throw new Error('webSocket connection error:)'); + } + + /** + * 开始重新连接 + * @author Sum1Dream + * @date 2019/1/22 + */ + reconnect() { + // 如果已重连,则直接return,避免重复连接 + if (this.connectSuccess) { + this.stopReconnect(); + console.log('已经连接成功,停止重连'); + return; + } + // 如果正在连接中,则直接return,避免产生多个轮训事件 + if (this.reconnectFlag) { + console.log('正在重连,直接返回'); + return; + } + // 开始重连 + this.reconnectFlag = true; + // 如果没能成功连接,则定时重连 + this.reconnectSubscription = interval(this.reconnectPeriod).subscribe(async (val) => { + console.log(`重连:${val}次`); + const url = this.url; + // 重新连接 + this.connect(url); + }); + } + + /** + * 停止重连 + * @author Sum1Dream + * @date 2019/1/22 + */ + stopReconnect() { + // 连接标识置为false + this.reconnectFlag = false; + // 取消订阅 + if (typeof this.reconnectSubscription !== 'undefined' && this.reconnectSubscription != null) { + this.reconnectSubscription.unsubscribe(); + } + } + + /** + * 开始心跳检测 + * @author Sum1Dream + * @date 2019/1/22 + */ + heartCheckStart() { + this.serverTimeoutSubscription = interval(this.period).subscribe((val) => { + // 保持连接状态,重置下 + if (this.webSocket != null && this.webSocket.readyState === 1) { + console.log(val, '连接状态,发送消息保持连接'); + } else { + // 停止心跳 + this.heartCheckStop(); + // 开始重连 + this.reconnect(); + console.log('连接已断开,重新连接'); + } + }); + } + + /** + * 停止心跳检测 + * @author Sum1Dream + * @date 2019/1/22 + */ + heartCheckStop() { + // 取消订阅停止心跳 + if (typeof this.serverTimeoutSubscription !== 'undefined' && this.serverTimeoutSubscription != null) { + this.serverTimeoutSubscription.unsubscribe(); + } + } + + /** + * 开始计算运行时间 + * @author Sum1Dream + * @date 2019/1/25 + */ + calcRunTime() { + this.runTimeSubscription = interval(this.runTimePeriod).subscribe(period => { + console.log('运行时间', `${period}分钟`); + }); + } + + /** + * 停止计算运行时间 + * @author Sum1Dream + * @date 2019/1/25 + */ + stopRunTime() { + if (typeof this.runTimeSubscription !== 'undefined' && this.runTimeSubscription !== null) { + this.runTimeSubscription.unsubscribe(); + } + } +} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index a2d6d6f..ca22a39 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,10 +4,10 @@ export const environment = { production: false, - baseUrl: 'http://localhost:9302/brest/', // 测试环境服务器地址(请求数据地址) - imageUrl: 'http://localhost:9302/filesystem/', - // baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) - // imageUrl: 'https://hsgcs.dctpay.com/filesystem/', +/* baseUrl: 'http://localhost:9302/brest/', // 测试环境服务器地址(请求数据地址) + imageUrl: 'http://localhost:9302/filesystem/',*/ + baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) + imageUrl: 'https://hsgcs.dctpay.com/filesystem/', key: 'https://hsgcs.dctpay.com/phone-recharge-H5/index.html?codeValue=', inviteUrl: 'https://hsgcs.dctpay.com/wx/?action=ic&id=', };