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
ec816c7d
Commit
ec816c7d
authored
Jul 03, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增权益订单下单和扫呗调用
parent
d00b3add
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
193 additions
and
5 deletions
+193
-5
OrderTypeEnum.java
...ommon/src/main/java/share/common/enums/OrderTypeEnum.java
+2
-1
EquityMembersOrderController.java
...e/web/controller/system/EquityMembersOrderController.java
+23
-0
RechargeController.java
.../java/share/web/controller/system/RechargeController.java
+2
-2
EquityMembersOrder.java
...src/main/java/share/system/domain/EquityMembersOrder.java
+1
-1
AttachVo.java
...system/src/main/java/share/system/domain/vo/AttachVo.java
+1
-1
CreateEquityMembersRequest.java
...java/share/system/request/CreateEquityMembersRequest.java
+23
-0
EquityMembersOrderService.java
.../java/share/system/service/EquityMembersOrderService.java
+4
-0
OrderPayService.java
...m/src/main/java/share/system/service/OrderPayService.java
+3
-0
EquityMembersOrderServiceImpl.java
...re/system/service/impl/EquityMembersOrderServiceImpl.java
+52
-0
OrderPayServiceImpl.java
...n/java/share/system/service/impl/OrderPayServiceImpl.java
+82
-0
No files found.
share-common/src/main/java/share/common/enums/OrderTypeEnum.java
View file @
ec816c7d
...
...
@@ -9,7 +9,8 @@ import share.common.utils.StringUtils;
public
enum
OrderTypeEnum
{
RESERVER
(
1
,
"reserver"
,
"预定"
),
RENEW
(
2
,
"renew"
,
"续费"
),
RECHARGE
(
3
,
"recharge"
,
"充值"
);
RECHARGE
(
3
,
"recharge"
,
"充值"
),
RIGHTS
(
4
,
"rights"
,
"权益"
);
private
Integer
code
;
private
String
value
;
...
...
share-front/src/main/java/share/web/controller/system/EquityMembersOrderController.java
View file @
ec816c7d
package
share
.
web
.
controller
.
system
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
share.common.annotation.Log
;
import
share.common.core.controller.BaseController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.domain.R
;
import
share.common.core.page.TableDataInfo
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.BusinessType
;
import
share.common.utils.JsonConvertUtil
;
import
share.common.utils.poi.ExcelUtil
;
import
share.system.domain.EquityMembersOrder
;
import
share.system.domain.vo.EquityMembersOrderVo
;
import
share.system.request.CreateEquityMembersRequest
;
import
share.system.response.RechargePayResultResponse
;
import
share.system.service.EquityMembersOrderService
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -21,11 +28,14 @@ import java.util.List;
* @author wuwenlong
* @date 2024-06-24
*/
@Slf4j
@RestController
@RequestMapping
(
"/equityMembersOrder"
)
public
class
EquityMembersOrderController
extends
BaseController
{
@Autowired
private
EquityMembersOrderService
equityMembersOrderService
;
@Autowired
private
RedisUtil
redisUtil
;
/**
* 查询权益会员订单列表
...
...
@@ -82,4 +92,17 @@ public class EquityMembersOrderController extends BaseController {
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
return
toAjax
(
equityMembersOrderService
.
deleteEquityMembersOrderByIds
(
ids
));
}
@Log
(
title
=
"权益会员下单"
,
businessType
=
BusinessType
.
DELETE
)
@PostMapping
(
"/createEquityMembers"
)
public
R
<
RechargePayResultResponse
>
createOrder
(
@RequestBody
@Validated
CreateEquityMembersRequest
request
)
{
if
(
"1"
.
equals
(
redisUtil
.
frontInOutLogSwitch
()))
{
log
.
info
(
"SOrderController method preOrder 入参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
request
));
}
RechargePayResultResponse
response
=
equityMembersOrderService
.
createEquityMembers
(
request
);
if
(
"1"
.
equals
(
redisUtil
.
frontInOutLogSwitch
()))
{
log
.
info
(
"SOrderController method preOrder 出参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
response
));
}
return
R
.
ok
(
response
);
}
}
share-front/src/main/java/share/web/controller/system/RechargeController.java
View file @
ec816c7d
...
...
@@ -92,8 +92,8 @@ public class RechargeController extends BaseController {
return
toAjax
(
rechargeService
.
deleteRechargeByIds
(
ids
));
}
@Log
(
title
=
"充值"
,
businessType
=
BusinessType
.
DELETE
)
@PostMapping
(
"/
r
echarge"
)
@Log
(
title
=
"充值
下单
"
,
businessType
=
BusinessType
.
DELETE
)
@PostMapping
(
"/
createR
echarge"
)
public
R
<
RechargePayResultResponse
>
createOrder
(
@RequestBody
@Validated
CreateRechargeRequest
request
)
{
if
(
"1"
.
equals
(
redisUtil
.
frontInOutLogSwitch
()))
{
log
.
info
(
"SOrderController method preOrder 入参 {}"
,
JsonConvertUtil
.
write2JsonStr
(
request
));
...
...
share-system/src/main/java/share/system/domain/EquityMembersOrder.java
View file @
ec816c7d
...
...
@@ -75,7 +75,7 @@ public class EquityMembersOrder extends BaseEntity {
* 支付状态(0:未支付,1:已支付)
*/
@Excel
(
name
=
"支付状态(0:未支付,1:已支付)"
)
private
Long
payStatus
;
private
Integer
payStatus
;
/**
* 支付时间
...
...
share-system/src/main/java/share/system/domain/vo/AttachVo.java
View file @
ec816c7d
...
...
@@ -23,7 +23,7 @@ public class AttachVo {
this
.
userId
=
userId
;
}
@ApiModelProperty
(
value
=
"业务类型, 订单 = order, 充值 = recharge"
,
required
=
true
)
@ApiModelProperty
(
value
=
"业务类型, 订单 = order, 充值 = recharge
, 权益 =
"
,
required
=
true
)
private
String
type
=
"order"
;
@ApiModelProperty
(
value
=
"用户id"
,
required
=
true
)
...
...
share-system/src/main/java/share/system/request/CreateEquityMembersRequest.java
0 → 100644
View file @
ec816c7d
package
share
.
system
.
request
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"CreateEquityMembersRequest对象"
,
description
=
"下单请求对象"
)
public
class
CreateEquityMembersRequest
{
@ApiModelProperty
(
value
=
"支付类型(1:微信,2:支付宝)"
,
required
=
true
)
@NotNull
(
message
=
"支付类型不能为空"
)
private
Integer
payType
;
@ApiModelProperty
(
value
=
"权益会员订单配置id"
)
@NotNull
(
message
=
"权益会员订单配置id"
)
private
Long
equityMembersConfigId
;
}
share-system/src/main/java/share/system/service/EquityMembersOrderService.java
View file @
ec816c7d
...
...
@@ -3,6 +3,8 @@ package share.system.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.system.domain.EquityMembersOrder
;
import
share.system.domain.vo.EquityMembersOrderVo
;
import
share.system.request.CreateEquityMembersRequest
;
import
share.system.response.RechargePayResultResponse
;
import
java.util.List
;
...
...
@@ -60,4 +62,6 @@ public interface EquityMembersOrderService extends IService<EquityMembersOrder>
* @return 结果
*/
public
int
deleteEquityMembersOrderById
(
Long
id
);
RechargePayResultResponse
createEquityMembers
(
CreateEquityMembersRequest
request
);
}
share-system/src/main/java/share/system/service/OrderPayService.java
View file @
ec816c7d
package
share
.
system
.
service
;
import
share.system.domain.EquityMembersOrder
;
import
share.system.domain.Recharge
;
import
share.system.domain.SOrder
;
import
share.system.response.OrderPayResultResponse
;
...
...
@@ -32,4 +33,6 @@ public interface OrderPayService {
*/
RechargePayResultResponse
saobeiRechargePayment
(
Recharge
recharge
);
RechargePayResultResponse
saobeiEquityMembersOrderPayment
(
EquityMembersOrder
equityMembersOrder
);
}
share-system/src/main/java/share/system/service/impl/EquityMembersOrderServiceImpl.java
View file @
ec816c7d
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.YesNoEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.BaseUtil
;
import
share.common.utils.DateUtils
;
import
share.common.utils.bean.BeanUtils
;
import
share.system.domain.EquityMembersOrder
;
import
share.system.domain.EquityMembersOrderConfig
;
import
share.system.domain.SConsumer
;
import
share.system.domain.vo.EquityMembersOrderVo
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.mapper.EquityMembersOrderMapper
;
import
share.system.request.CreateEquityMembersRequest
;
import
share.system.response.RechargePayResultResponse
;
import
share.system.service.EquityMembersOrderConfigService
;
import
share.system.service.EquityMembersOrderService
;
import
share.system.service.OrderPayService
;
import
share.system.service.SConsumerService
;
import
java.util.List
;
...
...
@@ -21,6 +35,12 @@ import java.util.List;
public
class
EquityMembersOrderServiceImpl
extends
ServiceImpl
<
EquityMembersOrderMapper
,
EquityMembersOrder
>
implements
EquityMembersOrderService
{
@Autowired
private
EquityMembersOrderMapper
equityMembersOrderMapper
;
@Autowired
private
SConsumerService
sConsumerService
;
@Autowired
private
EquityMembersOrderConfigService
equityMembersOrderConfigService
;
@Autowired
private
OrderPayService
orderPayService
;
/**
* 查询权益会员订单
...
...
@@ -89,4 +109,36 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
public
int
deleteEquityMembersOrderById
(
Long
id
)
{
return
equityMembersOrderMapper
.
deleteEquityMembersOrderById
(
id
);
}
@Override
public
RechargePayResultResponse
createEquityMembers
(
CreateEquityMembersRequest
request
)
{
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
if
(
ObjectUtil
.
isNull
(
user
))
{
throw
new
BaseException
(
"您的登录已过期,请先登录"
);
}
if
(
StringUtils
.
isEmpty
(
user
.
getPhone
()))
{
user
=
sConsumerService
.
getById
(
user
.
getId
());
if
(
StringUtils
.
isEmpty
(
user
.
getPhone
()))
{
throw
new
BaseException
(
"请绑定手机号"
);
}
}
EquityMembersOrder
equityMembersOrder
=
generatEquityMembersOrder
(
request
,
user
);
save
(
equityMembersOrder
);
RechargePayResultResponse
response
=
orderPayService
.
saobeiEquityMembersOrderPayment
(
equityMembersOrder
);
return
response
;
}
private
EquityMembersOrder
generatEquityMembersOrder
(
CreateEquityMembersRequest
request
,
SConsumer
user
)
{
EquityMembersOrder
equityMembersOrder
=
new
EquityMembersOrder
();
BeanUtils
.
copyProperties
(
request
,
equityMembersOrder
);
EquityMembersOrderConfig
equityMembersOrderConfig
=
equityMembersOrderConfigService
.
selectEquityMembersOrderConfigById
(
request
.
getEquityMembersConfigId
());
if
(
ObjectUtil
.
isEmpty
(
equityMembersOrderConfig
))
{
throw
new
BaseException
(
"权益模板异常"
);
}
equityMembersOrder
.
setConsumerId
(
user
.
getId
());
equityMembersOrder
.
setEquityOrderNo
(
BaseUtil
.
getOrderNo
(
"QY"
));
equityMembersOrder
.
setPayPrice
(
equityMembersOrderConfig
.
getRequiredAmount
());
equityMembersOrder
.
setPayStatus
(
YesNoEnum
.
no
.
getIndex
());
return
equityMembersOrder
;
}
}
share-system/src/main/java/share/system/service/impl/OrderPayServiceImpl.java
View file @
ec816c7d
...
...
@@ -20,6 +20,7 @@ import share.common.exception.base.BaseException;
import
share.common.utils.BaseUtil
;
import
share.common.utils.DateUtil
;
import
share.common.utils.JsonConvertUtil
;
import
share.system.domain.EquityMembersOrder
;
import
share.system.domain.Recharge
;
import
share.system.domain.SConsumerToken
;
import
share.system.domain.SOrder
;
...
...
@@ -58,6 +59,8 @@ public class OrderPayServiceImpl implements OrderPayService {
private
SaobeiService
saobeiService
;
@Autowired
private
RechargeService
rechargeService
;
@Autowired
private
EquityMembersOrderService
equityMembersOrderService
;
/**
* 获取域名
...
...
@@ -324,4 +327,83 @@ public class OrderPayServiceImpl implements OrderPayService {
return
vo
;
}
/**
* 充值支付(扫呗-微信支付)
*
* @param equityMembersOrder 支付参数
* @return
*/
@Override
public
RechargePayResultResponse
saobeiEquityMembersOrderPayment
(
EquityMembersOrder
equityMembersOrder
)
{
RechargePayResultResponse
response
=
new
RechargePayResultResponse
();
response
.
setRechargeNo
(
equityMembersOrder
.
getEquityOrderNo
());
response
.
setPayType
(
PayTypeEnum
.
getEnumByCode
(
equityMembersOrder
.
getPayType
().
intValue
()).
getValue
());
response
.
setStatus
(
YesNoEnum
.
no
.
getFlag
());
// 扫呗支付
ConcurrentHashMap
<
String
,
String
>
unifiedorder
=
saobeiUnifiedEquityMembersOrder
(
equityMembersOrder
);
WxPayJsResultVo
vo
=
new
WxPayJsResultVo
();
vo
.
setAppId
(
unifiedorder
.
get
(
"appId"
));
vo
.
setNonceStr
(
unifiedorder
.
get
(
"nonceStr"
));
vo
.
setPackages
(
unifiedorder
.
get
(
"package"
));
vo
.
setSignType
(
unifiedorder
.
get
(
"signType"
));
vo
.
setTimeStamp
(
unifiedorder
.
get
(
"timeStamp"
));
vo
.
setPaySign
(
unifiedorder
.
get
(
"paySign"
));
// 更新商户订单号
equityMembersOrder
.
setOutTradeNo
(
unifiedorder
.
get
(
"outTradeNo"
));
equityMembersOrder
.
setTerminalTrace
(
unifiedorder
.
get
(
"terminalTrace"
));
equityMembersOrderService
.
updateById
(
equityMembersOrder
);
response
.
setJsConfig
(
vo
);
return
response
;
}
private
ConcurrentHashMap
<
String
,
String
>
saobeiUnifiedEquityMembersOrder
(
EquityMembersOrder
equityMembersOrder
)
{
// 获取用户openId
SConsumerToken
userToken
=
consumerTokenService
.
getTokenByUserId
(
equityMembersOrder
.
getConsumerId
());
if
(
ObjectUtil
.
isNull
(
userToken
))
{
throw
new
BaseException
(
"该用户没有openId"
);
}
// 获取appid、mch_id
// 微信签名key
String
appId
=
weChatConfig
.
getAppId
();
String
mchId
=
weChatConfig
.
getMchId
();
String
signKey
=
weChatConfig
.
getSignKey
();
// 获取扫呗微信预下单对象
SaobeiMiniPayRequestVo
unifiedorderVo
=
getSaobeiUnifiedEquityMembersOrderVo
(
equityMembersOrder
,
userToken
.
getToken
(),
appId
,
mchId
,
signKey
);
// 预下单(统一下单)
SaobeiMiniPayResponse
response
=
saobeiService
.
wechatMinipay
(
unifiedorderVo
);
logger
.
info
(
"SaobeiMiniPayResponse :"
,
JsonConvertUtil
.
write2JsonStr
(
response
));
// 组装前端预下单参数
ConcurrentHashMap
<
String
,
String
>
map
=
new
ConcurrentHashMap
<>();
map
.
put
(
"appId"
,
response
.
getAppId
());
map
.
put
(
"nonceStr"
,
response
.
getNonceStr
());
map
.
put
(
"package"
,
response
.
getPackage_str
());
map
.
put
(
"signType"
,
response
.
getSignType
());
map
.
put
(
"timeStamp"
,
response
.
getTimeStamp
());
map
.
put
(
"paySign"
,
response
.
getPaySign
());
map
.
put
(
"prepayTime"
,
DateUtil
.
nowDateTimeStr
());
map
.
put
(
"outTradeNo"
,
response
.
getOut_trade_no
());
map
.
put
(
"terminalTrace"
,
unifiedorderVo
.
getTerminal_trace
());
return
map
;
}
private
SaobeiMiniPayRequestVo
getSaobeiUnifiedEquityMembersOrderVo
(
EquityMembersOrder
equityMembersOrder
,
String
openid
,
String
appId
,
String
mchId
,
String
signKey
)
{
AttachVo
attachVo
=
new
AttachVo
(
OrderTypeEnum
.
RIGHTS
.
getValue
(),
equityMembersOrder
.
getConsumerId
());
SaobeiMiniPayRequestVo
vo
=
new
SaobeiMiniPayRequestVo
();
vo
.
setSub_appid
(
appId
);
vo
.
setMerchant_no
(
saobeiConfig
.
getMerchantNo
());
vo
.
setTerminal_id
(
saobeiConfig
.
getTerminalId
());
vo
.
setAttach
(
JSONObject
.
toJSONString
(
attachVo
));
vo
.
setTerminal_trace
(
BaseUtil
.
getOrderNo
(
"WXNO"
));
vo
.
setTerminal_time
(
DateUtil
.
nowDate
(
Constants
.
DATE_TIME_FORMAT_NUM
));
vo
.
setOrder_body
(
StrUtil
.
concat
(
true
,
"开通"
+
equityMembersOrder
.
getPayPrice
().
toString
(),
"权益会员"
));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo
.
setTotal_fee
(
String
.
valueOf
(
equityMembersOrder
.
getPayPrice
().
multiply
(
BigDecimal
.
TEN
).
multiply
(
BigDecimal
.
TEN
).
intValue
()));
vo
.
setNotify_url
(
apiDomain
+
PayConstants
.
SAOBEI_PAY_NOTIFY_API_URI
);
vo
.
setTrade_type
(
PayConstants
.
WX_PAY_TRADE_TYPE_JS
);
vo
.
setOpen_id
(
openid
);
vo
.
setDevice_no
(
"WEB"
);
return
vo
;
}
}
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