ソースを参照

汇聚新增协议签名接口

李天标 5 年 前
コミット
b172640b58

+ 43 - 1
app-backend-web/src/main/java/com/hboxs/control/admin/JoinPayMchController.java

@@ -7,6 +7,7 @@ package com.hboxs.control.admin;
 
 import com.hboxs.common.Constant;
 import com.hboxs.common.JoinpayConstant;
+import com.hboxs.common.JsonMessage;
 import com.hboxs.common.Message;
 import com.hboxs.joinpay.entity.Mch;
 import com.hboxs.service.AdminService;
@@ -15,8 +16,10 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import javax.annotation.Resource;
@@ -46,7 +49,12 @@ public class JoinPayMchController extends BaseController {
         if (!StringUtils.isBlank(mch.getOrder_status())) {
             String result = mchService.refreshMch(mch);
             mchService.refreshMyAccount(mch);
-
+            //获取协议内容
+//            mchService.getQuerySignContent(mch);
+            //签定协议
+//            mchService.altMchSign(mch);
+            //查看协议内容
+            mchService.querySignRecord(mch);
 
             model.addAttribute("orderStatus", JoinpayConstant.order_status);
             model.addAttribute("mch", mch);
@@ -134,5 +142,39 @@ public class JoinPayMchController extends BaseController {
 
 
     }
+    /**
+     * 签约
+     */
+    @RequestMapping(value = "/altMchSign", method = RequestMethod.POST)
+    @ResponseBody
+    public JsonMessage altMchSign() {
+        Long id = adminService.getCurrent().getId();
+        Mch mch = mchService.getUniqueness(id);
+
+        // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
+        if (!StringUtils.isBlank(mch.getOrder_status())) {
+            //签定协议
+            String str =mchService.altMchSign(mch);
+            return JsonMessage.success(str);
+        } else {
+            return null;
+        }
+
+    }
+    @RequestMapping(value = "/altMchSign2", method = RequestMethod.POST)
+    @ResponseBody
+    public JsonMessage altMchSign2(Long id) {
+        adminService.getCurrent().getId();
+        Mch mch = mchService.getUniqueness(id);
+
+        // 如果分销商商户状态 不为空,则要远程请求刷一下当前的用户order_status
+        if (!StringUtils.isBlank(mch.getOrder_status())) {
+            //签定协议
+            String str =mchService.altMchSign(mch);
+            return JsonMessage.success(str);
+        } else {
+            return JsonMessage.success("分销商商户状态为空");
+        }
 
+    }
 }

+ 22 - 1
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminAgency/edit.ftl

@@ -193,7 +193,16 @@ $().ready(function() {
                      [#if mch.alt_merchant_type == '10'] 个人[/#if]
                      [#if mch.alt_merchant_type == '11'] 个体工商户[/#if]
                      [#if mch.alt_merchant_type == '12'] 企业[/#if]
-                </td
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    汇聚支付签约状态:
+                </th>
+                <td id="orderStatus">
+                    ${mch.sign_status}    &nbsp &nbsp <button type="button" id="qianyue" >签约</button>
+                </td>
+                <input type="text" style="display: none" value="${mch.adminId}" name="sn" id="adminId" class="text" required/>
             </tr>
             <tr>
                 <th>
@@ -364,4 +373,16 @@ $().ready(function() {
 		</table>
 	</form>
 </body>
+<script>
+    $('#qianyue').click(function(){
+        var id=	document.getElementById("adminId").value;
+        $.ajax({
+            url:"/asl-admin/joinPayMch/altMchSign2.htm?id="+id,
+            type:"POST",
+            success: function(data){
+                layer.msg(data.data);
+            }
+        })
+    });
+</script>
 </html>

+ 22 - 1
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminMerchant/edit.ftl

@@ -187,7 +187,16 @@ $().ready(function() {
                      [#if mch.alt_merchant_type == '10'] 个人[/#if]
                      [#if mch.alt_merchant_type == '11'] 个体工商户[/#if]
                      [#if mch.alt_merchant_type == '12'] 企业[/#if]
-                </td
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    汇聚支付签约状态:
+                </th>
+                <td id="orderStatus">
+                    ${mch.sign_status}    &nbsp &nbsp <button type="button" id="qianyue" >签约</button>
+                </td>
+                <input type="text" style="display: none" value="${mch.adminId}" name="sn" id="adminId" class="text" required/>
             </tr>
             <tr>
                 <th>
@@ -341,4 +350,16 @@ $().ready(function() {
 		</table>
 	</form>
 </body>
+<script>
+    $('#qianyue').click(function(){
+        var id=	document.getElementById("adminId").value;
+        $.ajax({
+            url:"/asl-admin/joinPayMch/altMchSign2.htm?id="+id,
+            type:"POST",
+            success: function(data){
+                layer.msg(data.data);
+            }
+        })
+    });
+</script>
 </html>

+ 22 - 1
app-backend-web/src/main/webapp/WEB-INF/template/admin/adminPersonage/edit.ftl

@@ -184,7 +184,16 @@ $().ready(function() {
                      [#if mch.alt_merchant_type == '10'] 个人[/#if]
                      [#if mch.alt_merchant_type == '11'] 个体工商户[/#if]
                      [#if mch.alt_merchant_type == '12'] 企业[/#if]
-                </td
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    汇聚支付签约状态:
+                </th>
+                <td id="orderStatus">
+                    ${mch.sign_status}    &nbsp &nbsp <button type="button" id="qianyue" >签约</button>
+                </td>
+                <input type="text" style="display: none" value="${mch.adminId}" name="sn" id="adminId" class="text" required/>
             </tr>
             <tr>
                 <th>
@@ -320,4 +329,16 @@ $().ready(function() {
 		</table>
 	</form>
 </body>
+<script>
+    $('#qianyue').click(function(){
+        var id=	document.getElementById("adminId").value;
+        $.ajax({
+            url:"/asl-admin/joinPayMch/altMchSign2.htm?id="+id,
+            type:"POST",
+            success: function(data){
+                layer.msg(data.data);
+            }
+        })
+    });
+</script>
 </html>

+ 19 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/joinpay/mch/edit.ftl

@@ -117,6 +117,14 @@ $().ready(function() {
                     ${(orderStatus.get(mch.order_status))!"-"}  <a href="javascript:location.reload()" style="font-size: 14px;color:#4666ff">刷新</a>
                 </td>
             </tr>
+            <tr>
+                <th>
+                    汇聚支付签约状态:
+                </th>
+                <td id="orderStatus">
+                    ${mch.sign_status}    &nbsp &nbsp <button type="button" id="qianyue" >签约</button>
+                </td>
+            </tr>
 			<tr>
 				<th>
                     <span class="requiredField">*</span>商户类型:
@@ -254,4 +262,15 @@ $().ready(function() {
 		</table>
 	</form>
 </body>
+<script>
+    $('#qianyue').click(function(){
+        $.ajax({
+            url:"/asl-admin/joinPayMch/altMchSign.htm",
+            type:"POST",
+            success: function(data){
+                layer.msg(data.data);
+            }
+        })
+    });
+</script>
 </html>

+ 23 - 0
app-entity/src/main/java/com/hboxs/joinpay/entity/Mch.java

@@ -237,6 +237,14 @@ public class Mch extends BaseEntity {
      */
     private String biz_code;
 
+    /**
+     * 签约状态
+     */
+    private String sign_status;
+    /**
+     * 签约流水号
+     */
+    private String sign_trx_no;
 
     /**
      *
@@ -252,6 +260,21 @@ public class Mch extends BaseEntity {
      */
     private String alt_mch_no;
 
+    public String getSign_status() {
+        return sign_status;
+    }
+
+    public void setSign_status(String sign_status) {
+        this.sign_status = sign_status;
+    }
+
+    public String getSign_trx_no() {
+        return sign_trx_no;
+    }
+
+    public void setSign_trx_no(String sign_trx_no) {
+        this.sign_trx_no = sign_trx_no;
+    }
 
     public String getLogin_name() {
         return login_name;

+ 17 - 0
app-service/src/main/java/com/hboxs/service/MchService.java

@@ -48,6 +48,23 @@ public interface MchService extends BaseService<Mch, Long> {
     public String refreshMch(Mch mch);
 
     /**
+     *   协议内容获取接口
+     * @return : Constant.correct_code=成功,其他String表示错误信息
+     */
+    public String getQuerySignContent(Mch mch);
+
+    /**
+     *   协议内容签约接口
+     * @return : Constant.correct_code=成功,其他String表示错误信息
+     */
+    public String altMchSign(Mch mch);
+
+    /**
+     *   协议签约查询接口
+     * @return : Constant.correct_code=成功,其他String表示错误信息
+     */
+    public String querySignRecord(Mch mch);
+    /**
      * 分账方账户查询接口
      * @return : Constant.correct_code=成功,其他String表示错误信息
      */

+ 222 - 0
app-service/src/main/java/com/hboxs/service/impl/MchServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -453,7 +454,228 @@ public class MchServiceImpl extends BaseServiceImpl<Mch, Long> implements MchSer
 
         return Constant.correct_code;
     }
+    //  协议内容获取接口
+    @Override
+    public String getQuerySignContent(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", "altMchSign.querySignContent");
+        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);
+
+        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);
+                if(JoinpayConstant.resp_code2.equals(resp_code)){
+                    org.json.JSONObject data = jsonObject.getJSONObject("data");
+                    if(data.has("biz_msg")){
+                        return data.getString("biz_msg");
+                    }else{
+                        return JoinpayConstant.resp_code.get(resp_code);
+                    }
+                }
+            }else{
+                return "请求失败";
+            }
+
+
+            // 处理data
+            if(jsonObject.has("data")){
+                org.json.JSONObject data = jsonObject.getJSONObject("data");
+                //update(mch);
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return Constant.correct_code;
+    }
+
+    //  协议内容签约接口
+    @Override
+    public String altMchSign(Mch mch) {
+
+        String url = "https://www.joinpay.com/allocFunds";
+
+        if(StringUtils.isEmpty(mch.getAlt_mch_no())){
+            return "找不到商家编号";
+        }
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+
+        JSONObject requestData = new JSONObject(new LinkedHashMap());
+        requestData.put("alt_mch_no" , mch.getAlt_mch_no());
+        requestData.put("sign_status" , "P1000");
+        requestData.put("sign_time" , dateString);
+
+        JSONObject requestJson = new JSONObject(new TreeMap<String, Object>());
+        requestJson.put("method", "altMchSign.sign");
+        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);
+                if(JoinpayConstant.resp_code2.equals(resp_code)){
+                    org.json.JSONObject data = jsonObject.getJSONObject("data");
+                    if(data.has("biz_msg")){
+                        return data.getString("biz_msg");
+                    }else{
+                        return JoinpayConstant.resp_code.get(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 sign_trx_no = data.getString("sign_trx_no");
+                    String sign_status = data.getString("sign_status");
+                    if(sign_status.equals("P1000")){
+                        sign_status="签约成功";
+                    }else {
+                        sign_status="签约失败";
+                    }
+                    mch.setSign_status(sign_status);
+                    mch.setSign_trx_no(sign_trx_no);
+                    back = sign_status;
+
+                }
+                update(mch);
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return back;
+    }
+
+    //  协议签约查询接口
+    @Override
+    public String querySignRecord(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", "altMchSign.querySignRecord");
+        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);
+
+        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);
+                if(JoinpayConstant.resp_code2.equals(resp_code)){
+                    org.json.JSONObject data = jsonObject.getJSONObject("data");
+                    if(data.has("biz_msg")){
+                        return data.getString("biz_msg");
+                    }else{
+                        return JoinpayConstant.resp_code.get(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 sign_trx_no = data.getString("sign_trx_no");
+                    String sign_status = data.getString("sign_status");
+                    if(sign_status.equals("P1000")){
+                        sign_status="签约成功";
+                    }else {
+                        sign_status="签约失败";
+                    }
+                    mch.setSign_status(sign_status);
+                    mch.setSign_trx_no(sign_trx_no);
+                    update(mch);
+                }
+
+
+
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return Constant.correct_code;
+    }
 
     /**
      * 签名算法sign , MD5 签名