市民卡代扣逻辑
authorXia Kaixiang <kaixiang.xia@supwisdom.com>
Wed, 8 May 2019 10:43:19 +0000 (18:43 +0800)
committerXia Kaixiang <kaixiang.xia@supwisdom.com>
Wed, 8 May 2019 10:43:51 +0000 (18:43 +0800)
25 files changed:
src/main/java/com/supwisdom/dlpay/api/dao/PersonIdentityDao.java
src/main/java/com/supwisdom/dlpay/api/dao/UserdtlDao.java
src/main/java/com/supwisdom/dlpay/api/domain/TPersonIdentity.java
src/main/java/com/supwisdom/dlpay/api/domain/TPersonIdentityPK.java [deleted file]
src/main/java/com/supwisdom/dlpay/api/domain/TUserdtl.java
src/main/java/com/supwisdom/dlpay/framework/dao/ApiClientDao.java
src/main/java/com/supwisdom/dlpay/framework/dao/FeetypeConfigDao.java [new file with mode: 0644]
src/main/java/com/supwisdom/dlpay/framework/util/Subject.java
src/main/java/com/supwisdom/dlpay/framework/util/TradeCode.java
src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java
src/main/java/com/supwisdom/dlpay/framework/util/TradeErrorCode.java
src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java
src/main/kotlin/com/supwisdom/dlpay/api/ThirdPayCall.kt
src/main/kotlin/com/supwisdom/dlpay/api/bean/api_request_param.kt
src/main/kotlin/com/supwisdom/dlpay/api/comsume_builder.kt
src/main/kotlin/com/supwisdom/dlpay/api/controller/consume_api_controller.kt
src/main/kotlin/com/supwisdom/dlpay/api/controller/notify_api_controller.kt
src/main/kotlin/com/supwisdom/dlpay/api/controller/shop_api_controller.kt
src/main/kotlin/com/supwisdom/dlpay/api/controller/user_api_controller.kt
src/main/kotlin/com/supwisdom/dlpay/api/service/impl/pay_service_impl.kt
src/main/kotlin/com/supwisdom/dlpay/api/service/impl/user_service_impl.kt
src/main/kotlin/com/supwisdom/dlpay/api/service/pay_service.kt
src/main/kotlin/com/supwisdom/dlpay/api/service/user_service.kt
src/main/kotlin/com/supwisdom/dlpay/framework/service/framework_service.kt
src/main/kotlin/com/supwisdom/dlpay/framework/service/impl/framework_service_impl.kt

index 26fe874..6ee3e99 100644 (file)
@@ -1,14 +1,10 @@
 package com.supwisdom.dlpay.api.dao;
 
 import com.supwisdom.dlpay.api.domain.TPersonIdentity;
-import com.supwisdom.dlpay.api.domain.TPersonIdentityPK;
 import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 @Repository
