Browse Source

cuspay项目初始化

zx 7 years ago
parent
commit
072b7f48b4
23 changed files with 2178 additions and 11 deletions
  1. 2 1
      .gitignore
  2. 0 2
      build.gradle
  3. 2 2
      src/main/java/com/emato/cuspay/CuspaySpringBootApplication.java
  4. 17 0
      src/main/java/com/emato/cuspay/dao/mapper/MerchCusCfgMapper.java
  5. 188 0
      src/main/java/com/emato/cuspay/dto/WxResponseMsg.java
  6. 19 0
      src/main/java/com/emato/cuspay/notify/MerchantNotice.java
  7. 22 0
      src/main/java/com/emato/cuspay/notify/WxMerchantNotice.java
  8. 19 0
      src/main/java/com/emato/cuspay/service/MerchNotify.java
  9. 21 0
      src/main/java/com/emato/cuspay/service/MerchPaymentService.java
  10. 34 0
      src/main/java/com/emato/cuspay/service/imp/MerchPaymentServiceImp.java
  11. 36 0
      src/main/java/com/emato/cuspay/service/wx/CusPayService.java
  12. 432 0
      src/main/java/com/emato/cuspay/service/wx/imp/CustomServiceImp.java
  13. 39 0
      src/main/java/com/emato/cuspay/task/wx/WxCusTimer.java
  14. 57 0
      src/main/java/com/emato/cuspay/util/Validator.java
  15. 22 0
      src/main/java/com/emato/cuspay/util/XmlUtils.java
  16. 49 0
      src/main/java/com/emato/cuspay/web/controller/MerchPaymentController.java
  17. 71 0
      src/main/java/com/emato/cuspay/web/controller/wx/WxCusController.java
  18. 1 0
      src/main/resources/application-dev.yml
  19. 14 6
      src/main/resources/application.yml
  20. 132 0
      src/main/resources/mybatis/mapper/MerchCusCfgMapper.xml
  21. 157 0
      src/main/resources/mybatis/mapper/MerchPayCfgMapper.xml
  22. 552 0
      src/main/resources/mybatis/mapper/wx/WxCbPayDocMapper.xml
  23. 292 0
      src/main/resources/mybatis/mapper/wx/WxPayErrorMapper.xml

+ 2 - 1
.gitignore

@@ -24,4 +24,5 @@
 /nbbuild/
 /dist/
 /nbdist/
-/.nb-gradle/
+/.nb-gradle/
+/bin/

+ 0 - 2
build.gradle

