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
c88ea733
Commit
c88ea733
authored
Jun 24, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改抖音验券
parent
3bf6045f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
75 deletions
+76
-75
TiktokServiceImpl.java
...ain/java/share/system/service/impl/TiktokServiceImpl.java
+76
-75
No files found.
share-system/src/main/java/share/system/service/impl/TiktokServiceImpl.java
View file @
c88ea733
...
...
@@ -379,15 +379,15 @@ public class TiktokServiceImpl implements TiktokService {
JSONObject
sku
=
entries
.
getJSONObject
(
"sku"
);
JSONObject
amount
=
entries
.
getJSONObject
(
"amount"
);
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
//查询领取记录表
LambdaQueryWrapper
<
SConsumerCoupon
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
SConsumerCoupon:
:
getCouponCode
,
entries
.
getStr
(
"encrypted_code"
));
queryWrapper
.
eq
(
SConsumerCoupon:
:
getUseStatus
,
UserStatusEnum
.
UNUSED
.
getCode
());
queryWrapper
.
eq
(
SConsumerCoupon:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
SConsumerCoupon
unUsedCoupon
=
isConsumerCouponService
.
getOne
(
queryWrapper
);
if
(
ObjectUtils
.
isNotEmpty
(
unUsedCoupon
))
{
throw
new
RuntimeException
(
"该券已被领取"
);
}
//
//查询领取记录表
//
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
//
queryWrapper.eq(SConsumerCoupon::getCouponCode, entries.getStr("encrypted_code"));
//
queryWrapper.eq(SConsumerCoupon::getUseStatus, UserStatusEnum.UNUSED.getCode());
//
queryWrapper.eq(SConsumerCoupon::getIsDelete, YesNoEnum.no.getIndex());
//
SConsumerCoupon unUsedCoupon = isConsumerCouponService.getOne(queryWrapper);
//
if (ObjectUtils.isNotEmpty(unUsedCoupon)) {
//
throw new RuntimeException("该券已被领取");
//
}
TiktokCouponDto
couponDto
=
new
TiktokCouponDto
();
couponDto
.
setVerifyToken
(
prepare
.
getStr
(
"verify_token"
));
couponDto
.
setPoiId
(
sStore
.
getTiktokPoiId
());
...
...
@@ -400,73 +400,74 @@ public class TiktokServiceImpl implements TiktokService {
couponDto
.
setEncryptedCodes
(
codes
);
JSONObject
verify
=
verify
(
couponDto
);
JSONArray
verifyResults
=
verify
.
getJSONArray
(
"verify_results"
);
Object
o1
=
verifyResults
.
get
(
0
);
JSONObject
verifyResult
=
new
JSONObject
(
o1
);
String
originCode
=
verifyResult
.
getStr
(
"origin_code"
);
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
sConsumerCoupon
.
setStoreId
(
sStore
.
getId
());
sConsumerCoupon
.
setCouponCode
(
originCode
);
sConsumerCoupon
.
setEncryptedCode
(
entries
.
getStr
(
"encrypted_code"
));
sConsumerCoupon
.
setName
(
sku
.
getStr
(
"title"
));
sConsumerCoupon
.
setSourceType
(
SourceTypeEnum
.
CHECK
.
getCode
());
sConsumerCoupon
.
setPlatformType
(
PlatformTypeEnum
.
TIKTOK
.
getCode
());
sConsumerCoupon
.
setUseStatus
(
UserStatusEnum
.
UNUSED
.
getCode
());
sConsumerCoupon
.
setCreateBy
(
String
.
valueOf
(
user
.
getId
()));
sConsumerCoupon
.
setCreateTime
(
new
Date
());
Integer
originalAmount
=
amount
.
getInt
(
"list_market_amount"
);
sConsumerCoupon
.
setOriginalPrice
(
BigDecimal
.
valueOf
(
originalAmount
/
100
));
sConsumerCoupon
.
setCouponPayPrice
(
BigDecimal
.
valueOf
(
amount
.
getInt
(
"coupon_pay_amount"
)
/
100
));
//时间戳转年月日时分秒
sConsumerCoupon
.
setEndDate
(
new
Date
(
entries
.
getInt
(
"expire_time"
)
*
1000L
));
//获取本日的00:00:00
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
Date
startOfDay
=
calendar
.
getTime
();
sConsumerCoupon
.
setStartDate
(
startOfDay
);
LambdaQueryWrapper
<
SCoupon
>
sCouponLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sCouponLambdaQueryWrapper
.
eq
(
SCoupon:
:
getTiktokSkuId
,
sku
.
getStr
(
"sku_id"
));
List
<
SCoupon
>
sCoupons
=
isCouponService
.
list
(
sCouponLambdaQueryWrapper
);
SCoupon
sCoupon
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
sCoupons
))
{
sCoupon
=
sCoupons
.
get
(
0
);
}
if
(
ObjectUtils
.
isEmpty
(
sCoupon
))
{
sConsumerCoupon
.
setTiktokSkuId
(
sku
.
getStr
(
"sku_id"
));
sConsumerCoupon
.
setCouponType
(
CouponTypeEnum
.
CASH
.
getCode
());
sConsumerCoupon
.
setStoreType
(
StoreType
.
getCodeList
());
sConsumerCoupon
.
setRoomType
(
RoomType
.
getCodeList
());
verifyResults
.
forEach
(
item
->
{
JSONObject
verifyResult
=
new
JSONObject
(
item
);
String
originCode
=
verifyResult
.
getStr
(
"origin_code"
);
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
sConsumerCoupon
.
setStoreId
(
sStore
.
getId
());
sConsumerCoupon
.
setCouponCode
(
originCode
);
sConsumerCoupon
.
setEncryptedCode
(
entries
.
getStr
(
"encrypted_code"
));
sConsumerCoupon
.
setName
(
sku
.
getStr
(
"title"
));
sConsumerCoupon
.
setSourceType
(
SourceTypeEnum
.
CHECK
.
getCode
());
sConsumerCoupon
.
setPlatformType
(
PlatformTypeEnum
.
TIKTOK
.
getCode
());
sConsumerCoupon
.
setUseStatus
(
UserStatusEnum
.
UNUSED
.
getCode
());
sConsumerCoupon
.
setCreateBy
(
String
.
valueOf
(
user
.
getId
()));
sConsumerCoupon
.
setMinDuration
(
DEFAULT_MIN_DURATION
);
sConsumerCoupon
.
setMaxDuration
(
DEFAULT_MAX_DURATION
);
sConsumerCoupon
.
setDuration
(
DEFAULT_DURATION
);
sConsumerCoupon
.
setMinPrice
(
DEFAULT_MIN_PRICE
);
sConsumerCoupon
.
setCouponTimeStart
(
DEFAULT_START_TIME
);
sConsumerCoupon
.
setCouponTimeEnd
(
DEFAULT_END_TIME
);
sConsumerCoupon
.
setSalePrice
(
sConsumerCoupon
.
getCouponPayPrice
());
}
else
{
sConsumerCoupon
.
setCouponId
(
sCoupon
.
getId
());
sConsumerCoupon
.
setCouponType
(
sCoupon
.
getCouponType
());
sConsumerCoupon
.
setStoreType
(
sCoupon
.
getStoreType
());
sConsumerCoupon
.
setRoomType
(
sCoupon
.
getRoomType
());
sConsumerCoupon
.
setMinDuration
(
sCoupon
.
getMinDuration
());
sConsumerCoupon
.
setMaxDuration
(
sCoupon
.
getMaxDuration
());
sConsumerCoupon
.
setDuration
(
sCoupon
.
getDuration
());
sConsumerCoupon
.
setMinPrice
(
sCoupon
.
getMinPrice
());
sConsumerCoupon
.
setCouponTimeStart
(
sCoupon
.
getValidStartTime
());
sConsumerCoupon
.
setCouponTimeEnd
(
sCoupon
.
getValidEndTime
());
sConsumerCoupon
.
setOrderType
(
sCoupon
.
getOrderType
());
sConsumerCoupon
.
setTiktokSkuId
(
sCoupon
.
getTiktokSkuId
());
sConsumerCoupon
.
setStoreIds
(
sCoupon
.
getStoreIds
());
sConsumerCoupon
.
setPackIds
(
sCoupon
.
getPackIds
());
sConsumerCoupon
.
setWeeks
(
sCoupon
.
getWeeks
());
sConsumerCoupon
.
setRemark
(
sCoupon
.
getRemark
());
sConsumerCoupon
.
setSalePrice
(
sCoupon
.
getSalePrice
());
}
isConsumerCouponService
.
insertSConsumerCoupon
(
sConsumerCoupon
);
sConsumerCoupon
.
setCreateTime
(
new
Date
());
Integer
originalAmount
=
amount
.
getInt
(
"list_market_amount"
);
sConsumerCoupon
.
setOriginalPrice
(
BigDecimal
.
valueOf
(
originalAmount
/
100
));
sConsumerCoupon
.
setCouponPayPrice
(
BigDecimal
.
valueOf
(
amount
.
getInt
(
"coupon_pay_amount"
)
/
100
));
//时间戳转年月日时分秒
sConsumerCoupon
.
setEndDate
(
new
Date
(
entries
.
getInt
(
"expire_time"
)
*
1000L
));
//获取本日的00:00:00
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
Date
startOfDay
=
calendar
.
getTime
();
sConsumerCoupon
.
setStartDate
(
startOfDay
);
LambdaQueryWrapper
<
SCoupon
>
sCouponLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sCouponLambdaQueryWrapper
.
eq
(
SCoupon:
:
getTiktokSkuId
,
sku
.
getStr
(
"sku_id"
));
List
<
SCoupon
>
sCoupons
=
isCouponService
.
list
(
sCouponLambdaQueryWrapper
);
SCoupon
sCoupon
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
sCoupons
))
{
sCoupon
=
sCoupons
.
get
(
0
);
}
if
(
ObjectUtils
.
isEmpty
(
sCoupon
))
{
sConsumerCoupon
.
setTiktokSkuId
(
sku
.
getStr
(
"sku_id"
));
sConsumerCoupon
.
setCouponType
(
CouponTypeEnum
.
CASH
.
getCode
());
sConsumerCoupon
.
setStoreType
(
StoreType
.
getCodeList
());
sConsumerCoupon
.
setRoomType
(
RoomType
.
getCodeList
());
sConsumerCoupon
.
setCreateBy
(
String
.
valueOf
(
user
.
getId
()));
sConsumerCoupon
.
setMinDuration
(
DEFAULT_MIN_DURATION
);
sConsumerCoupon
.
setMaxDuration
(
DEFAULT_MAX_DURATION
);
sConsumerCoupon
.
setDuration
(
DEFAULT_DURATION
);
sConsumerCoupon
.
setMinPrice
(
DEFAULT_MIN_PRICE
);
sConsumerCoupon
.
setCouponTimeStart
(
DEFAULT_START_TIME
);
sConsumerCoupon
.
setCouponTimeEnd
(
DEFAULT_END_TIME
);
sConsumerCoupon
.
setSalePrice
(
sConsumerCoupon
.
getCouponPayPrice
());
}
else
{
sConsumerCoupon
.
setCouponId
(
sCoupon
.
getId
());
sConsumerCoupon
.
setCouponType
(
sCoupon
.
getCouponType
());
sConsumerCoupon
.
setStoreType
(
sCoupon
.
getStoreType
());
sConsumerCoupon
.
setRoomType
(
sCoupon
.
getRoomType
());
sConsumerCoupon
.
setMinDuration
(
sCoupon
.
getMinDuration
());
sConsumerCoupon
.
setMaxDuration
(
sCoupon
.
getMaxDuration
());
sConsumerCoupon
.
setDuration
(
sCoupon
.
getDuration
());
sConsumerCoupon
.
setMinPrice
(
sCoupon
.
getMinPrice
());
sConsumerCoupon
.
setCouponTimeStart
(
sCoupon
.
getValidStartTime
());
sConsumerCoupon
.
setCouponTimeEnd
(
sCoupon
.
getValidEndTime
());
sConsumerCoupon
.
setOrderType
(
sCoupon
.
getOrderType
());
sConsumerCoupon
.
setTiktokSkuId
(
sCoupon
.
getTiktokSkuId
());
sConsumerCoupon
.
setStoreIds
(
sCoupon
.
getStoreIds
());
sConsumerCoupon
.
setPackIds
(
sCoupon
.
getPackIds
());
sConsumerCoupon
.
setWeeks
(
sCoupon
.
getWeeks
());
sConsumerCoupon
.
setRemark
(
sCoupon
.
getRemark
());
sConsumerCoupon
.
setSalePrice
(
sCoupon
.
getSalePrice
());
}
isConsumerCouponService
.
insertSConsumerCoupon
(
sConsumerCoupon
);
});
}
catch
(
RuntimeException
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
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