Browse Source

提交清款项目

qiubo 4 years ago
parent
commit
76d6d31fb9

+ 3 - 10
bankclear/src/main/java/com/hywa/banktest/common/OrderInfoClearingForm.java

@@ -1,5 +1,7 @@
 package com.hywa.banktest.common;
 
+import com.hywa.banktest.entity.BaseVO;
+
 import java.io.Serializable;
 
 /**
@@ -11,11 +13,10 @@ import java.io.Serializable;
  * @ProjectName gzcarbon2.0
  **/
 
-public class OrderInfoClearingForm implements Serializable {
+public class OrderInfoClearingForm extends BaseVO {
 
     private String orderId;
     private String recordId;
-    private String signStr;
 
     public String getOrderId() {
         return orderId;
@@ -32,12 +33,4 @@ public class OrderInfoClearingForm implements Serializable {
     public void setRecordId(String recordId) {
         this.recordId = recordId;
     }
-
-    public String getSignStr() {
-        return signStr;
-    }
-
-    public void setSignStr(String signStr) {
-        this.signStr = signStr;
-    }
 }

+ 2 - 1
bankclear/src/main/java/com/hywa/banktest/common/ResponseEnum.java

@@ -13,7 +13,8 @@ public enum ResponseEnum {
     FAIL(500,"系统错误"),
     REQNUMNULL(501,"请求值为空"),
     CHECKFAIL(502,"签名验证不通过"),
-    NODATA(503,"没有对应的清分数据")
+    NODATA(503,"没有对应的清分数据"),
+    ERROREQUEST(504,"非法请求")
     ;
 
     private Integer code;

+ 84 - 4
bankclear/src/main/java/com/hywa/banktest/controller/ApplyClearingController.java

@@ -2,10 +2,14 @@ package com.hywa.banktest.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.hywa.banktest.bankframework.pack.TransVo;
+import com.hywa.banktest.bankframework.service.BankService;
 import com.hywa.banktest.bankframework.utils.StringUtils;
 import com.hywa.banktest.bankframework.utils.httpclient.EasyHttpUtils;
 import com.hywa.banktest.common.*;
+import com.hywa.banktest.entity.CheckBankVO;
+import com.hywa.banktest.entity.GetBankNo;
 import com.hywa.banktest.entity.TransRequest;
+import com.hywa.banktest.service.CarbonBankService;
 import com.hywa.banktest.service.OrderInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +32,8 @@ public class ApplyClearingController  {
     @Autowired
     private OrderInfoService orderInfoService;
 
+    @Autowired
+    private CarbonBankService carbonBankService;
     @Value("spring.datasource.url")
     private String url;
     @PostMapping(value = "/apply")
@@ -50,12 +56,21 @@ public class ApplyClearingController  {
         }
         return new AjaxJson(AjaxJson.FAILURE,"验证字符串参数未传,请检查接口参数");
     }
+
+
     @PostMapping("/orApply")
     public AjaxJson applyByOrderId(@RequestBody OrderInfoClearingForm orderInfoClearingForm){
         log.info("orderInfoForm订单请求划款>>>>>{}", JSONObject.toJSONString(orderInfoClearingForm));
+        if (orderInfoClearingForm.getTimeStamp() == null){
+            return new AjaxJson(ResponseEnum.REQNUMNULL);
+        }
+        long time = orderInfoClearingForm.getTimeStamp();
+        long timeStamp = getTimeStamp(time);
+        if (timeStamp>60000||timeStamp<0){
+            return new AjaxJson(ResponseEnum.ERROREQUEST);
+        }
 
-
-         // 先进行值判断是否为空
+        // 先进行值判断是否为空
         if (StringUtils.isEmpty(orderInfoClearingForm.getOrderId())){
 
             return new AjaxJson(ResponseEnum.REQNUMNULL);
@@ -68,7 +83,7 @@ public class ApplyClearingController  {
         boolean flag = false;
         //验证字符串签名
         try {
-            flag = validateSignUtils.signVerify(orderInfoClearingForm.getRecordId()+"|"+orderInfoClearingForm.getOrderId(), orderInfoClearingForm.getSignStr());
+            flag = validateSignUtils.signVerify(time+"|"+orderInfoClearingForm.getRecordId()+"|"+orderInfoClearingForm.getOrderId(), orderInfoClearingForm.getSignStr());
         } catch (Exception e) {
             return new AjaxJson(ResponseEnum.FAIL);
         }
@@ -80,8 +95,73 @@ public class ApplyClearingController  {
 
     }
 
+    @PostMapping("/check")
+    public AjaxJson checkBankNo(@RequestBody CheckBankVO checkBankVO){
+        log.info("------请求银行卡验证---{}",JSONObject.toJSONString(checkBankVO));
+        if (checkBankVO.getTimeStamp()==null||StringUtils.isEmpty(checkBankVO.getSignStr())){
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        long timeStamp = checkBankVO.getTimeStamp();
+        long sc = getTimeStamp(timeStamp);
+        if (sc>60000||sc<0){
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        String strSign = checkBankVO.getSignStr();
+        String farmerPid = checkBankVO.getFarmerPid();
+        String farmerAccount = checkBankVO.getFarmerAccount();
+        if (StringUtils.isEmpty(farmerAccount)||StringUtils.isEmpty(farmerPid)){
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        boolean flag = false;
+        try {
+            flag = validateSignUtils.signVerify(timeStamp + "|" + farmerPid + "|" + farmerAccount, strSign);
+        } catch (Exception e) {
+            log.info("------系统异常---{}",JSONObject.toJSONString(checkBankVO));
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        if (flag){
+
+           return carbonBankService.checkBankCard(checkBankVO);
+        }
+        return  new AjaxJson(ResponseEnum.CHECKFAIL);
+
+
+    }
+
+    @PostMapping("/bankNum")
+    public AjaxJson getBankNum(@RequestBody GetBankNo getBankNo){
+        log.info("------请求银行卡余额数量---{}",JSONObject.toJSONString(getBankNo));
+        if (getBankNo==null||StringUtils.isEmpty(getBankNo.getSignStr())){
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        long timeStamp = getBankNo.getTimeStamp();
+        long sc = getTimeStamp(timeStamp);
+        if (sc>60000||sc<0){
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        String strSign = getBankNo.getSignStr();
+        boolean flag = false;
+        try {
+            flag = validateSignUtils.signVerify(timeStamp + "|gzth$12345", strSign);
+        } catch (Exception e) {
+            log.info("------系统异常---{}",JSONObject.toJSONString(getBankNo));
+            return new AjaxJson(AjaxJson.FAILURE,AjaxJson.MSGFAILURE);
+        }
+        if (flag){
+            return carbonBankService.findCardNumMoney(getBankNo);
+
+        }
+        return  new AjaxJson(ResponseEnum.CHECKFAIL);
+
+
+    }
+    public long getTimeStamp(long timeStamp){
+        long endTime = System.currentTimeMillis();
+        long sc = endTime - timeStamp;
+        return sc;
+    }
+
     public AjaxJson getApp(@RequestBody TransRequest transRequest) {
-        log.info("我 ==============进入请求打款界面:{} ",JSONObject.toJSONString(transRequest));
 
         // 先进行值判断是否为空
         if (StringUtils.isEmpty(transRequest.getRecord())){

+ 33 - 0
bankclear/src/main/java/com/hywa/banktest/entity/BaseVO.java

@@ -0,0 +1,33 @@
+package com.hywa.banktest.entity;
+
+import java.io.Serializable;
+
+public class BaseVO implements Serializable {
+    private String signStr;
+    private Long timeStamp;
+    private String companyType;
+
+    public String getCompanyType() {
+        return companyType;
+    }
+
+    public void setCompanyType(String companyType) {
+        this.companyType = companyType;
+    }
+
+    public String getSignStr() {
+        return signStr;
+    }
+
+    public void setSignStr(String signStr) {
+        this.signStr = signStr;
+    }
+
+    public Long getTimeStamp() {
+        return timeStamp;
+    }
+
+    public void setTimeStamp(Long timeStamp) {
+        this.timeStamp = timeStamp;
+    }
+}

+ 50 - 0
bankclear/src/main/java/com/hywa/banktest/entity/CheckBankVO.java

@@ -0,0 +1,50 @@
+package com.hywa.banktest.entity;
+
+public class CheckBankVO extends BaseVO{
+    private String farmerId;
+    private String farmerAccount;
+    private String farmerName;
+    private String farmerAccType;
+    private String farmerPid;
+
+
+    public String getFarmerId() {
+        return farmerId;
+    }
+
+    public void setFarmerId(String farmerId) {
+        this.farmerId = farmerId;
+    }
+
+    public String getFarmerAccount() {
+        return farmerAccount;
+    }
+
+    public void setFarmerAccount(String farmerAccount) {
+        this.farmerAccount = farmerAccount;
+    }
+
+    public String getFarmerName() {
+        return farmerName;
+    }
+
+    public void setFarmerName(String farmerName) {
+        this.farmerName = farmerName;
+    }
+
+    public String getFarmerAccType() {
+        return farmerAccType;
+    }
+
+    public void setFarmerAccType(String farmerAccType) {
+        this.farmerAccType = farmerAccType;
+    }
+
+    public String getFarmerPid() {
+        return farmerPid;
+    }
+
+    public void setFarmerPid(String farmerPid) {
+        this.farmerPid = farmerPid;
+    }
+}

+ 5 - 0
bankclear/src/main/java/com/hywa/banktest/entity/GetBankNo.java

@@ -0,0 +1,5 @@
+package com.hywa.banktest.entity;
+
+public class GetBankNo extends BaseVO{
+    private String password;
+}

+ 12 - 0
bankclear/src/main/java/com/hywa/banktest/service/CarbonBankService.java

@@ -0,0 +1,12 @@
+package com.hywa.banktest.service;
+
+import com.hywa.banktest.common.AjaxJson;
+import com.hywa.banktest.entity.CheckBankVO;
+import com.hywa.banktest.entity.GetBankNo;
+
+public interface CarbonBankService {
+
+    public AjaxJson checkBankCard(CheckBankVO checkBankVO);
+
+    public AjaxJson findCardNumMoney(GetBankNo getBankNo);
+}

+ 154 - 0
bankclear/src/main/java/com/hywa/banktest/service/impl/CarbonBankServiceImpl.java

@@ -0,0 +1,154 @@
+package com.hywa.banktest.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hywa.banktest.bankframework.pack.Dlmaps;
+import com.hywa.banktest.bankframework.pack.IN;
+import com.hywa.banktest.bankframework.pack.PUB;
+import com.hywa.banktest.bankframework.service.BankServiceImpl;
+import com.hywa.banktest.bankframework.socketHandle.BankSocket;
+import com.hywa.banktest.bankframework.utils.DateUtils;
+import com.hywa.banktest.bankframework.utils.StringUtils;
+import com.hywa.banktest.common.AjaxJson;
+import com.hywa.banktest.entity.CheckBankVO;
+import com.hywa.banktest.entity.GetBankNo;
+import com.hywa.banktest.service.CarbonBankService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+@Slf4j
+@Service
+public class CarbonBankServiceImpl implements CarbonBankService {
+
+    @Autowired
+    private BankSocket bankRequestKit;
+    @Autowired
+    private BankServiceImpl bankService;
+
+
+    private static final String TRANS_SUCCESS_CODE="0000";
+
+    /**
+     * APP类型
+     */
+    @Value("${dlmaps.pub.app_type}")
+    private String app_type;
+    /**
+     * 银行代码
+     */
+    @Value("${dlmaps.pub.bank_id}")
+    private String bank_id;
+    /**
+     * 公司代码
+     */
+    @Value("${dlmaps.pub.dpt_id}")
+    private String dpt_id;
+    /**
+     * 单位代码(固定如4000)
+     */
+    @Value("${dlmaps.in.company_id}")
+    private String company_id;
+    /**
+     * 对公账户(发改委账号)
+     */
+    @Value("${dlmaps.in.company_acc}")
+    private String company_acc;
+    /**
+     * 账号类型
+     */
+    @Value("${dlmaps.in.company_acc_type}")
+    private String company_acc_type;
+
+    @Value("${dlmaps.pub.jj.dpt_id}")
+    private String jj_dept_id;
+
+    @Value("${dlmaps.in.jj.company_acc}")
+    private String jj_company_acc;
+
+    @Override
+    public AjaxJson checkBankCard(CheckBankVO checkBankVO) {
+        String companyType = checkBankVO.getCompanyType();
+        boolean a = true;
+        if ("1".equals(companyType)){
+            a=false;
+        }
+        Dlmaps dlmaps = new Dlmaps();
+
+        PUB pub = new PUB();
+        pub.setAPP_TYPE(app_type);
+        pub.setBANK_ID(bank_id);
+        pub.setTRADE_ID("8911");
+        pub.setTRAN_TIME(DateUtils.formatDate(new Date(), "yyyyMMddHHmmss"));
+        if (a){
+            pub.setDPT_ID(jj_dept_id);
+        }else {
+            pub.setDPT_ID(dpt_id);
+        }
+
+        pub.setTRADE_SEQ(StringUtils.generateOrderNum());
+        dlmaps.setPUB(pub);
+        IN in = new IN();
+        //客户id
+        in.setCUST_ID(checkBankVO.getFarmerId());
+        //证件号码
+        in.setCARD_ID(checkBankVO.getFarmerPid());
+        //证件类型
+        in.setCARD_TYE("01");
+        //客户姓名
+        in.setCUST_NAME(checkBankVO.getFarmerName());
+        //银行账号
+        in.setCUST_ACC(checkBankVO.getFarmerAccount());
+        in.setCUST_ACC_TYE("");
+        dlmaps.setIN(in);
+        log.info("--------- bankVillate check before ------{}",JSONObject.toJSONString(dlmaps));
+        Dlmaps query = bankRequestKit.query(dlmaps);
+        log.info("--------- bankVillate check ------{}",JSONObject.toJSONString(query));
+        return new AjaxJson(AjaxJson.SUCCESS,AjaxJson.MSGSUCCESS,query.getOUT());
+    }
+
+    /**
+     * 查询对公账户剩余余额
+     * @param getBankNo
+     * @return
+     */
+    @Override
+    public AjaxJson findCardNumMoney(GetBankNo getBankNo) {
+        boolean a = true;
+        if ("1".equals(getBankNo.getCompanyType())){
+            a=false;
+        }
+        Dlmaps dlmaps = new Dlmaps();
+        //创建公共域
+        PUB pub = new PUB();
+        pub.setAPP_TYPE(app_type);//APP类型
+        pub.setBANK_ID(bank_id);//银行代码
+        pub.setTRADE_ID("8910");//"交易代码"
+        pub.setTRAN_TIME(DateUtils.formatDate(new Date(), "yyyyMMddHHmmss"));//时间戳
+        if (a){
+            pub.setDPT_ID(jj_dept_id);//基金会公司代码
+        }else {
+            pub.setDPT_ID(dpt_id);//发改委公司代码
+        }
+
+        pub.setTRADE_SEQ(StringUtils.generateOrderNum());
+        dlmaps.setPUB(pub);
+
+        IN in = new IN();
+        in.setCOMPANY_ID(company_id);//单位代码(固定如4000)
+        if (a){
+            in.setCOMPANY_ACC(jj_company_acc);//对公账户(发改委账号)
+        }else {
+            in.setCOMPANY_ACC(company_acc);//对公账户(发改委账号)
+        }
+
+        in.setCOMPANY_ACC_TYPE(company_acc_type);//"账号类型"
+        dlmaps.setIN(in);
+        Dlmaps query = bankRequestKit.query(dlmaps);
+        log.info("------request bankbalance ----------{}", JSONObject.toJSONString(query));
+        return new AjaxJson(AjaxJson.SUCCESS,AjaxJson.MSGSUCCESS,query.getOUT());
+    }
+
+
+}

+ 0 - 2
bankclear/src/main/java/com/hywa/banktest/service/impl/OrderInfoServiceImpl.java

@@ -120,10 +120,8 @@ public class OrderInfoServiceImpl extends BaseServiceImpl<OrderInfo> implements
 					//TODO 转换为资金清算服务的列表信息
 					log.info("开始转换为资金清算服务的列表信息");
 					List<TransVo> transVos = JSON.parseArray(JsonKit.toJson(list), TransVo.class);
-					log.info("transVos====================>{}",transVos);
 					Dlmaps moneyClearResult = this.post(transVos, recordId);
 
-					log.info("moneyClearResult====================>{}",moneyClearResult);
 					if (!"0000".equals(moneyClearResult.getOUT().getRET_CODE())) {
 						this.updateAllClearingDetailOrderInfo(transVos);
 						count=0;

+ 4 - 4
bankclear/src/main/java/com/hywa/banktest/web/PostBankController.java

@@ -29,10 +29,10 @@ public class PostBankController {
 		return bankService.queryBalance();
 	}
 
-	public String orderInfoToBank(){
-
-		return null;
-	}
+//	public String orderInfoToBank(){
+//
+//		return null;
+//	}
 	
 	/**
 	 * 1.1	个人账户开户校验(8911),请求银行接口

+ 5 - 1
bankclear/src/main/resources/application-dev.properties

@@ -25,7 +25,7 @@ local.post.socket.port=8083
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 # 121.36.158.171
-spring.datasource.url=jdbc:mysql://121.36.158.171:39001/carbon-platform-cp?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
+spring.datasource.url=jdbc:mysql://172.16.90.253:3306/carbon-platform?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
 
 #spring.datasource.url=jdbc:mysql://gz-cdb-l8dnsjli.sql.tencentcdb.com:63342/ty?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&allowMultiQueries=true
 spring.datasource.username=root
@@ -59,10 +59,14 @@ dlmaps.pub.bank_id=8
 ###\u90ae\u50a8\u5bf9\u63a5\u516c\u53f8\u4ee3\u7801
 dlmaps.pub.dpt_id=2001
 
+dlmaps.pub.jj.dpt_id=2002
+
 ###\u5355\u4f4d\u4ee3\u7801\uff08\u56fa\u5b9a\u59824000\uff09
 dlmaps.in.company_id=4000
 ###\u5bf9\u516c\u8d26\u6237(\u53d1\u6539\u59d4\u8d26\u53f7)
 dlmaps.in.company_acc=952002010004446675
+
+dlmaps.in.jj.company_acc=123456
 ###"\u8d26\u53f7\u7c7b\u578b"
 dlmaps.in.company_acc_type=1