@@ -19,8 +19,6 @@ tasks.withType(JavaCompile) {
 }
 
 repositories {
-    mavenLocal()
-    jcenter()
     mavenCentral()
     maven {
         url 'http://central.maven.org/maven2'

+ 2 - 2
src/main/java/com/emato/cuspay/CuspaySpringBootApplication.java

@@ -3,16 +3,16 @@ package com.emato.cuspay;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 @SpringBootApplication(
         exclude ={
-                // 多数据源,不使用自动配置
                 DataSourceAutoConfiguration.class
         },scanBasePackages = {
         "com.emato.cuspay"
     }
 )
+@EnableScheduling
 public class CuspaySpringBootApplication {
 
     public static void main(String[] args) {

+ 17 - 0
src/main/java/com/emato/cuspay/dao/mapper/MerchCusCfgMapper.java

@@ -0,0 +1,17 @@
+package com.emato.cuspay.dao.mapper;
+
+
+import com.emato.cuspay.dao.data.MerchCusCfg;
+import org.springframework.stereotype.Component;
+
+@Component
+public interface MerchCusCfgMapper {
+
+    int deleteByPrimaryKey(String cusCfgSn);
+
+    int insertSelective(MerchCusCfg record);
+
+    MerchCusCfg selectByPrimaryKey(String cusCfgSn);
+
+    int updateByPrimaryKeySelective(MerchCusCfg record);
+}

+ 188 - 0
src/main/java/com/emato/cuspay/dto/WxResponseMsg.java

@@ -0,0 +1,188 @@
+package com.emato.cuspay.dto;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * 微信支付报关响应数据实体类
+ */
+@XmlRootElement(name = "xml")
+public class WxResponseMsg {
+	//返回状态码
+	private String returnCode;
+	//返回信息
+	private String returnMsg;
+	//签名类型
+	private String signType;
+	//签名
+	private String sign;
+	//公众号ID
+	private String appid;
+	//商户号
+	private String mchId;
+	//业务结果
+	private String resultCode;
+	//错误代码
+	private String errCode;
+	//错误代码描述
+	private String errCodeDes;
+	//状态码
+	private String state;
+	//微信支付订单号
+	private String transactionId;
+	//商户订单号
+	private String outTradeNo;
+	//商户子订单号
+	private String subOrderNo;
+	//微信子订单号
+	private String subOrderId;
+	//最后更新时间
+	private String modifyTime;
+	//订购人和支付人 校验结果
+	private String certCheckResult;
+
+	@XmlElement(name = "return_code")
+	public String getReturnCode() {
+		return returnCode;
+	}
+
+	public void setReturnCode(String returnCode) {
+		this.returnCode = returnCode;
+	}
+	
+	@XmlElement(name = "return_msg")
+	public String getReturnMsg() {
+		return returnMsg;
+	}
+
+	public void setReturnMsg(String returnMsg) {
+		this.returnMsg = returnMsg;
+	}
+
+	@XmlElement(name = "sign_type")
+	public String getSignType() {
+		return signType;
+	}
+
+	public void setSignType(String signType) {
+		this.signType = signType;
+	}
+
+	@XmlElement(name = "sign")
+	public String getSign() {
+		return sign;
+	}
+
+	public void setSign(String sign) {
+		this.sign = sign;
+	}
+
+	@XmlElement(name = "appid")
+	public String getAppid() {
+		return appid;
+	}
+
+	public void setAppid(String appid) {
+		this.appid = appid;
+	}
+
+	@XmlElement(name = "mch_id")
+	public String getMchId() {
+		return mchId;
+	}
+
+	public void setMchId(String mchId) {
+		this.mchId = mchId;
+	}
+
+	@XmlElement(name = "result_code")
+	public String getResultCode() {
+		return resultCode;
+	}
+
+	public void setResultCode(String resultCode) {
+		this.resultCode = resultCode;
+	}
+
+	@XmlElement(name = "err_code")
+	public String getErrCode() {
+		return errCode;
+	}
+
+	public void setErrCode(String errCode) {
+		this.errCode = errCode;
+	}
+
+	@XmlElement(name = "err_code_des")
+	public String getErrCodeDes() {
+		return errCodeDes;
+	}
+
+	public void setErrCodeDes(String errCodeDes) {
+		this.errCodeDes = errCodeDes;
+	}
+
+	@XmlElement(name = "state")
+	public String getState() {
+		return state;
+	}
+
+	public void setState(String state) {
+		this.state = state;
+	}
+
+	@XmlElement(name = "transaction_id")
+	public String getTransactionId() {
+		return transactionId;
+	}
+
+	public void setTransactionId(String transactionId) {
+		this.transactionId = transactionId;
+	}
+
+	@XmlElement(name = "out_trade_no")
+	public String getOutTradeNo() {
+		return outTradeNo;
+	}
+
+	public void setOutTradeNo(String outTradeNo) {
+		this.outTradeNo = outTradeNo;
+	}
+
+	@XmlElement(name = "sub_order_no")
+	public String getSubOrderNo() {
+		return subOrderNo;
+	}
+
+	public void setSubOrderNo(String subOrderNo) {
+		this.subOrderNo = subOrderNo;
+	}
+
+	@XmlElement(name = "sub_order_id")
+	public String getSubOrderId() {
+		return subOrderId;
+	}
+
+	public void setSubOrderId(String subOrderId) {
+		this.subOrderId = subOrderId;
+	}
+
+	@XmlElement(name = "modify_time")
+	public String getModifyTime() {
+		return modifyTime;
+	}
+
+	public void setModifyTime(String modifyTime) {
+		this.modifyTime = modifyTime;
+	}
+
+	@XmlElement(name = "cert_check_result")
+	public String getCertCheckResult() {
+		return certCheckResult;
+	}
+
+	public void setCertCheckResult(String certCheckResult) {
+		this.certCheckResult = certCheckResult;
+	}
+	
+}

+ 19 - 0
src/main/java/com/emato/cuspay/notify/MerchantNotice.java

@@ -0,0 +1,19 @@
+package com.emato.cuspay.notify;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-17 17:22
+ */
+
+/**
+ * 通知回调接口
+ */
+public interface MerchantNotice {
+
+    /**
+     * 通知商户
+     */
+    void notifyMerchant();
+
+}

+ 22 - 0
src/main/java/com/emato/cuspay/notify/WxMerchantNotice.java

@@ -0,0 +1,22 @@
+package com.emato.cuspay.notify;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+
+/**
+ * @author zengjun
+ * @version 1.0
+ * 2018-05-18 09:44
+ */
+public class WxMerchantNotice implements MerchantNotice{
+
+    private static final Logger logger = LoggerFactory.getLogger(WxMerchantNotice.class);
+
+    @Value("${db.wx.limit}")
+    private Integer limit;
+
+    public void notifyMerchant() {
+
+    }
+}

+ 19 - 0
src/main/java/com/emato/cuspay/service/MerchNotify.java

@@ -0,0 +1,19 @@
+package com.emato.cuspay.service;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-17 17:22
+ */
+
+/**
+ * 商户通知回调接口
+ */
+public interface MerchNotify {
+
+    /**
+     * 通知商户
+     */
+    void notifyMerchant();
+
+}

+ 21 - 0
src/main/java/com/emato/cuspay/service/MerchPaymentService.java

@@ -0,0 +1,21 @@
+package com.emato.cuspay.service;
+
+import com.emato.cuspay.dao.data.MerchPayCfg;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+
+/**
+ * @author zx
+ *
+ *
+ * @version 1.0
+ * 2018-05-17 12:01
+ */
+public interface MerchPaymentService {
+
+    /**
+     *添加商户支付配置信息
+     * @param merchPayCfg 商户支付配置信息
+     * @return
+     */
+    ResponseMessage addMerchPayCfg(MerchPayCfg merchPayCfg);
+}

+ 34 - 0
src/main/java/com/emato/cuspay/service/imp/MerchPaymentServiceImp.java

@@ -0,0 +1,34 @@
+package com.emato.cuspay.service.imp;
+
+import com.emato.cuspay.dao.data.MerchPayCfg;
+import com.emato.cuspay.dao.mapper.MerchPayCfgMapper;
+import com.emato.cuspay.service.MerchPaymentService;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import com.emato.cuspay.support.msg.resp.ResponseStatus;
+import com.emato.cuspay.common.core.db.IdWorkerAide;
+import com.emato.cuspay.common.contant.TablePrimaryKeyPrefix;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-17 13:35
+ */
+
+@Service
+public class MerchPaymentServiceImp implements MerchPaymentService{
+
+    @Autowired
+    MerchPayCfgMapper merchPayCfgMapper;
+
+    public ResponseMessage addMerchPayCfg(MerchPayCfg merchPayCfg) {
+        merchPayCfg.setMerchSn(TablePrimaryKeyPrefix.merch_pay_cfg_type + IdWorkerAide.nextId());
+        int result = merchPayCfgMapper.insertSelective(merchPayCfg);
+        if (result > 0) {
+            return ResponseMessage.builder(ResponseStatus.SUCCESS.code, "添加成功").build();
+        }
+        return ResponseMessage.builder(ResponseStatus.ERROR.code, "添加失败").build();
+    }
+
+}

+ 36 - 0
src/main/java/com/emato/cuspay/service/wx/CusPayService.java

@@ -0,0 +1,36 @@
+package com.emato.cuspay.service.wx;
+
+import com.emato.cuspay.dao.data.wx.WxCbPayDoc;
+import com.emato.cuspay.dao.mapper.wx.WxCbPayDocMapper;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-15 09:36
+ */
+
+@Service
+public interface CusPayService {
+
+    /**
+     * @Description 支付单申报
+     * @return
+     */
+    void declarePayment();
+
+    /**
+     * 定时器扫描 通知商户报关状态
+     */
+    void notifyMecher();
+
+    /**
+     * 微信支付单入库
+     * @param wxCbPayDoc 微信支付单证
+     * @return
+     */
+    ResponseMessage addWxCbPayDoc(WxCbPayDoc wxCbPayDoc);
+
+}

+ 432 - 0
src/main/java/com/emato/cuspay/service/wx/imp/CustomServiceImp.java

@@ -0,0 +1,432 @@
+package com.emato.cuspay.service.wx.imp;
+
+import com.emato.cuspay.common.contant.Dict;
+import com.emato.cuspay.dao.data.MerchPayCfg;
+import com.emato.cuspay.dao.data.wx.WxCbPayDoc;
+import com.emato.cuspay.dao.data.wx.WxPayError;
+import com.emato.cuspay.dao.mapper.MerchCusCfgMapper;
+import com.emato.cuspay.dao.mapper.MerchPayCfgMapper;
+import com.emato.cuspay.dao.mapper.wx.WxCbPayDocMapper;
+import com.emato.cuspay.dao.mapper.wx.WxPayErrorMapper;
+import com.emato.cuspay.service.wx.CusPayService;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import com.emato.cuspay.support.msg.resp.ResponseStatus;
+import com.emato.cuspay.common.core.db.IdWorkerAide;
+import com.emato.cuspay.common.contant.TablePrimaryKeyPrefix;
+import com.emato.cuspay.dto.WxResponseMsg;
+import com.emato.cuspay.util.XmlUtils;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.xml.bind.JAXB;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author zengjun
+ * @version 1.0
+ * 2018-05-15 10:18
+ */
+
+@Service
+public class CustomServiceImp implements CusPayService {
+    private static final Logger logger = LoggerFactory.getLogger(CusPayService.class);
+
+    private final static String CHARSET = "utf-8";
+
+    private final static int HTTP_OK = 200;
+
+    private final static String FAIL = "FAIL";
+
+    private final static String RETURN_CODE_FAIL = "RETURN_CODE_FAIL";
+
+    private final static String SUCCESS = "SUCCESS";
+
+
+    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    @Value("${wx.payment.declare.url}")
+    private String declareURL;
+
+    @Value("${wx.payment.query.url}")
+    private String queryURL;
+
+    @Autowired
+    private WxCbPayDocMapper wxCbPayDocMapper;
+
+    @Autowired
+    private WxPayErrorMapper wxPayErrorMapper;
+
+    @Autowired
+    private MerchCusCfgMapper merchCusCfgMapper;
+
+    @Autowired
+    private MerchPayCfgMapper merchPayCfgMapper;
+
+    public void declarePayment() {
+        //获取待申报的支付单
+        List<WxCbPayDoc> wxCbPayDocs = wxCbPayDocMapper.selectBeDeclared();
+        if (wxCbPayDocs == null || wxCbPayDocs.isEmpty()) {
+            logger.info("没有待申报微信推海关的支付数据");
+            return;
+        }
+
+        //记录异常支付单订单
+        List<WxPayError> errors = Lists.newArrayList();
+
+        wxCbPayDocs.forEach(wxCbPayDoc -> {
+
+            MerchPayCfg merchPayCfg = merchPayCfgMapper.selectByWxMercherSn(wxCbPayDoc.getMerchSn());
+            if (merchPayCfg == null ) {
+                logger.error("商户编号位["+wxCbPayDoc.getMerchSn()+"]的商户不存在");
+                return;
+            }
+            if (merchPayCfg.getApiKey() == null) {
+                logger.error("商户编号为["+wxCbPayDoc.getMerchSn()+"]的api key 为空");
+                return;
+            }
+
+            //生成报关所需要的xml
+            String xml = XmlUtils.map2Xml(assemblyDeclareXml(wxCbPayDoc, merchPayCfg.getApiKey()));
+            logger.info("支付单申报数据xml:"+xml);
+
+            CloseableHttpClient httpClient = HttpClients.createDefault();
+            HttpPost httpPost = new HttpPost(declareURL);
+            httpPost.addHeader("Content-Type", "text/html;charset=UTF-8");
+            StringEntity strEntity = new StringEntity(xml, "utf-8");
+            httpPost.setEntity(strEntity);
+            CloseableHttpResponse  response  = null;
+            try {
+                response = httpClient.execute(httpPost);
+                int status = response.getStatusLine().getStatusCode();
+                if ( HTTP_OK == status) {
+                    HttpEntity httpEntity = response.getEntity();
+                    String strHttpEntity = EntityUtils.toString(httpEntity);
+                    logger.info("Http Entity string:"+strHttpEntity);
+                    //将xml 转换为java对象
+                    StringReader reader = new StringReader(strHttpEntity);
+                    WxResponseMsg wxResponseMsg = JAXB.unmarshal(reader, WxResponseMsg.class);
+
+                    //设置返回状态及返回消息
+                    wxCbPayDoc.setReturnCode(wxResponseMsg.getReturnCode());
+                    wxCbPayDoc.setReturnMsg(wxResponseMsg.getReturnMsg());
+                    //返回状态码为失败
+                    if (RETURN_CODE_FAIL.equals(wxResponseMsg.getReturnCode()) ||
+                                FAIL.equals(wxResponseMsg.getReturnCode())) {
+                        //设置申报状态为失败
+                        wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_03.getItem());
+                        //设置通知商户
+                        wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                        wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                    }
+
+                    //返回这状态码为成功 业务结果成功
+                    if (SUCCESS.equals(wxResponseMsg.getReturnCode()) && SUCCESS.equals(wxResponseMsg.getResultCode())) {
+                        wxCbPayDoc.setResultCode(wxResponseMsg.getResultCode());
+
+                        //返回状态未申报
+                        if (Dict.ResponseMsgState.UNDECLARED.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_01.getItem());
+                            wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                        //申报中
+                        if (Dict.ResponseMsgState.PROCESSING.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_22.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                        //申报已提交
+                        if (Dict.ResponseMsgState.SUBMITTED.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_10.getItem());
+                            wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                        //申报成功
+                        if (Dict.ResponseMsgState.SUCCESS.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_11.getItem());
+                            wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                        //申报失败
+                        if (Dict.ResponseMsgState.FAIL.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_03.getItem());
+                            wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                        //海关接口异常
+                        if (Dict.ResponseMsgState.EXCEPT.getItem().equals(wxResponseMsg.getState())) {
+                            wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_03.getItem());
+                            wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                            wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                        }
+                    }
+
+                    //返回状态码为成功 业务结果失败
+                    if (SUCCESS.equals(wxResponseMsg.getReturnCode()) && FAIL.equals(wxResponseMsg.getResultCode())) {
+                        wxCbPayDoc.setResultCode(wxResponseMsg.getResultCode());
+                        wxCbPayDoc.setErrCode(wxResponseMsg.getErrCode());
+                        wxCbPayDoc.setErrCodeDes(wxResponseMsg.getErrCodeDes());
+                        wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_12.getItem());
+                        //业务失败 通知商户
+                        wxCbPayDoc.setNotifyMerch(Dict.Whether.Yes.getItem());
+                        wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                    }
+                } else {
+                    throw new IOException("request url:["+declareURL+"] response code:"+ status);
+                }
+            } catch (IOException e) {
+                WxPayError wxPayError = assemblyWxPayError(wxCbPayDoc);
+                wxPayError.setErrCode("-1");
+                wxPayError.setErrMsg("支付推单调用海关推单接口["+declareURL+"]异常");
+                errors.add(wxPayError);
+            } finally {
+                if (response != null) {
+                    try {
+                        response.close();
+                    } catch (Exception ex) {
+                        //eat
+                    }
+                }
+            }
+
+            if (!errors.isEmpty()) {
+                logger.info("支付单报关异常数据集合errors:[]"+errors);
+
+                int result = wxPayErrorMapper.insertWxPayErrorBatch(errors);
+                if (result <= 0) {
+                    logger.error("添加异常记录信息失败");
+                }
+            }
+
+        });
+
+    }
+
+    /**
+     * 组装报关所需要的报关数据
+     * @param wxCbPayDoc 微信支付数据
+     * @param key 微信Api密钥
+     * @return
+     */
+    protected Map<String, String> assemblyDeclareXml(WxCbPayDoc wxCbPayDoc, String key) {
+        //1.选择报关数据,排序
+        SortedMap<String, String> sorted = Maps.newTreeMap();
+        sorted.put("appid", wxCbPayDoc.getAppid());
+        sorted.put("mch_id", wxCbPayDoc.getMchId());
+        sorted.put("out_trade_no", wxCbPayDoc.getOutTradeNo());
+        sorted.put("transaction_id", wxCbPayDoc.getTransactionId());
+        sorted.put("customs", wxCbPayDoc.getCustoms());
+        sorted.put("mch_customs_no", wxCbPayDoc.getMchCustomsNo());
+        if (wxCbPayDoc.getDuty() != null) {
+            sorted.put("duty", String.valueOf(wxCbPayDoc.getDuty()));
+        }
+        if (wxCbPayDoc.getActionType() != null) {
+            sorted.put("action_type", wxCbPayDoc.getActionType());
+        }
+        if (wxCbPayDoc.getSubOrderNo() != null) {
+            sorted.put("sub_order_no", wxCbPayDoc.getActionType());
+        }
+        if (wxCbPayDoc.getFeeType() != null) {
+            sorted.put("fee_type", wxCbPayDoc.getFeeType());
+        }
+        if (wxCbPayDoc.getOrderFee() != null) {
+            sorted.put("order_fee", String.valueOf(wxCbPayDoc.getOrderFee()));
+        }
+        if (wxCbPayDoc.getTransportFee() != null) {
+            sorted.put("transport_fee", String.valueOf(wxCbPayDoc.getTransportFee()));
+        }
+        if (wxCbPayDoc.getProductFee() != null) {
+            sorted.put("product_fee", String.valueOf(wxCbPayDoc.getProductFee()));
+        }
+        if (wxCbPayDoc.getCertType() != null ) {
+            sorted.put("cert_type", wxCbPayDoc.getCertType());
+        }
+        if (wxCbPayDoc.getCertId() != null) {
+            sorted.put("cert_id", wxCbPayDoc.getCertId());
+        }
+        if (wxCbPayDoc.getName() != null) {
+            sorted.put("name", wxCbPayDoc.getName());
+        }
+
+        //2.生成签名
+        StringBuilder sb = new StringBuilder();
+        for (Map.Entry<String,String> entry : sorted.entrySet()) {
+            sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
+        }
+        sb.append("key").append("=").append(key);
+        //签名MD5 加密
+        String sign = DigestUtils.md5Hex(sb.toString()).toUpperCase();
+
+        sorted.put("sign", sign);
+        return sorted;
+    }
+
+    public ResponseMessage addWxCbPayDoc(WxCbPayDoc wxCbPayDoc) {
+        wxCbPayDoc.setWxPaySn(TablePrimaryKeyPrefix.wx_cb_pay_type + IdWorkerAide.nextId());
+        //设置支付单状态 待审核
+        wxCbPayDoc.setDocStatus(Dict.PaymentDocStatus.i_00.getItem());
+
+        int result = wxCbPayDocMapper.insertSelective(wxCbPayDoc);
+        if (result > 0) {
+            return new ResponseMessage.Builder()
+                    .setCode(ResponseStatus.SUCCESS.code)
+                    .setMsg("入库成功")
+                    .build();
+        }
+        return  new ResponseMessage.Builder()
+                .setCode(ResponseStatus.ERROR.code)
+                .setMsg("入库失败")
+                .build();
+    }
+
+    /**
+     * 支付单状态改变 异步通知商户
+     */
+    public void notifyMecher() {
+        //查询需要通知商户的支付单
+        List<WxCbPayDoc> wxCbPayDocs = wxCbPayDocMapper.selectNotify();
+        if (wxCbPayDocs == null || wxCbPayDocs.isEmpty()) {
+            logger.info("没有要通知的商户的支付信息");
+            return;
+        }
+
+        //记录异常通知
+        List<WxPayError> errors = Lists.newArrayList();
+        //记录不需要通知的商户的支付信息
+        List<WxCbPayDoc> notifyOffs = Lists.newArrayList();
+
+        wxCbPayDocs.forEach((WxCbPayDoc wxCbPayDoc) -> {
+            //获取商户支付信息
+            MerchPayCfg merchPayCfg = merchPayCfgMapper.selectByWxMercherSn(wxCbPayDoc.getMerchSn());
+            if (merchPayCfg == null) {
+                logger.error("商户编号为["+wxCbPayDoc.getMerchSn()+"]的商户配置信息不存在");
+                //如果不存在商户信息 停止通知
+                WxPayError wxPayError = assemblyWxPayError(wxCbPayDoc);
+                wxPayError.setErrCode("-3");
+                wxPayError.setErrMsg("商户编号为["+wxCbPayDoc.getMerchSn()+"]的商户配置信息不存在");
+                errors.add(wxPayError);
+                notifyOffs.add(wxCbPayDoc);
+                return;
+            }
+            if (merchPayCfg.getNotifyUrl() == null) {
+                logger.error("商户编号为["+wxCbPayDoc.getMerchSn()+"]的回调通知接口为空");
+                // 如果回调接口为空 停止通知该商户
+                WxPayError wxPayError = assemblyWxPayError(wxCbPayDoc);
+                wxPayError.setErrCode("-4");
+                wxPayError.setErrMsg("商户编号为["+wxCbPayDoc.getMerchSn()+"]的商户的回调通知为空");
+                errors.add(wxPayError);
+                notifyOffs.add(wxCbPayDoc);
+                return;
+            }
+            String notify_str = merchPayCfg.getNotifyUrl();
+
+            CloseableHttpClient httpClient = HttpClients.createDefault();
+            HttpPost httpPost = new HttpPost(notify_str);
+            CloseableHttpResponse response = null;
+            try {
+                //通知商户数据填充 json格式数据
+                httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+
+                //设置参数
+                List<NameValuePair> pairs = Lists.newArrayList();
+                pairs.add(new BasicNameValuePair("sn","mgt111111"));
+                pairs.add(new BasicNameValuePair("name","test"));
+                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(pairs, CHARSET);
+
+                httpPost.setEntity(formEntity);
+
+                response = httpClient.execute(httpPost);
+                if (HTTP_OK == response.getStatusLine().getStatusCode()) {
+                    logger.info("response message:"+ EntityUtils.toString(response.getEntity()));
+                    //处理商户返回的状态
+                    wxCbPayDoc.setNotifyMerch(Dict.Whether.No.getItem());
+                    wxCbPayDocMapper.updateByPrimaryKeySelective(wxCbPayDoc);
+                } else {
+                    throw  new IOException("request url:["+notify_str+"] response code:\"+ status");
+                }
+            }catch (IOException e) {
+                logger.error("http post ["+notify_str+"] exception:" + e.getMessage());
+                WxPayError wxPayError = assemblyWxPayError(wxCbPayDoc);
+                wxPayError.setErrCode("-2");
+                wxPayError.setErrMsg("请求商户回掉接口["+notify_str+"]异常");
+                errors.add(wxPayError);
+                notifyOffs.add(wxCbPayDoc);
+            } finally {
+                if (response != null) {
+                    try {
+                        response.close();
+                    } catch (Exception e) {
+                        //eat
+                    }
+                }
+            }
+
+        });
+
+        if (!errors.isEmpty()) {
+            logger.info("商户回调通知异常数据集合errors:[]"+errors);
+
+            int result = wxPayErrorMapper.insertWxPayErrorBatch(errors);
+            if (result <= 0) {
+                logger.error("添加异常记录信息失败");
+            }
+        }
+
+        if (!notifyOffs.isEmpty()) {
+            int result = wxCbPayDocMapper.insertBatch(notifyOffs);
+            if (result <= 0) {
+                logger.error("添加异常记录信息失败");
+            }
+        }
+    }
+
+
+    /**
+     * 填充WxpayError
+     * @param wxCbPayDoc 支付信息
+     * @return
+     */
+    protected WxPayError assemblyWxPayError(WxCbPayDoc wxCbPayDoc) {
+        WxPayError wxPayError = new WxPayError();
+        wxPayError.setErrorSn(TablePrimaryKeyPrefix.wx_pay_error_type + IdWorkerAide.nextId());
+        wxPayError.setWxPaySn(wxCbPayDoc.getWxPaySn());
+        wxPayError.setAppid(wxCbPayDoc.getAppid());
+        wxPayError.setMerchSn(wxCbPayDoc.getMerchSn());
+        wxPayError.setMerchName(wxCbPayDoc.getMerchName());
+        wxPayError.setThirdPartyMerchCode(wxCbPayDoc.getThirdPartyMerchCode());
+        wxPayError.setThirdPartyMerchName(wxCbPayDoc.getThirdPartyMerchName());
+        wxPayError.setAppid(wxCbPayDoc.getAppid());
+        wxPayError.setMchId(wxCbPayDoc.getMchId());
+        wxPayError.setOutTradeNo(wxCbPayDoc.getOutTradeNo());
+        wxPayError.setTransactionId(wxCbPayDoc.getTransactionId());
+        wxPayError.setSubOrderNo(wxCbPayDoc.getSubOrderNo());
+        wxPayError.setCustoms(wxCbPayDoc.getCustoms());
+        wxPayError.setCreateTime(sdf.format(new Date()));
+        return wxPayError;
+    }
+
+    /**
+     * 查询支付单状态,如果支付单状态改变同步数据
+     */
+    public void QueryPaymentStateAndSynDB() {
+
+    }
+}

+ 39 - 0
src/main/java/com/emato/cuspay/task/wx/WxCusTimer.java

@@ -0,0 +1,39 @@
+package com.emato.cuspay.task.wx;
+
+import com.emato.cuspay.service.MerchNotify;
+import com.emato.cuspay.service.wx.CusPayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * 定时器
+ * @author zx
+ * @version 1.0
+ * 2018-05-15 17:16
+ */
+
+@Component
+public class WxCusTimer {
+
+    @Autowired
+    private CusPayService customService;
+
+    private MerchNotify merchNotify;
+
+    /**
+     * 支付申报定时任务
+     */
+    @Scheduled(fixedRate = 10000)
+    public void declareTask() {
+        customService.declarePayment();
+    }
+
+    /**
+     * 异步通知
+     */
+    @Scheduled(fixedRate = 10000)
+    public void notifyTask() {
+
+    }
+}

+ 57 - 0
src/main/java/com/emato/cuspay/util/Validator.java

@@ -0,0 +1,57 @@
+package com.emato.cuspay.util;
+
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import com.emato.cuspay.support.msg.resp.ResponseStatus;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-15 16:48
+ */
+public abstract class Validator {
+    /**
+     * 非空校验
+     *
+     * @param beVerified 要验证的字段 <code>{"字段名","错误消息"}</code>
+     * @param valideDate       验证数据
+     * @return
+     */
+    public static ResponseMessage isEmpty(Map<String, Object> beVerified, Map<String, Object> valideDate) {
+
+
+        /**
+         * 验证数据为空
+         */
+        if (valideDate == null) {
+            return new ResponseMessage.Builder()
+                        .setCode(ResponseStatus.ERROR.code)
+                        .setMsg("验证数据为空")
+                        .build();
+        }
+
+        /**
+         * 没有要验证的
+         */
+        if (beVerified == null) {
+            return new ResponseMessage.Builder()
+                    .setCode(ResponseStatus.ERROR.code)
+                    .setMsg("没有要验证的数据")
+                    .build();
+        }
+
+        for (String key : beVerified.keySet()) {
+            //验证数据没有要验证的字段, 或有要验证的字段,但字段为空
+            if (!valideDate.containsKey(key) ||
+                    (valideDate.containsKey(key) && StringUtils.isBlank(String.valueOf(valideDate.get(key)))) ||
+                    String.valueOf(valideDate.get(key)).equals("null")) {
+                return  ResponseMessage.builder(ResponseStatus.ERROR.code, beVerified.get(key)+"为空").build();
+            }
+        }
+        return new ResponseMessage.Builder()
+                    .setCode(ResponseStatus.SUCCESS.code)
+                    .build();
+    }
+}

+ 22 - 0
src/main/java/com/emato/cuspay/util/XmlUtils.java

@@ -15,6 +15,9 @@ import javax.xml.transform.sax.SAXSource;
 import java.io.File;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * XML处理类
@@ -141,4 +144,23 @@ public class XmlUtils {
         }
     }
 
+    public static String map2Xml(Map<String, String> map) {
+        StringBuffer sb = new StringBuffer();
+        sb.append("<xml>");
+        Set es = map.entrySet();
+        Iterator it = es.iterator();
+        while(it.hasNext()) {
+            Map.Entry entry = (Map.Entry)it.next();
+            String k = (String)entry.getKey();
+            String v = (String)entry.getValue();
+            //注意,有一些值要用![CDATA[value]]来表示
+            if ("attach".equalsIgnoreCase(k)||"body".equalsIgnoreCase(k)||"sign".equalsIgnoreCase(k)) {
+                sb.append("<"+k+">"+"<![CDATA["+v+"]]></"+k+">");
+            }else {
+                sb.append("<"+k+">"+v+"</"+k+">");
+            }
+        }
+        sb.append("</xml>");
+        return sb.toString();
+    }
 }

