Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
baa-pay-server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
贺超
baa-pay-server
Commits
de507dea
Commit
de507dea
authored
Sep 26, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建项目
parent
6241656a
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
149 additions
and
157 deletions
+149
-157
hibernate.cfg.xml
baa-pay-core/hibernate.cfg.xml
+1
-1
pom.xml
baa-pay-core/pom.xml
+8
-9
Acquirer.java
...ore/src/main/java/cn/quant/baa/pay/acquirer/Acquirer.java
+2
-2
ChannelResponse.java
.../main/java/cn/quant/baa/pay/acquirer/ChannelResponse.java
+0
-1
MerchantAcquirer.java
...main/java/cn/quant/baa/pay/acquirer/MerchantAcquirer.java
+2
-2
AlipayMerchantAcquirer.java
...quant/baa/pay/acquirer/alipay/AlipayMerchantAcquirer.java
+2
-2
WeiXinMerchantAcquirer.java
...quant/baa/pay/acquirer/weixin/WeiXinMerchantAcquirer.java
+2
-3
EntityBuilder.java
...ore/src/main/java/cn/quant/baa/pay/jpa/EntityBuilder.java
+8
-5
PayHistoryIds.java
.../main/java/cn/quant/baa/pay/jpa/entity/PayHistoryIds.java
+0
-81
TransactionSummaryEntity.java
...cn/quant/baa/pay/jpa/entity/TransactionSummaryEntity.java
+79
-22
BatchCycleTriggerRepository.java
...t/baa/pay/jpa/repository/BatchCycleTriggerRepository.java
+0
-2
TransactionSummaryRepository.java
.../baa/pay/jpa/repository/TransactionSummaryRepository.java
+15
-0
Test.java
baa-pay-core/src/test/java/cn/quant/baa/pay/Test.java
+14
-0
TransactionController.java
...ain/java/cn/quant/baa/pay/rest/TransactionController.java
+1
-2
TransactionService.java
...ain/java/cn/quant/baa/pay/service/TransactionService.java
+15
-25
No files found.
baa-pay-core/hibernate.cfg.xml
View file @
de507dea
...
...
@@ -28,7 +28,7 @@
<mapping
class=
"cn.quant.baa.pay.jpa.entity.DictionaryEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.CustomerEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.AccountEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.
PayHisto
ryEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.
TransactionSumma
ryEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.PayGoodsDetailEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.StatusCodeEntity"
/>
<mapping
class=
"cn.quant.baa.pay.jpa.entity.BatchCycleTriggerEntity"
/>
...
...
baa-pay-core/pom.xml
View file @
de507dea
...
...
@@ -13,7 +13,6 @@
<packaging>
jar
</packaging>
<dependencies>
<dependency>
...
...
@@ -100,14 +99,14 @@
<!--jpa-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.apache.tomcat</groupId>-->
<!--<artifactId>tomcat-jdbc</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.apache.tomcat</groupId>-->
<!--<artifactId>tomcat-jdbc</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<dependency>
<groupId>
cn.quant.spring.data
</groupId>
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/acquirer/Acquirer.java
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
.
acquirer
;
import
cn.quant.baa.pay.jpa.entity.
PayHisto
ryEntity
;
import
cn.quant.baa.pay.jpa.entity.
TransactionSumma
ryEntity
;
import
cn.quant.baa.pay.model.web.*
;
/**
...
...
@@ -9,7 +9,7 @@ import cn.quant.baa.pay.model.web.*;
public
interface
Acquirer
{
Object
code
();
ChannelResponse
pay
(
PayRequestData
payRequestData
,
PayHisto
ryEntity
payHistoryEntity
)
throws
Exception
;
ChannelResponse
pay
(
PayRequestData
payRequestData
,
TransactionSumma
ryEntity
payHistoryEntity
)
throws
Exception
;
ChannelResponse
refund
(
RefundRequestData
refundRequestData
)
throws
Exception
;
ChannelResponse
checkPay
(
CheckPayRequestData
checkPayRequestData
)
throws
Exception
;
ChannelResponse
checkRefund
(
CheckRefundRequestData
checkRefundRequestData
)
throws
Exception
;
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/acquirer/ChannelResponse.java
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
.
acquirer
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryEntity
;
import
com.fasterxml.jackson.databind.JsonNode
;
/**
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/acquirer/MerchantAcquirer.java
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
.
acquirer
;
import
cn.quant.baa.pay.jpa.entity.
PayHisto
ryEntity
;
import
cn.quant.baa.pay.jpa.entity.
TransactionSumma
ryEntity
;
import
cn.quant.baa.pay.model.web.*
;
import
cn.quant.spring.NotSupportedException
;
import
cn.quant.spring.security.Base64Cipher
;
...
...
@@ -64,7 +64,7 @@ public class MerchantAcquirer implements Acquirer {
}
@Override
public
ChannelResponse
pay
(
PayRequestData
request
,
PayHisto
ryEntity
history
)
throws
Exception
{
public
ChannelResponse
pay
(
PayRequestData
request
,
TransactionSumma
ryEntity
history
)
throws
Exception
{
ChannelResponse
response
=
acquirers
.
get
(
request
.
getChanId
()).
pay
(
request
,
history
);
response
.
setOrderNo
(
String
.
valueOf
(
history
.
getTransactionId
()));
return
response
;
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/acquirer/alipay/AlipayMerchantAcquirer.java
View file @
de507dea
...
...
@@ -3,7 +3,7 @@ package cn.quant.baa.pay.acquirer.alipay;
import
cn.quant.baa.pay.acquirer.AcquirerProperties
;
import
cn.quant.baa.pay.acquirer.ChannelResponse
;
import
cn.quant.baa.pay.acquirer.MerchantAcquirer
;
import
cn.quant.baa.pay.jpa.entity.
PayHisto
ryEntity
;
import
cn.quant.baa.pay.jpa.entity.
TransactionSumma
ryEntity
;
import
cn.quant.baa.pay.model.web.*
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
...
@@ -114,7 +114,7 @@ public class AlipayMerchantAcquirer extends MerchantAcquirer {
}
@Override
public
ChannelResponse
pay
(
PayRequestData
payRequestData
,
PayHisto
ryEntity
payHistoryEntity
)
{
public
ChannelResponse
pay
(
PayRequestData
payRequestData
,
TransactionSumma
ryEntity
payHistoryEntity
)
{
ObjectNode
bodyNode
=
objectMapper
.
createObjectNode
();
bodyNode
.
put
(
"out_trade_no"
,
payRequestData
.
getOutTradeNo
());
bodyNode
.
put
(
"total_amount"
,
payRequestData
.
getAmount
());
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/acquirer/weixin/WeiXinMerchantAcquirer.java
View file @
de507dea
...
...
@@ -4,8 +4,7 @@ import cn.quant.baa.pay.acquirer.AcquirerProperties;
import
cn.quant.baa.pay.acquirer.ChannelResponse
;
import
cn.quant.baa.pay.acquirer.MerchantAcquirer
;
import
cn.quant.baa.pay.config.DictionaryViewer
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryEntity
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryIds
;
import
cn.quant.baa.pay.jpa.entity.TransactionSummaryEntity
;
import
cn.quant.baa.pay.model.dto.DictionaryItemDTO
;
import
cn.quant.baa.pay.model.web.*
;
import
cn.quant.spring.NullException
;
...
...
@@ -100,7 +99,7 @@ public class WeiXinMerchantAcquirer extends MerchantAcquirer {
}
@Override
public
ChannelResponse
pay
(
PayRequestData
request
,
PayHisto
ryEntity
history
)
throws
Exception
{
public
ChannelResponse
pay
(
PayRequestData
request
,
TransactionSumma
ryEntity
history
)
throws
Exception
{
ObjectNode
bodyNode
=
objectMapper
.
createObjectNode
();
// 转换金额为分
BigInteger
amount
=
new
BigDecimal
(
request
.
getAmount
()).
multiply
(
new
BigDecimal
(
100
)).
toBigInteger
();
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/EntityBuilder.java
View file @
de507dea
...
...
@@ -19,7 +19,7 @@ import static cn.quant.baa.pay.Constant.MINI_LOCAL_DATE;
*/
public
class
EntityBuilder
{
public
static
int
nextTxnNo
(
AccountEntity
account
,
PayHisto
ryEntity
history
)
{
public
static
int
nextTxnNo
(
AccountEntity
account
,
TransactionSumma
ryEntity
history
)
{
Integer
txnNo
=
account
.
getNextTxnNo
();
account
.
setTxnNo
(
txnNo
);
account
.
setNextTxnNo
(
txnNo
+
1
);
...
...
@@ -60,7 +60,7 @@ public class EntityBuilder {
return
account
;
}
public
static
PayHistoryEntity
payHistory
(
AccountEntity
account
,
PayHistoryIds
ids
,
long
historyId
,
PayRequestData
data
,
AcquirerProperties
properties
public
static
TransactionSummaryEntity
payHistory
(
AccountEntity
account
,
long
historyId
,
PayRequestData
data
,
AcquirerProperties
properties
,
TransactionSession
session
)
{
BigDecimal
discount
=
new
BigDecimal
(
data
.
getDiscounts
());
...
...
@@ -70,8 +70,9 @@ public class EntityBuilder {
BigDecimal
amount
=
new
BigDecimal
(
data
.
getAmount
());
String
signer
=
data
.
getGoodsSigner
();
PayHistoryEntity
entity
=
new
PayHistoryEntity
();
entity
.
setIds
(
ids
);
TransactionSummaryEntity
entity
=
new
TransactionSummaryEntity
();
entity
.
setInstitutionId
(
properties
.
getInstitutionId
());
entity
.
setProductId
(
properties
.
getProductId
());
entity
.
setAccountId
(
account
.
getAccountId
());
entity
.
setAddress
(
data
.
getAddress
());
entity
.
setAttachText
(
data
.
getAttach
());
...
...
@@ -80,7 +81,9 @@ public class EntityBuilder {
entity
.
setCustomerGenFlag
(
true
);
entity
.
setChannelId
(
properties
.
getMchChanId
());
entity
.
setDiscAmount
(
discount
);
entity
.
setExternalOrderNo
(
data
.
getOutTradeNo
());
entity
.
setGenFeeAmount
(
BigDecimal
.
ZERO
);
entity
.
setGenOrderNo
(
""
);
entity
.
setGoodsSigner
(
signer
);
entity
.
setShopName
(
data
.
getShopName
());
entity
.
setMobilePhone
(
data
.
getPhoneNo
());
...
...
@@ -131,7 +134,7 @@ public class EntityBuilder {
return
entity
;
}
public
static
BatchCycleTriggerEntity
payTrigger
(
Long
triggerId
,
PayHisto
ryEntity
history
)
{
public
static
BatchCycleTriggerEntity
payTrigger
(
Long
triggerId
,
TransactionSumma
ryEntity
history
)
{
Date
now
=
DateUtils
.
now
();
BatchCycleTriggerEntity
entity
=
new
BatchCycleTriggerEntity
();
entity
.
setAccountId
(
history
.
getAccountId
());
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/entity/PayHistoryIds.java
deleted
100644 → 0
View file @
6241656a
package
cn
.
quant
.
baa
.
pay
.
jpa
.
entity
;
import
cn.quant.spring.data.jpa.entity.PrimaryIds
;
import
cn.quant.spring.util.StringUtils
;
import
javax.persistence.Column
;
import
javax.persistence.Embeddable
;
import
java.io.Serializable
;
import
java.util.Objects
;
/**
* Created by Administrator on 2021/8/26 0026.
*/
@Embeddable
public
class
PayHistoryIds
extends
PrimaryIds
implements
Serializable
{
public
final
static
String
CLASS_NAME
=
PayHistoryEntity
.
class
.
getSimpleName
();
@Column
(
name
=
"INSTITUTION_ID"
,
nullable
=
false
,
updatable
=
false
,
length
=
4
)
private
String
institutionId
;
@Column
(
name
=
"PRODUCT_ID"
,
nullable
=
false
,
updatable
=
false
,
length
=
4
)
private
String
productId
;
@Column
(
name
=
"EXTERNAL_ORDER_NO"
,
nullable
=
false
,
updatable
=
false
,
length
=
64
)
private
String
externalOrderNo
;
public
String
getInstitutionId
()
{
return
institutionId
;
}
public
void
setInstitutionId
(
String
institutionId
)
{
this
.
institutionId
=
institutionId
;
}
public
String
getProductId
()
{
return
productId
;
}
public
void
setProductId
(
String
productId
)
{
this
.
productId
=
productId
;
}
public
String
getExternalOrderNo
()
{
return
externalOrderNo
;
}
public
void
setExternalOrderNo
(
String
externalOrderNo
)
{
this
.
externalOrderNo
=
externalOrderNo
;
}
@Override
public
String
getPersistentKey
()
{
return
StringUtils
.
toDelimitedString
(
CLASS_NAME
,
institutionId
,
productId
,
externalOrderNo
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
PayHistoryIds
that
=
(
PayHistoryIds
)
o
;
return
Objects
.
equals
(
institutionId
,
that
.
institutionId
)
&&
Objects
.
equals
(
productId
,
that
.
productId
)
&&
Objects
.
equals
(
externalOrderNo
,
that
.
externalOrderNo
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
CLASS_NAME
,
institutionId
,
productId
,
externalOrderNo
);
}
@Override
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"PayHistoryIds{"
);
sb
.
append
(
"institutionId='"
).
append
(
institutionId
).
append
(
'\''
);
sb
.
append
(
", productId='"
).
append
(
productId
).
append
(
'\''
);
sb
.
append
(
", externalOrderNo='"
).
append
(
externalOrderNo
).
append
(
'\''
);
sb
.
append
(
'}'
);
return
sb
.
toString
();
}
}
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/entity/
PayHisto
ryEntity.java
→
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/entity/
TransactionSumma
ryEntity.java
View file @
de507dea
...
...
@@ -5,6 +5,7 @@ import cn.quant.baa.pay.dict.CurrencyCode;
import
cn.quant.baa.pay.dict.PayMethod
;
import
cn.quant.baa.pay.dict.StatusCode
;
import
cn.quant.spring.data.jpa.entity.DescribablePartitionEntity
;
import
cn.quant.spring.util.StringUtils
;
import
org.hibernate.annotations.Type
;
import
javax.persistence.*
;
...
...
@@ -20,16 +21,33 @@ import java.util.Objects;
* Created by Administrator on 2021/8/26 0026.
*/
@Entity
@Table
(
name
=
"
pay_histo
ry"
)
public
class
PayHistoryEntity
extends
DescribablePartitionEntity
implements
Serializable
{
@Table
(
name
=
"
transaction_summa
ry"
)
public
class
TransactionSummaryEntity
extends
DescribablePartitionEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6297586921507136281L
;
@EmbeddedId
private
PayHistoryIds
ids
;
private
static
final
String
CLASS_NAME
=
TransactionSummaryEntity
.
class
.
getSimpleName
()
;
@Column
(
name
=
"TRANSACTION_ID"
,
nullable
=
false
,
updatable
=
false
)
private
Long
transactionId
;
@Id
@Column
(
name
=
"CHECK_CODE"
,
nullable
=
false
,
updatable
=
false
,
length
=
32
)
private
String
checkCode
;
@Column
(
name
=
"INSTITUTION_ID"
,
nullable
=
false
,
updatable
=
false
,
length
=
4
)
private
String
institutionId
;
@Column
(
name
=
"PRODUCT_ID"
,
nullable
=
false
,
updatable
=
false
,
length
=
4
)
private
String
productId
;
@Column
(
name
=
"EXTERNAL_ORDER_NO"
,
nullable
=
false
,
updatable
=
false
,
length
=
64
)
private
String
externalOrderNo
;
@Column
(
name
=
"GEN_ORDER_NO"
,
nullable
=
false
,
updatable
=
false
,
length
=
64
)
private
String
genOrderNo
;
@Column
(
name
=
"ACCOUNT_ID"
,
nullable
=
false
,
updatable
=
false
)
private
Long
accountId
;
...
...
@@ -122,14 +140,6 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
@Column
(
name
=
"ATTACH_TEXT"
,
nullable
=
true
,
length
=
512
)
private
String
attachText
;
public
PayHistoryIds
getIds
()
{
return
ids
;
}
public
void
setIds
(
PayHistoryIds
ids
)
{
this
.
ids
=
ids
;
}
public
Long
getTransactionId
()
{
return
transactionId
;
}
...
...
@@ -138,6 +148,46 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
this
.
transactionId
=
transactionId
;
}
public
String
getCheckCode
()
{
return
checkCode
;
}
public
void
setCheckCode
(
String
checkCode
)
{
this
.
checkCode
=
checkCode
;
}
public
String
getInstitutionId
()
{
return
institutionId
;
}
public
void
setInstitutionId
(
String
institutionId
)
{
this
.
institutionId
=
institutionId
;
}
public
String
getProductId
()
{
return
productId
;
}
public
void
setProductId
(
String
productId
)
{
this
.
productId
=
productId
;
}
public
String
getExternalOrderNo
()
{
return
externalOrderNo
;
}
public
void
setExternalOrderNo
(
String
externalOrderNo
)
{
this
.
externalOrderNo
=
externalOrderNo
;
}
public
String
getGenOrderNo
()
{
return
genOrderNo
;
}
public
void
setGenOrderNo
(
String
genOrderNo
)
{
this
.
genOrderNo
=
genOrderNo
;
}
public
Long
getAccountId
()
{
return
accountId
;
}
...
...
@@ -190,8 +240,8 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
return
txnType
;
}
public
void
setTxnType
(
String
txnType
Code
)
{
this
.
txnType
=
txnType
Code
;
public
void
setTxnType
(
String
txnType
)
{
this
.
txnType
=
txnType
;
}
public
String
getTxnCode
()
{
...
...
@@ -334,8 +384,8 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
return
shopName
;
}
public
void
setShopName
(
String
merchant
Name
)
{
this
.
shopName
=
merchant
Name
;
public
void
setShopName
(
String
shop
Name
)
{
this
.
shopName
=
shop
Name
;
}
public
String
getMobilePhone
()
{
...
...
@@ -372,22 +422,29 @@ public class PayHistoryEntity extends DescribablePartitionEntity implements Seri
@Override
public
String
getPersistentKey
()
{
return
ids
.
getPersistentKey
(
);
return
StringUtils
.
toDelimitedString
(
CLASS_NAME
,
institutionId
,
productId
,
externalOrderNo
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
PayHistoryEntity
that
=
(
PayHistoryEntity
)
o
;
return
Objects
.
equals
(
ids
,
that
.
ids
);
TransactionSummaryEntity
that
=
(
TransactionSummaryEntity
)
o
;
return
Objects
.
equals
(
institutionId
,
that
.
institutionId
)
&&
Objects
.
equals
(
productId
,
that
.
productId
)
&&
Objects
.
equals
(
externalOrderNo
,
that
.
externalOrderNo
);
}
@Override
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"PayHistoryEntity{"
);
sb
.
append
(
"ids="
).
append
(
ids
);
sb
.
append
(
", transactionId="
).
append
(
transactionId
);
final
StringBuilder
sb
=
new
StringBuilder
(
"TransactionSummaryEntity{"
);
sb
.
append
(
"transactionId="
).
append
(
transactionId
);
sb
.
append
(
", checkCode='"
).
append
(
checkCode
).
append
(
'\''
);
sb
.
append
(
", institutionId='"
).
append
(
institutionId
).
append
(
'\''
);
sb
.
append
(
", productId='"
).
append
(
productId
).
append
(
'\''
);
sb
.
append
(
", externalOrderNo='"
).
append
(
externalOrderNo
).
append
(
'\''
);
sb
.
append
(
", genOrderNo='"
).
append
(
genOrderNo
).
append
(
'\''
);
sb
.
append
(
", accountId="
).
append
(
accountId
);
sb
.
append
(
", channelId="
).
append
(
channelId
);
sb
.
append
(
", subject='"
).
append
(
subject
).
append
(
'\''
);
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/repository/BatchCycleTriggerRepository.java
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
.
jpa
.
repository
;
import
cn.quant.baa.pay.jpa.entity.BatchCycleTriggerEntity
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryEntity
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryIds
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
...
...
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/repository/
PayHisto
ryRepository.java
→
baa-pay-core/src/main/java/cn/quant/baa/pay/jpa/repository/
TransactionSumma
ryRepository.java
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
.
jpa
.
repository
;
import
cn.quant.baa.pay.jpa.entity.PayFeatureEntity
;
import
cn.quant.baa.pay.jpa.entity.PayFeatureIds
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryEntity
;
import
cn.quant.baa.pay.jpa.entity.PayHistoryIds
;
import
cn.quant.baa.pay.jpa.entity.TransactionSummaryEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
/**
* Created by Administrator on 2021/8/22 0022.
*/
@Repository
public
interface
PayHistoryRepository
extends
JpaRepository
<
PayHistoryEntity
,
PayHistoryIds
>
{
public
interface
TransactionSummaryRepository
extends
JpaRepository
<
TransactionSummaryEntity
,
String
>
{
// @Query("")
// int counAAAt(
PayHisto
ryIds ids);
// int counAAAt(
TransactionSumma
ryIds ids);
}
baa-pay-core/src/test/java/cn/quant/baa/pay/Test.java
0 → 100644
View file @
de507dea
package
cn
.
quant
.
baa
.
pay
;
import
java.util.zip.CRC32
;
/**
* Created by Administrator on 2021/9/26 0026.
*/
public
class
Test
{
public
static
void
main
(
String
[]
args
)
{
CRC32
crc32
=
new
CRC32
();
crc32
.
update
(
"123"
.
getBytes
());
System
.
out
.
println
(
Long
.
toHexString
(
crc32
.
getValue
()));
}
}
\ No newline at end of file
baa-pay-server/src/main/java/cn/quant/baa/pay/rest/TransactionController.java
View file @
de507dea
...
...
@@ -63,9 +63,8 @@ public class TransactionController extends BusinessController {
AcquirerProperties
properties
=
check
(
requestData
);
String
institutionId
=
properties
.
getInstitutionId
();
String
productId
=
properties
.
getProductId
();
String
buyerId
=
requestData
.
getBuyerId
();
String
outTradeNo
=
requestData
.
getOutTradeNo
();
String
redisKey
=
StringUtils
.
toDelimitedString
(
REDIS_NAMESPACE_PAY
,
institutionId
,
productId
,
buyerId
,
outTradeNo
);
String
redisKey
=
StringUtils
.
toDelimitedString
(
REDIS_NAMESPACE_PAY
,
institutionId
,
productId
,
outTradeNo
);
String
redisValue
=
stringRedisTemplate
.
opsForValue
().
get
(
redisKey
);
if
(
redisValue
!=
null
)
{
return
ResponseEntity
.
ok
(
deserialize
(
redisValue
));
...
...
baa-pay-server/src/main/java/cn/quant/baa/pay/service/TransactionService.java
View file @
de507dea
...
...
@@ -5,31 +5,21 @@ import cn.quant.baa.pay.acquirer.ChannelResponse;
import
cn.quant.baa.pay.acquirer.MerchantAcquirer
;
import
cn.quant.baa.pay.context.TransactionSession
;
import
cn.quant.baa.pay.jpa.EntityBuilder
;
import
cn.quant.baa.pay.jpa.entity.*
;
import
cn.quant.baa.pay.jpa.entity.AccountEntity
;
import
cn.quant.baa.pay.jpa.entity.BatchCycleTriggerEntity
;
import
cn.quant.baa.pay.jpa.entity.PayGoodsDetailEntity
;
import
cn.quant.baa.pay.jpa.entity.TransactionSummaryEntity
;
import
cn.quant.baa.pay.model.web.*
;
import
cn.quant.baa.pay.util.AssertUtils
;
import
cn.quant.spring.util.StringUtils
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.ZonedDateTimeSerializer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.DigestUtils
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZonedDateTime
;
import
java.util.LinkedList
;
import
java.util.List
;
...
...
@@ -50,11 +40,13 @@ public class TransactionService extends BusinessService {
private
MerchantAcquirer
acquirer
;
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
check
(
PayHistoryIds
ids
,
TransactionSession
session
)
{
PayHistoryEntity
historyEntity
=
session
.
findOne
(
PayHistoryEntity
.
class
,
ids
);
public
String
check
(
String
institutionId
,
String
productId
,
String
tradeNo
,
TransactionSession
session
)
{
String
md5
=
DigestUtils
.
md5DigestAsHex
(
String
.
join
(
institutionId
,
productId
,
tradeNo
).
getBytes
());
TransactionSummaryEntity
historyEntity
=
session
.
findOne
(
TransactionSummaryEntity
.
class
,
md5
);
if
(
historyEntity
!=
null
)
{
AssertUtils
.
throwMessage
(
EXIST_ORDER
,
i
ds
.
getInstitutionId
(),
ids
.
getProductId
(),
ids
.
getExternalOrderNo
()
);
AssertUtils
.
throwMessage
(
EXIST_ORDER
,
i
nstitutionId
,
productId
,
tradeNo
);
}
return
md5
;
}
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
...
...
@@ -70,11 +62,8 @@ public class TransactionService extends BusinessService {
String
buyerId
=
data
.
getBuyerId
();
String
outTradeNo
=
data
.
getOutTradeNo
();
PayHistoryIds
ids
=
new
PayHistoryIds
();
ids
.
setInstitutionId
(
institutionId
);
ids
.
setProductId
(
productId
);
ids
.
setExternalOrderNo
(
outTradeNo
);
check
(
ids
,
session
);
String
checkCode
=
check
(
institutionId
,
productId
,
outTradeNo
,
session
);
prepare
(
institutionId
,
productId
,
buyerId
,
session
);
...
...
@@ -96,12 +85,13 @@ public class TransactionService extends BusinessService {
details
.
add
(
detailEntity
);
}
PayHistoryEntity
history
=
EntityBuilder
.
payHistory
(
account
,
ids
,
historyId
,
data
,
properties
,
session
);
TransactionSummaryEntity
history
=
EntityBuilder
.
payHistory
(
account
,
historyId
,
data
,
properties
,
session
);
ChannelResponse
responseData
=
acquirer
.
pay
(
data
,
history
);
if
(
responseData
.
getSuccess
())
{
EntityBuilder
.
nextTxnNo
(
account
,
history
);
history
.
setCheckCode
(
checkCode
);
history
.
setPayDueTime
(
LocalDateTime
.
now
().
plus
(
PAY_DUE_TIME
));
history
.
setRequestId
(
responseData
.
getRequestId
());
history
.
setDescText
(
responseData
.
getNotification
());
...
...
@@ -126,7 +116,7 @@ public class TransactionService extends BusinessService {
//
// TransactionSession session = payHistory(data);
//
//
PayHistoryEntity payHistoryEntity = session.getProperty(PayHistoryEntity.class, PayHisto
ryEntity.class);
//
TransactionSummaryEntity payHistoryEntity = session.getProperty(TransactionSummaryEntity.class, TransactionSumma
ryEntity.class);
// System.currentTimeMillis();
// return acquirer.pay(data, payHistoryEntity);
// }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment