k94314517
2024-10-30 47a53d22a025c0ed095c9c4ed2e1ce35ce54184e
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/third/EmayService.java
@@ -6,15 +6,23 @@
import cn.emay.sdk.core.dto.sms.response.SmsResponse;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.service.HKService;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.model.InterfaceLog;
import com.doumee.service.business.InterfaceLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
public class EmayService {
@@ -89,4 +97,28 @@
   }
   public  void sendSmsByHk(String phone,String content){
      try {
         String url = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_HTTPS).getCode() +
               systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_HOST).getCode() +
               HKConstants.ARTEMIS_PATH +
               HKConstants.InterfacePath.sendSms[0];
         Map<String,Object> map = new HashMap<>();
         map.put("phoneNo",phone.split(","));
         map.put("content",content);
         BaseResponse result = HKService.sendSmsByHk(map,url);
         if(result !=null){
            if(!StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){
               throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),result.getMsg());
            }
         }else{
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,短信发送失败,请稍后重试!");
         }
      }catch (Exception e){
         e.printStackTrace();
      }
      throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,短信发送失败,请稍后重试!");
   }
}