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
5caa0de0
Commit
5caa0de0
authored
Oct 24, 2023
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加点评北极星平台接口
parent
62df8d6b
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
492 additions
and
10 deletions
+492
-10
application-dev.yml
share-admin/src/main/resources/application-dev.yml
+4
-0
QPController.java
...c/main/java/share/web/controller/system/QPController.java
+53
-0
SConsumerCouponController.java
...hare/web/controller/system/SConsumerCouponController.java
+9
-8
application-dev.yml
share-front/src/main/resources/application-dev.yml
+4
-0
pom.xml
share-system/pom.xml
+30
-1
dianping-openapi-java-sdk-qa-1.1.240-sources.jar
.../src/lib/dianping-openapi-java-sdk-qa-1.1.240-sources.jar
+0
-0
dianping-openapi-java-sdk-qa-1.1.240.jar
...e-system/src/lib/dianping-openapi-java-sdk-qa-1.1.240.jar
+0
-0
SConsumer.java
...e-system/src/main/java/share/system/domain/SConsumer.java
+2
-0
SConsumerCoupon.java
...em/src/main/java/share/system/domain/SConsumerCoupon.java
+12
-0
CouponRequest.java
...tem/src/main/java/share/system/request/CouponRequest.java
+43
-0
ISConsumerCouponService.java
...in/java/share/system/service/ISConsumerCouponService.java
+3
-0
QPService.java
...-system/src/main/java/share/system/service/QPService.java
+22
-0
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+166
-0
SConsumerCouponServiceImpl.java
...share/system/service/impl/SConsumerCouponServiceImpl.java
+144
-1
No files found.
share-admin/src/main/resources/application-dev.yml
View file @
5caa0de0
...
@@ -174,3 +174,7 @@ meituan:
...
@@ -174,3 +174,7 @@ meituan:
developerId
:
123456
developerId
:
123456
signKey
:
abcdefghijklmnopqrstuvwxyz
signKey
:
abcdefghijklmnopqrstuvwxyz
appAuthToken
:
abcdefghijklmnopqrstuvwxyz
appAuthToken
:
abcdefghijklmnopqrstuvwxyz
dianping
:
appKey
:
abcdefghijklmnopqrstuvwxyz
appSecret
:
abcdefghijklmnopqrstuvwxyz
authCode
:
abcdefghijklmnopqrstuvwxyz
share-front/src/main/java/share/web/controller/system/QPController.java
0 → 100644
View file @
5caa0de0
package
share
.
web
.
controller
.
system
;
import
io.swagger.annotations.Api
;
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
share.common.core.domain.R
;
import
share.system.service.QPService
;
@RestController
@RequestMapping
(
"/front/chessCards"
)
@Api
(
tags
=
"首页-验券"
)
public
class
QPController
{
@Autowired
private
QPService
qpService
;
//输码验券校验接口
@GetMapping
(
"/prepare"
)
public
R
prepare
(
String
code
)
{
return
R
.
ok
(
qpService
.
prepare
(
code
));
}
//验券接口
@GetMapping
(
"/consume"
)
public
R
consume
(
String
code
,
int
count
)
{
return
R
.
ok
(
qpService
.
consume
(
code
,
count
));
}
//撤销验券接口
@GetMapping
(
"/reverseconsume"
)
public
R
reverseconsume
(
String
code
,
String
appDealId
)
{
return
R
.
ok
(
qpService
.
reverseconsume
(
code
,
appDealId
));
}
//查询已验券信息接口
@GetMapping
(
"/getconsumed"
)
public
R
getconsumed
(
String
code
)
{
return
R
.
ok
(
qpService
.
getconsumed
(
code
));
}
//用户验券接口
@GetMapping
(
"/consumeByUser"
)
public
R
consumeByUser
(
String
code
,
int
count
)
{
return
R
.
ok
(
qpService
.
consumeByUser
(
code
,
count
));
}
//用户销券接口
@GetMapping
(
"/reverseconsumeByUser"
)
public
R
reverseconsumeByUser
(
String
code
,
String
appDealId
)
{
return
R
.
ok
(
qpService
.
reverseconsumeByUser
(
code
,
appDealId
));
}
}
share-front/src/main/java/share/web/controller/system/SConsumerCouponController.java
View file @
5caa0de0
package
share
.
web
.
controller
.
system
;
package
share
.
web
.
controller
.
system
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
share.common.core.controller.BaseController
;
import
share.common.core.controller.BaseController
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.domain.AjaxResult
;
import
share.common.core.domain.R
;
import
share.common.core.page.TableDataInfo
;
import
share.common.core.page.TableDataInfo
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.request.CouponRequest
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISConsumerCouponService
;
import
java.util.List
;
import
java.util.List
;
...
@@ -21,6 +26,7 @@ import java.util.List;
...
@@ -21,6 +26,7 @@ import java.util.List;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/front/consumerCoupon"
)
@RequestMapping
(
"/front/consumerCoupon"
)
@Api
(
tags
=
"优惠券"
)
public
class
SConsumerCouponController
extends
BaseController
{
public
class
SConsumerCouponController
extends
BaseController
{
@Autowired
@Autowired
private
ISConsumerCouponService
sConsumerCouponService
;
private
ISConsumerCouponService
sConsumerCouponService
;
...
@@ -53,14 +59,9 @@ public class SConsumerCouponController extends BaseController {
...
@@ -53,14 +59,9 @@ public class SConsumerCouponController extends BaseController {
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
@ApiOperation
(
value
=
"优惠券-查询可用优惠券"
)
@PostMapping
(
"/query"
)
@PostMapping
(
"/query"
)
public
List
<
SConsumerCoupon
>
query
(
@RequestBody
SConsumerCoupon
sConsumerCoupon
)
{
public
R
<
List
<
SConsumerCoupon
>>
query
(
@RequestBody
@Validated
CouponRequest
couponRequest
)
{
return
R
.
ok
(
sConsumerCouponService
.
availableCouponList
(
couponRequest
));
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
sConsumerCoupon
.
setUseStatus
(
"0"
);
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
return
sConsumerCouponService
.
selectSConsumerCouponList
(
sConsumerCoupon
);
}
}
}
}
share-front/src/main/resources/application-dev.yml
View file @
5caa0de0
...
@@ -179,3 +179,7 @@ meituan:
...
@@ -179,3 +179,7 @@ meituan:
developerId
:
123456
developerId
:
123456
signKey
:
abcdefghijklmnopqrstuvwxyz
signKey
:
abcdefghijklmnopqrstuvwxyz
appAuthToken
:
abcdefghijklmnopqrstuvwxyz
appAuthToken
:
abcdefghijklmnopqrstuvwxyz
dianping
:
appKey
:
abcdefghijklmnopqrstuvwxyz
appSecret
:
abcdefghijklmnopqrstuvwxyz
authCode
:
abcdefghijklmnopqrstuvwxyz
share-system/pom.xml
View file @
5caa0de0
...
@@ -99,7 +99,35 @@
...
@@ -99,7 +99,35 @@
<version>
1.7.25
</version>
<version>
1.7.25
</version>
</dependency>
</dependency>
<!--美团SDK引入加相关依赖结束-->
<!--美团SDK引入加相关依赖结束-->
<dependency>
<groupId>
dianping-openapi
</groupId>
<artifactId>
dianping-openapi
</artifactId>
<version>
1.0
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/lib/dianping-openapi-java-sdk-qa-1.1.240.jar
</systemPath>
</dependency>
<dependency>
<groupId>
dianping-openapi-sources
</groupId>
<artifactId>
dianping-openapi-sources
</artifactId>
<version>
1.0
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/lib/dianping-openapi-java-sdk-qa-1.1.240-sources.jar
</systemPath>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
28.2-android
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.12.0
</version>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.4
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
share-system/src/lib/dianping-openapi-java-sdk-qa-1.1.240-sources.jar
0 → 100644
View file @
5caa0de0
File added
share-system/src/lib/dianping-openapi-java-sdk-qa-1.1.240.jar
0 → 100644
View file @
5caa0de0
File added
share-system/src/main/java/share/system/domain/SConsumer.java
View file @
5caa0de0
...
@@ -4,6 +4,7 @@ import java.io.Serializable;
...
@@ -4,6 +4,7 @@ import java.io.Serializable;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
...
@@ -89,6 +90,7 @@ public class SConsumer
...
@@ -89,6 +90,7 @@ public class SConsumer
private
Date
lastLoginTime
;
private
Date
lastLoginTime
;
@ApiModelProperty
(
value
=
"优惠卷数量"
)
@ApiModelProperty
(
value
=
"优惠卷数量"
)
@TableField
(
exist
=
false
)
private
Integer
number
;
private
Integer
number
;
}
}
share-system/src/main/java/share/system/domain/SConsumerCoupon.java
View file @
5caa0de0
...
@@ -114,4 +114,16 @@ public class SConsumerCoupon extends BaseEntity
...
@@ -114,4 +114,16 @@ public class SConsumerCoupon extends BaseEntity
@Excel
(
name
=
"更新时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
@Excel
(
name
=
"更新时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
deleteTime
;
private
Date
deleteTime
;
/**
* 是否可用 (0:可用,1:不可以)
*/
//是否可用 (0:可用,1:不可以)
@TableField
(
select
=
false
)
private
Integer
isAvailable
;
/**
* 原因
*/
@TableField
(
select
=
false
)
private
String
reason
;
}
}
share-system/src/main/java/share/system/request/CouponRequest.java
0 → 100644
View file @
5caa0de0
package
share
.
system
.
request
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"CouponRequest对象"
,
description
=
"优惠卷请求对象"
)
public
class
CouponRequest
{
@ApiModelProperty
(
value
=
"门店ID"
,
required
=
true
)
@NotBlank
(
message
=
"门店ID不能为空"
)
private
Long
storeId
;
@ApiModelProperty
(
value
=
"房间ID"
,
required
=
true
)
@NotBlank
(
message
=
"房间ID不能为空"
)
private
Long
roomId
;
/**
* 预约开始时间
*/
@ApiModelProperty
(
value
=
"预约开始时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm"
,
timezone
=
"GMT+8"
)
@NotNull
(
message
=
"预约开始时间不能为空"
)
private
Date
preStartDate
;
/**
* 预约结束时间
*/
@ApiModelProperty
(
value
=
"预约结束时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm"
,
timezone
=
"GMT+8"
)
@NotNull
(
message
=
"预约结束时间不能为空"
)
private
Date
preEndDate
;
}
share-system/src/main/java/share/system/service/ISConsumerCouponService.java
View file @
5caa0de0
...
@@ -3,6 +3,7 @@ package share.system.service;
...
@@ -3,6 +3,7 @@ package share.system.service;
import
java.util.List
;
import
java.util.List
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.request.CouponRequest
;
/**
/**
* 优惠券领取记录Service接口
* 优惠券领取记录Service接口
...
@@ -61,4 +62,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
...
@@ -61,4 +62,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
public
int
deleteSConsumerCouponById
(
Long
id
);
public
int
deleteSConsumerCouponById
(
Long
id
);
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
);
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
);
List
<
SConsumerCoupon
>
availableCouponList
(
CouponRequest
couponRequest
);
}
}
share-system/src/main/java/share/system/service/QPService.java
0 → 100644
View file @
5caa0de0
package
share
.
system
.
service
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptConsumeResponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareResponseEntity
;
import
com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptReverseConsumeResponseEntity
;
import
java.util.List
;
public
interface
QPService
{
TuangouReceiptPrepareResponseEntity
prepare
(
String
code
);
List
<
TuangouReceiptConsumeResponseEntity
>
consume
(
String
code
,
int
count
);
List
<
TuangouReceiptReverseConsumeResponseEntity
>
reverseconsume
(
String
code
,
String
appDealId
);
TuangouReceiptGetConsumedReponseEntity
getconsumed
(
String
code
);
String
consumeByUser
(
String
code
,
int
count
);
String
reverseconsumeByUser
(
String
code
,
String
appDealId
);
}
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
0 → 100644
View file @
5caa0de0
package
share
.
system
.
service
.
impl
;
import
com.dianping.openapi.sdk.api.oauth.DynamicToken
;
import
com.dianping.openapi.sdk.api.oauth.entity.DynamicTokenRequest
;
import
com.dianping.openapi.sdk.api.oauth.entity.DynamicTokenResponse
;
import
com.dianping.openapi.sdk.api.oauth.enums.GrantType
;
import
com.dianping.openapi.sdk.api.tuangou.TuangouReceiptConsume
;
import
com.dianping.openapi.sdk.api.tuangou.TuangouReceiptGetConsumed
;
import
com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare
;
import
com.dianping.openapi.sdk.api.tuangou.TuangouReceiptReverseConsume
;
import
com.dianping.openapi.sdk.api.tuangou.entity.*
;
import
com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SCoupon
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISCouponService
;
import
share.system.service.QPService
;
import
java.util.List
;
@Service
public
class
QPServiceImpl
implements
QPService
{
@Value
(
"${dianping.appKey}"
)
private
String
APP_KEY
;
@Value
(
"${dianping.appSecret}"
)
private
String
APP_SECRET
;
@Value
(
"${dianping.authCode}"
)
private
String
AUTH_CODE
;
@Autowired
private
ISCouponService
isCouponService
;
@Autowired
private
ISConsumerCouponService
isConsumerCouponService
;
/**
* 用户验卷接口
*/
@Override
public
String
consumeByUser
(
String
code
,
int
count
)
{
//验券准备
TuangouReceiptPrepareResponseEntity
prepare
=
prepare
(
code
);
SCoupon
sCoupon
=
isCouponService
.
selectSCouponByName
(
prepare
.
getDeal_title
());
if
(
sCoupon
==
null
)
{
throw
new
RuntimeException
(
"未找到对应的优惠券"
);
}
//执行验券
List
<
TuangouReceiptConsumeResponseEntity
>
consume
=
consume
(
code
,
count
);
consume
.
forEach
(
item
->
{
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
//取订单ID,如果为空,则取套餐ID
sConsumerCoupon
.
setCouponId
(
Long
.
valueOf
(
item
.
getOrder_id
())
!=
null
?
Long
.
valueOf
(
item
.
getOrder_id
())
:
item
.
getDeal_id
());
sConsumerCoupon
.
setCouponCode
(
code
);
sConsumerCoupon
.
setName
(
item
.
getDeal_title
());
sConsumerCoupon
.
setCouponType
(
String
.
valueOf
(
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
.
setSubPrice
(
sCoupon
.
getSubPrice
());
sConsumerCoupon
.
setSourceType
(
"3"
);
sConsumerCoupon
.
setPlatformType
(
"2"
);
sConsumerCoupon
.
setStartDate
(
sCoupon
.
getStartDate
());
sConsumerCoupon
.
setEndDate
(
item
.
getReceiptEndDate
());
sConsumerCoupon
.
setCreateBy
(
String
.
valueOf
(
user
.
getId
()));
isConsumerCouponService
.
insertSConsumerCoupon
(
sConsumerCoupon
);
});
return
"验券成功"
;
}
@Override
public
String
reverseconsumeByUser
(
String
code
,
String
appDealId
)
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
getconsumed
(
code
);
return
null
;
}
/**
* 验卷准备接口
* 根据团购券码,查询券码对应的dealid下,该用户可使用的券数据量
*/
@Override
public
TuangouReceiptPrepareResponseEntity
prepare
(
String
code
)
{
TuangouReceiptPrepareRequest
request
=
new
TuangouReceiptPrepareRequest
(
APP_KEY
,
APP_SECRET
,
"session"
,
code
,
""
);
TuangouReceiptPrepare
tuangouReceiptPrepare
=
new
TuangouReceiptPrepare
(
request
);
DefaultOpenAPIClient
client
=
new
DefaultOpenAPIClient
();
TuangouReceiptPrepareResponse
invoke
=
client
.
invoke
(
tuangouReceiptPrepare
);
if
(
invoke
.
getCode
()
!=
200
)
{
throw
new
RuntimeException
(
invoke
.
getMsg
());
}
return
invoke
.
getData
();
}
/**
* 验卷接口
* 根据团购券码,一次性验证同一订单下的若干团购券 同一个用户,同一个dealid下的券码
*/
@Override
public
List
<
TuangouReceiptConsumeResponseEntity
>
consume
(
String
code
,
int
count
)
{
TuangouReceiptConsumeRequest
request
=
new
TuangouReceiptConsumeRequest
(
APP_KEY
,
APP_SECRET
,
"session"
,
"requestid"
,
code
,
count
,
"open_shop_uuid"
,
"app_shop_account"
,
"app_shop_accountname"
);
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
TuangouReceiptConsume
tuangouReceiptConsume
=
new
TuangouReceiptConsume
(
request
);
TuangouReceiptConsumeResponse
invoke
=
openAPIClient
.
invoke
(
tuangouReceiptConsume
);
if
(
invoke
.
getCode
()
!=
200
)
{
throw
new
RuntimeException
(
invoke
.
getMsg
());
}
return
invoke
.
getData
();
}
/**
* 撤销验卷接口
* 撤销已经核销的券码(只可撤销当天核销且未超过10分钟的团购券)
*/
@Override
public
List
<
TuangouReceiptReverseConsumeResponseEntity
>
reverseconsume
(
String
code
,
String
appDealId
)
{
TuangouReceiptReverseConsumeRequest
tuangouReceiptReverseConsumeRequest
=
new
TuangouReceiptReverseConsumeRequest
(
APP_KEY
,
APP_SECRET
,
"session"
,
"app_deal_id"
,
code
,
appDealId
,
"app_shop_account"
,
"app_shop_accountname"
,
"open_shop_uuid"
);
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
TuangouReceiptReverseConsume
tuangouReceiptReverseConsume
=
new
TuangouReceiptReverseConsume
(
tuangouReceiptReverseConsumeRequest
);
TuangouReceiptReverseConsumeResponse
response
=
openAPIClient
.
invoke
(
tuangouReceiptReverseConsume
);
if
(
response
.
getCode
()
!=
200
)
{
throw
new
RuntimeException
(
response
.
getMsg
());
}
return
response
.
getData
();
}
/**
* 查询已验券信息接口
* 查询已经验证的券码信息,仅支持已经验证的券码
*/
@Override
public
TuangouReceiptGetConsumedReponseEntity
getconsumed
(
String
code
)
{
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
TuangouReceiptGetConsumedRequest
request
=
new
TuangouReceiptGetConsumedRequest
(
APP_KEY
,
APP_SECRET
,
"7bd6cc83aecf6fe937d4cd774e1682aeb87773ad"
,
code
,
"app_shop_id"
);
TuangouReceiptGetConsumed
tuangouReceiptGetConsumed
=
new
TuangouReceiptGetConsumed
(
request
);
TuangouReceiptGetConsumedReponse
response
=
openAPIClient
.
invoke
(
tuangouReceiptGetConsumed
);
if
(
response
.
getCode
()
!=
200
)
{
throw
new
RuntimeException
(
response
.
getMsg
());
}
return
response
.
getData
();
}
//商家通过接入授权UI,可获取到对应的auth_code,通过此接口获取此次发起授权的session。
public
DynamicTokenResponse
oauthToken
()
{
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
DynamicTokenRequest
request
=
new
DynamicTokenRequest
(
APP_KEY
,
APP_SECRET
,
GrantType
.
AUTHORIZATION_CODE
.
getValue
(),
AUTH_CODE
);
DynamicToken
dynamicToken
=
new
DynamicToken
(
request
);
DynamicTokenResponse
response
=
openAPIClient
.
invoke
(
dynamicToken
);
return
response
;
}
}
share-system/src/main/java/share/system/service/impl/SConsumerCouponServiceImpl.java
View file @
5caa0de0
package
share
.
system
.
service
.
impl
;
package
share
.
system
.
service
.
impl
;
import
java.util.List
;
import
java.lang.reflect.Array
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
cn.hutool.json.JSONArray
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.util.CollectionUtils
;
import
share.common.enums.RoomStatusEnum
;
import
share.common.enums.RoomType
;
import
share.common.enums.StoreType
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SRoom
;
import
share.system.domain.SStore
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.mapper.SConsumerCouponMapper
;
import
share.system.mapper.SConsumerCouponMapper
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.request.CouponRequest
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISRoomService
;
import
share.system.service.ISStoreService
;
/**
/**
* 优惠券领取记录Service业务层处理
* 优惠券领取记录Service业务层处理
...
@@ -21,6 +37,12 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
...
@@ -21,6 +37,12 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Autowired
@Autowired
private
SConsumerCouponMapper
sConsumerCouponMapper
;
private
SConsumerCouponMapper
sConsumerCouponMapper
;
@Autowired
private
ISRoomService
sRoomService
;
@Autowired
private
ISStoreService
sStoreService
;
/**
/**
* 查询优惠券领取记录
* 查询优惠券领取记录
*
*
...
@@ -99,4 +121,125 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
...
@@ -99,4 +121,125 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
public
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
)
{
public
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
)
{
return
sConsumerCouponMapper
.
selectSConsumerCouponConut
(
sConsumerCoupon
);
return
sConsumerCouponMapper
.
selectSConsumerCouponConut
(
sConsumerCoupon
);
}
}
@Override
public
List
<
SConsumerCoupon
>
availableCouponList
(
CouponRequest
couponRequest
)
{
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
sConsumerCoupon
.
setUseStatus
(
"0"
);
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
//查询用户未使用的优惠券
List
<
SConsumerCoupon
>
sConsumerCoupons
=
sConsumerCouponMapper
.
selectSConsumerCouponList
(
sConsumerCoupon
);
//计算时长
BigDecimal
bigDecimal
=
DateUtils
.
differentHour
(
couponRequest
.
getPreStartDate
(),
couponRequest
.
getPreEndDate
());
if
(
CollectionUtils
.
isEmpty
(
sConsumerCoupons
))
{
throw
new
RuntimeException
(
"用户没有可用的优惠券"
);
}
//迭代
sConsumerCoupons
.
forEach
(
item
->
{
if
(
item
.
getStartDate
().
compareTo
(
couponRequest
.
getPreStartDate
())
>
0
)
{
SStore
sStore
=
sStoreService
.
getById
(
couponRequest
.
getStoreId
());
SRoom
byId
=
sRoomService
.
getById
(
couponRequest
.
getRoomId
());
BigDecimal
subtract
=
new
BigDecimal
(
item
.
getMinDuration
());
if
(
item
.
getCouponType
().
equals
(
"3"
))
{
//判断门槛时长
if
(
bigDecimal
.
compareTo
(
subtract
)
>
0
)
{
//判断门店类型
if
(
item
.
getStoreType
().
contains
(
sStore
.
getStoreType
()))
{
//判断房间类型
if
(
item
.
getRoomType
().
contains
(
byId
.
getRoomType
()))
{
item
.
setIsAvailable
(
0
);
}
else
{
item
.
setIsAvailable
(
1
);
final
List
<
String
>
list
=
new
JSONArray
(
item
.
getRoomType
()).
toList
(
String
.
class
);
Map
<
String
,
String
>
colorMap
=
new
HashMap
<>();
EnumSet
<
RoomType
>
colors
=
EnumSet
.
allOf
(
RoomType
.
class
);
for
(
RoomType
color
:
colors
)
{
colorMap
.
put
(
color
.
getCode
(),
color
.
getName
());
}
StringBuilder
roomType
=
new
StringBuilder
();
for
(
String
type
:
list
)
{
roomType
.
append
(
colorMap
.
get
(
type
)).
append
(
","
);
}
item
.
setReason
(
"房间类型不支持,支持的房间类型为:"
+
roomType
);
}
}
else
{
item
.
setIsAvailable
(
1
);
final
List
<
String
>
list
=
new
JSONArray
(
item
.
getStoreType
()).
toList
(
String
.
class
);
Map
<
String
,
String
>
colorMap
=
new
HashMap
<>();
EnumSet
<
StoreType
>
colors
=
EnumSet
.
allOf
(
StoreType
.
class
);
for
(
StoreType
color
:
colors
)
{
colorMap
.
put
(
color
.
getCode
(),
color
.
getName
());
}
StringBuilder
storeType
=
new
StringBuilder
();
for
(
String
type
:
list
)
{
storeType
.
append
(
colorMap
.
get
(
type
)).
append
(
","
);
}
item
.
setReason
(
"门店类型不支持,支持的门店类型为:"
+
storeType
);
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"下单时长等于"
+
bigDecimal
+
"小时,不满足优惠券门槛时长"
);
}
}
else
{
//计算价格
BigDecimal
multiply
=
bigDecimal
.
multiply
(
byId
.
getPrice
());
//判断是否满足优惠券门槛
if
(
item
.
getMinPrice
().
compareTo
(
multiply
)
>
0
)
{
//判断门槛时长
if
(
bigDecimal
.
compareTo
(
subtract
)
>
0
)
{
//判断门店类型
if
(
item
.
getStoreType
().
contains
(
sStore
.
getStoreType
()))
{
//判断房间类型
if
(
item
.
getRoomType
().
contains
(
byId
.
getRoomType
()))
{
item
.
setIsAvailable
(
0
);
}
else
{
item
.
setIsAvailable
(
1
);
final
List
<
String
>
list
=
new
JSONArray
(
item
.
getRoomType
()).
toList
(
String
.
class
);
Map
<
String
,
String
>
colorMap
=
new
HashMap
<>();
EnumSet
<
RoomType
>
colors
=
EnumSet
.
allOf
(
RoomType
.
class
);
for
(
RoomType
color
:
colors
)
{
colorMap
.
put
(
color
.
getCode
(),
color
.
getName
());
}
StringBuilder
roomType
=
new
StringBuilder
();
for
(
String
type
:
list
)
{
roomType
.
append
(
colorMap
.
get
(
type
)).
append
(
","
);
}
item
.
setReason
(
"房间类型不支持,支持的房间类型为:"
+
roomType
);
}
}
else
{
item
.
setIsAvailable
(
1
);
final
List
<
String
>
list
=
new
JSONArray
(
item
.
getStoreType
()).
toList
(
String
.
class
);
Map
<
String
,
String
>
colorMap
=
new
HashMap
<>();
EnumSet
<
StoreType
>
colors
=
EnumSet
.
allOf
(
StoreType
.
class
);
for
(
StoreType
color
:
colors
)
{
colorMap
.
put
(
color
.
getCode
(),
color
.
getName
());
}
StringBuilder
storeType
=
new
StringBuilder
();
for
(
String
type
:
list
)
{
storeType
.
append
(
colorMap
.
get
(
type
)).
append
(
","
);
}
item
.
setReason
(
"门店类型不支持,支持的门店类型为:"
+
storeType
);
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"下单时长低于"
+
item
.
getMinDuration
()
+
"小时 "
);
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"消费金额低于"
+
item
.
getMinPrice
()
+
"元"
);
}
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"优惠卷未生效,优惠卷生效时间为"
+
item
.
getStartDate
()
+
"-"
+
item
.
getEndDate
());
}
});
return
sConsumerCoupons
;
}
}
}
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