Install.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace addons\Boss;
  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\Boss
  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/Boss/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. 'is_sediment' => 0,//是否开启股东分红沉淀池
  41. 'sediment_type' => 1,//沉淀池资金类型
  42. 'sediment_percent' => 0,//沉淀池比例
  43. 'detail' => '',//股东分红说明
  44. ];
  45. // 保存设置
  46. $res = Yii::$app->services->setting->addons->set($mall_id, $addons_name, $config);
  47. if ($res == false) throw new Exception('基础设置保存失败');
  48. return true;
  49. }
  50. }