Skip to content

Commit 21ac9ac

Browse files
committed
fix[litemall-wx, litemall-wx-api]: 修复订单商品评价
1 parent 31bf153 commit 21ac9ac

File tree

5 files changed

+16
-37
lines changed

5 files changed

+16
-37
lines changed

litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderGoodsService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ public List<LitemallOrderGoods> queryByOid(Integer orderId) {
2626
return orderGoodsMapper.selectByExample(example);
2727
}
2828

29-
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
30-
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
31-
example.or().andOrderIdEqualTo(orderId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
32-
return orderGoodsMapper.selectByExample(example);
33-
}
34-
3529
public LitemallOrderGoods findById(Integer id) {
3630
return orderGoodsMapper.selectByPrimaryKey(id);
3731
}

litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -955,29 +955,22 @@ public Object delete(Integer userId, String body) {
955955
* 待评价订单商品信息
956956
*
957957
* @param userId 用户ID
958-
* @param orderId 订单ID
959-
* @param goodsId 商品ID
958+
* @param ogid 订单商品ID
960959
* @return 待评价订单商品信息
961960
*/
962-
public Object goods(Integer userId, Integer orderId, Integer goodsId) {
961+
public Object goods(Integer userId, Integer ogid) {
963962
if (userId == null) {
964963
return ResponseUtil.unlogin();
965964
}
966-
LitemallOrder order = orderService.findById(userId, orderId);
967-
if (order == null) {
968-
return ResponseUtil.badArgument();
969-
}
970-
971-
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
972-
int size = orderGoodsList.size();
965+
LitemallOrderGoods orderGoods = orderGoodsService.findById(ogid);
973966

974-
Assert.state(size < 2, "存在多个符合条件的订单商品");
975-
976-
if (size == 0) {
977-
return ResponseUtil.badArgumentValue();
967+
if (orderGoods != null) {
968+
Integer orderId = orderGoods.getOrderId();
969+
LitemallOrder order = orderService.findById(orderId);
970+
if (!order.getUserId().equals(userId)) {
971+
return ResponseUtil.badArgument();
972+
}
978973
}
979-
980-
LitemallOrderGoods orderGoods = orderGoodsList.get(0);
981974
return ResponseUtil.ok(orderGoods);
982975
}
983976

@@ -1008,7 +1001,6 @@ public Object comment(Integer userId, String body) {
10081001
if (order == null) {
10091002
return ResponseUtil.badArgumentValue();
10101003
}
1011-
Short orderStatus = order.getOrderStatus();
10121004
if (!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)) {
10131005
return ResponseUtil.fail(ORDER_INVALID_OPERATION, "当前商品不能评价");
10141006
}

litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,13 @@ public Object delete(@LoginUser Integer userId, @RequestBody String body) {
159159
* 待评价订单商品信息
160160
*
161161
* @param userId 用户ID
162-
* @param orderId 订单ID
163-
* @param goodsId 商品ID
162+
* @param ogid 订单商品ID
164163
* @return 待评价订单商品信息
165164
*/
166165
@GetMapping("goods")
167166
public Object goods(@LoginUser Integer userId,
168-
@NotNull Integer orderId,
169-
@NotNull Integer goodsId) {
170-
return wxOrderService.goods(userId, orderId, goodsId);
167+
@NotNull Integer ogid) {
168+
return wxOrderService.goods(userId, ogid);
171169
}
172170

173171
/**

litemall-wx/pages/commentPost/commentPost.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ var util = require('../../utils/util.js');
44
var api = require('../../config/api.js');
55
Page({
66
data: {
7-
orderId: 0,
8-
type: 0,
9-
valueId: 0,
7+
ogid: 0,
108
orderGoods: {},
119
content: '',
1210
stars: [0, 1, 2, 3, 4],
@@ -97,17 +95,14 @@ Page({
9795
onLoad: function(options) {
9896
var that = this;
9997
that.setData({
100-
orderId: options.orderId,
101-
type: options.type,
102-
valueId: options.valueId
98+
ogid: options.ogid
10399
});
104100
this.getOrderGoods();
105101
},
106102
getOrderGoods: function() {
107103
let that = this;
108104
util.request(api.OrderGoods, {
109-
orderId: that.data.orderId,
110-
goodsId: that.data.valueId
105+
ogid: that.data.ogid
111106
}).then(function(res) {
112107
if (res.errno === 0) {
113108
that.setData({

litemall-wx/pages/ucenter/orderDetail/orderDetail.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<view class="attr">{{item.specifications}}</view>
4343
<view class="price">¥{{item.price}}</view>
4444
<view class="btn active" wx:if="{{handleOption.comment && (item.comment == 0)}}">
45-
<navigator url="../../commentPost/commentPost?orderId={{item.orderId}}&&valueId={{item.goodsId}}&type=0">去评价</navigator>
45+
<navigator url="../../commentPost/commentPost?ogid={{item.id}}">去评价</navigator>
4646
</view>
4747
<view class="btn active" wx:if="{{handleOption.rebuy}}">
4848
<navigator url="../../goods/goods?id={{item.goodsId}}">再次购买</navigator>

0 commit comments

Comments
 (0)