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
ca4835b2
Commit
ca4835b2
authored
May 07, 2019
by
Junling Bu
Browse files
chore[litemall-wx, litemall-wx-api]: 团购API调整及文档
parent
18702138
Changes
6
Hide whitespace changes
Inline
Side-by-side
doc/api.md
View file @
ca4835b2
...
...
@@ -623,6 +623,88 @@ API应该存在版本控制,以保证兼容性。
### 2.15 团购服务
注意
> 团购业务还不完善
#### 2.15.1 团购商品列表
应用场景
参加团购的商品列表信息
接口链接
请求参数
响应内容
错误码
略
#### 2.15.2 团购活动详情
应用场景
团购活动详情
接口链接
请求参数
响应内容
错误码
略
#### 2.15.3 参加团购
应用场景
参加团购的商品列表信息
接口链接
请求参数
响应内容
错误码
略
#### 2.15.4 用户参团列表
应用场景
用户参团列表
接口链接
请求参数
响应内容
错误码
略
### 2.16 帮助服务
### 2.17 搜索服务
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponRulesService.java
View file @
ca4835b2
...
...
@@ -57,36 +57,20 @@ public class LitemallGrouponRulesService {
/**
* 获取首页团购活动列表
*
* @param
offset
* @param
page
* @param limit
* @return
*/
public
List
<
Map
<
String
,
Object
>
>
queryList
(
i
nt
offset
,
i
nt
limit
)
{
return
queryList
(
offset
,
limit
,
"add_time"
,
"desc"
);
public
List
<
LitemallGrouponRules
>
queryList
(
I
nt
eger
page
,
I
nt
eger
limit
)
{
return
queryList
(
page
,
limit
,
"add_time"
,
"desc"
);
}
public
List
<
Map
<
String
,
Object
>
>
queryList
(
i
nt
offset
,
i
nt
limit
,
String
sort
,
String
order
)
{
public
List
<
LitemallGrouponRules
>
queryList
(
I
nt
eger
page
,
I
nt
eger
limit
,
String
sort
,
String
order
)
{
LitemallGrouponRulesExample
example
=
new
LitemallGrouponRulesExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
example
.
setOrderByClause
(
sort
+
" "
+
order
);
PageHelper
.
startPage
(
offset
,
limit
);
List
<
LitemallGrouponRules
>
grouponRules
=
mapper
.
selectByExample
(
example
);
List
<
Map
<
String
,
Object
>>
grouponList
=
new
ArrayList
<>(
grouponRules
.
size
());
for
(
LitemallGrouponRules
rule
:
grouponRules
)
{
Integer
goodsId
=
rule
.
getGoodsId
();
LitemallGoods
goods
=
goodsMapper
.
selectByPrimaryKeySelective
(
goodsId
,
goodsColumns
);
if
(
goods
==
null
)
continue
;
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"goods"
,
goods
);
item
.
put
(
"groupon_price"
,
goods
.
getRetailPrice
().
subtract
(
rule
.
getDiscount
()));
item
.
put
(
"groupon_member"
,
rule
.
getDiscountMember
());
grouponList
.
add
(
item
);
}
return
grouponList
;
PageHelper
.
startPage
(
page
,
limit
);
return
mapper
.
selectByExample
(
example
);
}
/**
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxGrouponRuleService.java
0 → 100644
View file @
ca4835b2
package
org.linlinjava.litemall.wx.service
;
import
com.github.pagehelper.Page
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.domain.LitemallGrouponRules
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallGrouponRulesService
;
import
org.linlinjava.litemall.db.service.LitemallGrouponService
;
import
org.linlinjava.litemall.wx.vo.GrouponRuleVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
WxGrouponRuleService
{
private
final
Log
logger
=
LogFactory
.
getLog
(
WxGrouponRuleService
.
class
);
@Autowired
private
LitemallGrouponRulesService
grouponRulesService
;
@Autowired
private
LitemallGrouponService
grouponService
;
@Autowired
private
LitemallGoodsService
goodsService
;
public
List
<
GrouponRuleVo
>
queryList
(
Integer
page
,
Integer
size
)
{
return
queryList
(
page
,
size
,
"add_time"
,
"desc"
);
}
public
List
<
GrouponRuleVo
>
queryList
(
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
Page
<
LitemallGrouponRules
>
grouponRulesList
=
(
Page
)
grouponRulesService
.
queryList
(
page
,
size
,
sort
,
order
);
Page
<
GrouponRuleVo
>
grouponList
=
new
Page
<
GrouponRuleVo
>();
grouponList
.
setPages
(
grouponRulesList
.
getPages
());
grouponList
.
setPageNum
(
grouponRulesList
.
getPageNum
());
grouponList
.
setPageSize
(
grouponRulesList
.
getPageSize
());
grouponList
.
setTotal
(
grouponRulesList
.
getTotal
());
for
(
LitemallGrouponRules
rule
:
grouponRulesList
)
{
Integer
goodsId
=
rule
.
getGoodsId
();
LitemallGoods
goods
=
goodsService
.
findById
(
goodsId
);
if
(
goods
==
null
)
continue
;
GrouponRuleVo
grouponRuleVo
=
new
GrouponRuleVo
();
grouponRuleVo
.
setId
(
goods
.
getId
());
grouponRuleVo
.
setName
(
goods
.
getName
());
grouponRuleVo
.
setBrief
(
goods
.
getBrief
());
grouponRuleVo
.
setPicUrl
(
goods
.
getPicUrl
());
grouponRuleVo
.
setCounterPrice
(
goods
.
getCounterPrice
());
grouponRuleVo
.
setRetailPrice
(
goods
.
getRetailPrice
());
grouponRuleVo
.
setGrouponPrice
(
goods
.
getRetailPrice
().
subtract
(
rule
.
getDiscount
()));
grouponRuleVo
.
setGrouponDiscount
(
rule
.
getDiscount
());
grouponRuleVo
.
setGrouponMember
(
rule
.
getDiscountMember
());
grouponList
.
add
(
grouponRuleVo
);
}
return
grouponList
;
}
}
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/vo/GrouponRuleVo.java
0 → 100644
View file @
ca4835b2
package
org.linlinjava.litemall.wx.vo
;
import
java.math.BigDecimal
;
public
class
GrouponRuleVo
{
private
Integer
id
;
private
String
name
;
private
String
brief
;
private
String
picUrl
;
private
BigDecimal
counterPrice
;
private
BigDecimal
retailPrice
;
private
BigDecimal
grouponPrice
;
private
BigDecimal
grouponDiscount
;
private
Integer
grouponMember
;
public
BigDecimal
getGrouponDiscount
()
{
return
grouponDiscount
;
}
public
void
setGrouponDiscount
(
BigDecimal
grouponDiscount
)
{
this
.
grouponDiscount
=
grouponDiscount
;
}
public
Integer
getGrouponMember
()
{
return
grouponMember
;
}
public
void
setGrouponMember
(
Integer
grouponMember
)
{
this
.
grouponMember
=
grouponMember
;
}
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getBrief
()
{
return
brief
;
}
public
void
setBrief
(
String
brief
)
{
this
.
brief
=
brief
;
}
public
String
getPicUrl
()
{
return
picUrl
;
}
public
void
setPicUrl
(
String
picUrl
)
{
this
.
picUrl
=
picUrl
;
}
public
BigDecimal
getCounterPrice
()
{
return
counterPrice
;
}
public
void
setCounterPrice
(
BigDecimal
counterPrice
)
{
this
.
counterPrice
=
counterPrice
;
}
public
BigDecimal
getRetailPrice
()
{
return
retailPrice
;
}
public
void
setRetailPrice
(
BigDecimal
retailPrice
)
{
this
.
retailPrice
=
retailPrice
;
}
public
BigDecimal
getGrouponPrice
()
{
return
grouponPrice
;
}
public
void
setGrouponPrice
(
BigDecimal
grouponPrice
)
{
this
.
grouponPrice
=
grouponPrice
;
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java
View file @
ca4835b2
package
org.linlinjava.litemall.wx.web
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.express.ExpressService
;
...
...
@@ -12,6 +11,8 @@ import org.linlinjava.litemall.db.domain.*;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.util.OrderUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.wx.service.WxGrouponRuleService
;
import
org.linlinjava.litemall.wx.vo.GrouponRuleVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -41,6 +42,8 @@ public class WxGrouponController {
@Autowired
private
LitemallGrouponRulesService
rulesService
;
@Autowired
private
WxGrouponRuleService
wxGrouponRuleService
;
@Autowired
private
LitemallGrouponService
grouponService
;
@Autowired
private
LitemallGoodsService
goodsService
;
...
...
@@ -67,12 +70,8 @@ public class WxGrouponController {
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
List
<
Map
<
String
,
Object
>>
topicList
=
grouponRulesService
.
queryList
(
page
,
limit
,
sort
,
order
);
long
total
=
PageInfo
.
of
(
topicList
).
getTotal
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
data
.
put
(
"data"
,
topicList
);
data
.
put
(
"count"
,
total
);
return
ResponseUtil
.
ok
(
data
);
List
<
GrouponRuleVo
>
grouponRuleVoList
=
wxGrouponRuleService
.
queryList
(
page
,
limit
,
sort
,
order
);
return
ResponseUtil
.
okList
(
grouponRuleVoList
);
}
/**
...
...
@@ -281,21 +280,4 @@ public class WxGrouponController {
return
ResponseUtil
.
ok
(
result
);
}
/**
* 商品所对应的团购规则
*
* @param goodsId 商品ID
* @return 团购规则详情
*/
@GetMapping
(
"query"
)
public
Object
query
(
@NotNull
Integer
goodsId
)
{
LitemallGoods
goods
=
goodsService
.
findById
(
goodsId
);
if
(
goods
==
null
)
{
return
ResponseUtil
.
fail
(
GOODS_UNKNOWN
,
"未找到对应的商品"
);
}
List
<
LitemallGrouponRules
>
rules
=
rulesService
.
queryByGoodsId
(
goodsId
);
return
ResponseUtil
.
ok
(
rules
);
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java
View file @
ca4835b2
...
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.db.domain.LitemallGoods;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.wx.service.HomeCacheManager
;
import
org.linlinjava.litemall.wx.service.WxGrouponRuleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -47,7 +48,7 @@ public class WxHomeController {
private
LitemallCategoryService
categoryService
;
@Autowired
private
Litemall
GrouponRule
s
Service
groupon
Rules
Service
;
private
Wx
GrouponRuleService
grouponService
;
@Autowired
private
LitemallCouponService
couponService
;
...
...
@@ -82,8 +83,6 @@ public class WxHomeController {
}
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
10
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
Callable
<
List
>
bannerListCallable
=
()
->
adService
.
queryIndex
();
Callable
<
List
>
channelListCallable
=
()
->
categoryService
.
queryChannel
();
...
...
@@ -100,12 +99,12 @@ public class WxHomeController {
Callable
<
List
>
hotGoodsListCallable
=
()
->
goodsService
.
queryByHot
(
0
,
SystemConfig
.
getHotLimit
());
Callable
<
List
>
brandListCallable
=
()
->
brandService
.
query
VO
(
0
,
SystemConfig
.
getBrandLimit
());
Callable
<
List
>
brandListCallable
=
()
->
brandService
.
query
(
0
,
SystemConfig
.
getBrandLimit
());
Callable
<
List
>
topicListCallable
=
()
->
topicService
.
queryList
(
0
,
SystemConfig
.
getTopicLimit
());
//团购专区
Callable
<
List
>
grouponListCallable
=
()
->
groupon
Rules
Service
.
queryList
(
0
,
5
);
Callable
<
List
>
grouponListCallable
=
()
->
grouponService
.
queryList
(
0
,
5
);
Callable
<
List
>
floorGoodsListCallable
=
this
::
getCategoryList
;
...
...
@@ -129,25 +128,26 @@ public class WxHomeController {
executorService
.
submit
(
grouponListTask
);
executorService
.
submit
(
floorGoodsListTask
);
Map
<
String
,
Object
>
entity
=
new
HashMap
<>();
try
{
data
.
put
(
"banner"
,
bannerTask
.
get
());
data
.
put
(
"channel"
,
channelTask
.
get
());
data
.
put
(
"couponList"
,
couponListTask
.
get
());
data
.
put
(
"newGoodsList"
,
newGoodsListTask
.
get
());
data
.
put
(
"hotGoodsList"
,
hotGoodsListTask
.
get
());
data
.
put
(
"brandList"
,
brandListTask
.
get
());
data
.
put
(
"topicList"
,
topicListTask
.
get
());
data
.
put
(
"grouponList"
,
grouponListTask
.
get
());
data
.
put
(
"floorGoodsList"
,
floorGoodsListTask
.
get
());
entity
.
put
(
"banner"
,
bannerTask
.
get
());
entity
.
put
(
"channel"
,
channelTask
.
get
());
entity
.
put
(
"couponList"
,
couponListTask
.
get
());
entity
.
put
(
"newGoodsList"
,
newGoodsListTask
.
get
());
entity
.
put
(
"hotGoodsList"
,
hotGoodsListTask
.
get
());
entity
.
put
(
"brandList"
,
brandListTask
.
get
());
entity
.
put
(
"topicList"
,
topicListTask
.
get
());
entity
.
put
(
"grouponList"
,
grouponListTask
.
get
());
entity
.
put
(
"floorGoodsList"
,
floorGoodsListTask
.
get
());
//缓存数据
HomeCacheManager
.
loadData
(
HomeCacheManager
.
INDEX
,
data
);
HomeCacheManager
.
loadData
(
HomeCacheManager
.
INDEX
,
entity
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
executorService
.
shutdown
();
}
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
entity
);
}
private
List
<
Map
>
getCategoryList
()
{
...
...
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