Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
cc5a1c17
Commit
cc5a1c17
authored
Aug 11, 2018
by
Menethil
Browse files
添加提交订单时验证团购活动是否过期
parent
a698766f
Changes
6
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGrouponController.java
View file @
cc5a1c17
...
...
@@ -51,7 +51,7 @@ public class AdminGrouponController {
List
<
Map
<
String
,
Object
>>
records
=
new
ArrayList
<>();
for
(
LitemallGroupon
groupon
:
grouponList
)
{
Map
<
String
,
Object
>
RecordData
=
new
HashMap
<>();
List
<
LitemallGroupon
>
subGrouponList
=
grouponService
.
queryJoin
ers
(
groupon
.
getId
());
List
<
LitemallGroupon
>
subGrouponList
=
grouponService
.
queryJoin
Record
(
groupon
.
getId
());
LitemallGrouponRules
rules
=
rulesService
.
queryById
(
groupon
.
getRulesId
());
LitemallGoods
goods
=
goodsService
.
findById
(
rules
.
getGoodsId
());
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponRulesService.java
View file @
cc5a1c17
...
...
@@ -8,6 +8,7 @@ import org.linlinjava.litemall.db.domain.LitemallGrouponRulesExample;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
@Service
...
...
@@ -19,8 +20,16 @@ public class LitemallGrouponRulesService {
return
mapper
.
insertSelective
(
rules
);
}
/**
* 根据ID查找对应团购项
*
* @param id
* @return
*/
public
LitemallGrouponRules
queryById
(
Integer
id
)
{
return
mapper
.
selectByPrimaryKey
(
id
);
LitemallGrouponRulesExample
example
=
new
LitemallGrouponRulesExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
);
return
mapper
.
selectOneByExample
(
example
);
}
/**
...
...
@@ -35,6 +44,13 @@ public class LitemallGrouponRulesService {
return
mapper
.
selectByExample
(
example
);
}
/**
* 获取首页团购活动列表
*
* @param offset
* @param limit
* @return
*/
public
List
<
LitemallGrouponRules
>
queryByIndex
(
int
offset
,
int
limit
)
{
LitemallGrouponRulesExample
example
=
new
LitemallGrouponRulesExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
...
...
@@ -43,6 +59,27 @@ public class LitemallGrouponRulesService {
return
mapper
.
selectByExample
(
example
);
}
/**
* 判断某个团购活动是否已经过期
*
* @return
*/
public
boolean
isExpired
(
LitemallGrouponRules
rules
)
{
if
(
rules
==
null
||
rules
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
return
false
;
return
true
;
}
/**
* 获取团购活动列表
*
* @param goodsId
* @param page
* @param size
* @param sort
* @param order
* @return
*/
public
List
<
LitemallGrouponRules
>
querySelective
(
String
goodsId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGrouponRulesExample
example
=
new
LitemallGrouponRulesExample
();
LitemallGrouponRulesExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java
View file @
cc5a1c17
...
...
@@ -16,17 +16,11 @@ public class LitemallGrouponService {
LitemallGrouponMapper
mapper
;
/**
*
查询用户所有参与
的团购
*
获取用户发起
的团购
记录
*
* @param userId
* @return
*/
public
List
<
LitemallGroupon
>
queryByUserId
(
Integer
userId
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andUserIdEqualTo
(
userId
).
andDeletedEqualTo
(
false
);
return
mapper
.
selectByExample
(
example
);
}
public
List
<
LitemallGroupon
>
queryMyGroupon
(
Integer
userId
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andUserIdEqualTo
(
userId
).
andCreatorUserIdEqualTo
(
userId
).
andGrouponIdEqualTo
(
0
).
andDeletedEqualTo
(
false
).
andPayedEqualTo
(
true
);
...
...
@@ -34,6 +28,12 @@ public class LitemallGrouponService {
return
mapper
.
selectByExample
(
example
);
}
/**
* 获取用户参与的团购记录
*
* @param userId
* @return
*/
public
List
<
LitemallGroupon
>
queryMyJoinGroupon
(
Integer
userId
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andUserIdEqualTo
(
userId
).
andGrouponIdNotEqualTo
(
0
).
andDeletedEqualTo
(
false
).
andPayedEqualTo
(
true
);
...
...
@@ -41,13 +41,25 @@ public class LitemallGrouponService {
return
mapper
.
selectByExample
(
example
);
}
/**
* 根据OrderId查询团购记录
*
* @param orderId
* @return
*/
public
LitemallGroupon
queryByOrderId
(
Integer
orderId
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andOrderIdEqualTo
(
orderId
).
andDeletedEqualTo
(
false
);
return
mapper
.
selectOneByExample
(
example
);
}
public
List
<
LitemallGroupon
>
queryJoiners
(
Integer
id
)
{
/**
* 获取某个团购活动参与的记录
*
* @param id
* @return
*/
public
List
<
LitemallGroupon
>
queryJoinRecord
(
Integer
id
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andGrouponIdEqualTo
(
id
).
andDeletedEqualTo
(
false
).
andPayedEqualTo
(
true
);
example
.
orderBy
(
"add_time desc"
);
...
...
@@ -61,7 +73,9 @@ public class LitemallGrouponService {
* @return
*/
public
LitemallGroupon
queryById
(
Integer
id
)
{
return
mapper
.
selectByPrimaryKey
(
id
);
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andIdEqualTo
(
id
).
andDeletedEqualTo
(
false
).
andPayedEqualTo
(
true
);
return
mapper
.
selectOneByExample
(
example
);
}
/**
...
...
@@ -76,18 +90,6 @@ public class LitemallGrouponService {
return
(
int
)
mapper
.
countByExample
(
example
);
}
/**
* 返回某个团购活动参与人数
*
* @param rulesId
* @return
*/
public
int
countRules
(
Integer
rulesId
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
example
.
or
().
andRulesIdEqualTo
(
rulesId
).
andDeletedEqualTo
(
false
);
return
(
int
)
mapper
.
countByExample
(
example
);
}
public
void
update
(
LitemallGroupon
groupon
)
{
mapper
.
updateByPrimaryKey
(
groupon
);
}
...
...
@@ -102,6 +104,17 @@ public class LitemallGrouponService {
return
mapper
.
insertSelective
(
groupon
);
}
/**
* 查询所有发起的团购记录
*
* @param rulesId
* @param page
* @param size
* @param sort
* @param order
* @return
*/
public
List
<
LitemallGroupon
>
querySelective
(
String
rulesId
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallGrouponExample
example
=
new
LitemallGrouponExample
();
LitemallGrouponExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/HomeCacheManager.java
View file @
cc5a1c17
...
...
@@ -8,6 +8,7 @@ import java.util.Map;
* 简单缓存的数据
*/
public
class
HomeCacheManager
{
public
static
final
boolean
ENABLE
=
true
;
public
static
final
String
INDEX
=
"index"
;
public
static
final
String
CATALOG
=
"catalog"
;
public
static
final
String
GOODS
=
"goods"
;
...
...
@@ -45,6 +46,9 @@ public class HomeCacheManager {
* @return
*/
public
static
boolean
hasData
(
String
cacheKey
)
{
if
(!
ENABLE
)
return
false
;
Map
<
String
,
Object
>
cacheData
=
cacheDataList
.
get
(
cacheKey
);
if
(
cacheData
==
null
)
{
return
false
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java
View file @
cc5a1c17
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -105,7 +106,7 @@ public class WxGrouponController {
linkGrouponId
=
groupon
.
getGrouponId
();
}
List
<
LitemallGroupon
>
groupons
=
grouponService
.
queryJoin
ers
(
linkGrouponId
);
List
<
LitemallGroupon
>
groupons
=
grouponService
.
queryJoin
Record
(
linkGrouponId
);
UserVo
joiner
;
for
(
LitemallGroupon
grouponItem
:
groupons
)
{
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
cc5a1c17
...
...
@@ -282,6 +282,19 @@ public class WxOrderController {
Integer
grouponRulesId
=
JacksonUtil
.
parseInteger
(
body
,
"grouponRulesId"
);
Integer
grouponLinkId
=
JacksonUtil
.
parseInteger
(
body
,
"grouponLinkId"
);
//如果是团购项目,验证活动是否有效
if
(
grouponRulesId
!=
null
&&
grouponRulesId
>
0
)
{
LitemallGrouponRules
rules
=
grouponRulesService
.
queryById
(
grouponRulesId
);
//找不到记录
if
(
rules
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
//团购活动已经过期
if
(
grouponRulesService
.
isExpired
(
rules
))
{
return
ResponseUtil
.
fail
(
402
,
"团购活动已经过期!"
);
}
}
if
(
cartId
==
null
||
addressId
==
null
||
couponId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
...
...
@@ -414,6 +427,7 @@ public class WxOrderController {
//参与者
if
(
grouponLinkId
!=
null
&&
grouponLinkId
>
0
)
{
//参与的团购记录
LitemallGroupon
baseGroupon
=
grouponService
.
queryById
(
grouponLinkId
);
groupon
.
setCreatorUserId
(
baseGroupon
.
getCreatorUserId
());
groupon
.
setGrouponId
(
grouponLinkId
);
...
...
Write
Preview
Supports
Markdown
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