| | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.nova.sankuai.infra.constants.Constants; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | */ |
| | | @Component |
| | | public class FirstMessage { |
| | | private static final Logger log = LoggerFactory.getLogger("smsLogger"); // 定义日志对象 |
| | | |
| | | private static final String ACCOUNT = "931110"; |
| | | private static final String PASSWORD = "Q9RHrD"; |
| | | private static final String EXTNO = "10690"; |
| | |
| | | paramMap.put("extno", EXTNO); |
| | | paramMap.put("rt", RT); |
| | | String result = HttpUtil.post(URL, paramMap, Constants.TIME_OUT); |
| | | log.info("原短信商日志: 用户手机:{},请求前参数:{},请求返回结果:{}", phone, paramMap, result); |
| | | if (StringUtils.isNotBlank(result)) { |
| | | JSONObject jsonResults = JSONUtil.parseObj(result); |
| | | return Constants.SUCCESS_CODE.equals(jsonResults.getStr(STATUS)); |
| | |
| | | return false; |
| | | } |
| | | |
| | | public static boolean sendSmsApprovalNotify(String phone, String content) { |
| | | HashMap<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("action", "send"); |
| | | paramMap.put("account", "932450"); |
| | | paramMap.put("password", "Un1iqu6PK"); |
| | | paramMap.put("content", content); |
| | | paramMap.put("mobile", phone); |
| | | paramMap.put("extno", "10690347"); |
| | | paramMap.put("rt", RT); |
| | | log.info("进件时获取到手机号短信通知日志: 用户手机={},请求参数={}", phone,paramMap); |
| | | String result = HttpUtil.post(URL, paramMap, Constants.TIME_OUT); |
| | | if (StringUtils.isNotBlank(result)) { |
| | | JSONObject jsonResults = JSONUtil.parseObj(result); |
| | | log.info("进件时获取到手机号短信通知日志: 用户手机={},返回参数={}", phone,result); |
| | | boolean status = Constants.SUCCESS_CODE.equals(jsonResults.getStr(STATUS)); |
| | | if (status){ |
| | | log.info("进件时获取到手机号短信通知日志: 用户手机={},发送返回成功", phone); |
| | | }else { |
| | | log.info("进件时获取到手机号短信通知日志: 用户手机={},发送返回失败", phone); |
| | | } |
| | | return status; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |