Browse Source

Merge branch 'dev'

lrf 2 năm trước cách đây
mục cha
commit
d9a662bf7d

+ 1 - 0
.gitignore

@@ -12,3 +12,4 @@ run/
 *.un~
 typings/
 .nyc_output/
+.vscode/

+ 3 - 2
app/controller/shop/config/.goods.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['is_cashBack', 'cb_config', 'sort', 'source', 'url', 'act_tags', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'tags', 'status'],
+    requestBody: ['code', 'is_cashBack', 'cb_config', 'sort', 'source', 'url', 'act_tags', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'tags', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['is_cashBack', 'cb_config', 'sort', 'source', 'url', 'act_tags', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'tags', 'status'],
+    requestBody: ['code', 'is_cashBack', 'cb_config', 'sort', 'source', 'url', 'act_tags', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'tags', 'status'],
   },
   show: {
     parameters: {
@@ -27,6 +27,7 @@ module.exports = {
         view_num: 'view_num',
         tags: 'tags',
         act_tags: 'act_tags',
+        code: '%code%',
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 5 - 3
app/controller/shop/config/.goodsSpec.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
+    requestBody: ['sort', 'file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
+    requestBody: ['sort', 'file', 'can_group', 'group_config', 'sell_money', 'flow_money', 'freight', 'goods', 'name', 'num', 'status'],
   },
   show: {
     parameters: {
@@ -25,6 +25,7 @@ module.exports = {
         name: 'name',
         status: 'status',
         can_group: 'can_group',
+        sort: 'sort',
       },
       // options: {
       //   "meta.state": 0 // 默认条件
@@ -33,7 +34,8 @@ module.exports = {
     service: 'query',
     options: {
       query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      // sort: [{ sort: -1 }, { 'meta.createdAt': -1 }],
+      sort: { sort: -1, 'meta.createdAt': -1 },
       desc: true,
       count: true,
     },

+ 3 - 0
app/controller/user/config/.admin.js

@@ -47,4 +47,7 @@ module.exports = {
   emailResetPwd: {
     requestBody: ['!account'],
   },
+  toMakeKey: {
+    requestBody: ['!password', '!target'],
+  },
 };

+ 1 - 1
app/controller/user/config/.user.js

@@ -3,7 +3,7 @@ module.exports = {
     requestBody: ['name', 'phone', 'password', 'icon', 'birth', 'gender', 'email', 'openid', 'status'],
   },
   destroy: {
-    params: ['!id'],
+    requestBody: ['!key', '!target'],
     service: 'delete',
   },
   update: {

+ 14 - 1
app/controller/util.js

@@ -1,7 +1,9 @@
 'use strict';
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
-
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const moment = require('moment');
 // 业务工具
 class UtilController extends Controller {
   constructor(ctx) {
@@ -10,7 +12,18 @@ class UtilController extends Controller {
     this.bodyObject = this.ctx.request.body;
     this.service = this.ctx.service.util;
     this.tradeService = this.ctx.service.util.trade;
+
   }
+  async util() {
+    this.ctx.ok();
+  }
+
+  async crk() {
+    const key = await this.ctx.service.util.rk.crk();
+    this.ctx.ok({ data: key });
+  }
+
+
   /**
    * 查询是否可以购买
    */

+ 3 - 0
app/controller/view/config/.user.js

@@ -0,0 +1,3 @@
+module.exports = {
+  toDeal: {},
+};

+ 13 - 0
app/controller/view/user.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.user.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 
+class UserController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.view.user;
+  }
+}
+module.exports = CrudController(UserController, meta);

+ 33 - 0
app/middleware/checkUserRK.js

@@ -0,0 +1,33 @@
+'use strict';
+const _ = require('lodash');
+const whiteList = [
+  '/util/crk', // 生成rk
+  '/admin/login', // 管理登陆
+  '/user/wxLogin', // 用户微信登陆
+  '/user/login', // 用户密码登录
+  '/user', // 创建用户
+  '/pay/order', // 支付回调
+];
+module.exports = options => {
+  return async function checkuserrk(ctx, next) {
+    const request = _.get(ctx, 'request');
+    const method = _.get(request, 'method');
+    const uri = _.get(request, 'url');
+    // 本地或局域网请求,放过
+    if (process.env.NODE_ENV === 'development') await next();
+    // get方法放过
+    else if (method === 'GET') await next();
+    else {
+      // 白名单中的路由放过: 查看是否以白名单中每一项为结尾,如果是的话,那就说明这个路由不需要检查requestKey
+      const inWhiteList = whiteList.find(f => _.endsWith(uri, f));
+      if (inWhiteList) await next();
+      // 管理员的post放过
+      else if (ctx.admin) await next();
+      // 检查rk
+      else {
+        await ctx.service.util.rk.urk();
+        await next();
+      }
+    }
+  };
+};

+ 9 - 1
app/middleware/errorEmail.js

@@ -9,14 +9,21 @@ module.exports = options => {
         errmsg = '服务发生错误',
         details;
       const emailData = {};
-      if (_.isNumber(e.errcode)) {
+      const ekeys = Object.keys(e);
+      if (ekeys.includes('errcode')) {
+        // 人为抛出异常
         errcode = _.get(e, 'errcode');
         errmsg = _.get(e, 'errmsg');
         details = _.get(e, 'details');
         emailData.errmsg = errmsg;
         emailData.details = details;
       } else {
+        // 由assert/参数判断抛出的
+        errmsg = e.message;
         emailData.errmsg = e.stack;
+        if (process.env.NODE_ENV === 'development') {
+          details = e.stack;
+        }
       }
       emailData.errcode = errcode;
       const request = ctx.request;
@@ -24,6 +31,7 @@ module.exports = options => {
       let body = _.get(request, 'body');
       if (body) body = JSON.stringify(body, null, 1);
       emailData.errmsg = `${url}\n${body}\n${emailData.errmsg}`;
+      // console.log(emailData.errmsg);
       // 未定义的错误需要发邮件,定义的错误不需要
       if (!_.isNumber(e.errcode)) {
         // 非开发模式发送邮件

+ 2 - 0
app/model/shop/goods.js

@@ -23,6 +23,7 @@ const goods = {
   url: { type: String, required: false, zh: '网址' }, //
   is_cashBack: { type: String, required: false, zh: '是否返现' }, // 字典:use
   cb_config: { type: Object, required: false, zh: '返现设置' }, // 返现设置
+  code: { type: String, required: false, zh: '商品编码' }, // 随机生成,8位
 };
 const schema = new Schema(goods, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -34,6 +35,7 @@ schema.index({ view_num: 1 });
 schema.index({ act_tags: 1 });
 schema.index({ sort: 1 });
 schema.index({ is_cashBack: 1 });
+schema.index({ code: 1 });
 
 schema.plugin(metaPlugin);
 

+ 2 - 0
app/model/shop/goodsSpec.js

@@ -13,6 +13,7 @@ const goodsSpec = {
   can_group: { type: String, required: false, zh: '是否可以团购' }, // 字典:tf
   group_config: { type: Object, required: false, zh: '团购设置' }, // 团购模块的设置:团购金额:money,需要人数:need_person
   file: { type: Array, required: false, zh: '图片' }, //
+  sort: { type: Number, required: false, default: 0, zh: '排序' }, //
 };
 const schema = new Schema(goodsSpec, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -21,6 +22,7 @@ schema.index({ goods: 1 });
 schema.index({ name: 1 });
 schema.index({ status: 1 });
 schema.index({ can_group: 1 });
+schema.index({ sort: 1 });
 
 schema.plugin(metaPlugin);
 schema.plugin(MoneyPlugin({ zh: '实际销售价格', required: false, key: 'sell_money' }));

+ 20 - 0
app/service/shop/goods.js

@@ -13,6 +13,14 @@ class GoodsService extends CrudService {
     this.goodsSpecmodel = this.ctx.model.Shop.GoodsSpec;
     this.tran = new Transaction();
   }
+
+  async beforeCreate(data) {
+    // 为商品随机生成不重复的code
+    if (!data.code) data.code = await this.makeCode();
+    return data;
+  }
+
+
   // 标签查询
   async beforeQuery(filter) {
     const { tags } = filter;
@@ -22,6 +30,18 @@ class GoodsService extends CrudService {
     return filter;
   }
 
+  // 生成商品编码
+  async makeCode() {
+    let code = '';
+    let is_has = false;
+    do {
+      code = Math.random().toString(36).substring(3, 11);
+      const num = await this.model.find({ code });
+      is_has = num > 0;
+    } while (is_has);
+    return code;
+  }
+
   async toDuplicate({ id }) {
     const data = await this.model.findById(id);
     if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到数据');

+ 23 - 0
app/service/shop/goodsSpec.js

@@ -10,6 +10,29 @@ class GoodsSpecService extends CrudService {
     super(ctx, 'goodsspec');
     this.model = this.ctx.model.Shop.GoodsSpec;
   }
+  async query(filter, { skip = 0, limit, sort, projection } = {}) {
+    const { sort: fs } = filter;
+    if (fs) {
+      sort.sort = parseInt(fs);
+      delete filter.sort;
+    }
+    // 处理排序
+    // if (sort && _.isString(sort)) {
+    //   sort = { [sort]: desc ? -1 : 1 };
+    // } else if (sort && _.isArray(sort)) {
+    //   sort = sort.map(f => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
+    // }
+    let condition = _.cloneDeep(filter);
+    condition = await this.beforeQuery(condition);
+    condition = this.dealFilter(condition);
+    // 过滤出ref字段
+    const { refMods, populate } = this.getRefMods();
+    // 带ref查询
+    let rs = await this.model.find(condition, projection, { skip, limit, sort }).populate(populate).exec();
+    rs = JSON.parse(JSON.stringify(rs));
+    rs = await this.afterQuery(filter, rs);
+    return rs;
+  }
 }
 
 module.exports = GoodsSpecService;

+ 15 - 8
app/service/trade/afterSale.js

@@ -128,6 +128,8 @@ class AfterSaleService extends CrudService {
         if (uStatus === '4') {
           refundInfo = await this.returnOrder(entity, this.tran);
           update.status = '-4';
+          // 检查是否是团购
+          await this.exitGroup(entity, this.tran);
         }
         update.end_time = moment().format('YYYY-MM-DD HH:mm:ss');
       } else if (type === '5') {
@@ -250,14 +252,6 @@ class AfterSaleService extends CrudService {
       }
     }
   }
-
-  /**
-   * 售后退库存
-   * @param {Object} data 售后修改前的数据
-   * @param {Transaction} tran 数据库事务
-   */
-  async toReturnStock(data, tran) {}
-
   /**
    * 售后:修改拆分订单
    * @param {Object} data 售后修改前的数据
@@ -360,6 +354,19 @@ class AfterSaleService extends CrudService {
 
     return refundInfo;
   }
+  /**
+   * 售后 取消订单 & 拒收处理完成
+   * @param {Object} data 售后修改前的数据
+   * @param {Transaction} tran 数据库事务
+   */
+  async exitGroup(data, tran) {
+    const { order_detail } = data;
+    const orderDetail = await this.orderDetailModel.findById(order_detail);
+    if (!orderDetail) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到订单数据');
+    const { type, group, customer } = orderDetail;
+    if (type !== '1' || !group) return;
+    await this.ctx.service.group.group.refund({ group, customer }, tran);
+  }
 
   /**
    * 判断是否全额退的商品

+ 13 - 8
app/service/trade/orderDetail.js

@@ -129,9 +129,11 @@ class OrderDetailService extends CrudService {
       const r = afterSale.find(f => ObjectId(_.get(f, 'goods._id')).equals(g._id));
       if (r) g.is_afterSale = true;
       else g.is_afterSale = false;
-      const r2 = rate.find(f => ObjectId(_.get(f, 'goods._id')).equals(g._id));
-      if (r2) g.is_rate = true;
-      else g.is_rate = false;
+      const r2 = rate.find(f => ObjectId(_.get(f, 'goodsSpec')).equals(g._id));
+      if (r2) {
+        g.is_rate = true;
+        g.rate = r2._id;
+      } else g.is_rate = false;
     }
     res.goods = goods;
     return res;
@@ -217,23 +219,26 @@ class OrderDetailService extends CrudService {
     const total = _.get(_.head(t), 'id');
     const list = [];
     for (const i of rs) {
-      const { goods } = i;
+      const { goods, _id: orderDetail } = i;
       const obj = _.cloneDeep(i);
       const real_pay = this.ctx.service.util.orderDetail.computedRealPay(obj);
       obj.real_pay = real_pay;
       obj.buy_num_total = goods.reduce((p, n) => this.ctx.plus(p, n.buy_num), 0);
       for (const og of obj.goods) {
-        const { file = [] } = og;
+        const { file = [], _id: goodsSpec } = og;
         const gfile = _.get(og, 'goods.file', []);
         const nf = [ ...file, ...gfile ];
         const url = _.get(_.head(nf), 'url');
         og.url = url;
         delete og.file;
         delete og.goods.file;
+        // 评价
+        const q = { orderDetail, goodsSpec };
+        const rate = await this.goodsRateModel.findOne(q, { _id: 1 });
+        obj.rate = _.get(rate, '_id');
+
       }
-      // 评价与售后
-      const rate = await this.goodsRateModel.findOne({ orderDetail: obj._id }, { _id: 1 });
-      obj.rate = _.get(rate, '_id');
+      // 售后
       const asum = await this.afterSaleModel.count({ order_detail: obj._id, status: { $nin: [ '0', '!1', '!2', '!3', '!4', '!5' ] } });
       obj.is_afterSale = asum > 0;
       list.push(obj);

+ 1 - 1
app/service/trade/pay.js

@@ -226,7 +226,7 @@ class PayService extends CrudService {
    */
   getWxPayData(order_id, money, no) {
     const openid = _.get(this.ctx, 'user.openid');
-    const data = { config: this.appConfig, money, openid, order_no: no, desc: '购物', notice_url: this.payOrderReturnUrl(order_id) };
+    const data = { config: this.appConfig, money, openid, order_no: no, desc: '购物', notice_url: this.payOrderReturnUrl };
     return data;
   }
 

+ 16 - 0
app/service/user/admin.js

@@ -75,7 +75,23 @@ class AdminService extends CrudService {
     } finally {
       this.tran.clean();
     }
+  }
 
+  /**
+   * 检验当前管理员密码,生成操作key
+   * @param {Object} body 参数体
+   * @param {String} body.password 管理员密码
+   * @param {String} body.target 目标key
+   */
+  async toMakeKey({ password, target }) {
+    const admin = _.get(this.ctx, 'admin');
+    const _id = _.get(admin, '_id');
+    const taData = await this.model.findById(_id, '+password');
+    if (!taData) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到当前操作管理人');
+    const { password: upwd } = taData;
+    if (password !== upwd.secret) throw new BusinessError(ErrorCode.BAD_PASSWORD);
+    const key = this.ctx.service.util.user.getDeleteUserKey(_id, target);
+    return key;
   }
 }
 

+ 15 - 0
app/service/user/user.js

@@ -166,6 +166,21 @@ class UserService extends CrudService {
     const token = this.ctx.service.util.jwt.encrypt(user);
     return token;
   }
+
+  /**
+   * 删除用户
+   * @param {Object} param 地址参数
+   * @param {String} param.key 就是key
+   * @param {String} param.target 操作对象
+   */
+  async delete({ key, target }) {
+    const { opera_id, target: rt } = await this.ctx.service.util.user.getKeyData(key);
+    const admin = _.get(this.ctx, 'admin');
+    const _id = _.get(admin, '_id');
+    if (opera_id !== _id) throw new BusinessError(ErrorCode.DATA_INVALID, '不是同一个操作人,操作无效');
+    if (target !== rt) throw new BusinessError(ErrorCode.DATA_INVALID, '操作对象不是同一个数据,操作无效');
+    await this.model.deleteOne({ _id: target });
+  }
 }
 
 module.exports = UserService;

+ 61 - 0
app/service/util/rk.js

@@ -0,0 +1,61 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+//
+class RkService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'rk');
+    this.redis = this.app.redis;
+    this.keyPrefix = 'requestKey:';
+  }
+  // 检测,使用key
+  async urk() {
+    const key = _.get(this.ctx, 'request.header.rk');
+    const keyName = this.getKeyName(key);
+    const value = await this.redis.get(keyName);
+    if (!value) throw new BusinessError(ErrorCode.SERVICE_FAULT, '未找到请求key');
+    await this.redis.del(keyName);
+    const keyInfo = JSON.parse(value);
+    const obj = this.getKeyInfo();
+    if (!_.isEqual(keyInfo, obj)) throw new BusinessError(ErrorCode.DATA_INVALID, 'key校验错误,拒绝请求', { keyInfo, obj });
+  }
+  // 生成key
+  async crk() {
+    const obj = this.getKeyInfo();
+    const str = JSON.stringify(obj);
+    const key = Math.random().toString(36).substr(2, 15);
+    await this.redis.set(this.getKeyName(key), str, 'EX', 180);
+    return key;
+  }
+
+  getKeyInfo() {
+    const request = this.ctx.request;
+    const ip = _.get(request, 'header.x-real-ip');
+    const forward = _.get(request, 'header.x-forwarded-for');
+    const host = _.get(request, 'header.host');
+    const referer = _.get(request, 'header.referer');
+    const query = this.ctx.query;
+    const userAgent = _.get(request, 'header.user-agent');
+    const views = _.get(request, 'header.views');
+    const obj = {};
+    if (!ip) throw new BusinessError(ErrorCode.DATA_INVALID, '1-缺少生成key的参数');
+    if (!referer) throw new BusinessError(ErrorCode.DATA_INVALID, '2-缺少生成key的参数');
+    if (forward) obj.forward = forward;
+    if (host) obj.host = host;
+    if (query) obj.query = query;
+    if (userAgent) obj.userAgent = userAgent;
+    if (views) obj.views = views;
+    obj.ip = ip;
+    obj.referer = referer;
+    return obj;
+  }
+
+  getKeyName(key) {
+    return `${this.keyPrefix}${key}`;
+  }
+}
+
+module.exports = RkService;

+ 41 - 0
app/service/util/user.js

@@ -0,0 +1,41 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+//
+class UserService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'user');
+    this.redis = this.app.redis;
+    this.deleteUserKey = 'deleteUser:';
+    this.redisTimeout = this.app.config.redisTimeout;
+  }
+  /**
+   * 生成操作key
+   * @param {String} opera_id 操作人id
+   * @param {String} target 操作对象数据
+   */
+  async getDeleteUserKey(opera_id, target) {
+    // 生成key
+    const key = `${this.deleteUserKey}${opera_id}`;
+    // 存储该key可操作的人
+    await this.redis.set(key, target, 'EX', this.redisTimeout);
+    // 返回key
+    return key;
+  }
+  /**
+   * 解析key数据
+   * @param {Object} key 操作key
+   */
+  async getKeyData(key) {
+    const target = await this.redis.get(key);
+    if (target) await this.redis.del(key);
+    const arr = key.split(this.deleteUserKey);
+    const opera_id = _.last(arr);
+    return { opera_id, target };
+  }
+}
+
+module.exports = UserService;

+ 27 - 0
app/service/view/user.js

@@ -0,0 +1,27 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+//
+class UserService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'user');
+    this.orderModel = this.ctx.model.Trade.Order;
+    this.orderDetailModel = this.ctx.model.Trade.OrderDetail;
+    this.afterSaleModel = this.ctx.model.Trade.AfterSale;
+  }
+  async toDeal() {
+    const customer = _.get(this.ctx, 'user._id');
+    if (!customer) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到当前用户信息');
+    // 未支付订单/已支付订单/发货中订单/售后
+    const notPay = await this.orderModel.count({ customer, status: '0' });
+    const isPay = await this.orderDetailModel.count({ customer, status: '1' });
+    const allSend = await this.orderDetailModel.count({ customer, status: '2' });
+    const afterSale = await this.afterSaleModel.count({ customer, status: { $in: [ '0', '1', '2', '3', '4', '5' ] } });
+    return { notPay, isPay, allSend, afterSale };
+  }
+}
+
+module.exports = UserService;

+ 1 - 1
app/z_router/trade/pay.js

@@ -7,7 +7,7 @@ const rkey = 'pay';
 const ckey = 'trade.pay';
 const keyZh = '支付接口';
 const routes = [
-  { method: 'post', path: `${rkey}/order/:id`, controller: `${ckey}.callBackPayOrder`, zh: `${keyZh}-支付回调函数` },
+  { method: 'post', path: `${rkey}/order`, controller: `${ckey}.callBackPayOrder`, zh: `${keyZh}-支付回调函数` },
   { method: 'post', path: `${rkey}/toPayOrder`, controller: `${ckey}.toPayOrder`, zh: `${keyZh}-去支付订单` },
 ];
 

+ 1 - 0
app/z_router/user/admin.js

@@ -7,6 +7,7 @@ const rkey = 'admin';
 const ckey = 'user.admin';
 const keyZh = '管理员';
 const routes = [
+  { method: 'post', path: `${rkey}/toMakeKey`, controller: `${ckey}.toMakeKey`, name: `${ckey}toMakeKey`, zh: `${keyZh}-生成管理员操作key` },
   { method: 'post', path: `${rkey}/emailResetPwd`, controller: `${ckey}.emailResetPwd`, name: `${ckey}emailResetPwd`, zh: `${keyZh}-随机重置密码并发送邮件` },
   { method: 'post', path: `${rkey}/resetPwd/:id`, controller: `${ckey}.resetPwd`, name: `${ckey}ResetPwd`, zh: `修改密码${keyZh}` },
   { method: 'post', path: `${rkey}/login`, controller: `${ckey}.login`, name: `${ckey}Login`, zh: `${keyZh}登陆` },

+ 1 - 1
app/z_router/user/user.js

@@ -21,7 +21,7 @@ const routes = [
   { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
   { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: ['password'], name: `${ckey}Create`, zh: `创建${keyZh}` },
   { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: ['password'], name: `${ckey}Update`, zh: `修改${keyZh}` },
-  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+  { method: 'delete', path: `${rkey}`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
 ];
 
 module.exports = app => {

+ 2 - 0
app/z_router/util.js

@@ -7,6 +7,8 @@ const rkey = 'util';
 const ckey = 'util';
 const keyZh = '工具接口';
 const routes = [
+  { method: 'post', path: `${rkey}/crk`, controller: `${ckey}.crk`, zh: `${keyZh}-创建请求key` },
+  { method: 'get', path: `${rkey}/util`, controller: `${ckey}.util`, zh: `${keyZh}-工具` },
   { method: 'post', path: `${rkey}/checkCanBuy`, controller: `${ckey}.checkCanBuy`, zh: `${keyZh}-检查是否可以购买商品` },
   { method: 'post', path: `${rkey}/checkCartBuy`, controller: `${ckey}.checkCartBuy`, zh: `${keyZh}-检查选中的购物车商品是否可以购买` },
 ];

+ 1 - 0
app/z_router/view/index.js

@@ -4,4 +4,5 @@
 module.exports = app => {
   require('./goods')(app); // 商品视图
   require('./shop')(app); // 店铺视图
+  require('./user')(app); // 用户视图
 };

+ 13 - 0
app/z_router/view/user.js

@@ -0,0 +1,13 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'viewUser';
+const ckey = 'view.user';
+const keyZh = '用户相关视图';
+const routes = [{ method: 'get', path: `${rkey}/toDeal`, controller: `${ckey}.toDeal`, name: `${ckey}toDeal`, zh: '用户-订单相关未处理统计' }];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 2 - 2
config/config.default.js

@@ -15,7 +15,7 @@ module.exports = appInfo => {
   config.keys = appInfo.name + '_1664237342649_2194';
   config.appName = '天恩活泉商城-服务';
   // add your middleware config here
-  config.middleware = [ 'errorEmail', 'setUserFromToken', 'checkLogin' ]; // , 'checkLogin'
+  config.middleware = [ 'errorEmail', 'setUserFromToken', 'checkLogin' ]; // , 'checkLogin', 'checkUserRK'
 
   // add your user config here
   const userConfig = {
@@ -85,7 +85,7 @@ module.exports = appInfo => {
   config.routePrefix = '/point/v1/api';
   // 支付路由回调设置
   config.payReturn = {
-    order: id => `/point/v1/api/pay/order/${id}`,
+    order: '/dev/point/v1/api/pay/order',
   };
 
   // http请求前缀