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
2357c337
Commit
2357c337
authored
Oct 25, 2023
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询可用优惠卷完成
parent
87fdcdb2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
93 deletions
+116
-93
QPController.java
...c/main/java/share/web/controller/system/QPController.java
+2
-2
SCoupon.java
share-system/src/main/java/share/system/domain/SCoupon.java
+4
-6
QPService.java
...-system/src/main/java/share/system/service/QPService.java
+1
-1
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+27
-4
SConsumerCouponServiceImpl.java
...share/system/service/impl/SConsumerCouponServiceImpl.java
+81
-79
SCouponMapper.xml
...system/src/main/resources/mapper/system/SCouponMapper.xml
+1
-1
No files found.
share-front/src/main/java/share/web/controller/system/QPController.java
View file @
2357c337
...
...
@@ -47,7 +47,7 @@ public class QPController {
//用户销券接口
@GetMapping
(
"/reverseconsumeByUser"
)
public
R
reverseconsumeByUser
(
String
code
,
String
appDealI
d
)
{
return
R
.
ok
(
qpService
.
reverseconsumeByUser
(
code
,
appDealI
d
));
public
R
reverseconsumeByUser
(
Long
i
d
)
{
return
R
.
ok
(
qpService
.
reverseconsumeByUser
(
i
d
));
}
}
share-system/src/main/java/share/system/domain/SCoupon.java
View file @
2357c337
...
...
@@ -38,14 +38,12 @@ public class SCoupon extends BaseEntity
private
Date
endDate
;
/** 有效开始时段 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@Excel
(
name
=
"有效开始时段"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
validStartTime
;
@Excel
(
name
=
"有效开始时段"
,
width
=
30
,
dateFormat
=
"HH:mm"
)
private
String
validStartTime
;
/** 有效结束时段 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@Excel
(
name
=
"有效结束时段"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
validEndTime
;
@Excel
(
name
=
"有效结束时段"
,
width
=
30
,
dateFormat
=
"HH:mm"
)
private
String
validEndTime
;
//门店类型
@Excel
(
name
=
"门店类型(1:标准店,2:外卖店,3:酒店,4:其他)"
)
...
...
share-system/src/main/java/share/system/service/QPService.java
View file @
2357c337
...
...
@@ -18,5 +18,5 @@ public interface QPService {
String
consumeByUser
(
String
code
,
int
count
);
String
reverseconsumeByUser
(
String
code
,
String
appDealI
d
);
String
reverseconsumeByUser
(
Long
i
d
);
}
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
View file @
2357c337
...
...
@@ -11,9 +11,11 @@ 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.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
share.common.utils.uuid.UUID
;
import
share.system.domain.SConsumer
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.domain.SCoupon
;
...
...
@@ -22,7 +24,11 @@ import share.system.service.ISConsumerCouponService;
import
share.system.service.ISCouponService
;
import
share.system.service.QPService
;
import
java.util.List
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
@Service
public
class
QPServiceImpl
implements
QPService
{
...
...
@@ -72,6 +78,8 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon
.
setPlatformType
(
"2"
);
sConsumerCoupon
.
setStartDate
(
sCoupon
.
getStartDate
());
sConsumerCoupon
.
setEndDate
(
item
.
getReceiptEndDate
());
sConsumerCoupon
.
setCouponTimeStart
(
sCoupon
.
getValidStartTime
());
sConsumerCoupon
.
setCouponTimeEnd
(
sCoupon
.
getValidEndTime
());
sConsumerCoupon
.
setCreateBy
(
String
.
valueOf
(
user
.
getId
()));
isConsumerCouponService
.
insertSConsumerCoupon
(
sConsumerCoupon
);
});
...
...
@@ -79,9 +87,24 @@ public class QPServiceImpl implements QPService {
}
@Override
public
String
reverseconsumeByUser
(
String
code
,
String
appDealId
)
{
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
getconsumed
(
code
);
return
null
;
public
String
reverseconsumeByUser
(
Long
id
)
{
SConsumerCoupon
byId
=
isConsumerCouponService
.
getById
(
id
);
if
(
byId
==
null
)
{
throw
new
RuntimeException
(
"未找到对应的券码"
);
}
if
(
StringUtils
.
isBlank
(
byId
.
getCouponCode
())){
throw
new
RuntimeException
(
"未找到对应的券码"
);
}
TuangouReceiptGetConsumedReponseEntity
getconsumed
=
getconsumed
(
byId
.
getCouponCode
());
if
(
getconsumed
==
null
)
{
throw
new
RuntimeException
(
"未找到对应的券码"
);
}
List
<
TuangouReceiptReverseConsumeResponseEntity
>
reverseconsume
=
reverseconsume
(
byId
.
getCouponCode
(),
getconsumed
.
getApp_shop_id
());
if
(
reverseconsume
==
null
)
{
throw
new
RuntimeException
(
"未找到对应的券码"
);
}
isConsumerCouponService
.
removeById
(
id
);
return
"销卷成功"
;
}
/**
...
...
share-system/src/main/java/share/system/service/impl/SConsumerCouponServiceImpl.java
View file @
2357c337
...
...
@@ -2,6 +2,7 @@ package share.system.service.impl;
import
java.lang.reflect.Array
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
cn.hutool.json.JSONArray
;
...
...
@@ -27,13 +28,12 @@ import share.system.service.ISStoreService;
/**
* 优惠券领取记录Service业务层处理
*
*
* @author wuwenlong
* @date 2023-10-12
*/
@Service
public
class
SConsumerCouponServiceImpl
extends
ServiceImpl
<
SConsumerCouponMapper
,
SConsumerCoupon
>
implements
ISConsumerCouponService
{
public
class
SConsumerCouponServiceImpl
extends
ServiceImpl
<
SConsumerCouponMapper
,
SConsumerCoupon
>
implements
ISConsumerCouponService
{
@Autowired
private
SConsumerCouponMapper
sConsumerCouponMapper
;
...
...
@@ -45,75 +45,69 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
/**
* 查询优惠券领取记录
*
*
* @param id 优惠券领取记录主键
* @return 优惠券领取记录
*/
@Override
public
SConsumerCoupon
selectSConsumerCouponById
(
Long
id
)
{
public
SConsumerCoupon
selectSConsumerCouponById
(
Long
id
)
{
return
sConsumerCouponMapper
.
selectSConsumerCouponById
(
id
);
}
/**
* 查询优惠券领取记录列表
*
*
* @param sConsumerCoupon 优惠券领取记录
* @return 优惠券领取记录
*/
@Override
public
List
<
SConsumerCoupon
>
selectSConsumerCouponList
(
SConsumerCoupon
sConsumerCoupon
)
{
public
List
<
SConsumerCoupon
>
selectSConsumerCouponList
(
SConsumerCoupon
sConsumerCoupon
)
{
return
sConsumerCouponMapper
.
selectSConsumerCouponList
(
sConsumerCoupon
);
}
/**
* 新增优惠券领取记录
*
*
* @param sConsumerCoupon 优惠券领取记录
* @return 结果
*/
@Override
public
int
insertSConsumerCoupon
(
SConsumerCoupon
sConsumerCoupon
)
{
public
int
insertSConsumerCoupon
(
SConsumerCoupon
sConsumerCoupon
)
{
sConsumerCoupon
.
setCreateTime
(
DateUtils
.
getNowDate
());
return
sConsumerCouponMapper
.
insertSConsumerCoupon
(
sConsumerCoupon
);
}
/**
* 修改优惠券领取记录
*
*
* @param sConsumerCoupon 优惠券领取记录
* @return 结果
*/
@Override
public
int
updateSConsumerCoupon
(
SConsumerCoupon
sConsumerCoupon
)
{
public
int
updateSConsumerCoupon
(
SConsumerCoupon
sConsumerCoupon
)
{
sConsumerCoupon
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
sConsumerCouponMapper
.
updateSConsumerCoupon
(
sConsumerCoupon
);
}
/**
* 批量删除优惠券领取记录
*
*
* @param ids 需要删除的优惠券领取记录主键
* @return 结果
*/
@Override
public
int
deleteSConsumerCouponByIds
(
Long
[]
ids
)
{
public
int
deleteSConsumerCouponByIds
(
Long
[]
ids
)
{
return
sConsumerCouponMapper
.
deleteSConsumerCouponByIds
(
ids
);
}
/**
* 删除优惠券领取记录信息
*
*
* @param id 优惠券领取记录主键
* @return 结果
*/
@Override
public
int
deleteSConsumerCouponById
(
Long
id
)
{
public
int
deleteSConsumerCouponById
(
Long
id
)
{
return
sConsumerCouponMapper
.
deleteSConsumerCouponById
(
id
);
}
...
...
@@ -127,7 +121,8 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
SConsumerCoupon
sConsumerCoupon
=
new
SConsumerCoupon
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
sConsumerCoupon
.
setUseStatus
(
"0"
);
sConsumerCoupon
.
setConsumerId
(
user
.
getId
());
// sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon
.
setConsumerId
(
1714160213741535234L
);
//查询用户未使用的优惠券
List
<
SConsumerCoupon
>
sConsumerCoupons
=
sConsumerCouponMapper
.
selectSConsumerCouponList
(
sConsumerCoupon
);
//计算时长
...
...
@@ -137,66 +132,22 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
}
//迭代
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
(
item
.
getStartDate
().
compareTo
(
couponRequest
.
getPreStartDate
())
<=
0
&&
item
.
getEndDate
().
compareTo
(
couponRequest
.
getPreEndDate
())
>=
0
)
{
SimpleDateFormat
sdf1
=
new
SimpleDateFormat
(
"HH:mm"
);
String
proStartTime
=
sdf1
.
format
(
couponRequest
.
getPreStartDate
());
if
(
proStartTime
.
compareTo
(
item
.
getCouponTimeStart
())
>=
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
(
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
<>();
...
...
@@ -228,16 +179,67 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"下单时长
低于"
+
item
.
getMinDuration
()
+
"小时
"
);
item
.
setReason
(
"下单时长
等于"
+
bigDecimal
+
"小时,不满足优惠券门槛时长
"
);
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"消费金额低于"
+
item
.
getMinPrice
()
+
"元"
);
//计算价格
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
.
getCouponTimeStart
()
+
"-"
+
item
.
getCouponTimeEnd
());
}
}
else
{
item
.
setIsAvailable
(
1
);
item
.
setReason
(
"优惠卷未生效,优惠卷
生效时间为"
+
item
.
getStartDate
()
+
"-"
+
item
.
getEndDate
(
));
item
.
setReason
(
"优惠卷未生效,优惠卷
有效时间为"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
item
.
getStartDate
())
+
"-"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
item
.
getEndDate
()
));
}
});
return
sConsumerCoupons
;
...
...
share-system/src/main/resources/mapper/system/SCouponMapper.xml
View file @
2357c337
...
...
@@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include
refid=
"selectSCouponVo"
/>
where id = #{id}
</select>
<select
id=
"selectSCouponByName"
resultType=
"share.system.domain.SCoupon
"
>
<select
id=
"selectSCouponByName"
resultMap=
"SCouponResult
"
>
<include
refid=
"selectSCouponVo"
/>
where name = #{name}
</select>
...
...
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