post; // $token = isset($post['token']) ? trim($post['token']) : ""; // if ($token == "") { // return json_show(101, 'token不能为空'); // } $where = ['type' => 0]; $page = isset($post['page']) ? intval($post['page']) : 1; $size = isset($post['size']) ? intval($post['size']) : 10; $count = Db::name("exec_rela_com_no")->where($where)->count(); $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1; $page = $page >= $total ? intval($total) : $page; $list = Db::name("exec_rela_com_no")->where($where)->page($page, $size)->select(); return json_show(0, "获取成功", ["list" => $list, "count" => $count]); } public function nowlist() { $param = $this->request->only(['relaComNo', 'page' => 1, 'size' => 10, 'type' => 1], 'post', 'trim'); $val = Validate::rule([ 'relaComNo' => 'require', 'page' => 'require|number|gt:0', 'size' => 'require|number|gt:0|lt:99999', 'type' => 'require|number|in:1,2,3', ]); if (!$val->check($param)) return json_show(1005, $val->getError()); $count = Db::name("exec_rela_com_no") ->where(['relaComNo' => $param['relaComNo'], 'type' => $param['type']]) ->count('id'); $list = Db::name("exec_rela_com_no") ->where(['relaComNo' => $param['relaComNo'], 'type' => $param['type']]) ->page($param['page'], $param['size']) ->order('id') ->select() ->toArray(); return json_show(0, "获取成功", ["list" => $list, "count" => $count]); } public function save() { $param = $this->request->only(['start', 'end', 'id', 'relaComNo'], 'post', 'trim'); $val = Validate::rule([ 'start' => 'require|date|elt:end', 'end' => 'require|date|egt:start', 'id' => 'require|number|gt:0', 'relaComNo' => 'require', ]); if ($val->check($param) == false) return json_show(1004, $val->getError()); $temp = \app\admin\common\User::getIns()->handle('getCodeAndName', ['code' => $param['relaComNo']]); if (!isset($temp['data'][$param['relaComNo']]) || $temp['data'][$param['relaComNo']] == '') return json_show(1004, '业务公司编码不存在'); else $param['relaComName'] = $temp['data'][$param['relaComNo']]; // $post = $this->post; // $token = isset($post['token']) ? trim($post['token']) : ""; // if ($token == "") { // return json_show(101, 'token不能为空'); // } // $userinfo = GetUserInfo($token); // if (!isset($userinfo['code']) || $userinfo['code'] != 0) { // return json_show(101, '未能获取用户信息'); // } // $start = isset($post['start']) && $post['start'] != "" ? $post['start'] . " 00:00:00" : ''; // $end = isset($post['end']) && $post['end'] != "" ? $post['end'] . " 23:59:59" : ''; // $id = isset($post['id']) && $post['id'] !== '' ? intval($post['id']) : ""; // if ($id == "") { // return json_show(1004, "参数id不能为空"); // } $info = Db::name("exec_rela_com_no")->where(["id" => $param['id']])->find(); if (empty($info)) return json_show(1004, "未找到下载数据"); // if($info['type']==1){ // $num = Db::name("exec_rela_com_no")->where(["type" =>1,"status"=>1])->where("id","<>",$id)->count(); // if($num>0){ // return json_show(1004, "已有脚本在运行"); // } // } if ($info['relaComNo'] == $param['relaComNo'] && $info['start'] == $param['start'] && $info['end'] == $param['end']) return json_show(1004, "数据已提交"); // if ($start != "") { // $info['start'] = $start; // } // if ($end != "") { // $info['end'] = $end; // } if (is_file(root_path() . 'public' . $info['down_url'])) { @unlink(root_path() . "public" . $info['down_url']); } $info['relaComNo'] = $param['relaComNo']; $info['relaComName'] = $param['relaComName']; $info['status'] = 1; $info['apply_id'] = $this->uid; $info['apply_name'] = $this->uname; $info['down_url'] = ''; $info['remark'] = ''; $info['updatetime'] = date("Y-m-d H:i:s"); $info['addtime'] = date("Y-m-d H:i:s"); $info['expiretime'] = date("Y-m-d H:i:s", time() + 7 * 24 * 3600); $info['start'] = $param['start'] . ' 00:00:00'; $info['end'] = $param['end'] . ' 23:59:59'; $up = Db::name("exec_rela_com_no") ->where('id', $param['id']) ->update($info); if ($up) { Cache::store("redis")->handler()->lPush($this->redis_key, json_encode($info)); return json_show(0, "编辑成功"); } else return json_show(0, "编辑失败"); // return $up ? json_show(0, "编辑成功") : json_show(1004, "编辑失败"); } public function down() { $post = $this->post; // $token = isset($post['token']) ? trim($post['token']) : ""; // if ($token == "") { // return json_show(101, 'token不能为空'); // } $id = isset($post['id']) && $post['id'] !== '' ? intval($post['id']) : ""; if ($id == "") { return json_show(1004, "参数id不能为空"); } $info = Db::name("exec_rela_com_no")->where(["id" => $id])->find(); if (empty($info)) { return json_show(1004, "未找到下载数据"); } // if ($info['type'] == 1) { // $num = Db::name("exec_rela_com_no")->where(["type" => 1, "status" => 1])->count(); // if ($num > 0) { // return json_show(1004, "已有脚本在运行"); // } // } // $effetc = VerifyTokens($token); // if(!empty($effetc) && $effetc['code']!=0){ // return json_show($effetc['code'],$effetc['message']); // } // $userinfo = GetUserInfo($token); // if (!isset($userinfo['code']) || $userinfo['code'] != 0) { // return json_show(101, '未能获取用户信息'); // } $info['status'] = 1; $info['down_url'] = ''; $info['remark'] = ''; $info['apply_id'] = $this->uid; $info['apply_name'] = $this->uname; $info['expiretime'] = date("Y-m-d H:i:s", time() + 7 * 24 * 3600); $info['updatetime'] = date("Y-m-d H:i:s"); $info['addtime'] = date("Y-m-d H:i:s"); $up = Db::name("exec_rela_com_no")->save($info); $redis = Cache::store("redis")->handler()->lPush($this->redis_key, json_encode($info)); return $up ? json_show(0, "编辑成功") : json_show(1004, "编辑失败"); } }