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
baceacea
Commit
baceacea
authored
Mar 07, 2019
by
Junling Bu
Browse files
fix: 小商城的订单列表支持分页
parent
5b04fa44
Changes
4
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
View file @
baceacea
...
...
@@ -69,7 +69,7 @@ public class LitemallOrderService {
return
orderSn
;
}
public
List
<
LitemallOrder
>
queryByOrderStatus
(
Integer
userId
,
List
<
Short
>
orderStatus
)
{
public
List
<
LitemallOrder
>
queryByOrderStatus
(
Integer
userId
,
List
<
Short
>
orderStatus
,
Integer
page
,
Integer
size
)
{
LitemallOrderExample
example
=
new
LitemallOrderExample
();
example
.
setOrderByClause
(
LitemallOrder
.
Column
.
addTime
.
desc
());
LitemallOrderExample
.
Criteria
criteria
=
example
.
or
();
...
...
@@ -78,20 +78,10 @@ public class LitemallOrderService {
criteria
.
andOrderStatusIn
(
orderStatus
);
}
criteria
.
andDeletedEqualTo
(
false
);
PageHelper
.
startPage
(
page
,
size
);
return
litemallOrderMapper
.
selectByExample
(
example
);
}
public
int
countByOrderStatus
(
Integer
userId
,
List
<
Short
>
orderStatus
)
{
LitemallOrderExample
example
=
new
LitemallOrderExample
();
LitemallOrderExample
.
Criteria
criteria
=
example
.
or
();
criteria
.
andUserIdEqualTo
(
userId
);
if
(
orderStatus
!=
null
)
{
criteria
.
andOrderStatusIn
(
orderStatus
);
}
criteria
.
andDeletedEqualTo
(
false
);
return
(
int
)
litemallOrderMapper
.
countByExample
(
example
);
}
public
List
<
LitemallOrder
>
querySelective
(
Integer
userId
,
String
orderSn
,
List
<
Short
>
orderStatusArray
,
Integer
page
,
Integer
size
,
String
sort
,
String
order
)
{
LitemallOrderExample
example
=
new
LitemallOrderExample
();
LitemallOrderExample
.
Criteria
criteria
=
example
.
createCriteria
();
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java
View file @
baceacea
...
...
@@ -7,6 +7,7 @@ import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import
com.github.binarywang.wxpay.bean.result.BaseWxPayResult
;
import
com.github.binarywang.wxpay.exception.WxPayException
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -135,8 +136,9 @@ public class WxOrderService {
}
List
<
Short
>
orderStatus
=
OrderUtil
.
orderStatus
(
showType
);
List
<
LitemallOrder
>
orderList
=
orderService
.
queryByOrderStatus
(
userId
,
orderStatus
);
int
count
=
orderService
.
countByOrderStatus
(
userId
,
orderStatus
);
List
<
LitemallOrder
>
orderList
=
orderService
.
queryByOrderStatus
(
userId
,
orderStatus
,
page
,
size
);
long
count
=
PageInfo
.
of
(
orderList
).
getTotal
();
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
count
/
size
);
List
<
Map
<
String
,
Object
>>
orderVoList
=
new
ArrayList
<>(
orderList
.
size
());
for
(
LitemallOrder
order
:
orderList
)
{
...
...
@@ -172,6 +174,7 @@ public class WxOrderService {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"count"
,
count
);
result
.
put
(
"data"
,
orderVoList
);
result
.
put
(
"totalPages"
,
totalPages
);
return
ResponseUtil
.
ok
(
result
);
}
...
...
litemall-wx/pages/ucenter/order/order.js
View file @
baceacea
...
...
@@ -4,7 +4,10 @@ var api = require('../../../config/api.js');
Page
({
data
:
{
orderList
:
[],
showType
:
0
showType
:
0
,
page
:
1
,
size
:
10
,
totalPages
:
1
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
...
...
@@ -29,20 +32,42 @@ Page({
getOrderList
()
{
let
that
=
this
;
util
.
request
(
api
.
OrderList
,
{
showType
:
that
.
data
.
showType
showType
:
that
.
data
.
showType
,
page
:
that
.
data
.
page
,
size
:
that
.
data
.
size
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
console
.
log
(
res
.
data
);
that
.
setData
({
orderList
:
res
.
data
.
data
orderList
:
that
.
data
.
orderList
.
concat
(
res
.
data
.
data
),
totalPages
:
res
.
data
.
totalPages
});
}
});
},
onReachBottom
()
{
if
(
this
.
data
.
totalPages
>
this
.
data
.
page
)
{
this
.
setData
({
page
:
this
.
data
.
page
+
1
});
this
.
getOrderList
();
}
else
{
wx
.
showToast
({
title
:
'
没有更多订单了
'
,
icon
:
'
none
'
,
duration
:
2000
});
return
false
;
}
},
switchTab
:
function
(
event
)
{
let
showType
=
event
.
currentTarget
.
dataset
.
index
;
this
.
setData
({
showType
:
showType
orderList
:
[],
showType
:
showType
,
page
:
1
,
size
:
10
,
totalPages
:
1
});
this
.
getOrderList
();
},
...
...
renard-wx/pages/ucenter/order/order.js
View file @
baceacea
...
...
@@ -4,7 +4,10 @@ var api = require('../../../config/api.js');
Page
({
data
:
{
orderList
:
[],
showType
:
0
showType
:
0
,
page
:
1
,
size
:
10
,
totalPages
:
1
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
...
...
@@ -28,20 +31,42 @@ Page({
let
that
=
this
;
util
.
request
(
api
.
OrderList
,
{
showType
:
that
.
data
.
showType
showType
:
that
.
data
.
showType
,
page
:
that
.
data
.
page
,
size
:
that
.
data
.
size
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
orderList
:
res
.
data
.
data
orderList
:
that
.
data
.
orderList
.
concat
(
res
.
data
.
data
),
totalPages
:
res
.
data
.
totalPages
});
wx
.
hideLoading
();
}
});
},
onReachBottom
()
{
if
(
this
.
data
.
totalPages
>
this
.
data
.
page
)
{
this
.
setData
({
page
:
this
.
data
.
page
+
1
});
this
.
getOrderList
();
}
else
{
wx
.
showToast
({
title
:
'
没有更多订单了
'
,
icon
:
'
none
'
,
duration
:
2000
});
return
false
;
}
},
switchTab
:
function
(
event
)
{
let
showType
=
event
.
currentTarget
.
dataset
.
index
;
this
.
setData
({
showType
:
showType
orderList
:
[],
showType
:
showType
,
page
:
1
,
size
:
10
,
totalPages
:
1
});
this
.
getOrderList
();
},
...
...
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