|
@@ -0,0 +1,746 @@
|
|
1
|
+<?php
|
|
2
|
+// +----------------------------------------------------------------------
|
|
3
|
+// | Yzncms [ 御宅男工作室 ]
|
|
4
|
+// +----------------------------------------------------------------------
|
|
5
|
+// | Copyright (c) 2018 http://yzncms.com All rights reserved.
|
|
6
|
+// +----------------------------------------------------------------------
|
|
7
|
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
8
|
+// +----------------------------------------------------------------------
|
|
9
|
+// | fastadmin: https://www.fastadmin.net/
|
|
10
|
+// +----------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+// +----------------------------------------------------------------------
|
|
13
|
+// | 邮箱验证码接口
|
|
14
|
+// +----------------------------------------------------------------------
|
|
15
|
+namespace app\api\controller;
|
|
16
|
+
|
|
17
|
+use app\common\controller\Api;
|
|
18
|
+use app\common\library\Ems as Emslib;
|
|
19
|
+use app\member\controller\MemberApi;
|
|
20
|
+use app\member\model\Member;
|
|
21
|
+use think\facade\Hook;
|
|
22
|
+use think\facade\Validate;
|
|
23
|
+use think\Db;
|
|
24
|
+
|
|
25
|
+/**
|
|
26
|
+ * @title 邮箱验证码接口
|
|
27
|
+ * @controller api\controller\Ems
|
|
28
|
+ * @group base
|
|
29
|
+ */
|
|
30
|
+class Cms extends MemberApi
|
|
31
|
+{
|
|
32
|
+
|
|
33
|
+ protected $noNeedLogin = ['login', 'register','getProduct','getProductSmall','createTask','tagHandle','taskHandle'];
|
|
34
|
+ protected $noNeedRight = [];
|
|
35
|
+
|
|
36
|
+ //初始化
|
|
37
|
+ protected function initialize()
|
|
38
|
+ {
|
|
39
|
+ parent::initialize();
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ /**
|
|
43
|
+ * @title 发送验证码
|
|
44
|
+ * @desc 最基础的接口注释写法
|
|
45
|
+ * @author 御宅男
|
|
46
|
+ * @url /api/Ems/send
|
|
47
|
+ * @method GET
|
|
48
|
+ * @tag 邮箱 验证码
|
|
49
|
+ * @param name:email type:string require:1 desc:邮箱
|
|
50
|
+ * @param name:event type:string require:1 desc:事件名称
|
|
51
|
+ * @return name:data type:array ref:definitions\dictionary
|
|
52
|
+ */
|
|
53
|
+ public function send()
|
|
54
|
+ {
|
|
55
|
+
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * @title 检测验证码
|
|
60
|
+ * @desc 最基础的接口注释写法
|
|
61
|
+ * @author 御宅男
|
|
62
|
+ * @url /api/Ems/check
|
|
63
|
+ * @method GET
|
|
64
|
+ * @tag 邮箱 验证码
|
|
65
|
+ * @param name:email type:string require:1 desc:邮箱
|
|
66
|
+ * @param name:event type:string require:1 desc:事件名称
|
|
67
|
+ * @param name:captcha type:string require:1 desc:验证码
|
|
68
|
+ * @return name:data type:array ref:definitions\dictionary
|
|
69
|
+ */
|
|
70
|
+ public function check()
|
|
71
|
+ {
|
|
72
|
+
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ /*
|
|
76
|
+ *
|
|
77
|
+ * 同步产品接口 - 大类
|
|
78
|
+ * 每天同步一次
|
|
79
|
+ * 防止产品未发布级别就同步过来 执行了
|
|
80
|
+ * http://console.zx2049.com/api/cms/getProduct
|
|
81
|
+ */
|
|
82
|
+ public function getProduct()
|
|
83
|
+ {
|
|
84
|
+ //查找区域
|
|
85
|
+ $area = Db::connect('db1')
|
|
86
|
+ ->table('ey_citysite')
|
|
87
|
+ ->where(['level'=>1,'is_open'=>1,'status'=>1])
|
|
88
|
+ ->select();
|
|
89
|
+ //dump($area);
|
|
90
|
+ $area[] = [
|
|
91
|
+ 'id' => 10000,
|
|
92
|
+ ];
|
|
93
|
+
|
|
94
|
+ foreach ($area as $index => $item) {
|
|
95
|
+
|
|
96
|
+ //查找最后创建时间create_time
|
|
97
|
+ $add_time = Db::name('cms_product')
|
|
98
|
+ ->where(['catid'=>2,'diqu'=>$item['id']]) //产品大类
|
|
99
|
+ ->order('add_time desc')
|
|
100
|
+ ->value('add_time');
|
|
101
|
+ //dump($create_time);
|
|
102
|
+ if(empty($add_time)){
|
|
103
|
+ $add_time = 0;
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ //不考虑分批次
|
|
107
|
+ $list = Db::connect('db1')
|
|
108
|
+ ->table('ey_arctype')
|
|
109
|
+ ->where(['topid'=>38,'area_id'=>$item['id'],'is_del'=>0])
|
|
110
|
+ ->where('add_time','>',$add_time)
|
|
111
|
+ ->select();
|
|
112
|
+ //dump($list);
|
|
113
|
+
|
|
114
|
+ foreach ($list as $key=>$row){
|
|
115
|
+ $one = Db::name('cms_product')->where([
|
|
116
|
+ 'catid' => 2,
|
|
117
|
+ 'aid' => $row['id'],
|
|
118
|
+ 'diqu' => $item['id'],
|
|
119
|
+ 'pid' => 0,
|
|
120
|
+ ])->find();
|
|
121
|
+ if(empty($one)){
|
|
122
|
+ //插入数据库
|
|
123
|
+ $insert_data = [
|
|
124
|
+ 'catid' => 2,
|
|
125
|
+ 'title' => $row['typename'],
|
|
126
|
+ 'add_time' => $row['add_time'],
|
|
127
|
+ 'create_time' => time(),
|
|
128
|
+ 'update_time' => time(),
|
|
129
|
+ 'status' => 1,
|
|
130
|
+ 'diqu' => $item['id'],
|
|
131
|
+ 'pid' => 0,
|
|
132
|
+ 'aid' => $row['id'],
|
|
133
|
+ 'site_id' => 1,
|
|
134
|
+ 'link' => ''
|
|
135
|
+ ];
|
|
136
|
+ $run = Db::name('cms_product')->insert($insert_data);
|
|
137
|
+ echo '插入'.$run.'条,产品id: '.$row['id'].'<br/>';
|
|
138
|
+ }else{
|
|
139
|
+ echo '插入0条,产品id: '.$row['id'].'已存在<br/>';
|
|
140
|
+ }
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ /*
|
|
146
|
+ * 同步产品接口 - 小类
|
|
147
|
+ * http://console.zx2049.com/api/cms/getProductSmall
|
|
148
|
+ */
|
|
149
|
+ public function getProductSmall()
|
|
150
|
+ {
|
|
151
|
+
|
|
152
|
+ //查找最后创建时间create_time
|
|
153
|
+ $add_time = Db::name('cms_product')
|
|
154
|
+ ->where(['catid'=>3]) //产品小类
|
|
155
|
+ ->order('add_time desc')
|
|
156
|
+ ->value('add_time');
|
|
157
|
+ //dump($create_time);
|
|
158
|
+ if(empty($add_time)){
|
|
159
|
+ $add_time = 0;
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ //不考虑分批次
|
|
163
|
+ $list = Db::connect('db1')
|
|
164
|
+ ->table('ey_arctype_cat')
|
|
165
|
+ ->where(['is_del'=>0])
|
|
166
|
+ ->where('add_time','>',$add_time)
|
|
167
|
+ ->select();
|
|
168
|
+ //dump($list);
|
|
169
|
+
|
|
170
|
+ foreach ($list as $key=>$row){
|
|
171
|
+
|
|
172
|
+ //查找上级所属区域id
|
|
173
|
+ $area_id = Db::connect('db1')->table('ey_arctype')->where(['id'=>$row['parent_id']])->value('area_id');
|
|
174
|
+
|
|
175
|
+ if(empty($area_id)){
|
|
176
|
+ $area_id = 0;
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ $one = Db::name('cms_product')->where([
|
|
180
|
+ 'catid' => 3,
|
|
181
|
+ 'aid' => $row['id'],
|
|
182
|
+ 'diqu' => $area_id,
|
|
183
|
+ 'pid' => 0,
|
|
184
|
+ ])->find();
|
|
185
|
+ if(empty($one)){
|
|
186
|
+ //插入数据库
|
|
187
|
+ $insert_data = [
|
|
188
|
+ 'catid' => 3,
|
|
189
|
+ 'title' => $row['typename'],
|
|
190
|
+ 'add_time' => $row['add_time'],
|
|
191
|
+ 'create_time' => time(),
|
|
192
|
+ 'update_time' => time(),
|
|
193
|
+ 'status' => 1,
|
|
194
|
+ 'diqu' => $area_id,
|
|
195
|
+ 'pid' => $row['parent_id'],
|
|
196
|
+ 'aid' => $row['id'],
|
|
197
|
+ 'site_id' => 1,
|
|
198
|
+ 'link' => ''
|
|
199
|
+ ];
|
|
200
|
+ $run = Db::name('cms_product')->insert($insert_data);
|
|
201
|
+ echo '插入'.$run.'条,产品id: '.$row['id'].'<br/>';
|
|
202
|
+ }else{
|
|
203
|
+ echo '插入0条,产品id: '.$row['id'].'已存在<br/>';
|
|
204
|
+ }
|
|
205
|
+ }
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ /*
|
|
209
|
+ * 同步删除操作
|
|
210
|
+ * 增加字段 is_del 和 delete_time
|
|
211
|
+ * 同步删除时间和是否删除
|
|
212
|
+ * 目前先在发文的时候判断是否已删除就行
|
|
213
|
+ */
|
|
214
|
+ public function delHandle()
|
|
215
|
+ {
|
|
216
|
+
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ /*
|
|
220
|
+ * 存在小类就不创建发文任务,因为只有概述
|
|
221
|
+ * 小类肯定都发文
|
|
222
|
+ * 一个产品发一篇 不按级别 级别作为轮询为发文内容
|
|
223
|
+ * 标签为 产品名+申报 (这个固定不变) 另 产品名与标签名 发生修改 不做统一校验
|
|
224
|
+ * 同时判断产品是否正常(非删除状态)
|
|
225
|
+ * 每一轮为一个定时任务 因为产品是不断增加的 同时任务也是不断增加的
|
|
226
|
+ * 每一轮的任务分组不一样 会持续不断发文 对应发文模板也不一样
|
|
227
|
+ * 参数 任务分组id
|
|
228
|
+ * http://console.zx2049.com/api/cms/createTask?taskid=10
|
|
229
|
+ */
|
|
230
|
+ public function createTask()
|
|
231
|
+ {
|
|
232
|
+ $taskid = $this->request->get('taskid',0);
|
|
233
|
+ if((int)$taskid === 0){
|
|
234
|
+ $this->error('fail');
|
|
235
|
+ }
|
|
236
|
+
|
|
237
|
+ //查询
|
|
238
|
+ $add_time = Db::table('yzn_task')
|
|
239
|
+ ->where(['catid'=>$taskid])
|
|
240
|
+ ->order('add_time desc')
|
|
241
|
+ ->value('add_time');
|
|
242
|
+
|
|
243
|
+ if(empty($add_time)){
|
|
244
|
+ $add_time = 0;
|
|
245
|
+ }
|
|
246
|
+
|
|
247
|
+ //不做分批次处理
|
|
248
|
+ //新赠的产品 大类
|
|
249
|
+ $list = Db::table('yzn_cms_product')
|
|
250
|
+ ->where(['status'=>1]) //,'catid'=>2 不管是大类还是小类
|
|
251
|
+ ->where('add_time','>',$add_time)
|
|
252
|
+ ->select();
|
|
253
|
+
|
|
254
|
+ foreach ($list as $key=>$row){
|
|
255
|
+ $one = Db::name('task')->where([
|
|
256
|
+ 'catid' => $taskid,
|
|
257
|
+ 'aid' => $row['aid'],
|
|
258
|
+ 'diqu' => $row['diqu'],
|
|
259
|
+ 'yid' => $row['catid'],
|
|
260
|
+ 'cid' => 111,
|
|
261
|
+ ])->find();
|
|
262
|
+ if(empty($one)){
|
|
263
|
+ //插入数据库
|
|
264
|
+ $insert_data = [
|
|
265
|
+ 'catid' => $taskid, //任务分组id
|
|
266
|
+ 'title' => $row['title'],
|
|
267
|
+ 'add_time' => $row['add_time'],
|
|
268
|
+ 'create_time' => time(),
|
|
269
|
+ 'update_time' => time(),
|
|
270
|
+ 'status' => 0, //初始状态为0 未执行
|
|
271
|
+ 'diqu' => $row['diqu'],
|
|
272
|
+ 'yid' => $row['catid'], //产品大类还是小类
|
|
273
|
+ 'aid' => $row['aid'], //产品id
|
|
274
|
+ 'site_id' => 1,
|
|
275
|
+ 'link' => '', //文章链接
|
|
276
|
+ 'tagid' => 0, //标签id 初始为0
|
|
277
|
+ 'cid' => 111, //常见问题
|
|
278
|
+ 'run_time' => time(),
|
|
279
|
+ 'is_run' => 0
|
|
280
|
+ ];
|
|
281
|
+ $run = Db::name('task')->insert($insert_data);
|
|
282
|
+ echo '插入'.$run.'条,产品id: '.$row['aid'].'-'.$row['title'].'<br/>';
|
|
283
|
+ }else{
|
|
284
|
+ echo '插入0条,产品id: '.$row['aid'].'-'.$row['title'].'已存在<br/>';
|
|
285
|
+ }
|
|
286
|
+ }
|
|
287
|
+ }
|
|
288
|
+
|
|
289
|
+ /*
|
|
290
|
+ * http://console.zx2049.com/api/cms/tagHandle?taskid=10
|
|
291
|
+ */
|
|
292
|
+ public function tagHandle()
|
|
293
|
+ {
|
|
294
|
+
|
|
295
|
+ $taskid = $this->request->get('taskid',0);
|
|
296
|
+ if((int)$taskid === 0){
|
|
297
|
+ $this->error('fail');
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ $page = 1;
|
|
301
|
+ $list = Db::name('task')->where([
|
|
302
|
+ 'catid' => $taskid, //任务分组id
|
|
303
|
+ 'tagid' => 0,
|
|
304
|
+ 'status' => 0,
|
|
305
|
+ ])
|
|
306
|
+ ->order('add_time asc')->paginate(1);
|
|
307
|
+ $list = $list->toArray();
|
|
308
|
+ $data = $list['data'];
|
|
309
|
+ foreach ($data as $index => $row) {
|
|
310
|
+
|
|
311
|
+ //获取标签
|
|
312
|
+ $tagname = $this->getName($row['title']);
|
|
313
|
+ $tagname = $tagname.'申报';
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+ if((int)$row['diqu'] === 10000){
|
|
317
|
+ $diqu = 0; //山东地区变为主页 区域为0
|
|
318
|
+ }else{
|
|
319
|
+ $diqu = $row['diqu'];
|
|
320
|
+ }
|
|
321
|
+
|
|
322
|
+ $one = Db::connect('db1')->table('ey_archives')
|
|
323
|
+ ->where(['typeid' => 523,'province_id'=>$diqu,'is_del'=>0])
|
|
324
|
+ ->where('title',$tagname)
|
|
325
|
+ ->find();
|
|
326
|
+ if(empty($one)){
|
|
327
|
+
|
|
328
|
+ //不存在
|
|
329
|
+ //判断是否需要增加标签
|
|
330
|
+ //远程判断产品状态
|
|
331
|
+ if((int)$row['yid'] === 2) {
|
|
332
|
+ //大类
|
|
333
|
+ $one = Db::connect('db1')->table('ey_arctype')->where(['id' => $row['aid']])->find();
|
|
334
|
+ }else if((int)$row['yid'] === 3) {
|
|
335
|
+ //小类
|
|
336
|
+ $one = Db::connect('db1')->table('ey_arctype_cat')->where(['id' => $row['aid']])->find();
|
|
337
|
+ }else{
|
|
338
|
+ //任务异常 退出
|
|
339
|
+ $this->error('fail');
|
|
340
|
+ }
|
|
341
|
+
|
|
342
|
+ if((int)$one['is_del'] === 1 || (int)$one['status'] === 0){
|
|
343
|
+ //已删除
|
|
344
|
+ Db::name('task')->where(['id'=>$row['id']])->update([
|
|
345
|
+ 'is_run' => 4, //执行异常
|
|
346
|
+ 'run_time' => time(),
|
|
347
|
+ 'status' => 1,
|
|
348
|
+ ]);
|
|
349
|
+ $this->error('fail');
|
|
350
|
+ }
|
|
351
|
+
|
|
352
|
+ //是否只有一个页面 (远程)
|
|
353
|
+ if((int)$row['yid'] === 2) {
|
|
354
|
+ //大类
|
|
355
|
+ $count = Db::connect('db1')->table('ey_archives')->where(['typeid' => $row['aid'],'product_id'=>0,'is_del'=>0])->count();
|
|
356
|
+ }else if((int)$row['yid'] === 3) {
|
|
357
|
+ //小类
|
|
358
|
+ $count = Db::connect('db1')->table('ey_archives')->where(['product_id' => $row['aid'],'is_del'=>0])->count();
|
|
359
|
+ }else{
|
|
360
|
+ //任务异常 退出
|
|
361
|
+ $this->error('fail');
|
|
362
|
+ }
|
|
363
|
+ //dump($count);
|
|
364
|
+
|
|
365
|
+ if($count <= 1) {
|
|
366
|
+ //只有一个主页 概述
|
|
367
|
+ Db::name('task')->where(['id' => $row['id']])->update([
|
|
368
|
+ 'is_run' => 3, //执行忽略
|
|
369
|
+ 'run_time' => time(),
|
|
370
|
+ 'status' => 1,
|
|
371
|
+ ]);
|
|
372
|
+ $this->error('fail');
|
|
373
|
+ }
|
|
374
|
+
|
|
375
|
+ //创建标签
|
|
376
|
+ $insert_data = [
|
|
377
|
+ 'typeid' => 523,
|
|
378
|
+ 'status' => 1,
|
|
379
|
+ 'is_del' => 0,
|
|
380
|
+ 'channel' => 101,
|
|
381
|
+ 'click' => rand(500,5000),
|
|
382
|
+ 'arcrank' => 0,
|
|
383
|
+ 'add_time' => time(),
|
|
384
|
+ 'update_time' => time(),
|
|
385
|
+ 'province_id' => (int)$diqu,
|
|
386
|
+ 'product_tag_id' => 0, //由其他任务处理
|
|
387
|
+ 'title' => $tagname,
|
|
388
|
+ ];
|
|
389
|
+ //执行插入
|
|
390
|
+ $aid = Db::connect('db1')->table('ey_archives')->insertGetId($insert_data);
|
|
391
|
+ if((int)$aid > 0) {
|
|
392
|
+ //增加详情
|
|
393
|
+ $insert_data_content = [
|
|
394
|
+ 'aid' => $aid,
|
|
395
|
+ 'add_time' => time(),
|
|
396
|
+ 'update_time' => time()
|
|
397
|
+ ];
|
|
398
|
+ Db::connect('db1')->table('ey_suipian_content')->insert($insert_data_content);
|
|
399
|
+ }
|
|
400
|
+ //更新任务 标签id
|
|
401
|
+ Db::name('task')->where(['id' => $row['id']])->update([
|
|
402
|
+ 'tagid' => $aid,
|
|
403
|
+ ]);
|
|
404
|
+ $this->success('成功');
|
|
405
|
+ }else{
|
|
406
|
+ //写入标签id 到 任务记录
|
|
407
|
+ Db::name('task')->where(['id' => $row['id']])->update([
|
|
408
|
+ 'tagid' => $one['aid'],
|
|
409
|
+ ]);
|
|
410
|
+ $this->success('成功');
|
|
411
|
+ }
|
|
412
|
+ }
|
|
413
|
+ }
|
|
414
|
+
|
|
415
|
+ /*
|
|
416
|
+ * 执行
|
|
417
|
+ * 增加字段 is_run 未执行0 执行成功1 执行失败2(远程响应错误) 执行忽略3(存在小类或无级别-只有一个主页) 产品异常4(删除或未审核或屏蔽)
|
|
418
|
+ * run_time 执行时间
|
|
419
|
+ * is_run = 0 每次处理10条
|
|
420
|
+ * http://console.zx2049.com/api/cms/taskHandle?taskid=10
|
|
421
|
+ */
|
|
422
|
+ public function taskHandle()
|
|
423
|
+ {
|
|
424
|
+ $taskid = $this->request->get('taskid',0);
|
|
425
|
+ if((int)$taskid === 0){
|
|
426
|
+ $this->error('fail');
|
|
427
|
+ }
|
|
428
|
+
|
|
429
|
+ //查询未执行的任务
|
|
430
|
+ $page = 1;
|
|
431
|
+ $list = Db::name('task')->where([
|
|
432
|
+ 'catid' => $taskid, //任务分组id
|
|
433
|
+ 'is_run' => 0,
|
|
434
|
+ 'status' => 0,
|
|
435
|
+ ])
|
|
436
|
+ ->where('tagid','>',0) //标签id需要已经获取到的
|
|
437
|
+ ->order('add_time asc')->paginate(1);
|
|
438
|
+ $list = $list->toArray();
|
|
439
|
+ $data = $list['data'];
|
|
440
|
+ //dump($data);die;
|
|
441
|
+
|
|
442
|
+ /*
|
|
443
|
+ * 跨库 无法保证远程和本地的事务一致性
|
|
444
|
+ * 这种机制 类似 支付
|
|
445
|
+ * 先简单处理
|
|
446
|
+ */
|
|
447
|
+ foreach ($data as $index => $row) {
|
|
448
|
+
|
|
449
|
+ //远程判断产品状态
|
|
450
|
+ /*if((int)$row['yid'] === 2) {
|
|
451
|
+ //大类
|
|
452
|
+ $one = Db::connect('db1')->table('ey_arctype')->where(['id' => $row['aid']])->find();
|
|
453
|
+ }else if((int)$row['yid'] === 3) {
|
|
454
|
+ //小类
|
|
455
|
+ $one = Db::connect('db1')->table('ey_arctype_cat')->where(['id' => $row['aid']])->find();
|
|
456
|
+ }else{
|
|
457
|
+ //任务异常 退出
|
|
458
|
+ return false;
|
|
459
|
+ }
|
|
460
|
+
|
|
461
|
+ if((int)$one['is_del'] === 1 || (int)$one['status'] === 0){
|
|
462
|
+ //已删除
|
|
463
|
+ Db::name('task')->where(['id'=>$row['id']])->update([
|
|
464
|
+ 'is_run' => 4, //执行异常
|
|
465
|
+ 'run_time' => time(),
|
|
466
|
+ 'status' => 1,
|
|
467
|
+ ]);
|
|
468
|
+ return false;
|
|
469
|
+ }*/
|
|
470
|
+
|
|
471
|
+ /*
|
|
472
|
+ *
|
|
473
|
+ *
|
|
474
|
+ //不管有没有小类 只有一个主页 就执行忽略
|
|
475
|
+ if((int)$row['yid'] === 2) {
|
|
476
|
+ //该任务记录 为 大类 产品
|
|
477
|
+ //是否存在小类(控制台产品不保证是最新数据 采用远程判断)
|
|
478
|
+ Db::connect('db1')->table('ey_arctype_cat')->where(['parent_id' => $row['aid']])->find();
|
|
479
|
+ }*/
|
|
480
|
+
|
|
481
|
+ //是否只有一个页面 (远程)
|
|
482
|
+ /*if((int)$row['yid'] === 2) {
|
|
483
|
+ //大类
|
|
484
|
+ $count = Db::connect('db1')->table('ey_archives')->where(['typeid' => $row['aid'],'product_id'=>0,'is_del'=>0])->count();
|
|
485
|
+ }else if((int)$row['yid'] === 3) {
|
|
486
|
+ //小类
|
|
487
|
+ $count = Db::connect('db1')->table('ey_archives')->where(['product_id' => $row['aid'],'is_del'=>0])->count();
|
|
488
|
+ }else{
|
|
489
|
+ //任务异常 退出
|
|
490
|
+ return false;
|
|
491
|
+ }
|
|
492
|
+ //dump($count);
|
|
493
|
+
|
|
494
|
+ if($count <= 1) {
|
|
495
|
+ //只有一个主页 概述
|
|
496
|
+ Db::name('task')->where(['id' => $row['id']])->update([
|
|
497
|
+ 'is_run' => 3, //执行忽略
|
|
498
|
+ 'run_time' => time(),
|
|
499
|
+ 'status' => 1,
|
|
500
|
+ ]);
|
|
501
|
+ return false;
|
|
502
|
+ }*/
|
|
503
|
+
|
|
504
|
+ //构建参数
|
|
505
|
+ if((int)$row['diqu'] === 10000){
|
|
506
|
+ $diqu = 0; //山东地区变为主页 区域为0
|
|
507
|
+ }else{
|
|
508
|
+ $diqu = $row['diqu'];
|
|
509
|
+ }
|
|
510
|
+ $insert_data = [
|
|
511
|
+ 'typeid' => 111,
|
|
512
|
+ 'status' => 1,
|
|
513
|
+ 'is_del' => 0,
|
|
514
|
+ 'channel' => 103,
|
|
515
|
+ 'click' => rand(500,5000),
|
|
516
|
+ 'arcrank' => 0,
|
|
517
|
+ 'add_time' => time(),
|
|
518
|
+ 'update_time' => time(),
|
|
519
|
+ 'province_id' => (int)$diqu,
|
|
520
|
+ 'product_tag_id' => $row['tagid'], //由其他任务处理
|
|
521
|
+ 'title' => $this->getTitle($row,$diqu),
|
|
522
|
+ 'seo_title' => $this->getSeoTitle($row,$diqu),
|
|
523
|
+ 'seo_keywords' => $this->getKeywords($row,$diqu),
|
|
524
|
+ 'seo_description' => $this->getDesc($row,$diqu),
|
|
525
|
+ ];
|
|
526
|
+ //执行插入
|
|
527
|
+ $aid = Db::connect('db1')->table('ey_archives')->insertGetId($insert_data);
|
|
528
|
+
|
|
529
|
+ //$aid=1;
|
|
530
|
+ //dump($insert_data);die;
|
|
531
|
+
|
|
532
|
+ if((int)$aid > 0) {
|
|
533
|
+ //增加详情
|
|
534
|
+ $content = $this->getContent($row,$diqu);
|
|
535
|
+ //echo htmlspecialchars_decode($content);die;
|
|
536
|
+
|
|
537
|
+ $insert_data_content = [
|
|
538
|
+ 'aid' => $aid,
|
|
539
|
+ 'add_time' => time(),
|
|
540
|
+ 'update_time' => time(),
|
|
541
|
+ 'content_5' => $content
|
|
542
|
+ ];
|
|
543
|
+ Db::connect('db1')->table('ey_zczygz_content')->insert($insert_data_content);
|
|
544
|
+
|
|
545
|
+ //增加序列号
|
|
546
|
+ $where6 = [
|
|
547
|
+ "type" => 2,
|
|
548
|
+ "tid" => 111,
|
|
549
|
+ 'topid' => 0,
|
|
550
|
+ 'parentid' => 0,
|
|
551
|
+ 'area_id' => (int)$diqu, //如果是0的话 后续也不能改
|
|
552
|
+ 'city_id' => 0, //如果是0的话 后续也不能改
|
|
553
|
+ ];
|
|
554
|
+ $last = Db::connect('db1')->name('seo_number')
|
|
555
|
+ ->where($where6)->order('number desc')->find();
|
|
556
|
+ if (empty($last['number'])) {
|
|
557
|
+ $num = 1;
|
|
558
|
+ } else {
|
|
559
|
+ $num = (int)$last['number'] + 1;
|
|
560
|
+ }
|
|
561
|
+ $insert_data_seo = [
|
|
562
|
+ "type" => 2, //产品类型
|
|
563
|
+ "aid" => $aid, //实际的ID
|
|
564
|
+ "tid" => 111, //属于哪个栏目的
|
|
565
|
+ 'is_del' => 0,
|
|
566
|
+ 'is_kan' => 0, // 0正常 1审核
|
|
567
|
+ 'status' => 1,
|
|
568
|
+ 'area_id' => (int)$diqu,
|
|
569
|
+ 'city_id' => 0,
|
|
570
|
+ 'topid' => 0,
|
|
571
|
+ 'parentid' => 0,
|
|
572
|
+ 'number' => $num
|
|
573
|
+ ];
|
|
574
|
+ Db::connect('db1')->table('ey_seo_number')->insert($insert_data_seo);
|
|
575
|
+
|
|
576
|
+ //更新状态
|
|
577
|
+ if ((int)$diqu === 0) {
|
|
578
|
+ $link = 'https://www.gdzcfw.com/wthz' . $num;
|
|
579
|
+ } else {
|
|
580
|
+ $domain = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->value('domain');
|
|
581
|
+ $link = 'https://' . $domain . '.gdzcfw.com/wthz' . $num;
|
|
582
|
+ }
|
|
583
|
+ Db::name('task')->where(['id' => $row['id']])->update([
|
|
584
|
+ 'is_run' => 1, //执行成功
|
|
585
|
+ 'run_time' => time(),
|
|
586
|
+ 'status' => 1,
|
|
587
|
+ 'link' => $link,
|
|
588
|
+ ]);
|
|
589
|
+ $this->success('成功');
|
|
590
|
+ }
|
|
591
|
+ }
|
|
592
|
+ }
|
|
593
|
+
|
|
594
|
+ /*
|
|
595
|
+ * 产品名称处理
|
|
596
|
+ */
|
|
597
|
+ public function getName($str){
|
|
598
|
+ $str = str_replace('职称', "", $str);
|
|
599
|
+ $str = $str.'职称';
|
|
600
|
+ return $str;
|
|
601
|
+ }
|
|
602
|
+ /*
|
|
603
|
+ * 模板1
|
|
604
|
+ */
|
|
605
|
+ public function getTitle($row,$diqu)
|
|
606
|
+ {
|
|
607
|
+ $area_name = '';
|
|
608
|
+ if((int)$diqu > 0){
|
|
609
|
+ $area_name = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->value('name');
|
|
610
|
+ }
|
|
611
|
+ $title = $this->getName($row['title']);
|
|
612
|
+ $str = $area_name.$title.'评定【2024年最新学历要求】';
|
|
613
|
+ return $str;
|
|
614
|
+ }
|
|
615
|
+
|
|
616
|
+ public function getSeoTitle($row,$diqu)
|
|
617
|
+ {
|
|
618
|
+ $area_name = '';
|
|
619
|
+ if((int)$diqu > 0){
|
|
620
|
+ $area_name = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->value('name');
|
|
621
|
+ }
|
|
622
|
+ $title = $this->getName($row['title']);
|
|
623
|
+ $str = $area_name.$title.'评定【2024年最新要求解读】';
|
|
624
|
+ return $str;
|
|
625
|
+ }
|
|
626
|
+
|
|
627
|
+ public function getKeywords($row,$diqu){
|
|
628
|
+ $area_name = '';
|
|
629
|
+ if((int)$diqu > 0){
|
|
630
|
+ $area_name = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->value('name');
|
|
631
|
+ }
|
|
632
|
+ $title = $this->getName($row['title']);
|
|
633
|
+ $str = $area_name.$title.'评定';
|
|
634
|
+ return $str;
|
|
635
|
+ }
|
|
636
|
+
|
|
637
|
+ public function getDesc($row,$diqu){
|
|
638
|
+ $area_name = '';
|
|
639
|
+ if((int)$diqu > 0){
|
|
640
|
+ $area_name = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->value('name');
|
|
641
|
+ }
|
|
642
|
+ $title = $this->getName($row['title']);
|
|
643
|
+ $str = $area_name.$title.'评定上【职称网】工程师职称破格评审绿色通道,专注工程师职称评审,专注工程师职称评审,提供职称材料撰写、职称申报、职称论文专利一站式服务。';
|
|
644
|
+ return $str;
|
|
645
|
+ }
|
|
646
|
+
|
|
647
|
+ /*
|
|
648
|
+ * 模板1
|
|
649
|
+ */
|
|
650
|
+ public function getContent($row,$diqu)
|
|
651
|
+ {
|
|
652
|
+ $area_name = '';
|
|
653
|
+ $domain = 'www';
|
|
654
|
+ if((int)$diqu > 0){
|
|
655
|
+ $area = Db::connect('db1')->name('citysite')->where('id', '=', $diqu)->find();
|
|
656
|
+ $area_name = $area['name'];
|
|
657
|
+ $domain = $area['domain'];
|
|
658
|
+ }
|
|
659
|
+ $title = $this->getTitle($row,$diqu);
|
|
660
|
+
|
|
661
|
+ //图片地址
|
|
662
|
+ $op = rand(1,9);
|
|
663
|
+ $imgurl = 'https://oss.gdzcfw.com/static/article/'.$op.'.png';
|
|
664
|
+
|
|
665
|
+ $html = '';
|
|
666
|
+ $html .= '<p style="text-align: center;">
|
|
667
|
+ <img src="'.$imgurl.'" style="max-width:100%;" /><br/>
|
|
668
|
+ <span>'.$title.'</span>
|
|
669
|
+</p>';
|
|
670
|
+
|
|
671
|
+ //调用其他级别的学历要求
|
|
672
|
+ if((int)$row['yid'] === 2) {
|
|
673
|
+ //大类
|
|
674
|
+ $aids = Db::connect('db1')->table('ey_archives')->field('aid,title')->where(['typeid' => $row['aid'],'product_id'=>0,'is_del'=>0])->select();
|
|
675
|
+ }else if((int)$row['yid'] === 3) {
|
|
676
|
+ //小类
|
|
677
|
+ $aids = Db::connect('db1')->table('ey_archives')->field('aid,title')->where(['product_id' => $row['aid'],'is_del'=>0])->order('level asc')->select();
|
|
678
|
+ }
|
|
679
|
+
|
|
680
|
+ $h = ['一)','二)','三)','四)','五)','六)','七)','八)','九)','十)','十一)'];
|
|
681
|
+ foreach ($aids as $k=>$v){
|
|
682
|
+ $data = Db::connect('db1')->table('ey_zczygz_content')
|
|
683
|
+ ->field('aid,content_6')->where('aid','=',$v['aid'])->find();
|
|
684
|
+ if(!empty($data['content_6'])){
|
|
685
|
+ $pro_title = $this->getName($row['title']);
|
|
686
|
+ $html .= '<p style="text-align: left;font-weight: bold;">
|
|
687
|
+'.$h[$k].$area_name.$pro_title.'评定'.$v['title'].'学历要求:</p>';
|
|
688
|
+ $html .= '<p style="text-align: left;">
|
|
689
|
+ '.$data['content_6'].'</p>';
|
|
690
|
+ }
|
|
691
|
+ }
|
|
692
|
+
|
|
693
|
+ //拼装产品
|
|
694
|
+ if((int)$row['yid'] === 2) {
|
|
695
|
+ //大类
|
|
696
|
+ $number = Db::connect('db1')->table('ey_seo_number')->where([
|
|
697
|
+ 'type' => 1,
|
|
698
|
+ 'aid' => $row['aid'],
|
|
699
|
+ 'parentid' => 38
|
|
700
|
+ ])->value('number');
|
|
701
|
+ $link = 'https://'.$domain.'.gdzcfw.com/id'.$number;
|
|
702
|
+ }else if((int)$row['yid'] === 3) {
|
|
703
|
+ //小类
|
|
704
|
+ $one = Db::connect('db1')->table('ey_seo_number')->where([
|
|
705
|
+ 'type' => 1,
|
|
706
|
+ 'aid' => $row['aid'],
|
|
707
|
+ ])->where('parentid','!=',38)->find();
|
|
708
|
+ $number = Db::connect('db1')->table('ey_seo_number')->where([
|
|
709
|
+ 'type' => 1,
|
|
710
|
+ 'aid' => $one['parentid'],
|
|
711
|
+ 'parentid' => 38
|
|
712
|
+ ])->value('number');
|
|
713
|
+ $link = 'https://'.$domain.'.gdzcfw.com/id'.$number.'/sid'.$one['number'];
|
|
714
|
+ }
|
|
715
|
+
|
|
716
|
+ $html .= '<p style="text-align: left;">
|
|
717
|
+ 最新'.$area_name.$pro_title.'评定政策详情请点击:<a href="'.$link.'" targey="_blank">'.$area_name.$pro_title.'评审</a></p>';
|
|
718
|
+
|
|
719
|
+ //其他链接
|
|
720
|
+ $html .= '<p style="text-align: left;">
|
|
721
|
+ <a href="https://'.$domain.'.gdzcfw.com">职称网</a>更多<a href="https://'.$domain.'.gdzcfw.com">职称评审</a>相关请点击:<br/>
|
|
722
|
+ '.$area_name.'职称政策文件下载: <a href="https://'.$domain.'.gdzcfw.com/zccl">https://'.$domain.'.gdzcfw.com/zccl</a><br/>
|
|
723
|
+ 职称答辩相关指引请点击: <a href="https://www.gdzcfw.com/zcdb">https://www.gdzcfw.com/zcdb</a><br/>
|
|
724
|
+ 职称评审绿色破格通道: <a href="https://zczl.gdzcfw.com">https://zczl.gdzcfw.com</a><br/></p>';
|
|
725
|
+
|
|
726
|
+ return $html;
|
|
727
|
+ }
|
|
728
|
+
|
|
729
|
+ /*
|
|
730
|
+ * 执行忽略 重新校验
|
|
731
|
+ * 产品后面增加了级别 一开始没有级别 也没有小类
|
|
732
|
+ * 产品后面增加了级别 一开始没有级别 有小类
|
|
733
|
+ * 产品后面增加了小类 一开始没有级别 也没有小类
|
|
734
|
+ * 产品后面增加了小类 一开始有级别 没有小类
|
|
735
|
+ *
|
|
736
|
+ * 不管有没有小类 是大类还是小类 只要没有级别 就不发文 就对了
|
|
737
|
+ * 就算有小类 有级别 就发文
|
|
738
|
+ * 正常情况 不会存在既有级别又有小类
|
|
739
|
+ * 这里把执行忽略的 校验后 改为未执行
|
|
740
|
+ */
|
|
741
|
+
|
|
742
|
+ /*
|
|
743
|
+ * 校验产品如果正常了 任务改为未执行
|
|
744
|
+ */
|
|
745
|
+
|
|
746
|
+}
|