1
0
suochencheng 7 лет назад
Родитель
Сommit
2e457ddf90

+ 1 - 1
src/main/java/com/izouma/awesomeadmin/dao/OrderImageMapper.xml

@@ -825,7 +825,7 @@
             WHERE
             del_flag = 'N'
             AND status_flag >= 5
-            <![CDATA[AND confirm_time < DATE_ADD(NOW(), INTERVAL - 7 DAY)]]>
+            <![CDATA[AND confirm_time < DATE_ADD(NOW(), INTERVAL - (SELECT extra FROM system_config WHERE id=1) DAY)]]>
             )
             <if test="orderId != null and !&quot;&quot;.equals(orderId)">
                 and order_id = #{orderId}

+ 8 - 0
src/main/java/com/izouma/awesomeadmin/web/OrderImageController.java

@@ -708,6 +708,14 @@ public class OrderImageController {
         return orderImageService.autoCleanOrderImage(null);
     }
 
+    @RequestMapping(value = "/handCleanOrderImage", method = RequestMethod.POST)
+    @ResponseBody
+    @RequiresAuthentication
+    public Result handCleanOrderImage(OrderImage record) {
+
+        return orderImageService.autoCleanOrderImage(record);
+    }
+
     /**
      * 导出注释
      *

+ 8 - 0
src/main/resources/spring/appWebService.xml

@@ -24,4 +24,12 @@
 	<!-- 配置基于注解的声明事务 默认使用注解来管理事务行为 -->
 	<tx:annotation-driven transaction-manager="transactionManager" />
 
+	<task:annotation-driven/> <!-- 定时器开关-->
+	<!--自动清理OSS计划定时任务-->
+	<bean id="orderImageTask" class="com.izouma.awesomeadmin.web.OrderImageController"></bean>
+
+	<task:scheduled-tasks>
+		<task:scheduled ref="orderImageTask" method="autoCleanOrderImage" cron="0 0 2 * * ? "/>
+	</task:scheduled-tasks>
+
 </beans>

+ 1 - 1
src/main/vue/src/pages/SystemConfig.vue

@@ -13,7 +13,7 @@
             <el-form-item prop="companyDeposit" label="公司押金">
                 <el-input v-model="formData.companyDeposit" ></el-input>
             </el-form-item>
-            <el-form-item prop="extra" label="预留字段">
+            <el-form-item prop="extra" label="订单清理天数">
                 <el-input v-model="formData.extra" :disabled="'extra'==subColumn"></el-input>
             </el-form-item>
             <el-form-item prop="useFlag" label="启用标识">

+ 18 - 0
src/main/vue/src/pages/UserOrders.vue

@@ -121,6 +121,7 @@
                             </el-button>
                             <el-button @click="$router.push({path:'/OrderInvoices',query:{column:scope.row.id+',orderId'}})" type="primary" size="small" plain>发票
                             </el-button>
+                             <el-button @click="cleanOssRow(scope.row)" type="danger" size="mini" plain>清理OSS</el-button>
                         </el-dropdown-menu>
                     </el-dropdown>
                 </template>
@@ -640,6 +641,23 @@ export default {
                 }
             })
         },
+        cleanOssRow(row) {
+            this.$alert('清理OSS将无法恢复,确认要清理么?', '警告', { type: 'error' }).then(() => {
+                return this.$http.post({
+                    url: '/orderImage/handCleanOrderImage',
+                    data: { orderId: row.id }
+                })
+            }).then(() => {
+                this.$message.success('成功');
+                this.getData();
+            }).catch(action => {
+                if (action === 'cancel') {
+                    this.$message.info('取消');
+                } else {
+                    this.$message.error('失败');
+                }
+            })
+        },
         DateTimeFormatter(row, column, cellValue) {
             if (cellValue) {
                 return format(cellValue, 'YYYY/MM/DD HH:mm', { locale: zh })