zs hace 1 año
padre
commit
63d7138e64

+ 8 - 4
src/entity/Order.entity.ts

@@ -17,10 +17,14 @@ export class Order extends BaseModel {
   buy_time: string;
   @prop({ required: false, index: false, zh: '审核记录' })
   record: Array<any>;
-  @prop({ required: false, index: false, zh: '领导' })
-  leader: Array<any>;
-  @prop({ required: false, index: false, zh: '会计' })
-  accounting: Array<any>;
+  @prop({ required: false, index: false, zh: '采购领导' })
+  s_leader: Array<any>;
+  @prop({ required: false, index: false, zh: '采购会计' })
+  s_accounting: Array<any>;
+  @prop({ required: false, index: false, zh: '回款领导' })
+  c_leader: Array<any>;
+  @prop({ required: false, index: false, zh: '回款会计' })
+  c_accounting: Array<any>;
   @prop({
     required: false,
     index: true,

+ 8 - 4
src/entity/OrderDetail.entity.ts

@@ -26,10 +26,14 @@ export class OrderDetail extends BaseModel {
   total_money: number;
   @prop({ required: false, index: false, zh: '审核记录' })
   record: Array<any>;
-  @prop({ required: false, index: false, zh: '领导' })
-  leader: Array<any>;
-  @prop({ required: false, index: false, zh: '会计' })
-  accounting: Array<any>;
+  @prop({ required: false, index: false, zh: '采购领导' })
+  s_leader: Array<any>;
+  @prop({ required: false, index: false, zh: '采购会计' })
+  s_accounting: Array<any>;
+  @prop({ required: false, index: false, zh: '回款领导' })
+  c_leader: Array<any>;
+  @prop({ required: false, index: false, zh: '回款会计' })
+  c_accounting: Array<any>;
   @prop({
     required: false,
     index: true,

+ 18 - 8
src/interface/Order.interface.ts

@@ -26,10 +26,14 @@ export class FVO_Order {
   'buy_time': string = undefined;
   @ApiProperty({ description: '审核记录' })
   'record': Array<any> = undefined;
-  @ApiProperty({ description: '领导' })
-  'leader': Array<any> = undefined;
-  @ApiProperty({ description: '会计' })
-  'accounting': Array<any> = undefined;
+  @ApiProperty({ description: '采购领导' })
+  's_leader': Array<any> = undefined;
+  @ApiProperty({ description: '采购会计' })
+  's_accounting': Array<any> = undefined;
+  @ApiProperty({ description: '回款领导' })
+  'c_leader': Array<any> = undefined;
+  @ApiProperty({ description: '回款会计' })
+  'c_accounting': Array<any> = undefined;
   @ApiProperty({ description: '订单状态' })
   'status': string = undefined;
 }
@@ -75,12 +79,18 @@ export class CDTO_Order {
   @ApiProperty({ description: '审核记录' })
   @Rule(RuleType['array']().empty(''))
   'record': Array<any> = undefined;
-  @ApiProperty({ description: '领导' })
+  @ApiProperty({ description: '采购领导' })
   @Rule(RuleType['array']().empty(''))
-  'leader': Array<any> = undefined;
-  @ApiProperty({ description: '会计' })
+  's_leader': Array<any> = undefined;
+  @ApiProperty({ description: '采购会计' })
   @Rule(RuleType['array']().empty(''))
-  'accounting': Array<any> = undefined;
+  's_accounting': Array<any> = undefined;
+  @ApiProperty({ description: '回款领导' })
+  @Rule(RuleType['array']().empty(''))
+  'c_leader': Array<any> = undefined;
+  @ApiProperty({ description: '回款会计' })
+  @Rule(RuleType['array']().empty(''))
+  'c_accounting': Array<any> = undefined;
   @ApiProperty({ description: '订单状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 18 - 8
src/interface/OrderDetail.interface.ts

@@ -36,10 +36,14 @@ export class FVO_OrderDetail {
   'total_money': number = undefined;
   @ApiProperty({ description: '审核记录' })
   'record': Array<any> = undefined;
-  @ApiProperty({ description: '领导' })
-  'leader': Array<any> = undefined;
-  @ApiProperty({ description: '会计' })
-  'accounting': Array<any> = undefined;
+  @ApiProperty({ description: '采购领导' })
+  's_leader': Array<any> = undefined;
+  @ApiProperty({ description: '采购会计' })
+  's_accounting': Array<any> = undefined;
+  @ApiProperty({ description: '回款领导' })
+  'c_leader': Array<any> = undefined;
+  @ApiProperty({ description: '回款会计' })
+  'c_accounting': Array<any> = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -116,12 +120,18 @@ export class CDTO_OrderDetail {
   @ApiProperty({ description: '审核记录' })
   @Rule(RuleType['array']().empty(''))
   'record': Array<any> = undefined;
-  @ApiProperty({ description: '领导' })
+  @ApiProperty({ description: '采购领导' })
   @Rule(RuleType['array']().empty(''))
-  'leader': Array<any> = undefined;
-  @ApiProperty({ description: '会计' })
+  's_leader': Array<any> = undefined;
+  @ApiProperty({ description: '采购会计' })
   @Rule(RuleType['array']().empty(''))
-  'accounting': Array<any> = undefined;
+  's_accounting': Array<any> = undefined;
+  @ApiProperty({ description: '回款领导' })
+  @Rule(RuleType['array']().empty(''))
+  'c_leader': Array<any> = undefined;
+  @ApiProperty({ description: '回款会计' })
+  @Rule(RuleType['array']().empty(''))
+  'c_accounting': Array<any> = undefined;
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 24 - 7
src/service/Cart.service.ts

@@ -11,7 +11,7 @@ import { Good } from '../entity/Good.entity';
 import { Specs } from '../entity/Specs.entity';
 import { User } from '../entity/User.entity';
 import { CDTO_Cart, QVO_Cart } from '../interface/Cart.interface';
-import { Types } from 'mongoose';
+import { Collection, Types } from 'mongoose';
 import _ = require('lodash');
 import { Office } from '../entity/Office.entity';
 import { Order } from '../entity/Order.entity';
@@ -47,6 +47,9 @@ export class CartService extends BaseService<modelType> {
   @InjectEntityModel(ShopSetting)
   shopModel: ReturnModelType<typeof ShopSetting>;
 
+  @InjectEntityModel(Collection)
+  collModel: ReturnModelType<typeof Collection>;
+
   // 特殊创建
   async specialCreate(data: CDTO_Cart): Promise<object> {
     const { user, supplier_id, goods, spec, num, total_money } = data;
@@ -133,6 +136,8 @@ export class CartService extends BaseService<modelType> {
       if (arr) list.push(arr);
     }
     let order;
+    let Collection;
+    let ShopSetting;
     if (list.length > 0) {
       // 创建订单数据
       const goods = [];
@@ -146,16 +151,26 @@ export class CartService extends BaseService<modelType> {
         let res;
         obj.user = result._id;
         if (result.community) {
-          order = await this.shopModel.findOne({ office: result.community });
+          ShopSetting = await this.shopModel.findOne({
+            office: result.community,
+          });
+          Collection = await this.collModel.findOne({
+            office: result.community,
+          });
           res = await this.offModel.findById(result.community).lean();
         } else if (result.street) {
-          order = await this.shopModel.findOne({ office: result.street });
+          ShopSetting = await this.shopModel.findOne({ office: result.street });
+          Collection = await this.collModel.findOne({
+            office: result.community,
+          });
           res = await this.offModel.findById(result.street).lean();
         } else assert(result.street, '缺少街道信息或社区信息!');
         if (res) obj.address = res.address;
         if (!order) obj.status = '4';
-        obj.accounting = order.accounting;
-        obj.leader = order.leader;
+        obj.s_accounting = ShopSetting.accounting;
+        obj.s_leader = ShopSetting.leader;
+        obj.c_accounting = Collection.accounting;
+        obj.c_leader = Collection.leader;
         obj.total_money = data.totalMoney;
         obj.buy_time = moment().format('YYYY-MM-DD HH:mm:ss');
         order = await this.orderModel.create(obj);
@@ -171,8 +186,10 @@ export class CartService extends BaseService<modelType> {
             num: val.num,
             money: val.money,
             total_money: val.total_money,
-            accounting: order.accounting,
-            leader: order.leader,
+            s_accounting: order.s_accounting,
+            s_leader: order.s_leader,
+            c_accounting: order.c_accounting,
+            c_leader: order.c_leader,
             buy_time: order.buy_time,
             status: order.status,
           };

+ 40 - 13
src/service/OrderDetail.service.ts

@@ -23,11 +23,22 @@ export class OrderDetailService extends BaseService<modelType> {
   userModel: ReturnModelType<typeof User>;
 
   async queryInfo(filter): Promise<object> {
-    const { skip = 0, limit, leader, accounting, goods, ...info } = filter;
+    const {
+      skip = 0,
+      limit,
+      s_leader,
+      s_accounting,
+      c_leader,
+      c_accounting,
+      goods,
+      ...info
+    } = filter;
     let list: any = [];
     let total: any = 0;
-    if (leader) info.leader = { $in: [leader] };
-    else if (accounting) info.accounting = { $in: [accounting] };
+    if (s_leader) info.s_leader = { $in: [s_leader] };
+    else if (s_accounting) info.s_accounting = { $in: [s_accounting] };
+    if (c_leader) info.c_leader = { $in: [c_leader] };
+    else if (c_accounting) info.c_accounting = { $in: [c_accounting] };
     if (goods) {
       const arr = await this.goodModel
         .findOne({
@@ -113,21 +124,37 @@ export class OrderDetailService extends BaseService<modelType> {
     info.user_role = arr.role;
     arr = await this.userModel.findById(res.supplier).lean();
     info.supplier_name = arr.name;
-    if (res.leader && res.leader.length > 0) {
-      const leader = [];
-      for (const val of res.leader) {
+    if (res.s_leader && res.s_leader.length > 0) {
+      const sleader = [];
+      for (const val of res.s_leader) {
         arr = await this.userModel.findById(val).lean();
-        leader.push(arr.name);
+        sleader.push(arr.name);
       }
-      info.leader_name = leader.toString();
+      info.sleader_name = sleader.toString();
     }
-    if (res.accounting && res.accounting.length > 0) {
-      const accounting = [];
-      for (const val of res.accounting) {
+    if (res.s_accounting && res.s_accounting.length > 0) {
+      const saccounting = [];
+      for (const val of res.s_accounting) {
         arr = await this.userModel.findById(val).lean();
-        accounting.push(arr.name);
+        saccounting.push(arr.name);
       }
-      info.accounting_name = accounting.toString();
+      info.saccounting_name = saccounting.toString();
+    }
+    if (res.c_leader && res.c_leader.length > 0) {
+      const cleader = [];
+      for (const val of res.c_leader) {
+        arr = await this.userModel.findById(val).lean();
+        cleader.push(arr.name);
+      }
+      info.cleader_name = cleader.toString();
+    }
+    if (res.c_accounting && res.c_accounting.length > 0) {
+      const caccounting = [];
+      for (const val of res.c_accounting) {
+        arr = await this.userModel.findById(val).lean();
+        caccounting.push(arr.name);
+      }
+      info.caccounting_name = caccounting.toString();
     }
     const result = _.assign(info, res);
     return result;