Browse Source

refill_task update

xiaoyu 3 years atrás
parent
commit
951c231b82

+ 3 - 2
admin/templates/default/provider.price.php

@@ -242,7 +242,7 @@
             }
         })
             newArr.forEach(item => {
-            htmll.push (item * 1)
+                html.push (item * 1)
         });
         function avg() {
 			let sum = 0;
@@ -251,6 +251,7 @@
 			}
 			return sum / arguments.length;
 		}
-            console.log(avg.apply(null, htmll));
+            let retain = avg.apply(null, html).toFixed(4);
+            console.log(retain);
     });
 </script>

+ 4 - 4
data/model/refill_task.model.php

@@ -33,14 +33,14 @@ class refill_taskModel extends Model
         return empty($this->where($condition)->find());
     }
 
-    public function TaskUnDisposeList($task_type)
+    public function TaskUnDispose($task_type)
     {
         $condition['is_del'] = 0;
         $condition['task_state'] = 1;
         $condition['task_type'] = $task_type;
-        $list = $this->where($condition)->page(1000)->order('add_time asc')->select();
-        if (empty($list)) return [];
-        return $list;
+        $task = $this->where($condition)->order('add_time asc')->find();
+        if (empty($task)) return [];
+        return $task;
     }
 
     public function TaskDispose($task_id)

+ 27 - 21
test/TestExportOrder.php

@@ -79,27 +79,33 @@ class TestExportOrder extends TestCase
     {
         $model_refill_task = Model('refill_task');
 
-        $task_list = $model_refill_task->TaskUnDisposeList('order_export');
-        foreach ($task_list as $task)
-        {
-            $type = $task['type'];
-            $task_id = $task['task_id'];
-            $task_condition = unserialize($task['task_condition']);
-            if(empty($task_condition)) continue;
-            if ($type === 'merchant') {
-                $task_condition['refill_order.mchid'] = $task['cid'];
-            } elseif ($type === 'provider') {
-                $task_condition['vr_order.store_id'] = $task['cid'];
-            } else {
-                continue;
-            }
-            $model_refill_task->TaskDispose($task_id);
-            [$state,$task_result] = $this->order_export($task_condition, $type, $task['task_id']);
-            if($state) {
-                $model_refill_task->TaskDisposeFinish($task_id, $task_result);
-            }else{
-                $model_refill_task->TaskDisposeErr($task_id, $task_result);
-            }
+        $task = $model_refill_task->TaskUnDispose('order_export');
+        if(empty($task)) return false;
+
+        $task_id = $task['task_id'];
+        $task_condition = unserialize($task['task_condition']);
+        if(empty($task_condition)) {
+            Log::record("refill task condition unserialize err, task_id:{$task_id}");
+            return false;
+        }
+
+        $type = $task['type'];
+        $cid = $task['cid'];
+        if ($type === 'merchant') {
+            $task_condition['refill_order.mchid'] = $cid;
+        } elseif ($type === 'provider') {
+            $task_condition['vr_order.store_id'] = $cid;
+        } else {
+            Log::record("refill task type err, task_id:{$task_id}");
+            return false;
+        }
+
+        $model_refill_task->TaskDispose($task_id);
+        [$state,$task_result] = $this->order_export($task_condition, $type, $task_id);
+        if($state) {
+            $model_refill_task->TaskDisposeFinish($task_id, $task_result);
+        }else{
+            $model_refill_task->TaskDisposeErr($task_id, $task_result);
         }
 
     }