@youzan-cloud/zan-saas-cli 0.0.0-stage → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPENDENCIES.json +50 -0
- package/INSTALL.md +79 -0
- package/LICENSE +21 -0
- package/NOTICE +1 -0
- package/README.md +151 -2
- package/THIRD_PARTY_NOTICES.txt +162 -0
- package/bin/zan-saas-cli.js +28 -0
- package/internal/registry/index.js +123 -0
- package/internal/registry/manifest.json +424 -0
- package/npm-shrinkwrap.json +86 -0
- package/package.json +33 -4
- package/skills/README.md +30 -0
- package/skills/zan-saas/SKILL.md +54 -0
- package/skills/zan-saas/references/host-entry.md +25 -0
- package/skills/zan-saas-access/SKILL.md +37 -0
- package/skills/zan-saas-access/references/role-list.md +11 -0
- package/skills/zan-saas-access/references/staff-perms-get.md +11 -0
- package/skills/zan-saas-aftersale/SKILL.md +31 -0
- package/skills/zan-saas-aftersale/references/case-list.md +13 -0
- package/skills/zan-saas-aftersale/references/case-scan.md +31 -0
- package/skills/zan-saas-benefit/SKILL.md +46 -0
- package/skills/zan-saas-benefit/references/card-get.md +7 -0
- package/skills/zan-saas-benefit/references/card-grant-list.md +11 -0
- package/skills/zan-saas-benefit/references/card-list.md +7 -0
- package/skills/zan-saas-benefit/references/customer-card-get.md +7 -0
- package/skills/zan-saas-benefit/references/customer-card-list.md +7 -0
- package/skills/zan-saas-coupon/SKILL.md +41 -0
- package/skills/zan-saas-coupon/references/activity-get.md +11 -0
- package/skills/zan-saas-coupon/references/activity-list.md +15 -0
- package/skills/zan-saas-coupon/references/voucher-get.md +13 -0
- package/skills/zan-saas-coupon/references/voucher-list.md +25 -0
- package/skills/zan-saas-customer/SKILL.md +73 -0
- package/skills/zan-saas-customer/references/customer-scan.md +11 -0
- package/skills/zan-saas-customer/references/segment-list.md +22 -0
- package/skills/zan-saas-fulfillment/SKILL.md +36 -0
- package/skills/zan-saas-fulfillment/references/delivery-get.md +11 -0
- package/skills/zan-saas-fulfillment/references/shipment-list.md +11 -0
- package/skills/zan-saas-fulfillment/references/waybill-get.md +9 -0
- package/skills/zan-saas-interaction/SKILL.md +37 -0
- package/skills/zan-saas-interaction/references/lottery-get.md +11 -0
- package/skills/zan-saas-interaction/references/lottery-list.md +19 -0
- package/skills/zan-saas-item/SKILL.md +61 -0
- package/skills/zan-saas-item/references/attribute-list.md +11 -0
- package/skills/zan-saas-item/references/brand-list.md +7 -0
- package/skills/zan-saas-item/references/classification-get.md +7 -0
- package/skills/zan-saas-item/references/classification-list.md +7 -0
- package/skills/zan-saas-item/references/group-list.md +9 -0
- package/skills/zan-saas-item/references/item-content.md +9 -0
- package/skills/zan-saas-item/references/item-get.md +9 -0
- package/skills/zan-saas-item/references/item-search.md +23 -0
- package/skills/zan-saas-item/references/product-identity.md +11 -0
- package/skills/zan-saas-member/SKILL.md +41 -0
- package/skills/zan-saas-member/references/customer-level-get.md +7 -0
- package/skills/zan-saas-member/references/growth-log-list.md +17 -0
- package/skills/zan-saas-member/references/membership-get.md +7 -0
- package/skills/zan-saas-order/SKILL.md +56 -0
- package/skills/zan-saas-order/references/order-get.md +26 -0
- package/skills/zan-saas-order/references/order-list.md +25 -0
- package/skills/zan-saas-order/references/order-scan.md +35 -0
- package/skills/zan-saas-org/SKILL.md +37 -0
- package/skills/zan-saas-org/references/staff-get.md +15 -0
- package/skills/zan-saas-org/references/staff-role-get.md +11 -0
- package/skills/zan-saas-org/references/unit-get.md +11 -0
- package/skills/zan-saas-org/references/unit-list.md +15 -0
- package/skills/zan-saas-points/SKILL.md +42 -0
- package/skills/zan-saas-points/references/account-get.md +7 -0
- package/skills/zan-saas-points/references/log-list.md +17 -0
- package/skills/zan-saas-points/references/rule-list.md +2 -0
- package/skills/zan-saas-privacy/SKILL.md +30 -0
- package/skills/zan-saas-privacy/references/field-decrypt.md +19 -0
- package/skills/zan-saas-shared/SKILL.md +94 -0
- package/skills/zan-saas-shared/references/authentication.md +52 -0
- package/skills/zan-saas-shared/references/value-processing.md +27 -0
- package/skills/zan-saas-stock/SKILL.md +28 -0
- package/skills/zan-saas-stock/references/log-list.md +11 -0
- package/skills/zan-saas-valuecard/SKILL.md +37 -0
- package/skills/zan-saas-valuecard/references/card-get.md +13 -0
- package/skills/zan-saas-valuecard/references/card-list.md +11 -0
- package/src/auth/browser.js +28 -0
- package/src/auth/callback-server.js +99 -0
- package/src/auth/config.js +53 -0
- package/src/auth/credential-store.js +109 -0
- package/src/auth/oauth-client.js +105 -0
- package/src/auth/pkce.js +28 -0
- package/src/auth/session.js +178 -0
- package/src/auth/tool.js +25 -0
- package/src/cli/command-paths.js +126 -0
- package/src/cli/context-help.js +102 -0
- package/src/cli/diagnostic-command.js +57 -0
- package/src/cli/domain-catalog.js +42 -0
- package/src/cli/help-text.js +32 -0
- package/src/cli/native-loader.js +120 -0
- package/src/cli/native-path.js +22 -0
- package/src/cli/parser-policy.js +141 -0
- package/src/cli/program.js +134 -0
- package/src/cli/skill-catalog.js +241 -0
- package/src/commands/native/access/commands.index.json +24 -0
- package/src/commands/native/access/domain.json +3 -0
- package/src/commands/native/access/role/list/command.js +141 -0
- package/src/commands/native/access/role/list/schema.json +393 -0
- package/src/commands/native/access/staff-perms/get/command.js +119 -0
- package/src/commands/native/access/staff-perms/get/schema.json +703 -0
- package/src/commands/native/aftersale/case/get/command.js +104 -0
- package/src/commands/native/aftersale/case/get/exact-json.js +52 -0
- package/src/commands/native/aftersale/case/get/money.js +28 -0
- package/src/commands/native/aftersale/case/get/projection.js +120 -0
- package/src/commands/native/aftersale/case/get/query.js +72 -0
- package/src/commands/native/aftersale/case/get/schema.json +134 -0
- package/src/commands/native/aftersale/case/list/command.js +135 -0
- package/src/commands/native/aftersale/case/list/schema.json +1095 -0
- package/src/commands/native/aftersale/case/scan/command.js +110 -0
- package/src/commands/native/aftersale/case/scan/query.js +62 -0
- package/src/commands/native/aftersale/case/scan/scan.js +78 -0
- package/src/commands/native/aftersale/case/scan/schema.json +964 -0
- package/src/commands/native/aftersale/case/scan/search.js +108 -0
- package/src/commands/native/aftersale/commands.index.json +42 -0
- package/src/commands/native/aftersale/domain.json +3 -0
- package/src/commands/native/aftersale/refund/list/command.js +97 -0
- package/src/commands/native/aftersale/refund/list/money.js +25 -0
- package/src/commands/native/aftersale/refund/list/projection.js +50 -0
- package/src/commands/native/aftersale/refund/list/query.js +73 -0
- package/src/commands/native/aftersale/refund/list/schema.json +130 -0
- package/src/commands/native/aftersale/shared/query.js +58 -0
- package/src/commands/native/aftersale/shared/search.js +128 -0
- package/src/commands/native/benefit/card-definition/get/command.js +110 -0
- package/src/commands/native/benefit/card-definition/get/schema.json +545 -0
- package/src/commands/native/benefit/card-definition/list/command.js +106 -0
- package/src/commands/native/benefit/card-definition/list/schema.json +690 -0
- package/src/commands/native/benefit/card-grant/list/command.js +135 -0
- package/src/commands/native/benefit/card-grant/list/schema.json +758 -0
- package/src/commands/native/benefit/commands.index.json +51 -0
- package/src/commands/native/benefit/customer-card/get/command.js +110 -0
- package/src/commands/native/benefit/customer-card/get/schema.json +340 -0
- package/src/commands/native/benefit/customer-card/list/command.js +103 -0
- package/src/commands/native/benefit/customer-card/list/schema.json +731 -0
- package/src/commands/native/benefit/domain.json +3 -0
- package/src/commands/native/coupon/activity/get/command.js +183 -0
- package/src/commands/native/coupon/activity/get/schema.json +624 -0
- package/src/commands/native/coupon/activity/list/command.js +169 -0
- package/src/commands/native/coupon/activity/list/schema.json +845 -0
- package/src/commands/native/coupon/commands.index.json +42 -0
- package/src/commands/native/coupon/domain.json +3 -0
- package/src/commands/native/coupon/shared/query.js +15 -0
- package/src/commands/native/coupon/voucher/get/command.js +113 -0
- package/src/commands/native/coupon/voucher/get/schema.json +147 -0
- package/src/commands/native/coupon/voucher/list/command.js +155 -0
- package/src/commands/native/coupon/voucher/list/schema.json +772 -0
- package/src/commands/native/customer/commands.index.json +96 -0
- package/src/commands/native/customer/customer/get/adapter.js +82 -0
- package/src/commands/native/customer/customer/get/command.js +106 -0
- package/src/commands/native/customer/customer/get/schema.json +958 -0
- package/src/commands/native/customer/customer/list/command.js +78 -0
- package/src/commands/native/customer/customer/list/input.js +145 -0
- package/src/commands/native/customer/customer/list/query.js +103 -0
- package/src/commands/native/customer/customer/list/schema.json +969 -0
- package/src/commands/native/customer/customer/scan/command.js +80 -0
- package/src/commands/native/customer/customer/scan/scan.js +92 -0
- package/src/commands/native/customer/customer/scan/schema.json +211 -0
- package/src/commands/native/customer/customer-tag/get/command.js +166 -0
- package/src/commands/native/customer/customer-tag/get/schema.json +317 -0
- package/src/commands/native/customer/customer-tag/list/command.js +143 -0
- package/src/commands/native/customer/customer-tag/list/schema.json +259 -0
- package/src/commands/native/customer/domain.json +3 -0
- package/src/commands/native/customer/segment/list/command.js +96 -0
- package/src/commands/native/customer/segment/list/query.js +98 -0
- package/src/commands/native/customer/segment/list/schema.json +135 -0
- package/src/commands/native/customer/segment-customer/list/command.js +171 -0
- package/src/commands/native/customer/segment-customer/list/schema.json +123 -0
- package/src/commands/native/customer/shared/search-input.js +179 -0
- package/src/commands/native/customer/shared/search-page.js +54 -0
- package/src/commands/native/customer/tag/get/command.js +73 -0
- package/src/commands/native/customer/tag/get/schema.json +339 -0
- package/src/commands/native/customer/tagcategory/get/command.js +80 -0
- package/src/commands/native/customer/tagcategory/get/query.js +98 -0
- package/src/commands/native/customer/tagcategory/get/schema.json +339 -0
- package/src/commands/native/customer/tagcategory/list/command.js +127 -0
- package/src/commands/native/customer/tagcategory/list/schema.json +394 -0
- package/src/commands/native/fulfillment/commands.index.json +33 -0
- package/src/commands/native/fulfillment/delivery/get/command.js +107 -0
- package/src/commands/native/fulfillment/delivery/get/projection.js +142 -0
- package/src/commands/native/fulfillment/delivery/get/schema.json +173 -0
- package/src/commands/native/fulfillment/domain.json +3 -0
- package/src/commands/native/fulfillment/shipment/list/command.js +83 -0
- package/src/commands/native/fulfillment/shipment/list/projection.js +130 -0
- package/src/commands/native/fulfillment/shipment/list/schema.json +752 -0
- package/src/commands/native/fulfillment/waybill/get/command.js +193 -0
- package/src/commands/native/fulfillment/waybill/get/response.js +68 -0
- package/src/commands/native/fulfillment/waybill/get/schema.json +190 -0
- package/src/commands/native/interaction/commands.index.json +24 -0
- package/src/commands/native/interaction/domain.json +3 -0
- package/src/commands/native/interaction/lottery/get/command.js +61 -0
- package/src/commands/native/interaction/lottery/get/query.js +152 -0
- package/src/commands/native/interaction/lottery/get/schema.json +1004 -0
- package/src/commands/native/interaction/lottery/list/command.js +176 -0
- package/src/commands/native/interaction/lottery/list/schema.json +898 -0
- package/src/commands/native/item/attribute/list/command.js +122 -0
- package/src/commands/native/item/attribute/list/schema.json +727 -0
- package/src/commands/native/item/brand/list/command.js +114 -0
- package/src/commands/native/item/brand/list/schema.json +725 -0
- package/src/commands/native/item/classification/get/command.js +87 -0
- package/src/commands/native/item/classification/get/schema.json +596 -0
- package/src/commands/native/item/classification/list/command.js +105 -0
- package/src/commands/native/item/classification/list/schema.json +676 -0
- package/src/commands/native/item/commands.index.json +87 -0
- package/src/commands/native/item/domain.json +1 -0
- package/src/commands/native/item/group/list/command.js +122 -0
- package/src/commands/native/item/group/list/schema.json +809 -0
- package/src/commands/native/item/item/get/command.js +122 -0
- package/src/commands/native/item/item/get/schema.json +3799 -0
- package/src/commands/native/item/item/list/command.js +7 -0
- package/src/commands/native/item/item/list/schema.json +1118 -0
- package/src/commands/native/item/item/scan/command.js +7 -0
- package/src/commands/native/item/item/scan/schema.json +1046 -0
- package/src/commands/native/item/item-content/get/command.js +54 -0
- package/src/commands/native/item/item-content/get/schema.json +677 -0
- package/src/commands/native/item/shared/api.js +31 -0
- package/src/commands/native/item/shared/content.js +20 -0
- package/src/commands/native/item/shared/diagnostics.js +61 -0
- package/src/commands/native/item/shared/h5.js +63 -0
- package/src/commands/native/item/shared/identity.js +62 -0
- package/src/commands/native/item/shared/normalize.js +49 -0
- package/src/commands/native/item/shared/scope.js +22 -0
- package/src/commands/native/item/shared/search-command.js +61 -0
- package/src/commands/native/item/shared/search-options.js +150 -0
- package/src/commands/native/item/shared/search.js +158 -0
- package/src/commands/native/member/commands.index.json +60 -0
- package/src/commands/native/member/customer-level/get/command.js +122 -0
- package/src/commands/native/member/customer-level/get/schema.json +300 -0
- package/src/commands/native/member/domain.json +3 -0
- package/src/commands/native/member/growth/get/command.js +64 -0
- package/src/commands/native/member/growth/get/schema.json +283 -0
- package/src/commands/native/member/growth-log/list/command.js +203 -0
- package/src/commands/native/member/growth-log/list/schema.json +695 -0
- package/src/commands/native/member/level/get/command.js +70 -0
- package/src/commands/native/member/level/get/query.js +125 -0
- package/src/commands/native/member/level/get/schema.json +339 -0
- package/src/commands/native/member/level/list/command.js +50 -0
- package/src/commands/native/member/level/list/query.js +109 -0
- package/src/commands/native/member/level/list/schema.json +104 -0
- package/src/commands/native/member/membership/get/command.js +78 -0
- package/src/commands/native/member/membership/get/schema.json +283 -0
- package/src/commands/native/order/commands.index.json +33 -0
- package/src/commands/native/order/domain.json +3 -0
- package/src/commands/native/order/order/get/command.js +155 -0
- package/src/commands/native/order/order/get/schema.json +1167 -0
- package/src/commands/native/order/order/list/command.js +230 -0
- package/src/commands/native/order/order/list/schema.json +1363 -0
- package/src/commands/native/order/order/scan/command.js +148 -0
- package/src/commands/native/order/order/scan/scan.js +89 -0
- package/src/commands/native/order/order/scan/schema.json +1445 -0
- package/src/commands/native/order/shared/projection.js +183 -0
- package/src/commands/native/order/shared/query.js +84 -0
- package/src/commands/native/order/shared/search.js +112 -0
- package/src/commands/native/org/commands.index.json +42 -0
- package/src/commands/native/org/domain.json +3 -0
- package/src/commands/native/org/shared/single-staff.js +115 -0
- package/src/commands/native/org/staff/get/command.js +148 -0
- package/src/commands/native/org/staff/get/schema.json +114 -0
- package/src/commands/native/org/staff-role/get/command.js +45 -0
- package/src/commands/native/org/staff-role/get/schema.json +93 -0
- package/src/commands/native/org/unit/get/command.js +131 -0
- package/src/commands/native/org/unit/get/schema.json +478 -0
- package/src/commands/native/org/unit/list/command.js +187 -0
- package/src/commands/native/org/unit/list/schema.json +828 -0
- package/src/commands/native/points/account/get/command.js +65 -0
- package/src/commands/native/points/account/get/schema.json +303 -0
- package/src/commands/native/points/commands.index.json +33 -0
- package/src/commands/native/points/domain.json +3 -0
- package/src/commands/native/points/log/list/command.js +141 -0
- package/src/commands/native/points/log/list/schema.json +761 -0
- package/src/commands/native/points/rule/list/command.js +82 -0
- package/src/commands/native/points/rule/list/schema.json +294 -0
- package/src/commands/native/privacy/commands.index.json +15 -0
- package/src/commands/native/privacy/domain.json +3 -0
- package/src/commands/native/privacy/field/decrypt/command.js +185 -0
- package/src/commands/native/privacy/field/decrypt/schema.json +656 -0
- package/src/commands/native/privacy/shared/order-source.js +33 -0
- package/src/commands/native/stock/commands.index.json +15 -0
- package/src/commands/native/stock/domain.json +3 -0
- package/src/commands/native/stock/log/list/command.js +207 -0
- package/src/commands/native/stock/log/list/schema.json +922 -0
- package/src/commands/native/valuecard/card/get/command.js +107 -0
- package/src/commands/native/valuecard/card/get/schema.json +683 -0
- package/src/commands/native/valuecard/card/list/command.js +136 -0
- package/src/commands/native/valuecard/card/list/pagination.js +23 -0
- package/src/commands/native/valuecard/card/list/schema.json +780 -0
- package/src/commands/native/valuecard/commands.index.json +24 -0
- package/src/commands/native/valuecard/domain.json +3 -0
- package/src/commands/native/valuecard/shared/projection.js +57 -0
- package/src/commands/system/api.js +47 -0
- package/src/commands/system/auth.js +118 -0
- package/src/commands/system/contracts.js +373 -0
- package/src/commands/system/doctor.js +24 -0
- package/src/commands/system/install.js +41 -0
- package/src/commands/system/printer.js +16 -0
- package/src/commands/system/schema.js +162 -0
- package/src/commands/system/shop-guidance.js +9 -0
- package/src/commands/system/shop.js +237 -0
- package/src/commands/system/skills.js +49 -0
- package/src/execution/beijing-date-time.js +29 -0
- package/src/execution/beijing-time.js +21 -0
- package/src/execution/bounded-input.js +42 -0
- package/src/execution/command-io.js +137 -0
- package/src/execution/command-policy.js +41 -0
- package/src/execution/command-schema.js +131 -0
- package/src/execution/datetime.js +83 -0
- package/src/execution/error-details.js +399 -0
- package/src/execution/error-model.js +82 -0
- package/src/execution/exact-json.js +80 -0
- package/src/execution/list-total.js +10 -0
- package/src/execution/money.js +59 -0
- package/src/execution/parser-error.js +66 -0
- package/src/execution/privacy.js +197 -0
- package/src/execution/public-schema.js +52 -0
- package/src/execution/query-api.js +101 -0
- package/src/execution/range.js +84 -0
- package/src/execution/request-state.js +55 -0
- package/src/execution/schema-completeness.js +116 -0
- package/src/execution/shop-query.js +54 -0
- package/src/execution/target-shop-default.js +23 -0
- package/src/execution/target-shop.js +49 -0
- package/src/identity/context-store.js +54 -0
- package/src/identity/context.js +38 -0
- package/src/installation/install.js +158 -0
- package/src/installation/npm-error.js +93 -0
- package/src/installation/skill.js +113 -0
- package/src/transport/account-api.js +152 -0
- package/src/transport/api.js +199 -0
- package/src/transport/shop-app.js +63 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
4
|
+
|
|
5
|
+
const { Command, Option } = require('commander');
|
|
6
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
7
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
8
|
+
const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
|
|
9
|
+
const { object } = require('../../../../../execution/query-api');
|
|
10
|
+
const schema = require('./schema.json');
|
|
11
|
+
|
|
12
|
+
const command = 'points.account.get';
|
|
13
|
+
const reject = (category, stage, scope, state, facts) =>
|
|
14
|
+
failure(command, category, stage, scope, state, facts);
|
|
15
|
+
|
|
16
|
+
function createCommand({ context } = {}) {
|
|
17
|
+
return new Command('get')
|
|
18
|
+
.description('查询一个已知客户的当前积分,不查询流水、规则或客户档案')
|
|
19
|
+
.allowExcessArguments(false)
|
|
20
|
+
.exitOverride(error => {
|
|
21
|
+
if (['commander.helpDisplayed', 'commander.version'].includes(error.code)) throw error;
|
|
22
|
+
throw reject('parameter', 'input');
|
|
23
|
+
})
|
|
24
|
+
.requiredOption('--yz-open-id <id>', '必填:客户 yzOpenId;不是手机号、微信 openId 或员工 ID')
|
|
25
|
+
.option('--kdt-id <id>', '目标店铺正安全整数;省略取有效上下文 shopId,非总部不可跨店')
|
|
26
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进')
|
|
27
|
+
.choices(['json', 'pretty']).default('json'))
|
|
28
|
+
.option('--dry-run', '本地预览积分请求与店铺核验请求,不读凭证、不联网')
|
|
29
|
+
.addHelpText('after', `
|
|
30
|
+
输出仅 data.account.points,保留 0 和负安全整数;缺值不能补成 0。
|
|
31
|
+
固定账号类型 5;最多一次店铺核验与一次账户查询,不重试、不换身份或店铺。
|
|
32
|
+
不查询账户版本,保留服务端扩展点默认行为,不承诺冻结、过期或累计积分。
|
|
33
|
+
支持主、辅 API 已证明范围的交集:微商城/零售单店、连锁 D 总部、连锁 L 总部及 L 总部高级版;不扩展到连锁网店/分店。
|
|
34
|
+
真实执行需有效四字段上下文及同店授权凭证;店铺核验不证明员工 OAuth 或连锁账本独立性。
|
|
35
|
+
契约:zan-saas schema points.account.get --format json
|
|
36
|
+
示例:zan-saas points account get --yz-open-id customer-1 --kdt-id 63077 --dry-run
|
|
37
|
+
`)
|
|
38
|
+
.action(async options => {
|
|
39
|
+
const scope = resolveTargetShop(options, context, command);
|
|
40
|
+
let input;
|
|
41
|
+
try {
|
|
42
|
+
input = { ...scope, yzOpenId: options.yzOpenId.trim() };
|
|
43
|
+
validateCommandValue(schema, 'input', input);
|
|
44
|
+
} catch { throw reject('parameter', 'input', scope); }
|
|
45
|
+
const preview = {
|
|
46
|
+
method: 'POST', path: schema.api.path,
|
|
47
|
+
body: { user: { account_type: 5, account_id: input.yzOpenId } },
|
|
48
|
+
scope, prerequisites: [{ method: 'POST', path: bindingPath, body: {} }]
|
|
49
|
+
};
|
|
50
|
+
validateCommandValue(schema, 'preview', preview);
|
|
51
|
+
let output = preview;
|
|
52
|
+
if (!options.dryRun) {
|
|
53
|
+
const read = await createShopQuery(scope, command);
|
|
54
|
+
const { data, facts } = await read(preview.path, preview.body, 'account');
|
|
55
|
+
if (!object(data) || !Number.isSafeInteger(data.point)) {
|
|
56
|
+
throw reject('protocol', 'account-model', scope, 'sent', facts);
|
|
57
|
+
}
|
|
58
|
+
output = { data: { account: { points: data.point } } };
|
|
59
|
+
validateCommandValue(schema, 'output', output);
|
|
60
|
+
}
|
|
61
|
+
console.log(JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"input": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"kdtId",
|
|
7
|
+
"yzOpenId"
|
|
8
|
+
],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"kdtId": {
|
|
12
|
+
"$ref": "#/definitions/shopId"
|
|
13
|
+
},
|
|
14
|
+
"yzOpenId": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"minLength": 1,
|
|
17
|
+
"pattern": "^\\S(?:[\\s\\S]*\\S)?$",
|
|
18
|
+
"description": "去除首尾空白后的单个客户 yzOpenId,不是手机号、微信 openId 或员工 ID。"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"description": "CLI 解析参数并完成必要上下文补全后的业务输入;不是直接传入 CLI 的 JSON。原始选项、必填条件和默认值见 options。"
|
|
22
|
+
},
|
|
23
|
+
"output": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"required": [
|
|
26
|
+
"data"
|
|
27
|
+
],
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"data": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"required": [
|
|
33
|
+
"account"
|
|
34
|
+
],
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"account": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"required": [
|
|
40
|
+
"points"
|
|
41
|
+
],
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"properties": {
|
|
44
|
+
"points": {
|
|
45
|
+
"type": "integer",
|
|
46
|
+
"minimum": -9007199254740991,
|
|
47
|
+
"maximum": 9007199254740991,
|
|
48
|
+
"description": "客户当前积分,单位积分;保留 0 和负安全整数,不表示冻结、过期或累计积分。"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"preview": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": [
|
|
59
|
+
"method",
|
|
60
|
+
"path",
|
|
61
|
+
"body",
|
|
62
|
+
"scope",
|
|
63
|
+
"prerequisites"
|
|
64
|
+
],
|
|
65
|
+
"additionalProperties": false,
|
|
66
|
+
"properties": {
|
|
67
|
+
"method": {
|
|
68
|
+
"const": "POST"
|
|
69
|
+
},
|
|
70
|
+
"path": {
|
|
71
|
+
"const": "youzan.crm.customer.points.get/1.0.0"
|
|
72
|
+
},
|
|
73
|
+
"body": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"required": [
|
|
76
|
+
"user"
|
|
77
|
+
],
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"properties": {
|
|
80
|
+
"user": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"required": [
|
|
83
|
+
"account_type",
|
|
84
|
+
"account_id"
|
|
85
|
+
],
|
|
86
|
+
"additionalProperties": false,
|
|
87
|
+
"properties": {
|
|
88
|
+
"account_type": {
|
|
89
|
+
"const": 5
|
|
90
|
+
},
|
|
91
|
+
"account_id": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"minLength": 1,
|
|
94
|
+
"pattern": "^\\S(?:[\\s\\S]*\\S)?$"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"scope": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"required": [
|
|
103
|
+
"kdtId"
|
|
104
|
+
],
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"properties": {
|
|
107
|
+
"kdtId": {
|
|
108
|
+
"$ref": "#/definitions/shopId"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"prerequisites": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"minItems": 1,
|
|
115
|
+
"maxItems": 1,
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "object",
|
|
118
|
+
"required": [
|
|
119
|
+
"method",
|
|
120
|
+
"path",
|
|
121
|
+
"body"
|
|
122
|
+
],
|
|
123
|
+
"additionalProperties": false,
|
|
124
|
+
"properties": {
|
|
125
|
+
"method": {
|
|
126
|
+
"const": "POST"
|
|
127
|
+
},
|
|
128
|
+
"path": {
|
|
129
|
+
"const": "youzan.shop.basic.get/3.0.0"
|
|
130
|
+
},
|
|
131
|
+
"body": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"error": {
|
|
141
|
+
"type": "object",
|
|
142
|
+
"required": [
|
|
143
|
+
"success",
|
|
144
|
+
"code",
|
|
145
|
+
"message",
|
|
146
|
+
"details"
|
|
147
|
+
],
|
|
148
|
+
"additionalProperties": false,
|
|
149
|
+
"properties": {
|
|
150
|
+
"success": {
|
|
151
|
+
"const": false
|
|
152
|
+
},
|
|
153
|
+
"code": {
|
|
154
|
+
"const": -10001
|
|
155
|
+
},
|
|
156
|
+
"message": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"minLength": 1
|
|
159
|
+
},
|
|
160
|
+
"details": {
|
|
161
|
+
"type": "object",
|
|
162
|
+
"required": [
|
|
163
|
+
"category",
|
|
164
|
+
"stage",
|
|
165
|
+
"command",
|
|
166
|
+
"targetScope",
|
|
167
|
+
"requestState",
|
|
168
|
+
"nextStep"
|
|
169
|
+
],
|
|
170
|
+
"additionalProperties": false,
|
|
171
|
+
"properties": {
|
|
172
|
+
"category": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"enum": [
|
|
175
|
+
"validation",
|
|
176
|
+
"configuration",
|
|
177
|
+
"parameter",
|
|
178
|
+
"permission",
|
|
179
|
+
"authentication",
|
|
180
|
+
"scope_unresolved",
|
|
181
|
+
"transport",
|
|
182
|
+
"http",
|
|
183
|
+
"protocol",
|
|
184
|
+
"business_rejected"
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"stage": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"enum": [
|
|
190
|
+
"validation",
|
|
191
|
+
"context",
|
|
192
|
+
"scope",
|
|
193
|
+
"input",
|
|
194
|
+
"configuration",
|
|
195
|
+
"shop-binding",
|
|
196
|
+
"account",
|
|
197
|
+
"account-model",
|
|
198
|
+
"transport",
|
|
199
|
+
"http",
|
|
200
|
+
"response"
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
"command": {
|
|
204
|
+
"const": "points.account.get"
|
|
205
|
+
},
|
|
206
|
+
"targetScope": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"additionalProperties": false,
|
|
209
|
+
"properties": {
|
|
210
|
+
"kdtId": {
|
|
211
|
+
"$ref": "#/definitions/shopId"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"requestState": {
|
|
216
|
+
"enum": [
|
|
217
|
+
"not_sent",
|
|
218
|
+
"sent",
|
|
219
|
+
"unknown"
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
"nextStep": {
|
|
223
|
+
"type": "string",
|
|
224
|
+
"minLength": 1
|
|
225
|
+
},
|
|
226
|
+
"api": {
|
|
227
|
+
"type": "string"
|
|
228
|
+
},
|
|
229
|
+
"httpStatus": {
|
|
230
|
+
"type": "integer"
|
|
231
|
+
},
|
|
232
|
+
"businessCode": {
|
|
233
|
+
"anyOf": [
|
|
234
|
+
{
|
|
235
|
+
"type": "integer",
|
|
236
|
+
"minimum": -9007199254740991,
|
|
237
|
+
"maximum": 9007199254740991
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"type": "string",
|
|
241
|
+
"pattern": "^-?\\d{1,12}$"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
"gatewayCode": {
|
|
246
|
+
"anyOf": [
|
|
247
|
+
{
|
|
248
|
+
"type": "integer",
|
|
249
|
+
"minimum": -9007199254740991,
|
|
250
|
+
"maximum": 9007199254740991
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"type": "string",
|
|
254
|
+
"pattern": "^-?\\d{1,12}$"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
"trace_id": {
|
|
259
|
+
"type": "string",
|
|
260
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
261
|
+
},
|
|
262
|
+
"request_id": {
|
|
263
|
+
"type": "string",
|
|
264
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"definitions": {
|
|
271
|
+
"shopId": {
|
|
272
|
+
"type": "integer",
|
|
273
|
+
"minimum": 1,
|
|
274
|
+
"maximum": 9007199254740991,
|
|
275
|
+
"description": "显式 --kdt-id 优先,否则取本次有效上下文 shopId。默认值是动态来源,不是授权证明;实际执行必须与同次凭证回读的店铺一致。"
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"modules": {
|
|
279
|
+
"account": {
|
|
280
|
+
"base": true,
|
|
281
|
+
"upstreamPath": "data.point",
|
|
282
|
+
"required": true,
|
|
283
|
+
"description": "仅投影客户当前积分 points,缺失或错型失败;未选择的扩展字段忽略。"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"api": {
|
|
287
|
+
"method": "POST",
|
|
288
|
+
"path": "youzan.crm.customer.points.get/1.0.0"
|
|
289
|
+
},
|
|
290
|
+
"success": {
|
|
291
|
+
"description": "店铺核验通过且当前积分明确为安全整数后输出 data.account.points。"
|
|
292
|
+
},
|
|
293
|
+
"errors": {
|
|
294
|
+
"description": "失败 stdout 为空,stderr 为一份脱敏错误 JSON,退出码非零;不返回部分成功,不自动重试、切换身份或目标。按 error 模型及安全下一步处理。"
|
|
295
|
+
},
|
|
296
|
+
"notes": [
|
|
297
|
+
"只返回 data.account.points,单位积分,保留 0 和负安全整数;不表示冻结、过期或累计积分。",
|
|
298
|
+
"缺失、null、字符串、小数或不安全整数失败,不补 0,也不解释为客户不存在。",
|
|
299
|
+
"最多一次店铺核验和一次积分读取;核验失败不继续查询,不读取客户档案、流水或规则。",
|
|
300
|
+
"支持微商城和零售单店、连锁 D 总部、L 总部及 L 总部高级版,不承诺连锁网店或分店。",
|
|
301
|
+
"本地 --dry-run 不读取凭证、不联网;预览只证明构造计划,不证明对象存在或权限有效。真实执行仍需有效上下文及目标范围授权,at 声明不替代服务端授权。"
|
|
302
|
+
]
|
|
303
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 3,
|
|
3
|
+
"domain": "points",
|
|
4
|
+
"businessCommands": [
|
|
5
|
+
{
|
|
6
|
+
"path": "points.account.get",
|
|
7
|
+
"kind": "atomic",
|
|
8
|
+
"risk": "read",
|
|
9
|
+
"availability": "available",
|
|
10
|
+
"at": "all",
|
|
11
|
+
"module": "points/account/get/command.js",
|
|
12
|
+
"fingerprint": "08172715d6faca6425edceca180b47e3259f321ac96f3bba04b59cd186f82865"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "points.log.list",
|
|
16
|
+
"kind": "atomic",
|
|
17
|
+
"risk": "read",
|
|
18
|
+
"availability": "available",
|
|
19
|
+
"at": "all",
|
|
20
|
+
"module": "points/log/list/command.js",
|
|
21
|
+
"fingerprint": "c93bc006243ed608efa288b9fe14e9503b1fe072bab969796c7045cde671aff4"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "points.rule.list",
|
|
25
|
+
"kind": "atomic",
|
|
26
|
+
"risk": "read",
|
|
27
|
+
"availability": "available",
|
|
28
|
+
"at": "all",
|
|
29
|
+
"module": "points/rule/list/command.js",
|
|
30
|
+
"fingerprint": "d6a0a0fa10e2417aefa31a4110e866ffb9f106f1c8e3a3591a160cd9c3bc1cb1"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { readTotal } = require('../../../../../execution/list-total');
|
|
4
|
+
|
|
5
|
+
const { withTargetShopDefault } = require('../../../../../execution/target-shop-default');
|
|
6
|
+
|
|
7
|
+
const { Option } = require('commander');
|
|
8
|
+
const { DiagnosticCommand } = require('../../../../../cli/diagnostic-command');
|
|
9
|
+
const { inputIssue, parseIntegerOption } = require('../../../../../execution/error-details');
|
|
10
|
+
const { resolveTargetShop } = require('../../../../../execution/target-shop');
|
|
11
|
+
const { validateCommandValue } = require('../../../../../execution/command-schema');
|
|
12
|
+
const { createShopQuery, failure, bindingPath } = require('../../../../../execution/shop-query');
|
|
13
|
+
const { object } = require('../../../../../execution/query-api');
|
|
14
|
+
const { parseDateTime, formatDateTime, apiDateTime } = require('../../../../../execution/datetime');
|
|
15
|
+
const { parseDateTimeRange } = require('../../../../../execution/range');
|
|
16
|
+
const schema = require('./schema.json');
|
|
17
|
+
|
|
18
|
+
const command = 'points.log.list';
|
|
19
|
+
const MAX_OUTPUT_BYTES = 5 * 1024 * 1024;
|
|
20
|
+
const SHANGHAI_OFFSET = 8 * 3600 * 1000;
|
|
21
|
+
const types = { all: 0, income: 1, expense: 2, frozen: 3 };
|
|
22
|
+
const reject = (category, stage, scope, state, facts) =>
|
|
23
|
+
failure(command, category, stage, scope, state, facts);
|
|
24
|
+
|
|
25
|
+
function earliestBegin(now) {
|
|
26
|
+
const local = new Date(now + SHANGHAI_OFFSET);
|
|
27
|
+
const year = local.getUTCFullYear() - 1;
|
|
28
|
+
const month = local.getUTCMonth();
|
|
29
|
+
const lastDay = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
30
|
+
return Date.UTC(year, month, Math.min(local.getUTCDate(), lastDay),
|
|
31
|
+
local.getUTCHours(), local.getUTCMinutes(), local.getUTCSeconds(), local.getUTCMilliseconds()) - SHANGHAI_OFFSET;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildInput(options, scope, now) {
|
|
35
|
+
let createdAt;
|
|
36
|
+
try { createdAt = parseDateTimeRange(options.createdAt,
|
|
37
|
+
{ precision: 'seconds', requireBoth: true, strictOrder: true }); }
|
|
38
|
+
catch { throw inputIssue('/createdAt', 'invalid_format', { format: '北京时间 YYYY-MM-DD HH:mm:ss..YYYY-MM-DD HH:mm:ss,必须两端且开始早于结束;不接受非零毫秒' }); }
|
|
39
|
+
const begin = parseDateTime(createdAt.start);
|
|
40
|
+
const end = parseDateTime(createdAt.end);
|
|
41
|
+
const input = { ...scope, yzOpenId: options.yzOpenId.trim(),
|
|
42
|
+
createdAt,
|
|
43
|
+
type: options.type, pageNo: parseIntegerOption(options.pageNo, schema, '/pageNo'), pageSize: parseIntegerOption(options.pageSize, schema, '/pageSize') };
|
|
44
|
+
if (end > now || end - begin >= 31 * 86400000 ||
|
|
45
|
+
begin < earliestBegin(now)) throw inputIssue('/createdAt', 'constraint', { format: '结束不晚于当前时刻;跨度须小于31天;开始不早于当前北京时间日历减12个月' });
|
|
46
|
+
validateCommandValue(schema, 'input', input);
|
|
47
|
+
return input;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function project(data, input, scope, facts) {
|
|
51
|
+
const invalid = () => reject('protocol', 'logs-model', scope, 'sent', facts);
|
|
52
|
+
const paginator = data?.paginator;
|
|
53
|
+
if (!object(data) || !Array.isArray(data.items) || data.items.length > input.pageSize ||
|
|
54
|
+
!object(paginator) || paginator.page !== input.pageNo || paginator.page_size !== input.pageSize) throw invalid();
|
|
55
|
+
const reportedTotal = readTotal(paginator, 'total_count', invalid);
|
|
56
|
+
const total = reportedTotal === null ? null : BigInt(reportedTotal);
|
|
57
|
+
const offset = BigInt(input.pageNo - 1) * BigInt(input.pageSize);
|
|
58
|
+
if (total !== null && (data.items.length ? offset + BigInt(data.items.length) > total : offset < total)) throw invalid();
|
|
59
|
+
const logs = data.items.map(item => {
|
|
60
|
+
if (!object(item)) throw invalid();
|
|
61
|
+
const log = {};
|
|
62
|
+
for (const [source, target, required] of [
|
|
63
|
+
['amount', 'amount', true], ['current', 'current', true], ['created_at', 'createdAt', true],
|
|
64
|
+
['expired_at', 'expiredAt', false], ['description', 'description', false], ['biz_value', 'bizValue', false]
|
|
65
|
+
]) {
|
|
66
|
+
if (!Object.hasOwn(item, source)) {
|
|
67
|
+
if (required) throw invalid();
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const value = item[source];
|
|
71
|
+
if (['description', 'biz_value'].includes(source) ? typeof value !== 'string' : !Number.isSafeInteger(value)) {
|
|
72
|
+
throw invalid();
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
log[target] = ['created_at', 'expired_at'].includes(source) ? formatDateTime(value * 1000) : value;
|
|
76
|
+
} catch { throw invalid(); }
|
|
77
|
+
}
|
|
78
|
+
return log;
|
|
79
|
+
});
|
|
80
|
+
const output = { data: { logs, pagination: { pageNo: input.pageNo, pageSize: input.pageSize,
|
|
81
|
+
...(reportedTotal === null ? {} : { total: reportedTotal }),
|
|
82
|
+
hasMore: total === null ? null : BigInt(input.pageNo) * BigInt(input.pageSize) < total } } };
|
|
83
|
+
try { validateCommandValue(schema, 'output', output); } catch { throw invalid(); }
|
|
84
|
+
if (Buffer.byteLength(JSON.stringify(output), 'utf8') > MAX_OUTPUT_BYTES) {
|
|
85
|
+
throw reject('budget_exceeded', 'output-budget', scope, 'sent', facts);
|
|
86
|
+
}
|
|
87
|
+
return output;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function createCommand({ context, now = () => Date.now() } = {}) {
|
|
91
|
+
return new DiagnosticCommand('list', { path: command, schema, parameterCategory: 'parameter' })
|
|
92
|
+
.description('分页查询一个已知客户在指定北京时间窗口内的积分流水(微商城单店)')
|
|
93
|
+
.allowExcessArguments(false)
|
|
94
|
+
.requiredOption('--yz-open-id <id>', '必填:客户 yzOpenId,不是手机号或微信 openId')
|
|
95
|
+
.option('--kdt-id <id>', '目标店铺正安全整数;默认 context.shopId,非总部不可跨店')
|
|
96
|
+
.requiredOption('--created-at <range>', '必填:流水创建时间 START..END,必须两端,北京时间,秒精度;开始 < 结束 <= 当前时刻')
|
|
97
|
+
.addOption(new Option('--type <type>', '积分变动类型').choices(Object.keys(types)).default('all'))
|
|
98
|
+
.option('--page-no <n>', '页码,1..2147483647', '1')
|
|
99
|
+
.option('--page-size <n>', '每页条数,1..50,默认20', '20')
|
|
100
|
+
.addOption(new Option('--format <format>', 'json 或 pretty,仅改变缩进').choices(['json', 'pretty']).default('json'))
|
|
101
|
+
.option('--dry-run', '本地预览请求及店铺核验,不读凭证、不联网')
|
|
102
|
+
.addHelpText('after', `
|
|
103
|
+
窗口严格小于31天,开始不得早于当前 Asia/Shanghai 日历时间减12个月(月底截断)。
|
|
104
|
+
所有时间固定为北京时间(Asia/Shanghai),输入 YYYY-MM-DD HH:mm:ss,可追加1至3位毫秒。
|
|
105
|
+
输出 createdAt/expiredAt 固定为 YYYY-MM-DD HH:mm:ss.SSS,不重复附带时区后缀。
|
|
106
|
+
区间必须包含 ..,必须两端,省略边界不补值,不承诺端点包含性。
|
|
107
|
+
API仅接受秒精度字符串:非零毫秒在请求前拒绝,全零毫秒可无损规范化,预览展示实际请求。
|
|
108
|
+
返回 data.logs 与四字段 pagination;amount 保留正负号和0,current 是变更后的积分而非当前余额。
|
|
109
|
+
单页最多50条,紧凑 JSON 输出预算5MiB;pretty使用同一预算,超额整体失败,不截断。
|
|
110
|
+
最多一次同凭证店铺核验和一次日志请求,不重试、不自动翻页、不切换身份或API。
|
|
111
|
+
hasMore=true 时保持客户、窗口、type和pageSize,将pageNo加1;达到页码上限必须停止。
|
|
112
|
+
分页不保证快照,短页不代表结束;不排序去重、不生成流水ID、不计算余额。
|
|
113
|
+
首期仅微商城单店,不提供全店、其他产品、事件筛选、全量导出或资产写入。
|
|
114
|
+
at: all 只是组织位置声明,不扩展产品或跨店权限;真实执行需有效上下文与同店凭证。
|
|
115
|
+
失败 stdout 为空,stderr 为安全错误JSON;停止并核对原客户、窗口和授权。
|
|
116
|
+
契约:zan-saas schema points.log.list --format json
|
|
117
|
+
示例:zan-saas points log list --yz-open-id customer-1 --kdt-id 63077 --created-at "2026-11-01 10:30:00..2026-11-01 11:30:00" --dry-run
|
|
118
|
+
`)
|
|
119
|
+
.action(async options => {
|
|
120
|
+
const startedAt = now();
|
|
121
|
+
const scope = resolveTargetShop(options, context, command);
|
|
122
|
+
let input;
|
|
123
|
+
try { input = buildInput(options, scope, startedAt); }
|
|
124
|
+
catch (error) { error.inputScope = scope; throw error; }
|
|
125
|
+
const preview = { method: 'POST', path: schema.api.path,
|
|
126
|
+
body: { user: { account_type: 5, account_id: input.yzOpenId }, page: input.pageNo,
|
|
127
|
+
page_size: input.pageSize, begin_time: apiDateTime(input.createdAt.start), end_time: apiDateTime(input.createdAt.end),
|
|
128
|
+
type: types[input.type] }, scope,
|
|
129
|
+
prerequisites: [{ method: 'POST', path: bindingPath, body: {} }] };
|
|
130
|
+
validateCommandValue(schema, 'preview', preview);
|
|
131
|
+
let output = preview;
|
|
132
|
+
if (!options.dryRun) {
|
|
133
|
+
const read = await createShopQuery(scope, command);
|
|
134
|
+
const { data, facts } = await read(preview.path, preview.body, 'logs');
|
|
135
|
+
output = project(data, input, scope, facts);
|
|
136
|
+
}
|
|
137
|
+
console.log(JSON.stringify(output, null, options.format === 'pretty' ? 2 : 0));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = { kind: 'atomic', risk: 'read', at: 'all', createCommand: withTargetShopDefault(createCommand) };
|