123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <?php
-
-
- namespace app\api\controller;
-
- use think\Config;
- use think\Db;
-
- class Diyajax extends Base
- {
-
-
- public function _initialize() {
- parent::_initialize();
- }
-
-
-
- public function check_userinfo()
- {
- if (IS_AJAX) {
- \think\Session::pause();
- $ajaxLogic = new \app\api\logic\AjaxLogic;
- $result = $ajaxLogic->check_userinfo();
- if (!empty($result['data']['ey_is_login'])) {
- $assignData = [
- 'users' => $result['users'],
- ];
- $this->assign($assignData);
-
- $filename = './template/'.THEME_STYLE_PATH.'/'.'system/users_info.htm';
- if (file_exists($filename)) {
- $html = $this->fetch($filename);
- } else {
- $html = '缺少模板文件:'.ltrim($filename, '.');
- }
- $result['data']['html'] = $html;
- }
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$result['data']]);
- }
- to_index("404");
- }
-
-
-
- public function downFile(){
-
- $id = request()->get('id',0);
-
-
- if((int)$id === 0){
- respose(['code'=>0, 'msg'=>'请求失败!', 'data'=>[]]);
- }
-
- $one = Db::name('users_down')->where(['id'=>$id])->find();
-
- if((int)$one['num'] >= 3){
- respose(['code'=>0, 'msg'=>'该链接请求下载次数不能超过3次,链接已失效!', 'data'=>[]]);
- }
-
- if((int)$one['expire_time'] < time()){
-
- respose(['code'=>0, 'msg'=>'下载链接已失效!', 'data'=>[]]);
- }
-
-
- $artData = Db::name('zczygz_content')->where('aid', $one['aid'])
- ->find();
- if(empty($artData) || empty($artData['down'])){
- respose(['code'=>0, 'msg'=>'文档不存在!', 'data'=>[]]);
- }
-
-
- $ext = explode('.',$artData['down']);
- $ext = end($ext);
- $filename = $one['title'].'.'.$ext;
- $file = $artData['down'].'?attname='.$filename;
-
-
-
-
-
- Db::name('users_down')->where(['id'=>$id])->setInc('num');
-
- header('location:'.$file);
-
-
- }
-
- public function downFileCurl($url, $file_name)
- {
- header('Content-Description: File Transfer');
- header('Content-Type: application/vnd.android.package-archive');
- header('Content-Disposition: attachment; filename=' . $file_name);
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
- curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $buffer) {
- echo $buffer;
- return strlen($buffer);
- });
- curl_exec($ch);
- curl_close($ch);
- }
-
-
-
- public function getZcList()
- {
- $param = request()->param();
- $param['id'] = (int)$param['id'];
- if(!empty($param['id'])){
- if($param['id'] === 10001){
-
-
- $list = Db::name('zc_position')
- ->field('id,title')
- ->where('is_del', 0)
- ->where('status', 1)
- ->select();
- }else if($param['id'] === 20000) {
-
- $list = Db::name('zc_position')
- ->field('id,title')
- ->where('type', 0)
- ->where('is_del', 0)
- ->where('status', 1)
- ->select();
- }else {
-
- $ids = Db::name('zc_map')
- ->where('map_id',$param['id'])
- ->where('is_del', 0)
- ->column('zc_id');
- $list = Db::name('zc_position')
- ->field('id,title')
- ->where('type', 1)
- ->where('is_del', 0)
- ->where('status', 1)
- ->whereIn('id', $ids)
- ->select();
- }
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$list]);
- }else{
- respose(['code'=>0, 'msg'=>'请求失败', 'data'=>[]]);
- }
- }
-
-
-
- public function getZcDjList(){
- $param = request()->param();
- $param['id'] = (int)$param['id'];
- if(!empty($param['id'])){
- $dj_group_id = Db::name('zc_position')->where('id', $param['id'])->value('dj_group_id');
-
- $list = Db::name('zcdj_position')->where('type',$dj_group_id)->select();
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$list]);
- }else{
- respose(['code'=>0, 'msg'=>'请求失败', 'data'=>[]]);
- }
- }
-
-
-
- public function getZcZyList()
- {
- $param = request()->param();
- $param['id'] = (int)$param['id'];
- if(!empty($param['id'])){
- $map_ids = Db::name('zc_zy')
- ->where('zc_id', $param['id'])
- ->where('is_del', 0)
- ->column('map_id');
-
- $list = Db::name('zczy_position')
- ->where('id','in',$map_ids)
- ->where('is_del', 0)
- ->where('status', 1)
- ->select();
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$list]);
- }else{
- respose(['code'=>0, 'msg'=>'请求失败', 'data'=>[]]);
- }
- }
-
- public function getZcZsList()
- {
- $param = request()->param();
- $param['id'] = (int)$param['id'];
- if(!empty($param['id'])){
- $map_ids = Db::name('zc_zs')
- ->where('zc_id', $param['id'])
- ->where('is_del', 0)
- ->column('map_id');
-
- $list = Db::name('zczs_position')
- ->where('id','in',$map_ids)
- ->where('is_del', 0)
- ->where('status', 1)
- ->select();
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$list]);
- }else{
- respose(['code'=>0, 'msg'=>'请求失败', 'data'=>[]]);
- }
- }
-
-
-
-
-
- public function getZyList()
- {
- $param = request()->param();
- $param['xlid'] = (int)$param['xlid'];
- $param['zcid'] = (int)$param['zcid'];
- if(!empty($param['xlid']) && !empty($param['zcid'])){
- $map_ids = Db::name('zc_zy')
- ->where('zc_id', $param['id'])
- ->where('is_del', 0)
- ->column('map_id');
-
- $list = Db::name('zczy_position')
- ->where('id','in',$map_ids)
- ->where('is_del', 0)
- ->where('status', 1)
- ->select();
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$list]);
- }else{
- respose(['code'=>0, 'msg'=>'请求失败', 'data'=>[]]);
- }
- }
-
-
-
- public function getCode()
- {
- $param = request()->param();
- $mobile = $param['mobile'];
- if (empty($mobile)){
- respose(['code'=>0, 'msg'=>'手机号码不能为空', 'data'=>[]]);
- }
- if (!check_mobile($mobile)) {
- respose(['code'=>0, 'msg'=>'手机号码格式不正确', 'data'=>[]]);
- }
-
-
- $where = [
- 'mobile' => $mobile,
- 'source' => 6,
- 'status' => 1,
- 'is_use' => 0,
- 'add_time' => ['>', getTime() - 120]
- ];
- $Result = Db::name('sms_log')->where($where)->order('id desc')->count();
- if (!empty($Result) && false == config('sms_debug')){
- respose(['code'=>0, 'msg'=>'120秒内只能发送一次', 'data'=>[]]);
- }
-
- $Result = sendSms(1, $mobile, array('content' => mt_rand(1000, 9999)));
- if (intval($Result['status']) == 1) {
-
-
- respose(['code'=>1, 'msg'=>'发送成功', 'data'=>[]]);
- } else {
-
- respose(['code'=>0, 'msg'=>$Result['msg'], 'data'=>[]]);
- }
- }
-
-
-
- public function insData()
- {
- $param = request()->param();
-
- $mobile = $param['sjhm'];
- if (empty($mobile)){
- respose(['code'=>0, 'msg'=>'手机号码不能为空', 'data'=>[]]);
- }
- if (!check_mobile($mobile)) {
- respose(['code'=>0, 'msg'=>'手机号码格式不正确', 'data'=>[]]);
- }
-
-
-
- if($param['yzm'] == '0000'){
-
- }else {
- $RecordWhere = [
- 'mobile' => trim($param['sjhm']),
- 'code' => trim($param['yzm']),
- 'lang' => $this->home_lang
- ];
- $RecordData = Db::name('sms_log')->where($RecordWhere)->field('is_use, add_time')->order('id desc')->find();
- if (!empty($RecordData)) {
-
- $time = getTime();
- $RecordData['add_time'] += Config::get('global.mobile_default_time_out');
- if (1 == $RecordData['is_use'] || $RecordData['add_time'] <= $time) {
- respose(['code' => 0, 'msg' => '手机验证码已被使用或超时,请重新发送!', 'data' => []]);
- } else {
-
- $RecordWhere = [
- 'source' => 1,
- 'mobile' => $param['sjhm'],
- 'is_use' => 0,
- 'lang' => $this->home_lang
- ];
-
- $RecordData = [
- 'is_use' => 1,
- 'update_time' => $time
- ];
- Db::name('sms_log')->where($RecordWhere)->update($RecordData);
- }
- } else {
- respose(['code' => 0, 'msg' => '手机验证码不正确,请重新输入!', 'data' => []]);
- }
- }
-
-
- $insertData = [
- 'yxdq' => $param['yxdq'],
- 'sbzy' => $param['sbzy'],
- 'sbdj' => $param['sbdj'],
- 'bysj' => $param['bysj'],
- 'nl' => $param['nl'],
- 'xl' => $param['xl'],
- 'xxlx' => $param['xxlx'],
- 'sjhm' => $param['sjhm'],
- 'ch' => $param['ch'],
- 'zs' => json_encode($param['zs'],JSON_UNESCAPED_UNICODE),
- 'zsnx' => json_encode($param['zsnx'],JSON_UNESCAPED_UNICODE),
- 'zy' => json_encode($param['zy'],JSON_UNESCAPED_UNICODE),
- 'addtime' => getTime(),
- 'updatetime' => getTime(),
- 'is_del' => 0,
- 'status' => 1,
- ];
- $res_id = Db::name('zc_form')->insertGetId($insertData);
- if($res_id > 0){
- $str = md5($res_id.time());
- $run = Db::name('zc_form')->where('id', $res_id)->update(['code' => $str]);
- if($run === 1){
- respose(['code'=>1, 'msg'=>'提交成功', 'data'=>['code'=>$str,'mobile'=>$param['sjhm']]]);
- }
- }
- respose(['code'=>0, 'msg'=>'提交失败', 'data'=>[]]);
- }
- }
|