🐞 fix(shop): 修复弱网下商品可买次数为负问题

This commit is contained in:
dingchaolin
2023-03-06 15:00:28 +08:00
parent df88325372
commit 7719a2ad86
4 changed files with 63 additions and 4 deletions
+16
View File
@@ -106,6 +106,22 @@ export function getShopPrice(goodId: number, count: number, buyCount: number, st
}]
}
/**
* 获取商品的最大购买次数
*
* @export
* @param {string} str 比如: 1&0|2&50|3&100|4&150|5&200
*/
export function getShopMaxBuyTimes(str: string) {
let arr = parseShopPrice(str);
for (let { times, maxTimes } of arr) {
if (maxTimes === -1) {
return times;
}
}
return 0;
}
function parseShopPrice(str: string) {
let result = new Array<{ times: number, price: number, maxTimes: number }>();
if (!str) return result;