+ 49 - 0
src/main/java/com/emato/cuspay/web/controller/MerchPaymentController.java

@@ -0,0 +1,49 @@
+package com.emato.cuspay.web.controller;
+
+import com.emato.cuspay.dao.data.MerchPayCfg;
+import com.emato.cuspay.service.MerchPaymentService;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import com.emato.cuspay.support.msg.resp.ResponseStatus;
+import com.emato.cuspay.util.MapBeanUtils;
+import com.emato.cuspay.util.Validator;
+import com.google.common.collect.Maps;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-17 11:58
+ */
+
+@RestController
+@RequestMapping("/merch")
+public class MerchPaymentController {
+
+    @Autowired
+    private MerchPaymentService merchPaymentService;
+
+    @RequestMapping(value = "add", method = RequestMethod.POST)
+    public ResponseMessage add(MerchPayCfg merchPayCfg) {
+        //校验数据
+        Map<String, Object> validate = MapBeanUtils.fromObject(merchPayCfg);
+        Map<String, Object> beVerified = Maps.newHashMap();
+
+        beVerified.put("merchSn", "商户编号");
+        beVerified.put("appKey","api密钥");
+        beVerified.put("notifyUrl","商户通知回调接口");
+        beVerified.put("sign","签名");
+        beVerified.put("payChnlFlag", "支付通道标识(weixin:微信,alipay:蚂蚁金服)");
+
+        ResponseMessage rst = Validator.isEmpty(beVerified, validate);
+        if (ResponseStatus.ERROR.code.equals(rst.getCode())) {
+            return  rst;
+        }
+
+        return merchPaymentService.addMerchPayCfg(merchPayCfg);
+    }
+}

