Commit 5bcb2a32 authored by qinhaitao's avatar qinhaitao

fix: 🐛 概率配置

parent f0e1ad2c
{"version":3,"file":"save.controller.js","sourceRoot":"","sources":["../../src/controller/save.controller.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,4CAAsD;AACtD,0CAAoE;AACpE,8BAAqC;AACrC,sCAAkD;AAClD,sDAAkD;AAgBlD;IAAA;IA2DA,CAAC;IA1DC;;OAEG;IACH,mEAAmE;IAG7D,gDAAgB,GAAtB,UAAuB,OAA6B,EAAE,EAAE,EAAE,EAAgD;YAA/C,qBAAqB,QAAA;;;;;;wBACxE,KAAmF,OAAO,CAAC,IAAI,EAA7F,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,SAAS,eAAA,EAAE,OAAO,aAAA,EAAE,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA,CAAiB;wBAC7F,MAAM,GAAK,OAAO,OAAZ,CAAY;wBAGpB,QAAQ,GAAsB;4BAClC,KAAK,OAAA;4BACL,SAAS,WAAA;4BACT,OAAO,SAAA;4BACP,IAAI,MAAA;4BACJ,MAAM,QAAA;4BACN,KAAK,OAAA;4BACL,wBAAwB;4BACxB,uBAAuB,EAAE,OAAO,GAAG,qBAAS;yBAC7C,CAAA;wBAGK,YAAY,kBAA8B,SAAS,CAAC,CAAA;6BAGtD,CAAC,UAAU,EAAX,wBAAW;wBAEE,qBAAM,qBAAqB,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAA;;wBAApF,MAAM,GAAG,SAA2E;wBAC1F,IAAI,MAAM,IAAI,MAAM,KAAK,CAAC,EAAE;4BAC1B,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;yBAClC;6BAAM;4BACL,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,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC;wBAEnF,gBAAgB;sBAFmE;;wBAA/E,MAAM,GAAG,SAAsE;wBAGpD,qBAAM,qBAAqB,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC;4BAElG,aAAa;0BAFqF;;wBAA5F,KAAyB,SAAmE,EAA1F,OAAO,aAAA,EAAE,SAAS,eAAA;wBAGjB,qBAAM,qBAAqB,CAAC,gBAAgB,CAAC,SAAS,CAAC;4BAEhE,UAAU;0BAFsD;;wBADhE,aAAa;wBACb,MAAM,GAAG,SAAuD,CAAA;wBAGvD,qBAAM,qBAAqB,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,EAAA;;wBAD5F,UAAU;wBACV,MAAM,GAAG,SAAmF,CAAA;wBAE5F,IAAI,MAAM,IAAI,MAAM,KAAK,CAAC,EAAE;4BAC1B,sBAAO,kBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;yBAClC;6BAAM;4BACL,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;4BAC7B,sBAAO,kBAAY,CAAC,KAAK,CAAC,sBAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAA;yBAC7D;;;;;;KAEJ;IAtDD;QAFC,0BAAc,CAAC,yBAAU,CAAC;QAC1B,oBAAQ,CAAC,CAAC,+BAAqB,CAAC,CAAC;;;;iEAuDjC;IACH,4BAAC;CAAA,AA9DD,IA8DC;kBA9DoB,qBAAqB"}
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi ...@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __exportStar = (this && this.__exportStar) || function(m, exports) { var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
/** @format */ /** @format */
......
...@@ -45,4 +45,5 @@ export default class ActivityConfigService { ...@@ -45,4 +45,5 @@ export default class ActivityConfigService {
formatPrizeConfig(prizeConfig: Array<IActivityPrize>): { formatPrizeConfig(prizeConfig: Array<IActivityPrize>): {
prizeList: IActivityPrize[]; prizeList: IActivityPrize[];
}; };
setPrizeProbalityRange(prizes: IActivityPrize[]): IActivityPrize[];
} }
...@@ -58,6 +58,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -58,6 +58,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var sdk_1 = require("../sdk"); var sdk_1 = require("../sdk");
var db_1 = require("../db"); var db_1 = require("../db");
var constants_1 = require("../constants"); var constants_1 = require("../constants");
var utils_1 = require("../utils");
var ActivityConfigService = /** @class */ (function () { var ActivityConfigService = /** @class */ (function () {
function ActivityConfigService(context) { function ActivityConfigService(context) {
this.activityconfigDao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME); this.activityconfigDao = new sdk_1.BaseDao(context, db_1.ACTIVITY_CONFIG_DB_NAME);
...@@ -554,6 +555,19 @@ var ActivityConfigService = /** @class */ (function () { ...@@ -554,6 +555,19 @@ var ActivityConfigService = /** @class */ (function () {
prizeList: prizeConfig prizeList: prizeConfig
}; };
}; };
// 概率奖品配置 properiodfrom properiodto
ActivityConfigService.prototype.setPrizeProbalityRange = function (prizes) {
var originPeriod = 1;
return prizes.map(function (v) {
if (!v.probability)
return v;
var properiodfrom = originPeriod;
var properiodto = +originPeriod + utils_1.signFigures(+v.probability * 100) - 1;
originPeriod = +originPeriod + utils_1.signFigures(+v.probability * 100);
return __assign(__assign({}, v), { properiodfrom: properiodfrom,
properiodto: properiodto });
});
};
return ActivityConfigService; return ActivityConfigService;
}()); }());
exports.default = ActivityConfigService; exports.default = ActivityConfigService;
......
"use strict"; "use strict";
/** @format */ /** @format */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.AwardsService = exports.InstanceService = exports.SellerService = exports.TaobaoTopService = exports.ActivityconfigService = void 0;
var activityconfig_service_1 = require("./activityconfig.service"); var activityconfig_service_1 = require("./activityconfig.service");
Object.defineProperty(exports, "ActivityconfigService", { enumerable: true, get: function () { return activityconfig_service_1.default; } }); Object.defineProperty(exports, "ActivityconfigService", { enumerable: true, get: function () { return activityconfig_service_1.default; } });
var taobaoTop_service_1 = require("./taobaoTop.service"); var taobaoTop_service_1 = require("./taobaoTop.service");
......
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;AAEd,mEAA2E;AAAlE,+HAAA,OAAO,OAAyB;AACzC,yDAAiE;AAAxD,qHAAA,OAAO,OAAoB;AACpC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,uDAA+D;AAAtD,mHAAA,OAAO,OAAmB;AACnC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,mEAA2E;AAAlE,+HAAA,OAAO,OAAyB;AACzC,yDAAiE;AAAxD,qHAAA,OAAO,OAAoB;AACpC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB;AACjC,uDAA+D;AAAtD,mHAAA,OAAO,OAAmB;AACnC,mDAA2D;AAAlD,+GAAA,OAAO,OAAiB"}
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi ...@@ -8,7 +8,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
o[k2] = m[k]; o[k2] = m[k];
})); }));
var __exportStar = (this && this.__exportStar) || function(m, exports) { var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./logger"), exports); __exportStar(require("./logger"), exports);
......
/** @format */ /** @format */
export declare function MathRand(): string; export declare function MathRand(): string;
export declare const signFigures: (num: any, rank?: number) => number;
"use strict"; "use strict";
/** @format */ /** @format */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.MathRand = void 0; exports.signFigures = exports.MathRand = void 0;
function MathRand() { function MathRand() {
var Num = ''; var Num = '';
for (var i = 0; i < 6; i++) { for (var i = 0; i < 6; i++) {
...@@ -10,4 +10,24 @@ function MathRand() { ...@@ -10,4 +10,24 @@ function MathRand() {
return Num; return Num;
} }
exports.MathRand = MathRand; exports.MathRand = MathRand;
//小数相乘
exports.signFigures = function (num, rank) {
if (rank === void 0) { rank = 6; }
if (!num)
return 0;
var sign = num / Math.abs(num);
var number = num * sign;
var temp = rank - 1 - Math.floor(Math.log10(number));
var ans;
if (temp > 0) {
ans = parseFloat(number.toFixed(temp));
}
else if (temp < 0) {
ans = Math.round(number / Math.pow(10, temp)) * temp;
}
else {
ans = Math.round(number);
}
return ans * sign;
};
//# sourceMappingURL=math.js.map //# sourceMappingURL=math.js.map
\ No newline at end of file
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/utils/math.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAEd,SAAgB,QAAQ;IACtB,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA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C"}
\ No newline at end of file \ No newline at end of file
...@@ -28,7 +28,7 @@ export default class ActivitSaveController { ...@@ -28,7 +28,7 @@ export default class ActivitSaveController {
@paramsValidate(saveParams) @paramsValidate(saveParams)
@services([ActivityconfigService]) @services([ActivityconfigService])
async saveActivityInfo(context: ISaveActivityContext, {}, [activityconfigService]: [ActivityconfigService]) { async saveActivityInfo(context: ISaveActivityContext, {}, [activityconfigService]: [ActivityconfigService]) {
const { title = '', activityId = '', startTime, endTime, tasks = {}, rule, prizeList } = context.data let { title = '', activityId = '', startTime, endTime, tasks = {}, rule, prizeList } = context.data
const { openId } = context const { openId } = context
// 存在b_activity_config表里属于基础配置 // 存在b_activity_config表里属于基础配置
...@@ -43,6 +43,9 @@ export default class ActivitSaveController { ...@@ -43,6 +43,9 @@ export default class ActivitSaveController {
awardReceiveExpiredTime: endTime + _48_HOURS awardReceiveExpiredTime: endTime + _48_HOURS
} }
// 概率奖品配置需要增加 properiodfrom properiodto字段
// prizeList = activityconfigService.setPrizeProbalityRange(prizeList)
// 所有奖品均存在b_prize_config表里, 根据需求定义的奖品参数都要整合到allPrizeLists里 // 所有奖品均存在b_prize_config表里, 根据需求定义的奖品参数都要整合到allPrizeLists里
const allPrizeList: Array<IActivityPrize> = [...prizeList] const allPrizeList: Array<IActivityPrize> = [...prizeList]
......
...@@ -4,6 +4,7 @@ import { BaseDao } from '../sdk' ...@@ -4,6 +4,7 @@ import { BaseDao } from '../sdk'
import { ACTIVITY_CONFIG_DB_NAME, PRIZE_CONFIG_DB_NAME } from '../db' import { ACTIVITY_CONFIG_DB_NAME, PRIZE_CONFIG_DB_NAME } from '../db'
import { DELETE_STATUS, OPEN_PRIZE_STATUS } from '../constants' import { DELETE_STATUS, OPEN_PRIZE_STATUS } from '../constants'
import { signFigures } from '../utils';
export default class ActivityConfigService { export default class ActivityConfigService {
activityconfigDao: IBaseDao activityconfigDao: IBaseDao
...@@ -392,4 +393,19 @@ export default class ActivityConfigService { ...@@ -392,4 +393,19 @@ export default class ActivityConfigService {
prizeList: prizeConfig prizeList: prizeConfig
} }
} }
// 概率奖品配置 properiodfrom properiodto
setPrizeProbalityRange(prizes: IActivityPrize[]) {
let originPeriod = 1;
return prizes.map((v) => {
if(!v.probability) return v
const properiodfrom = originPeriod;
const properiodto = +originPeriod + signFigures(+v.probability * 100) - 1;
originPeriod = +originPeriod + signFigures(+v.probability * 100);
return {
...v,
properiodfrom,
properiodto
};
})
}
} }
...@@ -7,8 +7,8 @@ interface IActivityBaseInfo { ...@@ -7,8 +7,8 @@ interface IActivityBaseInfo {
startTime: number startTime: number
endTime: number endTime: number
title: string title: string
deleteStatus?: 1 | 2 deleteStatus?: number
openPrizeStatus?: 1 | 2 | 3 | 4 openPrizeStatus?: number
remark?: string remark?: string
createTime?: number createTime?: number
updateTime?: number updateTime?: number
...@@ -20,15 +20,15 @@ interface IActivityPrize { ...@@ -20,15 +20,15 @@ interface IActivityPrize {
_id?: string _id?: string
activityId?: string activityId?: string
ename?: string ename?: string
prizeType: 1 | 2 prizeDataType: number
type: 1 | 2 | 3 | 4 | 5 type: number
image: string image: string
name: string name: string
probability?: string | number probability?: string | number
properiodto: number properiodto: number
properiodfrom: number properiodfrom: number
lockStatus?: 1 | 2 lockStatus?: number
switchStock?: 1 | 2 switchStock?: number
rank?: string | number rank?: string | number
useUrl?: string useUrl?: string
stock: number stock: number
......
...@@ -7,3 +7,20 @@ export function MathRand() { ...@@ -7,3 +7,20 @@ export function MathRand() {
} }
return Num return Num
} }
//小数相乘
export const signFigures = function (num, rank = 6) {
if (!num) return 0;
const sign = num / Math.abs(num);
const number = num * sign;
const temp = rank - 1 - Math.floor(Math.log10(number));
let ans;
if (temp > 0) {
ans = parseFloat(number.toFixed(temp));
} else if (temp < 0) {
ans = Math.round(number / Math.pow(10, temp)) * temp;
} else {
ans = Math.round(number);
}
return ans * sign;
};
\ No newline at end of file
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