-public interface PersonIdentityDao extends JpaRepository<TPersonIdentity, TPersonIdentityPK> {
-  @Query(value = "from TPersonIdentity t where t.thirdUserid=:thirdUserid and t.thirdSyscode=:thirdSyscode ")
-  TPersonIdentity getPersonIdentityById(@Param("thirdUserid") String thirdUserid, @Param("thirdSyscode") String thirdSyscode);
+public interface PersonIdentityDao extends JpaRepository<TPersonIdentity, String> {
+  TPersonIdentity getByThirdUid(String thirdUid);
 }
index 4eb1196..72181db 100644 (file)
@@ -22,4 +22,9 @@ public interface UserdtlDao extends JpaRepository<TUserdtl, String> {
   @QueryHints({@QueryHint(name = "javax.persistence.lock.timeout", value ="0")})
   @Query("select dtl from TUserdtl  dtl where dtl.refno = ?1")
   TUserdtl findByRefnoForUpdateNowait(String refno);
+
+  @Lock(LockModeType.PESSIMISTIC_WRITE)
+  @QueryHints({@QueryHint(name = "javax.persistence.lock.timeout", value ="0")})
+  @Query("select dtl from TUserdtl dtl where dtl.outtradeno = ?1 and dtl.shopaccno=?2 ")
+  TUserdtl findByBillnoForUpdateNowait(String billno,String shopaccno);
 }
index 73a8126..1125f8e 100644 (file)
@@ -4,43 +4,45 @@ import javax.persistence.*;
 
 @Entity
 @Table(name = "TB_PERSON_IDENTITY")
-@IdClass(TPersonIdentityPK.class)
 public class TPersonIdentity {
   @Id
-  @Column(name = "THIRD_USERID", nullable = false, length = 60)
-  private String thirdUserid;
-
-  @Id
-  @Column(name = "THIRD_SYSCODE", nullable = false, length = 20)
-  private String thirdSyscode;
+  @Column(name = "THIRD_UID", nullable = false, length = 60)
+  private String thirdUid;
 
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "USERID")
   private TPerson person; //绑定的系统用户
 
-  public TPersonIdentity() {
-  }
+  @Column(name = "STATUS", nullable = false, length = 20)
+  private String status;
 
-  public TPersonIdentity(String thirdUserid, String thirdSyscode, TPerson person) {
-    this.thirdUserid = thirdUserid;
-    this.thirdSyscode = thirdSyscode;
-    this.person = person;
-  }
+  @Column(name = "LOSSFLAG",nullable = false, precision = 1)
+  private Integer lossflag=0;
+
+  @Column(name = "LOCKFLAG", nullable = false, precision = 1)
+  private Integer lockflag=0;
 
-  public String getThirdUserid() {
-    return thirdUserid;
+  @Column(name = "CREATETIME", length = 14)
+  private String createtime;
+
+  public TPersonIdentity() {
   }
 
-  public void setThirdUserid(String thirdUserid) {
-    this.thirdUserid = thirdUserid;
+  public TPersonIdentity(String thirdUid, TPerson person, String status, Integer lossflag, Integer lockflag, String createtime) {
+    this.thirdUid = thirdUid;
+    this.person = person;
+    this.status = status;
+    this.lossflag = lossflag;
+    this.lockflag = lockflag;
+    this.createtime = createtime;
   }
 
-  public String getThirdSyscode() {
-    return thirdSyscode;
+  public String getThirdUid() {
+    return thirdUid;
   }
 
-  public void setThirdSyscode(String thirdSyscode) {
-    this.thirdSyscode = thirdSyscode;
+  public void setThirdUid(String thirdUid) {
+    this.thirdUid = thirdUid;
   }
 
   public TPerson getPerson() {
@@ -50,4 +52,37 @@ public class TPersonIdentity {
   public void setPerson(TPerson person) {
     this.person = person;
   }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public Integer getLossflag() {
+    return lossflag;
+  }
+
+  public void setLossflag(Integer lossflag) {
+    this.lossflag = lossflag;
+  }
+
+  public Integer getLockflag() {
+    return lockflag;
+  }
+
+  public void setLockflag(Integer lockflag) {
+    this.lockflag = lockflag;
+  }
+
+  public String getCreatetime() {
+    return createtime;
+  }
+
+  public void setCreatetime(String createtime) {
+    this.createtime = createtime;
+  }
+
 }
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TPersonIdentityPK.java b/src/main/java/com/supwisdom/dlpay/api/domain/TPersonIdentityPK.java
deleted file mode 100644 (file)
index 8ce1bfb..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-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 TPersonIdentityPK implements Serializable {
-  @Id
-  @Column(name="THIRD_USERID", nullable = false, length = 60)
-  private String thirdUserid;
-
-  @Id
-  @Column(name="THIRD_SYSCODE", nullable = false, length = 20)
-  private String thirdSyscode;
-
-  public TPersonIdentityPK() {
-  }
-
-  public TPersonIdentityPK(String thirdUserid, String thirdSyscode) {
-    this.thirdUserid = thirdUserid;
-    this.thirdSyscode = thirdSyscode;
-  }
-
-  public String getThirdUserid() {
-    return thirdUserid;
-  }
-
-  public void setThirdUserid(String thirdUserid) {
-    this.thirdUserid = thirdUserid;
-  }
-
-  public String getThirdSyscode() {
-    return thirdSyscode;
-  }
-
-  public void setThirdSyscode(String thirdSyscode) {
-    this.thirdSyscode = thirdSyscode;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    TPersonIdentityPK tPersonIdentityPK = (TPersonIdentityPK) o;
-    if (thirdUserid != null ? !thirdUserid.equals(tPersonIdentityPK.getThirdUserid()) : thirdUserid != null)
-      return false;
-    if (thirdSyscode != null ? !thirdSyscode.equals(tPersonIdentityPK.getThirdSyscode()) : thirdSyscode != null)
-      return false;
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int result = thirdUserid != null ? thirdUserid.hashCode() : 0;
-    result = 31 * result + (thirdSyscode != null ? thirdSyscode.hashCode() : 0);
-    return result;
-  }
-}
index 806c430..fc89e32 100644 (file)
@@ -52,7 +52,8 @@ public class TUserdtl {
   @Column(name = "OUTTRADENO", length = 60)
   private String outtradeno; //第三方流水号
 
-
+  @Column(name = "SHOPACCNO", length = 20)
+  private String shopaccno;
 
   @Column(name = "OPERID", precision = 9)
   private Integer operid; //操作员ID
@@ -187,6 +188,14 @@ public class TUserdtl {
     this.outtradeno = outtradeno;
   }
 
+  public String getShopaccno() {
+    return shopaccno;
+  }
+
+  public void setShopaccno(String shopaccno) {
+    this.shopaccno = shopaccno;
+  }
+
   public Integer getOperid() {
     return operid;
   }
index 4390368..e5ca834 100644 (file)
@@ -4,4 +4,5 @@ import com.supwisdom.dlpay.framework.domain.TApiClient;
 import org.springframework.data.repository.CrudRepository;
 
 public interface ApiClientDao extends CrudRepository<TApiClient, String> {
+  TApiClient findByAppid(String appid);
 }
diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/FeetypeConfigDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/FeetypeConfigDao.java
new file mode 100644 (file)
index 0000000..b626087
--- /dev/null
@@ -0,0 +1,13 @@
+package com.supwisdom.dlpay.framework.dao;
+
+import com.supwisdom.dlpay.framework.domain.TFeetypeConfig;
+import com.supwisdom.dlpay.framework.domain.TFeetypeConfigPK;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface FeetypeConfigDao extends JpaRepository<TFeetypeConfig, TFeetypeConfigPK> {
+  @Query("select a from TFeetypeConfig a where a.feetype=?1 and a.paytype=?2 ")
+  TFeetypeConfig getById(String feetype, String paytype);
+}
index 8afbaaa..4a46b28 100644 (file)
@@ -68,6 +68,11 @@ public class Subject {
    */
   public static final String SUBJNO_PAY_YKT = "112233";
 
+  /**
+   * 应收账款 - 市民卡支付款
+   */
+  public static final String SUBJNO_PAY_CITIZEN_CARD = "112234";
+
 
   //======================= 负债类 =====================//
 
index c4dde6e..5c51c26 100644 (file)
@@ -4,7 +4,7 @@ package com.supwisdom.dlpay.framework.util;
  * 交易码、交易类型
  * */
 public class TradeCode {
-  public static final int TRANSCODE_PAY = 6630;
+  public static final int TRANSCODE_PAY = 3000;
   public static final int TRANSCODE_YKTPAY=1000;
   public static final int TRANSCODE_WECHAT=1001;
 
index 6b45836..2b392b3 100644 (file)
@@ -44,6 +44,9 @@ public class TradeDict {
    */
   public static final String PAYTYPE_CASH = "cash";
   public static final String PAYTYPE_BALANCE = "balance";
+  public static final String PAYTYPE_ALIPAY = "alipay"; //市民卡
+  public static final String PAYTYPE_WECHAT = "wechat"; //市民卡
+  public static final String PAYTYPE_CITIZEN_CARD = "citizenCard"; //市民卡
 
 
   /**
index 7ef7051..a8139c9 100644 (file)
@@ -84,6 +84,20 @@ public class TradeErrorCode {
    * */
   public static final int LOCK_READ_TIMEOUT = 10015;
 
+  /**
+   *  卡已挂失
+   * */
+  public static final int ACCOUNT_IS_LOSS = 10016;
+
+  /**
+   *  卡已锁定
+   * */
+  public static final int ACCOUNT_IS_LOCKED = 10017;
+
+  /**
+   * 费用类别未定义
+   * */
+  public static final int FEETYPE_NOT_EXISTS = 10018;
 
   /**
    * 请求参数错误
@@ -107,5 +121,8 @@ public class TradeErrorCode {
 
   public static final int BUSINESS_SHOP_EXISTS = 30001; //商户已经存在
 
+  public static final int BUSINESS_APPID_NOTFOUND = 30002; //APPID没找到
+
+  public static final int BUSINESS_PAYTYPE_NOSUPPORT = 30003; //支付方式不支持
 
 }
index 13af83c..1bf5ac2 100644 (file)
@@ -21,4 +21,9 @@ public class ConstantUtil {
 
     public static final int SHOPTYPE_GROUP = 0; //商户组
     public static final int SHOPTYPE_LEAF = 1;  //末级商户,独立核算商户
+
+    public static final String FEETYPE_DEFAULT = "none";
+    public static final String FEETYPE_MEALER = "mealer";
+    public static final String FEETYPE_DISCOUNT = "discount";
+    public static final String[] FEETYPE_DICTS = {"none", "mealer", "discount"}; //联动
 }
index 2b3b6ee..d02ba57 100644 (file)
@@ -11,9 +11,15 @@ import com.supwisdom.dlpay.api.domain.TUserdtl
 import com.supwisdom.dlpay.framework.util.*
 import com.supwisdom.dlpay.util.Code
 
-/**
- * Created by shuwei on 2019/4/11.
- */
+class CallBackResp {
+    var retcode: String = "99"
+    var retmsg: String? = null
+    val data = mutableMapOf<String, String>()
+    fun add(key: String, value: String) {
+        this.data.plus(mapOf(key to value))
+    }
+}
+
 class CallService {
 
     companion object {
@@ -227,5 +233,11 @@ class CallService {
                 }
             }
         }
+
+        fun CallCitizenCardPay(config: Map<String, String?>, paydtl: TUserdtl): CallBackResp {
+            val resp = CallBackResp()
+            // TODO: 代扣逻辑
+            return resp
+        }
     }
 }
\ No newline at end of file
index d1f8c99..9087149 100644 (file)
@@ -8,7 +8,7 @@ import com.supwisdom.dlpay.framework.util.TradeErrorCode
 import com.supwisdom.dlpay.util.ConstantUtil
 
 open class APIRequestParam {
-    open val param_map = mutableMapOf<String, String>()
+    open val param_map = mutableMapOf<String, String?>()
 
     open fun checkSign(key: String): Boolean {
         val sign = param_map["sign"]
@@ -26,11 +26,9 @@ open class APIRequestParam {
 }
 
 
-
 // ============================ USER ============================ //
 class OpenUserParam : APIRequestParam() {
-    var syscode: String = "" //必传
-    var uid: String = ""    //必传
+    var uid: String = ""    //第三方用户ID,必传
     var name: String = ""   //必传
     var sex: String? = null
     var idtype: String = "" //必传
@@ -44,7 +42,6 @@ class OpenUserParam : APIRequestParam() {
     var sign_type: String? = null
 
     fun checkParam(): Boolean {
-        if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
         if (StringUtil.isEmpty(uid)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "用户唯一号不能为空")
         if (StringUtil.isEmpty(name)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "姓名不能为空")
         if (!StringUtil.isEmpty(sex) && ConstantUtil.SEX_MALE != sex && ConstantUtil.SEX_FEMALE != sex) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "性别非法[male|female]")
@@ -54,29 +51,26 @@ class OpenUserParam : APIRequestParam() {
         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, "sign_type" to sign_type))
+        param_map.plus(mapOf("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
     }
 }
 
 class QueryUserParam : APIRequestParam() {
-    var syscode: String = "" //必传
     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, "sign_type" to sign_type))
+        param_map.plus(mapOf("userid" to userid, "uid" to uid, "sign" to sign, "sign_type" to sign_type))
         return true
     }
 }
 
 class ModifyUserParam : APIRequestParam() {
-    var syscode: String = "" //必传
     var userid: String? = null  // 用户ID二选一 (两者都传取userid)
     var uid: String? = null    // 用户ID二选一
     var name: String? = null
@@ -92,7 +86,6 @@ class ModifyUserParam : APIRequestParam() {
     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, "用户唯一号不能为空")
         if (!StringUtil.isEmpty(sex) && ConstantUtil.SEX_MALE != sex && ConstantUtil.SEX_FEMALE != sex) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "性别非法[male|female]")
         if (!StringUtil.isEmpty(idtype) && !ConstantUtil.IDTYPE_DICTS.contains(idtype)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "证件类型非法")
@@ -103,16 +96,14 @@ class ModifyUserParam : APIRequestParam() {
         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, "sign_type" to sign_type))
+        param_map.plus(mapOf("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 = "" //必传
     var shopUniqueId: String = "" //必传
     var shoptype: Int = 1
     var fshopid: Int? = null
@@ -128,7 +119,6 @@ class OpenShopParam : APIRequestParam() {
     var sign_type: String? = null
 
     fun checkParam(): Boolean {
-        if (StringUtil.isEmpty(syscode)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "子系统注册代码不能为空")
         if (StringUtil.isEmpty(shopUniqueId)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "商户唯一号不能为空")
         if (ConstantUtil.SHOPTYPE_GROUP != shoptype && ConstantUtil.SHOPTYPE_LEAF != shoptype) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "请指定商户类型")
         if (StringUtil.isEmpty(shopname)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "商户名称不能为空")
@@ -138,13 +128,12 @@ class OpenShopParam : APIRequestParam() {
         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, "sign_type" to sign_type))
+        param_map.plus(mapOf("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
     }
 }
 
 class QueryShopParam : APIRequestParam() {
-    var syscode: String = "" //必传
     var shopid: Int? = null  //注册时返回的shopid
     var shopaccno: String? = null  //注册时返回的shopaccno
     var shopUniqueId: String? = null //注册传的商户唯一号
@@ -152,39 +141,69 @@ class QueryShopParam : APIRequestParam() {
     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, "sign_type" to sign_type))
+        param_map.plus(mapOf("shopUniqueId" to shopUniqueId, "shopid" to shopid, "shopaccno" to shopaccno, "sign" to sign, "sign_type" to sign_type))
         return true
     }
 }
 
 
 // ============================ CONSUME ============================ //
-class BankcardPayinitParam :  APIRequestParam() {
-    var syscode: String = "" //必传
+class ConsumeFeetype {
+    var feetype: String = ""
+    var amount: Int = 0
+}
+
+class QueryDtlResultParam : APIRequestParam() {
+    var refno:String?=null //二选一
+    var billno:String?=null //二选一 (billno+shopaccno) 传billno时,shopaccno必传
+    var shopaccno: String?=null
+    var sign: String = "" //必传
+    var sign_type: String? = null
+
+    fun checkParam(): Boolean {
+        if (StringUtil.isEmpty(refno) && (StringUtil.isEmpty(billno) || StringUtil.isEmpty(shopaccno))) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "流水唯一号不能为空")
+
+        param_map.plus(mapOf("refno" to refno, "billno" to billno, "shopaccno" to shopaccno,  "sign" to sign, "sign_type" to sign_type))
+        return true
+    }
+}
+
+class CitizenCardPayinitParam : APIRequestParam() {
     var cardNo: String = "" //必传
-    var amount: Int = 0 //必传
     var shopaccno: String = "" //必传
-    var paytype: String ="" //必传
-    var billno: String ="" //必传
-    var transdate: String="" //必传
-    var transtime: String="" //必传
+    var amount: Int = 0 //必传
+    var feelist: List<ConsumeFeetype>? = null// 的json字符串
+    var billno: String = "" //必传
+    var transdate: String = "" //必传
+    var transtime: String = "" //必传
+    var extend_data: 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(cardNo)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "卡唯一号不能为空")
+        if (StringUtil.isEmpty(shopaccno)) 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]")
+        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("cardNo" to cardNo, "amount" to amount, "feelist" to feelist, "shopaccno" to shopaccno, "billno" to billno, "transdate" to transdate, "transtime" to transtime, "sign" to sign, "sign_type" to sign_type))
+        return true
+    }
+}
+
+class CitizenCardPayfinishParam : APIRequestParam() {
+    var refno:String=""
+    var sign: String = "" //必传
+    var sign_type: String? = null
+
+    fun checkParam(): Boolean {
+        if (StringUtil.isEmpty(refno)) throw RequestParamCheckException(TradeErrorCode.REQUEST_PARAM_ERROR, "交易参考号不能为空")
 
-        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))
+        param_map.plus(mapOf("refno" to refno, "sign" to sign, "sign_type" to sign_type))
         return true
     }
 }
index 4ba03d4..94e5a08 100644 (file)
@@ -6,9 +6,9 @@ import com.supwisdom.dlpay.api.domain.TUserdtl
 import com.supwisdom.dlpay.api.service.AccountUtilServcie
 import com.supwisdom.dlpay.api.service.PersonBalancePayService
 import com.supwisdom.dlpay.exception.TransactionCheckException
+import com.supwisdom.dlpay.framework.domain.TFeetypeConfig
 import com.supwisdom.dlpay.framework.domain.TShopacc
 import com.supwisdom.dlpay.framework.domain.TSubject
-import com.supwisdom.dlpay.framework.domain.TTranstype
 import com.supwisdom.dlpay.framework.util.*
 
 class AccountHolder<T> private constructor(val accountId: String, val idType: Int) {
@@ -16,7 +16,7 @@ class AccountHolder<T> private constructor(val accountId: String, val idType: In
         const val IDTYPE_PERSON = 1
         const val IDTYPE_SHOP = 2
         const val IDTYPE_SUBJECT = 3
-        const val IDTYPE_TRANSTYPE = 4
+        const val IDTYPE_FEETYPE = 4
 
         fun person(userid: String): AccountHolder<TAccount> {
             return AccountHolder(userid, IDTYPE_PERSON)
@@ -30,8 +30,8 @@ class AccountHolder<T> private constructor(val accountId: String, val idType: In
             return AccountHolder(subjNo, IDTYPE_SUBJECT)
         }
 
-        fun transType(transType: Int): AccountHolder<TTranstype> {
-            return AccountHolder("$transType", IDTYPE_TRANSTYPE)
+        fun feetype(feetype: String, paytype: String): AccountHolder<TFeetypeConfig> {
+            return AccountHolder("$feetype@$paytype", IDTYPE_FEETYPE)
         }
     }
 
@@ -52,7 +52,7 @@ class AccountHolder<T> private constructor(val accountId: String, val idType: In
             IDTYPE_PERSON -> builder.accountUtil.readAccountForUpdateNowait(accountId)
             IDTYPE_SHOP -> builder.accountUtil.readShopAcc(accountId.toInt())
             IDTYPE_SUBJECT -> builder.accountUtil.readSubject(accountId)
-            IDTYPE_TRANSTYPE -> builder.accountUtil.readTranstype(accountId.toInt())
+            IDTYPE_FEETYPE -> builder.accountUtil.readFeetype(accountId.split("@")[0], accountId.split("@")[1])
             else -> throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "账户类型未知type<$idType>")
         } as T
     }
@@ -63,7 +63,7 @@ class AccountHolder<T> private constructor(val accountId: String, val idType: In
             IDTYPE_PERSON -> builder.accountUtil.readAccountForUpdateNowait(accountId)
             IDTYPE_SHOP -> builder.accountUtil.readShopAcc(accountId.toInt())
             IDTYPE_SUBJECT -> builder.accountUtil.readSubject(accountId)
-            IDTYPE_TRANSTYPE -> builder.accountUtil.readTranstype(accountId.toInt())
+            IDTYPE_FEETYPE -> builder.accountUtil.readFeetype(accountId.split("@")[0], accountId.split("@")[1])
             else -> throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "账户类型未知type<$idType>")
         } as T
     }
