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
2804e028
Commit
2804e028
authored
Feb 21, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初步完成抖音验卷
parent
33e0970b
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
306 additions
and
98 deletions
+306
-98
TiktokController.java
...in/java/share/web/controller/system/TiktokController.java
+73
-0
application-prod.yml
share-admin/src/main/resources/application-prod.yml
+4
-0
application-test.yml
share-admin/src/main/resources/application-test.yml
+7
-0
ReceiptRdeisEnum.java
...on/src/main/java/share/common/enums/ReceiptRdeisEnum.java
+4
-1
TiktokCouponStatusEnum.java
.../main/java/share/common/enums/TiktokCouponStatusEnum.java
+45
-0
TiktokController.java
...in/java/share/web/controller/system/TiktokController.java
+18
-20
application-prod.yml
share-front/src/main/resources/application-prod.yml
+4
-0
application-test.yml
share-front/src/main/resources/application-test.yml
+6
-0
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+25
-11
TiktokService.java
...tem/src/main/java/share/system/service/TiktokService.java
+3
-3
SCouponServiceImpl.java
...in/java/share/system/service/impl/SCouponServiceImpl.java
+30
-15
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+29
-13
TiktokServiceImpl.java
...ain/java/share/system/service/impl/TiktokServiceImpl.java
+58
-35
No files found.
share-admin/src/main/java/share/web/controller/system/TiktokController.java
0 → 100644
View file @
2804e028
package
share
.
web
.
controller
.
system
;
import
cn.hutool.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
share.common.core.domain.AjaxResult
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.service.TiktokService
;
import
java.util.List
;
import
static
share
.
common
.
core
.
domain
.
AjaxResult
.
success
;
@RestController
@RequestMapping
(
"/system/tiktok"
)
public
class
TiktokController
{
@Autowired
private
TiktokService
tiktokService
;
//权限限验证接口,返回client_token,用于调用其他接口,如果不需要,可以不用这个接口
@GetMapping
(
"/oauth/clientToken"
)
public
void
clientToken
()
{
tiktokService
.
clientToken
();
}
//验卷准备接口,返回code,用于调用其他接口
@PostMapping
(
"/certificate/prepare"
)
public
AjaxResult
prepare
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
prepare
(
tiktokCouponDto
));
}
//验卷接口,返回验卷结果
@PostMapping
(
"/certificate/verify"
)
public
AjaxResult
verify
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
verify
(
tiktokCouponDto
));
}
//撤销核销接口,返回撤销结果
@PostMapping
(
"/certificate/cancel"
)
public
AjaxResult
cancel
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
cancel
(
tiktokCouponDto
));
}
@GetMapping
(
"/certificate/get"
)
public
AjaxResult
certificateGet
(
String
encryptedCode
)
{
return
success
(
tiktokService
.
certificateGet
(
encryptedCode
));
}
@GetMapping
(
"/poi/query"
)
public
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
poiQuery
(
tiktokCouponDto
);
}
//查询所有线上商品数据列表
@GetMapping
(
"/online/query"
)
public
JSONObject
onlineQuery
(
OnlineQueryDto
onlineQueryDto
)
{
return
tiktokService
.
onlineQuery
(
onlineQueryDto
);
}
@GetMapping
(
"/online/gets"
)
public
JSONObject
onlineGet
(
String
productIds
,
String
accountId
)
{
return
tiktokService
.
onlineGet
(
productIds
,
accountId
);
}
//用户验券接口
@GetMapping
(
"/consumeByUser"
)
public
AjaxResult
consumeByUser
(
String
code
,
String
poiId
)
{
return
success
(
tiktokService
.
consumeByUser
(
code
,
poiId
));
}
}
share-admin/src/main/resources/application-prod.yml
View file @
2804e028
...
@@ -31,6 +31,10 @@ wx:
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
XML
msgDataFormat
:
XML
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
#扫呗支付配置
saobei
:
saobei
:
key
:
15490267
key
:
15490267
...
...
share-admin/src/main/resources/application-test.yml
View file @
2804e028
...
@@ -31,6 +31,10 @@ wx:
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
XML
msgDataFormat
:
XML
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
#扫呗支付配置
saobei
:
saobei
:
key
:
15490267
key
:
15490267
...
@@ -220,3 +224,5 @@ order:
...
@@ -220,3 +224,5 @@ order:
mqtt
:
mqtt
:
device-op-last-time
:
-5
device-op-last-time
:
-5
device-gateway-last-report-time
:
-10
device-gateway-last-report-time
:
-10
api
:
domain
:
https://www.coujio.com
\ No newline at end of file
share-common/src/main/java/share/common/enums/ReceiptRdeisEnum.java
View file @
2804e028
...
@@ -8,7 +8,10 @@ public enum ReceiptRdeisEnum {
...
@@ -8,7 +8,10 @@ public enum ReceiptRdeisEnum {
ORDER_NO_KEY
(
4
,
"ORDER_NO_KEY."
),
ORDER_NO_KEY
(
4
,
"ORDER_NO_KEY."
),
ACCESS_TOKEN_KEY
(
5
,
"ACCESS_TOKEN_KEY."
),
ACCESS_TOKEN_KEY
(
5
,
"ACCESS_TOKEN_KEY."
),
ORDER_NO
(
6
,
"ORDER_NO."
),
ORDER_NO
(
6
,
"ORDER_NO."
),
TIKTOK_CLIENT_TOKEN
(
7
,
"TIKTOK_CLIENT_TOKEN."
);
TIKTOK_CLIENT_TOKEN
(
7
,
"TIKTOK_CLIENT_TOKEN"
),
TIKTOK_CLIENT_TOKEN_KEY
(
8
,
"TIKTOK_CLIENT_TOKEN_KEY"
),
;
private
Integer
code
;
private
Integer
code
;
...
...
share-common/src/main/java/share/common/enums/TiktokCouponStatusEnum.java
0 → 100644
View file @
2804e028
package
share
.
common
.
enums
;
public
enum
TiktokCouponStatusEnum
{
//INIT=0 初始状态
//AVAILABLE=1 未使用
//USED=2 已使用
//REFUND_APPLYING=3 退款申请中(待审核)
//REFUND_SUCCESS=4 退款成功
//REFUND_FAILED=5 退款失败
//REFUNDING=6 退款中
INIT
(
0
,
"初始状态"
),
AVAILABLE
(
1
,
"未使用"
),
USED
(
2
,
"已使用"
),
REFUND_APPLYING
(
3
,
"退款申请中(待审核)"
),
REFUND_SUCCESS
(
4
,
"退款成功"
),
REFUND_FAILED
(
5
,
"退款失败"
),
REFUNDING
(
6
,
"退款中"
),
;
private
Integer
code
;
private
String
value
;
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
TiktokCouponStatusEnum
()
{
}
TiktokCouponStatusEnum
(
Integer
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
}
share-front/src/main/java/share/web/controller/system/TiktokController.java
View file @
2804e028
...
@@ -2,13 +2,11 @@ package share.web.controller.system;
...
@@ -2,13 +2,11 @@ package share.web.controller.system;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.domain.AjaxResult
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.service.TiktokService
;
import
share.system.service.TiktokService
;
import
java.util.List
;
import
java.util.List
;
...
@@ -16,7 +14,7 @@ import java.util.List;
...
@@ -16,7 +14,7 @@ import java.util.List;
import
static
share
.
common
.
core
.
domain
.
AjaxResult
.
success
;
import
static
share
.
common
.
core
.
domain
.
AjaxResult
.
success
;
@RestController
@RestController
@RequestMapping
(
"/chessCards"
)
@RequestMapping
(
"/
tiktok/
chessCards"
)
public
class
TiktokController
{
public
class
TiktokController
{
@Autowired
@Autowired
private
TiktokService
tiktokService
;
private
TiktokService
tiktokService
;
...
@@ -27,28 +25,28 @@ public class TiktokController {
...
@@ -27,28 +25,28 @@ public class TiktokController {
tiktokService
.
clientToken
();
tiktokService
.
clientToken
();
}
}
//验卷准备接口,返回code,用于调用其他接口
@GetMapping
(
"/certificate/prepare"
)
//验卷准备接口,返回code,用于调用其他接口
public
AjaxResult
prepare
(
TiktokCouponDto
tiktokCouponDto
)
{
@PostMapping
(
"/certificate/prepare"
)
public
AjaxResult
prepare
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
prepare
(
tiktokCouponDto
));
return
success
(
tiktokService
.
prepare
(
tiktokCouponDto
));
}
}
//验卷接口,返回验卷结果
//验卷接口,返回验卷结果
@
Ge
tMapping
(
"/certificate/verify"
)
@
Pos
tMapping
(
"/certificate/verify"
)
public
String
verify
(
TiktokCouponDto
tiktokCouponDto
)
{
public
AjaxResult
verify
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
verify
(
tiktokCouponDto
);
return
success
(
tiktokService
.
verify
(
tiktokCouponDto
)
);
}
}
//撤销核销接口,返回撤销结果
//撤销核销接口,返回撤销结果
@
Ge
tMapping
(
"/certificate/cancel"
)
@
Pos
tMapping
(
"/certificate/cancel"
)
public
String
cancel
(
TiktokCouponDto
tiktokCouponDto
)
{
public
AjaxResult
cancel
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
cancel
(
tiktokCouponDto
);
return
success
(
tiktokService
.
cancel
(
tiktokCouponDto
)
);
}
}
@GetMapping
(
"/certificate/get
)
"
)
@GetMapping
(
"/certificate/get"
)
public
String
certificateGet
(
TiktokCouponDto
tiktokCouponDto
)
{
public
AjaxResult
certificateGet
(
String
encryptedCode
)
{
return
tiktokService
.
certificateGet
(
tiktokCouponDto
);
return
success
(
tiktokService
.
certificateGet
(
encryptedCode
)
);
}
}
@GetMapping
(
"/poi/query"
)
@GetMapping
(
"/poi/query"
)
...
@@ -58,12 +56,12 @@ public class TiktokController {
...
@@ -58,12 +56,12 @@ public class TiktokController {
//查询所有线上商品数据列表
//查询所有线上商品数据列表
@GetMapping
(
"/online/query"
)
@GetMapping
(
"/online/query"
)
public
Object
onlineQuery
(
OnlineQueryDto
onlineQueryDto
)
{
public
JSON
Object
onlineQuery
(
OnlineQueryDto
onlineQueryDto
)
{
return
tiktokService
.
onlineQuery
(
onlineQueryDto
);
return
tiktokService
.
onlineQuery
(
onlineQueryDto
);
}
}
@GetMapping
(
"/online/
query
"
)
@GetMapping
(
"/online/
gets
"
)
public
Object
onlineGet
(
String
productIds
,
String
accountId
)
{
public
JSON
Object
onlineGet
(
String
productIds
,
String
accountId
)
{
return
tiktokService
.
onlineGet
(
productIds
,
accountId
);
return
tiktokService
.
onlineGet
(
productIds
,
accountId
);
}
}
...
...
share-front/src/main/resources/application-prod.yml
View file @
2804e028
...
@@ -31,6 +31,10 @@ wx:
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
JSON
msgDataFormat
:
JSON
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
#扫呗支付配置
saobei
:
saobei
:
key
:
15490267
key
:
15490267
...
...
share-front/src/main/resources/application-test.yml
View file @
2804e028
...
@@ -31,6 +31,10 @@ wx:
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
JSON
msgDataFormat
:
JSON
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
#扫呗支付配置
saobei
:
saobei
:
key
:
15490267
key
:
15490267
...
@@ -217,3 +221,5 @@ order:
...
@@ -217,3 +221,5 @@ order:
mqtt
:
mqtt
:
device-op-last-time
:
-5
device-op-last-time
:
-5
device-gateway-last-report-time
:
-10
device-gateway-last-report-time
:
-10
api
:
domain
:
https://www.coujio.com
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
2804e028
...
@@ -9,19 +9,13 @@ import cn.hutool.core.util.StrUtil;
...
@@ -9,19 +9,13 @@ import cn.hutool.core.util.StrUtil;
import
cn.hutool.json.JSONException
;
import
cn.hutool.json.JSONException
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse
;
import
com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse
;
import
com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareResponse
;
import
com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient
;
import
com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -30,11 +24,12 @@ import share.common.constant.MqttConstants;
...
@@ -30,11 +24,12 @@ import share.common.constant.MqttConstants;
import
share.common.core.redis.RedisUtil
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
import
share.common.enums.*
;
import
share.common.exception.base.BaseException
;
import
share.common.exception.base.BaseException
;
import
share.system.domain.*
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SOrder
;
import
share.system.domain.SRoom
;
import
share.system.domain.SStore
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.mapper.SConsumerMapper
;
import
share.system.service.*
;
import
share.system.service.*
;
import
share.system.service.impl.SOrderServiceImpl
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -85,6 +80,10 @@ public class RedisTask {
...
@@ -85,6 +80,10 @@ public class RedisTask {
@Autowired
@Autowired
private
SConsumerService
sConsumerService
;
private
SConsumerService
sConsumerService
;
@Autowired
private
TiktokService
tiktokService
;
//15分钟的常量
//15分钟的常量
final
long
FIFTEEN_MINUTES
=
60
*
15
;
final
long
FIFTEEN_MINUTES
=
60
*
15
;
//14分钟的常量
//14分钟的常量
...
@@ -112,13 +111,23 @@ public class RedisTask {
...
@@ -112,13 +111,23 @@ public class RedisTask {
List
<
Long
>
expiredCoupons
=
new
ArrayList
<>();
List
<
Long
>
expiredCoupons
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
coupons
))
{
if
(!
CollectionUtils
.
isEmpty
(
coupons
))
{
for
(
SConsumerCoupon
coupon
:
coupons
)
{
for
(
SConsumerCoupon
coupon
:
coupons
)
{
//验券
//美团复验券
if
(
ObjectUtil
.
isNotEmpty
(
coupon
.
getDealId
()))
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
coupon
.
getCouponCode
(),
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
coupon
.
getCouponCode
(),
stores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
coupon
.
getStoreId
())).
findFirst
().
get
().
getOpenShopUuid
());
stores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
coupon
.
getStoreId
())).
findFirst
().
get
().
getOpenShopUuid
());
if
(
getconsumed
==
null
)
{
if
(
getconsumed
==
null
)
{
expiredCoupons
.
add
(
coupon
.
getId
());
expiredCoupons
.
add
(
coupon
.
getId
());
}
}
logger
.
info
(
"券码:{}->查询结束:{}"
,
coupon
.
getCouponCode
(),
getconsumed
);
logger
.
info
(
"券码:{}->查询结束:{}"
,
coupon
.
getCouponCode
(),
getconsumed
);
}
else
if
(
StringUtils
.
isNoneEmpty
(
coupon
.
getSkuId
()))
{
//抖音复验券
JSONObject
object
=
tiktokService
.
certificateGet
(
coupon
.
getCouponCode
());
JSONObject
certificate
=
object
.
getJSONObject
(
"certificate"
);
Integer
status
=
certificate
.
getInt
(
"status"
);
if
(
status
.
equals
(
TiktokCouponStatusEnum
.
REFUND_SUCCESS
.
getCode
())
|
status
.
equals
(
TiktokCouponStatusEnum
.
REFUNDING
.
getCode
()))
{
expiredCoupons
.
add
(
coupon
.
getId
());
}
}
}
}
//逻辑删除所有异常优惠券
//逻辑删除所有异常优惠券
isConsumerCouponService
.
removeByIds
(
expiredCoupons
);
isConsumerCouponService
.
removeByIds
(
expiredCoupons
);
...
@@ -182,6 +191,11 @@ public class RedisTask {
...
@@ -182,6 +191,11 @@ public class RedisTask {
redisUtil
.
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
jsonObject
.
toString
());
redisUtil
.
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
jsonObject
.
toString
());
redisUtil
.
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
jsonObject
.
toString
(),
customerRefreshTokenResponse
.
getExpires_in
()
-
60
*
30
,
TimeUnit
.
SECONDS
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
jsonObject
.
toString
(),
customerRefreshTokenResponse
.
getExpires_in
()
-
60
*
30
,
TimeUnit
.
SECONDS
);
}
}
Boolean
tiktok
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
if
(!
tiktok
)
{
tiktokService
.
clientToken
();
}
}
}
//自动添加保洁记录
//自动添加保洁记录
...
...
share-system/src/main/java/share/system/service/TiktokService.java
View file @
2804e028
package
share
.
system
.
service
;
package
share
.
system
.
service
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.vo.OnlineQueryDto
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,11 +12,11 @@ public interface TiktokService {
...
@@ -12,11 +12,11 @@ public interface TiktokService {
JSONObject
prepare
(
TiktokCouponDto
tiktokCouponDto
);
JSONObject
prepare
(
TiktokCouponDto
tiktokCouponDto
);
String
verify
(
TiktokCouponDto
tiktokCouponDto
);
JSONObject
verify
(
TiktokCouponDto
tiktokCouponDto
);
String
cancel
(
TiktokCouponDto
tiktokCouponDto
);
String
cancel
(
TiktokCouponDto
tiktokCouponDto
);
String
certificateGet
(
TiktokCouponDto
tiktokCouponDto
);
JSONObject
certificateGet
(
String
encryptedCode
);
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
);
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
);
...
...
share-system/src/main/java/share/system/service/impl/SCouponServiceImpl.java
View file @
2804e028
package
share
.
system
.
service
.
impl
;
package
share
.
system
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
@@ -13,6 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...
@@ -13,6 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouDealQueryShopDealResponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouDealQueryShopDealResponseEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
share.common.core.page.PageDomain
;
import
share.common.core.page.PageDomain
;
...
@@ -23,16 +20,20 @@ import share.common.enums.RoomType;
...
@@ -23,16 +20,20 @@ import share.common.enums.RoomType;
import
share.common.enums.StoreType
;
import
share.common.enums.StoreType
;
import
share.common.enums.YesNoEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
share.system.domain.SConsumerCoupon
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.SCoupon
;
import
share.system.domain.
*
;
import
share.system.domain.
SStore
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.vo.SCouponVo
;
import
share.system.domain.vo.SCouponVo
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.mapper.SCouponMapper
;
import
share.system.mapper.SCouponMapper
;
import
share.system.mapper.SmsLogMapper
;
import
share.system.service.*
;
import
share.system.service.*
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* 优惠券Service业务层处理
* 优惠券Service业务层处理
*
*
...
@@ -61,7 +62,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
...
@@ -61,7 +62,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
private
static
final
String
DEFAULT_END_TIME
=
"23:00"
;
private
static
final
String
DEFAULT_END_TIME
=
"23:00"
;
private
static
final
String
TWO
=
"2"
;
private
static
final
String
TWO
=
"2"
;
@Value
(
"${tiktok.accountId}"
)
private
String
ACCOUNT_Id
;
private
String
ACCOUNT_Id
;
...
@@ -280,11 +281,15 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
...
@@ -280,11 +281,15 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
@Override
@Override
public
List
<
SCoupon
>
querySkuPoiList
()
{
public
List
<
SCoupon
>
querySkuPoiList
()
{
List
<
SStore
>
sStores
=
storeService
.
list
();
List
<
SStore
>
sStores
=
storeService
.
list
();
//过滤掉没有poiId的门店
sStores
=
sStores
.
stream
().
filter
(
store
->
StringUtils
.
isNotBlank
(
store
.
getPoiId
())).
collect
(
Collectors
.
toList
());
Map
<
String
,
SCoupon
>
sCouponList
=
new
LinkedHashMap
<>();
Map
<
String
,
SCoupon
>
sCouponList
=
new
LinkedHashMap
<>();
OnlineQueryDto
onlineQueryDto
=
new
OnlineQueryDto
();
OnlineQueryDto
onlineQueryDto
=
new
OnlineQueryDto
();
onlineQueryDto
.
setAccountId
(
ACCOUNT_Id
);
onlineQueryDto
.
setAccountId
(
ACCOUNT_Id
);
JSONObject
entries
=
tiktokService
.
onlineQuery
(
onlineQueryDto
);
JSONObject
entries
=
tiktokService
.
onlineQuery
(
onlineQueryDto
);
JSONArray
products
=
entries
.
getJSONArray
(
"products"
);
JSONArray
products
=
entries
.
getJSONArray
(
"products"
);
List
<
SStore
>
finalSStores
=
sStores
;
List
<
SStore
>
finalSStores1
=
sStores
;
products
.
stream
().
forEach
(
item
->
{
products
.
stream
().
forEach
(
item
->
{
JSONObject
jsonObject
=
(
JSONObject
)
item
;
JSONObject
jsonObject
=
(
JSONObject
)
item
;
if
(
jsonObject
.
getInt
(
"online_status"
).
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
if
(
jsonObject
.
getInt
(
"online_status"
).
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
...
@@ -298,7 +303,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
...
@@ -298,7 +303,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon
.
setName
(
sku
.
getStr
(
"sku_name"
));
sCoupon
.
setName
(
sku
.
getStr
(
"sku_name"
));
sCoupon
.
setStartDate
(
new
Date
(
product
.
getInt
(
"sold_start_time"
)
*
1000L
));
sCoupon
.
setStartDate
(
new
Date
(
product
.
getInt
(
"sold_start_time"
)
*
1000L
));
sCoupon
.
setEndDate
(
new
Date
(
product
.
getInt
(
"sold_end_time"
)
*
1000L
));
sCoupon
.
setEndDate
(
new
Date
(
product
.
getInt
(
"sold_end_time"
)
*
1000L
));
sCoupon
.
setSubPrice
(
jsonObject
.
getBigDecimal
(
"origin_amount"
).
divide
(
new
BigDecimal
(
"100"
)));
sCoupon
.
setSubPrice
(
sku
.
getBigDecimal
(
"origin_amount"
).
divide
(
new
BigDecimal
(
"100"
)));
sCoupon
.
setRoomType
(
RoomType
.
getCodeList
());
sCoupon
.
setRoomType
(
RoomType
.
getCodeList
());
sCoupon
.
setStoreType
(
StoreType
.
getCodeList
());
sCoupon
.
setStoreType
(
StoreType
.
getCodeList
());
sCoupon
.
setValidStartTime
(
DEFAULT_START_TIME
);
sCoupon
.
setValidStartTime
(
DEFAULT_START_TIME
);
...
@@ -307,15 +312,25 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
...
@@ -307,15 +312,25 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon
.
setMaxDuration
(
DEFAULT_MAX_DURATION
);
sCoupon
.
setMaxDuration
(
DEFAULT_MAX_DURATION
);
sCoupon
.
setMinPrice
(
new
BigDecimal
(
"0.00"
));
sCoupon
.
setMinPrice
(
new
BigDecimal
(
"0.00"
));
sCoupon
.
setCouponType
(
CouponTypeEnum
.
CASH
.
getCode
());
sCoupon
.
setCouponType
(
CouponTypeEnum
.
CASH
.
getCode
());
if
(
finalSStores
.
size
()
==
0
)
{
sCouponList
.
put
(
sku
.
getStr
(
"sku_id"
),
sCoupon
);
return
;
}
pois
.
stream
().
forEach
(
poi
->
{
pois
.
stream
().
forEach
(
poi
->
{
JSONObject
jsonObject1
=
(
JSONObject
)
poi
;
JSONObject
jsonObject1
=
(
JSONObject
)
poi
;
sCoupon
.
setStoreIds
(
sCoupon
.
getStoreIds
()
+
","
+
sStores
.
stream
().
filter
(
store
->
store
.
getPoiId
().
equals
(
jsonObject1
.
getStr
(
"poi_id"
))).
findFirst
().
get
().
getId
());
if
(
StringUtils
.
isEmpty
(
sCoupon
.
getStoreIds
()))
{
//判断
sCoupon
.
setStoreIds
(
String
.
valueOf
(
finalSStores
.
stream
().
filter
(
store
->
jsonObject1
.
getStr
(
"poi_id"
).
equals
(
store
.
getPoiId
())).
findFirst
().
get
().
getId
()));
}
else
{
sCoupon
.
setStoreIds
(
sCoupon
.
getStoreIds
()
+
","
+
finalSStores
.
stream
().
filter
(
store
->
jsonObject1
.
getStr
(
"poi_id"
).
equals
(
store
.
getPoiId
())).
findFirst
().
get
().
getId
());
}
});
});
sCouponList
.
put
(
sku
.
getStr
(
"sku_id"
),
sCoupon
);
sCouponList
.
put
(
sku
.
getStr
(
"sku_id"
),
sCoupon
);
}
else
{
}
else
{
pois
.
stream
().
forEach
(
poi
->
{
pois
.
stream
().
forEach
(
poi
->
{
JSONObject
jsonObject1
=
(
JSONObject
)
poi
;
JSONObject
jsonObject1
=
(
JSONObject
)
poi
;
sCoupon1
.
setStoreIds
(
sCoupon1
.
getStoreIds
()
+
","
+
sStores
.
stream
().
filter
(
store
->
store
.
getPoiId
().
equals
(
jsonObject1
.
getStr
(
"poi_id"
))).
findFirst
().
get
().
getId
());
sCoupon1
.
setStoreIds
(
sCoupon1
.
getStoreIds
()
+
","
+
finalSStores1
.
stream
().
filter
(
store
->
store
.
getPoiId
().
equals
(
jsonObject1
.
getStr
(
"poi_id"
))).
findFirst
().
get
().
getId
());
});
});
}
}
}
}
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
2804e028
package
share
.
system
.
service
.
impl
;
package
share
.
system
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUnit
;
...
@@ -20,7 +15,9 @@ import org.apache.commons.collections4.CollectionUtils;
...
@@ -20,7 +15,9 @@ import org.apache.commons.collections4.CollectionUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
share.common.constant.Constants
;
import
share.common.constant.Constants
;
import
share.common.core.redis.RedisUtil
;
import
share.common.core.redis.RedisUtil
;
...
@@ -29,12 +26,13 @@ import share.common.exception.base.BaseException;
...
@@ -29,12 +26,13 @@ import share.common.exception.base.BaseException;
import
share.common.utils.BaseUtil
;
import
share.common.utils.BaseUtil
;
import
share.common.utils.DateUtil
;
import
share.common.utils.DateUtil
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.utils.SecurityUtils
;
import
share.common.utils.SecurityUtils
;
import
share.common.utils.bean.BeanUtils
;
import
share.common.utils.bean.BeanUtils
;
import
share.system.domain.*
;
import
share.system.domain.*
;
import
share.system.domain.vo.*
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.SOrderDto
;
import
share.system.domain.vo.SOrderVo
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.mapper.SOrderMapper
;
import
share.system.mapper.SOrderMapper
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
import
share.system.request.OrderComputedPriceRequest
;
...
@@ -43,6 +41,11 @@ import share.system.response.ComputedOrderPriceResponse;
...
@@ -43,6 +41,11 @@ import share.system.response.ComputedOrderPriceResponse;
import
share.system.response.OrderPayResultResponse
;
import
share.system.response.OrderPayResultResponse
;
import
share.system.service.*
;
import
share.system.service.*
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* 订单Service业务层处理
* 订单Service业务层处理
*
*
...
@@ -102,6 +105,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -102,6 +105,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
@Autowired
private
ISCleanRecordsService
cleanRecordsService
;
private
ISCleanRecordsService
cleanRecordsService
;
@Autowired
private
TiktokService
tiktokService
;
private
final
static
Long
FIVE
=
5
l
;
private
final
static
Long
FIVE
=
5
l
;
...
@@ -363,7 +369,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -363,7 +369,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
throw
new
BaseException
(
"请绑定手机号"
);
throw
new
BaseException
(
"请绑定手机号"
);
}
}
}
}
SStore
sStore
=
storeService
.
getById
(
request
.
getStoreId
()
);
List
<
SStore
>
stores
=
storeService
.
list
(
);
SRoom
room
=
roomService
.
getById
(
request
.
getRoomId
());
SRoom
room
=
roomService
.
getById
(
request
.
getRoomId
());
if
(
ObjectUtil
.
isNotEmpty
(
room
)
&&
room
.
getIsDirtyRoom
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
room
)
&&
room
.
getIsDirtyRoom
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
throw
new
BaseException
(
"未保洁,不能预定!"
);
throw
new
BaseException
(
"未保洁,不能预定!"
);
...
@@ -376,16 +382,24 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -376,16 +382,24 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
checkOrderDate
(
request
);
checkOrderDate
(
request
);
//校验订单套餐
//校验订单套餐
checkOrderPack
(
request
,
user
);
checkOrderPack
(
request
,
user
);
SConsumerCoupon
byId
=
null
;
SConsumerCoupon
byId
;
if
(
Objects
.
nonNull
(
request
.
getCouponId
())
&&
request
.
getCouponId
()
!=
0
)
{
if
(
Objects
.
nonNull
(
request
.
getCouponId
())
&&
request
.
getCouponId
()
!=
0
)
{
byId
=
consumerCouponService
.
getById
(
request
.
getCouponId
());
byId
=
consumerCouponService
.
getById
(
request
.
getCouponId
());
if
(
Objects
.
nonNull
(
byId
))
{
if
(
Objects
.
nonNull
(
byId
))
{
if
(
byId
.
getUseStatus
().
equals
(
UserStatusEnum
.
UNUSED
.
getCode
()))
{
if
(
byId
.
getUseStatus
().
equals
(
UserStatusEnum
.
UNUSED
.
getCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
byId
.
getCouponCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
byId
.
getCouponCode
())
&&
ObjectUtil
.
isNotEmpty
(
byId
.
getDealId
())
)
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
byId
.
getCouponCode
(),
s
Store
.
getOpenShopUuid
());
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
byId
.
getCouponCode
(),
s
tores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
byId
.
getStoreId
())).
findFirst
().
get
()
.
getOpenShopUuid
());
if
(
getconsumed
==
null
)
{
if
(
getconsumed
==
null
)
{
throw
new
RuntimeException
(
"优惠券异常,请稍后再试"
);
throw
new
RuntimeException
(
"优惠券异常,请稍后再试"
);
}
}
}
else
if
(
StringUtils
.
isNoneEmpty
(
byId
.
getSkuId
()))
{
//抖音复验券
JSONObject
object
=
tiktokService
.
certificateGet
(
byId
.
getCouponCode
());
JSONObject
certificate
=
object
.
getJSONObject
(
"certificate"
);
Integer
status
=
certificate
.
getInt
(
"status"
);
if
(
status
.
equals
(
TiktokCouponStatusEnum
.
REFUND_SUCCESS
.
getCode
())
|
status
.
equals
(
TiktokCouponStatusEnum
.
REFUNDING
.
getCode
()))
{
throw
new
RuntimeException
(
"优惠券异常,请稍后再试"
);
}
}
}
}
else
{
}
else
{
throw
new
BaseException
(
"优惠券已使用!"
);
throw
new
BaseException
(
"优惠券已使用!"
);
...
@@ -393,6 +407,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -393,6 +407,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
{
}
else
{
throw
new
BaseException
(
"优惠券不存在!"
);
throw
new
BaseException
(
"优惠券不存在!"
);
}
}
}
else
{
byId
=
null
;
}
}
OrderPayResultResponse
response
=
new
OrderPayResultResponse
();
OrderPayResultResponse
response
=
new
OrderPayResultResponse
();
if
(
request
.
getPayFee
().
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
if
(
request
.
getPayFee
().
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
...
@@ -444,7 +460,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -444,7 +460,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//通知保洁人员
//通知保洁人员
sConsumerService
.
selectListByStoreId
(
sOrder
.
getStoreId
()).
stream
().
forEach
(
item
->
{
sConsumerService
.
selectListByStoreId
(
sOrder
.
getStoreId
()).
stream
().
forEach
(
item
->
{
// 循环发送短信提示门店保洁打扫卫生
// 循环发送短信提示门店保洁打扫卫生
smsService
.
sendSmsCleanRecordsStopRemind
(
item
.
getPhone
(),
s
Store
,
sRoom
);
smsService
.
sendSmsCleanRecordsStopRemind
(
item
.
getPhone
(),
s
tores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
request
.
getStoreId
())).
findFirst
().
get
()
,
sRoom
);
});
});
}
}
}
}
...
...
share-system/src/main/java/share/system/service/impl/TiktokServiceImpl.java
View file @
2804e028
...
@@ -12,20 +12,20 @@ import org.apache.commons.lang3.ObjectUtils;
...
@@ -12,20 +12,20 @@ import org.apache.commons.lang3.ObjectUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
share.common.core.redis.RedisUtil
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
import
share.common.enums.*
;
import
share.common.exception.base.BaseException
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SCoupon
;
import
share.system.domain.SCoupon
;
import
share.system.domain.SStore
;
import
share.system.domain.SStore
;
import
share.system.domain.tiktok.Sku
;
import
share.system.domain.tiktok.TiktokProduct
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISCouponService
;
import
share.system.service.ISCouponService
;
import
share.system.service.ISStoreService
;
import
share.system.service.ISStoreService
;
...
@@ -33,15 +33,19 @@ import share.system.service.TiktokService;
...
@@ -33,15 +33,19 @@ import share.system.service.TiktokService;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
@Service
@Service
public
class
TiktokServiceImpl
implements
TiktokService
{
public
class
TiktokServiceImpl
implements
TiktokService
{
@Value
(
"${tiktok.appSecret}"
)
private
String
CLIENT_SECRET
;
private
String
CLIENT_SECRET
;
@Value
(
"${tiktok.appId}"
)
private
String
CLIENT_KEY
;
private
String
CLIENT_KEY
;
@Value
(
"${tiktok.accountId}"
)
private
String
ACCOUNT_ID
;
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
...
@@ -71,13 +75,41 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -71,13 +75,41 @@ public class TiktokServiceImpl implements TiktokService {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TiktokServiceImpl
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TiktokServiceImpl
.
class
);
public
static
void
main
(
String
[]
args
)
{
String
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
POI_QUERY
.
getUrl
())
.
contentType
(
"application/json"
)
.
header
(
"access-token"
,
"clt.ba984ee2aebdd450c9254d8da380dfbeRoKWll1pEG34qWF0ph9kgR6EpexC"
)
.
form
(
"account_id"
,
"7325762036464355343"
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
50
)
.
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
}
JSONArray
pois
=
data
.
getJSONArray
(
"pois"
);
List
<
TiktokPoi
>
tiktokPois
=
new
ArrayList
<>();
List
<
JSONObject
>
list
=
pois
.
toList
(
JSONObject
.
class
);
list
.
stream
().
forEach
(
e
->
{
JSONObject
poi
=
e
.
getJSONObject
(
"poi"
);
TiktokPoi
tiktokPoi
=
new
TiktokPoi
();
tiktokPoi
.
setPoiId
(
poi
.
getStr
(
"poi_id"
));
tiktokPoi
.
setPoiName
(
poi
.
getStr
(
"poi_name"
));
tiktokPoi
.
setAddress
(
poi
.
getStr
(
"address"
));
tiktokPoi
.
setLatitude
(
poi
.
getFloat
(
"latitude"
));
tiktokPoi
.
setLongitude
(
poi
.
getFloat
(
"longitude"
));
tiktokPois
.
add
(
tiktokPoi
);
});
System
.
out
.
println
(
tiktokPois
);
}
@Override
@Override
public
void
clientToken
()
{
public
void
clientToken
()
{
// String url = "https://open.douyin.com/oauth/client_token/";
// String url = "https://open.douyin.com/oauth/client_token/";
HashMap
<
String
,
Object
>
tokenMap
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
tokenMap
=
new
HashMap
<>();
tokenMap
.
put
(
"client_key"
,
CLIENT_KEY
);
tokenMap
.
put
(
"client_key"
,
CLIENT_KEY
);
tokenMap
.
put
(
"client_secret"
,
CLIENT_SECRET
);
tokenMap
.
put
(
"client_secret"
,
CLIENT_SECRET
);
tokenMap
.
put
(
"grant_type"
,
"client_credential
s
"
);
tokenMap
.
put
(
"grant_type"
,
"client_credential"
);
String
post
=
HttpRequest
.
post
(
TiktokUrlEnum
.
OAUTH_CLIENT_TOKEN
.
getUrl
())
String
post
=
HttpRequest
.
post
(
TiktokUrlEnum
.
OAUTH_CLIENT_TOKEN
.
getUrl
())
.
contentType
(
"application/json"
)
.
contentType
(
"application/json"
)
.
body
(
new
JSONObject
(
tokenMap
).
toString
()).
execute
().
body
();
.
body
(
new
JSONObject
(
tokenMap
).
toString
()).
execute
().
body
();
...
@@ -100,7 +132,8 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -100,7 +132,8 @@ public class TiktokServiceImpl implements TiktokService {
String
expiresTime
=
DateUtil
.
format
(
date
,
DatePattern
.
NORM_DATETIME_PATTERN
);
String
expiresTime
=
DateUtil
.
format
(
date
,
DatePattern
.
NORM_DATETIME_PATTERN
);
map
.
put
(
"expiresTime"
,
expiresTime
);
map
.
put
(
"expiresTime"
,
expiresTime
);
JSONObject
jsonObject
=
new
JSONObject
(
map
);
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
(),
jsonObject
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
(),
jsonObject
.
toString
(),
6400L
,
TimeUnit
.
SECONDS
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN_KEY
.
getValue
(),
jsonObject
.
toString
());
}
}
@Override
@Override
...
@@ -141,7 +174,7 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -141,7 +174,7 @@ public class TiktokServiceImpl implements TiktokService {
}
}
@Override
@Override
public
String
verify
(
TiktokCouponDto
tiktokCouponDto
)
{
public
JSONObject
verify
(
TiktokCouponDto
tiktokCouponDto
)
{
String
accessToken
=
obtain
();
String
accessToken
=
obtain
();
// String url = "https://open.douyin.com/goodlife/v1/fulfilment/certificate/verify/";
// String url = "https://open.douyin.com/goodlife/v1/fulfilment/certificate/verify/";
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
@@ -156,14 +189,14 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -156,14 +189,14 @@ public class TiktokServiceImpl implements TiktokService {
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
extra
=
entries
.
getJSONObject
(
"extra"
);
JSONObject
extra
=
entries
.
getJSONObject
(
"extra"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
())
&&
data
.
getJSONObject
(
"verify_results"
).
getStr
(
"result"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
())
&&
((
JSONObject
)
data
.
getJSONArray
(
"verify_results"
).
get
(
0
)
).
getStr
(
"result"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
return
"验卷成功"
;
return
data
;
}
else
if
(
data
.
getStr
(
"error_code"
).
equals
(
"1208"
)
||
data
.
getJSONObject
(
"verify_results"
).
getStr
(
"result"
).
equals
(
VerifyResultsEnum
.
COOKED
.
getCode
()))
{
}
else
if
(
data
.
getStr
(
"error_code"
).
equals
(
"1208"
)
||
data
.
getJSONObject
(
"verify_results"
).
getStr
(
"result"
).
equals
(
VerifyResultsEnum
.
COOKED
.
getCode
()))
{
return
"验卷成功"
;
return
data
;
}
else
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
}
else
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
compensate
(
tiktokCouponDto
);
compensate
(
tiktokCouponDto
);
}
}
return
"验卷失败"
;
throw
new
RuntimeException
(
"验卷失败"
)
;
}
}
@Override
@Override
...
@@ -188,43 +221,32 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -188,43 +221,32 @@ public class TiktokServiceImpl implements TiktokService {
}
}
@Override
@Override
public
String
certificateGet
(
TiktokCouponDto
tiktokCouponDto
)
{
public
JSONObject
certificateGet
(
String
encryptedCode
)
{
String
accessToken
=
obtain
();
String
accessToken
=
obtain
();
// String url = "https://open.douyin.com/goodlife/v1/fulfilment/certificate/get/";
// String url = "https://open.douyin.com/goodlife/v1/fulfilment/certificate/get/";
String
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
CERTIFICATE_GET
.
getUrl
())
String
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
CERTIFICATE_GET
.
getUrl
())
.
contentType
(
"application/json"
)
.
contentType
(
"application/json"
)
.
header
(
"access-token"
,
accessToken
)
.
header
(
"access-token"
,
accessToken
)
.
form
(
"encrypted_code"
,
tiktokCouponDto
.
getEncryptedCode
()
).
execute
().
body
();
.
form
(
"encrypted_code"
,
encryptedCode
).
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
return
data
.
getStr
(
"description"
);
throw
new
BaseException
(
data
.
getStr
(
"description"
)
);
}
}
return
data
.
getJSONObject
(
"certificate"
).
getStr
(
"status"
)
;
return
data
;
}
}
@Override
@Override
public
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
)
{
public
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
)
{
String
accessToken
=
obtain
();
String
accessToken
=
obtain
();
// String url = "https://open.douyin.com/goodlife/v1/shop/poi/query/";
// String url = "https://open.douyin.com/goodlife/v1/shop/poi/query/";
String
result
=
null
;
String
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
POI_QUERY
.
getUrl
())
if
(
StringUtil
.
isNotEmpty
(
tiktokCouponDto
.
getAccountId
()))
{
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
POI_QUERY
.
getUrl
())
.
contentType
(
"application/json"
)
.
contentType
(
"application/json"
)
.
header
(
"access-token"
,
accessToken
)
.
header
(
"access-token"
,
accessToken
)
.
form
(
"account_id"
,
tiktokCouponDto
.
getAccountId
()
)
.
form
(
"account_id"
,
ACCOUNT_ID
)
.
form
(
"page"
,
1
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
50
)
.
form
(
"size"
,
50
)
.
execute
().
body
();
.
execute
().
body
();
}
else
if
(
StringUtil
.
isNotEmpty
(
tiktokCouponDto
.
getPoiId
()))
{
result
=
HttpRequest
.
get
(
TiktokUrlEnum
.
POI_QUERY
.
getUrl
())
.
contentType
(
"application/json"
)
.
header
(
"access-token"
,
accessToken
)
.
form
(
"poiId"
,
tiktokCouponDto
.
getPoiId
())
.
form
(
"page"
,
1
)
.
form
(
"size"
,
50
)
.
execute
().
body
();
}
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
...
@@ -236,8 +258,8 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -236,8 +258,8 @@ public class TiktokServiceImpl implements TiktokService {
list
.
stream
().
forEach
(
e
->
{
list
.
stream
().
forEach
(
e
->
{
JSONObject
poi
=
e
.
getJSONObject
(
"poi"
);
JSONObject
poi
=
e
.
getJSONObject
(
"poi"
);
TiktokPoi
tiktokPoi
=
new
TiktokPoi
();
TiktokPoi
tiktokPoi
=
new
TiktokPoi
();
tiktokPoi
.
setPoiId
(
poi
.
getStr
(
"poi
I
d"
));
tiktokPoi
.
setPoiId
(
poi
.
getStr
(
"poi
_i
d"
));
tiktokPoi
.
setPoiName
(
poi
.
getStr
(
"poi
N
ame"
));
tiktokPoi
.
setPoiName
(
poi
.
getStr
(
"poi
_n
ame"
));
tiktokPoi
.
setAddress
(
poi
.
getStr
(
"address"
));
tiktokPoi
.
setAddress
(
poi
.
getStr
(
"address"
));
tiktokPoi
.
setLatitude
(
poi
.
getFloat
(
"latitude"
));
tiktokPoi
.
setLatitude
(
poi
.
getFloat
(
"latitude"
));
tiktokPoi
.
setLongitude
(
poi
.
getFloat
(
"longitude"
));
tiktokPoi
.
setLongitude
(
poi
.
getFloat
(
"longitude"
));
...
@@ -374,10 +396,7 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -374,10 +396,7 @@ public class TiktokServiceImpl implements TiktokService {
codes
.
add
(
e
.
getStr
(
"encrypted_code"
));
codes
.
add
(
e
.
getStr
(
"encrypted_code"
));
});
});
couponDto
.
setEncryptedCodes
(
codes
);
couponDto
.
setEncryptedCodes
(
codes
);
String
verify
=
verify
(
couponDto
);
verify
(
couponDto
);
if
(
verify
.
equals
(
"验卷失败"
))
{
throw
new
RuntimeException
(
"验卷失败"
);
}
}
catch
(
RuntimeException
e
)
{
}
catch
(
RuntimeException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -391,6 +410,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -391,6 +410,10 @@ public class TiktokServiceImpl implements TiktokService {
String
o
;
String
o
;
o
=
redisUtil
.
get
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
o
=
redisUtil
.
get
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
//过期时间小于当前时间 重新获取token
//过期时间小于当前时间 重新获取token
if
(
StringUtil
.
isEmpty
(
o
))
{
clientToken
();
o
=
redisUtil
.
get
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
}
if
(
new
JSONObject
(
o
).
getDate
(
"expiresTime"
).
getTime
()
<
System
.
currentTimeMillis
())
{
if
(
new
JSONObject
(
o
).
getDate
(
"expiresTime"
).
getTime
()
<
System
.
currentTimeMillis
())
{
clientToken
();
clientToken
();
o
=
redisUtil
.
get
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
o
=
redisUtil
.
get
(
ReceiptRdeisEnum
.
TIKTOK_CLIENT_TOKEN
.
getValue
());
...
...
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