Commit f5b1a2df authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-admin-api, litemall-admin]: 管理后台支持评价回复。

parent 2d007e82
...@@ -9,10 +9,7 @@ import org.linlinjava.litemall.core.util.JacksonUtil; ...@@ -9,10 +9,7 @@ import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.validator.Order; import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort; import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.*; import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.LitemallOrderGoodsService; import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.db.service.LitemallOrderService;
import org.linlinjava.litemall.db.service.LitemallGoodsProductService;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.db.util.OrderUtil; import org.linlinjava.litemall.db.util.OrderUtil;
import org.linlinjava.litemall.core.util.ResponseUtil; import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -21,12 +18,14 @@ import org.springframework.transaction.PlatformTransactionManager; ...@@ -21,12 +18,14 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -48,6 +47,8 @@ public class AdminOrderController { ...@@ -48,6 +47,8 @@ public class AdminOrderController {
private LitemallGoodsProductService productService; private LitemallGoodsProductService productService;
@Autowired @Autowired
private LitemallUserService userService; private LitemallUserService userService;
@Autowired
private LitemallCommentService commentService;
@Autowired @Autowired
private NotifyService notifyService; private NotifyService notifyService;
...@@ -220,6 +221,48 @@ public class AdminOrderController { ...@@ -220,6 +221,48 @@ public class AdminOrderController {
return ResponseUtil.ok(); return ResponseUtil.ok();
} }
/**
* 回复订单商品
*
* @param adminId 管理员ID
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping("reply")
public Object reply(@LoginAdmin Integer adminId, @RequestBody String body) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer commentId = JacksonUtil.parseInteger(body, "commentId");
if(commentId == null || commentId == 0){
return ResponseUtil.badArgument();
}
// 目前只支持回复一次
if(commentService.findById(commentId) != null){
return ResponseUtil.fail(404, "订单商品已回复!");
}
String content = JacksonUtil.parseString(body, "content");
if(StringUtils.isEmpty(content)){
return ResponseUtil.badArgument();
}
// 创建评价回复
LitemallComment comment = new LitemallComment();
comment.setType((byte)2);
comment.setValueId(commentId);
comment.setContent(content);
comment.setUserId(0); // 评价回复没有用
comment.setStar((short)0); // 评价回复没有用
comment.setHasPicture(false); // 评价回复没有用
comment.setPicUrls(new String[]{}); // 评价回复没有用
commentService.save(comment);
return ResponseUtil.ok();
}
/** /**
* 自动取消订单 * 自动取消订单
* <p> * <p>
......
...@@ -35,3 +35,11 @@ export function refundOrder(data) { ...@@ -35,3 +35,11 @@ export function refundOrder(data) {
data data
}) })
} }
export function replyComment(data) {
return request({
url: '/order/reply',
method: 'post',
data
})
}
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
<el-table-column align="center" label="商品ID" prop="valueId"> <el-table-column align="center" label="商品ID" prop="valueId">
</el-table-column> </el-table-column>
<el-table-column align="center" label="打分" prop="star">
</el-table-column>
<el-table-column align="center" label="评论内容" prop="content"> <el-table-column align="center" label="评论内容" prop="content">
</el-table-column> </el-table-column>
...@@ -47,12 +50,25 @@ ...@@ -47,12 +50,25 @@
</el-pagination> </el-pagination>
</div> </div>
<!-- 评论回复 -->
<el-dialog title="回复" :visible.sync="replyFormVisible">
<el-form ref="replyForm" :model="replyForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
<el-form-item label="回复内容" prop="content">
<el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8}" v-model="replyForm.content"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="replyFormVisible = false">取消</el-button>
<el-button type="primary" @click="reply">确定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listComment, deleteComment } from '@/api/comment' import { listComment, deleteComment } from '@/api/comment'
import { MessageBox } from 'element-ui' import { replyComment } from '@/api/order'
export default { export default {
name: 'Comment', name: 'Comment',
...@@ -69,7 +85,12 @@ export default { ...@@ -69,7 +85,12 @@ export default {
sort: 'add_time', sort: 'add_time',
order: 'desc' order: 'desc'
}, },
downloadLoading: false downloadLoading: false,
replyForm: {
commentId: 0,
content: ''
},
replyFormVisible: false
} }
}, },
created() { created() {
...@@ -101,9 +122,21 @@ export default { ...@@ -101,9 +122,21 @@ export default {
this.getList() this.getList()
}, },
handleReply(row) { handleReply(row) {
MessageBox.alert('商品评论回复目前不支持', '失败', { this.replyForm = { commentId: row.id, content: '' }
confirmButtonText: '确定', this.replyFormVisible = true
type: 'error' },
reply() {
replyComment(this.replyForm).then(response => {
this.replyFormVisible = false
this.$notify.success({
title: '成功',
message: '回复成功'
})
}).catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
}) })
}, },
handleDelete(row) { handleDelete(row) {
......
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