Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
87e934bb
Commit
87e934bb
authored
Oct 25, 2023
by
吕明尚
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/main'
parents
f0e650c7
93ac8424
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
260 additions
and
4 deletions
+260
-4
CallbackController.java
.../java/share/web/controller/system/CallbackController.java
+55
-0
WeChatConfig.java
...ommon/src/main/java/share/common/config/WeChatConfig.java
+2
-0
Constants.java
...common/src/main/java/share/common/constant/Constants.java
+11
-0
OrderTypeEnum.java
...ommon/src/main/java/share/common/enums/OrderTypeEnum.java
+23
-4
AttachVo.java
...system/src/main/java/share/system/domain/vo/AttachVo.java
+32
-0
CallbackVo.java
...stem/src/main/java/share/system/domain/vo/CallbackVo.java
+100
-0
CallbackService.java
...m/src/main/java/share/system/service/CallbackService.java
+22
-0
ISOrderService.java
...em/src/main/java/share/system/service/ISOrderService.java
+2
-0
CallbackServiceImpl.java
...n/java/share/system/service/impl/CallbackServiceImpl.java
+0
-0
OrderPayServiceImpl.java
...n/java/share/system/service/impl/OrderPayServiceImpl.java
+6
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+7
-0
No files found.
share-admin/src/main/java/share/web/controller/system/CallbackController.java
0 → 100644
View file @
87e934bb
package
com
.
zbkj
.
admin
.
controller
;
import
com.zbkj.service.service.CallbackService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 支付回调
*/
@Slf4j
@RestController
@RequestMapping
(
"api/admin/payment/callback"
)
@Api
(
tags
=
"支付回调"
)
public
class
CallbackController
{
@Autowired
private
CallbackService
callbackService
;
/**
* 微信支付回调
*/
@ApiOperation
(
value
=
"微信支付回调"
)
@RequestMapping
(
value
=
"/wechat"
,
method
=
RequestMethod
.
POST
)
public
String
weChat
(
@RequestBody
String
request
)
{
System
.
out
.
println
(
"微信支付回调 request ===> "
+
request
);
String
response
=
callbackService
.
weChat
(
request
);
System
.
out
.
println
(
"微信支付回调 response ===> "
+
response
);
return
response
;
}
/**
* 微信退款回调
*/
@ApiOperation
(
value
=
"微信退款回调"
)
@RequestMapping
(
value
=
"/wechat/refund"
,
method
=
RequestMethod
.
POST
)
public
String
weChatRefund
(
@RequestBody
String
request
)
{
System
.
out
.
println
(
"微信退款回调 request ===> "
+
request
);
String
response
=
callbackService
.
weChatRefund
(
request
);
System
.
out
.
println
(
"微信退款回调 response ===> "
+
response
);
return
response
;
}
}
share-common/src/main/java/share/common/config/WeChatConfig.java
View file @
87e934bb
...
...
@@ -27,6 +27,8 @@ public class WeChatConfig
private
String
publicAppSecret
;
private
String
publicSignKey
;
private
Integer
wechatJsApiDebug
;
}
share-common/src/main/java/share/common/constant/Constants.java
View file @
87e934bb
...
...
@@ -9,6 +9,7 @@ import io.jsonwebtoken.Claims;
*/
public
class
Constants
{
public
static
final
String
CONFIG_KEY_SITE_URL
=
"site_url"
;
//域名
public
static
final
String
CONFIG_KEY_API_URL
=
"api_url"
;
//admin接口地址
// 订单取消Key
...
...
@@ -40,6 +41,16 @@ public class Constants
public
static
final
int
THIRD_LOGIN_TOKEN_TYPE_ANDROID_WX
=
6
;
//android微信
public
static
final
int
THIRD_LOGIN_TOKEN_TYPE_IOS
=
7
;
//ios
/** 订单支付成功后Task */
public
static
final
String
ORDER_TASK_PAY_SUCCESS_AFTER
=
"orderPaySuccessTask"
;
//订单操作redis队列
public
static
final
String
ORDER_TASK_REDIS_KEY_AFTER_DELETE_BY_USER
=
"alterOrderDeleteByUser"
;
// 用户删除订单后续操作
public
static
final
String
ORDER_TASK_REDIS_KEY_AFTER_COMPLETE_BY_USER
=
"alterOrderCompleteByUser"
;
// 用户完成订单后续操作
public
static
final
String
ORDER_TASK_REDIS_KEY_AFTER_CANCEL_BY_USER
=
"alterOrderCancelByUser"
;
// 用户取消订单后续操作
public
static
final
String
ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER
=
"alterOrderRefundByUser"
;
// 用户订单退款后续操作
public
static
final
int
NUM_ZERO
=
0
;
public
static
final
int
NUM_ONE
=
1
;
public
static
final
int
NUM_TWO
=
2
;
...
...
share-common/src/main/java/share/common/enums/OrderTypeEnum.java
View file @
87e934bb
package
share
.
common
.
enums
;
import
share.common.utils.StringUtils
;
/**
* @Author wwl
* @Date 2023/10/20 10:57
*/
public
enum
OrderTypeEnum
{
RESERVER
(
1
,
"预定"
),
RENEW
(
2
,
"续费"
),
RECHARGE
(
3
,
"充值"
);
RESERVER
(
1
,
"
reserver"
,
"
预定"
),
RENEW
(
2
,
"
renew"
,
"
续费"
),
RECHARGE
(
3
,
"
recharge"
,
"
充值"
);
private
Integer
code
;
private
String
value
;
private
String
name
;
OrderTypeEnum
(
Integer
code
,
String
name
)
{
OrderTypeEnum
(
Integer
code
,
String
value
,
String
name
)
{
this
.
code
=
code
;
this
.
value
=
value
;
this
.
name
=
name
;
}
...
...
@@ -26,10 +30,25 @@ public enum OrderTypeEnum {
return
null
;
}
public
static
OrderTypeEnum
getEnumByValue
(
String
value
){
if
(
StringUtils
.
isNotBlank
(
value
))
{
for
(
OrderTypeEnum
type
:
OrderTypeEnum
.
values
())
{
if
(
type
.
value
.
equals
(
value
))
{
return
type
;
}
}
}
return
null
;
}
public
Integer
getCode
(){
return
code
;
}
public
String
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
...
...
share-system/src/main/java/share/system/domain/vo/AttachVo.java
0 → 100644
View file @
87e934bb
package
share
.
system
.
domain
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* 支付附加对象
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"AttachVo对象"
,
description
=
"支付附加对象"
)
public
class
AttachVo
{
public
AttachVo
()
{
}
public
AttachVo
(
String
type
,
Long
userId
)
{
this
.
type
=
type
;
this
.
userId
=
userId
;
}
@ApiModelProperty
(
value
=
"业务类型, 订单 = order, 充值 = recharge"
,
required
=
true
)
private
String
type
=
"order"
;
@ApiModelProperty
(
value
=
"用户id"
,
required
=
true
)
private
Long
userId
;
}
share-system/src/main/java/share/system/domain/vo/CallbackVo.java
0 → 100644
View file @
87e934bb
package
com
.
zbkj
.
common
.
vo
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* 微信回调对象
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"CallbackVo对象"
,
description
=
"微信回调"
)
public
class
CallbackVo
{
@ApiModelProperty
(
value
=
"调用接口提交的公众账号ID"
)
@JsonProperty
(
value
=
"appid"
)
private
String
appId
;
@ApiModelProperty
(
value
=
"调用接口提交的商户号"
)
@JsonProperty
(
value
=
"mch_id"
)
private
String
mchId
;
@ApiModelProperty
(
value
=
"调用接口提交的终端设备号"
)
@JsonProperty
(
value
=
"device_info"
)
private
String
deviceInfo
;
@ApiModelProperty
(
value
=
"微信返回的随机字符串"
)
@JsonProperty
(
value
=
"nonce_str"
)
private
String
nonceStr
;
@ApiModelProperty
(
value
=
"微信返回的签名"
)
private
String
sign
;
@ApiModelProperty
(
value
=
"SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看trade_state来判断"
)
@JsonProperty
(
value
=
"return_code"
)
private
String
returnCode
;
@ApiModelProperty
(
value
=
"当return_code为FAIL时返回信息为错误原因 ,例如 签名失败 参数格式校验错误"
)
@JsonProperty
(
value
=
"return_msg"
)
private
String
returnMsg
;
@ApiModelProperty
(
value
=
"SUCCESS/FAIL 业务结果"
)
@JsonProperty
(
value
=
"result_code"
)
private
String
resultCode
;
@ApiModelProperty
(
value
=
"详细参见错误列表"
)
@JsonProperty
(
value
=
"err_code"
)
private
String
errCode
;
@ApiModelProperty
(
value
=
"错误返回的信息描述"
)
@JsonProperty
(
value
=
"err_code_des"
)
private
String
errCodeDes
;
@ApiModelProperty
(
value
=
"用户在商户appid下的唯一标识"
)
private
String
openid
;
@ApiModelProperty
(
value
=
"微信支付订单号"
)
@JsonProperty
(
value
=
"transaction_id"
)
private
String
transactionId
;
@ApiModelProperty
(
value
=
"微信支付订单号"
)
@JsonProperty
(
value
=
"out_trade_no"
)
private
String
outTradeNo
;
@ApiModelProperty
(
value
=
"商家数据包,原样返回"
)
private
String
attach
;
@ApiModelProperty
(
value
=
"支付完成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则"
)
@JsonProperty
(
value
=
"time_end"
)
private
String
timeEnd
;
@ApiModelProperty
(
value
=
"用户是否关注公众账号,Y-关注,N-未关注"
)
@JsonProperty
(
value
=
"is_subscribe"
)
private
String
isSubscribe
;
@ApiModelProperty
(
value
=
"银行类型"
)
@JsonProperty
(
value
=
"bank_type"
)
private
String
bankType
;
@ApiModelProperty
(
value
=
"现金支付金额"
)
@JsonProperty
(
value
=
"cash_fee"
)
private
Integer
cashFee
;
@ApiModelProperty
(
value
=
"总代金券金额"
)
@JsonProperty
(
value
=
"coupon_fee"
)
private
Integer
couponFee
;
}
share-system/src/main/java/share/system/service/CallbackService.java
0 → 100644
View file @
87e934bb
package
com
.
zbkj
.
service
.
service
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 订单支付回调 service
*/
public
interface
CallbackService
{
/**
* 微信支付回调
* @param xmlInfo 微信回调json
* @return String
*/
String
weChat
(
String
xmlInfo
);
/**
* 微信退款回调
* @param request 微信回调json
* @return String
*/
String
weChatRefund
(
String
request
);
}
share-system/src/main/java/share/system/service/ISOrderService.java
View file @
87e934bb
...
...
@@ -98,4 +98,6 @@ public interface ISOrderService extends IService<SOrder>
SOrder
getByOrderNo
(
String
orderNo
);
String
openDoor
(
Long
id
);
SOrder
getInfoByEntity
(
SOrder
orderParam
);
}
share-system/src/main/java/share/system/service/impl/CallbackServiceImpl.java
0 → 100644
View file @
87e934bb
This diff is collapsed.
Click to expand it.
share-system/src/main/java/share/system/service/impl/OrderPayServiceImpl.java
View file @
87e934bb
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,6 +9,7 @@ import org.springframework.stereotype.Service;
import
share.common.config.WeChatConfig
;
import
share.common.constant.Constants
;
import
share.common.constant.PayConstants
;
import
share.common.enums.OrderTypeEnum
;
import
share.common.enums.PayTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.exception.base.BaseException
;
...
...
@@ -16,6 +18,7 @@ import share.common.utils.DateUtil;
import
share.common.utils.JsonConvertUtil
;
import
share.system.domain.SConsumerToken
;
import
share.system.domain.SOrder
;
import
share.system.domain.vo.AttachVo
;
import
share.system.domain.vo.CreateOrderRequestVo
;
import
share.system.domain.vo.CreateOrderResponseVo
;
import
share.system.domain.vo.WxPayJsResultVo
;
...
...
@@ -117,11 +120,14 @@ public class OrderPayServiceImpl implements OrderPayService {
private
CreateOrderRequestVo
getUnifiedorderVo
(
SOrder
sOrder
,
String
openid
,
String
appId
,
String
mchId
,
String
signKey
)
{
// 获取域名
String
apiDomain
=
Constants
.
CONFIG_KEY_API_URL
;
AttachVo
attachVo
=
new
AttachVo
(
OrderTypeEnum
.
getEnumByCode
(
sOrder
.
getOrderType
()).
getValue
(),
sOrder
.
getConsumerId
());
CreateOrderRequestVo
vo
=
new
CreateOrderRequestVo
();
vo
.
setAppid
(
appId
);
vo
.
setMch_id
(
mchId
);
vo
.
setNonce_str
(
WxPayUtil
.
getNonceStr
());
vo
.
setSign_type
(
PayConstants
.
WX_PAY_SIGN_TYPE_MD5
);
vo
.
setAttach
(
JSONObject
.
toJSONString
(
attachVo
));
vo
.
setOut_trade_no
(
BaseUtil
.
getOrderNo
(
"wxNo"
));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo
.
setTotal_fee
(
sOrder
.
getPayPrice
().
multiply
(
BigDecimal
.
TEN
).
multiply
(
BigDecimal
.
TEN
).
intValue
());
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
87e934bb
...
...
@@ -271,6 +271,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
@Override
public
SOrder
getInfoByEntity
(
SOrder
orderParam
)
{
LambdaQueryWrapper
<
SOrder
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
setEntity
(
orderParam
);
return
getOne
(
lambdaQueryWrapper
);
}
@Override
public
String
openDoor
(
Long
id
)
{
SOrder
sOrder
=
sOrderMapper
.
selectSOrderById
(
id
);
if
(
Objects
.
isNull
(
sOrder
))
{
...
...
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