Install.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace addons\Redpack;
  3. use addons\Redpack\common\enums\RedpackEnum;
  4. use Yii;
  5. use yii\db\Exception;
  6. use yii\db\Migration;
  7. use common\interfaces\AddonWidget;
  8. use yii\helpers\Json;
  9. /**
  10. * 安装
  11. *
  12. * Class Install
  13. * @package addons\Redpack
  14. */
  15. class Install extends Migration implements AddonWidget
  16. {
  17. /**
  18. * @param $addon
  19. * @return mixed|void
  20. * @throws \yii\base\InvalidConfigException
  21. * @throws \yii\web\NotFoundHttpException
  22. * @throws \yii\web\UnprocessableEntityHttpException
  23. */
  24. public function run($addon)
  25. {
  26. // MigrateHelper::upByPath([
  27. // '@addons/Redpack/console/migrations/'
  28. // ]);
  29. }
  30. public function runApp($mall_id, $addons_name){
  31. // 商城应用市场安装时的初始化
  32. $config['basic'] = [
  33. 'frozen_status' => 2,
  34. 'give_type' => 2,
  35. 'redpack_name' => '红包',
  36. 'activation_num' => "",
  37. 'activation_time' => "",
  38. 'transfer_status' => 2,
  39. 'transfer_red_type' => Json::encode([RedpackEnum::WALLET_REDPACK_FROZEN, RedpackEnum::WALLET_REDPACK]),
  40. 'auth_status' => 1,
  41. 'transfer_percentage' => 0,
  42. 'transfer_out_status' => 2,
  43. 'transfer_out_type' => Json::encode([RedpackEnum::WALLET_REDPACK_FROZEN, RedpackEnum::WALLET_REDPACK]),
  44. 'transfer_out_mode' => "[1]",
  45. 'transfer_out_percentage' => "",
  46. 'transfer_out_service' => "",
  47. ];
  48. // 保存设置
  49. $res = Yii::$app->services->setting->addons->set($mall_id, $addons_name, $config);
  50. if ($res == false) throw new Exception('基础设置保存失败');
  51. return true;
  52. }
  53. }