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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
312 additions
and
105 deletions
+312
-105
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
+8
-2
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
+30
-16
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:
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
XML
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
saobei
:
key
:
15490267
...
...
share-admin/src/main/resources/application-test.yml
View file @
2804e028
...
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
XML
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
saobei
:
key
:
15490267
...
...
@@ -219,4 +223,6 @@ order:
allow-refund-time
:
3600
mqtt
:
device-op-last-time
:
-5
device-gateway-last-report-time
:
-10
\ No newline at end of file
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 {
ORDER_NO_KEY
(
4
,
"ORDER_NO_KEY."
),
ACCESS_TOKEN_KEY
(
5
,
"ACCESS_TOKEN_KEY."
),
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
;
...
...
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;
import
cn.hutool.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
share.common.core.domain.AjaxResult
;
import
share.system.domain.vo.OnlineQueryDto
;
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
;
...
...
@@ -16,7 +14,7 @@ import java.util.List;
import
static
share
.
common
.
core
.
domain
.
AjaxResult
.
success
;
@RestController
@RequestMapping
(
"/chessCards"
)
@RequestMapping
(
"/
tiktok/
chessCards"
)
public
class
TiktokController
{
@Autowired
private
TiktokService
tiktokService
;
...
...
@@ -27,28 +25,28 @@ public class TiktokController {
tiktokService
.
clientToken
();
}
//验卷准备接口,返回code,用于调用其他接口
@GetMapping
(
"/certificate/prepare"
)
public
AjaxResult
prepare
(
TiktokCouponDto
tiktokCouponDto
)
{
//验卷准备接口,返回code,用于调用其他接口
@PostMapping
(
"/certificate/prepare"
)
public
AjaxResult
prepare
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
prepare
(
tiktokCouponDto
));
}
//验卷接口,返回验卷结果
@
Ge
tMapping
(
"/certificate/verify"
)
public
String
verify
(
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
verify
(
tiktokCouponDto
);
@
Pos
tMapping
(
"/certificate/verify"
)
public
AjaxResult
verify
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
verify
(
tiktokCouponDto
)
);
}
//撤销核销接口,返回撤销结果
@
Ge
tMapping
(
"/certificate/cancel"
)
public
String
cancel
(
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
cancel
(
tiktokCouponDto
);
@
Pos
tMapping
(
"/certificate/cancel"
)
public
AjaxResult
cancel
(
@RequestBody
TiktokCouponDto
tiktokCouponDto
)
{
return
success
(
tiktokService
.
cancel
(
tiktokCouponDto
)
);
}
@GetMapping
(
"/certificate/get
)
"
)
public
String
certificateGet
(
TiktokCouponDto
tiktokCouponDto
)
{
return
tiktokService
.
certificateGet
(
tiktokCouponDto
);
@GetMapping
(
"/certificate/get"
)
public
AjaxResult
certificateGet
(
String
encryptedCode
)
{
return
success
(
tiktokService
.
certificateGet
(
encryptedCode
)
);
}
@GetMapping
(
"/poi/query"
)
...
...
@@ -58,12 +56,12 @@ public class TiktokController {
//查询所有线上商品数据列表
@GetMapping
(
"/online/query"
)
public
Object
onlineQuery
(
OnlineQueryDto
onlineQueryDto
)
{
public
JSON
Object
onlineQuery
(
OnlineQueryDto
onlineQueryDto
)
{
return
tiktokService
.
onlineQuery
(
onlineQueryDto
);
}
@GetMapping
(
"/online/
query
"
)
public
Object
onlineGet
(
String
productIds
,
String
accountId
)
{
@GetMapping
(
"/online/
gets
"
)
public
JSON
Object
onlineGet
(
String
productIds
,
String
accountId
)
{
return
tiktokService
.
onlineGet
(
productIds
,
accountId
);
}
...
...
share-front/src/main/resources/application-prod.yml
View file @
2804e028
...
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
JSON
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
saobei
:
key
:
15490267
...
...
share-front/src/main/resources/application-test.yml
View file @
2804e028
...
...
@@ -31,6 +31,10 @@ wx:
token
:
coujio
aesKey
:
zf8vTHbI0ZDPTkkCXHEuwh9EbtVtOn6n4vQjMb9OFrS
msgDataFormat
:
JSON
tiktok
:
appId
:
awt50u5zommqxkl9
appSecret
:
c567551e0c4ce1db4f985d0233025d8d
accountId
:
7325762036464355343
#扫呗支付配置
saobei
:
key
:
15490267
...
...
@@ -217,3 +221,5 @@ order:
mqtt
:
device-op-last-time
:
-5
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;
import
cn.hutool.json.JSONException
;
import
cn.hutool.json.JSONObject
;
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.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.TuangouReceiptPrepareRequest
;
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.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -30,11 +24,12 @@ import share.common.constant.MqttConstants;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
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.mapper.SConsumerMapper
;
import
share.system.service.*
;
import
share.system.service.impl.SOrderServiceImpl
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
@@ -85,6 +80,10 @@ public class RedisTask {
@Autowired
private
SConsumerService
sConsumerService
;
@Autowired
private
TiktokService
tiktokService
;
//15分钟的常量
final
long
FIFTEEN_MINUTES
=
60
*
15
;
//14分钟的常量
...
...
@@ -112,13 +111,23 @@ public class RedisTask {
List
<
Long
>
expiredCoupons
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
coupons
))
{
for
(
SConsumerCoupon
coupon
:
coupons
)
{
//验券
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
coupon
.
getCouponCode
(),
stores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
coupon
.
getStoreId
())).
findFirst
().
get
().
getOpenShopUuid
());
if
(
getconsumed
==
null
)
{
expiredCoupons
.
add
(
coupon
.
getId
());
//美团复验券
if
(
ObjectUtil
.
isNotEmpty
(
coupon
.
getDealId
()))
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
coupon
.
getCouponCode
(),
stores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
coupon
.
getStoreId
())).
findFirst
().
get
().
getOpenShopUuid
());
if
(
getconsumed
==
null
)
{
expiredCoupons
.
add
(
coupon
.
getId
());
}
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
());
}
}
logger
.
info
(
"券码:{}->查询结束:{}"
,
coupon
.
getCouponCode
(),
getconsumed
);
}
//逻辑删除所有异常优惠券
isConsumerCouponService
.
removeByIds
(
expiredCoupons
);
...
...
@@ -182,6 +191,11 @@ public class RedisTask {
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
);
}
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
;
import
cn.hutool.json.JSONObject
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.tiktok.TiktokCouponDto
;
import
share.system.domain.tiktok.TiktokPoi
;
import
share.system.domain.vo.OnlineQueryDto
;
import
java.util.List
;
...
...
@@ -12,11 +12,11 @@ public interface TiktokService {
JSONObject
prepare
(
TiktokCouponDto
tiktokCouponDto
);
String
verify
(
TiktokCouponDto
tiktokCouponDto
);
JSONObject
verify
(
TiktokCouponDto
tiktokCouponDto
);
String
cancel
(
TiktokCouponDto
tiktokCouponDto
);
String
certificateGet
(
TiktokCouponDto
tiktokCouponDto
);
JSONObject
certificateGet
(
String
encryptedCode
);
List
<
TiktokPoi
>
poiQuery
(
TiktokCouponDto
tiktokCouponDto
);
...
...
share-system/src/main/java/share/system/service/impl/SCouponServiceImpl.java
View file @
2804e028
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.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -13,6 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouDealQueryShopDealResponseEntity
;
import
org.apache.commons.lang3.StringUtils
;
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.ObjectUtils
;
import
share.common.core.page.PageDomain
;
...
...
@@ -23,16 +20,20 @@ import share.common.enums.RoomType;
import
share.common.enums.StoreType
;
import
share.common.enums.YesNoEnum
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.
*
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SCoupon
;
import
share.system.domain.
SStore
;
import
share.system.domain.vo.OnlineQueryDto
;
import
share.system.domain.vo.SCouponVo
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.mapper.SCouponMapper
;
import
share.system.mapper.SmsLogMapper
;
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业务层处理
*
...
...
@@ -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
TWO
=
"2"
;
@Value
(
"${tiktok.accountId}"
)
private
String
ACCOUNT_Id
;
...
...
@@ -280,11 +281,15 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
@Override
public
List
<
SCoupon
>
querySkuPoiList
()
{
List
<
SStore
>
sStores
=
storeService
.
list
();
//过滤掉没有poiId的门店
sStores
=
sStores
.
stream
().
filter
(
store
->
StringUtils
.
isNotBlank
(
store
.
getPoiId
())).
collect
(
Collectors
.
toList
());
Map
<
String
,
SCoupon
>
sCouponList
=
new
LinkedHashMap
<>();
OnlineQueryDto
onlineQueryDto
=
new
OnlineQueryDto
();
onlineQueryDto
.
setAccountId
(
ACCOUNT_Id
);
JSONObject
entries
=
tiktokService
.
onlineQuery
(
onlineQueryDto
);
JSONArray
products
=
entries
.
getJSONArray
(
"products"
);
List
<
SStore
>
finalSStores
=
sStores
;
List
<
SStore
>
finalSStores1
=
sStores
;
products
.
stream
().
forEach
(
item
->
{
JSONObject
jsonObject
=
(
JSONObject
)
item
;
if
(
jsonObject
.
getInt
(
"online_status"
).
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
...
...
@@ -298,7 +303,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon
.
setName
(
sku
.
getStr
(
"sku_name"
));
sCoupon
.
setStartDate
(
new
Date
(
product
.
getInt
(
"sold_start_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
.
setStoreType
(
StoreType
.
getCodeList
());
sCoupon
.
setValidStartTime
(
DEFAULT_START_TIME
);
...
...
@@ -307,15 +312,25 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon
.
setMaxDuration
(
DEFAULT_MAX_DURATION
);
sCoupon
.
setMinPrice
(
new
BigDecimal
(
"0.00"
));
sCoupon
.
setCouponType
(
CouponTypeEnum
.
CASH
.
getCode
());
if
(
finalSStores
.
size
()
==
0
)
{
sCouponList
.
put
(
sku
.
getStr
(
"sku_id"
),
sCoupon
);
return
;
}
pois
.
stream
().
forEach
(
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
);
}
else
{
pois
.
stream
().
forEach
(
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
;
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.DatePattern
;
import
cn.hutool.core.date.DateUnit
;
...
...
@@ -20,7 +15,9 @@ import org.apache.commons.collections4.CollectionUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
share.common.constant.Constants
;
import
share.common.core.redis.RedisUtil
;
...
...
@@ -29,12 +26,13 @@ import share.common.exception.base.BaseException;
import
share.common.utils.BaseUtil
;
import
share.common.utils.DateUtil
;
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.bean.BeanUtils
;
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.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
...
...
@@ -43,6 +41,11 @@ import share.system.response.ComputedOrderPriceResponse;
import
share.system.response.OrderPayResultResponse
;
import
share.system.service.*
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 订单Service业务层处理
*
...
...
@@ -102,6 +105,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
private
ISCleanRecordsService
cleanRecordsService
;
@Autowired
private
TiktokService
tiktokService
;
private
final
static
Long
FIVE
=
5
l
;
...
...
@@ -363,7 +369,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
throw
new
BaseException
(
"请绑定手机号"
);
}
}
SStore
sStore
=
storeService
.
getById
(
request
.
getStoreId
()
);
List
<
SStore
>
stores
=
storeService
.
list
(
);
SRoom
room
=
roomService
.
getById
(
request
.
getRoomId
());
if
(
ObjectUtil
.
isNotEmpty
(
room
)
&&
room
.
getIsDirtyRoom
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
throw
new
BaseException
(
"未保洁,不能预定!"
);
...
...
@@ -376,16 +382,24 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
checkOrderDate
(
request
);
//校验订单套餐
checkOrderPack
(
request
,
user
);
SConsumerCoupon
byId
=
null
;
SConsumerCoupon
byId
;
if
(
Objects
.
nonNull
(
request
.
getCouponId
())
&&
request
.
getCouponId
()
!=
0
)
{
byId
=
consumerCouponService
.
getById
(
request
.
getCouponId
());
if
(
Objects
.
nonNull
(
byId
))
{
if
(
byId
.
getUseStatus
().
equals
(
UserStatusEnum
.
UNUSED
.
getCode
()))
{
if
(
StringUtils
.
isNotEmpty
(
byId
.
getCouponCode
()))
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
byId
.
getCouponCode
(),
s
Store
.
getOpenShopUuid
());
if
(
StringUtils
.
isNotEmpty
(
byId
.
getCouponCode
())
&&
ObjectUtil
.
isNotEmpty
(
byId
.
getDealId
())
)
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
qpService
.
getconsumed
(
byId
.
getCouponCode
(),
s
tores
.
stream
().
filter
(
store
->
store
.
getId
().
equals
(
byId
.
getStoreId
())).
findFirst
().
get
()
.
getOpenShopUuid
());
if
(
getconsumed
==
null
)
{
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
{
throw
new
BaseException
(
"优惠券已使用!"
);
...
...
@@ -393,6 +407,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
{
throw
new
BaseException
(
"优惠券不存在!"
);
}
}
else
{
byId
=
null
;
}
OrderPayResultResponse
response
=
new
OrderPayResultResponse
();
if
(
request
.
getPayFee
().
compareTo
(
BigDecimal
.
ZERO
)
<=
0
)
{
...
...
@@ -444,7 +460,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//通知保洁人员
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
This diff is collapsed.
Click to expand it.
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