+ 71 - 0
src/main/java/com/emato/cuspay/web/controller/wx/WxCusController.java

@@ -0,0 +1,71 @@
+package com.emato.cuspay.web.controller.wx;
+
+import com.emato.cuspay.dao.data.wx.WxCbPayDoc;
+import com.emato.cuspay.service.wx.CusPayService;
+import com.emato.cuspay.support.msg.resp.ResponseMessage;
+import com.emato.cuspay.support.msg.resp.ResponseStatus;
+import com.emato.cuspay.util.MapBeanUtils;
+import com.emato.cuspay.util.Validator;
+import com.google.common.collect.Maps;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * @author zx
+ * @version 1.0
+ * 2018-05-15 09:31
+ */
+
+@RestController
+@RequestMapping("wx/custom")
+public class WxCusController {
+
+    @Autowired
+    CusPayService customService;
+
+    /**
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "declarepayment")
+    public ResponseMessage declarePayment(HttpServletRequest request){
+        String sn = request.getParameter("sn");
+        String name = request.getParameter("name");
+        System.out.println("============"+sn +":"+ name);
+        return new ResponseMessage.Builder().setCode(ResponseStatus.SUCCESS.code).setMsg("ok").build();
+    }
+
+    /**
+     * 支付单信息入库接口
+     * @param wxCbPayDoc
+     * @return
+     */
+    @RequestMapping(value = "wxcbpay", method = RequestMethod.POST)
+    public ResponseMessage addWxCbPayDoc(WxCbPayDoc wxCbPayDoc) {
+        //数据校验
+        Map<String, Object> validate = MapBeanUtils.fromObject(wxCbPayDoc);
+        Map<String, Object> beVerified = Maps.newHashMap();
+
+        beVerified.put("merchSn", "商户编号");
+        beVerified.put("platSn","平台编号");
+        beVerified.put("platName","平台中文名称");
+        beVerified.put("sign","签名");
+        beVerified.put("appid", "微信公众号ID");
+        beVerified.put("mchId", "商户号");
+        beVerified.put("outTradeNo", "商户订单号");
+        beVerified.put("transactionId","微信支付订单号");
+        beVerified.put("customs","海关");
+        beVerified.put("mchCustomsNo","海关备案号");
+
+        ResponseMessage rst = Validator.isEmpty(beVerified, validate);
+        if (ResponseStatus.ERROR.code.equals(rst.getCode())) {
+            return  rst;
+        }
+
+        return customService.addWxCbPayDoc(wxCbPayDoc);
+    }
+}

