|
@@ -18,9 +18,14 @@ import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.Base64Utils;
|
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
|
+import sun.net.www.content.image.png;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -678,6 +683,196 @@ public class MchServiceImpl extends BaseServiceImpl<Mch, Long> implements MchSer
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 传送身份证图片
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String sendCard(Mch mch,String cardPositive,String cardNegative) {
|
|
|
|
+
|
|
|
|
+ String url = "https://www.joinpay.com/allocFunds";
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isEmpty(mch.getAlt_mch_no())){
|
|
|
|
+ return "找不到商家编号";
|
|
|
|
+ }
|
|
|
|
+ String card_positive = ImageToBase64ByLocal(cardPositive);
|
|
|
|
+ String card_negative = ImageToBase64ByLocal(cardNegative);
|
|
|
|
+
|
|
|
|
+ JSONObject requestData = new JSONObject(new LinkedHashMap());
|
|
|
|
+ requestData.put("alt_mch_no" , mch.getAlt_mch_no());
|
|
|
|
+ requestData.put("card_positive" , card_positive);
|
|
|
|
+ requestData.put("card_negative" , card_negative);
|
|
|
|
+
|
|
|
|
+ JSONObject requestJson = new JSONObject(new TreeMap<String, Object>());
|
|
|
|
+ requestJson.put("method", "altMchPics.uploadPic");
|
|
|
|
+ requestJson.put("version", "1.0");
|
|
|
|
+ requestJson.put("data", requestData);
|
|
|
|
+ // 32位随机字符串
|
|
|
|
+ String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
|
|
|
+ requestJson.put("rand_str", uuid);
|
|
|
|
+ requestJson.put("sign_type", JoinpayConstant.sign_type_MD5);
|
|
|
|
+ requestJson.put("mch_no", JoinpayConstant.mch_no);
|
|
|
|
+
|
|
|
|
+ String sign = createMD5Sign(requestJson , JoinpayConstant.key);
|
|
|
|
+ requestJson.put("sign", sign.toUpperCase());
|
|
|
|
+ logger.info("请求参数:" + requestJson);
|
|
|
|
+ String back=null;
|
|
|
|
+ org.json.JSONObject jsonObject;
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ jsonObject = HttpClientUtils.postJson(url, requestJson.toString());
|
|
|
|
+ logger.info("响应参数:" + jsonObject);
|
|
|
|
+
|
|
|
|
+ // 判断请求是否正确,受理成功
|
|
|
|
+ if(jsonObject.has("resp_code")){
|
|
|
|
+ String resp_code = jsonObject.getString("resp_code");
|
|
|
|
+ mch.setResp_code(resp_code);
|
|
|
|
+ }else{
|
|
|
|
+ return "请求失败";
|
|
|
|
+ }
|
|
|
|
+ // 处理data
|
|
|
|
+ if(jsonObject.has("data")){
|
|
|
|
+ org.json.JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ String biz_code = data.getString("biz_code");
|
|
|
|
+ if(biz_code.equals("B100000")){
|
|
|
|
+ String approve_status = "审核中";
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ mch.setApprove_note("");
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ if(biz_code.equals("B100002")){
|
|
|
|
+ String approve_status = "上传失败";
|
|
|
|
+ String approve_note = data.getString("biz_msg");
|
|
|
|
+ mch.setApprove_note(approve_note);
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ if(biz_code.equals("B101017")){
|
|
|
|
+ String approve_status = "上传失败";
|
|
|
|
+ String approve_note = data.getString("biz_msg");
|
|
|
|
+ mch.setApprove_note(approve_note);
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ update(mch);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return back;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询身份证照片审核状态
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String searchApprove(Mch mch) {
|
|
|
|
+
|
|
|
|
+ String url = "https://www.joinpay.com/allocFunds";
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isEmpty(mch.getAlt_mch_no())){
|
|
|
|
+ return "找不到商家编号";
|
|
|
|
+ }
|
|
|
|
+ JSONObject requestData = new JSONObject(new LinkedHashMap());
|
|
|
|
+ requestData.put("alt_mch_no" , mch.getAlt_mch_no());
|
|
|
|
+
|
|
|
|
+ JSONObject requestJson = new JSONObject(new TreeMap<String, Object>());
|
|
|
|
+ requestJson.put("method", "altMchPics.queryPicsInfo");
|
|
|
|
+ requestJson.put("version", "1.0");
|
|
|
|
+ requestJson.put("data", requestData);
|
|
|
|
+ // 32位随机字符串
|
|
|
|
+ String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
|
|
|
+ requestJson.put("rand_str", uuid);
|
|
|
|
+ requestJson.put("sign_type", JoinpayConstant.sign_type_MD5);
|
|
|
|
+ requestJson.put("mch_no", JoinpayConstant.mch_no);
|
|
|
|
+
|
|
|
|
+ String sign = createMD5Sign(requestJson , JoinpayConstant.key);
|
|
|
|
+ requestJson.put("sign", sign.toUpperCase());
|
|
|
|
+ logger.info("请求参数:" + requestJson);
|
|
|
|
+ String back=null;
|
|
|
|
+ org.json.JSONObject jsonObject;
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ jsonObject = HttpClientUtils.postJson(url, requestJson.toString());
|
|
|
|
+ logger.info("响应参数:" + jsonObject);
|
|
|
|
+
|
|
|
|
+ // 判断请求是否正确,受理成功
|
|
|
|
+ if(jsonObject.has("resp_code")){
|
|
|
|
+ String resp_code = jsonObject.getString("resp_code");
|
|
|
|
+ mch.setResp_code(resp_code);
|
|
|
|
+ }else{
|
|
|
|
+ return "请求失败";
|
|
|
|
+ }
|
|
|
|
+ // 处理data
|
|
|
|
+ if(jsonObject.has("data")){
|
|
|
|
+ org.json.JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ String biz_code = data.getString("biz_code");
|
|
|
|
+ if(biz_code.equals("B100000")){
|
|
|
|
+ String approve_status = "审核通过";
|
|
|
|
+ String approve_note = data.getString("approve_note");
|
|
|
|
+ mch.setApprove_note(approve_note);
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ if(biz_code.equals("B110008")){
|
|
|
|
+ String approve_status = "审核未通过";
|
|
|
|
+ String approve_note = data.getString("biz_msg");
|
|
|
|
+ mch.setApprove_note(approve_note);
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ if(biz_code.equals("B101018")){
|
|
|
|
+ String approve_status = "审核未通过";
|
|
|
|
+ String approve_note = data.getString("biz_msg");
|
|
|
|
+ mch.setApprove_note(approve_note);
|
|
|
|
+ mch.setApprove_status(approve_status);
|
|
|
|
+ back = approve_status;
|
|
|
|
+ }
|
|
|
|
+ update(mch);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return back;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 本地图片转换成base64字符串
|
|
|
|
+ *
|
|
|
|
+ * @param imgFile 图片本地路径
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static String ImageToBase64ByLocal(String imgFile) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ InputStream in = null;
|
|
|
|
+ byte[] data = null;
|
|
|
|
+ // 读取图片字节数组
|
|
|
|
+ try {
|
|
|
|
+ in = new FileInputStream(imgFile);
|
|
|
|
+ data = new byte[in.available()];
|
|
|
|
+ in.read(data);
|
|
|
|
+ in.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ // 对字节数组Base64编码
|
|
|
|
+ BASE64Encoder encoder = new BASE64Encoder();
|
|
|
|
+ String[] strings = imgFile.split("\\.");
|
|
|
|
+ if(strings.length>1){
|
|
|
|
+ String str = strings[strings.length-1];
|
|
|
|
+ String title = "data:image/"+str+";base64,";
|
|
|
|
+ return title+encoder.encode(data);// 返回Base64编码过的字节数组字符串
|
|
|
|
+ }else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
* 签名算法sign , MD5 签名
|
|
* 签名算法sign , MD5 签名
|
|
* @param requestJson
|
|
* @param requestJson
|
|
* @return
|
|
* @return
|