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
b7e32a66
"jetbrains:/idea/checkout/git" did not exist on "d19ebe9f5f67f0da66792ae46dd8a12552d055ab"
Commit
b7e32a66
authored
Nov 09, 2018
by
Junling Bu
Browse files
小商场更新
parent
02e3d98f
Changes
19
Show whitespace changes
Inline
Side-by-side
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java
View file @
b7e32a66
...
...
@@ -117,7 +117,6 @@ public class WxAddressController {
data
.
put
(
"mobile"
,
address
.
getMobile
());
data
.
put
(
"address"
,
address
.
getAddress
());
data
.
put
(
"isDefault"
,
address
.
getIsDefault
());
data
.
put
(
"version"
,
address
.
getVersion
());
String
pname
=
regionService
.
findById
(
address
.
getProvinceId
()).
getName
();
data
.
put
(
"provinceName"
,
pname
);
String
cname
=
regionService
.
findById
(
address
.
getCityId
()).
getName
();
...
...
@@ -204,7 +203,6 @@ public class WxAddressController {
if
(
address
.
getId
()
==
null
||
address
.
getId
().
equals
(
0
))
{
address
.
setId
(
null
);
address
.
setAddTime
(
LocalDateTime
.
now
());
address
.
setUserId
(
userId
);
addressService
.
add
(
address
);
}
else
{
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java
View file @
b7e32a66
...
...
@@ -161,7 +161,6 @@ public class WxAuthController {
user
.
setStatus
((
byte
)
0
);
user
.
setLastLoginTime
(
LocalDateTime
.
now
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
}
else
{
...
...
@@ -307,7 +306,6 @@ public class WxAuthController {
user
.
setStatus
((
byte
)
0
);
user
.
setLastLoginTime
(
LocalDateTime
.
now
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
// userInfo
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java
View file @
b7e32a66
...
...
@@ -31,7 +31,7 @@ public class WxCartController {
@Autowired
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallProductService
productService
;
private
Litemall
Goods
ProductService
productService
;
@Autowired
private
LitemallAddressService
addressService
;
@Autowired
...
...
@@ -124,7 +124,7 @@ public class WxCartController {
return
ResponseUtil
.
fail
(
400
,
"商品已下架"
);
}
LitemallProduct
product
=
productService
.
findById
(
productId
);
Litemall
Goods
Product
product
=
productService
.
findById
(
productId
);
//判断购物车中是否存在此规格商品
LitemallCart
existCart
=
cartService
.
queryExist
(
goodsId
,
productId
,
userId
);
if
(
existCart
==
null
)
{
...
...
@@ -141,7 +141,6 @@ public class WxCartController {
cart
.
setSpecifications
(
product
.
getSpecifications
());
cart
.
setUserId
(
userId
);
cart
.
setChecked
(
true
);
cart
.
setAddTime
(
LocalDateTime
.
now
());
cartService
.
add
(
cart
);
}
else
{
//取得规格的信息,判断规格库存
...
...
@@ -198,7 +197,7 @@ public class WxCartController {
return
ResponseUtil
.
fail
(
400
,
"商品已下架"
);
}
LitemallProduct
product
=
productService
.
findById
(
productId
);
Litemall
Goods
Product
product
=
productService
.
findById
(
productId
);
//判断购物车中是否存在此规格商品
LitemallCart
existCart
=
cartService
.
queryExist
(
goodsId
,
productId
,
userId
);
if
(
existCart
==
null
)
{
...
...
@@ -279,7 +278,7 @@ public class WxCartController {
}
//取得规格的信息,判断规格库存
LitemallProduct
product
=
productService
.
findById
(
productId
);
Litemall
Goods
Product
product
=
productService
.
findById
(
productId
);
if
(
product
==
null
||
product
.
getNumber
()
<
number
)
{
return
ResponseUtil
.
fail
(
403
,
"库存不足"
);
}
...
...
@@ -501,6 +500,7 @@ public class WxCartController {
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"addressId"
,
addressId
);
data
.
put
(
"grouponRulesId"
,
grouponRulesId
);
data
.
put
(
"grouponPrice"
,
grouponPrice
);
data
.
put
(
"checkedAddress"
,
checkedAddress
);
data
.
put
(
"couponId"
,
couponId
);
data
.
put
(
"checkedCoupon"
,
0
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCollectController.java
View file @
b7e32a66
...
...
@@ -133,7 +133,6 @@ public class WxCollectController {
collect
.
setUserId
(
userId
);
collect
.
setValueId
(
valueId
);
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 @
b7e32a66
...
...
@@ -74,16 +74,16 @@ public class WxCommentController {
else
{
return
ResponseUtil
.
badArgumentValue
();
}
Boolean
hasPicture
=
comment
.
getHasPicture
();
if
(
hasPicture
==
null
||
!
hasPicture
){
comment
.
setPicUrls
(
new
String
[
0
]);
}
return
null
;
}
/**
* 发表评论
*
* TODO, 对于评论,应该检测用户是否有权限评论。
* 1. 如果用户没有购买过商品,则不能发表对该商品的评论
* 2. 如果用户购买商品后规定时间内没有评论,则过期也不能再评论
*
* @param userId 用户ID
* @param comment 评论内容
* @return 发表评论操作结果
...
...
@@ -105,7 +105,6 @@ public class WxCommentController {
return
error
;
}
comment
.
setAddTime
(
LocalDateTime
.
now
());
comment
.
setUserId
(
userId
);
commentService
.
save
(
comment
);
return
ResponseUtil
.
ok
(
comment
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java
View file @
b7e32a66
...
...
@@ -41,6 +41,11 @@ public class WxFeedbackController {
return
ResponseUtil
.
badArgument
();
}
Boolean
hasPicture
=
feedback
.
getHasPicture
();
if
(
hasPicture
==
null
||
!
hasPicture
){
feedback
.
setPicUrls
(
new
String
[
0
]);
}
// 测试手机号码是否正确
String
mobile
=
feedback
.
getMobile
();
if
(
StringUtils
.
isEmpty
(
mobile
)){
...
...
@@ -70,7 +75,6 @@ public class WxFeedbackController {
feedback
.
setId
(
null
);
feedback
.
setUserId
(
userId
);
feedback
.
setUsername
(
username
);
feedback
.
setAddTime
(
LocalDateTime
.
now
());
//状态默认是0,1表示状态已发生变化
feedback
.
setStatus
(
1
);
feedbackService
.
add
(
feedback
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java
View file @
b7e32a66
...
...
@@ -10,7 +10,6 @@ import org.linlinjava.litemall.core.validator.Sort;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.wx.service.HomeCacheManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -34,7 +33,7 @@ public class WxGoodsController {
@Autowired
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallProductService
productService
;
private
Litemall
Goods
ProductService
productService
;
@Autowired
private
LitemallIssueService
goodsIssueService
;
@Autowired
...
...
@@ -99,13 +98,20 @@ public class WxGoodsController {
Object
specificationList
=
goodsSpecificationService
.
getSpecificationVoList
(
id
);
// 商品规格对应的数量和价格
List
<
LitemallProduct
>
productList
=
productService
.
queryByGid
(
id
);
List
<
Litemall
Goods
Product
>
productList
=
productService
.
queryByGid
(
id
);
// 商品问题,这里是一些通用问题
List
<
LitemallIssue
>
issue
=
goodsIssueService
.
query
();
// 商品品牌商
LitemallBrand
brand
=
brandService
.
findById
(
info
.
getBrandId
());
Integer
brandId
=
info
.
getBrandId
();
LitemallBrand
brand
=
null
;
if
(
brandId
==
0
){
brand
=
new
LitemallBrand
();
}
else
{
brand
=
brandService
.
findById
(
info
.
getBrandId
());
}
// 评论
List
<
LitemallComment
>
comments
=
commentService
.
queryGoodsByGid
(
id
,
0
,
2
);
...
...
@@ -138,7 +144,6 @@ public class WxGoodsController {
// 记录用户的足迹
if
(
userId
!=
null
)
{
LitemallFootprint
footprint
=
new
LitemallFootprint
();
footprint
.
setAddTime
(
LocalDateTime
.
now
());
footprint
.
setUserId
(
userId
);
footprint
.
setGoodsId
(
id
);
footprintService
.
add
(
footprint
);
...
...
@@ -242,7 +247,6 @@ public class WxGoodsController {
//添加到搜索历史
if
(
userId
!=
null
&&
!
StringUtils
.
isNullOrEmpty
(
keyword
))
{
LitemallSearchHistory
searchHistoryVo
=
new
LitemallSearchHistory
();
searchHistoryVo
.
setAddTime
(
LocalDateTime
.
now
());
searchHistoryVo
.
setKeyword
(
keyword
);
searchHistoryVo
.
setUserId
(
userId
);
searchHistoryVo
.
setFrom
(
"wx"
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
b7e32a66
...
...
@@ -31,7 +31,6 @@ import org.springframework.transaction.TransactionDefinition;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -54,7 +53,7 @@ import java.util.Map;
* 101 订单生成,未支付;102,下单后未支付用户取消;103,下单后未支付超时系统自动取消
* 201 支付完成,商家未发货;202,订单生产,已付款未发货,但是退款取消;
* 301 商家发货,用户未确认;
* 401 用户确认收货
,订单结束
; 402 用户没有确认收货
,但是快递反馈已收获后,
超过一定时间,系统自动确认收货
,订单结束。
* 401 用户确认收货; 402 用户没有确认收货超过一定时间,系统自动确认收货
;
*
* 当101用户未付款时,此时用户可以进行的操作是取消订单,或者付款操作
* 当201支付完成而商家未发货时,此时用户可以取消订单并申请退款
...
...
@@ -63,7 +62,6 @@ import java.util.Map;
* 当402系统自动确认收货以后,此时用户可以删除订单,评价商品,或者再次购买
*
* 目前不支持订单退货和售后服务
*
*/
@RestController
@RequestMapping
(
"/wx/order"
)
...
...
@@ -86,7 +84,7 @@ public class WxOrderController {
@Autowired
private
LitemallRegionService
regionService
;
@Autowired
private
LitemallProductService
productService
;
private
Litemall
Goods
ProductService
productService
;
@Autowired
private
WxPayService
wxPayService
;
@Autowired
...
...
@@ -101,6 +99,8 @@ public class WxOrderController {
private
QCodeService
qCodeService
;
@Autowired
private
ExpressService
expressService
;
@Autowired
private
LitemallCommentService
commentService
;
private
String
detailedAddress
(
LitemallAddress
litemallAddress
)
{
Integer
provinceId
=
litemallAddress
.
getProvinceId
();
...
...
@@ -237,23 +237,10 @@ public class WxOrderController {
orderVo
.
put
(
"expNo"
,
order
.
getShipSn
());
List
<
LitemallOrderGoods
>
orderGoodsList
=
orderGoodsService
.
queryByOid
(
order
.
getId
());
List
<
Map
<
String
,
Object
>>
orderGoodsVoList
=
new
ArrayList
<>(
orderGoodsList
.
size
());
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Map
<
String
,
Object
>
orderGoodsVo
=
new
HashMap
<>();
orderGoodsVo
.
put
(
"id"
,
orderGoods
.
getId
());
orderGoodsVo
.
put
(
"orderId"
,
orderGoods
.
getOrderId
());
orderGoodsVo
.
put
(
"goodsId"
,
orderGoods
.
getGoodsId
());
orderGoodsVo
.
put
(
"goodsName"
,
orderGoods
.
getGoodsName
());
orderGoodsVo
.
put
(
"number"
,
orderGoods
.
getNumber
());
orderGoodsVo
.
put
(
"retailPrice"
,
orderGoods
.
getPrice
());
orderGoodsVo
.
put
(
"picUrl"
,
orderGoods
.
getPicUrl
());
orderGoodsVo
.
put
(
"goodsSpecificationValues"
,
orderGoods
.
getSpecifications
());
orderGoodsVoList
.
add
(
orderGoodsVo
);
}
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"orderInfo"
,
orderVo
);
result
.
put
(
"orderGoods"
,
orderGoods
Vo
List
);
result
.
put
(
"orderGoods"
,
orderGoodsList
);
// 订单状态为已发货且物流信息不为空
//"YTO", "800669400640887922"
...
...
@@ -290,6 +277,7 @@ public class WxOrderController {
Integer
cartId
=
JacksonUtil
.
parseInteger
(
body
,
"cartId"
);
Integer
addressId
=
JacksonUtil
.
parseInteger
(
body
,
"addressId"
);
Integer
couponId
=
JacksonUtil
.
parseInteger
(
body
,
"couponId"
);
String
message
=
JacksonUtil
.
parseString
(
body
,
"message"
);
Integer
grouponRulesId
=
JacksonUtil
.
parseInteger
(
body
,
"grouponRulesId"
);
Integer
grouponLinkId
=
JacksonUtil
.
parseInteger
(
body
,
"grouponLinkId"
);
...
...
@@ -373,10 +361,10 @@ public class WxOrderController {
order
=
new
LitemallOrder
();
order
.
setUserId
(
userId
);
order
.
setOrderSn
(
orderService
.
generateOrderSn
(
userId
));
order
.
setAddTime
(
LocalDateTime
.
now
());
order
.
setOrderStatus
(
OrderUtil
.
STATUS_CREATE
);
order
.
setConsignee
(
checkedAddress
.
getName
());
order
.
setMobile
(
checkedAddress
.
getMobile
());
order
.
setMessage
(
message
);
String
detailedAddress
=
detailedAddress
(
checkedAddress
);
order
.
setAddress
(
detailedAddress
);
order
.
setGoodsPrice
(
checkedGoodsPrice
);
...
...
@@ -421,7 +409,7 @@ public class WxOrderController {
// 商品货品数量减少
for
(
LitemallCart
checkGoods
:
checkedGoodsList
)
{
Integer
productId
=
checkGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
Litemall
Goods
Product
product
=
productService
.
findById
(
productId
);
Integer
remainNumber
=
product
.
getNumber
()
-
checkGoods
.
getNumber
();
if
(
remainNumber
<
0
)
{
...
...
@@ -429,7 +417,7 @@ public class WxOrderController {
}
product
.
setNumber
(
remainNumber
);
if
(
productService
.
updateById
(
product
)
==
0
){
throw
new
Exception
(
"更新数据
已失效
"
);
throw
new
Exception
(
"更新数据
失败
"
);
}
}
...
...
@@ -453,8 +441,6 @@ public class WxOrderController {
groupon
.
setGrouponId
(
0
);
}
groupon
.
setAddTime
(
LocalDateTime
.
now
());
grouponService
.
createGroupon
(
groupon
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -499,7 +485,7 @@ public class WxOrderController {
return
ResponseUtil
.
badArgumentValue
();
}
Integer
version
=
order
.
get
Version
();
LocalDateTime
preUpdateTime
=
order
.
get
UpdateTime
();
// 检测是否能够取消
OrderHandleOption
handleOption
=
OrderUtil
.
build
(
order
);
...
...
@@ -515,7 +501,7 @@ public class WxOrderController {
// 设置订单已取消状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_CANCEL
);
order
.
setEndTime
(
LocalDateTime
.
now
());
if
(
orderService
.
update
ByIdWithVersion
(
version
,
order
)
==
0
){
if
(
orderService
.
update
WithOptimisticLocker
(
order
)
==
0
){
throw
new
Exception
(
"更新数据已失效"
);
}
...
...
@@ -523,11 +509,11 @@ public class WxOrderController {
List
<
LitemallOrderGoods
>
orderGoodsList
=
orderGoodsService
.
queryByOid
(
orderId
);
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Integer
productId
=
orderGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
Litemall
Goods
Product
product
=
productService
.
findById
(
productId
);
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
setNumber
(
number
);
if
(
productService
.
updateById
(
product
)
==
0
){
throw
new
Exception
(
"更新数据
已失效
"
);
throw
new
Exception
(
"更新数据
失败
"
);
}
}
}
catch
(
Exception
ex
)
{
...
...
@@ -571,8 +557,6 @@ public class WxOrderController {
return
ResponseUtil
.
badArgumentValue
();
}
Integer
version
=
order
.
getVersion
();
// 检测是否能够取消
OrderHandleOption
handleOption
=
OrderUtil
.
build
(
order
);
if
(!
handleOption
.
isPay
())
{
...
...
@@ -615,7 +599,7 @@ public class WxOrderController {
return
ResponseUtil
.
fail
(
403
,
"订单不能支付"
);
}
if
(
orderService
.
update
ByIdWithVersion
(
version
,
order
)
==
0
){
if
(
orderService
.
update
WithOptimisticLocker
(
order
)
==
0
){
return
ResponseUtil
.
updatedDateExpired
();
}
return
ResponseUtil
.
ok
(
result
);
...
...
@@ -666,8 +650,6 @@ public class WxOrderController {
return
WxPayNotifyResponse
.
fail
(
"订单不存在 sn="
+
orderSn
);
}
Integer
version
=
order
.
getVersion
();
// 检查这个订单是否已经处理过
if
(
OrderUtil
.
isPayStatus
(
order
)
&&
order
.
getPayId
()
!=
null
)
{
return
WxPayNotifyResponse
.
success
(
"订单已经处理成功!"
);
...
...
@@ -681,19 +663,18 @@ public class WxOrderController {
order
.
setPayId
(
payId
);
order
.
setPayTime
(
LocalDateTime
.
now
());
order
.
setOrderStatus
(
OrderUtil
.
STATUS_PAY
);
if
(
orderService
.
update
ByIdWithVersion
(
version
,
order
)
==
0
)
{
if
(
orderService
.
update
WithOptimisticLocker
(
order
)
==
0
)
{
// 这里可能存在这样一个问题,用户支付和系统自动取消订单发生在同时
// 如果数据库首先因为系统自动取消订单而更新了订单状态;
// 此时用户支付完成回调这里也要更新数据库,而由于乐观锁机制这里的更新会失败
// 因此,这里会重新读取数据库检查状态是否是订单自动取消,如果是则更新成支付状态。
order
=
orderService
.
findBySn
(
orderSn
);
version
=
order
.
getVersion
();
int
updated
=
0
;
if
(
OrderUtil
.
isAutoCancelStatus
(
order
)){
order
.
setPayId
(
payId
);
order
.
setPayTime
(
LocalDateTime
.
now
());
order
.
setOrderStatus
(
OrderUtil
.
STATUS_PAY
);
updated
=
orderService
.
update
ByIdWithVersion
(
version
,
order
);
updated
=
orderService
.
update
WithOptimisticLocker
(
order
);
}
// 如果updated是0,那么数据库更新失败
...
...
@@ -768,8 +749,6 @@ public class WxOrderController {
return
ResponseUtil
.
badArgumentValue
();
}
Integer
version
=
order
.
getVersion
();
OrderHandleOption
handleOption
=
OrderUtil
.
build
(
order
);
if
(!
handleOption
.
isRefund
())
{
return
ResponseUtil
.
fail
(
403
,
"订单不能取消"
);
...
...
@@ -777,7 +756,7 @@ public class WxOrderController {
// 设置订单申请退款状态
order
.
setOrderStatus
(
OrderUtil
.
STATUS_REFUND
);
if
(
orderService
.
update
ByIdWithVersion
(
version
,
order
)
==
0
){
if
(
orderService
.
update
WithOptimisticLocker
(
order
)
==
0
){
return
ResponseUtil
.
updatedDateExpired
();
}
...
...
@@ -817,16 +796,17 @@ public class WxOrderController {
return
ResponseUtil
.
badArgumentValue
();
}
Integer
version
=
order
.
getVersion
();
OrderHandleOption
handleOption
=
OrderUtil
.
build
(
order
);
if
(!
handleOption
.
isConfirm
())
{
return
ResponseUtil
.
fail
(
403
,
"订单不能确认收货"
);
}
Short
comments
=
orderGoodsService
.
getComments
(
orderId
);
order
.
setComments
(
comments
);
order
.
setOrderStatus
(
OrderUtil
.
STATUS_CONFIRM
);
order
.
setConfirmTime
(
LocalDateTime
.
now
());
if
(
orderService
.
update
ByIdWithVersion
(
version
,
order
)
==
0
){
if
(
orderService
.
update
WithOptimisticLocker
(
order
)
==
0
){
return
ResponseUtil
.
updatedDateExpired
();
}
return
ResponseUtil
.
ok
();
...
...
@@ -883,8 +863,8 @@ public class WxOrderController {
* 成功则 { errno: 0, errmsg: '成功', data: xxx }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"
comment
"
)
public
Object
comment
(
@LoginUser
Integer
userId
,
@GetMapping
(
"
goods
"
)
public
Object
goods
(
@LoginUser
Integer
userId
,
@NotNull
Integer
orderId
,
@NotNull
Integer
goodsId
)
{
if
(
userId
==
null
)
{
...
...
@@ -903,4 +883,85 @@ public class WxOrderController {
LitemallOrderGoods
orderGoods
=
orderGoodsList
.
get
(
0
);
return
ResponseUtil
.
ok
(
orderGoods
);
}
/**
* 评价订单商品
* 确认商品收货后7天内可以评价
*
* @param userId 用户ID
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"comment"
)
public
Object
comment
(
@LoginUser
Integer
userId
,
@RequestBody
String
body
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
orderGoodsId
=
JacksonUtil
.
parseInteger
(
body
,
"orderGoodsId"
);
if
(
orderGoodsId
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallOrderGoods
orderGoods
=
orderGoodsService
.
findById
(
orderGoodsId
);
if
(
orderGoods
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
Integer
orderId
=
orderGoods
.
getOrderId
();
LitemallOrder
order
=
orderService
.
findById
(
orderId
);
if
(
order
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
Short
orderStatus
=
order
.
getOrderStatus
();
if
(!
OrderUtil
.
isConfirmStatus
(
order
)
&&
!
OrderUtil
.
isAutoConfirmStatus
(
order
))
{
return
ResponseUtil
.
fail
(
404
,
"当前商品不能评价"
);
}
if
(!
order
.
getUserId
().
equals
(
userId
)){
return
ResponseUtil
.
fail
(
404
,
"当前商品不属于用户"
);
}
Integer
commentId
=
orderGoods
.
getComment
();
if
(
commentId
==
-
1
){
return
ResponseUtil
.
fail
(
404
,
"当前商品评价时间已经过期"
);
}
if
(
commentId
!=
0
){
return
ResponseUtil
.
fail
(
404
,
"订单商品已评价"
);
}
String
content
=
JacksonUtil
.
parseString
(
body
,
"content"
);
Integer
star
=
JacksonUtil
.
parseInteger
(
body
,
"star"
);
if
(
star
==
null
||
star
<
0
||
star
>
5
){
return
ResponseUtil
.
badArgumentValue
();
}
Boolean
hasPicture
=
JacksonUtil
.
parseBoolean
(
body
,
"hasPicture"
);
List
<
String
>
picUrls
=
JacksonUtil
.
parseStringList
(
body
,
"picUrls"
);
if
(
hasPicture
==
null
||
!
hasPicture
){
picUrls
=
new
ArrayList
<>(
0
);
}
// 1. 创建评价
LitemallComment
comment
=
new
LitemallComment
();
comment
.
setUserId
(
userId
);
comment
.
setValueId
(
orderGoods
.
getGoodsId
());
comment
.
setType
((
byte
)
1
);
comment
.
setContent
(
content
);
comment
.
setHasPicture
(
hasPicture
);
comment
.
setPicUrls
(
picUrls
.
toArray
(
new
String
[]{}));
commentService
.
save
(
comment
);
// 2. 更新订单商品的评价列表
orderGoods
.
setComment
(
comment
.
getId
());
orderGoodsService
.
updateById
(
orderGoods
);
// 3. 更新订单中未评价的订单商品可评价数量
Short
commentCount
=
order
.
getComments
();
if
(
commentCount
>
0
){
commentCount
--;
}
order
.
setComments
(
commentCount
);
orderService
.
updateWithOptimisticLocker
(
order
);
return
ResponseUtil
.
ok
();
}
}
\ No newline at end of file
litemall-wx/config/api.js
View file @
b7e32a66
...
...
@@ -74,7 +74,8 @@ module.exports = {
OrderRefund
:
WxApiRoot
+
'
order/refund
'
,
//退款取消订单
OrderDelete
:
WxApiRoot
+
'
order/delete
'
,
//删除订单
OrderConfirm
:
WxApiRoot
+
'
order/confirm
'
,
//确认收货
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 代评价商品信息
OrderGoods
:
WxApiRoot
+
'
order/goods
'
,
// 代评价商品信息
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 评价订单商品信息
FeedbackAdd
:
WxApiRoot
+
'
feedback/submit
'
,
//添加反馈
FootprintList
:
WxApiRoot
+
'
footprint/list
'
,
//足迹列表
...
...
litemall-wx/pages/checkout/checkout.js
View file @
b7e32a66
...
...
@@ -18,6 +18,7 @@ Page({
cartId
:
0
,
addressId
:
0
,
couponId
:
0
,
message
:
''
,
grouponLinkId
:
0
,
//参与的团购,如果是发起则为0
grouponRulesId
:
0
//团购规则ID
},
...
...
@@ -63,6 +64,11 @@ Page({
url
:
'
/pages/ucenter/addressAdd/addressAdd
'
,
})
},
bindMessageInput
:
function
(
e
)
{
this
.
setData
({
message
:
e
.
detail
.
value
});
},
onReady
:
function
()
{
// 页面渲染完成
...
...
@@ -131,6 +137,7 @@ Page({
cartId
:
this
.
data
.
cartId
,
addressId
:
this
.
data
.
addressId
,
couponId
:
this
.
data
.
couponId
,
message
:
this
.
data
.
message
,
grouponRulesId
:
this
.
data
.
grouponRulesId
,
grouponLinkId
:
this
.
data
.
grouponLinkId
},
'
POST
'
).
then
(
res
=>
{
...
...
litemall-wx/pages/checkout/checkout.wxml
View file @
b7e32a66
...
...
@@ -35,6 +35,10 @@
</view>
</view>
<view class="message-box">
<input class="message-item" bindinput="bindMessageInput" placeholder="如需要,可以输入订单留言" value="{{message}}" />
</view>
<view class="order-box">
<view class="order-item">
<view class="l">
...
...
litemall-wx/pages/checkout/checkout.wxss
View file @
b7e32a66
...
...
@@ -140,6 +140,24 @@ page{
height: 52.078rpx;
}
.message-box{
margin-top: 20rpx;
width: 100%;
height: auto;
overflow: hidden;
background: #fff;
}
.message-box .message-item{
height: 52.078rpx;
overflow: hidden;
background: #fff;
display: flex;
margin-left: 31.25rpx;
padding-right: 31.25rpx;
padding-top: 26rpx;
}
.order-box{
margin-top: 20rpx;
width: 100%;
...
...
litemall-wx/pages/commentPost/commentPost.js
View file @
b7e32a66
...
...
@@ -105,11 +105,11 @@ Page({
type
:
options
.
type
,
valueId
:
options
.
valueId
});
this
.
getOrder
Comment
();
this
.
getOrder
Goods
();
},
getOrder
Comment
:
function
()
{
getOrder
Goods
:
function
()
{
let
that
=
this
;
util
.
request
(
api
.
Order
Comment
,
{
util
.
request
(
api
.
Order
Goods
,
{
orderId
:
that
.
data
.
orderId
,
goodsId
:
that
.
data
.
valueId
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
...
...
@@ -130,9 +130,8 @@ Page({
return
false
;
}
util
.
request
(
api
.
CommentPost
,
{
type
:
that
.
data
.
type
,
valueId
:
that
.
data
.
valueId
,
util
.
request
(
api
.
OrderComment
,
{
orderGoodsId
:
that
.
data
.
orderGoods
.
id
,
content
:
that
.
data
.
content
,
star
:
that
.
data
.
star
,
hasPicture
:
that
.
data
.
hasPicture
,
...
...
@@ -142,7 +141,9 @@ Page({
wx
.
showToast
({
title
:
'
评论成功
'
,
complete
:
function
()
{
wx
.
navigateBack
();
wx
.
switchTab
({
url
:
'
/pages/ucenter/index/index
'
})
}
})
}
...
...
litemall-wx/pages/ucenter/orderDetail/orderDetail.wxml
View file @
b7e32a66
...
...
@@ -29,9 +29,9 @@
<text class="name">{{item.goodsName}}</text>
<text class="number">x{{item.number}}</text>
</view>
<view class="attr">{{item.
goodsS
pecification
Value
s}}</view>
<view class="price">¥{{item.
retailP
rice}}</view>
<view class="btn active" wx:if="{{handleOption.comment}}">
<view class="attr">{{item.
s
pecifications}}</view>
<view class="price">¥{{item.
p
rice}}</view>
<view class="btn active" wx:if="{{handleOption.comment
&& (item.comment == 0)
}}">
<navigator url="../../commentPost/commentPost?orderId={{item.orderId}}&&valueId={{item.goodsId}}&type=0">去评价</navigator>
</view>
<view class="btn active" wx:if="{{handleOption.rebuy}}">
...
...
@@ -40,10 +40,6 @@
</view>
</view>
</view>
<!-- 展开 -->
<!-- <view class="data-expand p10 border-bottom" wx:if="{{ flag }}">
</view> -->
<view class="order-bottom">
<view class="address">
...
...
@@ -86,5 +82,4 @@
</view>
</view>
</view>
<!-- </view> -->
</view>
\ No newline at end of file
litemall-wx/project.config.json
View file @
b7e32a66
...
...
@@ -28,7 +28,7 @@
"list"
:
[]
},
"miniprogram"
:
{
"current"
:
3
3
,
"current"
:
3
4
,
"list"
:
[
{
"id"
:
-1
,
...
...
@@ -103,10 +103,10 @@
"query"
:
""
},
{
"id"
:
-
1
,
"id"
:
1
2
,
"name"
:
"商品"
,
"pathName"
:
"pages/goods/goods"
,
"query"
:
"id=118100
0
"
"query"
:
"id=118100
3
"
},
{
"id"
:
-1
,
...
...
@@ -123,7 +123,7 @@
{
"id"
:
-1
,
"name"
:
"下单"
,
"pathName"
:
"pages/
shopping/
checkout/checkout"
,
"pathName"
:
"pages/checkout/checkout"
,
"query"
:
""
},
{
...
...
@@ -233,6 +233,12 @@
"name"
:
"意见反馈"
,
"pathName"
:
"pages/ucenter/feedback/feedback"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"团购专区"
,
"pathName"
:
"pages/groupon/grouponList/grouponList"
,
"query"
:
""
}
]
}
...
...
renard-wx/app.json
View file @
b7e32a66
...
...
@@ -30,7 +30,8 @@
"pages/shopping/checkout/checkout"
,
"pages/goods/goods"
,
"pages/groupon/myGroupon/myGroupon"
,
"pages/groupon/grouponDetail/grouponDetail"
"pages/groupon/grouponDetail/grouponDetail"
,
"pages/groupon/grouponList/grouponList"
],
"window"
:
{
"navigationBarTitleText"
:
"Renard"
,
...
...
renard-wx/config/api.js
View file @
b7e32a66
...
...
@@ -71,7 +71,8 @@ module.exports = {
OrderRefund
:
WxApiRoot
+
'
order/refund
'
,
//退款取消订单
OrderDelete
:
WxApiRoot
+
'
order/delete
'
,
//删除订单
OrderConfirm
:
WxApiRoot
+
'
order/confirm
'
,
//确认收货
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 代评价商品信息
OrderGoods
:
WxApiRoot
+
'
order/goods
'
,
// 代评价商品信息
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 评价订单商品信息
FootprintList
:
WxApiRoot
+
'
footprint/list
'
,
//足迹列表
FootprintDelete
:
WxApiRoot
+
'
footprint/delete
'
,
//删除足迹
...
...
renard-wx/pages/commentPost/commentPost.js
View file @
b7e32a66
...
...
@@ -105,11 +105,11 @@ Page({
type
:
options
.
type
,
valueId
:
options
.
valueId
});
this
.
getOrder
Comment
();
this
.
getOrder
Goods
();
},
getOrder
Comment
:
function
()
{
getOrder
Goods
:
function
()
{
let
that
=
this
;
util
.
request
(
api
.
Order
Comment
,
{
util
.
request
(
api
.
Order
Goods
,
{
orderId
:
that
.
data
.
orderId
,
goodsId
:
that
.
data
.
valueId
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
...
...
renard-wx/pages/ucenter/orderDetail/orderDetail.wxml
View file @
b7e32a66
...
...
@@ -31,9 +31,9 @@
<text class="name">{{item.goodsName}}</text>
<text class="number">x{{item.number}}</text>
</view>
<view class="attr">{{item.
goodsS
pecification
Value
s}}</view>
<view class="price">¥{{item.
retailP
rice}}</view>
<view class="btn active" wx:if="{{handleOption.comment
}}">
<view class="attr">{{item.
s
pecifications}}</view>
<view class="price">¥{{item.
p
rice}}</view>
<view class="btn active" wx:if="{{handleOption.comment
&& (item.comment == 0)}}">
<navigator url="../../commentPost/commentPost?orderId={{item.orderId}}&&valueId={{item.goodsId}}&type=0">去评价</navigator>
</view>
<view class="btn active" wx:if="{{handleOption.rebuy}}">
...
...
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