+ 1 - 0
src/main/resources/application-dev.yml

@@ -4,3 +4,4 @@ spring:
   profiles: dev
 
 
+

+ 14 - 6
src/main/resources/application.yml

@@ -11,7 +11,7 @@ server:
     address: 127.0.0.1
     port: 8080
     servlet:
-      context-path: /cuspay
+      context-path: /
 
 ds:
     worker-id: 1
@@ -33,9 +33,9 @@ spring:
             # 数据源zaxxer HikariCP
             type: com.zaxxer.hikari.HikariDataSource
             driver-class-name: org.mariadb.jdbc.Driver
-            url: jdbc:mysql://127.0.0.1:3306/my_test?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull
+            url: jdbc:mysql://127.0.0.1:3306/cuspay?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull
             username: root
-            password: 111111
+            password: root
             # hikari连接池配置
             hikari:
                 connection-timeout: 10000
@@ -92,6 +92,14 @@ mybatis:
         mapper-locations: classpath:mybatis/mapper/**/*.xml
         type-aliases-package: com.emato.cuspay.dao.data
 
-
-
-
+wx: 
+  payment: 
+    declare:
+      url: https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder
+    query:
+      url: https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclarequery
+
+db:
+  wx:
+    #定时器报关一次区的数据
+    limit: 20

+ 132 - 0
src/main/resources/mybatis/mapper/MerchCusCfgMapper.xml

@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.emato.cuspay.dao.mapper.MerchCusCfgMapper" >
+  <resultMap id="BaseResultMap" type="com.emato.cuspay.dao.data.MerchCusCfg" >
+    <id column="cus_cfg_sn" property="cusCfgSn" jdbcType="VARCHAR" />
+    <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
+    <result column="cus_flag" property="cusFlag" jdbcType="VARCHAR" />
+    <result column="is_valid" property="isValid" jdbcType="CHAR" />
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
+    <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="VARCHAR" />
+    <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
+    <result column="mod_time" property="modTime" jdbcType="VARCHAR" />
+    <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
+  </resultMap>
+
+  <sql id="Base_Column_List" >
+    cus_cfg_sn, merch_sn, cus_flag, is_valid, remark, creater_sn, create_time, moder_sn, 
+    mod_time, tstm
+  </sql>
+
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select 
+    <include refid="Base_Column_List" />
+    from merch_cus_cfg
+    where cus_cfg_sn = #{cusCfgSn,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from merch_cus_cfg
+    where cus_cfg_sn = #{cusCfgSn,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insertSelective" parameterType="com.emato.cuspay.dao.data.MerchCusCfg" >
+    insert into merch_cus_cfg
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="cusCfgSn != null" >
+        cus_cfg_sn,
+      </if>
+      <if test="merchSn != null" >
+        merch_sn,
+      </if>
+      <if test="cusFlag != null" >
+        cus_flag,
+      </if>
+      <if test="isValid != null" >
+        is_valid,
+      </if>
+      <if test="remark != null" >
+        remark,
+      </if>
+      <if test="createrSn != null" >
+        creater_sn,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="moderSn != null" >
+        moder_sn,
+      </if>
+      <if test="modTime != null" >
+        mod_time,
+      </if>
+      <if test="tstm != null" >
+        tstm,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="cusCfgSn != null" >
+        #{cusCfgSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchSn != null" >
+        #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="cusFlag != null" >
+        #{cusFlag,jdbcType=VARCHAR},
+      </if>
+      <if test="isValid != null" >
+        #{isValid,jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.emato.cuspay.dao.data.MerchCusCfg" >
+    update merch_cus_cfg
+    <set >
+      <if test="merchSn != null" >
+        merch_sn = #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="cusFlag != null" >
+        cus_flag = #{cusFlag,jdbcType=VARCHAR},
+      </if>
+      <if test="isValid != null" >
+        is_valid = #{isValid,jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        creater_sn = #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        moder_sn = #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        mod_time = #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        tstm = #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where cus_cfg_sn = #{cusCfgSn,jdbcType=VARCHAR}
+  </update>
+</mapper>

+ 157 - 0
src/main/resources/mybatis/mapper/MerchPayCfgMapper.xml

@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.emato.cuspay.dao.mapper.MerchPayCfgMapper" >
+  <resultMap id="BaseResultMap" type="com.emato.cuspay.dao.data.MerchPayCfg" >
+    <id column="pay_cfg_sn" property="payCfgSn" jdbcType="VARCHAR" />
+    <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
+    <result column="api_key" property="apiKey" jdbcType="VARCHAR" />
+    <result column="notify_url" property="notifyUrl" jdbcType="VARCHAR" />
+    <result column="pay_chnl_flag" property="payChnlFlag" jdbcType="VARCHAR" />
+    <result column="is_valid" property="isValid" jdbcType="CHAR" />
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
+    <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="VARCHAR" />
+    <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
+    <result column="mod_time" property="modTime" jdbcType="VARCHAR" />
+    <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    pay_cfg_sn, merch_sn, api_key, notify_url, pay_chnl_flag, is_valid, remark, creater_sn, create_time, moder_sn,
+    mod_time, tstm
+  </sql>
+
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select 
+    <include refid="Base_Column_List" />
+    from merch_pay_cfg
+    where pay_cfg_sn = #{payCfgSn,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from merch_pay_cfg
+    where pay_cfg_sn = #{payCfgSn,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insertSelective" parameterType="com.emato.cuspay.dao.data.MerchPayCfg" >
+    insert into merch_pay_cfg
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="payCfgSn != null" >
+        pay_cfg_sn,
+      </if>
+      <if test="merchSn != null" >
+        merch_sn,
+      </if>
+      <if test="apiKey != null" >
+        api_key,
+      </if>
+      <if test="notifyUrl != null">
+        notify_url,
+      </if>
+      <if test="payChnlFlag != null" >
+        pay_chnl_flag,
+      </if>
+      <if test="isValid != null" >
+        is_valid,
+      </if>
+      <if test="remark != null" >
+        remark,
+      </if>
+      <if test="createrSn != null" >
+        creater_sn,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="moderSn != null" >
+        moder_sn,
+      </if>
+      <if test="modTime != null" >
+        mod_time,
+      </if>
+      <if test="tstm != null" >
+        tstm,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="payCfgSn != null" >
+        #{payCfgSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchSn != null" >
+        #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="apiKey != null" >
+        #{apiKey,jdbcType=VARCHAR},
+      </if>
+      <if test="notifyUrl != null">
+        #{notifyUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="payChnlFlag != null" >
+        #{payChnlFlag,jdbcType=VARCHAR},
+      </if>
+      <if test="isValid != null" >
+        #{isValid,jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.emato.cuspay.dao.data.MerchPayCfg" >
+    update merch_pay_cfg
+    <set >
+      <if test="merchSn != null" >
+        merch_sn = #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="apiKey != null" >
+        api_key = #{apiKey,jdbcType=VARCHAR},
+      </if>
+      <if test="notify_url != null">
+        notify_url = #{notifyUrl, jdbcType=VARCHAR},
+      </if>
+      <if test="payChnlFlag != null" >
+        pay_chnl_flag = #{payChnlFlag,jdbcType=VARCHAR},
+      </if>
+      <if test="isValid != null" >
+        is_valid = #{isValid,jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        creater_sn = #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        moder_sn = #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        mod_time = #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        tstm = #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where pay_cfg_sn = #{payCfgSn,jdbcType=VARCHAR}
+  </update>
+
+  <select id="selectByWxMercherSn" resultMap="BaseResultMap" parameterType="java.lang.String">
+      SELECT
+      <include refid="Base_Column_List" />
+      FROM merch_pay_cfg WHERE merch_sn = #{merchSn} AND pay_chnl_flag = "weixin"
+  </select>
+</mapper>

