Browse Source

取消发货

drew 6 years ago
parent
commit
93d0f2d206

+ 13 - 0
src/main/java/com/izouma/awesomeAdmin/service/OrderService.java

@@ -313,6 +313,19 @@ public class OrderService {
         orderRepo.save(order);
     }
 
+    public void cancelShip(Long orderId) {
+        Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
+        Product product = productRepo.findById(order.getProductId()).orElseThrow(new BusinessException("商品不存在"));
+        if (order.getStatus() == NOT_SHIPPED || order.getStatus() == SHIPPED) {
+            product.setLocked(order.isLocked());
+            product.setStatus(ProductStatus.IN_STOCK);
+            productRepo.save(product);
+
+            order.setStatus(SELLING);
+            orderRepo.save(order);
+        }
+    }
+
     public void shipOrder(Long userId, Long orderId, String logisticsType, String logisticsNo) {
         SecurityUtils.checkBanned();
         Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));

+ 6 - 0
src/main/java/com/izouma/awesomeAdmin/web/OrderController.java

@@ -93,6 +93,12 @@ public class OrderController extends BaseController {
         orderService.applyShip(SecurityUtils.getAuthenticatedUser().getId(), orderId);
     }
 
+    @PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/cancelShip")
+    public void cancelShip(@RequestParam Long orderId) {
+        orderService.cancelShip(orderId);
+    }
+
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/ship")
     @ApiOperation("发货")

+ 19 - 11
src/main/paintingmarket/src/components/OrderInfo.vue

