class SmsYunPianClient implements SmsClient {

    @Override
    public SendResult batchSend(List<String> mobileList, String sign,
                                String templateCode, String template,
                                Map<String, String> templateParams) {
        // build 模板
        template = buildTemplate(sign, template, templateParams);

        // 最大发送数为 1000，我们设置为 500 个, 分段发送
        int maxSendSize = MAX_BATCH_SIZE;
        int maxSendSizeCount = mobileList.size() % maxSendSize == 0
                ? mobileList.size() / maxSendSize
                : mobileList.size() / maxSendSize + 1;
        int j = 0;
        int j2 = mobileList.size();

        for (int i = 0; i < maxSendSizeCount; i++) {
            StringBuffer sendMobileStr = new StringBuffer();
            for (int k = j; k < j2; k++) {
                sendMobileStr.append(",");
                sendMobileStr.append(mobileList.get(k));
            }

            String dividedMobile = sendMobileStr.toString().substring(1);

            // 发送手机号
            Map<String, String> params = new LinkedHashMap<>();
            params.put("apikey", apiKey);
            params.put("mobile", dividedMobile);
            params.put("text", template);
            // TODO: 2019/5/19 sin 运营商发送报告 回调
            // params.put("callback_url", template);
            String result = post(URL_SEND_BATCH, params);
            JSONObject jsonObject = JSON.parseObject(result);
            if (jsonObject.containsKey("code")
                    && !(jsonObject.getInteger("code") == SUCCESS_CODE)) {
                throw new ServiceException(AdminErrorCodeEnum.SMS_PLATFORM_FAIL.getCode(),
                        jsonObject.getString("detail"));
            }

            // 用于递增 maxSendSize
            j = j2;
            j2 = j + maxSendSize;
        }

        return new SendResult()
                .setIsSuccess(true)
                .setCode(SUCCESS_CODE)
                .setMessage(SUCCESS_MESSAGE);
    }

}