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 {
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) {
return orderGoodsMapper.selectByPrimaryKey(id);
}
......
......@@ -955,29 +955,22 @@ public class WxOrderService {
* 待评价订单商品信息
*
* @param userId 用户ID
* @param orderId 订单ID
* @param goodsId 商品ID
* @param ogid 订单商品ID
* @return 待评价订单商品信息
*/
public Object goods(Integer userId, Integer orderId, Integer goodsId) {
public Object goods(Integer userId, Integer ogid) {
if (userId == null) {
return ResponseUtil.unlogin();
}
LitemallOrder order = orderService.findById(userId, orderId);
if (order == null) {
return ResponseUtil.badArgument();
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
int size = orderGoodsList.size();
LitemallOrderGoods orderGoods = orderGoodsService.findById(ogid);
Assert.state(size < 2, "存在多个符合条件的订单商品");
if (size == 0) {
return ResponseUtil.badArgumentValue();
if (orderGoods != null) {
Integer orderId = orderGoods.getOrderId();
LitemallOrder order = orderService.findById(orderId);
if (!order.getUserId().equals(userId)) {
return ResponseUtil.badArgument();
}
}
LitemallOrderGoods orderGoods = orderGoodsList.get(0);
return ResponseUtil.ok(orderGoods);
}
......@@ -1008,7 +1001,6 @@ public class WxOrderService {
if (order == null) {
return ResponseUtil.badArgumentValue();
}
Short orderStatus = order.getOrderStatus();
if (!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)) {
return ResponseUtil.fail(ORDER_INVALID_OPERATION, "当前商品不能评价");
}
......
......@@ -159,15 +159,13 @@ public class WxOrderController {
* 待评价订单商品信息
*
* @param userId 用户ID
* @param orderId 订单ID
* @param goodsId 商品ID
* @param ogid 订单商品ID
* @return 待评价订单商品信息
*/
@GetMapping("goods")
public Object goods(@LoginUser Integer userId,
@NotNull Integer orderId,
@NotNull Integer goodsId) {
return wxOrderService.goods(userId, orderId, goodsId);
@NotNull Integer ogid) {
return wxOrderService.goods(userId, ogid);
}
/**
......
......@@ -4,9 +4,7 @@ var util = require('../../utils/util.js');
var api = require('../../config/api.js');
Page({
data: {
orderId: 0,
type: 0,
valueId: 0,
ogid: 0,
orderGoods: {},
content: '',
stars: [0, 1, 2, 3, 4],
......@@ -97,17 +95,14 @@ Page({
onLoad: function(options) {
var that = this;
that.setData({
orderId: options.orderId,
type: options.type,
valueId: options.valueId
ogid: options.ogid
});
this.getOrderGoods();
},
getOrderGoods: function() {
let that = this;
util.request(api.OrderGoods, {
orderId: that.data.orderId,
goodsId: that.data.valueId
ogid: that.data.ogid
}).then(function(res) {
if (res.errno === 0) {
that.setData({
......
......@@ -42,7 +42,7 @@
<view class="attr">{{item.specifications}}</view>
<view class="price">¥{{item.price}}</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>
<navigator url="../../commentPost/commentPost?ogid={{item.id}}">去评价</navigator>
</view>
<view class="btn active" wx:if="{{handleOption.rebuy}}">
<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