商户支付方式参数关系表
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
index 15178a8..65f8e1a 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
@@ -3,12 +3,14 @@
import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
import com.supwisdom.dlpay.api.domain.TPaytypeConfigPK;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by shuwei on 2019/4/9.
*/
+@Repository
public interface PaytypeConfigDao extends JpaRepository<TPaytypeConfig, TPaytypeConfigPK> {
List<TPaytypeConfig> getByPaytype(String paytype);
}
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java
index ab493bb..f782db4 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java
@@ -2,9 +2,12 @@
import com.supwisdom.dlpay.api.domain.TPaytype;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
/**
* Created by shuwei on 2019/4/9.
*/
+@Repository
public interface PaytypeDao extends JpaRepository<TPaytype, String> {
+ TPaytype getByPaytype(String paytype);
}
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java
index 03fbfcd..9b03661 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java
@@ -3,11 +3,13 @@
import com.supwisdom.dlpay.api.domain.TPerson;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
/**
* Created by shuwei on 2019/4/12.
*/
+@Repository
public interface PersonDao extends JpaRepository<TPerson, String> {
@Query(value = "from TPerson where idtype=?1 and idno=?2 ")
TPerson findByIdentity(String idtype, String idno);
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java
new file mode 100644
index 0000000..036161a
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java
@@ -0,0 +1,14 @@
+package com.supwisdom.dlpay.api.dao;
+
+import com.supwisdom.dlpay.api.domain.TShopPaytypeConfig;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface ShopPaytypeConfigDao extends JpaRepository<TShopPaytypeConfig, String> {
+ @Query("select a from TShopPaytypeConfig a where a.paytype=?1 and a.shopaccno=?2 ")
+ List<TShopPaytypeConfig> getShopPaytypeConfigs(String paytype, String shopaccno);
+}
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java
new file mode 100644
index 0000000..750f8ac
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java
@@ -0,0 +1,13 @@
+package com.supwisdom.dlpay.api.dao;
+
+import com.supwisdom.dlpay.api.domain.TShopPaytype;
+import com.supwisdom.dlpay.api.domain.TShopPaytypePK;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ShopPaytypeDao extends JpaRepository<TShopPaytype,TShopPaytypePK> {
+ @Query("select a from TShopPaytype a where a.paytype=?1 and a.shopaccno=?2 ")
+ TShopPaytype getById(String paytype, String shopaccno);
+}
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TPaytype.java b/src/main/java/com/supwisdom/dlpay/api/domain/TPaytype.java
index c0c1e60..5872560 100644
--- a/src/main/java/com/supwisdom/dlpay/api/domain/TPaytype.java
+++ b/src/main/java/com/supwisdom/dlpay/api/domain/TPaytype.java
@@ -15,11 +15,14 @@
@Column(name = "ENABLE", nullable = false, length = 20)
private String enable;
- @Column(name = "DPS_ENABLE", length = 20)
- private String dpsEnable;
+ @Column(name = "CHARGE_ENABLE", nullable = false, length = 10)
+ private String chargeEnable;
- @Column(name = "REVERSE_ENABLE", length = 20)
- private String reverseEnable;
+ @Column(name = "CONSUME_ENABLE",nullable = false, length = 10)
+ private String consumeEnable;
+
+ @Column(name = "PAYDESC", length = 200)
+ private String paydesc;
public String getPaytype() {
return paytype;
@@ -37,19 +40,27 @@
this.enable = enable;
}
- public String getDpsEnable() {
- return dpsEnable;
+ public String getChargeEnable() {
+ return chargeEnable;
}
- public void setDpsEnable(String dpsEnable) {
- this.dpsEnable = dpsEnable;
+ public void setChargeEnable(String chargeEnable) {
+ this.chargeEnable = chargeEnable;
}
- public String getReverseEnable() {
- return reverseEnable;
+ public String getConsumeEnable() {
+ return consumeEnable;
}
- public void setReverseEnable(String reverseEnable) {
- this.reverseEnable = reverseEnable;
+ public void setConsumeEnable(String consumeEnable) {
+ this.consumeEnable = consumeEnable;
+ }
+
+ public String getPaydesc() {
+ return paydesc;
+ }
+
+ public void setPaydesc(String paydesc) {
+ this.paydesc = paydesc;
}
}
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytype.java b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytype.java
new file mode 100644
index 0000000..81c893c
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytype.java
@@ -0,0 +1,65 @@
+package com.supwisdom.dlpay.api.domain;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "TB_SHOP_PAYTYPE")
+@IdClass(TShopPaytypePK.class)
+public class TShopPaytype {
+ @Id
+ @Column(name = "SHOPACCNO", nullable = false, length = 10)
+ private String shopaccno;
+
+ @Id
+ @Column(name = "PAYTYPE", nullable = false, length = 20)
+ private String paytype;
+
+ @Column(name = "CONSUME_ENABLE", nullable = false, length = 10)
+ private String consumeEnable;
+
+ @Column(name = "REVERSE_ENABLE", nullable = false, length = 10)
+ private String reverseEnable;
+
+ @Column(name = "CREATETIME", length = 14)
+ private String createtime;
+
+ public String getShopaccno() {
+ return shopaccno;
+ }
+
+ public void setShopaccno(String shopaccno) {
+ this.shopaccno = shopaccno;
+ }
+
+ public String getPaytype() {
+ return paytype;
+ }
+
+ public void setPaytype(String paytype) {
+ this.paytype = paytype;
+ }
+
+ public String getConsumeEnable() {
+ return consumeEnable;
+ }
+
+ public void setConsumeEnable(String consumeEnable) {
+ this.consumeEnable = consumeEnable;
+ }
+
+ public String getReverseEnable() {
+ return reverseEnable;
+ }
+
+ public void setReverseEnable(String reverseEnable) {
+ this.reverseEnable = reverseEnable;
+ }
+
+ public String getCreatetime() {
+ return createtime;
+ }
+
+ public void setCreatetime(String createtime) {
+ this.createtime = createtime;
+ }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java
new file mode 100644
index 0000000..4d9fd72
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java
@@ -0,0 +1,89 @@
+package com.supwisdom.dlpay.api.domain;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "TB_SHOP_PAYTYPE_CONFIG", indexes = {@Index(name = "shop_paytype_config_uk", unique = true, columnList = "shopaccno,paytype,configid")})
+public class TShopPaytypeConfig {
+ @Id
+ @GenericGenerator(name = "idGenerator", strategy = "uuid")
+ @GeneratedValue(generator = "idGenerator")
+ @Column(name = "CFGID", nullable = false, length = 32)
+ private Integer cfgid;
+
+ @Column(name = "SHOPACCNO", nullable = false, length = 10)
+ private String shopaccno;
+
+ @Column(name = "PAYTYPE", nullable = false, length = 20)
+ private String paytype;
+
+ @Column(name = "CONFIGID", nullable = false, length = 40)
+ private String configid;
+
+ @Column(name = "CONFIG_VALUE", length = 2000)
+ private String configValue;
+
+ @Column(name = "CONFIG_NAME", length = 200)
+ private String configName;
+
+ public TShopPaytypeConfig() {
+ }
+
+ public TShopPaytypeConfig(String shopaccno, String paytype, String configid, String configValue, String configName) {
+ this.shopaccno = shopaccno;
+ this.paytype = paytype;
+ this.configid = configid;
+ this.configValue = configValue;
+ this.configName = configName;
+ }
+
+ public Integer getCfgid() {
+ return cfgid;
+ }
+
+ public void setCfgid(Integer cfgid) {
+ this.cfgid = cfgid;
+ }
+
+ public String getShopaccno() {
+ return shopaccno;
+ }
+
+ public void setShopaccno(String shopaccno) {
+ this.shopaccno = shopaccno;
+ }
+
+ public String getPaytype() {
+ return paytype;
+ }
+
+ public void setPaytype(String paytype) {
+ this.paytype = paytype;
+ }
+
+ public String getConfigid() {
+ return configid;
+ }
+
+ public void setConfigid(String configid) {
+ this.configid = configid;
+ }
+
+ public String getConfigValue() {
+ return configValue;
+ }
+
+ public void setConfigValue(String configValue) {
+ this.configValue = configValue;
+ }
+
+ public String getConfigName() {
+ return configName;
+ }
+
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypePK.java b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypePK.java
new file mode 100644
index 0000000..4196b55
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypePK.java
@@ -0,0 +1,61 @@
+package com.supwisdom.dlpay.api.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+@Embeddable
+public class TShopPaytypePK implements Serializable {
+ @Id
+ @Column(name = "SHOPACCNO", nullable = false, length = 10)
+ private String shopaccno;
+
+ @Id
+ @Column(name = "PAYTYPE", nullable = false, length = 20)
+ private String paytype;
+
+ public TShopPaytypePK() {
+ }
+
+ public TShopPaytypePK(String shopaccno, String paytype) {
+ this.shopaccno = shopaccno;
+ this.paytype = paytype;
+ }
+
+ public String getShopaccno() {
+ return shopaccno;
+ }
+
+ public void setShopaccno(String shopaccno) {
+ this.shopaccno = shopaccno;
+ }
+
+ public String getPaytype() {
+ return paytype;
+ }
+
+ public void setPaytype(String paytype) {
+ this.paytype = paytype;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ TShopPaytypePK tShopPaytypePK = (TShopPaytypePK) o;
+ if (shopaccno != null ? !shopaccno.equals(tShopPaytypePK.getShopaccno()) : shopaccno != null)
+ return false;
+ if (paytype != null ? !paytype.equals(tShopPaytypePK.getPaytype()) : paytype != null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = shopaccno != null ? shopaccno.hashCode() : 0;
+ result = 31 * result + (paytype != null ? paytype.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java b/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
index 22b0d9e..a6b733e 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
@@ -11,6 +11,9 @@
public class DateUtil {
private static final Logger logger = Logger.getLogger(DateUtil.class);
+ public static final String DATE_FMT = "yyyyMMdd";
+ public static final String TIME_FMT = "HHmmss";
+ public static final String DATETIME_FMT = "yyyyMMddHHmmss";
/**
* Description: 返回一个当前时间 @return String 格式:yyyyMMddHHmmss @exception Modify
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java b/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
index 6411cac..7ef7051 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
@@ -107,4 +107,5 @@
public static final int BUSINESS_SHOP_EXISTS = 30001; //商户已经存在
+
}
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt b/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
index e3ab38e..d1f8c99 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
@@ -1,6 +1,7 @@
package com.supwisdom.dlpay.api.bean
import com.supwisdom.dlpay.exception.RequestParamCheckException
+import com.supwisdom.dlpay.framework.util.DateUtil
import com.supwisdom.dlpay.framework.util.MD5
import com.supwisdom.dlpay.framework.util.StringUtil
import com.supwisdom.dlpay.framework.util.TradeErrorCode
@@ -11,6 +12,7 @@
open fun checkSign(key: String): Boolean {
val sign = param_map["sign"]
+ val signType = param_map["sign_type"] ?: "MD5"
if (StringUtil.isEmpty(sign)) return false //未签名
//判断签名
@@ -23,6 +25,8 @@
}
}
+
+
// ============================ USER ============================ //
class OpenUserParam : APIRequestParam() {
var syscode: String = "" //必传
@@ -37,6 +41,7 @@
var address: String? = null
var zipcode: String? = null
var sign: String = "" //必传
+ var sign_type: String? = null
fun checkParam(): Boolean {
if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
@@ -49,7 +54,7 @@
if (!StringUtil.isEmpty(mobile) && !StringUtil.isMobile(mobile)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "手机号格式错误")
if (!StringUtil.isEmpty(email) && !StringUtil.isEmail(email)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "邮箱格式错误")
- param_map.plus(mapOf("syscode" to syscode, "uid" to uid, "name" to name, "sex" to sex, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "tel" to tel, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign))
+ param_map.plus(mapOf("syscode" to syscode, "uid" to uid, "name" to name, "sex" to sex, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "tel" to tel, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign, "sign_type" to sign_type))
return true
}
}
@@ -59,12 +64,13 @@
var userid: String? = null // 用户ID二选一 (两者都传取userid)
var uid: String? = null // 用户ID二选一
var sign: String = "" //必传
+ var sign_type: String? = null
fun checkParam(): Boolean {
if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
if (StringUtil.isEmpty(userid) && StringUtil.isEmpty(uid)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "用户唯一号不能为空")
- param_map.plus(mapOf("syscode" to syscode, "userid" to userid, "uid" to uid, "sign" to sign))
+ param_map.plus(mapOf("syscode" to syscode, "userid" to userid, "uid" to uid, "sign" to sign, "sign_type" to sign_type))
return true
}
}
@@ -83,6 +89,7 @@
var address: String? = null
var zipcode: String? = null
var sign: String = "" //必传
+ var sign_type: String? = null
fun checkParam(): Boolean {
if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
@@ -96,12 +103,13 @@
if (!StringUtil.isEmpty(email) && !StringUtil.isEmail(email)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "邮箱格式错误")
- param_map.plus(mapOf("syscode" to syscode, "userid" to userid, "uid" to uid, "name" to name, "sex" to sex, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "tel" to tel, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign))
+ param_map.plus(mapOf("syscode" to syscode, "userid" to userid, "uid" to uid, "name" to name, "sex" to sex, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "tel" to tel, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign, "sign_type" to sign_type))
return true
}
}
+
// ============================ SHOP ============================ //
class OpenShopParam : APIRequestParam() {
var syscode: String = "" //必传
@@ -117,6 +125,7 @@
var address: String? = null
var zipcode: String? = null
var sign: String = "" //必传
+ var sign_type: String? = null
fun checkParam(): Boolean {
if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
@@ -129,7 +138,7 @@
if (!StringUtil.isEmpty(mobile) && !StringUtil.isMobile(mobile)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "手机号格式错误")
if (!StringUtil.isEmpty(email) && !StringUtil.isEmail(email)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "邮箱格式错误")
- param_map.plus(mapOf("syscode" to syscode, "shopUniqueId" to shopUniqueId, "shoptype" to shoptype, "fshopid" to fshopid, "shopname" to shopname, "contactman" to contactman, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign))
+ param_map.plus(mapOf("syscode" to syscode, "shopUniqueId" to shopUniqueId, "shoptype" to shoptype, "fshopid" to fshopid, "shopname" to shopname, "contactman" to contactman, "idtype" to idtype, "idno" to idno, "mobile" to mobile, "email" to email, "address" to address, "zipcode" to zipcode, "sign" to sign, "sign_type" to sign_type))
return true
}
}
@@ -140,12 +149,46 @@
var shopaccno: String? = null //注册时返回的shopaccno
var shopUniqueId: String? = null //注册传的商户唯一号
var sign: String = "" //必传
+ var sign_type: String? = null
fun checkParam(): Boolean {
if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
if (StringUtil.isEmpty(shopUniqueId) && null == shopid && StringUtil.isEmpty(shopaccno)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "商户唯一标志不能为空")
- param_map.plus(mapOf("syscode" to syscode, "shopUniqueId" to shopUniqueId, "shopid" to shopid, "shopaccno" to shopaccno, "sign" to sign))
+ param_map.plus(mapOf("syscode" to syscode, "shopUniqueId" to shopUniqueId, "shopid" to shopid, "shopaccno" to shopaccno, "sign" to sign, "sign_type" to sign_type))
return true
}
-}
\ No newline at end of file
+}
+
+
+// ============================ CONSUME ============================ //
+class BankcardPayinitParam : APIRequestParam() {
+ var syscode: String = "" //必传
+ var cardNo: String = "" //必传
+ var amount: Int = 0 //必传
+ var shopaccno: String = "" //必传
+ var paytype: String ="" //必传
+ var billno: String ="" //必传
+ var transdate: String="" //必传
+ var transtime: String="" //必传
+ var sign: String = "" //必传
+ var sign_type: String? = null
+
+ fun checkParam(): Boolean {
+ if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
+ if (StringUtil.isEmpty(cardNo)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "卡唯一号不能为空")
+ if (amount <= 0) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "交易金额必须大于零")
+ if(StringUtil.isEmpty(shopaccno)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "请指定交易商户")
+ if(StringUtil.isEmpty(paytype)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "请指定支付方式")
+ if(StringUtil.isEmpty(billno)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "对接系统唯一订单号不能为空")
+ if(!DateUtil.checkDatetimeValid(transdate, DateUtil.DATE_FMT)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "交易日期错误[yyyyMMdd]")
+ if(!DateUtil.checkDatetimeValid(transtime,DateUtil.TIME_FMT)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "交易时间错误[HHmmss]")
+
+ param_map.plus(mapOf("syscode" to syscode, "cardNo" to cardNo, "amount" to amount, "shopaccno" to shopaccno,"paytype" to paytype,"billno" to billno,"transdate" to transdate,"transtime" to transtime, "sign" to sign, "sign_type" to sign_type))
+ return true
+ }
+}
+
+
+
+
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/controller/consume_api_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/api/controller/consume_api_controller.kt
index 66cdb7d..3717a2b 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/api/controller/consume_api_controller.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/api/controller/consume_api_controller.kt
@@ -3,35 +3,69 @@
import com.supwisdom.dlpay.api.AccountHolder
import com.supwisdom.dlpay.api.CallService
import com.supwisdom.dlpay.api.PersonTransBuilder
-import com.supwisdom.dlpay.api.service.AccountUtilServcie
-import com.supwisdom.dlpay.api.service.PaytypeService
-import com.supwisdom.dlpay.api.service.PersonBalancePayService
-import com.supwisdom.dlpay.api.service.PersonService
+import com.supwisdom.dlpay.api.bean.BankcardPayinitParam
+import com.supwisdom.dlpay.api.service.*
+import com.supwisdom.dlpay.exception.RequestParamCheckException
import com.supwisdom.dlpay.exception.TransactionException
import com.supwisdom.dlpay.framework.ResponseBodyBuilder
+import com.supwisdom.dlpay.framework.service.SystemUtilService
import com.supwisdom.dlpay.framework.util.*
import com.supwisdom.dlpay.util.ConstantUtil
import com.supwisdom.dlpay.util.PaytypeUtil
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
-import org.springframework.web.bind.annotation.GetMapping
-import org.springframework.web.bind.annotation.PostMapping
-import org.springframework.web.bind.annotation.RequestMapping
-import org.springframework.web.bind.annotation.RestController
+import org.springframework.web.bind.annotation.*
@RestController
@RequestMapping("/api/consume")
class ConsumeController {
@Autowired
lateinit var accountUtilServcie: AccountUtilServcie
-
@Autowired
lateinit var personBalancePayService: PersonBalancePayService
-
@Autowired
lateinit var paytypeService: PaytypeService
@Autowired
- lateinit var personService: PersonService
+ lateinit var userService: UserService
+ @Autowired
+ lateinit var systemUtilService: SystemUtilService
+ @Autowired
+ lateinit var consumePayService: ConsumePayService
+
+ @PostMapping("/bankcard/payinit")
+ fun bankcardPayinit(@RequestBody request: BankcardPayinitParam): ResponseEntity<Any> {
+ return try{
+ if (request.checkParam() && request.checkSign(systemUtilService.getSubsystemSignKey(request.syscode))) {
+ ResponseEntity.ok(ResponseBodyBuilder.create()
+ .fail(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误"))
+ }
+ if (!consumePayService.checkShopPaytype(request.shopaccno, request.paytype)) {
+ ResponseEntity.ok(ResponseBodyBuilder.create()
+ .fail(TradeErrorCode.INPUT_DATA_ERROR, "支付方式不支持"))
+ }
+
+
+
+
+
+
+ ResponseEntity.ok(ResponseBodyBuilder.create()
+ .data("refno","")
+ .success("交易初始化成功"))
+ }catch (ex: RequestParamCheckException) {
+ ResponseEntity.ok(ResponseBodyBuilder.create()
+ .requestException(ex, "请求参数错误"))
+ } catch (et: TransactionException) {
+ ResponseEntity.ok(ResponseBodyBuilder.create()
+ .transException(et, "业务处理错误"))
+ }
+
+ }
+
+
+
+
+// ============================================== //
@PostMapping("/account/pay")
fun accountPay(userid: String, amount: Int, manageFee: Int): ResponseEntity<Any> {
@@ -80,12 +114,14 @@
ResponseEntity.ok(ResponseBodyBuilder.create()
.fail(1, "支付方式未开启"))
}
- val person = personService.getPersonByThirdUniqueIdenty(stuempno)
+ val person = userService.findByThirdUniqueIdenty(stuempno,"")
val dtl = PersonTransBuilder.newBuilder(accountUtilServcie)
.setTransDatetime(transdate, transtime)
.selectPaytype(PaytypeUtil.YKTPAY, payinfo)
.setOuttradeno(outtradeno)
- .setOwner(person)
+ .also {
+ if (null != person) it.setOwner(person)
+ }
.tryLock(true)
.setTransinfo(TradeCode.TRANSCODE_YKTPAY, "一卡通支付")
.chooseTradetype(Tradetype.CONSUME)
@@ -127,7 +163,7 @@
fun yktPayFinish(refno: String, yktshopid: String, devphyid: String?): ResponseEntity<Any> {
return try {
val dtl = personBalancePayService.wip(refno)
- val person = personService.getPersonByUserid(dtl.userid)
+ val person = userService.findPersonByUserid(dtl.userid)
val code = CallService.callYktPay(paytypeService.getPaytypeConfigByPaytype(PaytypeUtil.YKTPAY),
dtl, DateUtil.getNow(), "", yktshopid, devphyid)
if (code.retcode == "0") {
@@ -168,12 +204,14 @@
ResponseEntity.ok(ResponseBodyBuilder.create()
.fail(1, "支付方式未开启"))
}
- val person = personService.getPersonByThirdUniqueIdenty(stuempno)
+ val person = userService.findByThirdUniqueIdenty(stuempno,"")
val dtl = PersonTransBuilder.newBuilder(accountUtilServcie)
.setTransDatetime(transdate, transtime)
.selectPaytype(PaytypeUtil.WECHAT, payinfo)
.setOuttradeno(outtradeno)
- .setOwner(person)
+ .also {
+ if (null != person) it.setOwner(person)
+ }
.tryLock(true)
.setTransinfo(TradeCode.TRANSCODE_WECHAT, "微信支付")
.chooseTradetype(Tradetype.CONSUME)
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/controller/notify_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/api/controller/notify_api_controller.kt
similarity index 100%
rename from src/main/kotlin/com/supwisdom/dlpay/api/controller/notify_controller.kt
rename to src/main/kotlin/com/supwisdom/dlpay/api/controller/notify_api_controller.kt
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/consume_pay_service.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/consume_pay_service.kt
new file mode 100644
index 0000000..5d85e0f
--- /dev/null
+++ b/src/main/kotlin/com/supwisdom/dlpay/api/service/consume_pay_service.kt
@@ -0,0 +1,12 @@
+package com.supwisdom.dlpay.api.service
+
+import org.springframework.transaction.annotation.Propagation
+import org.springframework.transaction.annotation.Transactional
+
+interface ConsumePayService{
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = arrayOf(Exception::class))
+ fun checkShopPaytype(shopaccno: String, paytype: String): Boolean
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = arrayOf(Exception::class))
+ fun getPaytypeConfig(paytype: String, shopaccno: String, ignoreStatus: Boolean? = false): Map<String, String?>
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/Consume_pay_service_impl.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/Consume_pay_service_impl.kt
new file mode 100644
index 0000000..cdb134b
--- /dev/null
+++ b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/Consume_pay_service_impl.kt
@@ -0,0 +1,76 @@
+package com.supwisdom.dlpay.api.service.impl
+
+import com.supwisdom.dlpay.api.dao.PaytypeConfigDao
+import com.supwisdom.dlpay.api.dao.PaytypeDao
+import com.supwisdom.dlpay.api.dao.ShopPaytypeConfigDao
+import com.supwisdom.dlpay.api.dao.ShopPaytypeDao
+import com.supwisdom.dlpay.api.service.ConsumePayService
+import com.supwisdom.dlpay.exception.TransactionProcessException
+import com.supwisdom.dlpay.framework.util.TradeErrorCode
+import com.supwisdom.dlpay.util.ConstantUtil
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Service
+
+@Service
+class ConsumePayServiceImpl: ConsumePayService{
+ @Autowired
+ lateinit var paytypeDao: PaytypeDao
+ @Autowired
+ lateinit var shopPaytypeDao: ShopPaytypeDao
+ @Autowired
+ lateinit var shopPaytypeConfigDao: ShopPaytypeConfigDao
+
+ override fun checkShopPaytype(shopaccno: String, paytype: String): Boolean{
+ paytypeDao.getByPaytype(paytype).let {
+ if (null == it) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[$paytype]")
+ } else {
+ if (ConstantUtil.ENABLE_YES != it.enable || ConstantUtil.ENABLE_YES != it.consumeEnable) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统未启用支付方式[$paytype]消费")
+ }
+ }
+ }
+ shopPaytypeDao.getById(paytype, shopaccno).let {
+ if (null == it) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]未启用支付方式[$paytype]")
+ } else {
+ if (ConstantUtil.ENABLE_YES != it.consumeEnable) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]未启用支付方式[$paytype]")
+ }
+ }
+ }
+ return true
+ }
+
+ override fun getPaytypeConfig(paytype: String, shopaccno: String, ignoreStatus: Boolean?): Map<String, String?> {
+ paytypeDao.getByPaytype(paytype).let {
+ if (null == it) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统不支持支付方式[$paytype]")
+ } else {
+ if (true != ignoreStatus && (ConstantUtil.ENABLE_YES != it.enable || ConstantUtil.ENABLE_YES != it.consumeEnable)) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "系统未启用支付方式[$paytype]消费")
+ }
+ }
+ }
+
+ shopPaytypeDao.getById(paytype, shopaccno).let {
+ if (null == it) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]未启用支付方式[$paytype]")
+ } else {
+ if (true != ignoreStatus && ConstantUtil.ENABLE_YES != it.consumeEnable) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]未启用支付方式[$paytype]")
+ }
+ }
+ }
+
+ shopPaytypeConfigDao.getShopPaytypeConfigs(paytype, shopaccno)?.let {
+ if (it.size < 1) {
+ throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]的支付方式[$paytype]未配置参数")
+ } else {
+ val result = mutableMapOf<String, String?>()
+ it.forEach { result.plus(mapOf(it.configid to it.configValue)) }
+ return result
+ }
+ } ?: throw TransactionProcessException(TradeErrorCode.INPUT_DATA_ERROR, "该商户[$shopaccno]的支付方式[$paytype]未配置参数")
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/person_service_impl.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/person_service_impl.kt
deleted file mode 100644
index 6d05a8d..0000000
--- a/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/person_service_impl.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.supwisdom.dlpay.api.service.impl
-
-import com.supwisdom.dlpay.api.dao.PersonDao
-import com.supwisdom.dlpay.api.domain.TPerson
-import com.supwisdom.dlpay.api.service.PersonService
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.stereotype.Service
-
-/**
- * Created by shuwei on 2019/4/12.
- */
-@Service
-class PersonServiceImpl : PersonService {
- @Autowired
- lateinit var personDao: PersonDao
-
- override fun getPersonByThirdUniqueIdenty(thirdUniqueIdenty: String): TPerson {
- return personDao.findByUserid(thirdUniqueIdenty)
- }
-
- override fun getPersonByUserid(userid: String): TPerson {
- return personDao.getOne(userid)
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/service/person_service.kt b/src/main/kotlin/com/supwisdom/dlpay/api/service/person_service.kt
deleted file mode 100644
index 1ea08ba..0000000
--- a/src/main/kotlin/com/supwisdom/dlpay/api/service/person_service.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.supwisdom.dlpay.api.service
-
-import com.supwisdom.dlpay.api.domain.TPerson
-import org.springframework.transaction.annotation.Propagation
-import org.springframework.transaction.annotation.Transactional
-
-/**
- * Created by shuwei on 2019/4/12.
- */
-interface PersonService {
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = arrayOf(Exception::class), readOnly = true)
- fun getPersonByThirdUniqueIdenty(thirdUniqueIdenty: String): TPerson
-
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = arrayOf(Exception::class), readOnly = true)
- fun getPersonByUserid(userid: String): TPerson
-
-}
\ No newline at end of file
diff --git a/src/test/kotlin/com/supwisdom/dlpay/controller/ShopControllerTest.kt b/src/test/kotlin/com/supwisdom/dlpay/controller/ShopControllerTest.kt
index a9b27ae..b4347fa 100644
--- a/src/test/kotlin/com/supwisdom/dlpay/controller/ShopControllerTest.kt
+++ b/src/test/kotlin/com/supwisdom/dlpay/controller/ShopControllerTest.kt
@@ -2,8 +2,9 @@
import com.google.gson.Gson
import com.supwisdom.dlpay.MvcBaseTest
+import com.supwisdom.dlpay.api.bean.OpenShopParam
+import com.supwisdom.dlpay.api.bean.QueryShopParam
import com.supwisdom.dlpay.framework.domain.TShop
-import com.supwisdom.dlpay.shop.bean.ShopParam
import org.junit.Assert
import org.junit.Test
import org.springframework.http.MediaType
@@ -27,8 +28,9 @@
@Test
fun open() {
- val shopParam = ShopParam()
- shopParam.uniqueId = ""//random req
+ val shopParam = OpenShopParam()
+ shopParam.syscode = "ykt"//random req
+ shopParam.shopUniqueId = "ykt_shop_20001"
shopParam.shopname = "测试名称"
val gson = Gson()
val ret = mvc.perform(post("/api/shop/open").content(gson.toJson(shopParam))
@@ -47,9 +49,9 @@
@Test
fun get() {
- val shopParam = ShopParam()
- shopParam.uniqueId = "testuniqueId"//测试用
- shopParam.shopname = "测试名称:testuniqueId"
+ val shopParam = QueryShopParam()
+ shopParam.syscode = "ykt"//random req
+ shopParam.shopUniqueId = "ykt_shop_20001"
val gson = Gson()
val ret = mvc.perform(post("/shop/open").content(gson.toJson(shopParam))
.contentType(MediaType.APPLICATION_JSON))