Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
c2ba63b1
"litemall-os-api/src/main/vscode:/vscode.git/clone" did not exist on "691ac1cbd3b2dc7160acdac1be2a9a4a38cf0778"
Commit
c2ba63b1
authored
Oct 25, 2017
by
jmdhappy
Browse files
优化boot版本代码结构
parent
032d9db0
Changes
17
Hide whitespace changes
Inline
Side-by-side
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/Notify4AliPayController.java
View file @
c2ba63b1
...
...
@@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.xxpay.boot.
web.
NotifyPayService
;
import
org.xxpay.boot.
service.I
NotifyPayService
;
import
org.xxpay.common.constant.PayConstant
;
import
org.xxpay.common.util.MyLog
;
...
...
@@ -28,7 +28,7 @@ public class Notify4AliPayController {
private
static
final
MyLog
_log
=
MyLog
.
getLog
(
Notify4AliPayController
.
class
);
@Autowired
private
NotifyPayService
notifyPayService
;
private
I
NotifyPayService
notifyPayService
;
/**
* 支付宝移动支付后台通知响应
...
...
@@ -69,7 +69,7 @@ public class Notify4AliPayController {
_log
.
error
(
"{}请求参数为空"
,
logPrefix
);
return
PayConstant
.
RETURN_ALIPAY_VALUE_FAIL
;
}
return
notifyPayService
.
do
AliPayNotify
(
params
);
return
notifyPayService
.
handle
AliPayNotify
(
params
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/Notify4WxPayController.java
View file @
c2ba63b1
...
...
@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.xxpay.boot.
web.
NotifyPayService
;
import
org.xxpay.boot.
service.I
NotifyPayService
;
import
org.xxpay.common.util.MyLog
;
import
javax.servlet.ServletException
;
...
...
@@ -25,7 +25,7 @@ public class Notify4WxPayController {
private
static
final
MyLog
_log
=
MyLog
.
getLog
(
Notify4WxPayController
.
class
);
@Autowired
private
NotifyPayService
notifyPayService
;
private
I
NotifyPayService
notifyPayService
;
/**
* 微信支付(统一下单接口)后台通知响应
...
...
@@ -48,7 +48,7 @@ public class Notify4WxPayController {
String
logPrefix
=
"【微信支付回调通知】"
;
String
xmlResult
=
IOUtils
.
toString
(
request
.
getInputStream
(),
request
.
getCharacterEncoding
());
_log
.
info
(
"{}通知请求数据:reqStr={}"
,
logPrefix
,
xmlResult
);
return
notifyPayService
.
do
WxPayNotify
(
xmlResult
);
return
notifyPayService
.
handle
WxPayNotify
(
xmlResult
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/PayOrderController.java
View file @
c2ba63b1
...
...
@@ -8,9 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.xxpay.boot.
web.
MchInfoService
;
import
org.xxpay.boot.
web.
PayChannelService
;
import
org.xxpay.boot.
web.
PayOrderService
;
import
org.xxpay.boot.
service.I
MchInfoService
;
import
org.xxpay.boot.
service.I
PayChannelService
;
import
org.xxpay.boot.
service.I
PayOrderService
;
import
org.xxpay.common.constant.PayConstant
;
import
org.xxpay.common.util.MyLog
;
import
org.xxpay.common.util.MySeq
;
...
...
@@ -29,13 +29,13 @@ public class PayOrderController {
private
final
MyLog
_log
=
MyLog
.
getLog
(
PayOrderController
.
class
);
@Autowired
private
PayOrderService
payOrderService
;
private
I
PayOrderService
payOrderService
;
@Autowired
private
PayChannelService
payChannelService
;
private
I
PayChannelService
payChannelService
;
@Autowired
private
MchInfoService
mchInfoService
;
private
I
MchInfoService
mchInfoService
;
/**
* 统一下单接口:
...
...
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/QueryPayOrderController.java
View file @
c2ba63b1
...
...
@@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.xxpay.boot.
web.
MchInfoService
;
import
org.xxpay.boot.
web.
PayOrderService
;
import
org.xxpay.boot.
service.I
MchInfoService
;
import
org.xxpay.boot.
service.I
PayOrderService
;
import
org.xxpay.common.constant.PayConstant
;
import
org.xxpay.common.util.MyLog
;
import
org.xxpay.common.util.XXPayUtil
;
...
...
@@ -27,10 +27,10 @@ public class QueryPayOrderController {
private
final
MyLog
_log
=
MyLog
.
getLog
(
QueryPayOrderController
.
class
);
@Autowired
private
PayOrderService
payOrderService
;
private
I
PayOrderService
payOrderService
;
@Autowired
private
MchInfoService
mchInfoService
;
private
I
MchInfoService
mchInfoService
;
/**
* 查询支付订单接口:
...
...
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/IMchInfoService.java
View file @
c2ba63b1
package
org.xxpay.boot.service
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Map
;
/**
...
...
@@ -11,4 +13,6 @@ public interface IMchInfoService {
Map
selectMchInfo
(
String
jsonParam
);
JSONObject
getByMchId
(
String
mchId
);
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/INotifyPayService.java
View file @
c2ba63b1
...
...
@@ -14,4 +14,8 @@ public interface INotifyPayService {
Map
doWxPayNotify
(
String
jsonParam
);
Map
sendBizPayNotify
(
String
jsonParam
);
String
handleAliPayNotify
(
Map
params
);
String
handleWxPayNotify
(
String
xmlResult
);
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/IPayChannelService.java
View file @
c2ba63b1
package
org.xxpay.boot.service
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Map
;
/**
...
...
@@ -11,4 +13,5 @@ public interface IPayChannelService {
Map
selectPayChannel
(
String
jsonParam
);
JSONObject
getByMchIdAndChannelId
(
String
mchId
,
String
channelId
);
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/IPayOrderService.java
View file @
c2ba63b1
package
org.xxpay.boot.service
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Map
;
/**
...
...
@@ -25,4 +27,12 @@ public interface IPayOrderService {
Map
updateNotify
(
String
jsonParam
);
int
createPayOrder
(
JSONObject
payOrder
);
JSONObject
queryPayOrder
(
String
mchId
,
String
payOrderId
,
String
mchOrderNo
,
String
executeNotify
);
String
doWxPayReq
(
String
tradeType
,
JSONObject
payOrder
,
String
resKey
);
String
doAliPayReq
(
String
channelId
,
JSONObject
payOrder
,
String
resKey
);
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/impl/MchInfoServiceImpl.java
View file @
c2ba63b1
package
org.xxpay.boot.service.impl
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.boot.service.BaseService
;
import
org.xxpay.boot.service.IMchInfoService
;
...
...
@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil;
import
org.xxpay.common.util.RpcUtil
;
import
org.xxpay.dal.dao.model.MchInfo
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
...
...
@@ -41,4 +43,14 @@ public class MchInfoServiceImpl extends BaseService implements IMchInfoService {
String
jsonResult
=
JsonUtil
.
object2Json
(
mchInfo
);
return
RpcUtil
.
createBizResult
(
baseParam
,
jsonResult
);
}
public
JSONObject
getByMchId
(
String
mchId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"mchId"
,
mchId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
selectMchInfo
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
return
JSONObject
.
parseObject
(
s
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/impl/NotifyPayServiceImpl.java
View file @
c2ba63b1
...
...
@@ -290,5 +290,26 @@ public class NotifyPayServiceImpl extends Notify4BasePay implements INotifyPaySe
return
true
;
}
public
String
handleAliPayNotify
(
Map
params
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"params"
,
params
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
doAliPayNotify
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
PayConstant
.
RETURN_ALIPAY_VALUE_FAIL
;
}
return
s
;
}
public
String
handleWxPayNotify
(
String
xmlResult
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"xmlResult"
,
xmlResult
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
// 返回给微信的数据格式已经有service处理(包括正确与错误),肯定会返回result
Map
<
String
,
Object
>
result
=
doWxPayNotify
(
jsonParam
);
return
RpcUtil
.
mkRet
(
result
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/impl/PayChannelServiceImpl.java
View file @
c2ba63b1
package
org.xxpay.boot.service.impl
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.boot.service.BaseService
;
import
org.xxpay.boot.service.IPayChannelService
;
...
...
@@ -11,6 +12,7 @@ import org.xxpay.common.util.ObjectValidUtil;
import
org.xxpay.common.util.RpcUtil
;
import
org.xxpay.dal.dao.model.PayChannel
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
...
...
@@ -42,4 +44,15 @@ public class PayChannelServiceImpl extends BaseService implements IPayChannelSer
String
jsonResult
=
JsonUtil
.
object2Json
(
payChannel
);
return
RpcUtil
.
createBizResult
(
baseParam
,
jsonResult
);
}
public
JSONObject
getByMchIdAndChannelId
(
String
mchId
,
String
channelId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"channelId"
,
channelId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
selectPayChannel
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
return
JSONObject
.
parseObject
(
s
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/service/impl/PayOrderServiceImpl.java
View file @
c2ba63b1
package
org.xxpay.boot.service.impl
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.boot.service.
BaseService
;
import
org.xxpay.
boot.service.IPayOrderService
;
import
org.xxpay.boot.service.
*
;
import
org.xxpay.
common.constant.PayConstant
;
import
org.xxpay.common.domain.BaseParam
;
import
org.xxpay.common.enumm.RetEnum
;
import
org.xxpay.common.util.*
;
import
org.xxpay.dal.dao.model.PayOrder
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
...
...
@@ -21,6 +24,100 @@ public class PayOrderServiceImpl extends BaseService implements IPayOrderService
private
static
final
MyLog
_log
=
MyLog
.
getLog
(
PayOrderServiceImpl
.
class
);
@Autowired
private
INotifyPayService
notifyPayService
;
@Autowired
private
IPayChannel4WxService
payChannel4WxService
;
@Autowired
private
IPayChannel4AliService
payChannel4AliService
;
public
int
createPayOrder
(
JSONObject
payOrder
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
createPayOrder
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
0
;
return
Integer
.
parseInt
(
s
);
}
public
JSONObject
queryPayOrder
(
String
mchId
,
String
payOrderId
,
String
mchOrderNo
,
String
executeNotify
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
;
if
(
StringUtils
.
isNotBlank
(
payOrderId
))
{
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"payOrderId"
,
payOrderId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
selectPayOrderByMchIdAndPayOrderId
(
jsonParam
);
}
else
{
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"mchOrderNo"
,
mchOrderNo
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
selectPayOrderByMchIdAndMchOrderNo
(
jsonParam
);
}
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
boolean
isNotify
=
Boolean
.
parseBoolean
(
executeNotify
);
JSONObject
payOrder
=
JSONObject
.
parseObject
(
s
);
if
(
isNotify
)
{
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrderId"
,
payOrderId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
notifyPayService
.
sendBizPayNotify
(
jsonParam
);
s
=
RpcUtil
.
mkRet
(
result
);
_log
.
info
(
"业务查单完成,并再次发送业务支付通知.发送结果:{}"
,
s
);
}
return
payOrder
;
}
public
String
doWxPayReq
(
String
tradeType
,
JSONObject
payOrder
,
String
resKey
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"tradeType"
,
tradeType
);
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
payChannel4WxService
.
doWxPayReq
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
XXPayUtil
.
makeRetData
(
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_FAIL
,
"0111"
,
"调用微信支付失败"
),
resKey
);
}
Map
<
String
,
Object
>
map
=
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_SUCCESS
,
null
);
map
.
putAll
((
Map
)
result
.
get
(
"bizResult"
));
return
XXPayUtil
.
makeRetData
(
map
,
resKey
);
}
public
String
doAliPayReq
(
String
channelId
,
JSONObject
payOrder
,
String
resKey
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
;
switch
(
channelId
)
{
case
PayConstant
.
PAY_CHANNEL_ALIPAY_MOBILE
:
result
=
payChannel4AliService
.
doAliPayMobileReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_PC
:
result
=
payChannel4AliService
.
doAliPayPcReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_WAP
:
result
=
payChannel4AliService
.
doAliPayWapReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_QR
:
result
=
payChannel4AliService
.
doAliPayQrReq
(
jsonParam
);
break
;
default
:
result
=
null
;
break
;
}
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
XXPayUtil
.
makeRetData
(
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_FAIL
,
"0111"
,
"调用支付宝支付失败"
),
resKey
);
}
Map
<
String
,
Object
>
map
=
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_SUCCESS
,
null
);
map
.
putAll
((
Map
)
result
.
get
(
"bizResult"
));
return
XXPayUtil
.
makeRetData
(
map
,
resKey
);
}
@Override
public
Map
createPayOrder
(
String
jsonParam
)
{
BaseParam
baseParam
=
JsonUtil
.
getObjectFromJson
(
jsonParam
,
BaseParam
.
class
);
...
...
xxpay4spring-boot/src/main/java/org/xxpay/boot/web/MchInfoService.java
deleted
100644 → 0
View file @
032d9db0
package
org.xxpay.boot.web
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.common.util.RpcUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public
class
MchInfoService
{
@Autowired
private
RpcCommonService
rpcCommonService
;
public
JSONObject
getByMchId
(
String
mchId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"mchId"
,
mchId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcMchInfoService
.
selectMchInfo
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
return
JSONObject
.
parseObject
(
s
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/web/NotifyPayService.java
deleted
100644 → 0
View file @
032d9db0
package
org.xxpay.boot.web
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.common.constant.PayConstant
;
import
org.xxpay.common.util.RpcUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author: dingzhiwei
* @date: 17/9/10
* @description:
*/
@Service
public
class
NotifyPayService
{
@Autowired
private
RpcCommonService
rpcCommonService
;
public
String
doAliPayNotify
(
Map
params
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"params"
,
params
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcNotifyPayService
.
doAliPayNotify
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
PayConstant
.
RETURN_ALIPAY_VALUE_FAIL
;
}
return
s
;
}
public
String
doWxPayNotify
(
String
xmlResult
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"xmlResult"
,
xmlResult
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
// 返回给微信的数据格式已经有service处理(包括正确与错误),肯定会返回result
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcNotifyPayService
.
doWxPayNotify
(
jsonParam
);
return
RpcUtil
.
mkRet
(
result
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/web/PayChannelService.java
deleted
100644 → 0
View file @
032d9db0
package
org.xxpay.boot.web
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.common.util.RpcUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public
class
PayChannelService
{
@Autowired
private
RpcCommonService
rpcCommonService
;
public
JSONObject
getByMchIdAndChannelId
(
String
mchId
,
String
channelId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"channelId"
,
channelId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcPayChannelService
.
selectPayChannel
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
return
JSONObject
.
parseObject
(
s
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/web/PayOrderService.java
deleted
100644 → 0
View file @
032d9db0
package
org.xxpay.boot.web
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.common.constant.PayConstant
;
import
org.xxpay.common.util.MyLog
;
import
org.xxpay.common.util.RpcUtil
;
import
org.xxpay.common.util.XXPayUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author: dingzhiwei
* @date: 17/9/9
* @description:
*/
@Service
public
class
PayOrderService
{
private
static
final
MyLog
_log
=
MyLog
.
getLog
(
PayOrderService
.
class
);
@Autowired
private
RpcCommonService
rpcCommonService
;
public
int
createPayOrder
(
JSONObject
payOrder
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcPayOrderService
.
createPayOrder
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
0
;
return
Integer
.
parseInt
(
s
);
}
public
JSONObject
queryPayOrder
(
String
mchId
,
String
payOrderId
,
String
mchOrderNo
,
String
executeNotify
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
;
if
(
StringUtils
.
isNotBlank
(
payOrderId
))
{
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"payOrderId"
,
payOrderId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
rpcCommonService
.
rpcPayOrderService
.
selectPayOrderByMchIdAndPayOrderId
(
jsonParam
);
}
else
{
paramMap
.
put
(
"mchId"
,
mchId
);
paramMap
.
put
(
"mchOrderNo"
,
mchOrderNo
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
rpcCommonService
.
rpcPayOrderService
.
selectPayOrderByMchIdAndMchOrderNo
(
jsonParam
);
}
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
return
null
;
boolean
isNotify
=
Boolean
.
parseBoolean
(
executeNotify
);
JSONObject
payOrder
=
JSONObject
.
parseObject
(
s
);
if
(
isNotify
)
{
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrderId"
,
payOrderId
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
result
=
rpcCommonService
.
rpcNotifyPayService
.
sendBizPayNotify
(
jsonParam
);
s
=
RpcUtil
.
mkRet
(
result
);
_log
.
info
(
"业务查单完成,并再次发送业务支付通知.发送结果:{}"
,
s
);
}
return
payOrder
;
}
public
String
doWxPayReq
(
String
tradeType
,
JSONObject
payOrder
,
String
resKey
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"tradeType"
,
tradeType
);
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
=
rpcCommonService
.
rpcPayChannel4WxService
.
doWxPayReq
(
jsonParam
);
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
XXPayUtil
.
makeRetData
(
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_FAIL
,
"0111"
,
"调用微信支付失败"
),
resKey
);
}
Map
<
String
,
Object
>
map
=
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_SUCCESS
,
null
);
map
.
putAll
((
Map
)
result
.
get
(
"bizResult"
));
return
XXPayUtil
.
makeRetData
(
map
,
resKey
);
}
public
String
doAliPayReq
(
String
channelId
,
JSONObject
payOrder
,
String
resKey
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"payOrder"
,
payOrder
);
String
jsonParam
=
RpcUtil
.
createBaseParam
(
paramMap
);
Map
<
String
,
Object
>
result
;
switch
(
channelId
)
{
case
PayConstant
.
PAY_CHANNEL_ALIPAY_MOBILE
:
result
=
rpcCommonService
.
rpcPayChannel4AliService
.
doAliPayMobileReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_PC
:
result
=
rpcCommonService
.
rpcPayChannel4AliService
.
doAliPayPcReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_WAP
:
result
=
rpcCommonService
.
rpcPayChannel4AliService
.
doAliPayWapReq
(
jsonParam
);
break
;
case
PayConstant
.
PAY_CHANNEL_ALIPAY_QR
:
result
=
rpcCommonService
.
rpcPayChannel4AliService
.
doAliPayQrReq
(
jsonParam
);
break
;
default
:
result
=
null
;
break
;
}
String
s
=
RpcUtil
.
mkRet
(
result
);
if
(
s
==
null
)
{
return
XXPayUtil
.
makeRetData
(
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_FAIL
,
"0111"
,
"调用支付宝支付失败"
),
resKey
);
}
Map
<
String
,
Object
>
map
=
XXPayUtil
.
makeRetMap
(
PayConstant
.
RETURN_VALUE_SUCCESS
,
""
,
PayConstant
.
RETURN_VALUE_SUCCESS
,
null
);
map
.
putAll
((
Map
)
result
.
get
(
"bizResult"
));
return
XXPayUtil
.
makeRetData
(
map
,
resKey
);
}
}
xxpay4spring-boot/src/main/java/org/xxpay/boot/web/RpcCommonService.java
deleted
100644 → 0
View file @
032d9db0
package
org.xxpay.boot.web
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.xxpay.boot.service.*
;
/**
* @author: dingzhiwei
* @date: 17/9/10
* @description:
*/
@Service
public
class
RpcCommonService
{
@Autowired
public
IMchInfoService
rpcMchInfoService
;
@Autowired
public
IPayChannelService
rpcPayChannelService
;
@Autowired
public
IPayOrderService
rpcPayOrderService
;
@Autowired
public
IPayChannel4WxService
rpcPayChannel4WxService
;
@Autowired
public
IPayChannel4AliService
rpcPayChannel4AliService
;
@Autowired
public
INotifyPayService
rpcNotifyPayService
;
}
Write
Preview
Supports
Markdown
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