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);
}
@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);
}
@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() {
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;
+ }
+
}
+++ /dev/null
-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;
- }
-}
@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
this.outtradeno = outtradeno;
}
+ public String getShopaccno() {
+ return shopaccno;
+ }
+
+ public void setShopaccno(String shopaccno) {
+ this.shopaccno = shopaccno;
+ }
+
public Integer getOperid() {
return operid;
}
import org.springframework.data.repository.CrudRepository;
public interface ApiClientDao extends CrudRepository<TApiClient, String> {
+ TApiClient findByAppid(String appid);
}
--- /dev/null
+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);
+}
*/
public static final String SUBJNO_PAY_YKT = "112233";
+ /**
+ * 应收账款 - 市民卡支付款
+ */
+ public static final String SUBJNO_PAY_CITIZEN_CARD = "112234";
+
//======================= 负债类 =====================//
* 交易码、交易类型
* */
public class TradeCode {
- public static final int TRANSCODE_PAY = 663 0;
+ public static final int TRANSCODE_PAY = 300 0;
public static final int TRANSCODE_YKTPAY=1000;
public static final int TRANSCODE_WECHAT=1001;
*/
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"; //市民卡
/**
* */
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;
/**
* 请求参数错误
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; //支付方式不支持
}
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"}; //联动
}
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 {
}
}
}
+
+ fun CallCitizenCardPay(config: Map<String, String?>, paydtl: TUserdtl): CallBackResp {
+ val resp = CallBackResp()
+ // TODO: 代扣逻辑
+ return resp
+ }
}
}
\ No newline at end of file
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"]
}
-
// ============================ USER ============================ //
class OpenUserParam : APIRequestParam() {
- var syscode: String = "" //必传
- var uid: String = "" //必传
+ var uid: String = "" //第三方用户ID,必传
var name: String = "" //必传
var sex: String? = null
var idtype: String = "" //必传
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]")
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
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, "证件类型非法")
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
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, "商户名称不能为空")
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, "s hopUniqueId" 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 //注册传的商户唯一号
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, "s hopUniqueId" 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
}
}
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) {
const val IDTYPE_PERSON = 1
const val IDTYPE_SHOP = 2
const val IDTYPE_SUBJECT = 3
- const val IDTYPE_TRANS TYPE = 4
+ const val IDTYPE_FEE TYPE = 4
fun person(userid: String): AccountHolder<TAccount> {
return AccountHolder(userid, IDTYPE_PERSON)
return AccountHolder(subjNo, IDTYPE_SUBJECT)
}
- fun transType(transType: Int): AccountHolder<TTranstype > {
- return AccountHolder("$transType", IDTYPE_TRANS TYPE)
+ fun feetype(feetype: String, paytype: String): AccountHolder<TFeetypeConfig > {
+ return AccountHolder("$feetype@$paytype", IDTYPE_FEE TYPE)
}
}
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
}
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
}
// 以下为输入参数,调用接口时指定的参数值
lateinit var person: TPerson
lateinit var tradetype: Tradetype
+ lateinit var refno: String
+ lateinit var status: String
+ val resultMap = mutableMapOf<String, String>() //存调第三方结果数据
var transcode = 0
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
}
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 = ""
if (debitAccNo.isEmpty()) {
throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR,
- "交易配置<${transtype.trans type}> 借方账号配置错误")
+ "交易配置<${transtype.feetype}@${transtype.pay type}> 借方账号配置错误")
}
if (creditAccNo.isEmpty()) {
throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR,
- "交易配置<${transtype.trans type}> 贷方账号配置错误")
+ "交易配置<${transtype.feetype}@${transtype.pay type}> 贷方账号配置错误")
}
this.details.add(TransDetail(debitAccNo, debitSubjNo, creditAccNo, creditSubjNo,
amount, transtype.summary, this.details.size + 1))
}
/**
- * 单步交易,一次完成交易记账过程
- * @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
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
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")
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