@@ -83,6 +83,9 @@ class PersonTransBuilder private constructor(accUitl: AccountUtilServcie) {
     // 以下为输入参数,调用接口时指定的参数值
     lateinit var person: TPerson
     lateinit var tradetype: Tradetype
+    lateinit var refno: String
+    lateinit var status: String
+    val resultMap = mutableMapOf<String, String>() //存调第三方结果数据
 
     var transcode = 0
 
@@ -158,8 +161,18 @@ class PersonTransBuilder private constructor(accUitl: AccountUtilServcie) {
         return this
     }
 
-    fun setTradeno(outtradeno: String): PersonTransBuilder {
-        this.outtradeno = outtradeno
+    fun setRefno(refno: String): PersonTransBuilder {
+        this.refno = refno
+        return this
+    }
+
+    fun addResult(key: String, value: String): PersonTransBuilder {
+        this.resultMap.plus(mapOf(key to value))
+        return this
+    }
+
+    fun addResult(param: Map<String, String>): PersonTransBuilder {
+        this.resultMap.plus(param)
         return this
     }
 
@@ -276,10 +289,10 @@ class PersonTransBuilder private constructor(accUitl: AccountUtilServcie) {
         return this
     }
 
-    fun addDetail(accountHolder: AccountHolder<TTranstype>,
+    fun addDetail(accountHolder: AccountHolder<TFeetypeConfig>,
                   amount: Double): PersonTransBuilder {
         accountHolder.builder = this
-        val transtype = accountHolder.get<TTranstype>()
+        val transtype = accountHolder.get<TFeetypeConfig>()
 
         var debitAccNo = ""
         var debitSubjNo = ""
@@ -301,11 +314,11 @@ class PersonTransBuilder private constructor(accUitl: AccountUtilServcie) {
 
         if (debitAccNo.isEmpty()) {
             throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR,
-                    "交易配置<${transtype.transtype}> 借方账号配置错误")
+                    "交易配置<${transtype.feetype}@${transtype.paytype}> 借方账号配置错误")
         }
         if (creditAccNo.isEmpty()) {
             throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR,
-                    "交易配置<${transtype.transtype}> 贷方账号配置错误")
+                    "交易配置<${transtype.feetype}@${transtype.paytype}> 贷方账号配置错误")
         }
         this.details.add(TransDetail(debitAccNo, debitSubjNo, creditAccNo, creditSubjNo,
                 amount, transtype.summary, this.details.size + 1))
@@ -313,32 +326,37 @@ class PersonTransBuilder private constructor(accUitl: AccountUtilServcie) {
     }
 
     /**
-     * 单步交易,一次完成交易记账过程
-     * @param service
-     * @param isFinished - true : 完成交易过程,扣除账户余额; false - 完成检查
+     * 一步交易完成
      */
-    fun done(service: PersonBalancePayService, isFinished: Boolean): TUserdtl {
+    fun done(service: PersonBalancePayService): TUserdtl {
         prepareData()
         preCheckAccount()
-        return when (isFinished) {
-            true -> service.process(this)
-            false -> service.init(this)
-        }
+        return service.process(this)
     }
 
-    /**
-     * 两步交易,在 paydtl 基础完成确认过程
-     * @param paydtl
-     * @param status - 完成交易状态,见 TradeDict.DTL_STATUS_FAIL
-     */
-    fun done(paydtl: TUserdtl, status: String, service: PersonBalancePayService): TUserdtl {
-        return service.finish(paydtl, status, null)
+    fun init(service: PersonBalancePayService) : TUserdtl{
+        prepareData()
+        preCheckAccount()
+        return service.init(this)
     }
 
-    fun done(refno: String, status: String, service: PersonBalancePayService): TUserdtl {
-        return service.finish(refno, status, null)
+    fun wip(service: PersonBalancePayService): TUserdtl {
+        if (null == this.refno)
+            throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "交易参考号<refno>未指定")
+        return service.wip(this)
     }
-    fun done(refno: String, status: String, businessData: Map<String, String>?,service: PersonBalancePayService): TUserdtl {
-        return service.finish(refno, status, businessData)
+
+    fun finish(service: PersonBalancePayService, status: String): TUserdtl {
+        if (null == this.refno)
+            throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "交易参考号<refno>未指定")
+        this.status = status
+        return service.finish(this)
+    }
+
+    fun success(service: PersonBalancePayService): TUserdtl{
+        if (null == this.refno)
+            throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "交易参考号<refno>未指定")
+        this.status = TradeDict.DTL_STATUS_SUCCESS
+        return service.finish(this)
     }
 }
\ No newline at end of file
index 3717a2b..debf0e5 100644 (file)
@@ -3,11 +3,14 @@ package com.supwisdom.dlpay.api.controller
 import com.supwisdom.dlpay.api.AccountHolder
 import com.supwisdom.dlpay.api.CallService
 import com.supwisdom.dlpay.api.PersonTransBuilder
-import com.supwisdom.dlpay.api.bean.BankcardPayinitParam
+import com.supwisdom.dlpay.api.bean.CitizenCardPayfinishParam
+import com.supwisdom.dlpay.api.bean.CitizenCardPayinitParam
+import com.supwisdom.dlpay.api.bean.QueryDtlResultParam
 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.CommonService
 import com.supwisdom.dlpay.framework.service.SystemUtilService
 import com.supwisdom.dlpay.framework.util.*
 import com.supwisdom.dlpay.util.ConstantUtil
@@ -15,6 +18,8 @@ import com.supwisdom.dlpay.util.PaytypeUtil
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.http.ResponseEntity
 import org.springframework.web.bind.annotation.*
+import javax.servlet.http.HttpServletRequest
+import javax.servlet.http.HttpServletResponse
 
 @RestController
 @RequestMapping("/api/consume")
@@ -31,228 +36,352 @@ class ConsumeController {
     lateinit var systemUtilService: SystemUtilService
     @Autowired
     lateinit var consumePayService: ConsumePayService
+    @Autowired
+    lateinit var commonService: CommonService
 
-    @PostMapping("/bankcard/payinit")
-    fun bankcardPayinit(@RequestBody request: BankcardPayinitParam): ResponseEntity<Any> {
-        return try{
-            if (request.checkParam() && request.checkSign(systemUtilService.getSubsystemSignKey(request.syscode))) {
+    /**
+     * 流水结果查询统一接口
+     * */
+    fun queryDtlResult(@RequestBody param: QueryDtlResultParam, request: HttpServletRequest, response: HttpServletResponse): ResponseEntity<Any> {
+        return try {
+            if (param.checkParam() && param.checkSign(commonService.getAppidSecretByRequest(request))) {
                 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, "支付方式不支持"))
-            }
-
-
-
-
-
 
+            val dtl = if (StringUtil.isEmpty(param.refno)) {
+                personBalancePayService.getUserdtlForUpdateNowait(param.refno!!)
+            } else {
+                personBalancePayService.getUserdtlByBillnoForUpdateNowait(param.billno!!, param.shopaccno!!)
+            }
+            val person = dtl.userid?.let { userService.findPersonByUserid(dtl.userid) }
             ResponseEntity.ok(ResponseBodyBuilder.create()
-                    .data("refno","")
-                    .success("交易初始化成功"))
-        }catch (ex: RequestParamCheckException) {
+                    .data("refno", dtl.refno)
+                    .data("amount", dtl.amount)
+                    .data("paytype", dtl.paytype)
+                    .data("payinfo", dtl.payinfo)
+                    .also {
+                        if (null != person) {
+                            it.data("name", person.name)
+                        }
+                    }
+                    .success("查询成功"))
+
+        } catch (ex: RequestParamCheckException) {
             ResponseEntity.ok(ResponseBodyBuilder.create()
                     .requestException(ex, "请求参数错误"))
         } catch (et: TransactionException) {
             ResponseEntity.ok(ResponseBodyBuilder.create()
-                    .transException(et, "业务处理错误"))
+                    .transException(et, "查询错误"))
         }
 
     }
 
-
-
-
-// ============================================== //
-
-    @PostMapping("/account/pay")
-    fun accountPay(userid: String, amount: Int, manageFee: Int): ResponseEntity<Any> {
-        val dtl = PersonTransBuilder.newBuilder(accountUtilServcie)
-                .setTransDatetime("20190411", "112311")
-                .enableOverdraft(false)
-                .addDetail(AccountHolder.person(userid),
-                        AccountHolder.shop("12323"),
-                        amount / 100.0, "")
-                .addDetail(AccountHolder.person(userid), AccountHolder.transType(301),
-                        manageFee / 100.0, "")
-                .done(personBalancePayService, true)
-        return ResponseEntity.ok(dtl)
-    }
-
-    @GetMapping("/account/payinit")
-    fun accountPayInit(userid: String, amount: Int, manageFee: Int): ResponseEntity<Any> {
-        val dtl = PersonTransBuilder.newBuilder(accountUtilServcie)
-                .setTransDatetime("20190411", "112311")
-                .enableOverdraft(false)
-                .addDetail(AccountHolder.person(userid),
-                        AccountHolder.shop("12323"),
-                        amount / 100.0, "")
-                .addDetail(AccountHolder.person(userid), AccountHolder.transType(301),
-                        manageFee / 100.0, "")
-                .done(personBalancePayService, false)
-
-        return ResponseEntity.ok(dtl)
-    }
-
-    @GetMapping("/account/payfinish")
-    fun accountPayFinish(refno: String): ResponseEntity<Any> {
-        val dtl = PersonTransBuilder.newBuilder(accountUtilServcie)
-                .done(refno, TradeDict.DTL_STATUS_SUCCESS, personBalancePayService)
-        return ResponseEntity.ok(dtl)
-    }
-
-    @PostMapping("/ykt/payinit")
-    fun yktPayInit(userid: String, amount: Int, manageFee: Int,
-                   stuempno: String, shopid: String, transdate: String, transtime: String,
-                   outtradeno: String, payinfo: String, feetype: String): ResponseEntity<Any> {
-        //一卡通支付款 112240
+    /**
+     * 市民卡交易初始化
+     * */
+    @PostMapping("/citizencard/payinit")
+    fun citizencardPayinit(@RequestBody param: CitizenCardPayinitParam, request: HttpServletRequest, response: HttpServletResponse): ResponseEntity<Any> {
         return try {
-            val paytype = paytypeService.getByPaytype(PaytypeUtil.YKTPAY)
-            if (paytype == null || ConstantUtil.ENABLE_YES != paytype.enable) {
+            if (param.checkParam() && param.checkSign(commonService.getAppidSecretByRequest(request))) {
Content-type: text/html Supwisdom Source - epayment/food_payapi.git/commitdiff


500 - Internal Server Error

Unknown encoding 'gb18030' at /usr/local/share/gitweb/gitweb.cgi line 1539