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
3a137006
Commit
3a137006
authored
Jan 09, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠卷赠送功能
parent
3dc7a59f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
4 deletions
+52
-4
SConsumerCouponController.java
...hare/web/controller/system/SConsumerCouponController.java
+6
-0
ISConsumerCouponService.java
...in/java/share/system/service/ISConsumerCouponService.java
+2
-0
SConsumerCouponServiceImpl.java
...share/system/service/impl/SConsumerCouponServiceImpl.java
+44
-4
No files found.
share-admin/src/main/java/share/web/controller/system/SConsumerCouponController.java
View file @
3a137006
...
@@ -121,4 +121,10 @@ public class SConsumerCouponController extends BaseController
...
@@ -121,4 +121,10 @@ public class SConsumerCouponController extends BaseController
{
{
return
toAjax
(
sConsumerCouponService
.
deleteSConsumerCouponByIds
(
ids
));
return
toAjax
(
sConsumerCouponService
.
deleteSConsumerCouponByIds
(
ids
));
}
}
//赠送优惠卷
@PostMapping
(
"/give"
)
public
AjaxResult
give
(
@RequestBody
SConsumerCoupon
sConsumerCoupon
)
{
return
toAjax
(
sConsumerCouponService
.
give
(
sConsumerCoupon
));
}
}
}
share-system/src/main/java/share/system/service/ISConsumerCouponService.java
View file @
3a137006
...
@@ -64,4 +64,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
...
@@ -64,4 +64,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
);
int
selectSConsumerCouponConut
(
SConsumerCoupon
sConsumerCoupon
);
List
<
SConsumerCoupon
>
availableCouponList
(
CouponRequest
couponRequest
);
List
<
SConsumerCoupon
>
availableCouponList
(
CouponRequest
couponRequest
);
int
give
(
SConsumerCoupon
sConsumerCoupon
);
}
}
share-system/src/main/java/share/system/service/impl/SConsumerCouponServiceImpl.java
View file @
3a137006
...
@@ -8,18 +8,17 @@ import java.util.*;
...
@@ -8,18 +8,17 @@ import java.util.*;
import
cn.hutool.json.JSONArray
;
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
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
share.common.enums.*
;
import
share.common.enums.*
;
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.*
;
import
share.system.domain.SRoom
;
import
share.system.domain.SStore
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.domain.vo.FrontTokenComponent
;
import
share.system.mapper.SConsumerCouponMapper
;
import
share.system.mapper.SConsumerCouponMapper
;
import
share.system.domain.SConsumerCoupon
;
import
share.system.request.CouponRequest
;
import
share.system.request.CouponRequest
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISConsumerCouponService
;
import
share.system.service.ISCouponService
;
import
share.system.service.ISRoomService
;
import
share.system.service.ISRoomService
;
import
share.system.service.ISStoreService
;
import
share.system.service.ISStoreService
;
...
@@ -40,6 +39,11 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
...
@@ -40,6 +39,11 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Autowired
@Autowired
private
ISStoreService
sStoreService
;
private
ISStoreService
sStoreService
;
@Autowired
private
ISCouponService
sCouponService
;
private
static
final
Integer
ZERO
=
0
;
/**
/**
* 查询优惠券领取记录
* 查询优惠券领取记录
*
*
...
@@ -181,6 +185,42 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
...
@@ -181,6 +185,42 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
return
sConsumerCoupons
;
return
sConsumerCoupons
;
}
}
@Override
public
int
give
(
SConsumerCoupon
sConsumerCoupon
)
{
//根据优惠券id查询优惠券信息
SCoupon
sCoupon
=
sCouponService
.
selectSCouponById
(
sConsumerCoupon
.
getCouponId
());
if
(
ObjectUtils
.
isEmpty
(
sCoupon
))
{
return
0
;
}
if
(
sCoupon
.
getNumber
().
equals
(
ZERO
))
{
throw
new
RuntimeException
(
"优惠券数量为0"
);
}
//创建优惠卷领取记录
SConsumerCoupon
newSConsumerCoupon
=
new
SConsumerCoupon
();
newSConsumerCoupon
.
setCouponId
(
sCoupon
.
getId
());
newSConsumerCoupon
.
setConsumerId
(
sConsumerCoupon
.
getConsumerId
());
newSConsumerCoupon
.
setName
(
sCoupon
.
getName
());
newSConsumerCoupon
.
setStoreType
(
sCoupon
.
getStoreType
());
newSConsumerCoupon
.
setRoomType
(
sCoupon
.
getRoomType
());
newSConsumerCoupon
.
setCouponTimeStart
(
sCoupon
.
getValidStartTime
());
newSConsumerCoupon
.
setCouponTimeEnd
(
sCoupon
.
getValidEndTime
());
newSConsumerCoupon
.
setCouponType
(
sCoupon
.
getCouponType
());
newSConsumerCoupon
.
setMinDuration
(
sCoupon
.
getMinDuration
());
newSConsumerCoupon
.
setMaxDuration
(
sCoupon
.
getMaxDuration
());
newSConsumerCoupon
.
setDuration
(
sCoupon
.
getDuration
());
newSConsumerCoupon
.
setSourceType
(
SourceTypeEnum
.
GIVE
.
getCode
());
newSConsumerCoupon
.
setPlatformType
(
String
.
valueOf
(
sCoupon
.
getPlatformType
()));
newSConsumerCoupon
.
setStartDate
(
sCoupon
.
getStartDate
());
newSConsumerCoupon
.
setEndDate
(
sCoupon
.
getEndDate
());
int
insert
=
sConsumerCouponMapper
.
insert
(
newSConsumerCoupon
);
if
(
insert
>
0
)
{
//优惠券数量减一
sCoupon
.
setNumber
(
sCoupon
.
getNumber
()
-
1
);
sCouponService
.
updateSCoupon
(
sCoupon
);
}
return
insert
;
}
private
void
extracted
(
SConsumerCoupon
item
,
BigDecimal
bigDecimal
,
SRoom
byId
,
BigDecimal
subtract
,
SStore
sStore
)
{
private
void
extracted
(
SConsumerCoupon
item
,
BigDecimal
bigDecimal
,
SRoom
byId
,
BigDecimal
subtract
,
SStore
sStore
)
{
//计算价格
//计算价格
BigDecimal
multiply
=
bigDecimal
.
multiply
(
byId
.
getPrice
());
BigDecimal
multiply
=
bigDecimal
.
multiply
(
byId
.
getPrice
());
...
...
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