()
| 476 | } |
| 477 | |
| 478 | async getAssets() { |
| 479 | const assets = { coin: 0, integral: 0, ticket: 0, coupon: 0 }; |
| 480 | const accountNames = {}; |
| 481 | try { |
| 482 | const account = await this.ctx.request({ |
| 483 | apiPath: "/basic/shop/xcx/scene/getaccount", |
| 484 | shopId: this.shop.shopId, |
| 485 | token: this.token, |
| 486 | }); |
| 487 | const list = Array.isArray(account?.data) ? account.data : []; |
| 488 | for (const item of list) accountNames[Number(item.key)] = item.value; |
| 489 | } catch (e) { |
| 490 | $.log(`${this.prefix()} 查询账户类型失败: ${e.message || e}`); |
| 491 | } |
| 492 | |
| 493 | try { |
| 494 | const store = await this.ctx.request({ |
| 495 | apiPath: "/member/capp/member/store/get", |
| 496 | shopId: this.shop.shopId, |
| 497 | token: this.token, |
| 498 | }); |
| 499 | const list = Array.isArray(store?.data) ? store.data : []; |
| 500 | for (const item of list) addStoreAsset(assets, item.storeCategory, item.value, accountNames[Number(item.storeCategory)]); |
| 501 | } catch (e) { |
| 502 | $.log(`${this.prefix()} 查询资产失败: ${e.message || e}`); |
| 503 | } |
| 504 | try { |
| 505 | const coupon = await this.ctx.request({ |
| 506 | apiPath: "/coupon/capp/membercoupon/count", |
| 507 | shopId: this.shop.shopId, |
| 508 | token: this.token, |
| 509 | }); |
| 510 | if (coupon?.success) assets.coupon = Number(coupon.data || 0); |
| 511 | } catch (e) { |
| 512 | $.log(`${this.prefix()} 查询优惠券失败: ${e.message || e}`); |
| 513 | } |
| 514 | return assets; |
| 515 | } |
| 516 | |
| 517 | async getReward() { |
| 518 | const result = await this.ctx.request({ |
no test coverage detected