收藏
回答

小程序订阅消息报错47003?

小程序订阅消息报错47003,argument invalid! data.character_string1.value i rid: 66e3da65-174ac864-3bc02079

data -> {

"character_string1":{

     "value":"PD20240905000008"

   },

"amount2":{

"value":¥0.01

},

"thing3":{

"value":"预付定金"

},

"time9":{

"value":"2024年09月05日 14:00"

},

"thing4":{

"value":"预付定金"

}

}

同事试过了不走接口正常可以发送,应该不是传参问题

/**
 * 支付订阅消息推送
 * @param
 * @return
 * @throws Exception
 */
@ApiOperation("支付订阅消息推送")
@GetMapping("/pushWxPayMsg")
public Map<String, Object> pushWxPayMsg() {
    TuanBusinessPaymentDetailsEntity paymentDetailsEntity = tuanBusinessPaymentDetailsService.queryObject("PD20240905000008");
    if (paymentDetailsEntity==null) {
        throw new RRException("该支付单不存在,请检查支付单号是否正确!");
    }
    Gson gson = new Gson();
    //创建订阅信息的模板内容

    JSONObject data = new JSONObject();
    data.put("character_string1", new JSONObject() {{
        put("value", "PD20240905000008");
    }});
    data.put("amount2", new JSONObject() {{
        put("value", "¥" + paymentDetailsEntity.getPayAmount().toString());
    }});
    data.put("thing3", new JSONObject() {{
        put("value", paymentDetailsEntity.getPaymentDescription());
    }});
    data.put("time9", new JSONObject() {{
        put("value", DateUtils.parseDateTime(paymentDetailsEntity.getPayTime(), DateUtils.yyyyMMddHHmmFormat));
    }});
    data.put("thing4", new JSONObject() {{
        put("value", paymentDetailsEntity.getPaymentDescription());
    }});

    String requestURL = WxPayConfigV2.PAY_PUSH_URL + "?access_token=" + WxComUtil.getAccessToken().access_token;

    // 创建请求体
    Map<String, String> requestBody = new HashMap<>();
    requestBody.put("template_id", WxPayConfigV2.PAY_REMIND_SUBSCRIBE_TEMP_ID);
    requestBody.put("touser", "ot4cU7YgjtPGAghcrtNKpsqLRUbo");
    requestBody.put("data", data.toJSONString());
    requestBody.put("miniprogram_state", "trial");
    requestBody.put("lang", "zh_CN");

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(requestBody, headers);

    try {
        ResponseEntity<String> responseEntity = restTemplate.exchange(
                requestURL,
                HttpMethod.POST,
                requestEntity,
                String.class
        );
        Type mapType = new TypeToken<Map<String, Object>>(){}.getType();
        Map<String, Object> res = gson.fromJson(responseEntity.getBody(), mapType);
        return res;
    } catch (Exception e) {
        Map<String, Object> res = new HashMap<>();
        res.put("errCode",-1);
        res.put("errMsg","服务异常,请联系管理员...");
        return res;
    }
}


最后一次编辑于  09-13
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容