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
21cc67ca
Commit
21cc67ca
authored
Dec 15, 2020
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码结构调整
parent
16990677
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
BillingEnterpriseSmsPackageServiceImpl.java
.../service/impl/BillingEnterpriseSmsPackageServiceImpl.java
+9
-9
SmsRecordApiServiceImpl.java
...nterprise/service/outer/impl/SmsRecordApiServiceImpl.java
+11
-2
No files found.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/impl/BillingEnterpriseSmsPackageServiceImpl.java
View file @
21cc67ca
...
...
@@ -18,6 +18,8 @@ import org.springframework.stereotype.Service;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
*
* @ClassName: BillingEnterpriseSmsPackageServiceImpl
...
...
@@ -77,19 +79,17 @@ public class BillingEnterpriseSmsPackageServiceImpl implements BillingEnterprise
@Override
public
RAtomicLong
getTotalSmsInPackageByEnterpriseId
(
Integer
enterpriseId
)
{
RedissonClient
redisClient
=
RedisUtil
.
getRedisClient
();
RAtomicLong
smsCountR
=
redisClient
.
getAtomicLong
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT
+
enterpriseId
);
long
smsPackageCount
=
smsCountR
.
get
();
if
(
smsPackageCount
==
0
)
{
Long
smsCountCache
=
RedisUtil
.
getCache
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT
+
enterpriseId
,
Long
.
class
);
if
(
smsCountCache
==
null
)
{
try
{
RedisUtil
.
lock
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT_LOCK
+
enterpriseId
,
30L
);
logger
.
info
(
"redis中没有套餐包 查询数据库:{}"
,
enterpriseId
);
Integer
totalSms
=
tabBillingEnterpriseSmsPackageMapper
.
getTotalSmsInPackageByEnterpriseId
(
enterpriseId
);
if
(
totalSms
!=
null
)
{
smsCountR
.
set
(
totalSms
);
}
else
{
smsCountR
.
set
(
0
);
}
RedisUtil
.
setCache
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT
+
enterpriseId
,
totalSms
!=
null
?
totalSms
:
0
,
1L
,
TimeUnit
.
HOURS
);
}
finally
{
RedisUtil
.
unlock
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT_LOCK
+
enterpriseId
);
}
return
smsCountR
;
}
return
redisClient
.
getAtomicLong
(
Constants
.
ENTERPRISE_BILLING_SMS_PACKAGE_COUNT
+
enterpriseId
);
}
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/SmsRecordApiServiceImpl.java
View file @
21cc67ca
...
...
@@ -183,14 +183,23 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
套餐包计费
这里不能改成 decrementAndGet自减, 否则会出现减到0的情况
*/
boolean
smsCountDeduct
=
rSmsCount
.
compareAndSet
(
smsCount
,
smsCount
-
1
);
long
curr
=
rSmsCount
.
decrementAndGet
();
if
(
curr
<
0
)
{
// 因为并发超扣了 套餐包已经用完 那应该扣账户
billingAccountService
.
deductAccountByCache
(
fee
.
doubleValue
()
/
1000
,
enterpriseId
);
return
4
;
}
else
{
// 扣套餐包正常
return
0
;
}
/* boolean smsCountDeduct = rSmsCount.compareAndSet(smsCount, smsCount - 1);
// rSmsCount.decrementAndGet();
if (!smsCountDeduct) {
// 设置失败 重新计算
return deduct(rSmsCount, enterpriseId, fee);
} else {
return 0;
}
}
*/
}
else
{
// 账户计费
billingAccountService
.
deductAccountByCache
(
fee
.
doubleValue
()
/
1000
,
enterpriseId
);
...
...
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