"eladmin-tools/vscode:/vscode.git/clone" did not exist on "e4ca7afc70b7e164db578eb54ea00ee9f5a57f7c"
Commit 21ac9ac1 authored by linlinjava's avatar linlinjava
Browse files

fix[litemall-wx, litemall-wx-api]: 修复订单商品评价

parent 31bf153c
...@@ -26,12 +26,6 @@ public class LitemallOrderGoodsService { ...@@ -26,12 +26,6 @@ public class LitemallOrderGoodsService {
return orderGoodsMapper.selectByExample(example); return orderGoodsMapper.selectByExample(example);
} }
public List<LitemallOrderGoods> findByOidAndGid(Integer orderId, Integer goodsId) {
LitemallOrderGoodsExample example = new LitemallOrderGoodsExample();
example.or().andOrderIdEqualTo(orderId).andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
return orderGoodsMapper.selectByExample(example);
}
public LitemallOrderGoods findById(Integer id) { public LitemallOrderGoods findById(Integer id) {
return orderGoodsMapper.selectByPrimaryKey(id); return orderGoodsMapper.selectByPrimaryKey(id);
} }
......
...@@ -955,29 +955,22 @@ public class WxOrderService { ...@@ -955,29 +955,22 @@ public class WxOrderService {
* 待评价订单商品信息 * 待评价订单商品信息
* *
* @param userId 用户ID * @param userId 用户ID
* @param orderId 订单ID * @param ogid 订单商品ID
* @param goodsId 商品ID
* @return 待评价订单商品信息 * @return 待评价订单商品信息
*/ */
public Object goods(Integer userId, Integer orderId, Integer goodsId) { public Object goods(Integer userId, Integer ogid) {
if (userId == null) { if (userId == null) {
return ResponseUtil.unlogin(); return ResponseUtil.unlogin();
} }
LitemallOrder order = orderService.findById(userId, orderId); LitemallOrderGoods orderGoods = orderGoodsService.findById(ogid);
if (order == null) {
return ResponseUtil.badArgument();
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
int size = orderGoodsList.size();
Assert.state(size < 2, "存在多个符合条件的订单商品"); if (orderGoods != null) {
Integer orderId = orderGoods.getOrderId();
if (size == 0) { LitemallOrder order = orderService.findById(orderId);
return ResponseUtil.badArgumentValue(); if (!order.getUserId().equals(userId)) {
return ResponseUtil.badArgument();
}
} }
LitemallOrderGoods orderGoods = orderGoodsList.get(0);
return ResponseUtil.ok(orderGoods); return ResponseUtil.ok(orderGoods);
} }
...@@ -1008,7 +1001,6 @@ public class WxOrderService { ...@@ -1008,7 +1001,6 @@ public class WxOrderService {
if (order == null) { if (order == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
Short orderStatus = order.getOrderStatus();
if (!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)) { if (!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)) {
return ResponseUtil.fail(ORDER_INVALID_OPERATION, "当前商品不能评价"); return ResponseUtil.fail(ORDER_INVALID_OPERATION, "当前商品不能评价");
} }
......
...@@ -159,15 +159,13 @@ public class WxOrderController { ...@@ -159,15 +159,13 @@ public class WxOrderController {
* 待评价订单商品信息 * 待评价订单商品信息
* *
* @param userId 用户ID * @param userId 用户ID
* @param orderId 订单ID * @param ogid 订单商品ID
* @param goodsId 商品ID
* @return 待评价订单商品信息 * @return 待评价订单商品信息
*/ */
@GetMapping("goods") @GetMapping("goods")
public Object goods(@LoginUser Integer userId, public Object goods(@LoginUser Integer userId,
@NotNull Integer orderId, @NotNull Integer ogid) {
@NotNull Integer goodsId) { return wxOrderService.goods(userId, ogid);
return wxOrderService.goods(userId, orderId, goodsId);
} }
/** /**
......
...@@ -4,9 +4,7 @@ var util = require('../../utils/util.js'); ...@@ -4,9 +4,7 @@ var util = require('../../utils/util.js');
var api = require('../../config/api.js'); var api = require('../../config/api.js');
Page({ Page({
data: { data: {
orderId: 0, ogid: 0,
type: 0,
valueId: 0,
orderGoods: {}, orderGoods: {},
content: '', content: '',
stars: [0, 1, 2, 3, 4], stars: [0, 1, 2, 3, 4],
...@@ -97,17 +95,14 @@ Page({ ...@@ -97,17 +95,14 @@ Page({
onLoad: function(options) { onLoad: function(options) {
var that = this; var that = this;
that.setData({ that.setData({
orderId: options.orderId, ogid: options.ogid
type: options.type,
valueId: options.valueId
}); });
this.getOrderGoods(); this.getOrderGoods();
}, },
getOrderGoods: function() { getOrderGoods: function() {
let that = this; let that = this;
util.request(api.OrderGoods, { util.request(api.OrderGoods, {
orderId: that.data.orderId, ogid: that.data.ogid
goodsId: that.data.valueId
}).then(function(res) { }).then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
that.setData({ that.setData({
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<view class="attr">{{item.specifications}}</view> <view class="attr">{{item.specifications}}</view>
<view class="price">¥{{item.price}}</view> <view class="price">¥{{item.price}}</view>
<view class="btn active" wx:if="{{handleOption.comment && (item.comment == 0)}}"> <view class="btn active" wx:if="{{handleOption.comment && (item.comment == 0)}}">
<navigator url="../../commentPost/commentPost?orderId={{item.orderId}}&&valueId={{item.goodsId}}&type=0">去评价</navigator> <navigator url="../../commentPost/commentPost?ogid={{item.id}}">去评价</navigator>
</view> </view>
<view class="btn active" wx:if="{{handleOption.rebuy}}"> <view class="btn active" wx:if="{{handleOption.rebuy}}">
<navigator url="../../goods/goods?id={{item.goodsId}}">再次购买</navigator> <navigator url="../../goods/goods?id={{item.goodsId}}">再次购买</navigator>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment