InstallController.class.php
8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* 套件应用安装初始化数据
* 活动中心
* User: yingcai
* Date: 2017/11/22
* Time: 下午12:12
*/
namespace Rpc\Controller\Common;
use Common\Common\User;
use Common\Service\ActivityService;
use VcySDK\Attach;
use VcySDK\Exception;
use VcySDK\Service;
class InstallController extends AbstractController
{
public function Index()
{
$activity_serv = new ActivityService();
// 是否已经有默认数据
$default_data = $activity_serv->get_by_conds([]);
if (!$default_data) {
$result = [];
// 上传封面图片
$attach = new Attach(Service::instance());
try {
$picFile = CODE_ROOT . DIRECTORY_SEPARATOR . "www/static/img/activity/default_cover.jpeg";
$fileData = [
'file' => [
'name' => QY_DOMAIN . "default_cover.jpeg",
'type' => mime_content_type($picFile),
'size' => filesize($picFile),
'tmp_name' => $picFile,
],
];
$result = $attach->upload([
'atMediatype' => Attach::TYPE_IMG,
], $fileData);
} catch (Exception $e) {
\Think\Log::record('setDefaultMedal 方法内错误:::' . $e->getMessage());
} catch (\Exception $e) {
\Think\Log::record('setDefaultMedal 方法内错误:::' . $e->getMessage());
}
$userServ = &User::instance();
$result_user = $userServ->listBasicByConds([], 1, 1);
$unjoin_total = $result_user['total'];
// 写入默认数据
$data = [
'subject' => '【系统预设】真假学霸PK│快来晒出你的考试成绩!',
'source' => '员圈小助手',
'cover_id' => $result['atId'],
'begin_time' => MILLI_TIME,
'end_time' => 1917014400000,
'is_all' => 1,
'activity_status' => 1,
'publish_time' => MILLI_TIME,
'last_time' => MILLI_TIME,
'is_recomend' => 1,
'join_total' => 0,
'unjoin_total' => $unjoin_total,
'content' => serialize('<p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">这次,我们晒点不一样的?</p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">正所谓,成绩单是检验真假学霸的唯一标准</p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">接下来,请学霸们赶紧来切磋一下吧!</p><p class="p1" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">本次活动主题:真假学霸大<span class="s1" style="line-height: 1.5;">PK</span></p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">请在回帖中晒出一张使用本系统进行考试的成绩单</p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">获得点赞最多的前三名将会获得积分奖励!</p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">快来参与吧!</p><p class="p1" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);">注:此活动为预设内容,旨在帮助使用者熟悉了解活动应用。</p><p class="p2" style="margin-top: 0px; margin-bottom: 1em; padding: 0px; line-height: 1.5; color: rgb(54, 59, 66); font-family: "Helvetica Neue", "Helvetica Neue", Helvetica, Arial, "Lantinghei SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p>'),
];
$ac_id = $activity_serv->insert($data);
if ($ac_id) {
// 首页feed流推荐
$feed_right = [];
$url = rpcUrl('/Public/Rpc/Recommender/ArticleUpdate');
$data_send = [
'app' => APP_DIR,
'dataCategoryId' => '',
'dataId' => $ac_id,
'title' => $data['subject'],
'summary' => $data['content'],
'attachId' => $data['cover_id'],
'pic' => imgUrlReal($data['cover_id']),
'url' => 'Activity/Frontend/Index/Msg?type=1&id=' . $ac_id,
'endTime' => $data['end_time'],
'right' => $feed_right
];
\Com\Rpc::phprpc($url)->invoke('Index', $data_send);
}
}
}
}