+ 552 - 0
src/main/resources/mybatis/mapper/wx/WxCbPayDocMapper.xml

@@ -0,0 +1,552 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.emato.cuspay.dao.mapper.wx.WxCbPayDocMapper" >
+  <resultMap id="BaseResultMap" type="com.emato.cuspay.dao.data.wx.WxCbPayDoc" >
+    <id column="wx_pay_sn" property="wxPaySn" jdbcType="VARCHAR" />
+    <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
+    <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
+    <result column="plat_sn" property="platSn" jdbcType="VARCHAR" />
+    <result column="plat_name" property="platName" jdbcType="VARCHAR" />
+    <result column="third_party_merch_code" property="thirdPartyMerchCode" jdbcType="VARCHAR" />
+    <result column="third_party_merch_name" property="thirdPartyMerchName" jdbcType="VARCHAR" />
+    <result column="appid" property="appid" jdbcType="VARCHAR" />
+    <result column="mch_id" property="mchId" jdbcType="VARCHAR" />
+    <result column="out_trade_no" property="outTradeNo" jdbcType="VARCHAR" />
+    <result column="transaction_id" property="transactionId" jdbcType="VARCHAR" />
+    <result column="customs" property="customs" jdbcType="VARCHAR" />
+    <result column="mch_customs_no" property="mchCustomsNo" jdbcType="VARCHAR" />
+    <result column="duty" property="duty" jdbcType="INTEGER" />
+    <result column="action_type" property="actionType" jdbcType="VARCHAR" />
+    <result column="sub_order_no" property="subOrderNo" jdbcType="VARCHAR" />
+    <result column="fee_type" property="feeType" jdbcType="VARCHAR" />
+    <result column="order_fee" property="orderFee" jdbcType="INTEGER" />
+    <result column="transport_fee" property="transportFee" jdbcType="INTEGER" />
+    <result column="product_fee" property="productFee" jdbcType="INTEGER" />
+    <result column="cert_type" property="certType" jdbcType="VARCHAR" />
+    <result column="cert_id" property="certId" jdbcType="VARCHAR" />
+    <result column="name" property="name" jdbcType="VARCHAR" />
+    <result column="doc_status" property="docStatus" jdbcType="CHAR" />
+    <result column="notify_merch" property="notifyMerch" jdbcType="CHAR" />
+    <result column="remark" property="remark" jdbcType="VARCHAR" />
+    <result column="return_code" property="returnCode" jdbcType="VARCHAR" />
+    <result column="return_msg" property="returnMsg" jdbcType="VARCHAR" />
+    <result column="result_code" property="resultCode" jdbcType="VARCHAR" />
+    <result column="err_code" property="errCode" jdbcType="VARCHAR" />
+    <result column="err_code_des" property="errCodeDes" jdbcType="VARCHAR" />
+    <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="VARCHAR" />
+    <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
+    <result column="mod_time" property="modTime" jdbcType="VARCHAR" />
+    <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
+    <result column="ex_field" property="exField" jdbcType="VARCHAR" />
+    <result column="ex_field2" property="exField2" jdbcType="VARCHAR" />
+    <result column="ex_field3" property="exField3" jdbcType="VARCHAR" />
+    <result column="ex_field4" property="exField4" jdbcType="VARCHAR" />
+    <result column="ex_field5" property="exField5" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    wx_pay_sn, merch_sn, merch_name, plat_sn, plat_name, third_party_merch_code, third_party_merch_name, 
+    appid, mch_id, out_trade_no, transaction_id, customs, mch_customs_no, duty, action_type,
+    sub_order_no, fee_type, order_fee, transport_fee, product_fee, cert_type, cert_id, 
+    name, doc_status, notify_merch, remark, return_code, return_msg, result_code, err_code, err_code_des,
+    creater_sn, create_time, moder_sn, mod_time, tstm, ex_field, ex_field2, ex_field3, 
+    ex_field4, ex_field5
+  </sql>
+
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select 
+    <include refid="Base_Column_List" />
+    from wx_cb_pay_doc
+    where wx_pay_sn = #{wxPaySn,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from wx_cb_pay_doc
+    where wx_pay_sn = #{wxPaySn,jdbcType=VARCHAR}
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.emato.cuspay.dao.data.wx.WxCbPayDoc" >
+    insert into wx_cb_pay_doc
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="wxPaySn != null" >
+        wx_pay_sn,
+      </if>
+      <if test="merchSn != null" >
+        merch_sn,
+      </if>
+      <if test="merchName != null" >
+        merch_name,
+      </if>
+      <if test="platSn != null" >
+        plat_sn,
+      </if>
+      <if test="platName != null" >
+        plat_name,
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        third_party_merch_code,
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        third_party_merch_name,
+      </if>
+      <if test="appid != null" >
+        appid,
+      </if>
+      <if test="mchId != null" >
+        mch_id,
+      </if>
+      <if test="outTradeNo != null" >
+        out_trade_no,
+      </if>
+      <if test="transactionId != null" >
+        transaction_id,
+      </if>
+      <if test="customs != null" >
+        customs,
+      </if>
+      <if test="mchCustomsNo != null" >
+        mch_customs_no,
+      </if>
+      <if test="duty != null" >
+        duty,
+      </if>
+      <if test="actionType != null" >
+        action_type,
+      </if>
+      <if test="subOrderNo != null" >
+        sub_order_no,
+      </if>
+      <if test="feeType != null" >
+        fee_type,
+      </if>
+      <if test="orderFee != null" >
+        order_fee,
+      </if>
+      <if test="transportFee != null" >
+        transport_fee,
+      </if>
+      <if test="productFee != null" >
+        product_fee,
+      </if>
+      <if test="certType != null" >
+        cert_type,
+      </if>
+      <if test="certId != null" >
+        cert_id,
+      </if>
+      <if test="name != null" >
+        name,
+      </if>
+      <if test="docStatus != null" >
+        doc_status,
+      </if>
+      <if test="notifyMerch != null">
+        notify_merch,
+      </if>
+      <if test="remark != null" >
+        remark,
+      </if>
+      <if test="returnCode != null" >
+        return_code,
+      </if>
+      <if test="returnMsg != null" >
+        return_msg,
+      </if>
+      <if test="resultCode != null" >
+        result_code,
+      </if>
+      <if test="errCode != null" >
+        err_code,
+      </if>
+      <if test="errCodeDes != null" >
+        err_code_des,
+      </if>
+      <if test="createrSn != null" >
+        creater_sn,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="moderSn != null" >
+        moder_sn,
+      </if>
+      <if test="modTime != null" >
+        mod_time,
+      </if>
+      <if test="tstm != null" >
+        tstm,
+      </if>
+      <if test="exField != null" >
+        ex_field,
+      </if>
+      <if test="exField2 != null" >
+        ex_field2,
+      </if>
+      <if test="exField3 != null" >
+        ex_field3,
+      </if>
+      <if test="exField4 != null" >
+        ex_field4,
+      </if>
+      <if test="exField5 != null" >
+        ex_field5,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="wxPaySn != null" >
+        #{wxPaySn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchSn != null" >
+        #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchName != null" >
+        #{merchName,jdbcType=VARCHAR},
+      </if>
+      <if test="platSn != null" >
+        #{platSn,jdbcType=VARCHAR},
+      </if>
+      <if test="platName != null" >
+        #{platName,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        #{thirdPartyMerchCode,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        #{thirdPartyMerchName,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null" >
+        #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="mchId != null" >
+        #{mchId,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null" >
+        #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null" >
+        #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="customs != null" >
+        #{customs,jdbcType=VARCHAR},
+      </if>
+      <if test="mchCustomsNo != null" >
+        #{mchCustomsNo,jdbcType=VARCHAR},
+      </if>
+      <if test="duty != null" >
+        #{duty,jdbcType=INTEGER},
+      </if>
+      <if test="actionType != null" >
+        #{actionType,jdbcType=VARCHAR},
+      </if>
+      <if test="subOrderNo != null" >
+        #{subOrderNo,jdbcType=VARCHAR},
+      </if>
+      <if test="feeType != null" >
+        #{feeType,jdbcType=VARCHAR},
+      </if>
+      <if test="orderFee != null" >
+        #{orderFee,jdbcType=INTEGER},
+      </if>
+      <if test="transportFee != null" >
+        #{transportFee,jdbcType=INTEGER},
+      </if>
+      <if test="productFee != null" >
+        #{productFee,jdbcType=INTEGER},
+      </if>
+      <if test="certType != null" >
+        #{certType,jdbcType=VARCHAR},
+      </if>
+      <if test="certId != null" >
+        #{certId,jdbcType=VARCHAR},
+      </if>
+      <if test="name != null" >
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="docStatus != null" >
+        #{docStatus,jdbcType=CHAR},
+      </if>
+      <if test="notifyMerch != null">
+        #{notifyMerch, jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="returnCode != null" >
+        #{returnCode,jdbcType=VARCHAR},
+      </if>
+      <if test="returnMsg != null" >
+        #{returnMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="resultCode != null" >
+        #{resultCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errCode != null" >
+        #{errCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errCodeDes != null" >
+        #{errCodeDes,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        #{tstm,jdbcType=TIMESTAMP},
+      </if>
+      <if test="exField != null" >
+        #{exField,jdbcType=VARCHAR},
+      </if>
+      <if test="exField2 != null" >
+        #{exField2,jdbcType=VARCHAR},
+      </if>
+      <if test="exField3 != null" >
+        #{exField3,jdbcType=VARCHAR},
+      </if>
+      <if test="exField4 != null" >
+        #{exField4,jdbcType=VARCHAR},
+      </if>
+      <if test="exField5 != null" >
+        #{exField5,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="updateByPrimaryKeySelective" parameterType="com.emato.cuspay.dao.data.wx.WxCbPayDoc" >
+    update wx_cb_pay_doc
+    <set >
+      <if test="merchSn != null" >
+        merch_sn = #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchName != null" >
+        merch_name = #{merchName,jdbcType=VARCHAR},
+      </if>
+      <if test="platSn != null" >
+        plat_sn = #{platSn,jdbcType=VARCHAR},
+      </if>
+      <if test="platName != null" >
+        plat_name = #{platName,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        third_party_merch_code = #{thirdPartyMerchCode,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        third_party_merch_name = #{thirdPartyMerchName,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null" >
+        appid = #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="mchId != null" >
+        mch_id = #{mchId,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null" >
+        out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null" >
+        transaction_id = #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="customs != null" >
+        customs = #{customs,jdbcType=VARCHAR},
+      </if>
+      <if test="mchCustomsNo != null" >
+        mch_customs_no = #{mchCustomsNo,jdbcType=VARCHAR},
+      </if>
+      <if test="duty != null" >
+        duty = #{duty,jdbcType=INTEGER},
+      </if>
+      <if test="actionType != null" >
+        action_type = #{actionType,jdbcType=VARCHAR},
+      </if>
+      <if test="subOrderNo != null" >
+        sub_order_no = #{subOrderNo,jdbcType=VARCHAR},
+      </if>
+      <if test="feeType != null" >
+        fee_type = #{feeType,jdbcType=VARCHAR},
+      </if>
+      <if test="orderFee != null" >
+        order_fee = #{orderFee,jdbcType=INTEGER},
+      </if>
+      <if test="transportFee != null" >
+        transport_fee = #{transportFee,jdbcType=INTEGER},
+      </if>
+      <if test="productFee != null" >
+        product_fee = #{productFee,jdbcType=INTEGER},
+      </if>
+      <if test="certType != null" >
+        cert_type = #{certType,jdbcType=VARCHAR},
+      </if>
+      <if test="certId != null" >
+        cert_id = #{certId,jdbcType=VARCHAR},
+      </if>
+      <if test="name != null" >
+        name = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="docStatus != null" >
+        doc_status = #{docStatus,jdbcType=CHAR},
+      </if>
+      <if test="notifyMerch != null">
+        notify_merch = #{notifyMerch,jdbcType=CHAR},
+      </if>
+      <if test="remark != null" >
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="returnCode != null" >
+        return_code = #{returnCode,jdbcType=VARCHAR},
+      </if>
+      <if test="returnMsg != null" >
+        return_msg = #{returnMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="resultCode != null" >
+        result_code = #{resultCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errCode != null" >
+        err_code = #{errCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errCodeDes != null" >
+        err_code_des = #{errCodeDes,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        creater_sn = #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        moder_sn = #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        mod_time = #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        tstm = #{tstm,jdbcType=TIMESTAMP},
+      </if>
+      <if test="exField != null" >
+        ex_field = #{exField,jdbcType=VARCHAR},
+      </if>
+      <if test="exField2 != null" >
+        ex_field2 = #{exField2,jdbcType=VARCHAR},
+      </if>
+      <if test="exField3 != null" >
+        ex_field3 = #{exField3,jdbcType=VARCHAR},
+      </if>
+      <if test="exField4 != null" >
+        ex_field4 = #{exField4,jdbcType=VARCHAR},
+      </if>
+      <if test="exField5 != null" >
+        ex_field5 = #{exField5,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where wx_pay_sn = #{wxPaySn,jdbcType=VARCHAR}
+  </update>
+
+
+  <select id="selectBeDeclared" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from wx_cb_pay_doc
+    where doc_status = '00' limit 20
+  </select>
+  
+  <select id="selectNotify" resultMap="BaseResultMap" parameterType="java.lang.Integer">
+    SELECT 
+      <include refid="Base_Column_List"/>
+    FROM wx_cb_pay_doc WHERE doc_status != '00' AND notify_merch = 'Y' limit #{limit}
+  </select>
+
+  <select id="insertBatch">
+    INSERT wx_cb_pay_doc
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      wx_pay_sn,
+      merch_sn,
+      merch_name,
+      plat_sn,
+      plat_name,
+      third_party_merch_code,
+      third_party_merch_name,
+      appid,
+      mch_id,
+      out_trade_no,
+      transaction_id,
+      customs,
+      mch_customs_no,
+      duty,
+      action_type,
+      sub_order_no,
+      fee_type,
+      order_fee,
+      transport_fee,
+      product_fee,
+      cert_type,
+      cert_id,
+      name,
+      doc_status,
+      notify_merch,
+      remark,
+      return_code,
+      return_msg,
+      result_code,
+      err_code,
+      err_code_des,
+      creater_sn,
+      create_time,
+      moder_sn,
+      mod_time,
+      ex_field,
+      ex_field2,
+      ex_field3,
+      ex_field4,
+      ex_field5,
+    </trim>
+    VALUES
+    <foreach collection="list" item="item" index="index" separator=",">
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+          #{wxPaySn,jdbcType=VARCHAR},
+          #{merchSn,jdbcType=VARCHAR},
+          #{merchName,jdbcType=VARCHAR},
+          #{platSn,jdbcType=VARCHAR},
+          #{platName,jdbcType=VARCHAR},
+          #{thirdPartyMerchCode,jdbcType=VARCHAR},
+          #{thirdPartyMerchName,jdbcType=VARCHAR},
+          #{appid,jdbcType=VARCHAR},
+          #{mchId,jdbcType=VARCHAR},
+          #{outTradeNo,jdbcType=VARCHAR},
+          #{transactionId,jdbcType=VARCHAR},
+          #{customs,jdbcType=VARCHAR},
+          #{mchCustomsNo,jdbcType=VARCHAR},
+          #{duty,jdbcType=INTEGER},
+          #{actionType,jdbcType=VARCHAR},
+          #{subOrderNo,jdbcType=VARCHAR},
+          #{feeType,jdbcType=VARCHAR},
+          #{orderFee,jdbcType=INTEGER},
+          #{transportFee,jdbcType=INTEGER},
+          #{productFee,jdbcType=INTEGER},
+          #{certType,jdbcType=VARCHAR},
+          #{certId,jdbcType=VARCHAR},
+          #{name,jdbcType=VARCHAR},
+          #{docStatus,jdbcType=CHAR},
+          #{notifyMerch, jdbcType=CHAR},
+          #{remark,jdbcType=VARCHAR},
+          #{returnCode,jdbcType=VARCHAR},
+          #{returnMsg,jdbcType=VARCHAR},
+          #{resultCode,jdbcType=VARCHAR},
+          #{errCode,jdbcType=VARCHAR},
+          #{errCodeDes,jdbcType=VARCHAR},
+          #{createrSn,jdbcType=VARCHAR},
+          #{createTime,jdbcType=VARCHAR},
+          #{moderSn,jdbcType=VARCHAR},
+          #{modTime,jdbcType=VARCHAR},
+          #{exField,jdbcType=VARCHAR},
+          #{exField2,jdbcType=VARCHAR},
+          #{exField3,jdbcType=VARCHAR},
+          #{exField4,jdbcType=VARCHAR},
+          #{exField5,jdbcType=VARCHAR},
+      </trim>
+    </foreach>
+  </select>
+</mapper>

