diff --git a/doc/api.md b/doc/api.md index 07d6986..98ce9a1 100644 --- a/doc/api.md +++ b/doc/api.md @@ -6,7 +6,8 @@ 1. [增加用户信息](#212), [抽奖转盘信息](#213), [抽奖](#214), [邀请奖励信息](#215), [挑战详情](#216) 接口 2. 所有接口增加post字段 version(当前版本固定取1.0.1)和sessionid(取自jcfw) 3. 获取店铺信息 增加返回店铺的数字编号 -4. 上报测验题目答案接口的 奖励信息 增加返回rewardType, 0: 表明该奖励为优惠券, 1: 抽奖券 +4. 上报测验题目答案相关接口的 奖励信息 增加返回rewardType, 0: 表明该奖励为优惠券, 1: 抽奖券 +5. 用户信息上报接口 增加上报当前店铺 @@ -444,6 +445,7 @@ | country | 国家 | | province | 省份 | | city | 城市 | +| shop | 店铺id | 3. Response: JSON @@ -528,7 +530,7 @@ ```js [ // 奖励列表 { - coupon: '优惠券的id', + coupon: '优惠券的id', // 如果该值为 empty, 说明是留空的, name: '优惠券名', count: 1, //数量 couponUrl: '优惠券详情图的url', diff --git a/src/api/controllers/game_user.controller.ts b/src/api/controllers/game_user.controller.ts index a89fd8b..9911c0a 100644 --- a/src/api/controllers/game_user.controller.ts +++ b/src/api/controllers/game_user.controller.ts @@ -81,7 +81,7 @@ class GameUserController extends BaseController { @router('post /api/:accountId/share_rewards') async shareRewards(req: any) { const { accountId, sid, sessionid } = req.params - if (!sid) { + if (!sid || !sessionid) { throw new ZError(10, '缺少必要参数: sid') } const shop = await Shop.fetchByID(sid) diff --git a/src/common/Extend.ts b/src/common/Extend.ts index 07a3f4b..c4a53ec 100644 --- a/src/common/Extend.ts +++ b/src/common/Extend.ts @@ -665,7 +665,7 @@ Object.defineProperties(Array.prototype, { let idx = this.indexOf(t) if (!~idx) { idx = this.length - this[idx] = t + this.push(t) } return idx }, diff --git a/src/models/user/GameUser.ts b/src/models/user/GameUser.ts index d2656ea..0ede4fd 100644 --- a/src/models/user/GameUser.ts +++ b/src/models/user/GameUser.ts @@ -32,6 +32,18 @@ class GameUserClass extends BaseModule { public locked: boolean @prop() public lockedTime?: Date + /** + * 该帐号关联的所有店铺 + * @type {string[]} + */ + @prop({ type: () => [String] }) + public shops: string[] + /** + * 当前关联店铺 + * @type {string} + */ + @prop() + public shop: string public static async getByAccountID(this: ReturnModelType, accountId: string) { let records = await this.find({ accountId }).limit(1) @@ -46,6 +58,13 @@ class GameUserClass extends BaseModule { } return map } + + public updateFromReq(data: any) { + super.updateFromReq(data) + if (data.shop) { + this.shops.pushOnce(data.shop) + } + } } export const GameUser = getModelForClass(GameUserClass, { existingConnection: GameUserClass.db })