<?php /** * 套件应用安装初始化数据 * 积分 * @author zhoutao * @date 2017-09-27 10:05:30 */ namespace Rpc\Controller\Common; use Common\Common\Cache; use Common\Model\MedalModel; use Common\Service\MedalService; use Common\Service\PrizeService; use VcySDK\Attach; use VcySDK\Exception; use VcySDK\Integral; use VcySDK\Service; class InstallController extends AbstractController { public function index() { // 默认积分规则说明 $this->setDefaultIntegralRuleDesc(); // 默认奖品 $this->setDefaultPrize(); // 默认勋章 $this->setDefaultMedal(); // 默认学分规则说明 $this->setDefaultCreditRuleDesc(); return true; } /** * 默认积分规则说明 */ private function setDefaultIntegralRuleDesc() { // 获取当前配置信息 $cache = Cache::instance(); $strategySetting = $cache->get('Common.StrategySetting'); if (empty($strategySetting['eirsDesc'])) { $epConfig = $cache->get('Common.EnterpriseConfig'); $integralRule = '<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);"><span class="s1" style="line-height: 1.5;">“</span>【' . $epConfig['sitename'] . '】<span class="s1" style="line-height: 1.5;">”</span>积分规则说明</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="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);"><strong>一<span class="s1" style="line-height: 1.5;">,</span>积分获取规则</strong></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);">平台提供了多种途径来让员工获取积分<span class="s1" style="line-height: 1.5;">,</span>企业管理者可根据实际需求来设置相应的积分发放规则<span class="s1" style="line-height: 1.5;">,</span>具体说明如下<span class="s1" style="line-height: 1.5;">:</span></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);"><span class="s1" style="line-height: 1.5;">(1)</span>通过课程<span class="s1" style="line-height: 1.5;">,</span>考试<span class="s1" style="line-height: 1.5;">,</span>问答来关联相应的积分策略<span class="s1" style="line-height: 1.5;">,</span>员工学习课程<span class="s1" style="line-height: 1.5;">/</span>参与考试<span class="s1" style="line-height: 1.5;">/</span>进行问答达标后可以获得相应的积分奖励<span class="s1" style="line-height: 1.5;">;</span>另外<span class="s1" style="line-height: 1.5;">,</span>可以设置周期获取积分的最大次数<span class="s1" style="line-height: 1.5;">,</span>以此来限制积分最大值。</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);"><span class="s1" style="line-height: 1.5;">(2)</span>针对优秀的员工<span class="s1" style="line-height: 1.5;">,</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);"><br/></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);"><strong>二<span class="s1" style="line-height: 1.5;">,</span>积分消耗规则</strong></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);">平台提供了以下渠道来消耗积分<span class="s1" style="line-height: 1.5;">:</span>一是可以通过在<span class="s1" style="line-height: 1.5;">“</span>积分商城<span class="s1" style="line-height: 1.5;">”</span>兑换商品进行消耗<span class="s1" style="line-height: 1.5;">;</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);"><br/></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);"><strong>三<span class="s1" style="line-height: 1.5;">,</span>积分等级升级规则</strong></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);"><span class="s1" style="line-height: 1.5;">(1)</span>积分等级的升级依据有两种<span class="s1" style="line-height: 1.5;">:</span>累计获得积分和当前可用积分<span class="s1" style="line-height: 1.5;">,</span>如果选择<span class="s1" style="line-height: 1.5;">“</span>当前可用积分<span class="s1" style="line-height: 1.5;">”,</span>等级会随着积分的变化来升降<span class="s1" style="line-height: 1.5;">;</span>管理者可以根据企业实际需求来进行设置<span class="s1" style="line-height: 1.5;">;</span></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);"><span class="s1" style="line-height: 1.5;">(2)</span>等级设置<span class="s1" style="line-height: 1.5;">:</span>系统将会默认一套积分等级规则<span class="s1" style="line-height: 1.5;">,</span>默认十级<span class="s1" style="line-height: 1.5;">,</span>每级间隔为<span class="s1" style="line-height: 1.5;">100</span>积分<span class="s1" style="line-height: 1.5;">,</span>管理者可以根据企业需要进行设置修改。另外<span class="s1" style="line-height: 1.5;">,</span>为了满足企业个性化的需求<span class="s1" style="line-height: 1.5;">,</span>平台等级设置还可以按照不同的岗位<span class="s1" style="line-height: 1.5;">/</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);"><br/></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);"><strong>四<span class="s1" style="line-height: 1.5;">,</span>积分查看说明</strong></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);">个人积分信息查询<span class="s1" style="line-height: 1.5;">:</span>点击<span class="s1" style="line-height: 1.5;">“</span>员圈<span class="s1" style="line-height: 1.5;">-</span>我的<span class="s1" style="line-height: 1.5;">-</span>我的积分<span class="s1" style="line-height: 1.5;">”</span>进行查询。</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);"><span class="s1" style="line-height: 1.5;">(1)</span>积分规则<span class="s1" style="line-height: 1.5;">:</span>查看积分规则<span class="s1" style="line-height: 1.5;">;</span></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);"><span class="s1" style="line-height: 1.5;">(2)</span>积分排名<span class="s1" style="line-height: 1.5;">:</span>选择排名周期及排名范围<span class="s1" style="line-height: 1.5;">,</span>查看个人所在岗位积分排名<span class="s1" style="line-height: 1.5;">;</span>也可通过<span class="s1" style="line-height: 1.5;">“</span>员圈<span class="s1" style="line-height: 1.5;">-</span>首页<span class="s1" style="line-height: 1.5;">-</span>积分排名<span class="s1" style="line-height: 1.5;">”</span>进行查询<span class="s1" style="line-height: 1.5;">;</span></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);"><span class="s1" style="line-height: 1.5;">(3)</span>积分来源<span class="s1" style="line-height: 1.5;">:</span>查看个人积分来源明细。</p>'; try { $sdk = new Integral(Service::instance()); $sdk->updateSetting([ 'eirsId' => $strategySetting['eirsId'], 'eirsDesc' => $integralRule, 'miType' => 'mi_type0' ]); } catch (\Exception $e) { \Think\Log::record($e->getMessage()); } } $cache->set('Common.StrategySetting', null); return true; } /** * 默认奖品 */ private function setDefaultPrize() { $prizeServ = new PrizeService(); // 是否已经有默认数据 $defaultData = $prizeServ->get_by_conds([]); if (!$defaultData) { $result = []; // 上传默认图片 $attach = new Attach(Service::instance()); try { $picFile = CODE_ROOT . DIRECTORY_SEPARATOR . "www/static/img/integral/default_prize.png"; $fileData = [ 'file' => [ 'name' => QY_DOMAIN . "_default_prize.png", '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()); } // 写入默认数据 $prizeServ->insert([ 'name' => '【测试商品】移动/联通/电信 1G流量(测试商品请勿兑换)', 'sequence' => 1, 'on_sale' => 1, 'reserve' => 1000, 'integral' => 1000, 'desc' => ' <h3> <div style="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;"> <div style="line-height: 1.5;">积分中心—企业内部激励员工的管理体系.</div> <div style="line-height: 1.5;"> <div style="line-height: 1.5;">可以充分调动员工积极性,兼顾企业文化活跃与趣味性,同时积分支持企业内部奖品兑换,让员工真正玩起来。</div> </div> <div style="line-height: 1.5;"> <p class="p1" style="margin-bottom: 1em; line-height: 1.5;">此奖品为系统预设内容,旨在帮助使用者熟悉了解商城兑换功能,奖品不会实际发放。</p> </div> </div> </h3> ', 'picture' => $result['atId'] ]); } return true; } /** * 默认勋章 */ private function setDefaultMedal() { $medalServ = new MedalService(); $count = $medalServ->count(); if ($count > 0) { return true; } $insertAll = [ [ 'icon' => 'medal02', 'icon_type' => MedalModel::ICON_TYPE_SYS, 'name' => '初来乍到' ], [ 'icon' => 'medal03', 'icon_type' => MedalModel::ICON_TYPE_SYS, 'name' => '行业精英' ],[ 'icon' => 'medal08', 'icon_type' => MedalModel::ICON_TYPE_SYS, 'name' => '学习楷模' ],[ 'icon' => 'medal07', 'icon_type' => MedalModel::ICON_TYPE_SYS, 'name' => '专业人士' ],[ 'icon' => 'medal05', 'icon_type' => MedalModel::ICON_TYPE_SYS, 'name' => '资深专家' ], ]; $medalServ->insert_all($insertAll); return true; } /** * 默认学分规则说明 */ private function setDefaultCreditRuleDesc() { // 获取当前配置信息 $cache = Cache::instance(); $strategySetting = $cache->get('Common.StrategySettingCredit'); if (empty($strategySetting['eirsDesc'])) { $epConfig = $cache->get('Common.EnterpriseConfig'); $integralRule = '<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);"><span class="s1" style="line-height: 1.5;">“</span>【' . $epConfig['sitename'] . '】<span class="s1" style="line-height: 1.5;">”学分</span>规则说明</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="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);"><strong>一<span class="s1" style="line-height: 1.5;">,学分获得规则</span></strong></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);">平台提供了多种途径来让员工获取学分<span class="s1" style="line-height: 1.5;">,</span>企业管理者可根据实际需求来设置相应的学分发放规则<span class="s1" style="line-height: 1.5;">,</span>具体说明如下<span class="s1" style="line-height: 1.5;">:</span></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);"><span class="s1" style="line-height: 1.5;">(1)</span>通过课程<span class="s1" style="line-height: 1.5;">,</span>考试<span class="s1" style="line-height: 1.5;">,</span>问答来关联相应的学分策略<span class="s1" style="line-height: 1.5;">,</span>员工学习课程<span class="s1" style="line-height: 1.5;">/</span>参与考试<span class="s1" style="line-height: 1.5;">/</span>进行问答达标后可以获得相应的学分奖励<span class="s1" style="line-height: 1.5;">;</span>另外<span class="s1" style="line-height: 1.5;">,</span>可以设置周期获取学分的最大次数<span class="s1" style="line-height: 1.5;">,</span>以此来限制学分最大值。</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);"><span class="s1" style="line-height: 1.5;">(2)</span>针对优秀的员工<span class="s1" style="line-height: 1.5;">,</span>管理者可以在后台手动发放学分进行奖励。</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="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);"><strong><span class="s1" style="line-height: 1.5;">二,学分</span>查看说明</strong></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);">个人学分信息查询<span class="s1" style="line-height: 1.5;">:</span>点击<span class="s1" style="line-height: 1.5;">“</span>员圈<span class="s1" style="line-height: 1.5;">-</span>我的<span class="s1" style="line-height: 1.5;">-</span>学分<span class="s1" style="line-height: 1.5;">”</span>进行查询。</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);"><span class="s1" style="line-height: 1.5;">(1)学分</span>规则<span class="s1" style="line-height: 1.5;">:</span>查看学分规则<span class="s1" style="line-height: 1.5;">;</span></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);"><span class="s1" style="line-height: 1.5;">(2)学分明细</span><span class="s1" style="line-height: 1.5;">:</span>查看个人学分明细来源。<br/></p >'; try { $sdk = new Integral(Service::instance()); $sdk->updateSetting([ 'eirsId' => $strategySetting['eirsId'], 'eirsDesc' => $integralRule, 'miType' => 'mi_type1' ]); } catch (\Exception $e) { \Think\Log::record($e->getMessage()); } } $cache->set('Common.StrategySettingCredit', null); return true; } }