Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
youka-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
java-youka-wallet
youka-api
Commits
021df1c2
Commit
021df1c2
authored
Apr 13, 2018
by
Java-聂换换
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HL2通道支付
parent
fc5b0eaa
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1816 additions
and
84 deletions
+1816
-84
ComCode.java
src/main/java/com/thinkgem/jeesite/common/constant/ComCode.java
+30
-6
PayApiController.java
src/main/java/com/thinkgem/jeesite/modules/pay/api/PayApiController.java
+107
-1
PayApiDao.java
src/main/java/com/thinkgem/jeesite/modules/pay/dao/PayApiDao.java
+3
-0
OrderEntity.java
src/main/java/com/thinkgem/jeesite/modules/pay/entity/OrderEntity.java
+20
-0
RateEntity.java
src/main/java/com/thinkgem/jeesite/modules/pay/entity/RateEntity.java
+20
-1
PayBackDto.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/dto/PayBackDto.java
+19
-0
QrCodeDto.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/dto/QrCodeDto.java
+66
-0
JuHeZhongPayIntegralService.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayIntegralService.java
+19
-16
JuHeZhongPayJFenService.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayJFenService.java
+235
-0
JuHeZhongPayService.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayService.java
+3
-1
JFenHttpUtil.java
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/utils/JFenHttpUtil.java
+388
-0
PayApiService.java
src/main/java/com/thinkgem/jeesite/modules/pay/service/PayApiService.java
+333
-38
TimingService.java
src/main/java/com/thinkgem/jeesite/modules/pay/service/TimingService.java
+40
-0
JuHeZhongPayRequest.java
src/main/java/com/thinkgem/jeesite/modules/user/bean/JuHeZhongPayRequest.java
+29
-1
UserApiDao.java
src/main/java/com/thinkgem/jeesite/modules/user/dao/UserApiDao.java
+15
-0
CardEntity.java
src/main/java/com/thinkgem/jeesite/modules/user/entity/CardEntity.java
+10
-0
CardSwpaccidEntity.java
src/main/java/com/thinkgem/jeesite/modules/user/entity/CardSwpaccidEntity.java
+42
-0
UserSubMchId.java
src/main/java/com/thinkgem/jeesite/modules/user/entity/UserSubMchId.java
+33
-0
UserApiService.java
src/main/java/com/thinkgem/jeesite/modules/user/service/UserApiService.java
+244
-18
PayApiDao.xml
src/main/resources/mappings/modules/pay/PayApiDao.xml
+18
-2
UserDao.xml
src/main/resources/mappings/modules/user/UserDao.xml
+127
-0
youka.properties
src/main/resources/youka.properties
+15
-0
No files found.
src/main/java/com/thinkgem/jeesite/common/constant/ComCode.java
View file @
021df1c2
...
...
@@ -17,9 +17,9 @@ public class ComCode {
* juhezhong相关参数
*/
public
static
final
String
HOST
=
"http://pay.hezhongpay.com"
;
// 请求地址
public
static
final
String
MERCHANT_ID
=
"100532502195879"
;
// 商户号
public
static
final
String
MERCHANT_KEY
=
"670993bf-dd22-4464-9d81-69595d36b794"
;
//"670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public
static
final
String
MERCHANT_SECRET
=
"289ada73-27db-49e0-b2ad-3ae1613a665a"
;
//"289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
public
static
final
String
MERCHANT_ID
=
Global
.
getConfig
(
"pay.merchant_id"
)
;
// 商户号
public
static
final
String
MERCHANT_KEY
=
Global
.
getConfig
(
"pay.merchant.key"
)
;
//"670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public
static
final
String
MERCHANT_SECRET
=
Global
.
getConfig
(
"pay.merchant.secret"
)
;
//"289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
public
static
final
String
MERCHANT_REG_URL
=
"/api/quick/merchant/apply"
;
// 注册商户
public
static
final
String
ORDER_QUERY_URL
=
"/order/query"
;
// 查询订单
public
static
final
String
SETTLE_UPDATE_URL
=
"/api/quick/settle/card/update"
;
// 修改结算卡信息
...
...
@@ -31,15 +31,31 @@ public class ComCode {
public
static
final
String
EXTRA_RATE
=
"200"
;
// 附加手续费(单位:分)
public
static
final
String
INTEGRAL_MERCHANT_ID
=
"100532502191215"
;
// 商户号
public
static
final
String
INTEGRAL_MERCHANT_KEY
=
"781ed0d6-9657-404c-9f91-79eff2e0b782"
;
//"670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public
static
final
String
INTEGRAL_MERCHANT_SECRET
=
"0033fc8d-161b-4e97-87de-efed7a34bdea"
;
//"289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
public
static
final
String
INTEGRAL_MERCHANT_ID
=
Global
.
getConfig
(
"pay.integral.merchant_id"
)
;
// 商户号
public
static
final
String
INTEGRAL_MERCHANT_KEY
=
Global
.
getConfig
(
"pay.integral.merchant.key"
)
;
//"670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public
static
final
String
INTEGRAL_MERCHANT_SECRET
=
Global
.
getConfig
(
"pay.integral.merchant.secret"
)
;
//"289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
public
static
final
String
INTEGRAL_QUICK_PAY_URL
=
"/quick/pay"
;
// 积分快捷支付
public
static
final
String
INTEGRAL_ORDER_QUERY_URL
=
"/order/query"
;
// 积分查询订单
//快捷处理
public
static
final
String
INTEGRAL_MERCHANT_REG_URL
=
"/api/quick/pay/handle"
;
public
static
final
String
JFEN_MERCHANT_ID
=
Global
.
getConfig
(
"pay.jfen.merchant_id"
);
// 商户号
public
static
final
String
JFEN_MERCHANT_KEY
=
Global
.
getConfig
(
"pay.jfen.merchant.key"
);
//"670993bf-dd22-4464-9d81-69595d36b794"; // 商户key
public
static
final
String
JFEN_MERCHANT_SECRET
=
Global
.
getConfig
(
"pay.jfen.merchant.secret"
);
//"289ada73-27db-49e0-b2ad-3ae1613a665a"; // 商户sescet
//商户入网
public
static
final
String
JFEN_MICRO_HANDLE_URL
=
"/merchant/handle"
;
//快捷处理订单
public
static
final
String
JFEN_QUICK_PAY_URL
=
"/api/quick/pay/handle"
;
//银联二维码接口
public
static
final
String
JFEN_UNION_PAY_URL
=
"/union/qrcode"
;
//封顶快捷处理
public
static
final
String
JFEN_PEAK_QUICK_PAY_URL
=
"/peak/quick/pay/handle"
;
/**
* duolabao相关参数
*
...
...
@@ -123,4 +139,12 @@ public class ComCode {
*/
public
static
final
String
STATUS_CODE_6001
=
"6001"
;
public
static
final
String
STATUS_CODE_6001_DESC
=
"订单号不存在"
;
/**
* payChannel 通道
*/
public
static
final
String
PAYCHANNEL_HL1
=
"quick_no_integral"
;
public
static
final
String
PAYCHANNEL_HL2
=
"quick_jfen"
;
public
static
final
String
PAYCHANNEL_HL3
=
"quick_integral"
;
}
src/main/java/com/thinkgem/jeesite/modules/pay/api/PayApiController.java
View file @
021df1c2
...
...
@@ -9,6 +9,10 @@ import com.thinkgem.jeesite.modules.pay.service.PayApiService;
import
com.thinkgem.jeesite.modules.sys.entity.Dict
;
import
com.thinkgem.jeesite.modules.sys.service.DictService
;
import
com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest
;
import
com.thinkgem.jeesite.modules.user.bean.UserRequest
;
import
com.thinkgem.jeesite.modules.user.entity.CardEntity
;
import
com.thinkgem.jeesite.modules.user.entity.CardSwpaccidEntity
;
import
com.thinkgem.jeesite.modules.user.service.UserApiService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -34,6 +38,9 @@ public class PayApiController {
@Autowired
private
DictService
dictService
;
@Autowired
private
UserApiService
userApiService
;
/**
* 快捷支付
*
...
...
@@ -44,6 +51,7 @@ public class PayApiController {
public
Response
quickPay
(
JuHeZhongPayRequest
request
)
{
Response
resp
=
new
Response
();
try
{
PayBackDto
payBackDto
=
payService
.
quickPay
(
request
);
if
(
payBackDto
.
getUrl
()!=
null
&&
!
""
.
equals
(
payBackDto
.
getUrl
())){
resp
.
setStatus
(
ComCode
.
STATUS_CODE_2000
);
...
...
@@ -57,7 +65,7 @@ public class PayApiController {
}
catch
(
MyException
e
){
resp
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
resp
.
setMessage
(
ComCode
.
STATUS_CODE_9998_DESC
);
resp
.
setMessage
(
e
.
getMessage
()
);
resp
.
setError
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
...
...
@@ -69,6 +77,39 @@ public class PayApiController {
return
resp
;
}
/**
* 开卡
*
* @param request
* @return
*/
@PostMapping
(
"/openCard"
)
public
Response
openCard
(
UserRequest
request
)
{
Response
resp
=
new
Response
();
if
(
ComCode
.
PAYCHANNEL_HL2
.
equals
(
request
.
getPayChannel
())){
return
payService
.
openCardJFen
(
request
);
}
resp
.
setMessage
(
"没有该渠道"
);
resp
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
return
resp
;
}
/**
* 发送验证码
*
* @param request
* @return
*/
@PostMapping
(
"/sendMessagePay"
)
public
Response
sendMessagePay
(
JuHeZhongPayRequest
request
)
{
Response
resp
=
new
Response
();
if
(
ComCode
.
PAYCHANNEL_HL2
.
equals
(
request
.
getPayChannel
())){
return
payService
.
sendMessageJFen
(
request
);
}
resp
.
setMessage
(
"没有该渠道"
);
resp
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
return
resp
;
}
/**
* 回调
...
...
@@ -139,6 +180,71 @@ public class PayApiController {
/**
* 回调
* @param request
* @param response
*/
@RequestMapping
(
"/openCardCallback"
)
public
void
openCardCallback
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
System
.
out
.
println
(
"。。。。。。openCardCallback回调。。。。。"
);
Map
map
=
request
.
getParameterMap
();
Set
keSet
=
map
.
entrySet
();
for
(
Iterator
itr
=
keSet
.
iterator
();
itr
.
hasNext
();){
Map
.
Entry
me
=(
Map
.
Entry
)
itr
.
next
();
Object
ok
=
me
.
getKey
();
//获取参数名
Object
ov
=
me
.
getValue
();
//获取参数值
System
.
out
.
println
(
ok
+
"="
+
ok
.
toString
());
System
.
out
.
println
(
ov
+
"="
+
ov
.
toString
());
String
[]
value
=
new
String
[
1
];
if
(
ov
instanceof
String
[]){
value
=(
String
[])
ov
;
}
else
{
value
[
0
]=
ov
.
toString
();
}
for
(
int
k
=
0
;
k
<
value
.
length
;
k
++){
System
.
out
.
println
(
ok
+
"="
+
value
[
k
]);
}
}
//设置编码
try
{
request
.
setCharacterEncoding
(
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
String
swpaccid
=
request
.
getParameter
(
"swpaccid"
);
String
cardNo
=
request
.
getParameter
(
"cardNo"
);
String
phone
=
request
.
getParameter
(
"phone"
);
String
code
=
request
.
getParameter
(
"code"
);
if
(
"0000"
.
equals
(
code
)){
CardEntity
cardEntity
=
new
CardEntity
();
cardEntity
.
setCardNo
(
cardNo
);
cardEntity
.
setCardMobile
(
phone
);
cardEntity
=
userApiService
.
getCardByCardNo
(
cardNo
);
CardSwpaccidEntity
cardSwpaccidEntity
=
new
CardSwpaccidEntity
();
cardSwpaccidEntity
.
setPayMethod
(
"quick"
);
cardSwpaccidEntity
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
cardSwpaccidEntity
.
setSwpaccid
(
swpaccid
);
cardSwpaccidEntity
.
setCardCode
(
cardEntity
.
getCode
());
userApiService
.
addSwpaccid
(
cardSwpaccidEntity
);
//返回true 收到请求,停止通知
PrintWriter
write
=
null
;
try
{
write
=
response
.
getWriter
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
write
.
print
(
"true"
);
write
.
flush
();
write
.
close
();
}
}
/**
* 获取支付的结果
* @param orderEntity
* @return
...
...
src/main/java/com/thinkgem/jeesite/modules/pay/dao/PayApiDao.java
View file @
021df1c2
...
...
@@ -4,6 +4,7 @@ import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import
com.thinkgem.jeesite.modules.pay.entity.BenefitEntity
;
import
com.thinkgem.jeesite.modules.pay.entity.OrderEntity
;
import
com.thinkgem.jeesite.modules.pay.entity.UserRateEntity
;
import
com.thinkgem.jeesite.modules.user.entity.CardEntity
;
import
java.util.List
;
...
...
@@ -19,6 +20,7 @@ public interface PayApiDao {
void
saveBenefitInfo
(
BenefitEntity
benefitEntity
);
void
updateOrderStatus
(
OrderEntity
orderEntity
);
int
updateOrderTradeNo
(
OrderEntity
orderEntity
);
OrderEntity
getOrder
(
OrderEntity
orderEntity
);
...
...
@@ -31,4 +33,5 @@ public interface PayApiDao {
// 查询状态为支付中的状态
List
<
OrderEntity
>
getOrderListTimeing
(
OrderEntity
orderEntity
);
}
src/main/java/com/thinkgem/jeesite/modules/pay/entity/OrderEntity.java
View file @
021df1c2
...
...
@@ -22,6 +22,10 @@ public class OrderEntity extends BaseEntity implements Serializable {
private
String
createDate
;
private
String
startTime
;
private
String
endTime
;
public
OrderEntity
()
{
}
...
...
@@ -155,4 +159,20 @@ public class OrderEntity extends BaseEntity implements Serializable {
public
void
setPayMethodName
(
String
payMethodName
)
{
this
.
payMethodName
=
payMethodName
;
}
public
String
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
String
startTime
)
{
this
.
startTime
=
startTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/entity/RateEntity.java
View file @
021df1c2
...
...
@@ -11,13 +11,15 @@ public class RateEntity extends BaseEntity implements Serializable {
private
String
balance
;
// 结算
private
String
singleLimit
;
// 单笔限额
private
String
dayLimit
;
// 当天额度
private
String
payChannel
;
//
HL3通道的汇率编码
private
String
payChannel
;
//
通道
private
String
img
;
// 图标
private
String
payMethodLabel
;
// 支付方式名称
private
String
serviceType
;
private
String
rateType
;
public
RateEntity
()
{
}
...
...
@@ -99,4 +101,21 @@ public class RateEntity extends BaseEntity implements Serializable {
public
void
setPayChannel
(
String
payChannel
)
{
this
.
payChannel
=
payChannel
;
}
public
String
getServiceType
()
{
return
serviceType
;
}
public
void
setServiceType
(
String
serviceType
)
{
this
.
serviceType
=
serviceType
;
}
public
String
getRateType
()
{
return
rateType
;
}
public
void
setRateType
(
String
rateType
)
{
this
.
rateType
=
rateType
;
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/dto/PayBackDto.java
View file @
021df1c2
...
...
@@ -8,6 +8,9 @@ package com.thinkgem.jeesite.modules.pay.juhezhong.dto;
public
class
PayBackDto
{
private
String
url
;
// 支付url
private
String
message
;
private
String
payChannel
;
//
private
String
isUrl
=
"1"
;
// 是否是返回的url 1是 0否
public
String
getUrl
()
{
return
url
;
...
...
@@ -24,4 +27,20 @@ public class PayBackDto {
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getPayChannel
()
{
return
payChannel
;
}
public
void
setPayChannel
(
String
payChannel
)
{
this
.
payChannel
=
payChannel
;
}
public
String
getIsUrl
()
{
return
isUrl
;
}
public
void
setIsUrl
(
String
isUrl
)
{
this
.
isUrl
=
isUrl
;
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/dto/QrCodeDto.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
pay
.
juhezhong
.
dto
;
/**
* Created by lishi on 2017/11/21.
*/
public
class
QrCodeDto
extends
CommonDto
{
private
String
terminalId
;
//付款码
private
String
subMchId
=
""
;
//子商户号
private
String
bankSettNo
=
""
;
//联行号
private
String
acctName
=
""
;
//收款人姓名
private
String
acctNo
=
""
;
//收款人账号
private
String
idNo
=
""
;
//证件号码
public
String
getSubMchId
()
{
return
subMchId
;
}
public
void
setSubMchId
(
String
subMchId
)
{
this
.
subMchId
=
subMchId
;
}
public
String
getBankSettNo
()
{
return
bankSettNo
;
}
public
void
setBankSettNo
(
String
bankSettNo
)
{
this
.
bankSettNo
=
bankSettNo
;
}
public
String
getAcctName
()
{
return
acctName
;
}
public
void
setAcctName
(
String
acctName
)
{
this
.
acctName
=
acctName
;
}
public
String
getAcctNo
()
{
return
acctNo
;
}
public
void
setAcctNo
(
String
acctNo
)
{
this
.
acctNo
=
acctNo
;
}
public
String
getIdNo
()
{
return
idNo
;
}
public
void
setIdNo
(
String
idNo
)
{
this
.
idNo
=
idNo
;
}
public
String
getTerminalId
()
{
return
terminalId
;
}
public
void
setTerminalId
(
String
terminalId
)
{
this
.
terminalId
=
terminalId
;
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayIntegralService.java
View file @
021df1c2
...
...
@@ -12,13 +12,16 @@ import com.thinkgem.jeesite.modules.pay.juhezhong.utils.HttpUtil;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Map
;
@Transactional
@Service
@Lazy
(
false
)
@Transactional
public
class
JuHeZhongPayIntegralService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
Logger
.
class
);
...
...
@@ -32,7 +35,7 @@ public class JuHeZhongPayIntegralService {
* @throws Exception
*/
public
JSONObject
query
(
CommonDto
dto
)
throws
Exception
{
dto
.
setMerchantId
(
ComCode
.
MERCHANT_ID
);
dto
.
setMerchantId
(
ComCode
.
INTEGRAL_
MERCHANT_ID
);
dto
.
setMerchantKey
(
ComCode
.
INTEGRAL_MERCHANT_KEY
);
Map
<
String
,
Object
>
params
=
Bean2Map
.
Entity2Map
(
dto
);
String
signBefore
=
SignUtils
.
signBefore
(
params
);
...
...
@@ -66,7 +69,7 @@ public class JuHeZhongPayIntegralService {
// JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
// System.out.println(jsonObject.toJSONString());
JuHeZhongPayIntegralService
juHeZhongPayIntegralService
=
new
JuHeZhongPayIntegralService
();
//
JuHeZhongPayIntegralService juHeZhongPayIntegralService = new JuHeZhongPayIntegralService();
// JSONObject dto = new JSONObject();
//
// dto.put("orderId", MakeOrderNum.makeOrderNum());//标识请求唯一(非订单号)
...
...
@@ -93,18 +96,18 @@ public class JuHeZhongPayIntegralService {
// String sign = SignUtils.sign(signBefore, ComCode.INTEGRAL_MERCHANT_SECRET);
//B105004538
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"serviceType"
,
10
);
// 服务类型
dto
.
put
(
"merchantId"
,
ComCode
.
INTEGRAL_MERCHANT_ID
);
//商户号
dto
.
put
(
"orderId"
,
IdGen
.
randomBase62
(
64
));
//订单号
// 李波的交通银行卡subMchId 403196720
dto
.
put
(
"subMchId"
,
"403196720"
);
//由系统分配的商户号
dto
.
put
(
"merchantKey"
,
ComCode
.
INTEGRAL_MERCHANT_KEY
);
//商户key
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
//时间戳
JSONObject
jsonObject
=
juHeZhongPayIntegralService
.
quickPayHandle
(
dto
);
//
//
JSONObject dto = new JSONObject();
//
//
dto.put("serviceType", 10);// 服务类型
//
dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);//商户号
//
dto.put("orderId", IdGen.randomBase62(64));//订单号
//
//
// 李波的交通银行卡subMchId 403196720
//
dto.put("subMchId", "403196720");//由系统分配的商户号
//
dto.put("merchantKey", ComCode.INTEGRAL_MERCHANT_KEY);//商户key
//
dto.put("timestamp", System.currentTimeMillis());//时间戳
//
JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
// JSONObject dto = new JSONObject();
...
...
@@ -144,7 +147,7 @@ public class JuHeZhongPayIntegralService {
// dto.put("timestamp", System.currentTimeMillis());//时间戳
// System.out.println(dto.toJSONString());
// JSONObject jsonObject = juHeZhongPayIntegralService.quickPayHandle(dto);
System
.
out
.
println
(
jsonObject
.
toJSONString
());
//
System.out.println(jsonObject.toJSONString());
}
...
...
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayJFenService.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
pay
.
juhezhong
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.thinkgem.jeesite.common.config.Global
;
import
com.thinkgem.jeesite.common.constant.ComCode
;
import
com.thinkgem.jeesite.common.utils.DateUtils
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.ApiQuickPayDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.CommonDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.QrCodeDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.QuickDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.Bean2Map
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.JFenHttpUtil
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.MakeOrderNum
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.SignUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.Map
;
/**
* 首页通知
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
JuHeZhongPayJFenService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
Logger
.
class
);
/**
* 查询订单状态
*
* @param dto
* @return
* @throws Exception
*/
public
JSONObject
query
(
CommonDto
dto
)
throws
Exception
{
Map
<
String
,
Object
>
params
=
Bean2Map
.
Entity2Map
(
dto
);
String
signBefore
=
SignUtils
.
signBefore
(
params
);
String
sign
=
SignUtils
.
sign
(
signBefore
,
ComCode
.
JFEN_MERCHANT_SECRET
);
params
.
put
(
"sign"
,
sign
);
String
respStr
=
JFenHttpUtil
.
post
(
ComCode
.
HOST
+
ComCode
.
ORDER_QUERY_URL
,
params
);
logger
.
info
(
"respStr:{}"
,
respStr
);
return
JSONObject
.
parseObject
(
respStr
);
}
public
JSONObject
merchantIn
(
JSONObject
dto
)
throws
Exception
{
dto
.
put
(
"merchantId"
,
ComCode
.
JFEN_MERCHANT_ID
);
dto
.
put
(
"merchantKey"
,
ComCode
.
JFEN_MERCHANT_KEY
);
String
signBefore
=
SignUtils
.
signBefore
(
dto
);
logger
.
info
(
"signBefore:{}"
,
signBefore
);
String
sign
=
SignUtils
.
sign
(
signBefore
,
ComCode
.
JFEN_MERCHANT_SECRET
);
dto
.
put
(
"sign"
,
sign
);
String
respStr
=
JFenHttpUtil
.
postRaw
(
ComCode
.
HOST
+
ComCode
.
JFEN_MICRO_HANDLE_URL
,
dto
.
toString
());
return
JSONObject
.
parseObject
(
respStr
);
}
public
JSONObject
merchantAddFeel
(
JSONObject
dto
)
throws
Exception
{
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
dto
.
put
(
"serviceType"
,
"6"
);
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
return
merchantIn
(
dto
);
}
public
JSONObject
merchantModifyFeel
(
JSONObject
dto
)
throws
Exception
{
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
dto
.
put
(
"serviceType"
,
"7"
);
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
return
merchantIn
(
dto
);
}
public
JSONObject
openCard
(
JSONObject
dto
)
throws
Exception
{
String
signBefore
=
SignUtils
.
signBefore
(
dto
);
logger
.
info
(
"signBefore:{}"
,
signBefore
);
String
sign
=
SignUtils
.
sign
(
signBefore
,
ComCode
.
JFEN_MERCHANT_SECRET
);
dto
.
put
(
"sign"
,
sign
);
String
respStr
=
JFenHttpUtil
.
postRaw
(
ComCode
.
HOST
+
ComCode
.
JFEN_QUICK_PAY_URL
,
dto
.
toString
());
return
JSONObject
.
parseObject
(
respStr
);
}
public
JSONObject
unionQrCodePay
(
QrCodeDto
dto
)
throws
Exception
{
Map
<
String
,
Object
>
params
=
Bean2Map
.
Entity2Map
(
dto
);
String
signBefore
=
SignUtils
.
signBefore
(
params
);
logger
.
info
(
"signBefore:{}"
,
signBefore
);
String
sign
=
SignUtils
.
sign
(
signBefore
,
ComCode
.
JFEN_MERCHANT_SECRET
);
params
.
put
(
"sign"
,
sign
);
String
respStr
=
JFenHttpUtil
.
post
(
ComCode
.
HOST
+
ComCode
.
JFEN_UNION_PAY_URL
,
params
);
return
JSONObject
.
parseObject
(
respStr
);
}
public
JSONObject
peakQuickPayHandle
(
JSONObject
dto
)
throws
Exception
{
String
signBefore
=
SignUtils
.
signBefore
(
dto
);
logger
.
info
(
"signBefore:{}"
,
signBefore
);
String
sign
=
SignUtils
.
sign
(
signBefore
,
ComCode
.
JFEN_MERCHANT_SECRET
);
dto
.
put
(
"sign"
,
sign
);
String
respStr
=
JFenHttpUtil
.
post
(
ComCode
.
HOST
+
ComCode
.
JFEN_PEAK_QUICK_PAY_URL
,
dto
.
toJSONString
());
return
JSONObject
.
parseObject
(
respStr
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
JuHeZhongPayJFenService
juHeZhongPayJFenService
=
new
JuHeZhongPayJFenService
();
JSONObject
dto
=
new
JSONObject
();
// dto.put("orderId", MakeOrderNum.makeOrderNum());
// subMchId = B105244442
// 聂换换 B105247024
// dto.put("serviceType",1);
// dto.put("subMerchantName","kklsubMerchantName32");
// dto.put("subMerchantType","PERSON");
// dto.put("businessLicense","businessLicense23");
// dto.put("legalPersonName","聂换换");
// dto.put("legalPersonID","130434199212214429");
// dto.put("subMerchantPersonName","聂换换");
// dto.put("subMerchantPersonPhone","13722537737");
// dto.put("bankType","TOPRIVATE");
//
// dto.put("accountName","聂换换");
// dto.put("accountNo","6217000060031684713");
// dto.put("bankName","中国建设银行");
// dto.put("bankProv","天津");
// dto.put("bankCity","天津市");
// dto.put("bankBranch","开户地址new");
// dto.put("bankCode","105100000017");
//
// dto.put("timestamp",System.currentTimeMillis());
//
// juHeZhongPayJFenService.merchantIn(dto);
// dto.put("subMchId","B105247024");
// dto.put("paymentType","QUICKPAY");
// dto.put("d0Fee","0.0043");// 最低是0.0043 d0Fee和d1Fee建议两个值相同
// dto.put("d1Fee","0.0043");// 最低是0.0043
// juHeZhongPayJFenService.merchantModifyFeel(dto);
//
//
// dto.put("orderId",MakeOrderNum.makeOrderNum());
// dto.put("merchantId",ComCode.JFEN_MERCHANT_ID);
// dto.put("serviceType","8");
// dto.put("subMchId","B105244442");
// dto.put("idType","01");
// dto.put("idNo","53250219850831031X");
// dto.put("d0Fee","0.0043");
// dto.put("accountName","李波");
// dto.put("accountNo","6225571645517950");
// dto.put("mobile","13821934497");
// dto.put("notifyUrl","http://39.107.124.166:8080/youka-api/api/pay/openCardCallback");
// dto.put("merchantKey",ComCode.JFEN_MERCHANT_KEY);
// dto.put("timestamp",System.currentTimeMillis());
/**
* 。。。。。。openCardCallback回调。。。。。
swpaccid=swpaccid
[Ljava.lang.String;@37c7e16f=[Ljava.lang.String;@37c7e16f
swpaccid=3296555230614091180
msg=msg
[Ljava.lang.String;@5fb7df1a=[Ljava.lang.String;@5fb7df1a
msg=成功
code=code
[Ljava.lang.String;@7a5c7842=[Ljava.lang.String;@7a5c7842
code=0000
merchantId=merchantId
[Ljava.lang.String;@53c16c4b=[Ljava.lang.String;@53c16c4b
merchantId=100532502198424
phone=phone
[Ljava.lang.String;@5b8533c5=[Ljava.lang.String;@5b8533c5
phone=13821934497
sign=sign
[Ljava.lang.String;@3aab68a0=[Ljava.lang.String;@3aab68a0
sign=1c7358d6e3c067902ad8d24cb17e3aa6
subMchId=subMchId
[Ljava.lang.String;@232c89df=[Ljava.lang.String;@232c89df
subMchId=B105244442
cardNo=cardNo
[Ljava.lang.String;@7bd70ac5=[Ljava.lang.String;@7bd70ac5
cardNo=6225571645517950
merchantKey=merchantKey
[Ljava.lang.String;@93e1561=[Ljava.lang.String;@93e1561
merchantKey=260a7539-6a2b-410d-aeec-9897ccee92a1
timestamp=timestamp
[Ljava.lang.String;@6831928e=[Ljava.lang.String;@6831928e
timestamp=1523590870783
2018-04-13 11:41:10,939 DEBUG [jeesite.modules.sys.interceptor.LogInterceptor] - 计时结束:11:41:10.939 耗时:0:0:0.37 URI: /youka-api/api/pay/openCardCallback 最大内存: 1739m 已分配内存: 743m 已分配内存中的剩余空间: 145m 最大可用内存: 1141m
*/
// System.out.println(dto.toJSONString());
// juHeZhongPayJFenService.openCard(dto);
// dto.put("orderId",MakeOrderNum.makeOrderNum());
// dto.put("merchantId",ComCode.JFEN_MERCHANT_ID);
// dto.put("serviceType","4");
// dto.put("subMchId","B105244442");
// dto.put("merchantKey",ComCode.JFEN_MERCHANT_KEY);
// dto.put("timestamp",System.currentTimeMillis());
// dto.put("amount","100");
// dto.put("idNo","53250219850831031X");
// dto.put("accountName","李波");
// dto.put("accountNo","6225571645517950");
//
// dto.put("mobile","13821934497");
// dto.put("swpaccid","3296555230614091180");
//
// dto.put("notifyUrl","http://39.107.124.166:8080/youka-api/api/pay/openCardCallback");
// dto.put("amount","1000");
// juHeZhongPayJFenService.openCard(dto);
// trade_no 20180413135023288124
/**
* 2018-04-13 13:54:01,804 DEBUG [modules.pay.juhezhong.utils.HttpUtil] - httpclient调用状态:HTTP/1.1 200
2018-04-13 13:54:01,809 DEBUG [modules.pay.juhezhong.utils.HttpUtil] - httpclient调用结果{"serviceType":"4","swpaccid":"3296555230614091180","msg":"成功","amount":"1000","code":"0000","accountName":"李波","orderId":"20180413135359987000","mobile":"13821934497","sign":"9f0276f8632701b07ec67a9a2de637b7","subMchId":"B105244442","idNo":"53250219850831031X","merchantKey":"260a7539-6a2b-410d-aeec-9897ccee92a1","merchantId":"100532502198424","accountNo":"6225571645517950","notifyUrl":"http://39.107.124.166:8080/youka-api/api/pay/openCardCallback","trade_no":"20180413135359746143","timestamp":1523598840038}
*/
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
dto
.
put
(
"merchantId"
,
ComCode
.
JFEN_MERCHANT_ID
);
dto
.
put
(
"serviceType"
,
"5"
);
dto
.
put
(
"subMchId"
,
"B105244442"
);
dto
.
put
(
"merchantKey"
,
ComCode
.
JFEN_MERCHANT_KEY
);
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
dto
.
put
(
"passwd"
,
"249286"
);
dto
.
put
(
"productName"
,
"productName"
);
dto
.
put
(
"tradeNo"
,
"20180413135359746143"
);
dto
.
put
(
"swpaccid"
,
"3296555230614091180"
);
juHeZhongPayJFenService
.
openCard
(
dto
);
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/service/JuHeZhongPayService.java
View file @
021df1c2
...
...
@@ -10,6 +10,7 @@ import com.thinkgem.jeesite.modules.pay.juhezhong.utils.Bean2Map;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.HttpUtil
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.SignUtils
;
import
com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -19,7 +20,8 @@ import java.util.Map;
* 首页通知
*/
@Service
@Transactional
(
readOnly
=
true
)
@Lazy
(
false
)
@Transactional
public
class
JuHeZhongPayService
{
/**
...
...
src/main/java/com/thinkgem/jeesite/modules/pay/juhezhong/utils/JFenHttpUtil.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
pay
.
juhezhong
.
utils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.config.Registry
;
import
org.apache.http.config.RegistryBuilder
;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
import
org.apache.http.conn.socket.PlainConnectionSocketFactory
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.LoggerFactory
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.security.cert.CertificateException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
static
java
.
lang
.
System
.
currentTimeMillis
;
/***
* httpUtil
*
* @author
*/
public
class
JFenHttpUtil
{
private
static
final
org
.
slf4j
.
Logger
log
=
LoggerFactory
.
getLogger
(
HttpUtil
.
class
);
private
static
PoolingHttpClientConnectionManager
cm
=
null
;
private
static
RequestConfig
defaultRequestConfig
=
null
;
static
{
try
{
//采用绕过验证的方式处理https请求
SSLContext
sslcontext
=
createIgnoreVerifySSL
();
Registry
<
ConnectionSocketFactory
>
socketFactoryRegistry
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
.
register
(
"https"
,
new
SSLConnectionSocketFactory
(
sslcontext
))
.
register
(
"http"
,
new
PlainConnectionSocketFactory
())
.
build
();
cm
=
new
PoolingHttpClientConnectionManager
(
socketFactoryRegistry
);
cm
.
setMaxTotal
(
2000
);
cm
.
setDefaultMaxPerRoute
(
20
);
defaultRequestConfig
=
RequestConfig
.
custom
()
.
setSocketTimeout
(
30000
)
.
setConnectTimeout
(
30000
)
.
setConnectionRequestTimeout
(
30000
)
.
setStaleConnectionCheckEnabled
(
true
)
.
build
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
static
SSLContext
createIgnoreVerifySSL
()
throws
Exception
{
SSLContext
sc
=
SSLContext
.
getInstance
(
"SSLv3"
);
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager
trustManager
=
new
X509TrustManager
()
{
@Override
public
void
checkClientTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
paramArrayOfX509Certificate
,
String
paramString
)
throws
CertificateException
{
}
@Override
public
void
checkServerTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
paramArrayOfX509Certificate
,
String
paramString
)
throws
CertificateException
{
}
@Override
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
};
sc
.
init
(
null
,
new
TrustManager
[]{
trustManager
},
null
);
return
sc
;
}
public
static
String
get
(
String
url
,
String
param
)
throws
IOException
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
// 发送get请求
try
{
// 用get方法发送http请求
HttpGet
get
=
new
HttpGet
(
url
+
URLEncoder
.
encode
(
param
,
"UTF-8"
));
get
.
setHeader
(
"User-Agent"
,
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36"
);
System
.
out
.
println
(
"执行get请求, uri: "
+
get
.
getURI
());
response
=
httpclient
.
execute
(
get
);
// response实体
HttpEntity
entity
=
response
.
getEntity
();
if
(
null
!=
entity
)
{
String
str
=
EntityUtils
.
toString
(
entity
);
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
statusCode
==
HttpStatus
.
SC_OK
)
{
// 成功
return
str
;
}
else
{
return
null
;
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"httpclient请求失败"
);
return
null
;
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
return
null
;
}
public
static
String
post
(
String
url
,
List
<
NameValuePair
>
nvps
)
throws
Exception
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
"utf-8"
));
response
=
httpclient
.
execute
(
httpPost
);
HttpEntity
entity
=
response
.
getEntity
();
str
=
EntityUtils
.
toString
(
entity
);
log
.
debug
(
"httpclient调用状态:"
+
response
.
getStatusLine
());
log
.
debug
(
"httpclient调用结果{}"
,
str
);
// return EntityUtils.toString(response.getEntity());
return
str
;
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
}
public
static
String
post
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
Long
time
=
System
.
currentTimeMillis
();
// CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(defaultRequestConfig).build();
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
build
();
CloseableHttpResponse
response
=
null
;
HttpPost
httpPost
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
//设置参数
List
<
NameValuePair
>
list
=
new
ArrayList
<
NameValuePair
>();
for
(
String
key
:
params
.
keySet
())
{
list
.
add
(
new
BasicNameValuePair
(
key
,
""
+
params
.
get
(
key
)));
}
if
(
list
.
size
()
>
0
)
{
UrlEncodedFormEntity
entity
=
new
UrlEncodedFormEntity
(
list
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
list
,
"UTF-8"
));
}
response
=
httpclient
.
execute
(
httpPost
);
str
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
log
.
info
(
"请求耗时:{}ms"
,
(
System
.
currentTimeMillis
()
-
time
));
return
str
;
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
}
public
static
String
postRaw
(
String
url
,
String
json
)
throws
Exception
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
StringEntity
postingString
=
new
StringEntity
(
json
,
"UTF-8"
);
// json传递
httpPost
.
setEntity
(
postingString
);
httpPost
.
setHeader
(
"Content-type"
,
"application/json"
);
response
=
httpclient
.
execute
(
httpPost
);
try
{
HttpEntity
entity
=
response
.
getEntity
();
str
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
log
.
debug
(
"httpclient调用状态:"
+
response
.
getStatusLine
());
log
.
debug
(
"httpclient调用结果{}"
,
str
);
// return EntityUtils.toString(response.getEntity());
return
str
;
}
finally
{
response
.
close
();
}
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
}
public
static
String
get
(
String
url
)
throws
Exception
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
HttpGet
httpget
=
null
;
try
{
httpget
=
new
HttpGet
(
url
);
String
str
=
""
;
response
=
httpclient
.
execute
(
httpget
);
// 获取状态行
HttpEntity
entity
=
response
.
getEntity
();
str
=
EntityUtils
.
toString
(
entity
);
log
.
debug
(
"httpclient调用状态:"
+
response
.
getStatusLine
());
log
.
debug
(
"httpclient调用结果{}"
,
str
);
return
str
;
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpget
!=
null
)
{
httpget
.
releaseConnection
();
}
}
}
public
static
void
main
(
String
[]
args
)
{
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
try
{
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
Long
time
=
currentTimeMillis
();
get
(
"https://www.baidu.com/website/index"
);
System
.
out
.
println
(
"耗时:"
+
((
currentTimeMillis
()
-
time
)
/
1000
)
+
"s"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
String
formSubmit
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
IOException
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
CloseableHttpResponse
response
=
null
;
HttpPost
httpPost
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setHeader
(
"Accept"
,
"Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
);
httpPost
.
setHeader
(
"Accept-Charset"
,
"GB2312,utf-8;q=0.7,*;q=0.7"
);
httpPost
.
setHeader
(
"Accept-Encoding"
,
"gzip, deflate"
);
httpPost
.
setHeader
(
"Accept-Language"
,
"zh-cn,zh;q=0.5"
);
httpPost
.
setHeader
(
"Connection"
,
"keep-alive"
);
httpPost
.
setHeader
(
"Cookie"
,
"__utma=226521935.73826752.1323672782.1325068020.1328770420.6;"
);
httpPost
.
setHeader
(
"Host"
,
"localhost"
);
httpPost
.
setHeader
(
"refer"
,
""
);
httpPost
.
setHeader
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
);
httpPost
.
setHeader
(
"Content-type"
,
"application/x-www-form-urlencoded"
);
//设置参数
List
<
NameValuePair
>
list
=
new
ArrayList
<
NameValuePair
>();
for
(
String
key
:
params
.
keySet
())
{
list
.
add
(
new
BasicNameValuePair
(
key
,
""
+
params
.
get
(
key
)));
}
if
(
list
.
size
()
>
0
)
{
UrlEncodedFormEntity
entity
=
new
UrlEncodedFormEntity
(
list
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
list
,
"utf-8"
));
}
response
=
httpclient
.
execute
(
httpPost
);
str
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
return
str
;
}
public
static
String
sendData
(
String
url
,
String
xml
)
throws
Exception
{
Long
time
=
System
.
currentTimeMillis
();
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
StringEntity
postingString
=
new
StringEntity
(
xml
,
"UTF-8"
);
// json传递
httpPost
.
setEntity
(
postingString
);
response
=
httpclient
.
execute
(
httpPost
);
try
{
str
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
log
.
debug
(
"请求耗时:{}ms"
,
(
System
.
currentTimeMillis
()
-
time
));
return
str
;
}
finally
{
response
.
close
();
}
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
}
public
static
String
post
(
String
url
,
String
json
)
throws
Exception
{
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setConnectionManager
(
cm
).
build
();
HttpPost
httpPost
=
null
;
CloseableHttpResponse
response
=
null
;
String
str
=
""
;
try
{
httpPost
=
new
HttpPost
(
url
);
StringEntity
postingString
=
new
StringEntity
(
json
,
"UTF-8"
);
// json传递
httpPost
.
setEntity
(
postingString
);
httpPost
.
setHeader
(
"Content-type"
,
"application/json"
);
response
=
httpclient
.
execute
(
httpPost
);
try
{
HttpEntity
entity
=
response
.
getEntity
();
str
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
log
.
debug
(
"httpclient调用状态:"
+
response
.
getStatusLine
());
log
.
debug
(
"httpclient调用结果{}"
,
str
);
// return EntityUtils.toString(response.getEntity());
return
str
;
}
finally
{
response
.
close
();
}
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
if
(
httpPost
!=
null
)
{
httpPost
.
releaseConnection
();
}
}
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/service/PayApiService.java
View file @
021df1c2
...
...
@@ -2,6 +2,7 @@ package com.thinkgem.jeesite.modules.pay.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.thinkgem.jeesite.common.baseBean.Request
;
import
com.thinkgem.jeesite.common.baseBean.Response
;
import
com.thinkgem.jeesite.common.config.Global
;
import
com.thinkgem.jeesite.common.constant.ComCode
;
import
com.thinkgem.jeesite.common.utils.DateUtils
;
...
...
@@ -17,18 +18,22 @@ import com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.PayBackDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.QuickDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayIntegralService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayJFenService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.MakeOrderNum
;
import
com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest
;
import
com.thinkgem.jeesite.modules.user.bean.UserRequest
;
import
com.thinkgem.jeesite.modules.user.entity.CardEntity
;
import
com.thinkgem.jeesite.modules.user.entity.UserEntity
;
import
com.thinkgem.jeesite.modules.user.entity.*
;
import
com.thinkgem.jeesite.modules.user.service.UserApiService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.*
;
...
...
@@ -36,7 +41,9 @@ import java.util.*;
/**
* 支付相关
*/
@Service
@Lazy
(
false
)
@Transactional
(
readOnly
=
true
)
public
class
PayApiService
{
@Autowired
...
...
@@ -49,8 +56,17 @@ public class PayApiService {
@Autowired
private
JuHeZhongPayIntegralService
juHeZhongPayIntegralService
;
@Autowired
private
JuHeZhongPayJFenService
juHeZhongPayJFenService
;
@Transactional
(
readOnly
=
false
)
public
PayBackDto
quickPay
(
JuHeZhongPayRequest
request
)
throws
MyException
,
Exception
{
if
(
ComCode
.
PAYCHANNEL_HL2
.
equals
(
request
.
getPayChannel
())){
PayBackDto
payBackDto
=
this
.
jFenPayJuhezhong
(
request
);
payBackDto
.
setIsUrl
(
"0"
);
return
payBackDto
;
}
// 1. 根据入参获取用户详情信息,包括支付卡片信息
UserEntity
userEntity
=
userService
.
getUserInfo
(
new
Request
(
request
.
getSubMerchantCode
()));
userEntity
=
userService
.
getUserDetailInfo
(
userEntity
);
...
...
@@ -65,35 +81,62 @@ public class PayApiService {
String
payCode
=
IdGen
.
randomBase62
(
64
);
DecimalFormat
df
=
new
DecimalFormat
(
"######0.00"
);
String
amount
=
df
.
format
(
Double
.
valueOf
(
request
.
getAmount
()));
OrderEntity
orderEntity
=
new
OrderEntity
(
code
,
request
.
getSubMerchantCode
(),
payNo
,
payCode
,
"quick"
,
request
.
getPayChannel
(),
"1"
,
amount
,
request
.
getSubject
(),
""
,
String
.
valueOf
(
"D"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
5
:
(
"C"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
6
:
0
)),
request
.
getCardCode
());
payDao
.
saveOrderInfo
(
orderEntity
);
// 3. 创建分润信息,并保存
Map
<
String
,
String
>
userBenefits
=
getUserBenefit
(
userEntity
,
request
);
for
(
String
key
:
userBenefits
.
keySet
())
{
String
benefitCode
=
IdGen
.
randomBase62
(
64
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
(
benefitCode
,
request
.
getSubMerchantCode
(),
code
,
request
.
getPayChannel
(),
"0"
,
"A"
,
userBenefits
.
get
(
key
),
""
);
benefitEntity
.
setAmount
(
String
.
valueOf
(
Double
.
valueOf
(
benefitEntity
.
getAmount
())));
payDao
.
saveBenefitInfo
(
benefitEntity
);
}
// 4. JuHeZhong支付
PayBackDto
payBackDto
=
new
PayBackDto
();
// 获取支付卡号
CardEntity
cardEntityPay
=
userService
.
getCardInfo
(
request
);
if
(
"quick_no_integral"
.
equals
(
request
.
getPayChannel
())){
if
(
ComCode
.
PAYCHANNEL_HL1
.
equals
(
request
.
getPayChannel
())){
OrderEntity
orderEntity
=
new
OrderEntity
(
code
,
request
.
getSubMerchantCode
(),
payNo
,
payCode
,
"quick"
,
request
.
getPayChannel
(),
"1"
,
amount
,
request
.
getSubject
(),
""
,
String
.
valueOf
(
"D"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
5
:
(
"C"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
6
:
0
)),
request
.
getCardCode
());
payDao
.
saveOrderInfo
(
orderEntity
);
// 3. 创建分润信息,并保存
Map
<
String
,
String
>
userBenefits
=
getUserBenefit
(
userEntity
,
request
);
for
(
String
key
:
userBenefits
.
keySet
())
{
String
benefitCode
=
IdGen
.
randomBase62
(
64
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
(
benefitCode
,
request
.
getSubMerchantCode
(),
code
,
request
.
getPayChannel
(),
"0"
,
"A"
,
userBenefits
.
get
(
key
),
""
);
benefitEntity
.
setAmount
(
String
.
valueOf
(
Double
.
valueOf
(
benefitEntity
.
getAmount
())));
payDao
.
saveBenefitInfo
(
benefitEntity
);
}
// 获取支付卡号
CardEntity
cardEntityPay
=
userService
.
getCardInfo
(
request
);
payBackDto
=
quickPayJuHeZhongPay
(
userEntity
,
orderEntity
,
request
,
cardEntityPay
);
}
else
if
(
"quick_integral"
.
equals
(
request
.
getPayChannel
())){
}
else
if
(
ComCode
.
PAYCHANNEL_HL3
.
equals
(
request
.
getPayChannel
())){
OrderEntity
orderEntity
=
new
OrderEntity
(
code
,
request
.
getSubMerchantCode
(),
payNo
,
payCode
,
"quick"
,
request
.
getPayChannel
(),
"1"
,
amount
,
request
.
getSubject
(),
""
,
String
.
valueOf
(
"D"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
5
:
(
"C"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
6
:
0
)),
request
.
getCardCode
());
payDao
.
saveOrderInfo
(
orderEntity
);
// 3. 创建分润信息,并保存
Map
<
String
,
String
>
userBenefits
=
getUserBenefit
(
userEntity
,
request
);
for
(
String
key
:
userBenefits
.
keySet
())
{
String
benefitCode
=
IdGen
.
randomBase62
(
64
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
(
benefitCode
,
request
.
getSubMerchantCode
(),
code
,
request
.
getPayChannel
(),
"0"
,
"A"
,
userBenefits
.
get
(
key
),
""
);
benefitEntity
.
setAmount
(
String
.
valueOf
(
Double
.
valueOf
(
benefitEntity
.
getAmount
())));
payDao
.
saveBenefitInfo
(
benefitEntity
);
}
// 获取支付卡号
CardEntity
cardEntityPay
=
userService
.
getCardInfo
(
request
);
if
(!
"C"
.
equals
(
cardEntityPay
.
getCardType
())){
payBackDto
.
setMessage
(
"只能用信用卡支付"
);
}
else
if
(
cardEntityPay
.
getSupportPayChannel
()==
null
||
!
cardEntityPay
.
getSupportPayChannel
().
contains
(
"
quick_integral
,"
)){
}
else
if
(
cardEntityPay
.
getSupportPayChannel
()==
null
||
!
cardEntityPay
.
getSupportPayChannel
().
contains
(
"
ComCode.PAYCHANNEL_HL3
,"
)){
payBackDto
.
setMessage
(
"不支持"
+
cardEntityPay
.
getBankName
());
}
else
{
payBackDto
=
this
.
quickPayJuHeZhongIntegralPay
(
userEntity
,
orderEntity
,
request
,
cardEntityPay
);
}
}
else
{
OrderEntity
orderEntity
=
new
OrderEntity
(
code
,
request
.
getSubMerchantCode
(),
payNo
,
payCode
,
"quick"
,
ComCode
.
PAYCHANNEL_HL3
,
"1"
,
amount
,
request
.
getSubject
(),
""
,
String
.
valueOf
(
"D"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
5
:
(
"C"
.
equalsIgnoreCase
(
userEntity
.
getUserDetail
().
getCard
().
getCardType
())
?
6
:
0
)),
request
.
getCardCode
());
payDao
.
saveOrderInfo
(
orderEntity
);
// 3. 创建分润信息,并保存
Map
<
String
,
String
>
userBenefits
=
getUserBenefit
(
userEntity
,
request
);
for
(
String
key
:
userBenefits
.
keySet
())
{
String
benefitCode
=
IdGen
.
randomBase62
(
64
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
(
benefitCode
,
request
.
getSubMerchantCode
(),
code
,
request
.
getPayChannel
(),
"0"
,
"A"
,
userBenefits
.
get
(
key
),
""
);
benefitEntity
.
setAmount
(
String
.
valueOf
(
Double
.
valueOf
(
benefitEntity
.
getAmount
())));
payDao
.
saveBenefitInfo
(
benefitEntity
);
}
// 获取支付卡号
CardEntity
cardEntityPay
=
userService
.
getCardInfo
(
request
);
if
(!
"C"
.
equals
(
cardEntityPay
.
getCardType
())){
payBackDto
.
setMessage
(
"只能用信用卡支付"
);
}
else
if
(
cardEntityPay
.
getSupportPayChannel
()==
null
||
!
cardEntityPay
.
getSupportPayChannel
().
contains
(
"
quick_integral
,"
)){
}
else
if
(
cardEntityPay
.
getSupportPayChannel
()==
null
||
!
cardEntityPay
.
getSupportPayChannel
().
contains
(
"
ComCode.PAYCHANNEL_HL3
,"
)){
payBackDto
.
setMessage
(
"不支持"
+
cardEntityPay
.
getBankName
());
}
else
{
payBackDto
=
this
.
quickPayJuHeZhongIntegralPay
(
userEntity
,
orderEntity
,
request
,
cardEntityPay
);
...
...
@@ -160,7 +203,7 @@ public class PayApiService {
RateEntity
rateEntity
=
new
RateEntity
();
rateEntity
.
setUserLevel
(
userEntity
.
getLevel
());
rateEntity
.
setPayMethod
(
"quick"
);
rateEntity
.
setPayChannel
(
"quick_no_integral"
);
rateEntity
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL1
);
rateEntity
=
userService
.
getRateByLevel
(
rateEntity
);
if
(
rateEntity
!=
null
){
double
userFee
=
Long
.
parseLong
(
request
.
getAmount
())*
100
*
Double
.
valueOf
(
rateEntity
.
getRate
());
...
...
@@ -200,22 +243,31 @@ public class PayApiService {
* @throws Exception
*/
public
PayBackDto
quickPayJuHeZhongIntegralPay
(
UserEntity
userEntity
,
OrderEntity
orderEntity
,
JuHeZhongPayRequest
request
,
CardEntity
cardEntity
)
throws
Exception
{
UserRequest
userRequest
=
new
UserRequest
();
userRequest
.
setSubMerchantCode
(
request
.
getSubMerchantCode
());
userRequest
.
setBelongBank
(
userEntity
.
getUserDetail
().
getCard
().
getBelongBank
());
userRequest
.
setRealName
(
userEntity
.
getUserDetail
().
getRealName
());
userRequest
.
setCardNo
(
userEntity
.
getUserDetail
().
getCard
().
getCardNo
());
userRequest
.
setMobile
(
userEntity
.
getMobile
());
userRequest
.
setIdCard
(
userEntity
.
getUserDetail
().
getIdCard
());
userRequest
.
setCardPlace
(
userEntity
.
getUserDetail
().
getCard
().
getCardPlace
());
String
subMchId
=
userService
.
quickPayHandleJuhezhong
(
userRequest
,
""
);
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL3
);
userSubMchId
.
setUserCode
(
userEntity
.
getCode
());
userSubMchId
=
userService
.
getUserSubmchid
(
userSubMchId
);
String
subMchId
=
null
;
if
(
userSubMchId
==
null
){
UserRequest
userRequest
=
new
UserRequest
();
userRequest
.
setSubMerchantCode
(
request
.
getSubMerchantCode
());
userRequest
.
setBelongBank
(
userEntity
.
getUserDetail
().
getCard
().
getBelongBank
());
userRequest
.
setRealName
(
userEntity
.
getUserDetail
().
getRealName
());
userRequest
.
setCardNo
(
userEntity
.
getUserDetail
().
getCard
().
getCardNo
());
userRequest
.
setMobile
(
userEntity
.
getMobile
());
userRequest
.
setIdCard
(
userEntity
.
getUserDetail
().
getIdCard
());
userRequest
.
setCardPlace
(
userEntity
.
getUserDetail
().
getCard
().
getCardPlace
());
subMchId
=
userService
.
quickPayHandleJuhezhong
(
userRequest
,
""
,
userEntity
.
getLevel
());
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL3
);
userSubMchId
.
setUserCode
(
userEntity
.
getCode
());
userSubMchId
.
setSubmchid
(
subMchId
);
userService
.
addUserSubmchid
(
userSubMchId
);
}
else
{
subMchId
=
userSubMchId
.
getSubmchid
();
}
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"serviceType"
,
4
);
// 服务类型
dto
.
put
(
"orderId"
,
orderEntity
.
getPayCode
());
//订单号
dto
.
put
(
"amount"
,
Long
.
parseLong
(
request
.
getAmount
())*
100
);
//交易金额
...
...
@@ -283,6 +335,184 @@ public class PayApiService {
return
userBenefit
;
}
// HL2 通道 即JFEN 开卡
public
Response
openCardJFen
(
UserRequest
request
){
CardEntity
cardEntity
=
userService
.
getCardInfo
(
request
);
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setUserCode
(
request
.
getSubMerchantCode
());
userSubMchId
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
userSubMchId
=
userService
.
getUserSubmchid
(
userSubMchId
);
UserEntity
userEntity
=
userService
.
getUserInfo
(
request
);
UserDetailEntity
userDetailEntity
=
userService
.
getUserDetailByCode
(
request
.
getSubMerchantCode
());
RateEntity
rateEntity
=
new
RateEntity
();
rateEntity
.
setUserLevel
(
userEntity
.
getLevel
());
rateEntity
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
rateEntity
.
setPayMethod
(
"quick"
);
rateEntity
=
userService
.
getRateByLevel
(
rateEntity
);
Response
response
=
new
Response
();
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
dto
.
put
(
"merchantId"
,
ComCode
.
JFEN_MERCHANT_ID
);
dto
.
put
(
"serviceType"
,
"8"
);
dto
.
put
(
"subMchId"
,
userSubMchId
.
getSubmchid
());
dto
.
put
(
"idType"
,
"01"
);
dto
.
put
(
"idNo"
,
userDetailEntity
.
getIdCard
());
if
(
rateEntity
==
null
){
dto
.
put
(
"d0Fee"
,
"0.0043"
);
}
else
{
dto
.
put
(
"d0Fee"
,
rateEntity
.
getRate
());
}
dto
.
put
(
"accountName"
,
userDetailEntity
.
getRealName
());
dto
.
put
(
"accountNo"
,
cardEntity
.
getCardNo
());
dto
.
put
(
"mobile"
,
cardEntity
.
getCardMobile
());
dto
.
put
(
"notifyUrl"
,
Global
.
getConfig
(
"project.access.url"
)+
"/api/pay/openCardCallback"
);
dto
.
put
(
"merchantKey"
,
ComCode
.
JFEN_MERCHANT_KEY
);
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
PayBackDto
payBackDto
=
new
PayBackDto
();
try
{
JSONObject
jsonObject
=
juHeZhongPayJFenService
.
openCard
(
dto
);
if
(
"0000"
.
equals
(
jsonObject
.
get
(
"code"
))){
payBackDto
.
setUrl
(
jsonObject
.
getString
(
"url"
));
response
.
setData
(
payBackDto
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_2000
);
return
response
;
}
else
{
payBackDto
.
setUrl
(
jsonObject
.
getString
(
"url"
));
response
.
setData
(
payBackDto
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
response
.
setMessage
(
jsonObject
.
getString
(
"msg"
));
return
response
;
}
}
catch
(
Exception
e
)
{
response
.
setData
(
payBackDto
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
response
.
setMessage
(
ComCode
.
STATUS_CODE_9998_DESC
);
}
return
response
;
}
// HL2 通道 即JFEN 发送验证码 需要的参数 SubMerchantCode\amount\cardCode\PayChannel 通道\
@Transactional
(
readOnly
=
false
)
public
Response
sendMessageJFen
(
JuHeZhongPayRequest
request
){
request
.
setPayMethod
(
"quick"
);
CardEntity
cardEntity
=
userService
.
getCardInfoSwpaccid
(
request
);
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setUserCode
(
request
.
getSubMerchantCode
());
userSubMchId
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
userSubMchId
=
userService
.
getUserSubmchid
(
userSubMchId
);
UserEntity
userEntity
=
userService
.
getUserInfo
(
request
);
UserDetailEntity
userDetailEntity
=
userService
.
getUserDetailByCode
(
request
.
getSubMerchantCode
());
userEntity
.
setUserDetail
(
userDetailEntity
);
// 2. 创建支付订单信息,并保存
String
code
=
IdGen
.
randomBase62
(
64
);
String
payNo
=
ComCode
.
YYYYMMDDHHMM
.
format
(
new
Date
())
+
IdGen
.
randomBase62
(
8
);
// 订单号
String
payCode
=
IdGen
.
randomBase62
(
64
);
DecimalFormat
df
=
new
DecimalFormat
(
"######0.00"
);
String
amount
=
df
.
format
(
Double
.
valueOf
(
request
.
getAmount
()));
OrderEntity
orderEntity
=
new
OrderEntity
(
code
,
request
.
getSubMerchantCode
(),
payNo
,
payCode
,
"quick"
,
request
.
getPayChannel
(),
"1"
,
amount
,
request
.
getSubject
(),
""
,
String
.
valueOf
(
"D"
.
equalsIgnoreCase
(
userDetailEntity
.
getCard
().
getCardType
())
?
5
:
(
"C"
.
equalsIgnoreCase
(
userDetailEntity
.
getCard
().
getCardType
())
?
6
:
0
)),
request
.
getCardCode
());
payDao
.
saveOrderInfo
(
orderEntity
);
// 3. 创建分润信息,并保存
Map
<
String
,
String
>
userBenefits
=
getUserBenefit
(
userEntity
,
request
);
for
(
String
key
:
userBenefits
.
keySet
())
{
String
benefitCode
=
IdGen
.
randomBase62
(
64
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
(
benefitCode
,
request
.
getSubMerchantCode
(),
code
,
request
.
getPayChannel
(),
"0"
,
"A"
,
userBenefits
.
get
(
key
),
""
);
benefitEntity
.
setAmount
(
String
.
valueOf
(
Double
.
valueOf
(
benefitEntity
.
getAmount
())));
payDao
.
saveBenefitInfo
(
benefitEntity
);
}
Response
response
=
new
Response
();
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"orderId"
,
payCode
);
// 订单号
dto
.
put
(
"merchantId"
,
ComCode
.
JFEN_MERCHANT_ID
);
dto
.
put
(
"serviceType"
,
"4"
);
dto
.
put
(
"subMchId"
,
userSubMchId
.
getSubmchid
());
dto
.
put
(
"merchantKey"
,
ComCode
.
JFEN_MERCHANT_KEY
);
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
dto
.
put
(
"amount"
,
amount
);
dto
.
put
(
"idNo"
,
userDetailEntity
.
getIdCard
());
dto
.
put
(
"accountName"
,
userDetailEntity
.
getRealName
());
dto
.
put
(
"accountNo"
,
cardEntity
.
getCardNo
());
dto
.
put
(
"mobile"
,
cardEntity
.
getCardMobile
());
dto
.
put
(
"swpaccid"
,
cardEntity
.
getSwpaccid
());
dto
.
put
(
"notifyUrl"
,
Global
.
getConfig
(
"project.access.url"
)+
"/api/pay/openCardCallback"
);
try
{
JSONObject
jsonObject
=
juHeZhongPayJFenService
.
openCard
(
dto
);
if
(
"0000"
.
equals
(
jsonObject
.
get
(
"code"
))){
orderEntity
.
setTradeNo
(
jsonObject
.
getString
(
"trade_no"
));
payDao
.
updateOrderTradeNo
(
orderEntity
);
response
.
setData
(
orderEntity
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_2000
);
response
.
setMessage
(
ComCode
.
STATUS_CODE_2000_DESC
);
return
response
;
}
response
.
setData
(
orderEntity
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
response
.
setMessage
(
jsonObject
.
getString
(
"msg"
));
return
response
;
}
catch
(
Exception
e
)
{
response
.
setData
(
orderEntity
);
response
.
setStatus
(
ComCode
.
STATUS_CODE_9998
);
response
.
setMessage
(
ComCode
.
STATUS_CODE_9998_DESC
);
response
.
setError
(
e
.
getMessage
());
}
return
response
;
}
// HL2 通道 即JFEN 发送验证码 需要的参数 SubMerchantCode\payNo\passwd\cardCode \
@Transactional
(
readOnly
=
false
)
public
PayBackDto
jFenPayJuhezhong
(
JuHeZhongPayRequest
request
)
throws
Exception
{
request
.
setPayMethod
(
"quick"
);
CardEntity
cardEntity
=
userService
.
getCardInfoSwpaccid
(
request
);
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setUserCode
(
request
.
getSubMerchantCode
());
userSubMchId
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
userSubMchId
=
userService
.
getUserSubmchid
(
userSubMchId
);
OrderEntity
orderEntity
=
this
.
getOrder
(
request
.
getPayNo
());
PayBackDto
payBackDto
=
new
PayBackDto
();
payBackDto
.
setIsUrl
(
"0"
);
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
// 非订单号
dto
.
put
(
"merchantId"
,
ComCode
.
JFEN_MERCHANT_ID
);
// 商户号
dto
.
put
(
"serviceType"
,
"5"
);
// 操作类型 5
dto
.
put
(
"subMchId"
,
userSubMchId
.
getSubmchid
());
// 子商户号
dto
.
put
(
"merchantKey"
,
ComCode
.
JFEN_MERCHANT_KEY
);
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
dto
.
put
(
"passwd"
,
request
.
getPasswd
());
dto
.
put
(
"productName"
,
"productName"
);
dto
.
put
(
"tradeNo"
,
orderEntity
.
getTradeNo
());
dto
.
put
(
"swpaccid"
,
cardEntity
.
getSwpaccid
());
JSONObject
jsonObject
=
juHeZhongPayJFenService
.
openCard
(
dto
);
this
.
notifyPay
(
orderEntity
);
if
(
"0000"
.
equals
(
jsonObject
.
get
(
"code"
))){
payBackDto
.
setMessage
(
jsonObject
.
getString
(
"msg"
));
return
payBackDto
;
}
else
{
payBackDto
.
setMessage
(
jsonObject
.
getString
(
"msg"
));
throw
new
MyException
(
jsonObject
.
getString
(
"msg"
));
}
}
/**
* 回调
* @param orderEntity
...
...
@@ -297,7 +527,20 @@ public class PayApiService {
dto
.
setMerchantKey
(
ComCode
.
MERCHANT_KEY
);
dto
.
setTimestamp
(
System
.
currentTimeMillis
());
JSONObject
jsonObject
=
juHeZhongPayService
.
query
(
dto
);
orderEntity
=
payDao
.
getOrder
(
orderEntity
);
JSONObject
jsonObject
=
null
;
if
(
ComCode
.
PAYCHANNEL_HL3
.
equals
(
orderEntity
.
getPayChannel
())){
dto
.
setMerchantId
(
ComCode
.
INTEGRAL_MERCHANT_ID
);
dto
.
setMerchantKey
(
ComCode
.
INTEGRAL_MERCHANT_KEY
);
jsonObject
=
juHeZhongPayIntegralService
.
query
(
dto
);
}
else
if
(
ComCode
.
PAYCHANNEL_HL1
.
equals
(
orderEntity
.
getPayChannel
())){
jsonObject
=
juHeZhongPayService
.
query
(
dto
);
}
else
if
(
ComCode
.
PAYCHANNEL_HL2
.
equals
(
orderEntity
.
getPayChannel
())){
dto
.
setMerchantId
(
ComCode
.
JFEN_MERCHANT_ID
);
dto
.
setMerchantKey
(
ComCode
.
JFEN_MERCHANT_KEY
);
jsonObject
=
juHeZhongPayService
.
query
(
dto
);
}
System
.
out
.
println
(
"查询订单返回结果:"
+
jsonObject
.
toJSONString
());
// 支付成功
if
(
"0000"
.
equals
(
jsonObject
.
get
(
"code"
))){
...
...
@@ -309,7 +552,7 @@ public class PayApiService {
// benefitEntity.setOrderCode(orderEntity.getPayCode());
// benefitEntity.setBenefitStatus("1");
// payDao.updateBenefit(benefitEntity);
}
else
if
(
"0001"
.
equals
(
jsonObject
.
get
(
"code"
)))
{
// 支付失败
}
else
{
// 支付失败
orderEntity
.
setPayStatus
(
"4"
);
payDao
.
updateOrderStatus
(
orderEntity
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
();
...
...
@@ -326,13 +569,17 @@ public class PayApiService {
return
payDao
.
getOrder
(
orderEntity
);
}
public
OrderEntity
getOrder
(
String
payNo
){
OrderEntity
orderEntity
=
new
OrderEntity
();
orderEntity
.
setPayNo
(
payNo
);
return
payDao
.
getOrder
(
orderEntity
);
}
@Scheduled
(
cron
=
"*/30 * * * * ?"
)
@Transactional
(
readOnly
=
false
)
public
void
updateOrderTiming
(){
System
.
out
.
println
(
"定时任务。
。。。。"
);
// System.out.println("。。。。。。。定时任务。updateOrderTiming开始
。。。。");
OrderEntity
orderEntity
=
new
OrderEntity
();
orderEntity
.
set
Created
(
DateUtils
.
getYesterday
(
DateUtils
.
getYesterday
(
"yyyy-MM-dd HH:mm:ss"
)));
orderEntity
.
set
EndTime
(
DateUtils
.
getYesterday
(
DateUtils
.
getYesterday
(
"yyyy-MM-dd HH:mm:ss"
)));
List
<
OrderEntity
>
list
=
payDao
.
getOrderListTimeing
(
orderEntity
);
for
(
OrderEntity
order:
list
){
order
.
setPayStatus
(
"3"
);
...
...
@@ -341,5 +588,53 @@ public class PayApiService {
benefitEntity
.
setOrderCode
(
order
.
getPayCode
());
payDao
.
deleteBenefit
(
benefitEntity
);
}
// System.out.println("。。。。。。。定时任务。updateOrderTiming结束。。。。");
}
@Transactional
(
readOnly
=
false
)
public
void
updateOrders
(){
// System.out.println("。。。。。。。定时任务。updateOrders开始。。。。");
try
{
OrderEntity
orderEntity
=
new
OrderEntity
();
orderEntity
.
setStartTime
(
DateUtils
.
getYesterday
(
DateUtils
.
getYesterday
(
"yyyy-MM-dd HH:mm:ss"
)));
orderEntity
.
setEndTime
(
DateUtils
.
formatDate
(
DateUtils
.
addHours
(
new
Date
(),-
12
),
"yyyy-MM-dd HH:mm:ss"
));
List
<
OrderEntity
>
list
=
payDao
.
getOrderListTimeing
(
orderEntity
);
for
(
OrderEntity
order:
list
){
QuickDto
dto
=
new
QuickDto
();
dto
.
setOrderId
(
order
.
getPayCode
());
dto
.
setTimestamp
(
System
.
currentTimeMillis
());
JSONObject
jsonObject
=
null
;
if
(
ComCode
.
PAYCHANNEL_HL3
.
equals
(
order
.
getPayChannel
())){
dto
.
setMerchantId
(
ComCode
.
MERCHANT_ID
);
dto
.
setMerchantKey
(
ComCode
.
MERCHANT_KEY
);
jsonObject
=
juHeZhongPayIntegralService
.
query
(
dto
);
}
else
if
(
ComCode
.
PAYCHANNEL_HL1
.
equals
(
order
.
getPayChannel
())){
jsonObject
=
juHeZhongPayService
.
query
(
dto
);
}
if
(
jsonObject
!=
null
){
// System.out.println("查询订单返回结果:"+jsonObject.toJSONString());
// 支付成功
if
(
"0000"
.
equals
(
jsonObject
.
get
(
"code"
))){
System
.
out
.
println
(
"查询订单返回结果:"
+
jsonObject
.
toJSONString
());
order
.
setPayStatus
(
"2"
);
payDao
.
updateOrderStatus
(
order
);
}
else
{
// 支付失败
order
.
setPayStatus
(
"4"
);
payDao
.
updateOrderStatus
(
order
);
BenefitEntity
benefitEntity
=
new
BenefitEntity
();
benefitEntity
.
setOrderCode
(
order
.
getPayCode
());
benefitEntity
.
setDelFlag
(
"1"
);
payDao
.
deleteBenefit
(
benefitEntity
);
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// System.out.println("。。。。。。。定时任务。updateOrders结束。。。。");
}
}
src/main/java/com/thinkgem/jeesite/modules/pay/service/TimingService.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
pay
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.thinkgem.jeesite.common.constant.ComCode
;
import
com.thinkgem.jeesite.modules.pay.dao.PayApiDao
;
import
com.thinkgem.jeesite.modules.pay.entity.BenefitEntity
;
import
com.thinkgem.jeesite.modules.pay.entity.OrderEntity
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.QuickDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayIntegralService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayService
;
import
com.thinkgem.jeesite.modules.user.service.UserApiService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
@Lazy
(
false
)
public
class
TimingService
{
@Autowired
private
PayApiService
payApiService
;
@Autowired
private
JuHeZhongPayService
juHeZhongPayService
;
@Autowired
private
JuHeZhongPayIntegralService
juHeZhongPayIntegralService
;
@Scheduled
(
cron
=
"0 0 0/1 * * ?"
)
public
void
updateOrders
(){
payApiService
.
updateOrderTiming
();
payApiService
.
updateOrders
();
}
}
src/main/java/com/thinkgem/jeesite/modules/user/bean/JuHeZhongPayRequest.java
View file @
021df1c2
...
...
@@ -6,7 +6,11 @@ public class JuHeZhongPayRequest extends Request {
private
String
amount
;
// 金额
private
String
cardCode
;
// 支付卡code
private
String
subject
;
// 商品名称
private
String
payChannel
;
// 渠道 目前合众支付接口仅传入quick_no_integral quick_integral
private
String
payChannel
;
// 渠道 目前合众支付接口仅传入quick_no_integral ComCode.PAYCHANNEL_HL3
private
String
payMethod
;
//
private
String
passwd
;
// 验证码
private
String
payNo
;
// 订单号
public
String
getAmount
()
{
return
amount
;
...
...
@@ -39,4 +43,28 @@ public class JuHeZhongPayRequest extends Request {
public
void
setPayChannel
(
String
payChannel
)
{
this
.
payChannel
=
payChannel
;
}
public
String
getPayMethod
()
{
return
payMethod
;
}
public
void
setPayMethod
(
String
payMethod
)
{
this
.
payMethod
=
payMethod
;
}
public
String
getPasswd
()
{
return
passwd
;
}
public
void
setPasswd
(
String
passwd
)
{
this
.
passwd
=
passwd
;
}
public
String
getPayNo
()
{
return
payNo
;
}
public
void
setPayNo
(
String
payNo
)
{
this
.
payNo
=
payNo
;
}
}
src/main/java/com/thinkgem/jeesite/modules/user/dao/UserApiDao.java
View file @
021df1c2
...
...
@@ -83,4 +83,19 @@ public interface UserApiDao {
Level
getLevelByUserLevel
(
UserRequest
request
);
void
addUserSubmchid
(
UserSubMchId
userSubMchId
);
UserSubMchId
getUserSubmchid
(
UserSubMchId
userSubMchId
);
public
int
updateUserSubmchid
(
UserSubMchId
userSubMchId
);
public
CardEntity
getCardByCardNo
(
CardEntity
cardEntity
);
public
int
addSwpaccid
(
CardSwpaccidEntity
entity
);
public
CardSwpaccidEntity
getSwpaccid
(
CardSwpaccidEntity
cardSwpaccidEntity
);
CardEntity
getCardInfoSwpaccid
(
Request
request
);
}
src/main/java/com/thinkgem/jeesite/modules/user/entity/CardEntity.java
View file @
021df1c2
...
...
@@ -37,6 +37,8 @@ public class CardEntity extends BaseEntity implements Serializable {
private
String
supportPayChannel
;
private
String
swpaccid
;
// HL2通道 开卡唯一标识
public
CardEntity
()
{
}
...
...
@@ -221,4 +223,12 @@ public class CardEntity extends BaseEntity implements Serializable {
public
void
setSupportPayChannel
(
String
supportPayChannel
)
{
this
.
supportPayChannel
=
supportPayChannel
;
}
public
String
getSwpaccid
()
{
return
swpaccid
;
}
public
void
setSwpaccid
(
String
swpaccid
)
{
this
.
swpaccid
=
swpaccid
;
}
}
src/main/java/com/thinkgem/jeesite/modules/user/entity/CardSwpaccidEntity.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
user
.
entity
;
public
class
CardSwpaccidEntity
{
private
String
cardCode
;
private
String
payMethod
;
// 支付方式
private
String
payChannel
;
// 通道
private
String
swpaccid
;
public
String
getCardCode
()
{
return
cardCode
;
}
public
void
setCardCode
(
String
cardCode
)
{
this
.
cardCode
=
cardCode
;
}
public
String
getPayMethod
()
{
return
payMethod
;
}
public
void
setPayMethod
(
String
payMethod
)
{
this
.
payMethod
=
payMethod
;
}
public
String
getPayChannel
()
{
return
payChannel
;
}
public
void
setPayChannel
(
String
payChannel
)
{
this
.
payChannel
=
payChannel
;
}
public
String
getSwpaccid
()
{
return
swpaccid
;
}
public
void
setSwpaccid
(
String
swpaccid
)
{
this
.
swpaccid
=
swpaccid
;
}
}
src/main/java/com/thinkgem/jeesite/modules/user/entity/UserSubMchId.java
0 → 100644
View file @
021df1c2
package
com
.
thinkgem
.
jeesite
.
modules
.
user
.
entity
;
public
class
UserSubMchId
{
private
String
userCode
;
private
String
submchid
;
private
String
payChannel
;
public
String
getUserCode
()
{
return
userCode
;
}
public
void
setUserCode
(
String
userCode
)
{
this
.
userCode
=
userCode
;
}
public
String
getSubmchid
()
{
return
submchid
;
}
public
void
setSubmchid
(
String
submchid
)
{
this
.
submchid
=
submchid
;
}
public
String
getPayChannel
()
{
return
payChannel
;
}
public
void
setPayChannel
(
String
payChannel
)
{
this
.
payChannel
=
payChannel
;
}
}
src/main/java/com/thinkgem/jeesite/modules/user/service/UserApiService.java
View file @
021df1c2
...
...
@@ -10,6 +10,7 @@ import com.thinkgem.jeesite.modules.commonError.MyException;
import
com.thinkgem.jeesite.modules.message.MessageUtils
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.dto.MerchantDto
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayIntegralService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayJFenService
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayService
;
import
com.thinkgem.jeesite.modules.pay.entity.RateEntity
;
import
com.thinkgem.jeesite.modules.pay.juhezhong.utils.MakeOrderNum
;
...
...
@@ -19,6 +20,7 @@ import com.thinkgem.jeesite.modules.user.dao.UserApiDao;
import
com.thinkgem.jeesite.modules.user.entity.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -35,7 +37,8 @@ import java.util.List;
* 前端用户相关
*/
@Service
@Transactional
(
readOnly
=
true
)
@Lazy
(
false
)
@Transactional
public
class
UserApiService
{
@Autowired
...
...
@@ -46,6 +49,9 @@ public class UserApiService {
@Autowired
private
JuHeZhongPayIntegralService
juHeZhongPayIntegralService
;
@Autowired
private
JuHeZhongPayJFenService
juHeZhongPayJFenService
;
public
UserEntity
getUserInfo
(
Request
request
)
{
UserEntity
user
=
userDao
.
getUserInfo
(
request
);
// 以下两行代码应Android要求,增加空detail和card
...
...
@@ -184,6 +190,12 @@ public class UserApiService {
return
entity
;
}
public
CardEntity
getCardInfoSwpaccid
(
Request
request
)
{
CardEntity
entity
=
userDao
.
getCardInfoSwpaccid
(
request
);
return
entity
;
}
@Transactional
(
readOnly
=
false
)
public
void
removeCards
(
UserRequest
request
)
{
userDao
.
removeCards
(
request
);
...
...
@@ -214,6 +226,7 @@ public class UserApiService {
return
userDao
.
getAboutUsInfo
(
request
);
}
// 实名认证
@Transactional
(
readOnly
=
false
)
public
void
certification
(
UserRequest
request
)
throws
MyException
,
Exception
{
// 更新用户详情
...
...
@@ -227,18 +240,23 @@ public class UserApiService {
String
type
=
"1"
;
// 默认将卡片添加为对私
String
status
=
"0"
;
// 新增卡片审核状态均为未审核
String
subMerchantId
=
null
;
//registJuHeZhongPay(request, type);
// String subMerchantId = quickPayHandleJuhezhong(request,type);
submitPayTest
(
subMerchantId
);
// 更新银行卡详情
CardEntity
cardStatusEntity
=
new
CardEntity
(
request
.
getSubMerchantCode
(),
"N"
);
userDao
.
updateCardStatus
(
cardStatusEntity
);
CardEntity
cardEntity
=
new
CardEntity
(
IdGen
.
randomBase62
(
64
),
request
.
getSubMerchantCode
(),
"D"
,
request
.
getCardNo
(),
request
.
getCardMobile
(),
request
.
getBelongBank
(),
request
.
getCardBank
(),
request
.
getCardPlace
(),
"Y"
,
subMerchantId
,
request
.
getCardSrc
().
replace
(
Global
.
getConfig
(
"sys.pre.url"
),
""
),
type
,
status
,
request
.
getProvince
(),
request
.
getCity
());
userDao
.
addNewCard
(
cardEntity
);
// 更新用户状态
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
setCode
(
request
.
getSubMerchantCode
());
userEntity
.
setStatus
(
"1"
);
userDao
.
updateUserInfo
(
userEntity
);
// 查询与实名用户相同推荐人的信息
UserEntity
queryUserRecommendEntity
=
new
UserEntity
(
request
.
getSubMerchantCode
());
List
<
UserEntity
>
countRecommend
=
userDao
.
getUserInfoBySameRecommend
(
queryUserRecommendEntity
);
...
...
@@ -249,14 +267,108 @@ public class UserApiService {
recommendedUser
.
setLevel
(
"D"
);
// 实名用户的推荐人等级由E(青铜)升为D(白银)
userDao
.
updateUserLevel
(
recommendedUser
);
// 修改实名用户推荐人的银行卡费率
// RateEntity rateEntityParam = new RateEntity("D", "quick",);
// RateEntity rateEntity = userDao.getRateByLevel(rateEntityParam);
// List<CardEntity> recommendCards = userDao.getRecommendCardsInfo(recommendedUser);
// for (CardEntity entity : recommendCards) {
// updateRateJuHeZhongPay(entity, rateEntity);
// }
RateEntity
rateEntityParam
=
new
RateEntity
();
rateEntityParam
.
setUserLevel
(
"D"
);
List
<
RateEntity
>
list
=
userDao
.
getRateListByLevel
(
rateEntityParam
);
for
(
RateEntity
rateEntity:
list
){
if
(
ComCode
.
PAYCHANNEL_HL3
.
equals
(
rateEntity
.
getPayChannel
())){
String
subMchId
=
this
.
quickPayHandleJuhezhong
(
request
,
""
,
"D"
);
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setSubmchid
(
subMchId
);
userSubMchId
.
setUserCode
(
recommendedUser
.
getCode
());
userSubMchId
.
setPayChannel
(
rateEntity
.
getPayChannel
());
int
row
=
this
.
updateUserSubmchid
(
userSubMchId
);
if
(
row
==
0
){
this
.
addUserSubmchid
(
userSubMchId
);
}
}
else
if
(
ComCode
.
PAYCHANNEL_HL2
.
equals
(
rateEntity
.
getPayChannel
())){
UserSubMchId
userSubMchId
=
new
UserSubMchId
();
userSubMchId
.
setUserCode
(
recommendedUser
.
getCode
());
userSubMchId
.
setPayChannel
(
rateEntity
.
getPayChannel
());
UserSubMchId
userSubMchIdQuery
=
userDao
.
getUserSubmchid
(
userSubMchId
);
// 如果推荐人的 quick_jfen 通道下的 subMchId 是空 则该通道下先注册
if
(
userSubMchIdQuery
==
null
){
recommendedUser
=
this
.
getUserDetailInfo
(
recommendedUser
);
JSONObject
dto
=
new
JSONObject
();
String
orderId
=
MakeOrderNum
.
makeOrderNum
();
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
dto
.
put
(
"serviceType"
,
1
);
dto
.
put
(
"subMerchantName"
,
recommendedUser
.
getUserDetail
().
getRealName
()+
orderId
);
dto
.
put
(
"subMerchantType"
,
"PERSON"
);
dto
.
put
(
"businessLicense"
,
recommendedUser
.
getUserDetail
().
getRealName
()+
orderId
);
dto
.
put
(
"legalPersonName"
,
recommendedUser
.
getUserDetail
().
getRealName
());
dto
.
put
(
"legalPersonID"
,
recommendedUser
.
getUserDetail
().
getIdCard
());
dto
.
put
(
"subMerchantPersonName"
,
recommendedUser
.
getUserDetail
().
getRealName
());
dto
.
put
(
"subMerchantPersonPhone"
,
recommendedUser
.
getMobile
());
dto
.
put
(
"bankType"
,
"TOPRIVATE"
);
dto
.
put
(
"accountName"
,
recommendedUser
.
getUserDetail
().
getRealName
());
dto
.
put
(
"accountNo"
,
recommendedUser
.
getUserDetail
().
getCard
().
getCardNo
());
dto
.
put
(
"bankName"
,
recommendedUser
.
getUserDetail
().
getCard
().
getBankName
());
dto
.
put
(
"bankProv"
,
recommendedUser
.
getUserDetail
().
getCard
().
getProvince
());
dto
.
put
(
"bankCity"
,
recommendedUser
.
getUserDetail
().
getCard
().
getCity
());
dto
.
put
(
"bankBranch"
,
recommendedUser
.
getUserDetail
().
getCard
().
getCardPlace
());
dto
.
put
(
"bankCode"
,
recommendedUser
.
getUserDetail
().
getCard
().
getBelongBank
());
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
JSONObject
jsonObject
=
juHeZhongPayJFenService
.
merchantIn
(
dto
);
if
(!
"0000"
.
equals
(
jsonObject
.
getString
(
"code"
)))
{
throw
new
MyException
(
jsonObject
.
getString
(
"msg"
));
}
String
subMchId
=
jsonObject
.
getString
(
"subMchId"
);
rateEntity
.
setServiceType
(
"0"
);
// 添加费率
this
.
merchantFeelJFen
(
subMchId
,
rateEntity
);
}
else
{
// 修改费率
rateEntity
.
setServiceType
(
"0"
);
this
.
merchantFeelJFen
(
userSubMchId
.
getSubmchid
(),
rateEntity
);
}
}
else
if
(
""
.
equals
(
rateEntity
.
getPayChannel
())){
}
}
}
/* 实名认证用户 商户入网 和 添加对应的费率 开始*/
UserEntity
userEntityRequest
=
this
.
getUserInfo
(
request
);
RateEntity
rate
=
new
RateEntity
();
rate
.
setUserLevel
(
userEntityRequest
.
getLevel
());
UserSubMchId
userSubMchIdRequest
=
new
UserSubMchId
();
userSubMchIdRequest
.
setUserCode
(
request
.
getSubMerchantCode
());
// ComCode.PAYCHANNEL_HL3 商户入网
String
inregralSubMchId
=
this
.
quickPayHandleJuhezhong
(
request
,
""
,
userEntityRequest
.
getLevel
());
userSubMchIdRequest
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL3
);
userSubMchIdRequest
.
setSubmchid
(
inregralSubMchId
);
this
.
addUserSubmchid
(
userSubMchIdRequest
);
// 加添费率
this
.
quickPayHandleJuhezhong
(
request
,
""
,
userEntityRequest
.
getLevel
());
// JFen 商户入网 + 添加费率
String
JFenSubMchId
=
this
.
merchantInJFenJuhezhong
(
request
);
userSubMchIdRequest
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
userSubMchIdRequest
.
setSubmchid
(
inregralSubMchId
);
this
.
addUserSubmchid
(
userSubMchIdRequest
);
rate
.
setPayChannel
(
ComCode
.
PAYCHANNEL_HL2
);
RateEntity
rateEntity
=
this
.
getRateByLevel
(
rate
);
rateEntity
.
setServiceType
(
"0"
);
// 添加费率
this
.
merchantFeelJFen
(
JFenSubMchId
,
rateEntity
);
/* 实名认证用户 商户入网 和 添加对应的费率 结束*/
}
public
List
<
ProvinceCityEntity
>
getProvinceCity
(
UserRequest
request
)
{
...
...
@@ -273,6 +385,7 @@ public class UserApiService {
return
userDao
.
getBelongBank
(
request
);
}
// 改变结算卡
@Transactional
(
readOnly
=
false
)
public
void
changeDebit
(
UserRequest
request
)
throws
MyException
,
Exception
{
// 将该用户的所有卡类型置为非结算卡
...
...
@@ -289,7 +402,7 @@ public class UserApiService {
*/
/**
* 注册JuHeZhong支付用户
* 注册JuHeZhong支付用户
无积分
*
* @param request
* @param type
...
...
@@ -332,14 +445,12 @@ public class UserApiService {
return
jsonObject
.
getString
(
"subMchId"
);
}
public
String
quickPayHandleJuhezhong
(
UserRequest
request
,
String
type
)
throws
MyException
,
Exception
{
UserEntity
userEntity
=
userDao
.
getUserInfo
(
request
);
// 积分 商户入网
public
String
quickPayHandleJuhezhong
(
UserRequest
request
,
String
type
,
String
level
)
throws
MyException
,
Exception
{
BelongBankEntity
belongBankEntity
=
userDao
.
getBelongBankEntity
(
request
);
if
(
userEntity
==
null
)
{
throw
new
MyException
(
"用户信息为空"
);
}
// UserDetailEntity userDetailEntity = userDao.getUserDetailByCode(userEntity);
RateEntity
rateEntityParam
=
new
RateEntity
(
userEntity
.
getLevel
(),
"quick"
,
"quick_integral"
);
RateEntity
rateEntityParam
=
new
RateEntity
(
level
,
"quick"
,
ComCode
.
PAYCHANNEL_HL3
);
RateEntity
rateEntity
=
userDao
.
getRateByLevel
(
rateEntityParam
);
if
(
rateEntity
==
null
)
{
throw
new
MyException
(
"费率等级信息为空"
);
...
...
@@ -361,7 +472,7 @@ public class UserApiService {
dto
.
put
(
"mobile"
,
request
.
getMobile
());
dto
.
put
(
"idNo"
,
request
.
getIdCard
());
//身份证号
dto
.
put
(
"settleType"
,
rateEntity
.
getRate
());
//费率类型 795934
dto
.
put
(
"settleType"
,
rateEntity
.
getRate
Type
());
//费率类型 795934
dto
.
put
(
"address"
,
request
.
getCardPlace
());
//地址
dto
.
put
(
"merchantKey"
,
ComCode
.
INTEGRAL_MERCHANT_KEY
);
//商户key
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
//时间戳
...
...
@@ -375,6 +486,54 @@ public class UserApiService {
// JFen 商户入网
public
String
merchantInJFenJuhezhong
(
UserRequest
request
)
throws
MyException
,
Exception
{
UserEntity
userEntity
=
userDao
.
getUserInfo
(
request
);
BelongBankEntity
belongBankEntity
=
userDao
.
getBelongBankEntity
(
request
);
if
(
userEntity
==
null
)
{
throw
new
MyException
(
"用户信息为空"
);
}
// UserDetailEntity userDetailEntity = userDao.getUserDetailByCode(userEntity);
RateEntity
rateEntityParam
=
new
RateEntity
(
userEntity
.
getLevel
(),
"quick"
,
ComCode
.
PAYCHANNEL_HL3
);
RateEntity
rateEntity
=
userDao
.
getRateByLevel
(
rateEntityParam
);
if
(
rateEntity
==
null
)
{
throw
new
MyException
(
"费率等级信息为空"
);
}
JSONObject
dto
=
new
JSONObject
();
String
orderId
=
MakeOrderNum
.
makeOrderNum
();
dto
.
put
(
"orderId"
,
MakeOrderNum
.
makeOrderNum
());
dto
.
put
(
"serviceType"
,
1
);
dto
.
put
(
"subMerchantName"
,
request
.
getRealName
()+
orderId
);
dto
.
put
(
"subMerchantType"
,
"PERSON"
);
dto
.
put
(
"businessLicense"
,
request
.
getRealName
()+
orderId
);
dto
.
put
(
"legalPersonName"
,
request
.
getRealName
());
dto
.
put
(
"legalPersonID"
,
request
.
getIdCard
());
dto
.
put
(
"subMerchantPersonName"
,
request
.
getRealName
());
dto
.
put
(
"subMerchantPersonPhone"
,
request
.
getMobile
());
dto
.
put
(
"bankType"
,
"TOPRIVATE"
);
dto
.
put
(
"accountName"
,
request
.
getRealName
());
dto
.
put
(
"accountNo"
,
request
.
getCardNo
());
dto
.
put
(
"bankName"
,
belongBankEntity
.
getBankName
());
dto
.
put
(
"bankProv"
,
request
.
getProvince
());
dto
.
put
(
"bankCity"
,
request
.
getCity
());
dto
.
put
(
"bankBranch"
,
request
.
getCardPlace
());
dto
.
put
(
"bankCode"
,
request
.
getBelongBank
());
dto
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
JSONObject
jsonObject
=
juHeZhongPayJFenService
.
merchantIn
(
dto
);
if
(!
"0000"
.
equals
(
jsonObject
.
getString
(
"code"
)))
{
throw
new
MyException
(
jsonObject
.
getString
(
"msg"
));
}
return
jsonObject
.
getString
(
"subMchId"
);
}
public
void
submitPayTest
(
String
subMchId
)
throws
Exception
{
JSONObject
dto
=
new
JSONObject
();
...
...
@@ -391,7 +550,31 @@ public class UserApiService {
}
}
/**
* JuHeZhong支付用户费率
* @param rateEntity
* @return
* @throws MyException
* @throws Exception
*/
public
void
merchantFeelJFen
(
String
subMchId
,
RateEntity
rateEntity
)
throws
MyException
,
Exception
{
// 修改费率
JSONObject
dto
=
new
JSONObject
();
dto
.
put
(
"subMchId"
,
subMchId
);
dto
.
put
(
"paymentType"
,
"QUICKPAY"
);
dto
.
put
(
"d0Fee"
,
rateEntity
.
getRate
());
dto
.
put
(
"d1Fee"
,
rateEntity
.
getRate
());
JSONObject
jsonObject
=
null
;
if
(
"1"
.
equals
(
rateEntity
.
getServiceType
())){
jsonObject
=
juHeZhongPayJFenService
.
merchantModifyFeel
(
dto
);
}
else
{
jsonObject
=
juHeZhongPayJFenService
.
merchantAddFeel
(
dto
);
}
if
(!
"0000"
.
equals
(
jsonObject
.
getString
(
"code"
)))
{
throw
new
MyException
(
jsonObject
.
getString
(
"msg"
));
}
}
/**
* 修改JuHeZhong支付用户费率
...
...
@@ -455,6 +638,11 @@ public class UserApiService {
return
userDao
.
getDebitCardByUserCode
(
request
);
}
public
CardEntity
getDebitCardByUserCode
(
String
code
){
UserRequest
request
=
new
UserRequest
();
request
.
setSubMerchantCode
(
code
);
return
userDao
.
getDebitCardByUserCode
(
request
);
}
@Transactional
(
readOnly
=
false
)
...
...
@@ -473,4 +661,42 @@ public class UserApiService {
return
userDao
.
getLevelByUserLevel
(
request
);
}
public
void
addUserSubmchid
(
UserSubMchId
userSubMchId
){
userDao
.
addUserSubmchid
(
userSubMchId
);
}
public
UserSubMchId
getUserSubmchid
(
UserSubMchId
userSubMchId
){
return
userDao
.
getUserSubmchid
(
userSubMchId
);
}
public
int
updateUserSubmchid
(
UserSubMchId
userSubMchId
){
return
userDao
.
updateUserSubmchid
(
userSubMchId
);
}
public
BelongBankEntity
getBelongBankEntity
(
String
belongBank
){
UserRequest
request
=
new
UserRequest
();
request
.
setBelongBank
(
belongBank
);
return
userDao
.
getBelongBankEntity
(
request
);
}
public
CardEntity
getCardByCardNo
(
String
cardNo
){
CardEntity
cardEntity
=
new
CardEntity
();
cardEntity
.
setCardNo
(
cardNo
);
return
userDao
.
getCardByCardNo
(
cardEntity
);
}
public
int
addSwpaccid
(
CardSwpaccidEntity
entity
){
return
userDao
.
addSwpaccid
(
entity
);
}
public
CardSwpaccidEntity
getSwpaccid
(
CardSwpaccidEntity
cardSwpaccidEntity
){
return
userDao
.
getSwpaccid
(
cardSwpaccidEntity
);
}
public
UserDetailEntity
getUserDetailByCode
(
String
userCode
){
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
setCode
(
userCode
);
return
userDao
.
getUserDetailByCode
(
userEntity
);
}
}
src/main/resources/mappings/modules/pay/PayApiDao.xml
View file @
021df1c2
...
...
@@ -8,6 +8,7 @@
user_code,
pay_no,
pay_code,
pay_method,
pay_channel,
pay_status,
amount,
...
...
@@ -17,7 +18,7 @@
card_code,
create_by,
update_by
) VALUES (#{code}, #{userCode}, #{payNo}, #{payCode}, #{payChannel}, #{payStatus}, #{amount}, #{subject}, #{tradeNo}, #{payType}, #{cardCode}, #{createdUser}, #{modifiedUser})
) VALUES (#{code}, #{userCode}, #{payNo}, #{payCode},
#{payMethod},
#{payChannel}, #{payStatus}, #{amount}, #{subject}, #{tradeNo}, #{payType}, #{cardCode}, #{createdUser}, #{modifiedUser})
</insert>
<update
id=
"updateOrderStatus"
>
UPDATE youka_orders
...
...
@@ -25,6 +26,13 @@
WHERE pay_code = #{payCode}
</update>
<update
id=
"updateOrderTradeNo"
>
UPDATE youka_orders
SET trade_no = #{tradeNo}
WHERE pay_code = #{payCode}
</update>
<select
id=
"getCDEUsers"
resultType=
"com.thinkgem.jeesite.modules.pay.entity.UserRateEntity"
>
SELECT
yu.code AS userCode,
...
...
@@ -69,6 +77,7 @@
pay_no,
pay_code,
pay_channel,
pay_method,
pay_status,
amount,
subject,
...
...
@@ -95,9 +104,16 @@
card_code
FROM youka_orders
WHERE pay_status = 1
AND create_date
<
= #{create}
<if
test=
"endTime != null and endTime != ''"
>
AND create_date
<
= #{endTime}
</if>
<if
test=
"startTime != null and startTime != ''"
>
AND create_date >= #{startTime}
</if>
AND del_flag = 0
</select>
<select
id=
"getBenefitSum"
resultType=
"com.thinkgem.jeesite.modules.pay.entity.BenefitEntity"
>
SELECT
SUM(amount) AS amount
...
...
src/main/resources/mappings/modules/user/UserDao.xml
View file @
021df1c2
...
...
@@ -286,6 +286,47 @@
LIMIT 1
</select>
<select
id=
"getCardInfoSwpaccid"
resultType=
"com.thinkgem.jeesite.modules.user.entity.CardEntity"
>
SELECT
yc.id,
yc.code,
yc.user_code AS userCode,
yc.card_type AS cardType,
yc.card_no AS cardNo,
yc.card_mobile AS cardMobile,
yc.belong_bank AS belongBank,
yb.bank_name AS bankName,
yb.bank_short AS bankShort,
yb.support_pay_channel AS supportPayChannel,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
yc.update_by AS modifiedUser,
yc.del_flag AS delFlag,
ycs.swpaccid
FROM
youka_cards yc
LEFT JOIN youka_bank yb ON yc.belong_bank = yb.bank_code
LEFT JOIN youka_card_swpaccid ON ycs.card_code = yc.code
WHERE
yc.user_code = #{subMerchantCode}
AND yc.code = #{cardCode}
AND yc.del_flag = '0'
AND ycs.pay_method = #{payMethod}
AND ycs.pay_channel = #{payChannel}
LIMIT 1
</select>
<update
id=
"removeCards"
>
UPDATE
youka_cards
...
...
@@ -425,6 +466,7 @@
yr.pay_method AS payMethod,
yr.pay_channel AS payChannel,
yr.rate,
yr.rate_type,
yr.balance,
yr.single_limit AS singleLimit,
yr.day_limit AS dayLimit,
...
...
@@ -695,5 +737,89 @@
WHERE
yl.`level` = #{level}
</select>
<insert
id=
"addUserSubmchid"
>
insert into youka_user_submchid(
user_code,
pay_channel,
submchid
) VALUES(
#{userCode},
#{payChannel},
#{submchid}
)
</insert>
<update
id=
"updateUserSubmchid"
>
UPDATE youka_user_submchid SET submchid = #{submchid}
WHERE user_code = #{userCode}
AND pay_channel = #{payChannel}
</update>
<select
id=
"getUserSubmchid"
resultType=
"com.thinkgem.jeesite.modules.user.entity.UserSubMchId"
>
SELECT
user_code,
pay_channel,
submchid
FROM youka_user_submchid
WHERE user_code = #{userCode}
AND pay_channel = #{payChannel}
</select>
<select
id=
"getDebitCardByUserCode"
resultType=
"com.thinkgem.jeesite.modules.user.entity.CardEntity"
>
SELECT
yc.id,
yc.code,
yc.user_code AS userCode,
yc.card_type AS cardType,
yc.card_no AS cardNo,
yc.card_mobile AS cardMobile,
yc.belong_bank AS belongBank,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
yc.update_by AS modifiedUser,
yc.del_flag AS delFlag
FROM
youka_cards yc
WHERE
yc.card_no = #{cardNo}
</select>
<insert
id=
"addSwpaccid"
>
INSERT INTO youka_card_swpaccid(
card_code,
pay_method,
pay_channel,
swpaccid
)VALUES(
#{cardCode},
#{payMethod},
#{payChannel},
#{swpaccid}
)
</insert>
<select
id=
"getSwpaccid"
resultType=
"com.thinkgem.jeesite.modules.user.entity.CardSwpaccidEntity"
>
SELECT
card_code,
pay_method,
pay_channel,
swpaccid
FROM youka_card_swpaccid
WHEN card_code = #{cardCode}
AND pay_method = #{payMethod}
AND pay_channel = #{payChannel}
</select>
</mapper>
\ No newline at end of file
src/main/resources/youka.properties
View file @
021df1c2
...
...
@@ -109,7 +109,22 @@ logo.bank.url=https://apimg.alipay.com/combo.png?d=cashier&t=
## 快捷支付相关
pay.y
=
0
## 无积分
pay.settle.type
=
177631
pay.merchant_id
=
100532502195879
pay.merchant.key
=
670993bf-dd22-4464-9d81-69595d36b794
pay.merchant.secret
=
289ada73-27db-49e0-b2ad-3ae1613a665a
## 积分 对应通道C-HL3
pay.integral.merchant_id
=
100532502191215
pay.integral.merchant.key
=
781ed0d6-9657-404c-9f91-79eff2e0b782
pay.integral.merchant.secret
=
0033fc8d-161b-4e97-87de-efed7a34bdea
## jfen 对应通道C-HL2
pay.jfen.merchant_id
=
100532502198424
pay.jfen.merchant.key
=
260a7539-6a2b-410d-aeec-9897ccee92a1
pay.jfen.merchant.secret
=
9ad18861-24b3-4904-a2c3-c4401f6f60f3
## 短信相关
message.username
=
710047
...
...
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