有赞新零售社区

发帖
API使用问题»测试环境调用出现依赖问题

[API调用-其它] 测试环境调用出现依赖问题

91d62a5462ff 02-08 540 浏览 8 评论 | 只看楼主 [打印]
问题:使用有赞JAVA SDK 调用增加积分功能,报方法无法找到错误。

本地调用正常 (IDEA启动) ,测试环境异常 (容器 + Jar包方式启动)

调用接口:
https://doc.youzanyun.com/detail/API/0/872



用手机打开
收藏 ··· 回复
    Caused by: java.lang.NoSuchMethodException: com.youzan.cloud.open.sdk.gen.v4_0_0.model.YouzanCrmCustomerPointsIncreaseParams.get$jacocoData()
            at java.lang.Class.getMethod(Class.java:1786)
            at com.youzan.cloud.open.sdk.api.AbstractApiParams.toParams(AbstractApiParams.java:35)
            ... 94 common frames omitted

      尊敬的有赞用户 您好,我们已收到您的问题,并已安排相关技术支持正在处理中,请耐心等待。建议您留言邮箱地址,问题进度将通过邮件提醒方式触达,减少论坛等待时间。








          POM 依赖
          <dependency>
                      <groupId>com.youzan.cloud</groupId>
                      <artifactId>open-sdk-core</artifactId>
                      <version>1.0.28-RELEASE</version>
                  </dependency>
                  <dependency>
                      <groupId>com.youzan.cloud</groupId>
                      <artifactId>open-sdk-gen</artifactId>
                      <version>1.0.28.10005392202501241430-RELEASE</version>
                  </dependency>

            这个看起来是环境的问题 入参 和报错trace 提供下如果没有trace 看下本地Maven 环境配好了吗 具体的代码是什么样的
            • 感觉和MAVEN没啥关系,本地和测试环境都是一套的。然后编译和打包都正常通过。

              但我看,调用的这个 YouzanCrmCustomerPointsIncreaseParams 有2个版本

              com.youzan.cloud.open.sdk.gen.v3_1_0.model.YouzanCrmCustomerPointsIncreaseParams
              com.youzan.cloud.open.sdk.gen.v4_0_0.model.YouzanCrmCustomerPointsIncreaseParams



            调用代码:

            Token token = new Token(accessToken);
                        YouzanCrmCustomerPointsIncrease youzanCrmCustomerPointsIncrease = new YouzanCrmCustomerPointsIncrease();
                        YouzanCrmCustomerPointsIncreaseParams youzanCrmCustomerPointsIncreaseParams = new YouzanCrmCustomerPointsIncreaseParams();
                        YouzanCrmCustomerPointsIncreaseParams.YouzanCrmCustomerPointsIncreaseParamsParams youzanCrmCustomerPointsIncreaseParamsParams = new YouzanCrmCustomerPointsIncreaseParams.YouzanCrmCustomerPointsIncreaseParamsParams();
                        youzanCrmCustomerPointsIncreaseParams.setParams(youzanCrmCustomerPointsIncreaseParamsParams);
                        String orderNo = pointsDeliveryDTO.getOrderNo();
                        String pointsMonth = InsureStringUtil.getValueStr(pointsDeliveryDTO.getPointsMonth());
                        String reason = orderNo.concat(":").concat(pointsMonth).concat(":").concat(pointsDeliveryDTO.getMobile());
                        youzanCrmCustomerPointsIncreaseParamsParams.setReason("出单派发:" + reason);
                        youzanCrmCustomerPointsIncreaseParamsParams.setBizValue(reason);
                        //youzanCrmCustomerPointsIncreaseParamsParams.setBizToken();
                        youzanCrmCustomerPointsIncreaseParamsParams.setSourceKdtId(shopId);
                        youzanCrmCustomerPointsIncreaseParamsParams.setCheckCustomer(Boolean.FALSE);
                        youzanCrmCustomerPointsIncreaseParamsParams.setPoints(pointsDeliveryDTO.getDeliveryPoints());
                        youzanCrmCustomerPointsIncreaseParamsParams.setIsDoExtPoint(Boolean.FALSE);
                        YouzanCrmCustomerPointsIncreaseParams.YouzanCrmCustomerPointsIncreaseParamsUser youzanCrmCustomerPointsIncreaseParamsUser
                                = new YouzanCrmCustomerPointsIncreaseParams.YouzanCrmCustomerPointsIncreaseParamsUser();
                        youzanCrmCustomerPointsIncreaseParamsParams.setUser(youzanCrmCustomerPointsIncreaseParamsUser);
                        youzanCrmCustomerPointsIncreaseParamsUser.setAccountType(2);
                        youzanCrmCustomerPointsIncreaseParamsUser.setAccountId(pointsDeliveryDTO.getMobile());

                        youzanCrmCustomerPointsIncrease.setAPIParams(youzanCrmCustomerPointsIncreaseParams);
                        log.info("[有赞API] 新增积分 入参={}", JSONObject.toJSONString(youzanCrmCustomerPointsIncreaseParams));
                        YouzanCrmCustomerPointsIncreaseResult result = youZanClient.invoke(youzanCrmCustomerPointsIncrease, token, YouzanCrmCustomerPointsIncreaseResult.class);
                        log.info("[有赞API] 新增积分 响应={}", JSONObject.toJSONString(result));


              从日志和代码中看到以下关键信息:

              异常日志:

              错误信息:com.youzan.cloud.open.sdk.common.exception.SDKException: code:108,message:handler factory exception
              这是一个 SDK 异常,code:108 指向了一个通用的处理器工厂异常。
              可能原因:

              在代码中,未为 bizToken 设置值 (//youzanCrmCustomerPointsIncreaseParamsParams.setBizToken();)。
              youzanCrmCustomerPointsIncreaseParamsParams 中一些参数可能未完全符合 API 文档的要求。
              pointsDeliveryDTO 中的一些值(例如 getOrderNo, getPointsMonth, getMobile, getDeliveryPoints 等)可能为空或不符合预期格式。
              setUser 方法中的 accountId 和 accountType 可能未正确匹配有赞的接口要求。
              建议的检查步骤:

              根据有赞云的 API 文档,仔细检查所有请求参数是否符合要求:
              sourceKdtId 是否为正确的店铺 ID。
              reason 和 bizValue 是否长度超出限制。
              accountType 和 accountId 是否正确匹配目标用户。
              检查是否需要设置 bizToken 参数。
              确保 pointsDeliveryDTO 中所有字段都已正确初始化且非空。
              定位原因:

              打印所有参数值,特别是 youzanCrmCustomerPointsIncreaseParamsParams 的完整内容。
              验证接口响应的完整异常栈,可能提示具体字段错误。
              尝试调用其他 API,判断是否为客户端或环境问题(例如:权限或网络异常)。
              建议改进代码:


              // 添加对关键字段的检查和日志
              if (pointsDeliveryDTO == null || pointsDeliveryDTO.getMobile() == null || pointsDeliveryDTO.getDeliveryPoints() == null) {
                  throw new IllegalArgumentException("PointsDeliveryDTO 或其字段不能为空");
              }

              if (shopId == null || shopId.isEmpty()) {
                  throw new IllegalArgumentException("Shop ID 不能为空");
              }

              youzanCrmCustomerPointsIncreaseParamsParams.setBizToken("需要设置正确的 BizToken 值");
              如果需要,我可以帮助你进一步分析具体原因,或协助测试和优化代码。

                1跳至
                您需要登录后才可以回帖 登录 | 立即注册

                本版积分规则

                复制链接
                新浪微博
                QQ空间
                微信扫码
                • 回复

                • 评分

                客服工作时间是9:00-18:00,客服妹子当前不在线,若不能及时回复请谅解。试试右上角的搜索吧,论坛有丰富的经验贴、公告贴,相信一定能够帮到您~

                复制成功