Commit f7279c9b authored by qinhaitao's avatar qinhaitao

fix: 🐛 vip回调策略

parent 22c51efa
......@@ -30,11 +30,11 @@ export default class AwardsController {
/**
* 权益重新领取
*/
receiveEnamePrize(context: IContext<IReceiveEnameParams>, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | object[] | number[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<CodeType | IAwards, true>>;
receiveEnamePrize(context: IContext<IReceiveEnameParams>, {}: {}, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<CodeType | IAwards, true>>;
/**
* 概率抽奖
*/
drawLotteryPrize(context: IContext<IParams>, { userInfo }: IControllerInfos, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | object[] | number[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
drawLotteryPrize(context: IContext<IParams>, { userInfo }: IControllerInfos, [awardSer]: [AwardsService]): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<{
data: {
type: number;
name: string;
......
......@@ -18,5 +18,5 @@ export default class StatController {
/**
* 统计数据
*/
getStats(context: IContext<IGetStatsParams>): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | object[] | number[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any[], true>>;
getStats(context: IContext<IGetStatsParams>): Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any[], true>>;
}
......@@ -49,7 +49,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var decorator_1 = require("../decorator");
var sdk_1 = require("../sdk");
var service_1 = require("../service");
var config_1 = require("../config");
var isUseVipMock_1 = require("../utils/package/isUseVipMock");
var User = /** @class */ (function () {
function User() {
}
......@@ -95,17 +95,12 @@ var User = /** @class */ (function () {
var session = _a.session, activityUserNick = _a.activityUserNick;
var userService = _b[0];
return __awaiter(this, void 0, void 0, function () {
var _c, activityId, _d, inviteId, vipCallBackUrl, query, callbackUrl, result;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
_c = context.data, activityId = _c.activityId, _d = _c.inviteId, inviteId = _d === void 0 ? '' : _d;
vipCallBackUrl = config_1.getConfig(context).vipCallBackUrl;
query = "activityId=" + activityId + "&inviteId=" + inviteId;
callbackUrl = vipCallBackUrl + "&query=" + encodeURIComponent(query);
return [4 /*yield*/, userService.getShopVip(session, activityUserNick, callbackUrl)];
var result;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, userService.getShopVip(session, isUseVipMock_1.formatVipCbUrl(context), activityUserNick)];
case 1:
result = _e.sent();
result = _c.sent();
return [2 /*return*/, sdk_1.resultsModel.success(result)];
}
});
......
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAuE;AAEvE,8BAAqC;AACrC,sCAAuD;AACvD,oCAAqC;AAYrC;IAAA;IAkDA,CAAC;IAjDC;;OAEG;IAIG,oBAAK,GAAX,UACE,OAA+B,EAC/B,EAAqD,EACrD,EAA0D;YADxD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;wBAEnB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAElB,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;6BAE7B,CAAC,QAAQ,EAAT,wBAAS;wBACX,qBAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE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AC,CAAC;;;;0CAgBvB;IACH,WAAC;CAAA,AAlDD,IAkDC;kBAlDoB,IAAI"}
\ No newline at end of file
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/controller/user.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,0CAAuE;AAEvE,8BAAqC;AACrC,sCAAuD;AAEvD,8DAA8D;AAY9D;IAAA;IA4CA,CAAC;IA3CC;;OAEG;IAIG,oBAAK,GAAX,UACE,OAA+B,EAC/B,EAAqD,EACrD,EAA0D;YADxD,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,YAAY,kBAAA;YAChC,WAAW,QAAA,EAAE,aAAa,QAAA;;;;;;wBAEnB,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAElB,QAAQ,GAAK,OAAO,CAAC,IAAI,SAAjB,CAAiB;6BAE7B,CAAC,QAAQ,EAAT,wBAAS;wBACX,qBAAM,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,EAAA;;wBAArD,SAAqD,CAAA;;4BAErD,qBAAM,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAA;;wBAAjE,SAAiE,CAAA;;;oBAGnE,UAAU;oBACV,qBAAM,aAAa,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,EAAA;;wBADtD,UAAU;wBACV,SAAsD,CAAA;wBAEtD,sBAAO,kBAAY,CAAC,OAAO,CAAC;gCAC1B,MAAM,QAAA;6BACP,CAAC,EAAA;;;;KACH;IACD;;OAEG;IAGG,yBAAU,GAAhB,UACE,OAA6B,EAC7B,EAA+C,EAC/C,EAA4B;YAD1B,OAAO,aAAA,EAAE,gBAAgB,sBAAA;YAC1B,WAAW,QAAA;;;;;4BAGG,qBAAM,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,6BAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,EAAA;;wBAAzF,MAAM,GAAG,SAAgF;wBAE/F,sBAAO,kBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAA;;;;KACpC;IApCD;QAHC,uBAAW,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7D,6BAAiB;QACjB,oBAAQ,CAAC,CAAC,qBAAW,EAAE,uBAAa,CAAC,CAAC;;;;qCAsBtC;IAMD;QAFC,uBAAW,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3B,oBAAQ,CAAC,CAAC,qBAAW,CAAC,CAAC;;;;0CAUvB;IACH,WAAC;CAAA,AA5CD,IA4CC;kBA5CoB,IAAI"}
\ No newline at end of file
......@@ -53,7 +53,7 @@ var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var service_1 = require("../service");
var utils_1 = require("../utils");
var config_1 = require("../config");
var isUseVipMock_1 = require("../utils/package/isUseVipMock");
// 检验参数是否存在
exports.paramsCheck = function (params) {
return function (target, name, descriptor) {
......@@ -114,22 +114,18 @@ exports.vipCheck = function (_a) {
args[_i] = arguments[_i];
}
return __awaiter(this, void 0, void 0, function () {
var context, _a, otherArgs, _b, activityId, _c, inviteId, vipCallBackUrl, query, callbackUrl, userService, session, vipInfo;
return __generator(this, function (_d) {
switch (_d.label) {
var context, _a, otherArgs, userService, _b, session, userNick, vipInfo;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
context = args[0], _a = args[1], otherArgs = _a === void 0 ? {} : _a;
_b = context.data, activityId = _b.activityId, _c = _b.inviteId, inviteId = _c === void 0 ? '' : _c;
vipCallBackUrl = config_1.getConfig(context).vipCallBackUrl;
query = "activityId=" + activityId + "&inviteId=" + inviteId;
callbackUrl = vipCallBackUrl + "&query=" + encodeURIComponent(query);
userService = new service_1.UserService(context);
return [4 /*yield*/, utils_1.getSellerSession(context)];
case 1:
session = (_d.sent()).session;
return [4 /*yield*/, userService.getShopVip(session, callbackUrl)];
_b = _c.sent(), session = _b.session, userNick = _b.userNick;
return [4 /*yield*/, userService.getShopVip(session, isUseVipMock_1.formatVipCbUrl(context), userNick)];
case 2:
vipInfo = _d.sent();
vipInfo = _c.sent();
if (!vipInfo.isVip && intercept)
return [2 /*return*/, sdk_1.resultsModel.error(constants_1.CODE_TYPES.ERROR_NO_VIP, '非店铺会员', vipInfo)];
return [2 /*return*/, method.apply(target, [context, __assign(__assign({}, otherArgs), { vipInfo: vipInfo, session: session })])];
......
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/decorator/check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,8BAAqC;AACrC,0CAAyC;AACzC,sCAAqD;AACrD,kCAA2C;AAC3C,oCAAqC;AACrC,WAAW;AACE,QAAA,WAAW,GAAG,UAAC,MAAgB;IAC1C,OAAO,UAAU,MAAc,EAAE,IAAY,EAAE,UAA8B;QAC3E,IAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAA;QAE/B,UAAU,CAAC,KAAK,GAAG;YAAU,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAClC,IAAA,OAAO,GAAoB,IAAI,GAAxB,EAAE,KAAkB,IAAI,GAAR,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAQ;YACtC,IAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACtC,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;gBACvB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;oBAAE,OAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,iBAAK,KAAK,iB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CAAC,KAAK,CAAC,sBAAU,CAAC,sBAAsB,EAAE,gCAAO,CAAC,EAAA;yBACtE;wBACD,IAAI,WAAW,GAAG,OAAO,EAAE;4BACzB,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,mBAAmB,EAAE,gCAAO,CAAC,EAAA;yBACnE;wBACD,sBAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,wBAAO,SAAS,KAAE,YAAY,cAAA,IAAG,CAAC,EAAA;;;;KACvE,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -42,6 +42,7 @@ var service_1 = require("../service");
var utils_1 = require("../utils");
var sdk_1 = require("../sdk");
var constants_1 = require("../constants");
var isUseVipMock_1 = require("../utils/package/isUseVipMock");
function initBaseInfo(context, baseInfos) {
return __awaiter(this, void 0, void 0, function () {
var userService, userInfo, _a, session, userNick, vipInfo;
......@@ -65,7 +66,7 @@ function initBaseInfo(context, baseInfos) {
_b.label = 4;
case 4:
if (!!baseInfos.vipInfo) return [3 /*break*/, 6];
return [4 /*yield*/, userService.getShopVip(baseInfos.session)];
return [4 /*yield*/, userService.getShopVip(baseInfos.session, isUseVipMock_1.formatVipCbUrl(context), baseInfos.activityUserNick)];
case 5:
vipInfo = _b.sent();
baseInfos.vipInfo = vipInfo;
......
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/decorator/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,sCAAwC;AACxC,kCAAkE;AAClE,8BAAqC;AACrC,0CAAyC;AACzC,SAAe,YAAY,CAAC,OAA0B,EAAE,SAA2B;;;;;;oBAC3E,WAAW,GAAG,IAAI,qBAAW,CAAC,OAAO,CAAC,CAAA;yBAExC,CAAC,SAAS,CAAC,QAAQ,EAAnB,wBAAmB;oBACJ,qBAAM,WAAW,CAAC,WAAW,EAAE,EAAA;;oBAA1C,QAAQ,GAAG,SAA+B;oBAChD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M,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,EAAA;;4BAAxE,GAAG,GAAG,SAAkE,CAAA;;;;4BAExE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAK,CAAC,CAAA;4BAC3B,qBAAM,sBAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAK,CAAC,QAAQ,EAAE,EAAE,OAAK,CAAC,KAAK,CAAC,EAAA;;4BAAvE,SAAuE,CAAA;4BACvE,GAAG,GAAG,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAA;;gCAEnD,sBAAO,GAAG,EAAA;;;;SACX,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
\ No newline at end of file
......@@ -13,8 +13,8 @@ declare const _default: {
}>, {}: {}, [baseService]: [import("./service").BaseService]) => Promise<IResult<IActivityInfo>>;
getMyPrizeList: (context: IContext<import("./controller/awards.controller").IPrizeListParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<IAwards[]>>;
receiveObjectPrize: (context: IContext<import("./controller/awards.controller").IReceiveOjectParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<IResult<boolean>>;
receiveEnamePrize: (context: IContext<import("./controller/awards.controller").IReceiveEnameParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | object[] | number[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<import("taobao-mini-sdk/lib/utils/codetypes").CodeType | IAwards, true>>;
receiveEnamePrize: (context: IContext<import("./controller/awards.controller").IReceiveEnameParams>, {}: {}, [awardSer]: [import("./service").AwardsService]) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<import("taobao-mini-sdk/lib/utils/codetypes").CodeType | IAwards, true>>;
doHelp: (context: IContext<IParams>, { userInfo, vipInfo, activityInfo }: IControllerInfos, [userService, taskService, accessService]: [import("./service/user.service").default, import("./service").TaskService, import("./service").AccessService]) => Promise<IResult<boolean>>;
getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | object[] | number[] | string[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any[], true>>;
getStats: (context: IContext<import("./controller/stat.controller").IGetStatsParams>) => Promise<import("taobao-mini-sdk/lib/utils/resultmodel").Result<string | boolean | object | string[] | object[] | number[], false> | import("taobao-mini-sdk/lib/utils/resultmodel").Result<any[], true>>;
};
export default _default;
......@@ -24,7 +24,7 @@ declare class UserService extends BaseService {
* @param {调用淘宝接口的session} session
* @returns {isVip: boolean(是否是会员), url: string(入会链接) }
*/
getShopVip(session: string, activityUserNick?: string, callbackUrl?: string): Promise<IVipInfo>;
getShopVip(session: string, callbackUrl?: string, activityUserNick?: string): Promise<IVipInfo>;
/**
* 初始化用户数据
*
......
......@@ -123,9 +123,9 @@ var UserService = /** @class */ (function (_super) {
* @param {调用淘宝接口的session} session
* @returns {isVip: boolean(是否是会员), url: string(入会链接) }
*/
UserService.prototype.getShopVip = function (session, activityUserNick, callbackUrl) {
if (activityUserNick === void 0) { activityUserNick = ''; }
UserService.prototype.getShopVip = function (session, callbackUrl, activityUserNick) {
if (callbackUrl === void 0) { callbackUrl = ''; }
if (activityUserNick === void 0) { activityUserNick = ''; }
return __awaiter(this, void 0, void 0, function () {
var activityId, result, shopUrl, e_1;
return __generator(this, function (_a) {
......
This diff is collapsed.
/** @format */
/** @format */
export declare const isUseVipMock: (context: IContext<IParams>, userNick: string) => boolean;
export declare const formatVipCbUrl: (context: IContext<IParams>) => string;
"use strict";
/** @format */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUseVipMock = void 0;
exports.formatVipCbUrl = exports.isUseVipMock = void 0;
var index_1 = require("../../config/index");
/** @format */
// 测试环境 duib2账户mock数据
exports.isUseVipMock = function (context, userNick) {
var isTestEnv = context.env === 'test';
var isDuibaAccount = userNick.startsWith('duiba2');
return isTestEnv && isDuibaAccount;
};
// 格式化Vip回调地址
exports.formatVipCbUrl = function (context) {
var _a = context.data, activityId = _a.activityId, _b = _a.inviteId, inviteId = _b === void 0 ? '' : _b;
var vipCallBackUrl = index_1.getConfig(context).vipCallBackUrl;
// 拼接回调参数
var query = "activityId=" + activityId + "&inviteId=" + inviteId;
var callbackUrl = vipCallBackUrl + "&query=" + encodeURIComponent(query);
return callbackUrl;
};
//# sourceMappingURL=isUseVipMock.js.map
\ No newline at end of file
{"version":3,"file":"isUseVipMock.js","sourceRoot":"","sources":["../../../src/utils/package/isUseVipMock.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,qBAAqB;AACR,QAAA,YAAY,GAAG,UAAC,OAA0B,EAAE,QAAgB;IACvE,IAAM,SAAS,GAAG,OAAO,CAAC,GAAG,KAAK,MAAM,CAAA;IACxC,IAAM,cAAc,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAEpD,OAAO,SAAS,IAAI,cAAc,CAAA;AACpC,CAAC,CAAA"}
\ No newline at end of file
{"version":3,"file":"isUseVipMock.js","sourceRoot":"","sources":["../../../src/utils/package/isUseVipMock.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,4CAA8C;AAC9C,cAAc;AAEd,qBAAqB;AACR,QAAA,YAAY,GAAG,UAAC,OAA0B,EAAE,QAAgB;IACvE,IAAM,SAAS,GAAG,OAAO,CAAC,GAAG,KAAK,MAAM,CAAA;IACxC,IAAM,cAAc,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAEpD,OAAO,SAAS,IAAI,cAAc,CAAA;AACpC,CAAC,CAAA;AAED,aAAa;AACA,QAAA,cAAc,GAAG,UAAC,OAA0B;IACjD,IAAA,KAAgC,OAAO,CAAC,IAAI,EAA1C,UAAU,gBAAA,EAAE,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAiB,CAAA;IAC5C,IAAA,cAAc,GAAK,iBAAS,CAAC,OAAO,CAAC,eAAvB,CAAuB;IAE3C,SAAS;IACT,IAAI,KAAK,GAAG,gBAAc,UAAU,kBAAa,QAAU,CAAA;IAC3D,IAAI,WAAW,GAAc,cAAc,eAAU,kBAAkB,CAAC,KAAK,CAAG,CAAA;IAChF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import { services, paramsCheck, activityTimeCheck } from '../decorator'
import { resultsModel } from '../sdk'
import { UserService, AccessService } from '../service'
import { getConfig } from '../config'
import { formatVipCbUrl } from '../utils/package/isUseVipMock'
export interface IVipParams {
activityId: string
inviteId?: string // 需要助力回调时请求该接口
......@@ -55,14 +56,8 @@ export default class User {
{ session, activityUserNick }: IControllerInfos,
[userService]: [UserService]
): Promise<IResult<IVipInfo>> {
const { activityId, inviteId = '' } = context.data
let { vipCallBackUrl } = getConfig(context)
// 拼接回调参数
let query = `activityId=${activityId}&inviteId=${inviteId}`
let callbackUrl: string = `${vipCallBackUrl}&query=${encodeURIComponent(query)}`
const result = await userService.getShopVip(session, activityUserNick, callbackUrl)
const result = await userService.getShopVip(session, formatVipCbUrl(context), activityUserNick)
return resultsModel.success(result)
}
......
......@@ -4,6 +4,7 @@ import { CODE_TYPES } from '../constants'
import { UserService, BaseService } from '../service'
import { getSellerSession } from '../utils'
import { getConfig } from '../config'
import { formatVipCbUrl } from '../utils/package/isUseVipMock'
// 检验参数是否存在
export const paramsCheck = (params: string[]) => {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
......@@ -45,15 +46,11 @@ export const vipCheck = ({ intercept = true }) => {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
const [context, otherArgs = {}] = args
const { activityId, inviteId = '' } = context.data
const { vipCallBackUrl } = getConfig(context)
// 拼接回调参数
let query = `activityId=${activityId}&inviteId=${inviteId}`
let callbackUrl: string = `${vipCallBackUrl}&query=${encodeURIComponent(query)}`
const userService = new UserService(context)
const { session } = await getSellerSession(context)
const vipInfo = await userService.getShopVip(session, callbackUrl)
const { session, userNick } = await getSellerSession(context)
const vipInfo = await userService.getShopVip(session, formatVipCbUrl(context), userNick)
if (!vipInfo.isVip && intercept) return resultsModel.error(CODE_TYPES.ERROR_NO_VIP, '非店铺会员', vipInfo)
return method.apply(target, [context, { ...otherArgs, vipInfo, session }])
......
......@@ -3,6 +3,7 @@ import { UserService } from '../service'
import { getSellerSession, logFn, recordErrorLog } from '../utils'
import { resultsModel } from '../sdk'
import { CODE_TYPES } from '../constants'
import { formatVipCbUrl } from '../utils/package/isUseVipMock'
async function initBaseInfo(context: IContext<IParams>, baseInfos: IControllerInfos) {
const userService = new UserService(context)
......@@ -18,7 +19,7 @@ async function initBaseInfo(context: IContext<IParams>, baseInfos: IControllerIn
}
if (!baseInfos.vipInfo) {
const vipInfo = await userService.getShopVip(baseInfos.session)
const vipInfo = await userService.getShopVip(baseInfos.session, formatVipCbUrl(context), baseInfos.activityUserNick)
baseInfos.vipInfo = vipInfo
}
return baseInfos
......
......@@ -44,7 +44,7 @@ class UserService extends BaseService {
* @param {调用淘宝接口的session} session
* @returns {isVip: boolean(是否是会员), url: string(入会链接) }
*/
async getShopVip(session: string, activityUserNick: string = '', callbackUrl: string = ''): Promise<IVipInfo> {
async getShopVip(session: string, callbackUrl: string = '', activityUserNick: string = ''): Promise<IVipInfo> {
if (isUseVipMock(this.context, activityUserNick)) {
return VIP_MOCK
}
......
/** @format */
import { getConfig } from '../../config/index'
/** @format */
// 测试环境 duib2账户mock数据
export const isUseVipMock = (context: IContext<IParams>, userNick: string) => {
const isTestEnv = context.env === 'test'
......@@ -7,3 +10,14 @@ export const isUseVipMock = (context: IContext<IParams>, userNick: string) => {
return isTestEnv && isDuibaAccount
}
// 格式化Vip回调地址
export const formatVipCbUrl = (context: IContext<IParams>) => {
const { activityId, inviteId = '' } = context.data
let { vipCallBackUrl } = getConfig(context)
// 拼接回调参数
let query = `activityId=${activityId}&inviteId=${inviteId}`
let callbackUrl: string = `${vipCallBackUrl}&query=${encodeURIComponent(query)}`
return callbackUrl
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment