lrf 2 years ago
parent
commit
56128e35f9

+ 2 - 3
app/controller/trade/config/.order.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['total', 'freight', 'customer', 'address', 'shop', 'discount', 'buy_time', 'pay_time', 'pay_id', 'pay_no', 'status'],
+    requestBody: ['total', 'customer', 'address', 'total_detail', 'buy_time', 'pay_time', 'pay_id', 'pay_no', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['total', 'freight', 'customer', 'address', 'shop', 'discount', 'buy_time', 'pay_time', 'pay_id', 'pay_no', 'status'],
+    requestBody: ['total', 'customer', 'address', 'total_detail', 'buy_time', 'pay_time', 'pay_id', 'pay_no', 'status'],
   },
   show: {
     parameters: {
@@ -22,7 +22,6 @@ module.exports = {
         'meta.createdAt@start': 'meta.createdAt@start',
         'meta.createdAt@end': 'meta.createdAt@end',
         customer: 'customer',
-        shop: 'shop',
         buy_time: 'buy_time',
         pay_id: 'pay_id',
         pay_no: 'pay_no',

+ 2 - 2
app/controller/trade/config/.orderDetail.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['total', 'order', 'shop', 'customer', 'address', 'goods', 'freight', 'buy_time', 'pay_time', 'status'],
+    requestBody: ['discount', 'total', 'order', 'shop', 'customer', 'address', 'goods', 'freight', 'buy_time', 'pay_time', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['total', 'order', 'shop', 'customer', 'address', 'goods', 'freight', 'buy_time', 'pay_time', 'status'],
+    requestBody: ['discount', 'total', 'order', 'shop', 'customer', 'address', 'goods', 'freight', 'buy_time', 'pay_time', 'status'],
   },
   show: {
     parameters: {

+ 1 - 4
app/model/trade/order.js

@@ -8,8 +8,7 @@ const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-pl
 const order = {
   customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
   address: { type: String, required: false, zh: '邮寄地址', ref: 'User.address' }, //
-  shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
-  discount: { type: Array, required: false, zh: '优惠' }, // 优惠情况汇总:e.g.:多个可重叠的优惠券
+  total_detail: { type: Array, required: false, zh: '总金额明细' }, // 运费,优惠,活动,商品原费用的和
   buy_time: { type: String, required: false, zh: '下单时间' }, //
   pay_time: { type: String, required: false, zh: '支付时间' }, //
   pay_id: { type: String, required: false, zh: '支付id' }, //
@@ -20,14 +19,12 @@ const schema = new Schema(order, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.index({ customer: 1 });
-schema.index({ shop: 1 });
 schema.index({ buy_time: 1 });
 schema.index({ pay_id: 1 });
 schema.index({ pay_no: 1 });
 
 schema.plugin(metaPlugin);
 schema.plugin(MoneyPlugin({ zh: '总金额', required: false, key: 'total' }));
-schema.plugin(MoneyPlugin({ zh: '运费', required: false, key: 'freight' }));
 
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/trade/orderDetail.js

@@ -14,6 +14,7 @@ const orderDetail = {
   freight: { type: String, required: false, zh: '运费' }, //
   buy_time: { type: String, required: false, zh: '下单时间' }, //
   pay_time: { type: String, required: false, zh: '支付时间' }, //
+  discount: { type: Array, required: false, zh: '优惠' }, // 优惠情况汇总:e.g.:多个可重叠的优惠券
   status: { type: String, required: false, zh: '订单状态' }, // 字典:order_process
 };
 const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } });

+ 3 - 3
app/service/user/admin.js

@@ -18,13 +18,13 @@ class AdminService extends CrudService {
    */
   async login({ account, password }) {
     const { populate } = this.getRefMods();
-    const user = await this.model.findOne({ account }, '+password').populate(populate);
+    let user = await this.model.findOne({ account }, '+password').populate(populate);
     if (!user) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
-    const { password: upwd, status } = user;
-    if (status !== '0') throw new BusinessError(ErrorCode.USER_NOT_BIND, '该账号处于禁止使用状态');
+    const { password: upwd } = user;
     if (password !== upwd.secret) throw new BusinessError(ErrorCode.BAD_PASSWORD);
     // // 使用redis存储,后续的任何操作进行token的校验
     // await this.setUserInRedis(user);
+    user = JSON.parse(JSON.stringify(user));
     delete user.password;
     delete user.meta;
     delete user.__v;

+ 1 - 1
app/service/util/jwt.js

@@ -10,7 +10,7 @@ class JwtService extends CrudService {
 
   encrypt(data) {
     const { secret } = this.config.jwt;
-    const token = jwt.sign(data, secret);
+    const token = jwt.sign(JSON.stringify(data), secret);
     return token;
   }
 }