123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- defined('InShopNC') or exit('Access Invalid!');
- class refill_taskModel extends Model
- {
- const DisposeState = 2;
- const FinishState = 3;
- const ErrState = 4;
- public function __construct()
- {
- parent::__construct('refill_task');
- }
- public function getRefillTaskList($condition, $pagesize = '', $field = '*', $order = 'add_time desc', $limit = '', $master = false)
- {
- $condition['is_del'] = 0;
- $list = $this->field($field)->where($condition)->page($pagesize)->order($order)->limit($limit)->master($master)->select();
- if (empty($list)) return [];
- return $list;
- }
- public function TaskInsert($data)
- {
- return $this->insert($data);
- }
- public function TaskHashCheck($hash): bool
- {
- $condition['is_del'] = 0;
- $condition['task_hash'] = $hash;
- return empty($this->where($condition)->find());
- }
- public function TaskUnDispose($task_type)
- {
- $condition['is_del'] = 0;
- $condition['task_state'] = 1;
- $condition['task_type'] = $task_type;
- $task = $this->where($condition)->order('add_time asc')->find();
- if (empty($task)) return [];
- return $task;
- }
- public function TaskDispose($task_id)
- {
- $condition['is_del'] = 0;
- $condition['task_id'] = $task_id;
- return $this->where($condition)->update(
- ['task_state' => self::DisposeState]
- );
- }
- public function TaskDisposeErr($task_id, $err_msg)
- {
- $condition['is_del'] = 0;
- $condition['task_id'] = $task_id;
- return $this->where($condition)->update(
- ['task_state' => self::ErrState, 'task_result' => $err_msg]
- );
- }
- public function TaskDisposeFinish($task_id, $result)
- {
- $condition['is_del'] = 0;
- $condition['task_id'] = $task_id;
- return $this->where($condition)->update(
- ['task_state' => self::FinishState, 'task_result' => $result]
- );
- }
- }
|