1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-19 14:46:14 +08:00
course-tencent-cloud/db/migrations/20201212112717_data_202012121830.php
koogua 0336a54911 1.源文件增加版权信息
2.群组状态和课程协同
2021-06-13 15:49:47 +08:00

101 lines
2.7 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
use Phinx\Migration\AbstractMigration;
final class Data202012121830 extends AbstractMigration
{
public function up()
{
$noticeTemplate = json_encode([
'account_login' => '',
'order_finish' => '',
'refund_finish' => '',
'live_begin' => '',
'consult_reply' => '',
]);
$rows = [
[
'section' => 'wechat.oa',
'item_key' => 'enabled',
'item_value' => '0',
],
[
'section' => 'wechat.oa',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'wechat.oa',
'item_key' => 'app_secret',
'item_value' => '',
],
[
'section' => 'wechat.oa',
'item_key' => 'app_token',
'item_value' => '',
],
[
'section' => 'wechat.oa',
'item_key' => 'aes_key',
'item_value' => '',
],
[
'section' => 'wechat.oa',
'item_key' => 'notify_url',
'item_value' => '',
],
[
'section' => 'wechat.oa',
'item_key' => 'notice_template',
'item_value' => $noticeTemplate,
],
];
$this->table('kg_setting')->insert($rows)->save();
$this->updateSmsTemplate();
}
public function down()
{
$this->getQueryBuilder()
->delete('kg_setting')
->where(['section' => 'wechat.oa'])
->execute();
}
protected function updateSmsTemplate()
{
$setting = $this->getQueryBuilder()
->select('*')
->from('kg_setting')
->where(['section' => 'sms', 'item_key' => 'template'])
->execute()->fetch('assoc');
if (!$setting) return;
$itemValue = json_decode($setting['item_value'], true);
$newItemValue = json_encode([
'verify' => $itemValue['verify'] ?? '',
'order_finish' => $itemValue['order'] ?? '',
'refund_finish' => $itemValue['refund'] ?? '',
'live_begin' => $itemValue['live'] ?? '',
'consult_reply' => $itemValue['consult'] ?? '',
]);
$this->getQueryBuilder()
->update('kg_setting')
->where(['id' => $setting['id']])
->set('item_value', $newItemValue)
->execute();
}
}