|
@@ -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,
|
|
|
};
|