Install.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace addons\BossWeight;
  3. use Yii;
  4. use yii\db\Exception;
  5. use yii\db\Migration;
  6. use common\helpers\MigrateHelper;
  7. use common\interfaces\AddonWidget;
  8. use common\traits\ErrorTrait;
  9. /**
  10. * 安装
  11. *
  12. * Class Install
  13. * @package addons\BossWeight
  14. */
  15. class Install extends Migration implements AddonWidget
  16. {
  17. use ErrorTrait;
  18. /**
  19. * @param $addon
  20. * @return mixed|void
  21. * @throws \yii\base\InvalidConfigException
  22. * @throws \yii\web\NotFoundHttpException
  23. * @throws \yii\web\UnprocessableEntityHttpException
  24. */
  25. public function run($addon)
  26. {
  27. // MigrateHelper::upByPath([
  28. // '@addons/BossWeight/console/migrations/'
  29. // ]);
  30. }
  31. public function runApp($mall_id, $addons_name)
  32. {
  33. // 基础配置-初始化
  34. $config['basic'] = [
  35. 'is_enable' => 0,// 启用插件
  36. 'compute_type' => 0,//佣金计算方式
  37. 'compute_period' => 1,//结算周期
  38. 'settlement_method' => 0,//结算方式
  39. 'settlement_period' => 1,//佣金结算周期
  40. 'detail' => '',//股东分红说明
  41. ];
  42. // 保存设置
  43. $res = Yii::$app->services->setting->addons->set($mall_id, $addons_name, $config);
  44. if ($res == false) throw new Exception('基础设置保存失败');
  45. return true;
  46. }
  47. }