Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
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
base_platform_enterprise
gic-platform-enterprise
Commits
15d767f6
Commit
15d767f6
authored
Dec 01, 2020
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码结构调整
parent
3d13d105
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
377 additions
and
61 deletions
+377
-61
BuyTypeEnum.java
...rc/main/java/com/gic/enterprise/constant/BuyTypeEnum.java
+19
-9
Constants.java
.../src/main/java/com/gic/enterprise/constant/Constants.java
+19
-0
ApprovalCallBackDTO.java
...main/java/com/gic/enterprise/dto/ApprovalCallBackDTO.java
+12
-0
AuditLogApiServiceImpl.java
...enterprise/service/outer/impl/AuditLogApiServiceImpl.java
+1
-1
BillingAccountApiServiceImpl.java
...rise/service/outer/impl/BillingAccountApiServiceImpl.java
+32
-43
BillingBalancePayApiServiceImpl.java
...e/service/outer/impl/BillingBalancePayApiServiceImpl.java
+0
-0
BillingPayInfoApiServiceImpl.java
...rise/service/outer/impl/BillingPayInfoApiServiceImpl.java
+4
-1
InternationalSmsRecordApiServiceImpl.java
...vice/outer/impl/InternationalSmsRecordApiServiceImpl.java
+2
-2
SmsRecordApiServiceImpl.java
...nterprise/service/outer/impl/SmsRecordApiServiceImpl.java
+27
-5
AliPayStrategy.java
...gic/enterprise/service/outer/impl/pay/AliPayStrategy.java
+1
-0
OfflineStrategy.java
...ic/enterprise/service/outer/impl/pay/OfflineStrategy.java
+0
-0
WxPayStrategy.java
.../gic/enterprise/service/outer/impl/pay/WxPayStrategy.java
+0
-0
PayCompleteHandler.java
...se/service/outer/impl/payComplete/PayCompleteHandler.java
+26
-0
RechargeHandler.java
...prise/service/outer/impl/payComplete/RechargeHandler.java
+125
-0
SmsPackageHandler.java
...ise/service/outer/impl/payComplete/SmsPackageHandler.java
+108
-0
dubbo-gic-platform-enterprise-service.xml
.../main/resources/dubbo-gic-platform-enterprise-service.xml
+1
-0
No files found.
gic-platform-enterprise-api/src/main/java/com/gic/enterprise/constant/BuyTypeEnum.java
View file @
15d767f6
...
...
@@ -10,18 +10,20 @@ public enum BuyTypeEnum {
/**
* 短信套餐包购买
*/
BUY_SHORT_MESSAGE_PACKAGE
(
2
,
"短信套餐包购买"
),
BUY_SHORT_MESSAGE_PACKAGE
(
2
,
"短信套餐包购买"
,
"BUY_SHORT_MESSAGE_PACKAGE"
),
/**
* 商户余额充值
*/
BALANCE_RECHARGE
(
1
,
"商户余额充值"
);
BALANCE_RECHARGE
(
1
,
"商户余额充值"
,
"BALANCE_RECHARGE"
);
private
int
code
;
private
String
message
;
private
String
type
;
private
BuyTypeEnum
(
int
code
,
String
message
)
{
private
BuyTypeEnum
(
int
code
,
String
message
,
String
type
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
type
=
type
;
}
public
static
String
getMessageByCode
(
Integer
code
)
{
...
...
@@ -36,19 +38,27 @@ public enum BuyTypeEnum {
return
"未知"
;
}
public
int
getCode
()
{
return
code
;
public
static
String
getTypeByCode
(
Integer
code
)
{
if
(
code
==
null
)
{
return
"未知"
;
}
for
(
BuyTypeEnum
typeEnum
:
values
())
{
if
(
code
.
intValue
()
==
typeEnum
.
getCode
())
{
return
typeEnum
.
getType
();
}
}
return
"未知"
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
public
int
getCode
(
)
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
messag
e
;
public
String
getType
(
)
{
return
typ
e
;
}
}
gic-platform-enterprise-api/src/main/java/com/gic/enterprise/constant/Constants.java
View file @
15d767f6
...
...
@@ -93,4 +93,23 @@ public interface Constants {
String
NATIONCODESIGN
=
"+86"
;
String
ERP
=
"erp"
;
/**
* 支付锁
*/
String
PAY_LOCK
=
"enterprise:biilingcenterpay"
;
/**
* 余额支付锁
*/
String
PAY_BALANCE_LOCK
=
"enterprise:biilingcenterbalancepay"
;
/**
* 退款锁
*/
String
REFUND_LOCK
=
"enterprise:refund"
;
/**
* 支付回调
*/
String
PAY_BACK_LOCK
=
"enterprise:biilingcentercallback"
;
}
gic-platform-enterprise-api/src/main/java/com/gic/enterprise/dto/ApprovalCallBackDTO.java
View file @
15d767f6
...
...
@@ -31,6 +31,10 @@ public class ApprovalCallBackDTO implements Serializable {
@NotNull
(
message
=
"审批时间不能为空, 格式为yyyyMMdd"
,
groups
=
ApprovalValid
.
class
)
private
String
timeEnd
;
private
String
prepayId
;
/**
* 支付类型
*/
private
Integer
payType
;
private
String
onlineSerialNumber
;
...
...
@@ -138,6 +142,14 @@ public class ApprovalCallBackDTO implements Serializable {
this
.
totalFee
=
totalFee
;
}
public
Integer
getPayType
()
{
return
payType
;
}
public
void
setPayType
(
Integer
payType
)
{
this
.
payType
=
payType
;
}
@Override
public
String
toString
()
{
return
"ApprovalCallBackDTO{"
+
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/AuditLogApiServiceImpl.java
View file @
15d767f6
...
...
@@ -329,7 +329,7 @@ public class AuditLogApiServiceImpl implements AuditLogApiService {
if
(
AuditTypeEnum
.
HAOBAN
.
getCode
().
equals
(
auditLogDTO
.
getAuditType
()))
{
position
=
StringUtils
.
isBlank
(
auditLogDTO
.
getPosition
())
?
""
:
auditLogDTO
.
getPosition
();
}
else
{
UserDTO
userDTO
=
userApiService
.
getUserById
(
auditLogDTO
.
getApplyUserId
()).
getResult
();
UserDTO
userDTO
=
userApiService
.
getUser
Info
ById
(
auditLogDTO
.
getApplyUserId
()).
getResult
();
LoginUserTypeEnum
userTypeEnum
=
LoginUserTypeEnum
.
getByCode
(
userDTO
.
getLoginType
());
position
=
userTypeEnum
!=
null
?
userTypeEnum
.
getMessage
()
:
""
;
}
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/BillingAccountApiServiceImpl.java
View file @
15d767f6
...
...
@@ -238,44 +238,21 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
@Override
public
ServiceResponse
<
Integer
>
deductAccount
(
double
totalFee
,
Integer
enterpriseId
)
{
if
(
isNotInWhiteList
(
enterpriseId
))
{
TabBillingAccount
billingAccount
=
billingAccountService
.
getByEnterpriseId
(
enterpriseId
);
Double
accountBalance
=
billingAccount
.
getAccountBalance
();
if
(
accountBalance
>=
0
)
{
int
i
=
billingAccountService
.
deductAccount
(
totalFee
,
enterpriseId
);
LOGGER
.
info
(
"扣费是否成功:{}"
,
i
>
0
);
if
(
i
>
0
)
{
TabBillingAccount
account
=
this
.
billingAccountService
.
getByEnterpriseId
(
enterpriseId
);
if
(
account
.
getAccountBalance
()
<
0
)
{
Object
cache
=
RedisUtil
.
getCache
(
"message:"
+
enterpriseId
);
if
(
cache
==
null
)
{
String
content
=
"您的达摩账户已欠费, 为避免您的业务受到影响,请及时<a href='"
+
config
.
getHost
()
+
"cost-center/billing-center/recharge'>充值</a>"
;
this
.
pushMessageApiService
.
pushMessage
(
enterpriseId
,
"系统消息"
,
"商户欠费"
,
content
);
sendSms
(
enterpriseId
,
"GICJFZX012"
);
// 待办事项
sendTotoItem
(
enterpriseId
,
"您的达摩账户已欠费"
);
RedisUtil
.
setCache
(
"message:"
+
enterpriseId
,
1
,
1L
,
TimeUnit
.
DAYS
);
}
}
else
if
(
account
.
getAccountBalance
()
<
ACCOUNT_NOTICE_LINE
)
{
Object
cache
=
RedisUtil
.
getCache
(
"insufficientAccountBalanceMessage:"
+
enterpriseId
);
if
(
cache
==
null
)
{
String
content
=
"您的达摩账户余额已不足1000元,若账户欠费将中断部分正常业务,请及时<a href='"
+
config
.
getHost
()
+
"cost-center/billing-center/recharge'>充值</a>"
;
this
.
pushMessageApiService
.
pushMessage
(
enterpriseId
,
"系统消息"
,
"商户欠费"
,
content
);
sendSms
(
enterpriseId
,
"GICJFZX001"
);
// 待办事项
sendTotoItem
(
enterpriseId
,
"您的达摩账户余额已不足1000元"
);
RedisUtil
.
setCache
(
"insufficientAccountBalanceMessage:"
+
enterpriseId
,
1
,
7L
,
TimeUnit
.
DAYS
);
}
}
}
return
ServiceResponse
.
success
(
i
);
}
else
{
return
ServiceResponse
.
failure
(
ErrorCode
.
OPERATION_FAILED
.
getCode
(),
"余额不足"
);
}
}
else
{
// 在白名单中
if
(
isInWhiteList
(
enterpriseId
))
{
int
i
=
billingAccountService
.
deductAccount
(
totalFee
,
enterpriseId
);
return
ServiceResponse
.
success
(
i
);
}
// 不在白名单中
TabBillingAccount
billingAccount
=
billingAccountService
.
getByEnterpriseId
(
enterpriseId
);
Double
accountBalance
=
billingAccount
.
getAccountBalance
();
if
(
accountBalance
<
0
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
OPERATION_FAILED
.
getCode
(),
"余额不足"
);
}
int
i
=
billingAccountService
.
deductAccount
(
totalFee
,
enterpriseId
);
LOGGER
.
info
(
"扣费是否成功:{}"
,
i
>
0
);
return
ServiceResponse
.
success
(
i
);
}
private
void
sendSms
(
Integer
enterpriseId
,
String
sceneId
)
{
...
...
@@ -300,14 +277,21 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
Integer
enterpriseId
=
enterpriseDTO
.
getEnterpriseId
();
if
(
isNotInWhiteList
(
enterpriseId
))
{
TabBillingAccount
account
=
this
.
billingAccountService
.
getByEnterpriseId
(
enterpriseId
);
if
(
account
.
getAccountBalance
()
<
ACCOUNT_NOTICE_LINE
)
{
String
[]
smsArr
=
new
String
[]{
enterpriseDTO
.
getEnterpriseName
(),
String
.
valueOf
(-
account
.
getAccountBalance
())};
ServiceResponse
<
UserDTO
>
userResult
=
userApiService
.
getUserByEnterpriseId
(
enterpriseId
);
UserDTO
userDTO
=
userResult
.
getResult
();
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
account
.
getAccountBalance
()
<
0
?
"GICJFZX012"
:
"GICJFZX001"
,
enterpriseId
,
userDTO
.
getPhoneAreaCode
(),
userDTO
.
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
LOGGER
.
warn
(
smsSendResult
.
getMessage
());
if
(
account
.
getAccountBalance
()
<
0
)
{
String
content
=
"您的达摩账户已欠费, 为避免您的业务受到影响,请及时<a href='"
+
config
.
getHost
()
+
"cost-center/billing-center/recharge'>充值</a>"
;
this
.
pushMessageApiService
.
pushMessage
(
enterpriseId
,
"系统消息"
,
"商户欠费"
,
content
);
sendSms
(
enterpriseId
,
"GICJFZX012"
);
// 待办事项
sendTotoItem
(
enterpriseId
,
"您的达摩账户已欠费"
);
}
else
if
(
account
.
getAccountBalance
()
<
ACCOUNT_NOTICE_LINE
)
{
Object
cache
=
RedisUtil
.
getCache
(
"insufficientAccountBalanceMessage:"
+
enterpriseId
);
if
(
cache
==
null
)
{
String
content
=
"您的达摩账户余额已不足1000元,若账户欠费将中断部分正常业务,请及时<a href='"
+
config
.
getHost
()
+
"cost-center/billing-center/recharge'>充值</a>"
;
this
.
pushMessageApiService
.
pushMessage
(
enterpriseId
,
"系统消息"
,
"商户欠费"
,
content
);
sendSms
(
enterpriseId
,
"GICJFZX001"
);
// 待办事项
sendTotoItem
(
enterpriseId
,
"您的达摩账户余额已不足1000元"
);
RedisUtil
.
setCache
(
"insufficientAccountBalanceMessage:"
+
enterpriseId
,
1
,
7L
,
TimeUnit
.
DAYS
);
}
}
}
...
...
@@ -320,6 +304,11 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
return
this
.
enterpriseWhiteListService
.
getEnterpriseWhiteList
(
enterpriseId
)
==
null
;
}
private
boolean
isInWhiteList
(
Integer
enterpriseId
)
{
// 判断商户在不在白名单中
return
this
.
enterpriseWhiteListService
.
getEnterpriseWhiteList
(
enterpriseId
)
!=
null
;
}
private
void
sendTotoItem
(
Integer
enterpriseId
,
String
content
)
{
TodoItemDTO
todoItemDTO
=
new
TodoItemDTO
();
UserDTO
userDTO
=
userApiService
.
getUserByEnterpriseId
(
enterpriseId
).
getResult
();
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/BillingBalancePayApiServiceImpl.java
View file @
15d767f6
This diff is collapsed.
Click to expand it.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/BillingPayInfoApiServiceImpl.java
View file @
15d767f6
...
...
@@ -59,7 +59,6 @@ public class BillingPayInfoApiServiceImpl implements BillingPayInfoApiService {
@Autowired
public
BillingPayInfoApiServiceImpl
(
Map
<
String
,
PayStrategy
>
strategyMap
)
{
this
.
strategyMap
.
clear
();
this
.
strategyMap
.
putAll
(
strategyMap
);
}
...
...
@@ -126,7 +125,10 @@ public class BillingPayInfoApiServiceImpl implements BillingPayInfoApiService {
approvalCallBackDTO
.
setPrepayId
(
resData
.
getPrepay_id
());
approvalCallBackDTO
.
setResultCode
(
StringUtils
.
equalsIgnoreCase
(
resData
.
getResult_code
(),
"SUCCESS"
)
?
1
:
0
);
approvalCallBackDTO
.
setTotalFeePaid
(
new
BigDecimal
(
resData
.
getTotal_fee
()).
divide
(
new
BigDecimal
(
"100"
),
5
,
RoundingMode
.
HALF_UP
).
doubleValue
());
approvalCallBackDTO
.
setTotalFee
(
approvalCallBackDTO
.
getTotalFeePaid
());
approvalCallBackDTO
.
setOnlineSerialNumber
(
resData
.
getTransaction_id
());
approvalCallBackDTO
.
setAuditStatus
(
BillingAuditStatusEnum
.
PASS
.
getCode
());
approvalCallBackDTO
.
setPayType
(
PayTypeEnum
.
WE_CHAT_PAY
.
getCode
());
return
strategyMap
.
get
(
PayTypeEnum
.
WE_CHAT_PAY
.
getCode
()
+
""
).
callBack
(
approvalCallBackDTO
);
}
...
...
@@ -145,6 +147,7 @@ public class BillingPayInfoApiServiceImpl implements BillingPayInfoApiService {
// 银行回调取计划金额
approvalCallBackDTO
.
setTotalFee
(
jsonObject
.
getDouble
(
"plannedAmount"
));
approvalCallBackDTO
.
setTotalFeePaid
(
jsonObject
.
getDouble
(
"accountAmount"
));
approvalCallBackDTO
.
setPayType
(
PayTypeEnum
.
OFFLINE_PAY
.
getCode
());
ServiceResponse
<
Void
>
validParam
=
ValidParamsUtils
.
allCheckValidate
(
approvalCallBackDTO
,
ApprovalCallBackDTO
.
ApprovalValid
.
class
);
if
(!
validParam
.
isSuccess
())
{
return
validParam
;
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/InternationalSmsRecordApiServiceImpl.java
View file @
15d767f6
...
...
@@ -147,11 +147,11 @@ public class InternationalSmsRecordApiServiceImpl implements InternationalSmsRec
*/
private
void
setUserName
(
InternationalSmsRecordDTO
smsRecordDTO
)
{
if
(
smsRecordDTO
.
getUserId
()
!=
null
)
{
ServiceResponse
<
UserDTO
>
userResp
=
userApiService
.
getUserById
(
smsRecordDTO
.
getUserId
());
ServiceResponse
<
UserDTO
>
userResp
=
userApiService
.
getUser
Info
ById
(
smsRecordDTO
.
getUserId
());
if
(
userResp
.
isSuccess
())
{
UserDTO
userDTO
=
userResp
.
getResult
();
if
(
userDTO
!=
null
)
{
smsRecordDTO
.
setUserName
(
smsRecord
DTO
.
getUserName
());
smsRecordDTO
.
setUserName
(
user
DTO
.
getUserName
());
}
}
else
{
logger
.
info
(
"userId:{}, UserApiService.getUserById 调用失败:{}"
,
smsRecordDTO
.
getUserId
(),
userResp
.
getMessage
());
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/SmsRecordApiServiceImpl.java
View file @
15d767f6
...
...
@@ -111,10 +111,28 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
logger
.
info
(
"短信验证不通过:{}"
,
paramResult
.
getMessage
());
return
paramResult
;
}
// 判断是扣套餐包还是扣余额
RAtomicLong
smsCount
=
billingEnterpriseSmsPackageService
.
getTotalSmsInPackageByEnterpriseId
(
smsRecordDTO
.
getEnterpriseId
());
smsRecordDTO
.
setCacheStatus
(
0
);
smsRecordDTO
.
setDatabaseStatus
(
0
);
// 缓存扣费 0套餐包 4余额
Integer
fee
=
accountStandardService
.
queryUnitFee
(
smsRecordDTO
.
getEnterpriseId
(),
AccountStandardEnum
.
SMS
.
getCode
());
int
deductType
=
deduct
(
smsCount
,
smsRecordDTO
.
getEnterpriseId
(),
fee
);
smsRecordDTO
.
setPayType
(
deductType
);
smsRecordDTO
.
setFee
((
double
)
fee
/
1000
);
Long
smsRecordId
=
billingSmsRecordService
.
saveSmsRecord
(
smsRecordDTO
);
smsRecordDTO
.
setSmsRecordId
(
smsRecordId
);
billingSmsRecordService
.
updateCacheStatus
(
smsRecordDTO
.
getSmsRecordId
());
smsRecordDTO
.
setCacheStatus
(
1
);
// 队列
GicMQClient
client
=
GICMQClientUtil
.
getClientInstance
();
try
{
String
json
=
JSON
.
toJSONString
(
smsRecordDTO
);
client
.
sendMessage
(
"smsMq"
,
json
);
client
.
sendMessage
(
"smsDbMq"
,
JSON
.
toJSONString
(
smsRecordDTO
));
}
catch
(
Exception
e
)
{
logger
.
warn
(
"调用mq失败"
,
e
);
}
...
...
@@ -126,7 +144,7 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
@Override
public
ServiceResponse
<
Void
>
run
(
String
arg
)
{
// 缓存中计费
/
*/
/ 缓存中计费
GicMQClient client = GICMQClientUtil.getClientInstance();
try {
logger.info("国内短信缓存扣费:{}", arg);
...
...
@@ -154,17 +172,21 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
} catch (Exception e) {
logger.warn("调用mq失败", e);
}
*/
return
ServiceResponse
.
success
();
}
private
int
deduct
(
RAtomicLong
rSmsCount
,
Integer
enterpriseId
,
Integer
fee
)
{
long
smsCount
=
rSmsCount
.
get
();
if
(
smsCount
>
0
)
{
// 套餐包计费
/*
套餐包计费
这里不能改成 decrementAndGet自减, 否则会出现减到0的情况
*/
boolean
smsCountDeduct
=
rSmsCount
.
compareAndSet
(
smsCount
,
smsCount
-
1
);
// rSmsCount.decrementAndGet();
if
(!
smsCountDeduct
)
{
// 设置失败 重新计算
// todo 这里不知道要不要加个延时之类的
return
deduct
(
rSmsCount
,
enterpriseId
,
fee
);
}
else
{
return
0
;
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/pay/AliPayStrategy.java
View file @
15d767f6
...
...
@@ -36,6 +36,7 @@ public class AliPayStrategy implements PayStrategy {
@Override
public
ServiceResponse
<
Void
>
callBack
(
ApprovalCallBackDTO
resData
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
UNKNOWN_ERROR
.
getCode
(),
ErrorCode
.
UNKNOWN_ERROR
.
getMsg
());
}
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/pay/OfflineStrategy.java
View file @
15d767f6
This diff is collapsed.
Click to expand it.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/pay/WxPayStrategy.java
View file @
15d767f6
This diff is collapsed.
Click to expand it.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/payComplete/PayCompleteHandler.java
0 → 100644
View file @
15d767f6
package
com
.
gic
.
enterprise
.
service
.
outer
.
impl
.
payComplete
;
import
com.gic.enterprise.dto.ApprovalCallBackDTO
;
import
com.gic.enterprise.entity.TabBillingPayInfo
;
/**
*
* @Description:
* @author zhiwj
* @date 2020-11-24 15:39
*/
public
interface
PayCompleteHandler
{
/**
* 购买套餐包或余额充值以后的统一处理
* @Title: payComplete
* @Description:
* @author zhiwj
* @param callBackDTO
* @param billingPayInfo
* @return void
* @throws
*/
void
payComplete
(
ApprovalCallBackDTO
callBackDTO
,
TabBillingPayInfo
billingPayInfo
);
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/payComplete/RechargeHandler.java
0 → 100644
View file @
15d767f6
package
com
.
gic
.
enterprise
.
service
.
outer
.
impl
.
payComplete
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.enterprise.constant.BillingAuditStatusEnum
;
import
com.gic.enterprise.constant.PayTypeEnum
;
import
com.gic.enterprise.dto.ApprovalCallBackDTO
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.entity.TabBillingPayInfo
;
import
com.gic.enterprise.entity.TabBillingRechargeRecord
;
import
com.gic.enterprise.service.BillingRechargeRecordService
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
com.gic.enterprise.service.PushMessageApiService
;
import
com.gic.log.api.dto.SystemSetLogDTO
;
import
com.gic.log.api.service.LogApiService
;
import
com.gic.marketing.process.api.service.sms.SmsSendApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* 余额充值支付完成
* @Description:
* @author zhiwj
* @date 2020-11-24 15:57
*/
@Component
(
"BALANCE_RECHARGE"
)
public
class
RechargeHandler
implements
PayCompleteHandler
{
private
Logger
logger
=
LogManager
.
getLogger
(
RechargeHandler
.
class
);
@Autowired
private
BillingRechargeRecordService
billingRechargeRecordService
;
@Autowired
private
UserApiService
userApiService
;
@Autowired
private
PushMessageApiService
pushMessageApiService
;
@Autowired
private
EnterpriseApiService
enterpriseApiService
;
@Autowired
private
SmsSendApiService
smsSendApiService
;
@Autowired
private
LogApiService
logApiService
;
@Override
public
void
payComplete
(
ApprovalCallBackDTO
resData
,
TabBillingPayInfo
billingPayInfo
)
{
// 通知
pushMessageApiService
.
pushMessage
(
resData
.
getEnterpriseId
(),
"系统通知"
,
"余额充值"
,
"您的商户成功充值"
+
resData
.
getTotalFeePaid
()+
"元!感谢您的支持和使用!"
);
// 充值成功短信
sendRechargeSuccessSms
(
resData
,
billingPayInfo
.
getEnterpriseId
());
// 日志
TabBillingRechargeRecord
rechargeRecord
=
billingRechargeRecordService
.
getRechargeRecordBySerialNumber
(
billingPayInfo
.
getOrderSerialNumber
());
UserDTO
userDTO
=
userApiService
.
getUserInfoById
(
rechargeRecord
.
getInitiatorUser
()).
getResult
();
doLog
(
"充值"
,
"账户余额"
,
userDTO
);
// 审核成功短信
if
(
PayTypeEnum
.
OFFLINE_PAY
.
getCode
()
==
resData
.
getPayType
())
{
sendApprovalSms
(
resData
,
"GICJFZX008"
);
}
billingRechargeRecordService
.
updateBySerialNumber
(
resData
.
getEnterpriseId
(),
resData
.
getOrderSerialNumber
(),
resData
.
getTotalFee
(),
resData
.
getTotalFeePaid
(),
resData
.
getAuditStatus
(),
resData
.
getTimeEnd
(),
resData
.
getOnlineSerialNumber
());
}
private
void
sendApprovalSms
(
ApprovalCallBackDTO
resData
,
String
code
)
{
TabBillingRechargeRecord
rechargeRecord
=
billingRechargeRecordService
.
getRechargeRecordBySerialNumber
(
resData
.
getOrderSerialNumber
());
Integer
initiator
=
rechargeRecord
.
getInitiator
();
UserDTO
userDTO
=
userApiService
.
getUserInfoById
(
initiator
).
getResult
();
sendSms
(
resData
,
userDTO
,
code
);
}
private
void
sendRechargeSuccessSms
(
ApprovalCallBackDTO
resData
,
Integer
enterpriseId
)
{
UserDTO
userDTO
=
userApiService
.
getUserByEnterpriseId
(
enterpriseId
).
getResult
();
sendSms
(
resData
,
userDTO
,
"GICJFZX005"
);
}
private
void
sendSms
(
ApprovalCallBackDTO
resData
,
UserDTO
userDTO
,
String
code
)
{
try
{
if
(
StringUtils
.
isBlank
(
userDTO
.
getPhoneAreaCode
()))
{
userDTO
.
setPhoneAreaCode
(
"+86"
);
}
EnterpriseDTO
enterpriseDTO
=
enterpriseApiService
.
getEnterpriseById
(
userDTO
.
getEnterpriseId
()).
getResult
();
String
[]
smsArr
=
new
String
[]{
enterpriseDTO
.
getEnterpriseName
(),
resData
.
getOrderSerialNumber
(),
BillingAuditStatusEnum
.
PASS
.
getCode
().
equals
(
resData
.
getAuditStatus
())
?
"成功"
:
"失败"
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
code
,
userDTO
.
getEnterpriseId
(),
userDTO
.
getPhoneAreaCode
(),
userDTO
.
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
logger
.
warn
(
smsSendResult
.
getMessage
());
}
}
catch
(
Exception
e
)
{
logger
.
info
(
"发送短信失败"
,
e
);
}
}
private
void
doLog
(
String
content
,
String
operationObject
,
UserDTO
userDTO
)
{
final
SystemSetLogDTO
logDTO
=
new
SystemSetLogDTO
();
//操作时间
logDTO
.
setLogTime
(
new
Date
());
logDTO
.
setCreateTime
(
new
Date
());
//操作人
logDTO
.
setUserId
(
Long
.
valueOf
(
userDTO
.
getUserId
()));
logDTO
.
setUserName
(
userDTO
.
getUserName
());
//操作内容
logDTO
.
setContent
(
content
);
//为了search查询,暂时用这个字段存
logDTO
.
setInterfaceName
(
content
);
////操作对象
logDTO
.
setBusinessName
(
operationObject
);
//操作模块
logDTO
.
setRelationId
(
45000L
);
logDTO
.
setProject
(
"企业-计费中心"
);
// }
//账号(手机号)
logDTO
.
setRemark1
(
userDTO
.
getPhoneAreaCode
());
logDTO
.
setRemark2
(
userDTO
.
getPhoneNumber
());
logDTO
.
setEnterpriseId
(
userDTO
.
getEnterpriseId
().
longValue
());
EnterpriseDTO
enterpriseDTO
=
enterpriseApiService
.
getEnterpriseById
(
userDTO
.
getEnterpriseId
()).
getResult
();
logDTO
.
setEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
());
logApiService
.
saveSystemSetLog
(
logDTO
);
}
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/payComplete/SmsPackageHandler.java
0 → 100644
View file @
15d767f6
package
com
.
gic
.
enterprise
.
service
.
outer
.
impl
.
payComplete
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.UserDTO
;
import
com.gic.auth.service.UserApiService
;
import
com.gic.enterprise.constant.BillingAuditStatusEnum
;
import
com.gic.enterprise.dto.ApprovalCallBackDTO
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.entity.TabBillingOrder
;
import
com.gic.enterprise.entity.TabBillingPayInfo
;
import
com.gic.enterprise.service.BillingOrderService
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
com.gic.log.api.dto.SystemSetLogDTO
;
import
com.gic.log.api.service.LogApiService
;
import
com.gic.marketing.process.api.service.sms.SmsSendApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
*
* @Description:
* @author zhiwj
* @date 2020-11-24 16:01
*/
@Component
(
"BUY_SHORT_MESSAGE_PACKAGE"
)
public
class
SmsPackageHandler
implements
PayCompleteHandler
{
private
Logger
logger
=
LogManager
.
getLogger
(
SmsPackageHandler
.
class
);
@Autowired
private
BillingOrderService
billingOrderService
;
@Autowired
private
UserApiService
userApiService
;
@Autowired
private
EnterpriseApiService
enterpriseApiService
;
@Autowired
private
SmsSendApiService
smsSendApiService
;
@Autowired
private
LogApiService
logApiService
;
@Override
public
void
payComplete
(
ApprovalCallBackDTO
resData
,
TabBillingPayInfo
billingPayInfo
)
{
billingOrderService
.
updateBySerialNumber
(
resData
.
getOrderSerialNumber
(),
resData
.
getTotalFeePaid
(),
resData
.
getAuditStatus
(),
resData
.
getTimeEnd
());
TabBillingOrder
order
=
this
.
billingOrderService
.
getOrderBySerialNumber
(
resData
.
getOrderSerialNumber
());
UserDTO
user
=
userApiService
.
getUserInfoById
(
order
.
getInitiatorUser
()).
getResult
();
doLog
(
"支付"
,
"订单内容"
,
user
);
sendOrderApprovalSms
(
resData
,
"GICJFZX006"
);
}
private
void
sendOrderApprovalSms
(
ApprovalCallBackDTO
resData
,
String
code
)
{
TabBillingOrder
order
=
billingOrderService
.
getOrderBySerialNumber
(
resData
.
getOrderSerialNumber
());
Integer
initiator
=
order
.
getInitiatorUser
();
if
(
initiator
!=
null
)
{
UserDTO
userDTO
=
userApiService
.
getUserInfoById
(
initiator
).
getResult
();
sendSms
(
resData
,
userDTO
,
code
);
}
}
private
void
sendSms
(
ApprovalCallBackDTO
resData
,
UserDTO
userDTO
,
String
code
)
{
try
{
if
(
StringUtils
.
isBlank
(
userDTO
.
getPhoneAreaCode
()))
{
userDTO
.
setPhoneAreaCode
(
"+86"
);
}
EnterpriseDTO
enterpriseDTO
=
enterpriseApiService
.
getEnterpriseById
(
userDTO
.
getEnterpriseId
()).
getResult
();
String
[]
smsArr
=
new
String
[]{
enterpriseDTO
.
getEnterpriseName
(),
resData
.
getOrderSerialNumber
(),
BillingAuditStatusEnum
.
PASS
.
getCode
().
equals
(
resData
.
getAuditStatus
())
?
"成功"
:
"失败"
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
code
,
userDTO
.
getEnterpriseId
(),
userDTO
.
getPhoneAreaCode
(),
userDTO
.
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
logger
.
warn
(
smsSendResult
.
getMessage
());
}
}
catch
(
Exception
e
)
{
logger
.
info
(
"发送短信失败"
,
e
);
}
}
private
void
doLog
(
String
content
,
String
operationObject
,
UserDTO
userDTO
)
{
final
SystemSetLogDTO
logDTO
=
new
SystemSetLogDTO
();
//操作时间
logDTO
.
setLogTime
(
new
Date
());
logDTO
.
setCreateTime
(
new
Date
());
//操作人
logDTO
.
setUserId
(
Long
.
valueOf
(
userDTO
.
getUserId
()));
logDTO
.
setUserName
(
userDTO
.
getUserName
());
//操作内容
logDTO
.
setContent
(
content
);
//为了search查询,暂时用这个字段存
logDTO
.
setInterfaceName
(
content
);
////操作对象
logDTO
.
setBusinessName
(
operationObject
);
//操作模块
logDTO
.
setRelationId
(
45000L
);
logDTO
.
setProject
(
"企业-计费中心"
);
// }
//账号(手机号)
logDTO
.
setRemark1
(
userDTO
.
getPhoneAreaCode
());
logDTO
.
setRemark2
(
userDTO
.
getPhoneNumber
());
logDTO
.
setEnterpriseId
(
userDTO
.
getEnterpriseId
().
longValue
());
EnterpriseDTO
enterpriseDTO
=
enterpriseApiService
.
getEnterpriseById
(
userDTO
.
getEnterpriseId
()).
getResult
();
logDTO
.
setEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
());
logApiService
.
saveSystemSetLog
(
logDTO
);
}
}
gic-platform-enterprise-service/src/main/resources/dubbo-gic-platform-enterprise-service.xml
View file @
15d767f6
...
...
@@ -149,4 +149,5 @@
<dubbo:reference
interface=
"com.gic.widget.screening.api.service.EsScreeningEnterpriseInitService"
id=
"esScreeningEnterpriseInitService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.cloud.service.IndexDescApiService"
id=
"indexDescApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.member.tag.api.service.SceneCrowdGroupApiService"
id=
"sceneCrowdGroupApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.store.service.StoreWidgetApiService"
id=
"storeWidgetApiService"
timeout=
"6000"
/>
</beans>
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