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
b68151cb
Unverified
Commit
b68151cb
authored
Jul 13, 2018
by
Menethil
Committed by
GitHub
Jul 13, 2018
Browse files
Merge pull request #1 from linlinjava/master
update
parents
126d027a
02679509
Changes
251
Show whitespace changes
Inline
Side-by-side
litemall-os-api/src/main/resources/application-prod.properties
View file @
b68151cb
...
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
@@ -26,6 +26,7 @@ logging.level.org.mybatis=ERROR
logging.level.org.linlinjava.litemall.db
=
ERROR
logging.level.org.linlinjava.litemall
=
DEBUG
# 开发者应该设置成自己的域名
org.linlinjava.litemall.os.address
=
www.example.com
org.linlinjava.litemall.os.port
=
80
\ No newline at end of file
# 开发者应该设置成自己的域名,必须附带http或者https
# 开发者可以查看OsStorageController.generateUrl
org.linlinjava.litemall.os.address
=
https://www.example.com
org.linlinjava.litemall.os.port
=
443
\ No newline at end of file
litemall-wx-api/pom.xml
View file @
b68151cb
...
...
@@ -10,6 +10,10 @@
<version>
0.1.0
</version>
</parent>
<properties>
<docker.image.prefix>
litemall
</docker.image.prefix>
</properties>
<dependencies>
<dependency>
...
...
@@ -35,6 +39,22 @@
</dependencies>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/java
</directory>
<includes>
<include>
**/*.properties
</include>
<include>
**/*.xml
</include>
</includes>
<filtering>
false
</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -53,6 +73,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>
com.spotify
</groupId>
<artifactId>
docker-maven-plugin
</artifactId>
<version>
0.4.13
</version>
<configuration>
<imageName>
${docker.image.prefix}/${project.artifactId}
</imageName>
<dockerDirectory>
src/main/docker
</dockerDirectory>
<resources>
<resource>
<targetPath>
/
</targetPath>
<directory>
${project.build.directory}
</directory>
<include>
${project.build.finalName}.jar
</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
...
...
litemall-wx-api/src/main/docker/Dockerfile
0 → 100644
View file @
b68151cb
FROM
java
MAINTAINER
tiger <tiger@microsoul.com>
ADD
/litemall-wx-api-0.1.0.jar //
ENTRYPOINT
java -jar /litemall-wx-api-0.1.0.jar
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java
View file @
b68151cb
...
...
@@ -69,7 +69,7 @@ public class WxAuthController {
List
<
LitemallUser
>
userList
=
userService
.
queryByUsername
(
username
);
LitemallUser
user
=
null
;
if
(
userList
.
size
()
>
1
){
return
ResponseUtil
.
fail502
();
return
ResponseUtil
.
serious
();
}
else
if
(
userList
.
size
()
==
0
){
return
ResponseUtil
.
badArgumentValue
();
...
...
@@ -147,11 +147,13 @@ public class WxAuthController {
user
.
setWeixinOpenid
(
openId
);
user
.
setAvatar
(
userInfo
.
getAvatarUrl
());
user
.
setNickname
(
userInfo
.
getNickName
());
user
.
setGender
(
userInfo
.
getGender
()
==
1
?
"男"
:
"女"
);
user
.
setUserLevel
(
"普通用户"
);
user
.
setStatus
(
"可用"
);
user
.
setGender
(
userInfo
.
getGender
());
user
.
setUserLevel
(
(
byte
)
0
);
user
.
setStatus
(
(
byte
)
0
);
user
.
setLastLoginTime
(
LocalDateTime
.
now
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
}
else
{
...
...
@@ -232,11 +234,12 @@ public class WxAuthController {
user
.
setWeixinOpenid
(
""
);
user
.
setAvatar
(
"https://yanxuan.nosdn.127.net/80841d741d7fa3073e0ae27bf487339f.jpg?imageView&quality=90&thumbnail=64x64"
);
user
.
setNickname
(
username
);
user
.
setGender
(
"未知"
);
user
.
setUserLevel
(
"普通用户"
);
user
.
setStatus
(
"可用"
);
user
.
setGender
(
(
byte
)
0
);
user
.
setUserLevel
(
(
byte
)
0
);
user
.
setStatus
(
(
byte
)
0
);
user
.
setLastLoginTime
(
LocalDateTime
.
now
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java
View file @
b68151cb
...
...
@@ -32,8 +32,6 @@ public class WxCartController {
private
LitemallGoodsSpecificationService
goodsSpecificationService
;
@Autowired
private
LitemallAddressService
addressService
;
@Autowired
private
LitemallCouponService
apiCouponService
;
/**
* 购物车
...
...
@@ -65,10 +63,10 @@ public class WxCartController {
BigDecimal
checkedGoodsAmount
=
new
BigDecimal
(
0.00
);
for
(
LitemallCart
cart
:
cartList
)
{
goodsCount
+=
cart
.
getNumber
();
goodsAmount
=
goodsAmount
.
add
(
cart
.
get
Retail
Price
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
goodsAmount
=
goodsAmount
.
add
(
cart
.
getPrice
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
if
(
cart
.
getChecked
())
{
checkedGoodsCount
+=
cart
.
getNumber
();
checkedGoodsAmount
=
checkedGoodsAmount
.
add
(
cart
.
get
Retail
Price
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
checkedGoodsAmount
=
checkedGoodsAmount
.
add
(
cart
.
getPrice
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
}
}
Map
<
String
,
Object
>
cartTotal
=
new
HashMap
<>();
...
...
@@ -127,32 +125,16 @@ public class WxCartController {
LitemallCart
existCart
=
cartService
.
queryExist
(
goodsId
,
productId
,
userId
);
if
(
existCart
==
null
){
//取得规格的信息,判断规格库存
if
(
product
==
null
||
number
>
product
.
get
Goods
Number
()
){
if
(
product
==
null
||
number
>
product
.
getNumber
()
){
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
Integer
[]
ids
=
product
.
getGoodsSpecificationIds
();
String
goodsSpecificationValue
=
null
;
for
(
Integer
id
:
ids
){
LitemallGoodsSpecification
goodsSpecification
=
goodsSpecificationService
.
findById
(
id
);
if
(
goodsSpecification
==
null
||
!
goodsSpecification
.
getGoodsId
().
equals
(
goodsId
)){
return
ResponseUtil
.
badArgument
();
}
if
(
goodsSpecificationValue
==
null
){
goodsSpecificationValue
=
goodsSpecification
.
getValue
();
}
else
{
goodsSpecificationValue
=
goodsSpecificationValue
+
" "
+
goodsSpecification
.
getValue
();
}
}
cart
.
setId
(
null
);
cart
.
setGoodsSn
(
goods
.
getGoodsSn
());
cart
.
setGoodsName
((
goods
.
getName
()));
cart
.
setPicUrl
(
goods
.
getPrimaryPicUrl
());
cart
.
setRetailPrice
(
product
.
getRetailPrice
());
cart
.
setGoodsSpecificationIds
(
product
.
getGoodsSpecificationIds
());
cart
.
setGoodsSpecificationValues
(
goodsSpecificationValue
);
cart
.
setPicUrl
(
goods
.
getPicUrl
());
cart
.
setPrice
(
product
.
getPrice
());
cart
.
setSpecifications
(
product
.
getSpecifications
());
cart
.
setUserId
(
userId
);
cart
.
setChecked
(
true
);
cartService
.
add
(
cart
);
...
...
@@ -160,7 +142,7 @@ public class WxCartController {
else
{
//取得规格的信息,判断规格库存
int
num
=
existCart
.
getNumber
()
+
number
;
if
(
num
>
product
.
get
Goods
Number
()){
if
(
num
>
product
.
getNumber
()){
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
existCart
.
setNumber
((
short
)
num
);
...
...
@@ -215,32 +197,16 @@ public class WxCartController {
LitemallCart
existCart
=
cartService
.
queryExist
(
goodsId
,
productId
,
userId
);
if
(
existCart
==
null
){
//取得规格的信息,判断规格库存
if
(
product
==
null
||
number
>
product
.
get
Goods
Number
()
){
if
(
product
==
null
||
number
>
product
.
getNumber
()
){
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
Integer
[]
ids
=
product
.
getGoodsSpecificationIds
();
String
goodsSpecificationValue
=
null
;
for
(
Integer
id
:
ids
){
LitemallGoodsSpecification
goodsSpecification
=
goodsSpecificationService
.
findById
(
id
);
if
(
goodsSpecification
==
null
||
!
goodsSpecification
.
getGoodsId
().
equals
(
goodsId
)){
return
ResponseUtil
.
badArgument
();
}
if
(
goodsSpecificationValue
==
null
){
goodsSpecificationValue
=
goodsSpecification
.
getValue
();
}
else
{
goodsSpecificationValue
=
goodsSpecificationValue
+
" "
+
goodsSpecification
.
getValue
();
}
}
cart
.
setId
(
null
);
cart
.
setGoodsSn
(
goods
.
getGoodsSn
());
cart
.
setGoodsName
((
goods
.
getName
()));
cart
.
setPicUrl
(
goods
.
getPrimaryPicUrl
());
cart
.
setRetailPrice
(
product
.
getRetailPrice
());
cart
.
setGoodsSpecificationIds
(
product
.
getGoodsSpecificationIds
());
cart
.
setGoodsSpecificationValues
(
goodsSpecificationValue
);
cart
.
setPicUrl
(
goods
.
getPicUrl
());
cart
.
setPrice
(
product
.
getPrice
());
cart
.
setSpecifications
(
product
.
getSpecifications
());
cart
.
setUserId
(
userId
);
cart
.
setChecked
(
true
);
cartService
.
add
(
cart
);
...
...
@@ -248,7 +214,7 @@ public class WxCartController {
else
{
//取得规格的信息,判断规格库存
int
num
=
number
;
if
(
num
>
product
.
get
Goods
Number
()){
if
(
num
>
product
.
getNumber
()){
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
existCart
.
setNumber
((
short
)
num
);
...
...
@@ -307,7 +273,7 @@ public class WxCartController {
//取得规格的信息,判断规格库存
LitemallProduct
product
=
productService
.
findById
(
productId
);
if
(
product
==
null
||
product
.
get
Goods
Number
()
<
number
){
if
(
product
==
null
||
product
.
getNumber
()
<
number
){
return
ResponseUtil
.
fail
(
403
,
"库存不足"
);
}
...
...
@@ -498,7 +464,7 @@ public class WxCartController {
}
BigDecimal
checkedGoodsPrice
=
new
BigDecimal
(
0.00
);
for
(
LitemallCart
cart
:
checkedGoodsList
)
{
checkedGoodsPrice
=
checkedGoodsPrice
.
add
(
cart
.
get
Retail
Price
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
checkedGoodsPrice
=
checkedGoodsPrice
.
add
(
cart
.
getPrice
().
multiply
(
new
BigDecimal
(
cart
.
getNumber
())));
}
// 根据订单商品总价计算运费,满88则免运费,否则8元;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCollectController.java
View file @
b68151cb
...
...
@@ -29,7 +29,7 @@ public class WxCollectController {
* 用户收藏列表
*
* @param userId 用户ID
* @param type
Id
类型
ID
* @param type 类型
,如果是0则是商品收藏,如果是1则是专题收藏
* 目前没有使用
* @param page 分页页数
* @param size 分页大小
...
...
@@ -47,31 +47,31 @@ public class WxCollectController {
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@LoginUser
Integer
userId
,
Integer
type
Id
,
public
Object
list
(
@LoginUser
Integer
userId
,
Byte
type
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
Integer
size
)
{
if
(
userId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
type
Id
==
null
){
if
(
type
==
null
){
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallCollect
>
collectList
=
collectService
.
queryByType
(
userId
,
type
Id
,
page
,
size
);
int
count
=
collectService
.
countByType
(
userId
,
type
Id
);
List
<
LitemallCollect
>
collectList
=
collectService
.
queryByType
(
userId
,
type
,
page
,
size
);
int
count
=
collectService
.
countByType
(
userId
,
type
);
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
count
/
size
);
List
<
Object
>
collects
=
new
ArrayList
<>(
collectList
.
size
());
for
(
LitemallCollect
collect
:
collectList
){
Map
<
String
,
Object
>
c
=
new
HashMap
();
c
.
put
(
"id"
,
collect
.
getId
());
c
.
put
(
"type
Id
"
,
collect
.
getType
Id
());
c
.
put
(
"type"
,
collect
.
getType
());
c
.
put
(
"valueId"
,
collect
.
getValueId
());
LitemallGoods
goods
=
goodsService
.
findById
(
collect
.
getValueId
());
c
.
put
(
"name"
,
goods
.
getName
());
c
.
put
(
"
goodsB
rief"
,
goods
.
get
Goods
Brief
());
c
.
put
(
"
listP
icUrl"
,
goods
.
get
List
PicUrl
());
c
.
put
(
"
b
rief"
,
goods
.
getBrief
());
c
.
put
(
"
p
icUrl"
,
goods
.
getPicUrl
());
c
.
put
(
"retailPrice"
,
goods
.
getRetailPrice
());
collects
.
add
(
c
);
...
...
@@ -109,13 +109,13 @@ public class WxCollectController {
return
ResponseUtil
.
badArgument
();
}
Integer
type
Id
=
JacksonUtil
.
parse
Integer
(
body
,
"type
Id
"
);
Byte
type
=
JacksonUtil
.
parse
Byte
(
body
,
"type"
);
Integer
valueId
=
JacksonUtil
.
parseInteger
(
body
,
"valueId"
);
if
(!
ObjectUtils
.
allNotNull
(
type
Id
,
valueId
)){
if
(!
ObjectUtils
.
allNotNull
(
type
,
valueId
)){
return
ResponseUtil
.
badArgument
();
}
LitemallCollect
collect
=
collectService
.
queryByTypeAndValue
(
userId
,
type
Id
,
valueId
);
LitemallCollect
collect
=
collectService
.
queryByTypeAndValue
(
userId
,
type
,
valueId
);
String
handleType
=
null
;
if
(
collect
!=
null
){
...
...
@@ -127,7 +127,7 @@ public class WxCollectController {
collect
=
new
LitemallCollect
();
collect
.
setUserId
(
userId
);
collect
.
setValueId
(
valueId
);
collect
.
setType
Id
(
type
Id
);
collect
.
setType
(
type
);
collect
.
setAddTime
(
LocalDateTime
.
now
());
collectService
.
add
(
collect
);
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java
View file @
b68151cb
...
...
@@ -3,7 +3,6 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.linlinjava.litemall.db.domain.LitemallComment
;
import
org.linlinjava.litemall.db.service.LitemallCommentService
;
import
org.linlinjava.litemall.db.service.LitemallCouponService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
...
...
@@ -26,8 +25,6 @@ public class WxCommentController {
@Autowired
private
LitemallUserService
userService
;
@Autowired
private
LitemallCouponService
couponService
;
@Autowired
private
UserInfoService
userInfoService
;
/**
...
...
@@ -66,8 +63,8 @@ public class WxCommentController {
/**
* 评论数量
*
* @param type
Id
类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type
Id
是0,则是商品ID;如果type
Id
是1,则是专题ID。
* @param type 类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @return 评论数量
* 成功则
* {
...
...
@@ -82,9 +79,9 @@ public class WxCommentController {
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"count"
)
public
Object
count
(
Byte
type
Id
,
Integer
valueId
)
{
int
allCount
=
commentService
.
count
(
type
Id
,
valueId
,
0
,
0
,
0
);
int
hasPicCount
=
commentService
.
count
(
type
Id
,
valueId
,
1
,
0
,
0
);
public
Object
count
(
Byte
type
,
Integer
valueId
)
{
int
allCount
=
commentService
.
count
(
type
,
valueId
,
0
,
0
,
0
);
int
hasPicCount
=
commentService
.
count
(
type
,
valueId
,
1
,
0
,
0
);
Map
<
String
,
Object
>
data
=
new
HashMap
();
data
.
put
(
"allCount"
,
allCount
);
data
.
put
(
"hasPicCount"
,
hasPicCount
);
...
...
@@ -94,8 +91,8 @@ public class WxCommentController {
/**
* 评论列表
*
* @param type
Id
类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type
Id
是0,则是商品ID;如果type
Id
是1,则是专题ID。
* @param type 类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @param showType 显示类型。如果是0,则查询全部;如果是1,则查询有图片的评论。
* @param page 分页页数
* @param size 分页大小
...
...
@@ -114,15 +111,15 @@ public class WxCommentController {
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
Byte
type
Id
,
Integer
valueId
,
Integer
showType
,
public
Object
list
(
Byte
type
,
Integer
valueId
,
Integer
showType
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
Integer
size
)
{
if
(!
ObjectUtils
.
allNotNull
(
type
Id
,
valueId
,
showType
)){
if
(!
ObjectUtils
.
allNotNull
(
type
,
valueId
,
showType
)){
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallComment
>
commentList
=
commentService
.
query
(
type
Id
,
valueId
,
showType
,
page
,
size
);
int
count
=
commentService
.
count
(
type
Id
,
valueId
,
showType
,
page
,
size
);
List
<
LitemallComment
>
commentList
=
commentService
.
query
(
type
,
valueId
,
showType
,
page
,
size
);
int
count
=
commentService
.
count
(
type
,
valueId
,
showType
,
page
,
size
);
List
<
Map
<
String
,
Object
>>
commentVoList
=
new
ArrayList
<>(
commentList
.
size
());
for
(
LitemallComment
comment
:
commentList
){
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java
View file @
b68151cb
...
...
@@ -97,8 +97,8 @@ public class WxFootprintController {
LitemallGoods
goods
=
goodsService
.
findById
(
footprint
.
getGoodsId
());
c
.
put
(
"name"
,
goods
.
getName
());
c
.
put
(
"
goodsB
rief"
,
goods
.
get
Goods
Brief
());
c
.
put
(
"
listP
icUrl"
,
goods
.
get
List
PicUrl
());
c
.
put
(
"
b
rief"
,
goods
.
getBrief
());
c
.
put
(
"
p
icUrl"
,
goods
.
getPicUrl
());
c
.
put
(
"retailPrice"
,
goods
.
getRetailPrice
());
footprintVoList
.
add
(
c
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java
View file @
b68151cb
...
...
@@ -5,7 +5,6 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.db.util.SortUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -48,8 +47,6 @@ public class WxGoodsController {
@Autowired
private
LitemallSearchHistoryService
searchHistoryService
;
@Autowired
private
LitemallCouponService
apiCouponService
;
@Autowired
private
LitemallCartService
cartService
;
@Autowired
private
LitemallGoodsSpecificationService
goodsSpecificationService
;
...
...
@@ -182,14 +179,14 @@ public class WxGoodsController {
LitemallCategory
parent
=
null
;
List
<
LitemallCategory
>
children
=
null
;
if
(
cur
.
getP
arentI
d
()
==
0
){
if
(
cur
.
getP
i
d
()
==
0
){
parent
=
cur
;
children
=
categoryService
.
queryByPid
(
cur
.
getId
());
cur
=
children
.
get
(
0
);
}
else
{
parent
=
categoryService
.
findById
(
cur
.
getP
arentI
d
());
children
=
categoryService
.
queryByPid
(
cur
.
getP
arentI
d
());
parent
=
categoryService
.
findById
(
cur
.
getP
i
d
());
children
=
categoryService
.
queryByPid
(
cur
.
getP
i
d
());
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"currentCategory"
,
cur
);
...
...
@@ -229,14 +226,12 @@ public class WxGoodsController {
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
Integer
categoryId
,
Integer
brandId
,
String
keyword
,
Integer
isNew
,
Integer
isHot
,
public
Object
list
(
Integer
categoryId
,
Integer
brandId
,
String
keyword
,
Boolean
isNew
,
Boolean
isHot
,
@LoginUser
Integer
userId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
Integer
size
,
String
sort
,
String
order
)
{
String
sortWithOrder
=
SortUtil
.
goodsSort
(
sort
,
order
);
//添加到搜索历史
if
(
userId
!=
null
&&
!
StringUtils
.
isNullOrEmpty
(
keyword
))
{
LitemallSearchHistory
searchHistoryVo
=
new
LitemallSearchHistory
();
...
...
@@ -248,8 +243,8 @@ public class WxGoodsController {
}
//查询列表数据
List
<
LitemallGoods
>
goodsList
=
goodsService
.
querySelective
(
categoryId
,
brandId
,
keyword
,
isHot
,
isNew
,
page
,
size
,
sort
WithO
rder
);
int
total
=
goodsService
.
countSelective
(
categoryId
,
brandId
,
keyword
,
isHot
,
isNew
,
page
,
size
,
sort
WithO
rder
);
List
<
LitemallGoods
>
goodsList
=
goodsService
.
querySelective
(
categoryId
,
brandId
,
keyword
,
isHot
,
isNew
,
page
,
size
,
sort
,
o
rder
);
int
total
=
goodsService
.
countSelective
(
categoryId
,
brandId
,
keyword
,
isHot
,
isNew
,
page
,
size
,
sort
,
o
rder
);
// 查询商品所属类目列表。
List
<
Integer
>
goodsCatIds
=
goodsService
.
getCatIds
(
brandId
,
keyword
,
isHot
,
isNew
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxHomeController.java
View file @
b68151cb
...
...
@@ -57,7 +57,7 @@ public class WxHomeController {
public
Object
index
()
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
List
<
LitemallAd
>
banner
=
adService
.
query
ByApid
(
1
);
List
<
LitemallAd
>
banner
=
adService
.
query
Index
(
);
data
.
put
(
"banner"
,
banner
);
List
<
LitemallCategory
>
channel
=
categoryService
.
queryChannel
();
...
...
@@ -84,7 +84,14 @@ public class WxHomeController {
l2List
.
add
(
catL2
.
getId
());
}
List
<
LitemallGoods
>
categoryGoods
=
goodsService
.
queryByCategory
(
l2List
,
0
,
5
);
List
<
LitemallGoods
>
categoryGoods
=
null
;
if
(
l2List
.
size
()
==
0
){
categoryGoods
=
new
ArrayList
<>();
}
else
{
categoryGoods
=
goodsService
.
queryByCategory
(
l2List
,
0
,
5
);
}
Map
catGoods
=
new
HashMap
();
catGoods
.
put
(
"id"
,
catL1
.
getId
());
catGoods
.
put
(
"name"
,
catL1
.
getName
());
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
b68151cb
...
...
@@ -125,7 +125,7 @@ public class WxOrderController {
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
Integer
size
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
fail401
();
return
ResponseUtil
.
unlogin
();
}
if
(
showType
==
null
)
{
showType
=
0
;
...
...
@@ -186,10 +186,10 @@ public class WxOrderController {
@GetMapping
(
"detail"
)
public
Object
detail
(
@LoginUser
Integer
userId
,
Integer
orderId
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
fail401
();
return
ResponseUtil
.
unlogin
();
}
if
(
orderId
==
null
)
{
return
ResponseUtil
.
fail402
();
return
ResponseUtil
.
badArgument
();
}
// 订单信息
...
...
@@ -222,9 +222,9 @@ public class WxOrderController {
orderGoodsVo
.
put
(
"goodsId"
,
orderGoods
.
getGoodsId
());
orderGoodsVo
.
put
(
"goodsName"
,
orderGoods
.
getGoodsName
());
orderGoodsVo
.
put
(
"number"
,
orderGoods
.
getNumber
());
orderGoodsVo
.
put
(
"retailPrice"
,
orderGoods
.
get
Retail
Price
());
orderGoodsVo
.
put
(
"retailPrice"
,
orderGoods
.
getPrice
());
orderGoodsVo
.
put
(
"picUrl"
,
orderGoods
.
getPicUrl
());
orderGoodsVo
.
put
(
"goodsSpecificationValues"
,
orderGoods
.
get
Goods
Specification
Value
s
());
orderGoodsVo
.
put
(
"goodsSpecificationValues"
,
orderGoods
.
getSpecifications
());
orderGoodsVoList
.
add
(
orderGoodsVo
);
}
...
...
@@ -284,7 +284,7 @@ public class WxOrderController {
}
BigDecimal
checkedGoodsPrice
=
new
BigDecimal
(
0.00
);
for
(
LitemallCart
checkGoods
:
checkedGoodsList
)
{
checkedGoodsPrice
=
checkedGoodsPrice
.
add
(
checkGoods
.
get
Retail
Price
().
multiply
(
new
BigDecimal
(
checkGoods
.
getNumber
())));
checkedGoodsPrice
=
checkedGoodsPrice
.
add
(
checkGoods
.
getPrice
().
multiply
(
new
BigDecimal
(
checkGoods
.
getNumber
())));
}
// 根据订单商品总价计算运费,满88则免运费,否则8元;
...
...
@@ -337,10 +337,10 @@ public class WxOrderController {
orderGoods
.
setProductId
(
cartGoods
.
getProductId
());
orderGoods
.
setGoodsName
(
cartGoods
.
getGoodsName
());
orderGoods
.
setPicUrl
(
cartGoods
.
getPicUrl
());
orderGoods
.
set
Retail
Price
(
cartGoods
.
get
Retail
Price
());
orderGoods
.
setPrice
(
cartGoods
.
getPrice
());
orderGoods
.
setNumber
(
cartGoods
.
getNumber
());
orderGoods
.
set
Goods
Specification
Id
s
(
cartGoods
.
get
Goods
Specification
Id
s
());
orderGoods
.
set
GoodsSpecificationValues
(
cartGoods
.
getGoodsSpecificationValues
());
orderGoods
.
setSpecifications
(
cartGoods
.
getSpecifications
());
orderGoods
.
set
AddTime
(
LocalDateTime
.
now
());
// 添加订单商品表项
orderGoodsService
.
add
(
orderGoods
);
...
...
@@ -354,11 +354,11 @@ public class WxOrderController {
Integer
productId
=
checkGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
Integer
remainNumber
=
product
.
get
Goods
Number
()
-
checkGoods
.
getNumber
();
Integer
remainNumber
=
product
.
getNumber
()
-
checkGoods
.
getNumber
();
if
(
remainNumber
<
0
)
{
throw
new
RuntimeException
(
"下单的商品货品数量大于库存量"
);
}
product
.
set
Goods
Number
(
remainNumber
);
product
.
setNumber
(
remainNumber
);
productService
.
updateById
(
product
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -424,8 +424,8 @@ public class WxOrderController {
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Integer
productId
=
orderGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
Integer
number
=
product
.
get
Goods
Number
()
+
orderGoods
.
getNumber
();
product
.
set
Goods
Number
(
number
);
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
setNumber
(
number
);
productService
.
updateById
(
product
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -488,9 +488,12 @@ public class WxOrderController {
// TODO 更有意义的显示名称
orderRequest
.
setBody
(
"litemall小商场-订单测试支付"
);
// 元转成分
// 这里仅支付1分
// TODO 这里1分钱需要改成实际订单金额
orderRequest
.
setTotalFee
(
1
);
Integer
fee
=
1
;
// 这里演示仅支付1分
// 实际项目取消下面两行注释
// BigDecimal actualPrice = order.getActualPrice();
// fee = actualPrice.multiply(new BigDecimal(100)).intValue();
orderRequest
.
setTotalFee
(
fee
);
// TODO 用户IP地址
orderRequest
.
setSpbillCreateIp
(
"123.12.12.123"
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxTopicController.java
View file @
b68151cb
...
...
@@ -87,7 +87,7 @@ public class WxTopicController {
@GetMapping
(
"related"
)
public
Object
related
(
Integer
id
)
{
if
(
id
==
null
){
return
ResponseUtil
.
fail402
();
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallTopic
>
topicRelatedList
=
topicService
.
queryRelatedList
(
id
,
0
,
4
);
...
...
litemall-wx-api/src/main/resources/application-dep.properties
View file @
b68151cb
...
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-wx-api/src/main/resources/application-dev.properties
View file @
b68151cb
...
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-wx-api/src/main/resources/application-docker.yml
0 → 100644
View file @
b68151cb
spring
:
datasource
:
driver-class-name
:
com.mysql.jdbc.Driver
url
:
jdbc:mysql://${MYSQL_HOST}:3306/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=utf-8
username
:
${MYSQL_USERNAME}
password
:
${MYSQL_PASSWORD}
type
:
com.alibaba.druid.pool.DruidDataSource
wx
:
app-id
:
${WX_APP_ID}
app-secret
:
${WX_APP_SECRET}
mch-id
:
${WX_MCH_ID}
mch-key
:
${WX_MCH_KEY}
notify-url
:
${WX_NOTIFY_URL}
\ No newline at end of file
litemall-wx-api/src/main/resources/application-prod.properties
View file @
b68151cb
...
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-wx-api/src/main/resources/application.properties
View file @
b68151cb
spring.profiles.active
=
prod
spring.profiles.active
=
dev
server.port
=
8082
logging.level.org.linlinjava.litemall.wx.Application
=
DEBUG
litemall-wx/app.json
View file @
b68151cb
litemall-wx/pages/brand/brand.wxml
View file @
b68151cb
...
...
@@ -2,7 +2,7 @@
<view class="brand-list" >
<navigator url="../brandDetail/brandDetail?id={{item.id}}" class="item" wx:for="{{brandList}}" wx:key="id">
<view class="img-bg">
<image src="{{item.
appListP
icUrl}}" background-size="cover"></image>
<image src="{{item.
p
icUrl}}" background-size="cover"></image>
</view>
<view class="txt-box">
<view class="line">
...
...
litemall-wx/pages/brandDetail/brandDetail.wxml
View file @
b68151cb
<view class="container">
<view class="brand-info">
<view class="name">
<image class="img" src="{{brand.
appListP
icUrl}}" background-size="cover"></image>
<image class="img" src="{{brand.
p
icUrl}}" background-size="cover"></image>
<view class="info-box">
<view class="info">
<text class="txt">{{brand.name}}</text>
...
...
@@ -10,7 +10,7 @@
</view>
</view>
<view class="desc">
{{brand.
simpleD
esc}}
{{brand.
d
esc}}
</view>
</view>
...
...
@@ -18,7 +18,7 @@
<view class="b">
<block wx:for="{{goodsList}}" wx:key="id" wx:for-index="iindex" wx:for-item="iitem">
<navigator class="item {{iindex % 2 == 0 ? 'item-b' : ''}}" url="../goods/goods?id={{iitem.id}}">
<image class="img" src="{{iitem.
listP
icUrl}}" background-size="cover"></image>
<image class="img" src="{{iitem.
p
icUrl}}" background-size="cover"></image>
<text class="name">{{iitem.name}}</text>
<text class="price">¥{{iitem.retailPrice}}</text>
</navigator>
...
...
Prev
1
…
7
8
9
10
11
12
13
Next
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