+ 292 - 0
src/main/resources/mybatis/mapper/wx/WxPayErrorMapper.xml

@@ -0,0 +1,292 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.emato.cuspay.dao.mapper.wx.WxPayErrorMapper" >
+  <resultMap id="BaseResultMap" type="com.emato.cuspay.dao.data.wx.WxPayError" >
+    <id column="error_sn" property="errorSn" jdbcType="VARCHAR" />
+    <result column="wx_pay_sn" property="wxPaySn" jdbcType="VARCHAR" />
+    <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
+    <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
+    <result column="plat_sn" property="platSn" jdbcType="VARCHAR" />
+    <result column="plat_name" property="platName" jdbcType="VARCHAR" />
+    <result column="third_party_merch_code" property="thirdPartyMerchCode" jdbcType="VARCHAR" />
+    <result column="third_party_merch_name" property="thirdPartyMerchName" jdbcType="VARCHAR" />
+    <result column="appid" property="appid" jdbcType="VARCHAR" />
+    <result column="mch_id" property="mchId" jdbcType="VARCHAR" />
+    <result column="out_trade_no" property="outTradeNo" jdbcType="VARCHAR" />
+    <result column="transaction_id" property="transactionId" jdbcType="VARCHAR" />
+    <result column="sub_order_no" property="subOrderNo" jdbcType="VARCHAR" />
+    <result column="customs" property="customs" jdbcType="VARCHAR" />
+    <result column="err_code" property="errCode" jdbcType="VARCHAR" />
+    <result column="err_msg" property="errMsg" jdbcType="VARCHAR" />
+    <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
+    <result column="create_time" property="createTime" jdbcType="VARCHAR" />
+    <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
+    <result column="mod_time" property="modTime" jdbcType="VARCHAR" />
+    <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    error_sn, wx_pay_sn, merch_sn, merch_name, plat_sn, plat_name, third_party_merch_code,
+    third_party_merch_name, appid, mch_id, out_trade_no, transaction_id, sub_order_no,
+    customs, err_code, err_msg, creater_sn, create_time, moder_sn, mod_time, tstm
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select
+    <include refid="Base_Column_List" />
+    from wx_pay_error
+    where error_sn = #{errorSn,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from wx_pay_error
+    where error_sn = #{errorSn,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insertSelective" parameterType="com.emato.cuspay.dao.data.wx.WxPayError" >
+    insert into wx_pay_error
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="errorSn != null" >
+        error_sn,
+      </if>
+      <if test="wxPaySn != null" >
+        wx_pay_sn,
+      </if>
+      <if test="merchSn != null" >
+        merch_sn,
+      </if>
+      <if test="merchName != null" >
+        merch_name,
+      </if>
+      <if test="platSn != null" >
+        plat_sn,
+      </if>
+      <if test="platName != null" >
+        plat_name,
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        third_party_merch_code,
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        third_party_merch_name,
+      </if>
+      <if test="appid != null" >
+        appid,
+      </if>
+      <if test="mchId != null" >
+        mch_id,
+      </if>
+      <if test="outTradeNo != null" >
+        out_trade_no,
+      </if>
+      <if test="transactionId != null" >
+        transaction_id,
+      </if>
+      <if test="subOrderNo != null" >
+        sub_order_no,
+      </if>
+      <if test="customs != null" >
+        customs,
+      </if>
+      <if test="errCode != null" >
+        err_code,
+      </if>
+      <if test="errMsg != null" >
+        err_msg,
+      </if>
+      <if test="createrSn != null" >
+        creater_sn,
+      </if>
+      <if test="createTime != null" >
+        create_time,
+      </if>
+      <if test="moderSn != null" >
+        moder_sn,
+      </if>
+      <if test="modTime != null" >
+        mod_time,
+      </if>
+      <if test="tstm != null" >
+        tstm,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="errorSn != null" >
+        #{errorSn,jdbcType=VARCHAR},
+      </if>
+      <if test="wxPaySn != null" >
+        #{wxPaySn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchSn != null" >
+        #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchName != null" >
+        #{merchName,jdbcType=VARCHAR},
+      </if>
+      <if test="platSn != null" >
+        #{platSn,jdbcType=VARCHAR},
+      </if>
+      <if test="platName != null" >
+        #{platName,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        #{thirdPartyMerchCode,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        #{thirdPartyMerchName,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null" >
+        #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="mchId != null" >
+        #{mchId,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null" >
+        #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null" >
+        #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="subOrderNo != null" >
+        #{subOrderNo,jdbcType=VARCHAR},
+      </if>
+      <if test="customs != null" >
+        #{customs,jdbcType=VARCHAR},
+      </if>
+      <if test="errCode != null" >
+        #{errCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errMsg != null" >
+        #{errMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.emato.cuspay.dao.data.wx.WxPayError" >
+    update wx_pay_error
+    <set >
+      <if test="wxPaySn != null" >
+        wx_pay_sn = #{wxPaySn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchSn != null" >
+        merch_sn = #{merchSn,jdbcType=VARCHAR},
+      </if>
+      <if test="merchName != null" >
+        merch_name = #{merchName,jdbcType=VARCHAR},
+      </if>
+      <if test="platSn != null" >
+        plat_sn = #{platSn,jdbcType=VARCHAR},
+      </if>
+      <if test="platName != null" >
+        plat_name = #{platName,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchCode != null" >
+        third_party_merch_code = #{thirdPartyMerchCode,jdbcType=VARCHAR},
+      </if>
+      <if test="thirdPartyMerchName != null" >
+        third_party_merch_name = #{thirdPartyMerchName,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null" >
+        appid = #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="mchId != null" >
+        mch_id = #{mchId,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null" >
+        out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null" >
+        transaction_id = #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="subOrderNo != null" >
+        sub_order_no = #{subOrderNo,jdbcType=VARCHAR},
+      </if>
+      <if test="customs != null" >
+        customs = #{customs,jdbcType=VARCHAR},
+      </if>
+      <if test="errCode != null" >
+        err_code = #{errCode,jdbcType=VARCHAR},
+      </if>
+      <if test="errMsg != null" >
+        err_msg = #{errMsg,jdbcType=VARCHAR},
+      </if>
+      <if test="createrSn != null" >
+        creater_sn = #{createrSn,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        create_time = #{createTime,jdbcType=VARCHAR},
+      </if>
+      <if test="moderSn != null" >
+        moder_sn = #{moderSn,jdbcType=VARCHAR},
+      </if>
+      <if test="modTime != null" >
+        mod_time = #{modTime,jdbcType=VARCHAR},
+      </if>
+      <if test="tstm != null" >
+        tstm = #{tstm,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where error_sn = #{errorSn,jdbcType=VARCHAR}
+  </update>
+
+  <insert id="insertWxPayErrorBatch" parameterType="java.util.List">
+    insert into wx_pay_error
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      error_sn,
+      wx_pay_sn,
+      merch_sn,
+      merch_name,
+      plat_sn,
+      plat_name,
+      third_party_merch_code,
+      third_party_merch_name,
+      appid,
+      mch_id,
+      out_trade_no,
+      transaction_id,
+      sub_order_no,
+      customs,
+      err_code,
+      err_msg,
+      creater_sn,
+      create_time,
+      moder_sn,
+      mod_time
+    </trim>
+    VALUES
+    <foreach collection="list" item="item" index="index" separator=",">
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+        #{item.errorSn,jdbcType=VARCHAR},
+        #{item.wxPaySn,jdbcType=VARCHAR},
+        #{item.merchSn,jdbcType=VARCHAR},
+        #{item.merchName,jdbcType=VARCHAR},
+        #{item.platSn,jdbcType=VARCHAR},
+        #{item.platName,jdbcType=VARCHAR},
+        #{item.thirdPartyMerchCode,jdbcType=VARCHAR},
+        #{item.thirdPartyMerchName,jdbcType=VARCHAR},
+        #{item.appid,jdbcType=VARCHAR},
+        #{item.mchId,jdbcType=VARCHAR},
+        #{item.outTradeNo,jdbcType=VARCHAR},
+        #{item.transactionId,jdbcType=VARCHAR},
+        #{item.subOrderNo,jdbcType=VARCHAR},
+        #{item.customs,jdbcType=VARCHAR},
+        #{item.errCode,jdbcType=VARCHAR},
+        #{item.errMsg,jdbcType=VARCHAR},
+        #{item.createrSn,jdbcType=VARCHAR},
+        #{item.createTime,jdbcType=VARCHAR},
+        #{item.moderSn,jdbcType=VARCHAR},
+        #{item.modTime,jdbcType=VARCHAR},
+      </trim>
+    </foreach>
+  </insert>
+</mapper>