暫無描述
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.

ZcwfPosition.php 49KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  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 ZcwfPosition 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('zcwf_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,type_son 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('zcwf')
  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('zcwf_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.zcwf10000.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. //增加
  198. $post['zhengshu_val'] = substr($post['zhengshu_val'], 0, -1);
  199. $post['zhengshu'] = explode(',',$post['zhengshu_val']);
  200. //var_dump($post['zhengshu']);die;
  201. //var_dump($post);die;
  202. if((int)$post['is_zs'] === 0){
  203. $post['zhengshu'] = '';
  204. $post['sjnx'] = '';
  205. }else{
  206. //重新遍历
  207. foreach ($post['zhengshu'] as $key => $value) {
  208. $sjnx_new[] = $post['sjnx'][$key];
  209. }
  210. $post['sjnx'] = $sjnx_new;
  211. }
  212. if(empty($post['zhengshu'])){
  213. $post['sjnx'] = '';
  214. $post['zhengshu'] = '';
  215. }
  216. //验证是否已经有重复的
  217. $one = Db::name('zcwf_position')->where([
  218. 'type' => $post['type'], //规则id
  219. 'type_son' => $post['type_son'], //第二规则id
  220. 'is_zs' => $post['is_zs'], //是否需要前置证书
  221. 'zhengshu' => json_encode($post['zhengshu']), //数组
  222. 'sjnx' => json_encode($post['sjnx']), //数组
  223. 'is_del' => 0,
  224. ])->find();
  225. if(!empty($one)){
  226. $this->error('该规则已存在,请检查!', url('ZcwfPosition/index'));
  227. }
  228. //拼装title $post['type']
  229. $post['title'] = '';
  230. if((int)$post['type'] > 0){
  231. $row = Db::name('zcwe_position')->where(['id'=>$post['type_son']])->find();
  232. $post['title'] .= $row['title'];
  233. }
  234. //允许重复
  235. /*$map = array(
  236. 'title' => trim($post['title']),
  237. 'lang' => $this->admin_lang,
  238. );
  239. if(Db::name('zcwf_position')->where($map)->count() > 0){
  240. $this->error('该职称名称已存在,请检查', url('ZcwfPosition/index'));
  241. }*/
  242. // 添加广告位置表信息
  243. $data = array(
  244. 'title' => trim($post['title']),
  245. 'type' => $post['type'], //职称地区
  246. 'type_son' => $post['type_son'], //职称地区
  247. 'intro' => '0', //备注
  248. 'admin_id' => session('admin_id'),
  249. 'lang' => $this->admin_lang,
  250. 'add_time' => getTime(),
  251. 'update_time' => getTime(),
  252. 'sf' => 0,
  253. 'cs' => 0,
  254. 'sbdj' => 0,
  255. 'is_ega' => 0,
  256. 'ega_0' => 0,
  257. 'ega_1' => 0,
  258. 'byzy' => 0,
  259. 'zhengshu2' => '',
  260. 'xlyq' => 0,
  261. 'xxlx' => 0,
  262. 'bysj' =>0,
  263. 'bysj_time' => 0,
  264. 'is_zs' => $post['is_zs'],
  265. 'zhengshu' => json_encode($post['zhengshu']),
  266. 'sjnx' => json_encode($post['sjnx']),
  267. 'gzyq' => json_encode($post['gzyq'],JSON_UNESCAPED_UNICODE),
  268. 'qttj' => $post['qttj'],
  269. );
  270. $insertID = Db::name('zcwf_position')->insertGetId($data);
  271. if (!empty($insertID)) {
  272. // 同步广告位置ID到多语言的模板变量里,添加多语言广告位
  273. //$this->syn_add_language_attribute($insertID);
  274. // 读取组合广告位的图片及信息
  275. $AdData = [];
  276. if (!empty($post['img_litpic'])) { // 图片类型
  277. $i = 1;
  278. foreach ($post['img_litpic'] as $key => $value) {
  279. if (!empty($value)) {
  280. // 去掉http:
  281. $value = str_replace("http:", "", $value);
  282. // 去掉https:
  283. $value = str_replace("https:", "", $value);
  284. // 主要参数
  285. $AdData['litpic'] = $value;
  286. $AdData['pid'] = $insertID;
  287. $AdData['title'] = trim($post['img_title'][$key]);
  288. $AdData['links'] = $post['img_links'][$key];
  289. $AdData['intro'] = $post['img_intro'][$key];
  290. $target = !empty($post['img_target'][$key]) ? 1 : 0;
  291. $AdData['target'] = $target;
  292. // 其他参数
  293. $AdData['media_type'] = 1;
  294. $AdData['admin_id'] = session('admin_id');
  295. $AdData['lang'] = $this->admin_lang;
  296. $AdData['sort_order'] = $i++;
  297. $AdData['add_time'] = getTime();
  298. $AdData['update_time'] = getTime();
  299. // 添加到广告图表
  300. $ad_id = Db::name('zcwf')->add($AdData);
  301. // 同步多语言
  302. //$this->syn_add_ad_language_attribute($ad_id);
  303. }
  304. }
  305. }
  306. //Cache::clear('ad');
  307. adminLog('新增职称:'.$post['title']);
  308. $this->success("操作成功", url('ZcwfPosition/index'));
  309. } else {
  310. $this->error("操作失败", url('ZcwfPosition/index'));
  311. }
  312. }
  313. // 上传通道
  314. $WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
  315. $WeappOpen = [];
  316. foreach ($WeappConfig as $value) {
  317. if ('Qiniuyun' == $value['code']) {
  318. $WeappOpen['qny_open'] = $value['status'];
  319. } else if ('AliyunOss' == $value['code']) {
  320. $WeappOpen['oss_open'] = $value['status'];
  321. } else if ('Cos' == $value['code']) {
  322. $WeappOpen['cos_open'] = $value['status'];
  323. }
  324. }
  325. $this->assign('WeappOpen', $WeappOpen);
  326. // 系统最大上传视频的大小
  327. $upload_max_filesize = upload_max_filesize();
  328. $this->assign('upload_max_filesize', $upload_max_filesize);
  329. // 视频类型
  330. $media_type = tpCache('global.media_type');
  331. $media_type = !empty($media_type) ? $media_type : config('global.media_ext');
  332. $media_type = str_replace(",", "|", $media_type);
  333. $this->assign('media_type', $media_type);
  334. //查找区域数据
  335. $pro_list = Db::name('citysite')->where(['level'=>1,'is_open'=>1])->select();
  336. //var_dump($pro_list);
  337. $this->assign('pro_list', $pro_list);
  338. //查找职称数据
  339. $pos = Db::name('zc_position')->where(['is_del'=>0])->select();
  340. //var_dump($pos);
  341. $this->assign('pos_list', $pos);
  342. $param = request()->param();
  343. //读取规则详情
  344. $row = Db::name('zcwd_position')->where(['id'=>$param['type']])->find();
  345. $this->assign('detail', $row);
  346. $this->assign('rule_id', $param['type']);
  347. //读取
  348. $row2 = Db::name('zcwe_position')->where(['id'=>$param['id']])->find();
  349. $this->assign('detail_son', $row2);
  350. $this->assign('rule_id_son', $param['id']);
  351. //读取证书详情
  352. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$row['type'],'is_del'=>0])->column('map_id');
  353. $listwww = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  354. //var_dump($listwww);
  355. $html = '';
  356. $arr = json_decode($row['zhengshu'],true);
  357. foreach ($listwww as $key => $value) {
  358. if(in_array($value['id'],$arr)){
  359. $checked = 'checked';
  360. }else{
  361. $checked = '';
  362. }
  363. $html .= '<span style="margin-right: 10px;margin-top:5px;display: block;"><input type="checkbox" name="zhengshu[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'';
  364. $html .= '<select name="sjnx[]" class="select" id="selectTest888" style="margin:0px 5px;height:30px;width:60px;">
  365. <option value="0" selected>不限</option>
  366. <option value="1">1年</option>
  367. <option value="2">2年</option>
  368. <option value="3">3年</option>
  369. <option value="4">4年</option>
  370. <option value="5">5年</option>
  371. <option value="6">6年</option>
  372. <option value="7">7年</option>
  373. <option value="8">8年</option>
  374. </select>
  375. 以上(包括)</span>';
  376. }
  377. if(empty($html)){
  378. $html = '请先添加相关证书';
  379. }
  380. $this->assign('zs_html',$html);
  381. return $this->fetch();
  382. }
  383. public function getZs()
  384. {
  385. $id = request()->post('id',0);
  386. //读取证书
  387. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$id,'is_del'=>0])->column('map_id');
  388. $list = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  389. $html = '';
  390. foreach ($list as $key => $value) {
  391. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu[]" value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  392. }
  393. if(empty($html)){
  394. $html = '<font style="color:red;">请先绑定申报专业相关的证书才能进行选择!</font>';
  395. }
  396. $data = [
  397. 'code' => 0,
  398. 'msg' => '查询成功',
  399. 'data' => $html
  400. ];
  401. return json($data);
  402. }
  403. public function getZs2()
  404. {
  405. $id = request()->post('id',0);
  406. //读取证书
  407. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$id,'is_del'=>0])->column('map_id');
  408. $list = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  409. $html = '';
  410. foreach ($list as $key => $value) {
  411. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  412. }
  413. if(empty($html)){
  414. $html = '<font style="color:red;">请先绑定申报专业相关的毕业专业才能进行选择!</font>';
  415. }
  416. $data = [
  417. 'code' => 0,
  418. 'msg' => '查询成功',
  419. 'data' => $html
  420. ];
  421. return json($data);
  422. }
  423. public function getMap($sid='')
  424. {
  425. if($sid == ''){
  426. $id = request()->post('id',0);
  427. }else{
  428. $id = $sid;
  429. }
  430. //查找区域
  431. $map_ids = Db::name('zc_map')
  432. ->where('zc_id','=',$id)
  433. ->where('is_del','=',0)
  434. ->column('map_id');
  435. //获取地区
  436. $list = Db::name('citysite')
  437. ->where('id','in',$map_ids)
  438. ->select();
  439. $type_name = '';
  440. foreach ($list as $k2 => $v2) {
  441. $type_name .= $v2['name'].',';
  442. }
  443. if(empty($type_name)){
  444. $type_name = '全国';
  445. }
  446. $data = [
  447. 'code' => 0,
  448. 'msg' => '获取成功',
  449. 'data' => $type_name,
  450. ];
  451. if($sid == ''){
  452. return json($data);
  453. }else{
  454. return $type_name;
  455. }
  456. }
  457. /**
  458. * 编辑
  459. */
  460. public function edit()
  461. {
  462. if (IS_POST) {
  463. $post = input('post.');
  464. if (!empty($post['id'])) {
  465. $post['id'] = intval($post['id']);
  466. if (array_key_exists($post['id'], $this->ad_position_system_id)) {
  467. $this->error("不可更改系统预定义位置", url('ZcwfPosition/edit',array('id'=>$post['id'])));
  468. }
  469. //增加
  470. $post['zhengshu_val'] = substr($post['zhengshu_val'], 0, -1);
  471. $post['zhengshu'] = explode(',',$post['zhengshu_val']);
  472. //var_dump($post['zhengshu']);die;
  473. //var_dump($post);die;
  474. if((int)$post['is_zs'] === 0){
  475. $post['zhengshu'] = '';
  476. $post['sjnx'] = '';
  477. }else{
  478. //重新遍历
  479. foreach ($post['zhengshu'] as $key => $value) {
  480. $sjnx_new[] = $post['sjnx'][$key];
  481. }
  482. $post['sjnx'] = $sjnx_new;
  483. }
  484. if(empty($post['zhengshu'])){
  485. $post['sjnx'] = '';
  486. $post['zhengshu'] = '';
  487. }
  488. //var_dump($post);die;
  489. //验证是否已经有重复的 排除自身ID
  490. $one = Db::name('zcwf_position')->where([
  491. 'type' => $post['type'], //规则id
  492. 'type_son' => $post['type_son'], //第二规则id
  493. 'is_zs' => $post['is_zs'], //是否需要前置证书
  494. 'zhengshu' => json_encode($post['zhengshu']), //数组
  495. 'sjnx' => json_encode($post['sjnx']), //数组
  496. 'is_del' => 0,
  497. ])->where('id','<>',$post['id'])->find();
  498. if(!empty($one)){
  499. $this->error('该规则已存在,请检查!', url('ZcwfPosition/index'));
  500. }
  501. //var_dump($one);die;
  502. //拼装title $post['type']
  503. $post['title'] = '';
  504. if((int)$post['type'] > 0){
  505. $row = Db::name('zcwe_position')->where(['id'=>$post['type_son']])->find();
  506. $post['title'] .= $row['title'];
  507. }
  508. /* 判断除自身外是否还有相同广告名称已存在 */
  509. /*$map = array(
  510. 'id' => array('NEQ', $post['id']),
  511. 'title' => trim($post['title']),
  512. //'lang' => $this->admin_lang,
  513. );
  514. if (Db::name('zcwf_position')->where($map)->count() > 0) $this->error('该职称名称已存在,请检查');*/
  515. //处理年龄
  516. /* if((int)$post['is_ega'] > 0){
  517. if((int)$post['ega'][0] >= (int)$post['ega'][1]){
  518. $this->error('请输入正确的年龄区间,请检查', url('ZcwfPosition/index'));
  519. }
  520. }*/
  521. /* END */
  522. /* 判断广告是否切换广告类型 */
  523. // $where = [
  524. // 'id' => $post['id'],
  525. // 'type' => $post['type'],
  526. // 'lang' => $this->admin_lang
  527. // ];
  528. // if (Db::name('zcwf_position')->where($where)->count() == 0) {
  529. // // 已切换广告类型,清除广告中的广告内容
  530. // $where = [
  531. // 'pid' => $post['id'],
  532. // 'lang' => $this->admin_lang
  533. // ];
  534. // Db::name('zcwf')->where($where)->delete();
  535. // }
  536. /* END */
  537. /* 修改广告主体信息 */
  538. $data = array(
  539. 'id' => $post['id'],
  540. 'title' => trim($post['title']),
  541. 'type' => $post['type'], //职称地区
  542. 'type_son' => $post['type_son'], //职称地区
  543. 'intro' => '0', //备注
  544. 'lang' => $this->admin_lang,
  545. 'update_time' => getTime(),
  546. 'sf' => 0,
  547. 'cs' => 0,
  548. 'sbdj' => 0,
  549. 'is_ega' => 0,
  550. 'ega_0' => 0,
  551. 'ega_1' => 0,
  552. 'byzy' => 0,
  553. 'zhengshu2' => '',
  554. 'xlyq' => 0,
  555. 'xxlx' => 0,
  556. 'bysj' =>0,
  557. 'bysj_time' => 0,
  558. 'is_zs' => $post['is_zs'],
  559. 'zhengshu' => json_encode($post['zhengshu']),
  560. 'sjnx' => json_encode($post['sjnx']),
  561. 'gzyq' => json_encode($post['gzyq'],JSON_UNESCAPED_UNICODE),
  562. 'qttj' => $post['qttj'],
  563. );
  564. $resultID = Db::name('zcwf_position')->update($data);
  565. /* END */
  566. }
  567. if (!empty($resultID)) {
  568. $ad_db = Db::name('zcwf');
  569. if (!empty($post['img_litpic'])) { // 图片类型
  570. // 读取组合广告位的图片及信息
  571. $i = 1;
  572. foreach ($post['img_litpic'] as $key => $value) {
  573. if (!empty($value)) {
  574. // 去掉http:
  575. $value = str_replace("http:", "", $value);
  576. // 去掉https:
  577. $value = str_replace("https:", "", $value);
  578. // 是否新窗口打开
  579. $target = !empty($post['img_target'][$key]) ? 1 : 0;
  580. // 广告位ID,为空则表示添加
  581. $ad_id = $post['img_id'][$key];
  582. if (!empty($ad_id)) {
  583. // 查询更新条件
  584. $where = [
  585. 'id' => $ad_id,
  586. 'lang' => $this->admin_lang,
  587. ];
  588. if ($ad_db->where($where)->count() > 0) {
  589. // 主要参数
  590. $AdData['litpic'] = $value;
  591. $AdData['title'] = $post['img_title'][$key];
  592. $AdData['links'] = $post['img_links'][$key];
  593. $AdData['intro'] = $post['img_intro'][$key];
  594. $AdData['target'] = $target;
  595. // 其他参数
  596. $AdData['sort_order'] = $i++;
  597. $AdData['update_time'] = getTime();
  598. // 更新,不需要同步多语言
  599. $ad_db->where($where)->update($AdData);
  600. } else {
  601. // 主要参数
  602. $AdData['litpic'] = $value;
  603. $AdData['pid'] = $post['id'];
  604. $AdData['title'] = $post['img_title'][$key];
  605. $AdData['links'] = $post['img_links'][$key];
  606. $AdData['intro'] = $post['img_intro'][$key];
  607. $AdData['target'] = $target;
  608. // 其他参数
  609. $AdData['media_type'] = 1;
  610. $AdData['admin_id'] = session('admin_id');
  611. $AdData['lang'] = $this->admin_lang;
  612. $AdData['sort_order'] = $i++;
  613. $AdData['add_time'] = getTime();
  614. $AdData['update_time'] = getTime();
  615. $ad_id = $ad_db->add($AdData);
  616. // 同步多语言
  617. //$this->syn_add_ad_language_attribute($ad_id);
  618. }
  619. } else {
  620. // 主要参数
  621. $AdData['litpic'] = $value;
  622. $AdData['pid'] = $post['id'];
  623. $AdData['title'] = $post['img_title'][$key];
  624. $AdData['links'] = $post['img_links'][$key];
  625. $AdData['intro'] = $post['img_intro'][$key];
  626. $AdData['target'] = $target;
  627. // 其他参数
  628. $AdData['media_type'] = 1;
  629. $AdData['admin_id'] = session('admin_id');
  630. $AdData['lang'] = $this->admin_lang;
  631. $AdData['sort_order'] = $i++;
  632. $AdData['add_time'] = getTime();
  633. $AdData['update_time'] = getTime();
  634. $ad_id = $ad_db->add($AdData);
  635. // 同步多语言
  636. //$this->syn_add_ad_language_attribute($ad_id);
  637. }
  638. }
  639. }
  640. }
  641. //Cache::clear('ad');
  642. adminLog('编辑职称名称:'.$post['title']);
  643. $this->success("操作成功", url('ZcwfPosition/index'));
  644. } else {
  645. $this->error("操作失败");
  646. }
  647. }
  648. $assign_data = array();
  649. $id = input('id/d');
  650. $field = Db::name('zcwf_position')->field('a.*')->alias('a')->where(array('a.id'=>$id))->find();
  651. if (empty($field)) $this->error('职称不存在,请联系管理员!');
  652. switch ($field['type']) {
  653. case '1':
  654. $field['type_name'] = '图片';
  655. break;
  656. case '2':
  657. $field['type_name'] = '多媒体';
  658. break;
  659. case '3':
  660. $field['type_name'] = 'HTML代码';
  661. break;
  662. }
  663. $assign_data['field'] = $field;
  664. // 广告
  665. $ad_data = Db::name('zcwf')->where(array('pid'=>$field['id']))->order('sort_order asc')->select();
  666. foreach ($ad_data as $key => $val) {
  667. if (1 == $val['media_type']) {
  668. $ad_data[$key]['litpic'] = get_default_pic($val['litpic']); // 支持子目录
  669. }
  670. }
  671. $assign_data['ad_data'] = $ad_data;
  672. // 上传通道
  673. $WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
  674. $WeappOpen = [];
  675. foreach ($WeappConfig as $value) {
  676. if ('Qiniuyun' == $value['code']) {
  677. $WeappOpen['qny_open'] = $value['status'];
  678. } else if ('AliyunOss' == $value['code']) {
  679. $WeappOpen['oss_open'] = $value['status'];
  680. } else if ('Cos' == $value['code']) {
  681. $WeappOpen['cos_open'] = $value['status'];
  682. }
  683. }
  684. $this->assign('WeappOpen', $WeappOpen);
  685. // 系统最大上传视频的大小
  686. $file_size = tpCache('global.file_size');
  687. $postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
  688. $fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
  689. $min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
  690. $min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
  691. $upload_max_filesize = intval($min_size) * 1024 * 1024;
  692. $assign_data['upload_max_filesize'] = $upload_max_filesize;
  693. // 视频类型
  694. $media_type = tpCache('global.media_type');
  695. $media_type = !empty($media_type) ? $media_type : config('global.media_ext');
  696. $media_type = str_replace(",", "|", $media_type);
  697. $assign_data['media_type'] = $media_type;
  698. //查找区域数据
  699. $pro_list = Db::name('citysite')->where(['level'=>1,'is_open'=>1])->select();
  700. //var_dump($pro_list);
  701. $this->assign('pro_list', $pro_list);
  702. $this->assign('curr_id', $field['type']);
  703. //查找职称数据
  704. $pos = Db::name('zc_position')->where(['is_del'=>0])->select();
  705. //var_dump($pos);
  706. $this->assign('pos_list', $pos);
  707. $tn = $this->getMap($field['type']);
  708. $this->assign('tn',$tn);
  709. if((int)$field['cs'] > 0) {
  710. $csn = Db::name('citysite')->where(['id' => $field['cs']])->value('name');
  711. $this->assign('csn',$csn);
  712. }
  713. $pro_list2 = Db::name('citysite')->where(['parent_id'=>$field['sf']])->select();
  714. //var_dump($pro_list2);
  715. $this->assign('pro_list2', $pro_list2);
  716. $this->assign('curr_id2', $field['cs']);
  717. if((int)$field['byzy'] > 0) {
  718. $map_ids = Db::name('zc_zy')->where(['zc_id'=>$field['type'],'is_del'=>0])->column('map_id');
  719. $listwww = Db::name('zczy_position')->where('id','in',$map_ids)->select();
  720. $html = '';
  721. $arr = json_decode($field['zhengshu2'],true);
  722. foreach ($listwww as $key => $value) {
  723. if(in_array($value['id'],$arr)){
  724. $checked = 'checked';
  725. }else{
  726. $checked = '';
  727. }
  728. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu2[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  729. }
  730. $this->assign('byzy_html',$html);
  731. }
  732. if((int)$field['is_zs'] > 0) {
  733. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$field['type'],'is_del'=>0])->column('map_id');
  734. $listwww = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  735. $html = '';
  736. $arr = json_decode($field['zhengshu'],true);
  737. foreach ($listwww as $key => $value) {
  738. if(in_array($value['id'],$arr)){
  739. $checked = 'checked';
  740. }else{
  741. $checked = '';
  742. }
  743. $html .= '<span style="margin-right: 10px;"><input type="checkbox" name="zhengshu[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'</span>';
  744. }
  745. $this->assign('zs_html',$html);
  746. }
  747. $gzyq = json_decode($field['gzyq'],true);
  748. $this->assign('gzyq',$gzyq);
  749. $param = request()->param();
  750. //读取规则详情
  751. $row = Db::name('zcwd_position')->where(['id'=>$field['type']])->find();
  752. $this->assign('detail', $row);
  753. $this->assign('rule_id', $field['type']);
  754. //读取
  755. $row2 = Db::name('zcwe_position')->where(['id'=>$field['type_son']])->find();
  756. $this->assign('detail_son', $row2);
  757. $this->assign('rule_id_son', $field['type_son']);
  758. //读取证书详情
  759. $map_ids = Db::name('zc_zs')->where(['zc_id'=>$row['type'],'is_del'=>0])->column('map_id');
  760. $listwww = Db::name('zczs_position')->where('id','in',$map_ids)->select();
  761. //var_dump($listwww);
  762. $html = '';
  763. $arr = json_decode($field['zhengshu'],true);
  764. $arr_2 = json_decode($field['sjnx'],true);
  765. foreach ($listwww as $key => $value) {
  766. if(in_array($value['id'],$arr)){
  767. $checked = 'checked';
  768. foreach ($arr as $key_2 => $value_2) {
  769. if($value['id'] == $value_2){
  770. $year = $arr_2[$key_2];
  771. $option = '<option value="0">不限</option>';
  772. for($i=1;$i<=8;$i++){
  773. if($i == $year){
  774. $selected = 'selected';
  775. }else{
  776. $selected = '';
  777. }
  778. $option .= '<option value="'.$i.'" '.$selected.'>'.$i.'年</option>';
  779. }
  780. }
  781. }
  782. }else{
  783. $checked = '';
  784. $year = 0;
  785. $option = '<option value="0" selected>不限</option>
  786. <option value="1">1年</option>
  787. <option value="2">2年</option>
  788. <option value="3">3年</option>
  789. <option value="4">4年</option>
  790. <option value="5">5年</option>
  791. <option value="6">6年</option>
  792. <option value="7">7年</option>
  793. <option value="8">8年</option>';
  794. }
  795. $html .= '<span style="margin-right: 10px;margin-top:5px;display: block;"><input type="checkbox" name="zhengshu[]" '.$checked.' value="'.$value['id'].'" id="category'.$value['id'].'"/>'.$value['title'].'';
  796. $html .= '<select name="sjnx[]" class="select" id="selectTest888" style="margin:0px 5px;height:30px;width:60px;">
  797. '.$option.'
  798. </select>
  799. 以上(包括)</span>';
  800. }
  801. if(empty($html)){
  802. $html = '请先添加相关证书';
  803. }
  804. $this->assign('zs_html',$html);
  805. $this->assign($assign_data);
  806. return $this->fetch();
  807. }
  808. /**
  809. * 删除广告图片
  810. */
  811. public function del_imgupload()
  812. {
  813. if (is_language() && empty($this->globalConfig['language_split'])) {
  814. $this->language_access(); // 多语言功能操作权限
  815. }
  816. $id_arr = input('del_id/a');
  817. $id_arr = eyIntval($id_arr);
  818. if(IS_POST && !empty($id_arr)){
  819. /*多语言*/
  820. $attr_name_arr = [];
  821. if (empty($this->globalConfig['language_split'])) {
  822. foreach ($id_arr as $key => $val) {
  823. $attr_name_arr[] = 'ad'.$val;
  824. }
  825. if (is_language()) {
  826. $new_id_arr = Db::name('language_attr')->where([
  827. 'attr_name' => ['IN', $attr_name_arr],
  828. 'attr_group' => 'ad',
  829. ])->column('attr_value');
  830. !empty($new_id_arr) && $id_arr = $new_id_arr;
  831. }
  832. } else {
  833. if (get_admin_lang() == get_main_lang()) {
  834. foreach ($id_arr as $key => $val) {
  835. $attr_name_arr[] = 'ad'.$val;
  836. }
  837. }
  838. }
  839. /*--end*/
  840. $r = Db::name('zcwf')->where([
  841. 'id' => ['IN', $id_arr],
  842. ])
  843. ->delete();
  844. if ($r !== false) {
  845. /*多语言*/
  846. if (!empty($attr_name_arr)) {
  847. Db::name('language_attr')->where([
  848. 'attr_name' => ['IN', $attr_name_arr],
  849. 'attr_group' => 'ad',
  850. ])->delete();
  851. Db::name('language_attribute')->where([
  852. 'attr_name' => ['IN', $attr_name_arr],
  853. 'attr_group' => 'ad',
  854. ])->delete();
  855. }
  856. /*--end*/
  857. Cache::clear('ad');
  858. adminLog('删除广告-id:'.implode(',', $id_arr));
  859. }
  860. }
  861. }
  862. /**
  863. * 删除
  864. */
  865. public function del()
  866. {
  867. if (is_language() && empty($this->globalConfig['language_split'])) {
  868. $this->language_access(); // 多语言功能操作权限
  869. }
  870. $id_arr = input('del_id/a');
  871. $id_arr = eyIntval($id_arr);
  872. if(IS_POST && !empty($id_arr)){
  873. foreach ($id_arr as $key => $val) {
  874. if(array_key_exists($val, $this->ad_position_system_id)){
  875. $this->error('系统预定义,不能删除');
  876. }
  877. }
  878. /*多语言*/
  879. $attr_name_arr = [];
  880. foreach ($id_arr as $key => $val) {
  881. $attr_name_arr[] = 'adp'.$val;
  882. }
  883. if (is_language() && empty($this->globalConfig['language_split'])) {
  884. $new_id_arr = Db::name('language_attr')->where([
  885. 'attr_name' => ['IN', $attr_name_arr],
  886. 'attr_group' => 'ad_position',
  887. ])->column('attr_value');
  888. !empty($new_id_arr) && $id_arr = $new_id_arr;
  889. }
  890. /*--end*/
  891. $r = Db::name('zcwf_position')->where('id','IN',$id_arr)->delete();
  892. if ($r !== false) {
  893. /*多语言*/
  894. if (!empty($attr_name_arr)) {
  895. if (get_admin_lang() == get_main_lang()) {
  896. Db::name('language_attribute')->where([
  897. 'attr_name' => ['IN', $attr_name_arr],
  898. 'attr_group' => 'ad_position',
  899. ])->delete();
  900. }
  901. if (empty($this->globalConfig['language_split'])) {
  902. Db::name('language_attr')->where([
  903. 'attr_name' => ['IN', $attr_name_arr],
  904. 'attr_group' => 'ad_position',
  905. ])->delete();
  906. } else {
  907. Db::name('language_attr')->where([
  908. 'attr_value' => ['IN', $id_arr],
  909. 'attr_group' => 'ad_position',
  910. ])->delete();
  911. }
  912. }
  913. /*--end*/
  914. $ad_ids = Db::name('zcwf')->where(['pid'=>['IN', $id_arr]])->column('id');
  915. $attr_name_arr = [];
  916. foreach ($ad_ids as $key => $val) {
  917. $attr_name_arr[] = "ad{$val}";
  918. }
  919. $r1 = Db::name('zcwf')->where('pid','IN',$id_arr)->delete();
  920. if ($r1 !== false) {
  921. /*多语言*/
  922. if (!empty($attr_name_arr)) {
  923. if (get_admin_lang() == get_main_lang()) {
  924. Db::name('language_attribute')->where([
  925. 'attr_name' => ['IN', $attr_name_arr],
  926. 'attr_group' => 'ad',
  927. ])->delete();
  928. }
  929. if (empty($this->globalConfig['language_split'])) {
  930. Db::name('language_attr')->where([
  931. 'attr_name' => ['IN', $attr_name_arr],
  932. 'attr_group' => 'ad',
  933. ])->delete();
  934. } else {
  935. Db::name('language_attr')->where([
  936. 'attr_value' => ['IN', $ad_ids],
  937. 'attr_group' => 'ad',
  938. ])->delete();
  939. }
  940. }
  941. /*--end*/
  942. }
  943. Cache::clear('ad');
  944. adminLog('删除广告-id:'.implode(',', $id_arr));
  945. $this->success('删除成功');
  946. } else {
  947. $this->error('删除失败');
  948. }
  949. }else{
  950. $this->error('参数有误');
  951. }
  952. }
  953. /**
  954. * 打开预览视频
  955. */
  956. public function open_preview_video()
  957. {
  958. $post = input('post.');
  959. $video_litpic = $post['video_litpic'];
  960. if (!is_http_url($video_litpic)) {
  961. $video_litpic = request()->domain() . handle_subdir_pic($video_litpic, 'media');
  962. }
  963. $this->success('执行成功', $video_litpic);
  964. }
  965. /**
  966. * 检测广告名称是否存在重复
  967. */
  968. public function detection_title_repeat()
  969. {
  970. if (IS_AJAX_POST) {
  971. $post = input('post.');
  972. $where = [
  973. 'id' => ['NEQ', $post['id']],
  974. 'title' => trim($post['title']),
  975. 'lang' => $this->admin_lang,
  976. ];
  977. $count = Db::name('zcwf_position')->where($where)->count();
  978. if (empty($count)) {
  979. $this->success('检测通过');
  980. } else {
  981. $this->error('该广告名称已存在,请检查');
  982. }
  983. }
  984. }
  985. /**
  986. * 同步新增广告位置ID到多语言的模板变量里
  987. */
  988. private function syn_add_language_attribute($adp_id)
  989. {
  990. /*单语言情况下不执行多语言代码*/
  991. if (!is_language() || tpCache('language.language_split')) {
  992. return true;
  993. }
  994. /*--end*/
  995. $attr_group = 'ad_position';
  996. $admin_lang = $this->admin_lang;
  997. $main_lang = $this->main_lang;
  998. $languageRow = Db::name('language')->field('mark')->order('id asc')->select();
  999. if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
  1000. $ad_position_db = Db::name('zcwf_position');
  1001. $result = $ad_position_db->find($adp_id);
  1002. $attr_name = 'adp'.$adp_id;
  1003. $r = Db::name('language_attribute')->save([
  1004. 'attr_title' => $result['title'],
  1005. 'attr_name' => $attr_name,
  1006. 'attr_group' => $attr_group,
  1007. 'add_time' => getTime(),
  1008. 'update_time' => getTime(),
  1009. ]);
  1010. if (false !== $r) {
  1011. $data = [];
  1012. foreach ($languageRow as $key => $val) {
  1013. /*同步新广告位置到其他语言广告位置列表*/
  1014. if ($val['mark'] != $admin_lang) {
  1015. $addsaveData = $result;
  1016. $addsaveData['lang'] = $val['mark'];
  1017. $addsaveData['title'] = $val['mark'].$addsaveData['title'];
  1018. unset($addsaveData['id']);
  1019. $adp_id = $ad_position_db->insertGetId($addsaveData);
  1020. }
  1021. /*--end*/
  1022. /*所有语言绑定在主语言的ID容器里*/
  1023. $data[] = [
  1024. 'attr_name' => $attr_name,
  1025. 'attr_value' => $adp_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. /**
  1040. * 同步新增广告ID到多语言的模板变量里
  1041. */
  1042. private function syn_add_ad_language_attribute($ad_id)
  1043. {
  1044. /*单语言情况下不执行多语言代码*/
  1045. if (!is_language() || tpCache('language.language_split')) {
  1046. return true;
  1047. }
  1048. /*--end*/
  1049. $attr_group = 'ad';
  1050. $admin_lang = $this->admin_lang;
  1051. $main_lang = get_main_lang();
  1052. $languageRow = Db::name('language')->field('mark')->order('id asc')->select();
  1053. if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
  1054. $ad_db = Db::name('zcwf');
  1055. $result = $ad_db->find($ad_id);
  1056. $attr_name = 'ad'.$ad_id;
  1057. $r = Db::name('language_attribute')->save([
  1058. 'attr_title' => $result['title'],
  1059. 'attr_name' => $attr_name,
  1060. 'attr_group' => $attr_group,
  1061. 'add_time' => getTime(),
  1062. 'update_time' => getTime(),
  1063. ]);
  1064. if (false !== $r) {
  1065. $data = [];
  1066. foreach ($languageRow as $key => $val) {
  1067. /*同步新广告到其他语言广告列表*/
  1068. if ($val['mark'] != $admin_lang) {
  1069. $addsaveData = $result;
  1070. $addsaveData['lang'] = $val['mark'];
  1071. $newPid = Db::name('language_attr')->where([
  1072. 'attr_name' => 'adp'.$result['pid'],
  1073. 'attr_group' => 'ad_position',
  1074. 'lang' => $val['mark'],
  1075. ])->getField('attr_value');
  1076. $addsaveData['pid'] = $newPid;
  1077. $addsaveData['title'] = $val['mark'].$addsaveData['title'];
  1078. unset($addsaveData['id']);
  1079. $ad_id = $ad_db->insertGetId($addsaveData);
  1080. }
  1081. /*--end*/
  1082. /*所有语言绑定在主语言的ID容器里*/
  1083. $data[] = [
  1084. 'attr_name' => $attr_name,
  1085. 'attr_value' => $ad_id,
  1086. 'lang' => $val['mark'],
  1087. 'attr_group' => $attr_group,
  1088. 'add_time' => getTime(),
  1089. 'update_time' => getTime(),
  1090. ];
  1091. /*--end*/
  1092. }
  1093. if (!empty($data)) {
  1094. model('LanguageAttr')->saveAll($data);
  1095. }
  1096. }
  1097. }
  1098. }
  1099. }