1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- use app\model\Permission;
- use think\migration\Migrator;
- use think\migration\db\Column;
- class CreateOutCallTable extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- $had = Permission::where(['auth_name' => '外呼设置'])->find();
- if (!$had) {
- $parent = Permission::where(['auth_name' => '企业管理'])->find();
- $data = [
- 'pid' => $parent->id,
- 'auth_name' => '外呼设置',
- 'uri' => 'yhuatong/setting',
- 'is_menu' => 1,
- 'sort' => 53,
- 'relation' => 'yhuatong/setting,yhuatong/balence,yhuatong/settingSave,yhuatong/comIndustryList'
- ];
- // 添加权限
- Permission::create($data);
- }
- // 创建配置表
- $this->table('out_call_setting', ['comment' => '外呼系统设置'])
- ->addColumn('root_id', 'integer', ['comment' => '所属企业id'])
- ->addColumn('type', 'string', ['comment' => '外呼系统类型'])
- ->addColumn('config', 'json', ['comment' => '外呼系统配置'])
- ->create();
- // 创建通话记录表
- $this->table('out_call_log', ['comment' => '外呼记录'])
- ->addColumn('session_id', 'string', ['comment' => '唯一标识ID'])
- ->addColumn('bind_num', 'string', ['comment' => '中间号'])
- ->addColumn('caller_num', 'string', ['comment' => '主叫'])
- ->addColumn('callee_num', 'string', ['comment' => '被叫'])
- ->addColumn('fwd_start_time', 'string', ['comment' => '外呼开始时间', 'null' => true])
- ->addColumn('call_end_time', 'string', ['comment' => '通话结束时间', 'null' => true])
- ->addColumn('billsec', 'integer', ['comment' => '通话时长(秒)', 'null' => true])
- ->addColumn('status', 'integer', ['comment' => '通话状态 1-接通 -1-未接通 -2未拨打', 'default' => -2])
- ->addColumn('call_status', 'integer', ['comment' => '释放原因', 'null' => true])
- ->addColumn('employee_id', 'integer', ['comment' => '员工id'])
- ->addColumn('root_id', 'integer', ['comment' => '企业ID'])
- ->addColumn('customer_id', 'integer', ['comment' => '客户id'])
- ->addColumn('key', 'string', ['comment' => '录音key', 'null' => true])
- ->addColumn('hash', 'string', ['comment' => '文件hash', 'null' => true])
- ->addColumn('fsize', 'string', ['comment' => '文件大小', 'null' => true])
- ->addColumn('url', 'string', ['comment' => '录音地址', 'null' => true])
- ->addColumn('call_id', 'string', ['comment' => '呼叫id', 'null' => true])
- ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP'])
- ->create();
- // 跟踪记录添加跟踪类型
- $this->table('customer_visit_log')
- ->addColumn('data_type', 'string', ['comment' => '多态关联类型', 'null' => true])
- ->addColumn('data_id', 'integer', ['comment' => '多态关联类型id', 'null' => true])
- ->update();
- }
- }
|