20221229013714_create_out_call_table.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. use app\model\Permission;
  3. use think\migration\Migrator;
  4. use think\migration\db\Column;
  5. class CreateOutCallTable extends Migrator
  6. {
  7. /**
  8. * Change Method.
  9. *
  10. * Write your reversible migrations using this method.
  11. *
  12. * More information on writing migrations is available here:
  13. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14. *
  15. * The following commands can be used in this method and Phinx will
  16. * automatically reverse them when rolling back:
  17. *
  18. * createTable
  19. * renameTable
  20. * addColumn
  21. * renameColumn
  22. * addIndex
  23. * addForeignKey
  24. *
  25. * Remember to call "create()" or "update()" and NOT "save()" when working
  26. * with the Table class.
  27. */
  28. public function change()
  29. {
  30. $had = Permission::where(['auth_name' => '外呼设置'])->find();
  31. if (!$had) {
  32. $parent = Permission::where(['auth_name' => '企业管理'])->find();
  33. $data = [
  34. 'pid' => $parent->id,
  35. 'auth_name' => '外呼设置',
  36. 'uri' => 'yhuatong/setting',
  37. 'is_menu' => 1,
  38. 'sort' => 53,
  39. 'relation' => 'yhuatong/setting,yhuatong/balence,yhuatong/settingSave,yhuatong/comIndustryList'
  40. ];
  41. // 添加权限
  42. Permission::create($data);
  43. }
  44. // 创建配置表
  45. $this->table('out_call_setting', ['comment' => '外呼系统设置'])
  46. ->addColumn('root_id', 'integer', ['comment' => '所属企业id'])
  47. ->addColumn('type', 'string', ['comment' => '外呼系统类型'])
  48. ->addColumn('config', 'json', ['comment' => '外呼系统配置'])
  49. ->create();
  50. // 创建通话记录表
  51. $this->table('out_call_log', ['comment' => '外呼记录'])
  52. ->addColumn('session_id', 'string', ['comment' => '唯一标识ID'])
  53. ->addColumn('bind_num', 'string', ['comment' => '中间号'])
  54. ->addColumn('caller_num', 'string', ['comment' => '主叫'])
  55. ->addColumn('callee_num', 'string', ['comment' => '被叫'])
  56. ->addColumn('fwd_start_time', 'string', ['comment' => '外呼开始时间', 'null' => true])
  57. ->addColumn('call_end_time', 'string', ['comment' => '通话结束时间', 'null' => true])
  58. ->addColumn('billsec', 'integer', ['comment' => '通话时长(秒)', 'null' => true])
  59. ->addColumn('status', 'integer', ['comment' => '通话状态 1-接通 -1-未接通 -2未拨打', 'default' => -2])
  60. ->addColumn('call_status', 'integer', ['comment' => '释放原因', 'null' => true])
  61. ->addColumn('employee_id', 'integer', ['comment' => '员工id'])
  62. ->addColumn('root_id', 'integer', ['comment' => '企业ID'])
  63. ->addColumn('customer_id', 'integer', ['comment' => '客户id'])
  64. ->addColumn('key', 'string', ['comment' => '录音key', 'null' => true])
  65. ->addColumn('hash', 'string', ['comment' => '文件hash', 'null' => true])
  66. ->addColumn('fsize', 'string', ['comment' => '文件大小', 'null' => true])
  67. ->addColumn('url', 'string', ['comment' => '录音地址', 'null' => true])
  68. ->addColumn('call_id', 'string', ['comment' => '呼叫id', 'null' => true])
  69. ->addColumn('addtime', 'timestamp', ['comment' => '添加时间', 'default' => 'CURRENT_TIMESTAMP'])
  70. ->create();
  71. // 跟踪记录添加跟踪类型
  72. $this->table('customer_visit_log')
  73. ->addColumn('data_type', 'string', ['comment' => '多态关联类型', 'null' => true])
  74. ->addColumn('data_id', 'integer', ['comment' => '多态关联类型id', 'null' => true])
  75. ->update();
  76. }
  77. }