@@ -326,19 +326,27 @@ export default {
             }
         },
         applyShip() {
-            this.$http
-                .post('/order/applyShip', {
-                    orderId: this.info.id
+            this.$dialog
+                .confirm({
+                    title: '提示',
+                    message: '确认申请发货?'
                 })
-                .then(res => {
-                    this.$toast.success('申请成功');
-                    setTimeout(() => {
-                        this.$emit('updateOrder', res);
-                    }, 1000);
+                .then(() => {
+                    this.$http
+                        .post('/order/applyShip', {
+                            orderId: this.info.id
+                        })
+                        .then(res => {
+                            this.$toast.success('申请成功');
+                            setTimeout(() => {
+                                this.$emit('updateOrder', res);
+                            }, 1000);
+                        })
+                        .catch(e => {
+                            return this.$toast(e.error);
+                        });
                 })
-                .catch(e => {
-                    return this.$toast(e.error);
-                });
+                .catch(() => {});
         },
         receive() {
             this.$http

+ 28 - 19
src/main/paintingmarket/src/views/order/OrderDetail.vue

@@ -60,12 +60,12 @@
             <div class="pay-content">
                 <div class="detail-item">
                     <div class="name">收款人</div>
-                    <div class="val">{{ fromUser.aliName }}</div>
+                    <div class="val">{{ fromUser ? fromUser.aliName : '' }}</div>
                 </div>
 
                 <div class="detail-item">
                     <div class="name">收款支付宝号</div>
-                    <div class="val">{{ fromUser.aliAccount }}</div>
+                    <div class="val">{{ fromUser ? fromUser.aliAccount : '' }}</div>
                 </div>
             </div>
 
@@ -157,6 +157,7 @@
 import { mapState } from 'vuex';
 import { orderStatus } from '../../status';
 import { parse } from 'date-fns';
+import { Dialog } from 'vant';
 export default {
     name: 'orderDetail',
     data() {
@@ -386,25 +387,33 @@ export default {
             }
         },
         applyShip() {
-            this.$toast.loading({
-                mask: false,
-                message: '加载中...',
-                duration: 0,
-                forbidClick: true
-            });
-            this.$http
-                .post('/order/applyShip', {
-                    orderId: this.orderInfo.id
+            this.$dialog
+                .confirm({
+                    title: '提示',
+                    message: '确认申请发货?'
                 })
-                .then(res => {
-                    this.$toast.success('申请成功');
-                    setTimeout(() => {
-                        this.getInfo();
-                    }, 1000);
+                .then(() => {
+                    this.$toast.loading({
+                        mask: false,
+                        message: '加载中...',
+                        duration: 0,
+                        forbidClick: true
+                    });
+                    this.$http
+                        .post('/order/applyShip', {
+                            orderId: this.orderInfo.id
+                        })
+                        .then(res => {
+                            this.$toast.success('申请成功');
+                            setTimeout(() => {
+                                this.getInfo();
+                            }, 1000);
+                        })
+                        .catch(e => {
+                            return this.$toast(e.error);
+                        });
                 })
-                .catch(e => {
-                    return this.$toast(e.error);
-                });
+                .catch(() => {});
         },
         receive() {
             this.$toast.loading({

+ 43 - 1
src/main/vue/src/views/OrderList.vue

@@ -72,7 +72,7 @@
             <el-table-column prop="cancelTime" label="取消时间" width="140"> </el-table-column>
             <el-table-column prop="confirmTime" label="确认时间" width="140"> </el-table-column>
             <el-table-column prop="delegateTime" label="托管时间" width="140"> </el-table-column>
-            <el-table-column label="操作" align="center" fixed="right" min-width="150">
+            <el-table-column label="操作" align="center" fixed="right" min-width="250">
                 <template slot-scope="{ row }">
                     <el-button
                         @click="shipRow(row)"
@@ -83,6 +83,15 @@
                     >
                         发货
                     </el-button>
+                    <el-button
+                        @click="cancelShip(row)"
+                        v-if="row.status == 'NOT_SHIPPED' || row.status == 'SHIPPED'"
+                        type="success"
+                        size="mini"
+                        plain
+                    >
+                        取消发货
+                    </el-button>
                     <!-- <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button> -->
                     <el-button @click="cancel(row)" type="danger" size="mini" plain v-if="row.status === 'NOT_PAID'">
                         取消订单
@@ -244,6 +253,39 @@ export default {
             };
             this.$refs.ship.show = true;
         },
+        cancelShip(row) {
+            this.$msgbox({
+                title: '提示',
+                message: '确定取消发货?',
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'info',
+                beforeClose: (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        instance.confirmButtonText = '执行中...';
+                        this.$http
+                            .post('/order/cancelShip', {
+                                orderId: row.id
+                            })
+                            .then(res => {
+                                instance.confirmButtonLoading = false;
+                                done();
+                                this.getData();
+                            })
+                            .catch(e => {
+                                instance.confirmButtonLoading = false;
+                                done();
+                                this.$message.error(e.error);
+                            });
+                    } else {
+                        done();
+                    }
+                }
+            })
+                .then(() => {})
+                .catch(() => {});
+        },
         editRow(row) {
             this.$router.push({
                 path: '/orderEdit',

+ 7 - 2
src/main/vue/src/views/ProductList.vue

@@ -14,6 +14,9 @@
                 <el-option label="未锁定" :value="1"></el-option>
                 <el-option label="已锁定" :value="2"></el-option>
             </el-select>
+            <el-select v-model="categoryId" class="filter-item" placeholder="筛选分类" clearable>
+                <el-option v-for="item in categoryList" :label="item.name" :value="item.id" :key="item.id"></el-option>
+            </el-select>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button>
             <el-radio-group
                 v-model="reserve"
@@ -141,7 +144,8 @@ export default {
             categoryList: [],
             reserveCount: 0,
             status: '',
-            locked: 1
+            locked: 1,
+            categoryId: null
         };
     },
     computed: {
@@ -170,7 +174,8 @@ export default {
                 query: {
                     reserve: this.reserve,
                     status: this.status,
-                    locked: this.locked === 1 ? false : true
+                    locked: this.locked === 1 ? false : true,
+                    categoryId: this.categoryId
                 }
             };
         },