暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZcwePosition.php 46KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\controller;
  14. use think\Page;
  15. use think\Db;
  16. use think\Cache;
  17. class ZcwePosition extends Base
  18. {
  19. private $ad_position_system_id = array(); // 系统默认位置ID,不可删除
  20. public function _initialize() {
  21. parent::_initialize();
  22. }
  23. public function index()
  24. {
  25. $list = array();
  26. $get = input('get.');
  27. $keywords = input('keywords/s');
  28. $condition = [];
  29. // 应用搜索条件
  30. foreach (['keywords', 'type'] as $key) {
  31. $get[$key] = addslashes(trim($get[$key]));
  32. if (isset($get[$key]) && $get[$key] !== '') {
  33. if ($key == 'keywords') {
  34. $condition['a.title'] = array('LIKE', "%{$get[$key]}%");
  35. } else {
  36. $tmp_key = 'a.'.$key;
  37. $condition[$tmp_key] = array('eq', $get[$key]);
  38. }
  39. }
  40. }
  41. // 多语言
  42. //$condition['a.lang'] = array('eq', $this->admin_lang);
  43. $adPositionM = Db::name('zcwe_position');
  44. $count = $adPositionM->alias('a')->where($condition)->count();// 查询满足要求的总记录数
  45. $Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  46. $list = $adPositionM->alias('a')->where($condition)
  47. ->order('type desc,xlyq desc,id desc')
  48. ->limit($Page->firstRow.','.$Page->listRows)->getAllWithIndex('id');
  49. //var_dump($condition);die;
  50. // 每组获取三张图片
  51. $pids = get_arr_column($list, 'id');
  52. $ad = Db::name('zcwd')
  53. ->where(['pid' => ['IN', $pids], 'lang' => $this->admin_lang])
  54. ->order('pid asc, id asc')
  55. ->select();
  56. foreach ($list as $k => $v) {
  57. /*
  58. if (1 == $v['type']) {
  59. // 图片封面图片
  60. $v['ad'] = [];
  61. foreach ($ad as $m => $n) {
  62. if ($v['id'] == $n['pid']) {
  63. $n['litpic'] = get_default_pic($n['litpic']); // 支持子目录
  64. $v['ad'][] = $n;
  65. unset($ad[$m]);
  66. } else {
  67. continue;
  68. }
  69. }
  70. // 若没有内容则显示默认图片
  71. if (empty($v['ad'])) {
  72. $v['ad_count'] = 0;
  73. $v['ad'][]['litpic'] = ROOT_DIR . '/public/static/common/images/not_adv.jpg';
  74. } else {
  75. $v['ad_count'] = count($v['ad']);
  76. }
  77. // 广告类型
  78. $v['type_name'] = '图片';
  79. } else if (2 == $v['type']) {
  80. // 多媒体封面图片
  81. $v['ad'][]['litpic'] = ROOT_DIR . '/public/static/admin/images/ad_type_media.png';
  82. // 广告类型
  83. $v['type_name'] = '多媒体';
  84. } else if (3 == $v['type']) {
  85. // HTML代码封面图片
  86. $v['ad'][]['litpic'] = ROOT_DIR . '/public/static/admin/images/ad_type_html.png';
  87. // 广告类型
  88. $v['type_name'] = 'HTML代码';
  89. }*/
  90. //处理颜色
  91. if((int)$temp_id !== (int)$v['type']){
  92. $red = mt_rand(0, 255);
  93. $green = mt_rand(0, 255);
  94. $blue = mt_rand(0, 255);
  95. $t_color = sprintf("#%02x%02x%02x", $red, $green, $blue);
  96. }
  97. $temp_id = (int)$v['type'];
  98. //处理图片
  99. $v['ad'] = [];
  100. foreach ($ad as $m => $n) {
  101. if ($v['id'] == $n['pid']) {
  102. $n['litpic'] = get_default_pic($n['litpic']); // 支持子目录
  103. $v['ad'][] = $n;
  104. unset($ad[$m]);
  105. } else {
  106. continue;
  107. }
  108. }
  109. // 若没有内容则显示默认图片
  110. if (empty($v['ad'])) {
  111. $v['ad_count'] = 0;
  112. $v['ad'][]['litpic'] = ROOT_DIR . '/public/static/common/images/not_adv.jpg';
  113. } else {
  114. $v['ad_count'] = count($v['ad']);
  115. }
  116. //获取地区
  117. $one = Db::name('citysite')
  118. ->where(['id'=>$v['type']])
  119. ->find();
  120. $v['type_name'] = $one['name'];
  121. $v['color'] = $t_color;
  122. $list[$k] = $v;
  123. }
  124. $show = $Page->show();// 分页显示输出
  125. $this->assign('page',$show);// 赋值分页输出
  126. $this->assign('list',$list);// 赋值数据集
  127. $this->assign('pager',$Page);// 赋值分页对象
  128. /*多语言模式下,广告位ID显示主体语言的ID和属性title名称*/
  129. $main_adv_list = [];
  130. if ($this->admin_lang != $this->main_lang && empty($this->globalConfig['language_split'])) {
  131. $attr_values = get_arr_column($list, 'id');
  132. $languageAttrRow = Db::name('language_attr')->field('attr_name,attr_value')->where([
  133. 'attr_value' => ['IN', $attr_values],
  134. 'attr_group' => 'ad_position',
  135. 'lang' => $this->admin_lang,
  136. ])->getAllWithIndex('attr_value');
  137. $ids = [];
  138. foreach ($languageAttrRow as $key => $val) {
  139. $tid_tmp = str_replace('adp', '', $val['attr_name']);
  140. array_push($ids, intval($tid_tmp));
  141. }
  142. $main_advRow = Db::name('zcwe_position')->field("id,title,CONCAT('adp', id) AS attr_name")
  143. ->where([
  144. 'id' => ['IN', $ids],
  145. 'lang' => $this->main_lang,
  146. ])->getAllWithIndex('attr_name');
  147. foreach ($list as $key => $val) {
  148. $key_tmp = !empty($languageAttrRow[$val['id']]['attr_name']) ? $languageAttrRow[$val['id']]['attr_name'] : '';
  149. $main_adv_list[$val['id']] = [
  150. 'id' => !empty($main_advRow[$key_tmp]['id']) ? $main_advRow[$key_tmp]['id'] : '',
  151. 'title' => !empty($main_advRow[$key_tmp]['title']) ? $main_advRow[$key_tmp]['title'] : '',
  152. ];
  153. }
  154. }
  155. $this->assign('main_adv_list', $main_adv_list);
  156. /*end*/
  157. //查找区域数据
  158. $pro_list = Db::name('citysite')->where(['level'=>1,'is_open'=>1])->select();
  159. //var_dump($pro_list);
  160. $this->assign('pro_list', $pro_list);
  161. return $this->fetch();
  162. }
  163. /*
  164. * 获取区域
  165. */
  166. public function getCity(){
  167. $id = request()->post('id');
  168. //查找子集城市
  169. $list = Db::name('citysite')->where(['status'=>1,'parent_id'=>$id])->select();
  170. $html = '<option value="0">选择市</option>';
  171. foreach ($list as $k=>$v){
  172. $html .= '<option value="'.$v['id'].'">'.$v['name'].'</option>';
  173. }
  174. $data = [
  175. 'code' => 0,
  176. 'msg' => '获取成功',
  177. 'data' => $html,
  178. ];
  179. return json($data);
  180. }
  181. /**
  182. * 新增
  183. */
  184. public function add()
  185. {
  186. //防止php超时
  187. function_exists('set_time_limit') && set_time_limit(0);
  188. if (is_language() && empty($this->globalConfig['language_split'])) {
  189. $this->language_access(); // 多语言功能操作权限
  190. }
  191. if (IS_POST) {
  192. $post = input('post.');
  193. /*
  194. * array(11) { ["title"]=> string(12) "建筑职称" ["type"]=> string(1) "1" ["img_id"]=> array(1) { [0]=> string(0) "" } ["img_litpic"]=> array(1) { [0]=> string(67) "https://oss.zcwd10000.com/uploads/allimg/20240528/1-24052R01005Z4.png" } ["img_title"]=> array(1) { [0]=> string(0) "" } ["img_links"]=> array(1) { [0]=> string(0) "" } ["img_intro"]=> array(1) { [0]=> string(0) "" } ["img_target"]=> array(1) { [0]=> string(1) "0" } ["video_litpic"]=> string(0) "" ["html_intro"]=> string(0) "" ["intro"]=> string(0) "" }
  195. */
  196. //var_dump($post);die;
  197. if((int)$post['byzy'] === 0){
  198. $post['zhengshu2'] = '';
  199. }
  200. if(empty($post['zhengshu2'])){
  201. $post['zhengshu2'] = '';
  202. }
  203. //验证是否已经有重复的
  204. $one = Db::name('zcwe_position')->where([
  205. 'type' => $post['type'], //规则id
  206. 'xlyq' => $post['xlyq'], //学历要求
  207. 'is_ega' => $post['is_ega'],
  208. 'ega_0' => $post['ega'][0],
  209. 'ega_1' => $post['ega'][1],
  210. 'byzy' => $post['byzy'], //毕业专业 是否要求
  211. 'zhengshu2' => json_encode($post['zhengshu2']),
  212. 'xxlx' => $post['xxlx'], //学校要求
  213. 'bysj' => $post['bysj'], //毕业时间
  214. 'bysj_time' => $post['bysj_time'],
  215. 'is_del' => 0,
  216. ])->find();
  217. if(!empty($one)){
  218. $this->error('该规则已存在,请检查!', url('ZcwePosition/index'));
  219. }
  220. //拼装title $post['type']
  221. $post['title'] = '';
  222. if((int)$post['type'] > 0){
  223. $row = Db::name('zcwd_position')->where(['id'=>$post['type']])->find();
  224. $post['title'] .= $row['title'];
  225. }
  226. $less = ['','中专','高技','大专','本科','硕士','博士'];
  227. $post['title'] .= '-'.$less[(int)$post['xlyq']];
  228. //允许重复
  229. /*$map = array(
  230. 'title' => trim($post['title']),
  231. 'lang' => $this->admin_lang,
  232. );
  233. if(Db::name('zcwe_position')->where($map)->count() > 0){
  234. $this->error('该规则名称已存在,请检查', url('ZcwePosition/index'));
  235. }*/
  236. //处理年龄
  237. if((int)$post['is_ega'] > 0){
  238. if((int)$post['ega'][0] >= (int)$post['ega'][1]){
  239. $this->error('请输入正确的年龄区间,请检查', url('ZcwePosition/index'));
  240. }
  241. }
  242. // 添加广告位置表信息
  243. $data = array(
  244. 'title' => trim($post['title']),
  245. 'type' => $post['type'], //规则ID
  246. 'intro' => '0', //备注
  247. 'admin_id' => session('admin_id'),
  248. 'lang' => $this->admin_lang,
  249. 'add_time' => getTime(),
  250. 'update_time' => getTime(),
  251. 'sf' => 0,
  252. 'cs' => 0,
  253. 'sbdj' => 0,
  254. 'is_ega' => $post['is_ega'],
  255. 'ega_0' => $post['ega'][0],
  256. 'ega_1' => $post['ega'][1],
  257. 'byzy' => $post['byzy'],
  258. 'zhengshu2' => json_encode($post['zhengshu2']),
  259. 'xlyq' => $post['xlyq'],
  260. 'xxlx' => $post['xxlx'],
  261. 'bysj' => $post['bysj'],
  262. 'bysj_time' => $post['bysj_time'],
  263. 'is_zs' => 0,
  264. 'zhengshu' => '',
  265. 'sjnx' => 0,
  266. 'gzyq' => '',
  267. 'qttj' => '0',
  268. );
  269. $insertID = Db::name('zcwe_position')->insertGetId($data);
  270. if (!empty($insertID)) {
  271. // 同步广告位置ID到多语言的模板变量里,添加多语言广告位
  272. //$this->syn_add_language_attribute($insertID);
  273. // 读取组合广告位的图片及信息
  274. $AdData = [];
  275. if (!empty($post['img_litpic'])) { // 图片类型
  276. $i = 1;
  277. foreach ($post['img_litpic'] as $key => $value) {
  278. if (!empty($value)) {
  279. // 去掉http:
  280. $value = str_replace("http:", "", $value);
  281. // 去掉https:
  282. $value = str_replace("https:", "", $value);
  283. // 主要参数
  284. $AdData['litpic'] = $value;
  285. $AdData['pid'] = $insertID;
  286. $AdData['title'] = trim($post['img_title'][$key]);
  287. $AdData['links'] = $post['img_links'][$key];
  288. $AdData['intro'] = $post['img_intro'][$key];
  289. $target = !empty($post['img_target'][$key]) ? 1 : 0;
  290. $AdData['target'] = $target;
  291. // 其他参数
  292. $AdData['media_type'] = 1;
  293. $AdData['admin_id'] = session('admin_id');
  294. $AdData['lang'] = $this->admin_lang;
  295. $AdData['sort_order'] = $i++;
  296. $AdData['add_time'] = getTime();
  297. $AdData['update_time'] = getTime();
  298. // 添加到广告图表
  299. $ad_id = Db::name('zcwd')->add($AdData);
  300. // 同步多语言
  301. //$this->syn_add_ad_language_attribute($ad_id);
  302. }
  303. }
  304. }
  305. //Cache::clear('ad');
  306. adminLog('新增职称:'.$post['title']);
  307. $this->success("操作成功", url('ZcwePosition/index'));
  308. } else {
  309. $this->error("操作失败", url('ZcwePosition/index'));
  310. }
  311. }
  312. // 上传通道
  313. $WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
  314. $WeappOpen = [];
  315. foreach ($WeappConfig as $value) {
  316. if ('Qiniuyun' == $value['code']) {
  317. $WeappOpen['qny_open'] = $value['status'];
  318. } else if ('AliyunOss' == $value['code']) {
  319. $WeappOpen['oss_open'] = $value['status'];
  320. } else if ('Cos' == $value['code']) {
  321. $WeappOpen['cos_open'] = $value['status'];
  322. }
  323. }
  324. $this->assign('WeappOpen', $WeappOpen);
  325. // 系统最大上传视频的大小
  326. $upload_max_filesize = upload_max_filesize();
  327. $this->assign('upload_max_filesize', $upload_max_filesize);
  328. // 视频类型
  329. $media_type = tpCache('global.media_type');
  330. $media_type = !empty($media_type) ? $media_type : config('global.media_ext');
  331. $media_type = str_replace(",", "|", $media_type);
  332. $this->assign('media_type', $media_type);
  333. //查找区域数据
  334. $pro_list = Db::name('citysite')->where(['level'=>1,'is_open'=>1])->select();
  335. //var_dump($pro_list);
  336. $this->assign('pro_list', $pro_list);
  337. //查找职称数据
  338. $pos = Db::name('zc_position')->where(['is_del'=>0])->select();
  339. //var_dump($pos);
  340. $this->assign('pos_list', $pos);
  341. $param = request()->param();
  342. //读取规则详情
  343. $row = Db::name('zcwd_position')->where(['id'=>$param['id']])->find();
  344. $this->assign('detail', $row);
  345. $this->assign('rule_id', $param['id']);
  346. //读取毕业专业详情
  347. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$row['type'],'is_del'=>0])->column('map_id');
  348. $listwww = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  349. //var_dump($listwww);
  350. $html = '';
  351. $arr = json_decode($row['zhengshu2'],true);
  352. foreach ($listwww as $key => $value) {
  353. if(in_array($value['id'],$arr)){
  354. $checked = 'checked';
  355. }else{
  356. $checked = '';
  357. }
  358. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  359. }
  360. if(empty($html)){
  361. $html = '请先添加相关毕业专业';
  362. }
  363. $this->assign('byzy_html',$html);
  364. return $this->fetch();
  365. }
  366. public function getZs()
  367. {
  368. $id = request()->post('id',0);
  369. //读取证书
  370. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$id,'is_del'=>0])->column('map_id');
  371. $list = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  372. $html = '';
  373. foreach ($list as $key => $value) {
  374. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu[]" value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  375. }
  376. if(empty($html)){
  377. $html = '<font style="color:red;">请先绑定申报专业相关的证书才能进行选择!</font>';
  378. }
  379. $data = [
  380. 'code' => 0,
  381. 'msg' => '查询成功',
  382. 'data' => $html
  383. ];
  384. return json($data);
  385. }
  386. public function getZs2()
  387. {
  388. $id = request()->post('id',0);
  389. //读取证书
  390. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$id,'is_del'=>0])->column('map_id');
  391. $list = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  392. $html = '';
  393. foreach ($list as $key => $value) {
  394. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  395. }
  396. if(empty($html)){
  397. $html = '<font style="color:red;">请先绑定申报专业相关的毕业专业才能进行选择!</font>';
  398. }
  399. $data = [
  400. 'code' => 0,
  401. 'msg' => '查询成功',
  402. 'data' => $html
  403. ];
  404. return json($data);
  405. }
  406. public function getMap($sid='')
  407. {
  408. if($sid == ''){
  409. $id = request()->post('id',0);
  410. }else{
  411. $id = $sid;
  412. }
  413. //查找区域
  414. $map_ids = Db::name('zc_map')
  415. ->where('zc_id','=',$id)
  416. ->where('is_del','=',0)
  417. ->column('map_id');
  418. //获取地区
  419. $list = Db::name('citysite')
  420. ->where('id','in',$map_ids)
  421. ->select();
  422. $type_name = '';
  423. foreach ($list as $k2 => $v2) {
  424. $type_name .= $v2['name'].',';
  425. }
  426. if(empty($type_name)){
  427. $type_name = '全国';
  428. }
  429. $data = [
  430. 'code' => 0,
  431. 'msg' => '获取成功',
  432. 'data' => $type_name,
  433. ];
  434. if($sid == ''){
  435. return json($data);
  436. }else{
  437. return $type_name;
  438. }
  439. }
  440. /**
  441. * 编辑
  442. */
  443. public function edit()
  444. {
  445. if (IS_POST) {
  446. $post = input('post.');
  447. if (!empty($post['id'])) {
  448. $post['id'] = intval($post['id']);
  449. if (array_key_exists($post['id'], $this->ad_position_system_id)) {
  450. $this->error("不可更改系统预定义位置", url('ZcwePosition/edit',array('id'=>$post['id'])));
  451. }
  452. if((int)$post['byzy'] === 0){
  453. $post['zhengshu2'] = '';
  454. }
  455. if(empty($post['zhengshu2'])){
  456. $post['zhengshu2'] = '';
  457. }
  458. //验证是否已经有重复的 排除自身ID
  459. $one = Db::name('zcwe_position')->where([
  460. 'type' => $post['type'], //规则id
  461. 'xlyq' => $post['xlyq'], //学历要求
  462. 'is_ega' => $post['is_ega'],
  463. 'ega_0' => $post['ega'][0],
  464. 'ega_1' => $post['ega'][1],
  465. 'byzy' => $post['byzy'], //毕业专业 是否要求
  466. 'zhengshu2' => json_encode($post['zhengshu2']),
  467. 'xxlx' => $post['xxlx'], //学校要求
  468. 'bysj' => $post['bysj'], //毕业时间
  469. 'bysj_time' => $post['bysj_time'],
  470. 'is_del' => 0,
  471. ])->where('id','<>',$post['id'])->find();
  472. if(!empty($one)){
  473. $this->error('该规则已存在,请检查!', url('ZcwePosition/index'));
  474. }
  475. //拼装title $post['type']
  476. $post['title'] = '';
  477. if((int)$post['type'] > 0){
  478. $row = Db::name('zcwd_position')->where(['id'=>$post['type']])->find();
  479. $post['title'] .= $row['title'];
  480. }
  481. $less = ['','中专','高技','大专','本科','硕士','博士'];
  482. $post['title'] .= '-'.$less[(int)$post['xlyq']];
  483. /* 判断除自身外是否还有相同广告名称已存在 */
  484. /*$map = array(
  485. 'id' => array('NEQ', $post['id']),
  486. 'title' => trim($post['title']),
  487. //'lang' => $this->admin_lang,
  488. );
  489. if (Db::name('zcwe_position')->where($map)->count() > 0) $this->error('该职称名称已存在,请检查');*/
  490. //处理年龄
  491. if((int)$post['is_ega'] > 0){
  492. if((int)$post['ega'][0] >= (int)$post['ega'][1]){
  493. $this->error('请输入正确的年龄区间,请检查', url('ZcwePosition/index'));
  494. }
  495. }
  496. /* END */
  497. /* 判断广告是否切换广告类型 */
  498. // $where = [
  499. // 'id' => $post['id'],
  500. // 'type' => $post['type'],
  501. // 'lang' => $this->admin_lang
  502. // ];
  503. // if (Db::name('zcwe_position')->where($where)->count() == 0) {
  504. // // 已切换广告类型,清除广告中的广告内容
  505. // $where = [
  506. // 'pid' => $post['id'],
  507. // 'lang' => $this->admin_lang
  508. // ];
  509. // Db::name('zcwd')->where($where)->delete();
  510. // }
  511. /* END */
  512. /* 修改广告主体信息 */
  513. $data = array(
  514. 'id' => $post['id'],
  515. 'title' => trim($post['title']),
  516. 'type' => $post['type'], //规则id
  517. 'intro' => '0',
  518. 'update_time' => getTime(),
  519. 'sf' => 0,
  520. 'cs' => 0,
  521. 'sbdj' => 0,
  522. 'is_ega' => $post['is_ega'],
  523. 'ega_0' => $post['ega'][0],
  524. 'ega_1' => $post['ega'][1],
  525. 'byzy' => $post['byzy'],
  526. 'zhengshu2' => json_encode($post['zhengshu2']),
  527. 'xlyq' => $post['xlyq'],
  528. 'xxlx' => $post['xxlx'],
  529. 'bysj' => $post['bysj'],
  530. 'bysj_time' => $post['bysj_time'],
  531. 'is_zs' => 0,
  532. 'zhengshu' => '',
  533. 'sjnx' => 0,
  534. 'gzyq' => '',
  535. 'qttj' => '0',
  536. );
  537. $resultID = Db::name('zcwe_position')->update($data);
  538. /* END */
  539. }
  540. if (!empty($resultID)) {
  541. $ad_db = Db::name('zcwd');
  542. if (!empty($post['img_litpic'])) { // 图片类型
  543. // 读取组合广告位的图片及信息
  544. $i = 1;
  545. foreach ($post['img_litpic'] as $key => $value) {
  546. if (!empty($value)) {
  547. // 去掉http:
  548. $value = str_replace("http:", "", $value);
  549. // 去掉https:
  550. $value = str_replace("https:", "", $value);
  551. // 是否新窗口打开
  552. $target = !empty($post['img_target'][$key]) ? 1 : 0;
  553. // 广告位ID,为空则表示添加
  554. $ad_id = $post['img_id'][$key];
  555. if (!empty($ad_id)) {
  556. // 查询更新条件
  557. $where = [
  558. 'id' => $ad_id,
  559. 'lang' => $this->admin_lang,
  560. ];
  561. if ($ad_db->where($where)->count() > 0) {
  562. // 主要参数
  563. $AdData['litpic'] = $value;
  564. $AdData['title'] = $post['img_title'][$key];
  565. $AdData['links'] = $post['img_links'][$key];
  566. $AdData['intro'] = $post['img_intro'][$key];
  567. $AdData['target'] = $target;
  568. // 其他参数
  569. $AdData['sort_order'] = $i++;
  570. $AdData['update_time'] = getTime();
  571. // 更新,不需要同步多语言
  572. $ad_db->where($where)->update($AdData);
  573. } else {
  574. // 主要参数
  575. $AdData['litpic'] = $value;
  576. $AdData['pid'] = $post['id'];
  577. $AdData['title'] = $post['img_title'][$key];
  578. $AdData['links'] = $post['img_links'][$key];
  579. $AdData['intro'] = $post['img_intro'][$key];
  580. $AdData['target'] = $target;
  581. // 其他参数
  582. $AdData['media_type'] = 1;
  583. $AdData['admin_id'] = session('admin_id');
  584. $AdData['lang'] = $this->admin_lang;
  585. $AdData['sort_order'] = $i++;
  586. $AdData['add_time'] = getTime();
  587. $AdData['update_time'] = getTime();
  588. $ad_id = $ad_db->add($AdData);
  589. // 同步多语言
  590. //$this->syn_add_ad_language_attribute($ad_id);
  591. }
  592. } else {
  593. // 主要参数
  594. $AdData['litpic'] = $value;
  595. $AdData['pid'] = $post['id'];
  596. $AdData['title'] = $post['img_title'][$key];
  597. $AdData['links'] = $post['img_links'][$key];
  598. $AdData['intro'] = $post['img_intro'][$key];
  599. $AdData['target'] = $target;
  600. // 其他参数
  601. $AdData['media_type'] = 1;
  602. $AdData['admin_id'] = session('admin_id');
  603. $AdData['lang'] = $this->admin_lang;
  604. $AdData['sort_order'] = $i++;
  605. $AdData['add_time'] = getTime();
  606. $AdData['update_time'] = getTime();
  607. $ad_id = $ad_db->add($AdData);
  608. // 同步多语言
  609. //$this->syn_add_ad_language_attribute($ad_id);
  610. }
  611. }
  612. }
  613. }
  614. //Cache::clear('ad');
  615. adminLog('编辑职称名称:'.$post['title']);
  616. $this->success("操作成功", url('ZcwePosition/index'));
  617. } else {
  618. $this->error("操作失败");
  619. }
  620. }
  621. $assign_data = array();
  622. $id = input('id/d');
  623. $field = Db::name('zcwe_position')->field('a.*')->alias('a')->where(array('a.id'=>$id))->find();
  624. if (empty($field)) $this->error('职称不存在,请联系管理员!');
  625. switch ($field['type']) {
  626. case '1':
  627. $field['type_name'] = '图片';
  628. break;
  629. case '2':
  630. $field['type_name'] = '多媒体';
  631. break;
  632. case '3':
  633. $field['type_name'] = 'HTML代码';
  634. break;
  635. }
  636. $assign_data['field'] = $field;
  637. // 广告
  638. $ad_data = Db::name('zcwd')->where(array('pid'=>$field['id']))->order('sort_order asc')->select();
  639. foreach ($ad_data as $key => $val) {
  640. if (1 == $val['media_type']) {
  641. $ad_data[$key]['litpic'] = get_default_pic($val['litpic']); // 支持子目录
  642. }
  643. }
  644. $assign_data['ad_data'] = $ad_data;
  645. // 上传通道
  646. $WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
  647. $WeappOpen = [];
  648. foreach ($WeappConfig as $value) {
  649. if ('Qiniuyun' == $value['code']) {
  650. $WeappOpen['qny_open'] = $value['status'];
  651. } else if ('AliyunOss' == $value['code']) {
  652. $WeappOpen['oss_open'] = $value['status'];
  653. } else if ('Cos' == $value['code']) {
  654. $WeappOpen['cos_open'] = $value['status'];
  655. }
  656. }
  657. $this->assign('WeappOpen', $WeappOpen);
  658. // 系统最大上传视频的大小
  659. $file_size = tpCache('global.file_size');
  660. $postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
  661. $fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
  662. $min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
  663. $min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
  664. $upload_max_filesize = intval($min_size) * 1024 * 1024;
  665. $assign_data['upload_max_filesize'] = $upload_max_filesize;
  666. // 视频类型
  667. $media_type = tpCache('global.media_type');
  668. $media_type = !empty($media_type) ? $media_type : config('global.media_ext');
  669. $media_type = str_replace(",", "|", $media_type);
  670. $assign_data['media_type'] = $media_type;
  671. //查找区域数据
  672. $pro_list = Db::name('citysite')->where(['level'=>1,'is_open'=>1])->select();
  673. //var_dump($pro_list);
  674. $this->assign('pro_list', $pro_list);
  675. $this->assign('curr_id', $field['type']);
  676. //查找职称数据
  677. $pos = Db::name('zc_position')->where(['is_del'=>0])->select();
  678. //var_dump($pos);
  679. $this->assign('pos_list', $pos);
  680. $tn = $this->getMap($field['type']);
  681. $this->assign('tn',$tn);
  682. if((int)$field['cs'] > 0) {
  683. $csn = Db::name('citysite')->where(['id' => $field['cs']])->value('name');
  684. $this->assign('csn',$csn);
  685. }
  686. $pro_list2 = Db::name('citysite')->where(['parent_id'=>$field['sf']])->select();
  687. //var_dump($pro_list2);
  688. $this->assign('pro_list2', $pro_list2);
  689. $this->assign('curr_id2', $field['cs']);
  690. if((int)$field['byzy'] > 0) {
  691. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$field['type'],'is_del'=>0])->column('map_id');
  692. $listwww = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  693. $html = '';
  694. $arr = json_decode($field['zhengshu2'],true);
  695. foreach ($listwww as $key => $value) {
  696. if(in_array($value['id'],$arr)){
  697. $checked = 'checked';
  698. }else{
  699. $checked = '';
  700. }
  701. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  702. }
  703. $this->assign('byzy_html',$html);
  704. }
  705. if((int)$field['is_zs'] > 0) {
  706. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$field['type'],'is_del'=>0])->column('map_id');
  707. $listwww = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  708. $html = '';
  709. $arr = json_decode($field['zhengshu'],true);
  710. foreach ($listwww as $key => $value) {
  711. if(in_array($value['id'],$arr)){
  712. $checked = 'checked';
  713. }else{
  714. $checked = '';
  715. }
  716. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  717. }
  718. $this->assign('zs_html',$html);
  719. }
  720. $gzyq = json_decode($field['gzyq'],true);
  721. $this->assign('gzyq',$gzyq);
  722. $param = request()->param();
  723. //读取规则详情
  724. $row = Db::name('zcwd_position')->where(['id'=>$field['type']])->find();
  725. $this->assign('detail', $row);
  726. $this->assign('rule_id',$field['type']);
  727. //读取毕业专业详情
  728. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$row['type'],'is_del'=>0])->column('map_id');
  729. $listwww = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  730. //var_dump($listwww);
  731. $html = '';
  732. $arr = json_decode($field['zhengshu2'],true);
  733. foreach ($listwww as $key => $value) {
  734. if(in_array($value['id'],$arr)){
  735. $checked = 'checked';
  736. }else{
  737. $checked = '';
  738. }
  739. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  740. }
  741. if(empty($html)){
  742. $html = '请先添加相关毕业专业';
  743. }
  744. $this->assign('byzy_html',$html);
  745. $this->assign($assign_data);
  746. return $this->fetch();
  747. }
  748. /**
  749. * 删除广告图片
  750. */
  751. public function del_imgupload()
  752. {
  753. if (is_language() && empty($this->globalConfig['language_split'])) {
  754. $this->language_access(); // 多语言功能操作权限
  755. }
  756. $id_arr = input('del_id/a');
  757. $id_arr = eyIntval($id_arr);
  758. if(IS_POST && !empty($id_arr)){
  759. /*多语言*/
  760. $attr_name_arr = [];
  761. if (empty($this->globalConfig['language_split'])) {
  762. foreach ($id_arr as $key => $val) {
  763. $attr_name_arr[] = 'ad'.$val;
  764. }
  765. if (is_language()) {
  766. $new_id_arr = Db::name('language_attr')->where([
  767. 'attr_name' => ['IN', $attr_name_arr],
  768. 'attr_group' => 'ad',
  769. ])->column('attr_value');
  770. !empty($new_id_arr) && $id_arr = $new_id_arr;
  771. }
  772. } else {
  773. if (get_admin_lang() == get_main_lang()) {
  774. foreach ($id_arr as $key => $val) {
  775. $attr_name_arr[] = 'ad'.$val;
  776. }
  777. }
  778. }
  779. /*--end*/
  780. $r = Db::name('zcwd')->where([
  781. 'id' => ['IN', $id_arr],
  782. ])
  783. ->delete();
  784. if ($r !== false) {
  785. /*多语言*/
  786. if (!empty($attr_name_arr)) {
  787. Db::name('language_attr')->where([
  788. 'attr_name' => ['IN', $attr_name_arr],
  789. 'attr_group' => 'ad',
  790. ])->delete();
  791. Db::name('language_attribute')->where([
  792. 'attr_name' => ['IN', $attr_name_arr],
  793. 'attr_group' => 'ad',
  794. ])->delete();
  795. }
  796. /*--end*/
  797. Cache::clear('ad');
  798. adminLog('删除广告-id:'.implode(',', $id_arr));
  799. }
  800. }
  801. }
  802. /**
  803. * 删除
  804. */
  805. public function del()
  806. {
  807. if (is_language() && empty($this->globalConfig['language_split'])) {
  808. $this->language_access(); // 多语言功能操作权限
  809. }
  810. $id_arr = input('del_id/a');
  811. $id_arr = eyIntval($id_arr);
  812. if(IS_POST && !empty($id_arr)){
  813. foreach ($id_arr as $key => $val) {
  814. if(array_key_exists($val, $this->ad_position_system_id)){
  815. $this->error('系统预定义,不能删除');
  816. }
  817. }
  818. /*多语言*/
  819. $attr_name_arr = [];
  820. foreach ($id_arr as $key => $val) {
  821. $attr_name_arr[] = 'adp'.$val;
  822. }
  823. if (is_language() && empty($this->globalConfig['language_split'])) {
  824. $new_id_arr = Db::name('language_attr')->where([
  825. 'attr_name' => ['IN', $attr_name_arr],
  826. 'attr_group' => 'ad_position',
  827. ])->column('attr_value');
  828. !empty($new_id_arr) && $id_arr = $new_id_arr;
  829. }
  830. /*--end*/
  831. $r = Db::name('zcwe_position')->where('id','IN',$id_arr)->delete();
  832. if ($r !== false) {
  833. /*多语言*/
  834. if (!empty($attr_name_arr)) {
  835. if (get_admin_lang() == get_main_lang()) {
  836. Db::name('language_attribute')->where([
  837. 'attr_name' => ['IN', $attr_name_arr],
  838. 'attr_group' => 'ad_position',
  839. ])->delete();
  840. }
  841. if (empty($this->globalConfig['language_split'])) {
  842. Db::name('language_attr')->where([
  843. 'attr_name' => ['IN', $attr_name_arr],
  844. 'attr_group' => 'ad_position',
  845. ])->delete();
  846. } else {
  847. Db::name('language_attr')->where([
  848. 'attr_value' => ['IN', $id_arr],
  849. 'attr_group' => 'ad_position',
  850. ])->delete();
  851. }
  852. }
  853. /*--end*/
  854. $ad_ids = Db::name('zcwd')->where(['pid'=>['IN', $id_arr]])->column('id');
  855. $attr_name_arr = [];
  856. foreach ($ad_ids as $key => $val) {
  857. $attr_name_arr[] = "ad{$val}";
  858. }
  859. $r1 = Db::name('zcwd')->where('pid','IN',$id_arr)->delete();
  860. if ($r1 !== false) {
  861. /*多语言*/
  862. if (!empty($attr_name_arr)) {
  863. if (get_admin_lang() == get_main_lang()) {
  864. Db::name('language_attribute')->where([
  865. 'attr_name' => ['IN', $attr_name_arr],
  866. 'attr_group' => 'ad',
  867. ])->delete();
  868. }
  869. if (empty($this->globalConfig['language_split'])) {
  870. Db::name('language_attr')->where([
  871. 'attr_name' => ['IN', $attr_name_arr],
  872. 'attr_group' => 'ad',
  873. ])->delete();
  874. } else {
  875. Db::name('language_attr')->where([
  876. 'attr_value' => ['IN', $ad_ids],
  877. 'attr_group' => 'ad',
  878. ])->delete();
  879. }
  880. }
  881. /*--end*/
  882. }
  883. Cache::clear('ad');
  884. adminLog('删除广告-id:'.implode(',', $id_arr));
  885. $this->success('删除成功');
  886. } else {
  887. $this->error('删除失败');
  888. }
  889. }else{
  890. $this->error('参数有误');
  891. }
  892. }
  893. /**
  894. * 打开预览视频
  895. */
  896. public function open_preview_video()
  897. {
  898. $post = input('post.');
  899. $video_litpic = $post['video_litpic'];
  900. if (!is_http_url($video_litpic)) {
  901. $video_litpic = request()->domain() . handle_subdir_pic($video_litpic, 'media');
  902. }
  903. $this->success('执行成功', $video_litpic);
  904. }
  905. /**
  906. * 检测广告名称是否存在重复
  907. */
  908. public function detection_title_repeat()
  909. {
  910. if (IS_AJAX_POST) {
  911. $post = input('post.');
  912. $where = [
  913. 'id' => ['NEQ', $post['id']],
  914. 'title' => trim($post['title']),
  915. 'lang' => $this->admin_lang,
  916. ];
  917. $count = Db::name('zcwe_position')->where($where)->count();
  918. if (empty($count)) {
  919. $this->success('检测通过');
  920. } else {
  921. $this->error('该广告名称已存在,请检查');
  922. }
  923. }
  924. }
  925. /**
  926. * 同步新增广告位置ID到多语言的模板变量里
  927. */
  928. private function syn_add_language_attribute($adp_id)
  929. {
  930. /*单语言情况下不执行多语言代码*/
  931. if (!is_language() || tpCache('language.language_split')) {
  932. return true;
  933. }
  934. /*--end*/
  935. $attr_group = 'ad_position';
  936. $admin_lang = $this->admin_lang;
  937. $main_lang = $this->main_lang;
  938. $languageRow = Db::name('language')->field('mark')->order('id asc')->select();
  939. if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
  940. $ad_position_db = Db::name('zcwe_position');
  941. $result = $ad_position_db->find($adp_id);
  942. $attr_name = 'adp'.$adp_id;
  943. $r = Db::name('language_attribute')->save([
  944. 'attr_title' => $result['title'],
  945. 'attr_name' => $attr_name,
  946. 'attr_group' => $attr_group,
  947. 'add_time' => getTime(),
  948. 'update_time' => getTime(),
  949. ]);
  950. if (false !== $r) {
  951. $data = [];
  952. foreach ($languageRow as $key => $val) {
  953. /*同步新广告位置到其他语言广告位置列表*/
  954. if ($val['mark'] != $admin_lang) {
  955. $addsaveData = $result;
  956. $addsaveData['lang'] = $val['mark'];
  957. $addsaveData['title'] = $val['mark'].$addsaveData['title'];
  958. unset($addsaveData['id']);
  959. $adp_id = $ad_position_db->insertGetId($addsaveData);
  960. }
  961. /*--end*/
  962. /*所有语言绑定在主语言的ID容器里*/
  963. $data[] = [
  964. 'attr_name' => $attr_name,
  965. 'attr_value' => $adp_id,
  966. 'lang' => $val['mark'],
  967. 'attr_group' => $attr_group,
  968. 'add_time' => getTime(),
  969. 'update_time' => getTime(),
  970. ];
  971. /*--end*/
  972. }
  973. if (!empty($data)) {
  974. model('LanguageAttr')->saveAll($data);
  975. }
  976. }
  977. }
  978. }
  979. /**
  980. * 同步新增广告ID到多语言的模板变量里
  981. */
  982. private function syn_add_ad_language_attribute($ad_id)
  983. {
  984. /*单语言情况下不执行多语言代码*/
  985. if (!is_language() || tpCache('language.language_split')) {
  986. return true;
  987. }
  988. /*--end*/
  989. $attr_group = 'ad';
  990. $admin_lang = $this->admin_lang;
  991. $main_lang = get_main_lang();
  992. $languageRow = Db::name('language')->field('mark')->order('id asc')->select();
  993. if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
  994. $ad_db = Db::name('zcwd');
  995. $result = $ad_db->find($ad_id);
  996. $attr_name = 'ad'.$ad_id;
  997. $r = Db::name('language_attribute')->save([
  998. 'attr_title' => $result['title'],
  999. 'attr_name' => $attr_name,
  1000. 'attr_group' => $attr_group,
  1001. 'add_time' => getTime(),
  1002. 'update_time' => getTime(),
  1003. ]);
  1004. if (false !== $r) {
  1005. $data = [];
  1006. foreach ($languageRow as $key => $val) {
  1007. /*同步新广告到其他语言广告列表*/
  1008. if ($val['mark'] != $admin_lang) {
  1009. $addsaveData = $result;
  1010. $addsaveData['lang'] = $val['mark'];
  1011. $newPid = Db::name('language_attr')->where([
  1012. 'attr_name' => 'adp'.$result['pid'],
  1013. 'attr_group' => 'ad_position',
  1014. 'lang' => $val['mark'],
  1015. ])->getField('attr_value');
  1016. $addsaveData['pid'] = $newPid;
  1017. $addsaveData['title'] = $val['mark'].$addsaveData['title'];
  1018. unset($addsaveData['id']);
  1019. $ad_id = $ad_db->insertGetId($addsaveData);
  1020. }
  1021. /*--end*/
  1022. /*所有语言绑定在主语言的ID容器里*/
  1023. $data[] = [
  1024. 'attr_name' => $attr_name,
  1025. 'attr_value' => $ad_id,
  1026. 'lang' => $val['mark'],
  1027. 'attr_group' => $attr_group,
  1028. 'add_time' => getTime(),
  1029. 'update_time' => getTime(),
  1030. ];
  1031. /*--end*/
  1032. }
  1033. if (!empty($data)) {
  1034. model('LanguageAttr')->saveAll($data);
  1035. }
  1036. }
  1037. }
  1038. }
  1039. }