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
a4d37af8
Commit
a4d37af8
authored
Jan 15, 2024
by
wuwenlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
available coupon weeks check dev;
parent
fda8f480
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
155 additions
and
24 deletions
+155
-24
WeekEnum.java
share-common/src/main/java/share/common/enums/WeekEnum.java
+94
-0
SConsumerCoupon.java
...em/src/main/java/share/system/domain/SConsumerCoupon.java
+1
-1
SCoupon.java
share-system/src/main/java/share/system/domain/SCoupon.java
+1
-1
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+1
-1
SConsumerCouponServiceImpl.java
...share/system/service/impl/SConsumerCouponServiceImpl.java
+46
-9
SConsumerCouponMapper.xml
...rc/main/resources/mapper/system/SConsumerCouponMapper.xml
+6
-6
SCouponMapper.xml
...system/src/main/resources/mapper/system/SCouponMapper.xml
+6
-6
No files found.
share-common/src/main/java/share/common/enums/WeekEnum.java
0 → 100644
View file @
a4d37af8
package
share
.
common
.
enums
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* @Author wwl
* @Date 2024/1/15 13:27
*/
public
enum
WeekEnum
{
MONDAY
(
1
,
"周一"
),
TUESDAY
(
2
,
"周二"
),
WEDNESDAY
(
3
,
"周三"
),
THURSDAY
(
4
,
"周四"
),
FRIDAY
(
5
,
"周五"
),
SATURDAY
(
6
,
"周六"
),
SUNDAY
(
7
,
"周日"
);
private
Integer
code
;
private
String
value
;
WeekEnum
(
Integer
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
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
;
}
public
static
String
getValueByCode
(
Integer
code
){
WeekEnum
week
=
getEnumByCode
(
code
);
if
(
Objects
.
nonNull
(
week
)){
return
week
.
value
;
}
return
""
;
}
public
static
WeekEnum
getEnumByCode
(
Integer
code
){
for
(
WeekEnum
week
:
WeekEnum
.
values
())
{
if
(
week
.
code
.
compareTo
(
code
)==
0
)
{
return
week
;
}
}
return
null
;
}
public
static
Boolean
isSundays
(
ArrayList
<
Integer
>
weeks
){
List
<
Integer
>
sundays
=
new
ArrayList
<
Integer
>(){{
add
(
SATURDAY
.
code
);
add
(
SUNDAY
.
code
);
}};
if
(
weeks
.
size
()==
2
&&
sundays
.
contains
(
weeks
.
get
(
0
))
&&
sundays
.
contains
(
weeks
.
get
(
1
))){
return
true
;
}
return
false
;
}
public
static
Boolean
isAllWorkDays
(
ArrayList
<
Integer
>
weeks
){
List
<
Integer
>
workDays
=
new
ArrayList
<
Integer
>(){{
add
(
MONDAY
.
code
);
add
(
TUESDAY
.
code
);
add
(
WEDNESDAY
.
code
);
add
(
THURSDAY
.
code
);
add
(
FRIDAY
.
code
);
}};
if
(
weeks
.
size
()==
5
&&
workDays
.
contains
(
weeks
.
get
(
0
))
&&
workDays
.
contains
(
weeks
.
get
(
1
))
&&
workDays
.
contains
(
weeks
.
get
(
2
))
&&
workDays
.
contains
(
weeks
.
get
(
3
))
&&
workDays
.
contains
(
weeks
.
get
(
4
))){
return
true
;
}
return
false
;
}
}
share-system/src/main/java/share/system/domain/SConsumerCoupon.java
View file @
a4d37af8
...
...
@@ -159,7 +159,7 @@ public class SConsumerCoupon extends BaseEntity
* 适用星期列表(1:周一,2:周二,3:周三,4:周四,5:周五,6:周六,7:周日)
*/
@Excel
(
name
=
"适用星期列表"
)
private
String
sunday
s
;
private
String
week
s
;
/** 更新者 */
@Excel
(
name
=
"更新者"
)
...
...
share-system/src/main/java/share/system/domain/SCoupon.java
View file @
a4d37af8
...
...
@@ -115,7 +115,7 @@ public class SCoupon extends BaseEntity
* 适用星期列表(1:周一,2:周二,3:周三,4:周四,5:周五,6:周六,7:周日)
*/
@Excel
(
name
=
"适用星期列表"
)
private
String
sunday
s
;
private
String
week
s
;
/**
* 第三方平台类型(1:自营,2:美团)
...
...
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
View file @
a4d37af8
...
...
@@ -182,7 +182,7 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon
.
setDealgroupId
(
sCoupon
.
getDealgroupId
());
sConsumerCoupon
.
setStoreIds
(
sCoupon
.
getStoreIds
());
sConsumerCoupon
.
setPackageId
(
sCoupon
.
getPackageId
());
sConsumerCoupon
.
set
Sundays
(
sCoupon
.
getSunday
s
());
sConsumerCoupon
.
set
Weeks
(
sCoupon
.
getWeek
s
());
sConsumerCoupon
.
setRemark
(
sCoupon
.
getRemark
());
}
isConsumerCouponService
.
insertSConsumerCoupon
(
sConsumerCoupon
);
...
...
share-system/src/main/java/share/system/service/impl/SConsumerCouponServiceImpl.java
View file @
a4d37af8
...
...
@@ -203,19 +203,56 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
&&
checkCouponType
(
item
,
couponRequest
,
sStores
,
sRooms
,
timeLong
)
&&
checkOrderType
(
item
,
couponRequest
)
&&
checkPack
(
item
,
couponRequest
,
sPacks
)
&&
chekc
Sunday
(
item
,
couponRequest
);
&&
chekc
Weeks
(
item
,
couponRequest
);
}
private
Boolean
chekcSunday
(
SConsumerCoupon
item
,
CouponRequest
couponRequest
)
{
// if (Objects.nonNull(item.getSundays()) && item.getSundays().compareTo(YesNoEnum.yes.getIndex()) == 0) {
// if (!DateUtil.isWeekend(couponRequest.getPreStartDate()) || DateUtil.isWeekend(couponRequest.getPreEndDate())) {
// item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode());
// item.setReason("优惠卷周末可用");
// }
// }
private
Boolean
chekcWeeks
(
SConsumerCoupon
item
,
CouponRequest
couponRequest
)
{
if
(
StringUtils
.
isNotBlank
(
item
.
getWeeks
()))
{
Integer
startWeek
=
DateUtil
.
dayOfWeek
(
DateUtils
.
addDays
(
couponRequest
.
getPreStartDate
(),
-
1
));
Integer
endWeek
=
DateUtil
.
dayOfWeek
(
DateUtils
.
addDays
(
couponRequest
.
getPreEndDate
(),
-
1
));
ArrayList
<
Integer
>
weeks
=
(
ArrayList
<
Integer
>)
Arrays
.
stream
(
item
.
getWeeks
().
split
(
","
))
.
map
(
Integer:
:
parseInt
).
collect
(
Collectors
.
toList
());
if
(!
weeks
.
contains
(
startWeek
)||!
weeks
.
contains
(
endWeek
)){
item
.
setIsAvailable
(
AvailableEnum
.
UNAVAILABLE
.
getCode
());
if
(
checkIfArrayIsContinuous
(
weeks
.
stream
().
mapToInt
(
i
->
i
.
intValue
()).
toArray
())){
if
(
weeks
.
size
()==
1
)
{
item
.
setReason
(
"优惠卷"
+
WeekEnum
.
getValueByCode
(
weeks
.
get
(
0
))
+
"可用"
);
}
else
if
(
WeekEnum
.
isSundays
(
weeks
)){
item
.
setReason
(
"优惠卷周末可用"
);
}
else
if
(
WeekEnum
.
isAllWorkDays
(
weeks
)){
item
.
setReason
(
"优惠卷周一至周五可用"
);
}
else
{
item
.
setReason
(
"优惠卷"
+
WeekEnum
.
getValueByCode
(
weeks
.
get
(
0
))
+
"至"
+
WeekEnum
.
getValueByCode
(
weeks
.
get
(
weeks
.
size
()-
1
))+
"可用"
);
}
}
else
{
StringBuffer
buf
=
new
StringBuffer
(
"优惠券"
);
for
(
int
index
=
0
;
index
<
weeks
.
size
();
index
++){
buf
.
append
(
WeekEnum
.
getValueByCode
(
weeks
.
get
(
index
)));
if
(
index
<
weeks
.
size
()-
1
){
buf
.
append
(
","
);
buf
.
append
(
"可用"
);
}
}
item
.
setReason
(
buf
.
toString
());
}
}
}
return
item
.
getIsAvailable
()
==
0
;
}
private
static
boolean
checkIfArrayIsContinuous
(
int
[]
array
)
{
if
(
array
==
null
||
array
.
length
<
2
)
{
return
true
;
// 空数组或只有一个元素时认为是连续的
}
Arrays
.
sort
(
array
);
// 先对数组进行排序
for
(
int
i
=
0
;
i
<
array
.
length
-
1
;
i
++)
{
if
(
array
[
i
]
!=
array
[
i
+
1
])
{
return
false
;
// 如果相邻两个元素之间存在跨度大于1的情况则返回false
}
}
return
true
;
// 没有发现跨度大于1的情况则返回true
}
private
Boolean
checkPack
(
SConsumerCoupon
item
,
CouponRequest
couponRequest
,
List
<
SPack
>
sPacks
){
if
(
Objects
.
nonNull
(
item
.
getPackageId
())&&
item
.
getPackageId
().
compareTo
(
couponRequest
.
getPackageId
())!=
0
){
SPack
pack
=
sPacks
.
stream
().
filter
(
obj
->
obj
.
getId
().
compareTo
(
item
.
getPackageId
())==
0
).
findFirst
().
orElse
(
null
);
...
...
@@ -337,7 +374,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
newSConsumerCoupon
.
setCouponType
(
sCoupon
.
getCouponType
());
newSConsumerCoupon
.
setMinPrice
(
new
BigDecimal
(
0.00
));
newSConsumerCoupon
.
setSubPrice
(
sCoupon
.
getSubPrice
());
newSConsumerCoupon
.
set
Sundays
(
sCoupon
.
getSunday
s
());
newSConsumerCoupon
.
set
Weeks
(
sCoupon
.
getWeek
s
());
newSConsumerCoupon
.
setMinDuration
(
sCoupon
.
getMinDuration
());
newSConsumerCoupon
.
setMaxDuration
(
sCoupon
.
getMaxDuration
());
newSConsumerCoupon
.
setDuration
(
sCoupon
.
getDuration
());
...
...
share-system/src/main/resources/mapper/system/SConsumerCouponMapper.xml
View file @
a4d37af8
...
...
@@ -33,7 +33,7 @@
<result
property=
"useDate"
column=
"use_date"
/>
<result
property=
"useStatus"
column=
"use_status"
/>
<result
property=
"isDelete"
column=
"is_delete"
/>
<result
property=
"
sundays"
column=
"sunday
s"
/>
<result
property=
"
weeks"
column=
"week
s"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
...
...
@@ -68,7 +68,7 @@
use_date,
use_status,
is_delete,
sunday
s,
week
s,
create_by,
create_time,
update_by,
...
...
@@ -108,7 +108,7 @@
<if
test=
"endDate != null "
>
and end_date = #{endDate}
</if>
<if
test=
"useDate != null "
>
and use_date = #{useDate}
</if>
<if
test=
"useStatus != null and useStatus != '' or useStatus==0"
>
and use_status = #{useStatus}
</if>
<if
test=
"
sundays != null and sundays != ''"
>
and sundays = #{sunday
s}
</if>
<if
test=
"
weeks != null and weeks != ''"
>
and weeks = #{week
s}
</if>
<if
test=
"isDelete != null "
>
and is_delete = #{isDelete}
</if>
<if
test=
"deleteBy != null and deleteBy != ''"
>
and delete_by = #{deleteBy}
</if>
<if
test=
"deleteTime != null "
>
and delete_time = #{deleteTime}
</if>
...
...
@@ -158,7 +158,7 @@
<if
test=
"useDate != null"
>
use_date,
</if>
<if
test=
"useStatus != null"
>
use_status,
</if>
<if
test=
"isDelete != null"
>
is_delete,
</if>
<if
test=
"
sundays != null"
>
sunday
s,
</if>
<if
test=
"
weeks != null"
>
week
s,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
...
...
@@ -195,7 +195,7 @@
<if
test=
"useDate != null"
>
#{useDate},
</if>
<if
test=
"useStatus != null"
>
#{useStatus},
</if>
<if
test=
"isDelete != null"
>
#{isDelete},
</if>
<if
test=
"
sundays != null"
>
#{sunday
s},
</if>
<if
test=
"
weeks != null"
>
#{week
s},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
...
...
@@ -236,7 +236,7 @@
<if
test=
"useDate != null"
>
use_date = #{useDate},
</if>
<if
test=
"useStatus != null"
>
use_status = #{useStatus},
</if>
<if
test=
"isDelete != null"
>
is_delete = #{isDelete},
</if>
<if
test=
"
sundays != null"
>
sundays = #{sunday
s},
</if>
<if
test=
"
weeks != null"
>
weeks = #{week
s},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
...
...
share-system/src/main/resources/mapper/system/SCouponMapper.xml
View file @
a4d37af8
...
...
@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"minPrice"
column=
"min_price"
/>
<result
property=
"subPrice"
column=
"sub_price"
/>
<result
property=
"isOverlay"
column=
"is_overlay"
/>
<result
property=
"
sundays"
column=
"sunday
s"
/>
<result
property=
"
weeks"
column=
"week
s"
/>
<result
property=
"platformType"
column=
"platform_type"
/>
<result
property=
"number"
column=
"number"
/>
<result
property=
"createBy"
column=
"create_by"
/>
...
...
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order_type,
package_id,
dealgroup_id,
sunday
s,
week
s,
store_ids,
duration,min_duration,max_duration,
min_price,sub_price,is_overlay,
...
...
@@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"subPrice != null and subPrice != ''"
>
and sub_price = #{subPrice}
</if>
<if
test=
"isOverlay != null"
>
and is_overlay = #{isOverlay}
</if>
<if
test=
"platformType != null"
>
and platform_type = #{platformType}
</if>
<if
test=
"
sundays != null"
>
and sundays = #{sunday
s}
</if>
<if
test=
"
weeks != null"
>
and weeks = #{week
s}
</if>
<if
test=
"number != null"
>
and number = #{number}
</if>
<if
test=
"createBy != null"
>
and create_by = #{createBy}
</if>
<if
test=
"createTime != null"
>
and create_time = #{createTime}
</if>
...
...
@@ -130,7 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"minPrice != null"
>
min_price,
</if>
<if
test=
"subPrice != null"
>
sub_price,
</if>
<if
test=
"isOverlay != null"
>
is_overlay,
</if>
<if
test=
"
sundays != null"
>
sunday
s,
</if>
<if
test=
"
weeks != null"
>
week
s,
</if>
<if
test=
"platformType != null"
>
platform_type,
</if>
<if
test=
"number != null"
>
number,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
...
...
@@ -156,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"minPrice != null"
>
#{minPrice},
</if>
<if
test=
"subPrice != null"
>
#{subPrice},
</if>
<if
test=
"isOverlay != null"
>
#{isOverlay},
</if>
<if
test=
"
sundays != null"
>
#{sunday
s},
</if>
<if
test=
"
weeks != null"
>
#{week
s},
</if>
<if
test=
"platformType != null"
>
#{platformType},
</if>
<if
test=
"number != null"
>
#{number},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
...
...
@@ -187,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"duration != null and duration != ''"
>
duration = #{duration},
</if>
<if
test=
"minDuration != null and minDuration != ''"
>
min_duration = #{minDuration},
</if>
<if
test=
"maxDuration != null and maxDuration != ''"
>
max_duration = #{maxDuration},
</if>
<if
test=
"
sundays != null"
>
sundays = #{sunday
s},
</if>
<if
test=
"
weeks != null"
>
weeks = #{week
s},
</if>
<if
test=
"minPrice != null and minPrice != ''"
>
min_price = #{minPrice},
</if>
<if
test=
"subPrice != null and subPrice != ''"
>
sub_price = #{subPrice},
</if>
<if
test=
"isOverlay != null"
>
is_overlay = #{isOverlay},
</if>
...
...
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