|
|
@@ -0,0 +1,41 @@
|
|
|
+package com.izouma.nineth.service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
|
+import com.huifu.adapay.model.AdapayCommon;
|
|
|
+import com.izouma.nineth.config.AdapayProperties;
|
|
|
+import com.izouma.nineth.exception.BusinessException;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@AllArgsConstructor
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class AdapayService {
|
|
|
+
|
|
|
+ private final AdapayProperties adapayProperties;
|
|
|
+
|
|
|
+ public void createMember(Long id, String tel, String name, String idNo) throws BaseAdaPayException {
|
|
|
+ Map<String, Object> memberParams = new HashMap<>();
|
|
|
+ memberParams.put("adapay_func_code", "members.realname");
|
|
|
+ memberParams.put("member_id", id.toString());
|
|
|
+ memberParams.put("app_id", adapayProperties.getAppId());
|
|
|
+ memberParams.put("tel_no", tel);
|
|
|
+ memberParams.put("user_name", name);
|
|
|
+ memberParams.put("cert_type", "00");
|
|
|
+ memberParams.put("cert_id", idNo);
|
|
|
+ Map<String, Object> member = AdapayCommon.requestAdapay(memberParams);
|
|
|
+ log.info("createMember\n{}", JSON.toJSONString(member, SerializerFeature.PrettyFormat));
|
|
|
+ if (!"succeeded".equals(MapUtils.getString(member, "status"))) {
|
|
|
+ String errMsg = MapUtils.getString(member, "error_msg");
|
|
|
+ String errCode = MapUtils.getString(member, "error_code");
|
|
|
+ throw new BusinessException(errMsg + "(" + errCode + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|