(memberInfo = {})
| 416 | } |
| 417 | |
| 418 | async getAssets(memberInfo = {}) { |
| 419 | const assets = { |
| 420 | coin: firstValue(memberInfo, ["MyScrip", "Coin", "CoinAmount", "Scrip", "Balance"]), |
| 421 | goldCoin: firstValue(memberInfo, ["GoldCoin", "GoldCoinAmount"]), |
| 422 | integral: firstValue(memberInfo, ["ARTotalIntegral", "Integral", "Exchange", "Points"]), |
| 423 | ticket: firstValue(memberInfo, ["Ticket", "TicketPackage", "TicketCount", "Lottery"]), |
| 424 | coupon: firstValue(memberInfo, ["Coupon", "CouponCount"]), |
| 425 | }; |
| 426 | |
| 427 | try { |
| 428 | const data = await this.request({ apiPath: "/ykb_huiyuan/api/v1/Member/GetMemberStoredValue" }); |
| 429 | const list = [ |
| 430 | ...(Array.isArray(data) ? data : []), |
| 431 | ...(Array.isArray(data?.List) ? data.List : []), |
| 432 | ...(Array.isArray(data?.Data) ? data.Data : []), |
| 433 | ...(Array.isArray(data?.LeaguerValues) ? data.LeaguerValues : []), |
| 434 | ...(Array.isArray(data?.Data?.LeaguerValues) ? data.Data.LeaguerValues : []), |
| 435 | ...(Array.isArray(data?.StoredValueList) ? data.StoredValueList : []), |
| 436 | ]; |
| 437 | const source = Array.isArray(data) ? {} : data || {}; |
| 438 | assets.coin = firstValue(source, ["BalanceNum", "MyScrip", "Coin", "CoinAmount", "Scrip", "Balance", "StoredCoin", "GameCoin"]); |
| 439 | assets.goldCoin = firstValue(source, ["GoldCoin", "GoldCoinAmount"]); |
| 440 | assets.integral = firstValue(source, ["ARTotalIntegral", "Integral", "Exchange", "Points", "Point"]); |
| 441 | assets.ticket = firstValue(source, ["Ticket", "TicketPackage", "TicketCount", "Lottery", "LotteryTicket"]); |
| 442 | assets.coupon = firstValue(source, ["Coupon", "CouponCount"]); |
| 443 | for (const item of list) { |
| 444 | const type = String(item.Equity || item.Type || item.StoredValueType || item.StoreCategory || item.Category || item.Name || item.Title || item.Key || ""); |
| 445 | const amount = firstValue(item, ["BalanceNum", "Balance", "AllAmount", "Amount", "Num", "Count", "Value", "Total", "Available", "StoredValue"]); |
| 446 | if (/GoldCoin|金币/i.test(type)) assets.goldCoin = amount; |
| 447 | else if (/Ticket|TicketPackage|彩票|票/i.test(type)) assets.ticket = amount; |
| 448 | else if (/Coupon|优惠券|券/i.test(type)) assets.coupon = amount; |
| 449 | else if (/Integral|Point|积分|Exchange/i.test(type)) assets.integral = amount; |
| 450 | else if (/Coin|代币|MyScrip|币/i.test(type)) assets.coin = amount; |
| 451 | } |
| 452 | } catch (e) { |
| 453 | this.log(`查询储值资产失败: ${e.message || e}`); |
| 454 | } |
| 455 | |
| 456 | return assets; |
| 457 | } |
| 458 | |
| 459 | async tryMemberCheckIn() { |
| 460 | try { |
no test coverage detected