| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace addons\Redpack;
- use addons\Redpack\common\enums\RedpackEnum;
- use Yii;
- use yii\db\Exception;
- use yii\db\Migration;
- use common\interfaces\AddonWidget;
- use yii\helpers\Json;
- /**
- * 安装
- *
- * Class Install
- * @package addons\Redpack
- */
- class Install extends Migration implements AddonWidget
- {
- /**
- * @param $addon
- * @return mixed|void
- * @throws \yii\base\InvalidConfigException
- * @throws \yii\web\NotFoundHttpException
- * @throws \yii\web\UnprocessableEntityHttpException
- */
- public function run($addon)
- {
- // MigrateHelper::upByPath([
- // '@addons/Redpack/console/migrations/'
- // ]);
- }
- public function runApp($mall_id, $addons_name){
- // 商城应用市场安装时的初始化
- $config['basic'] = [
- 'frozen_status' => 2,
- 'give_type' => 2,
- 'redpack_name' => '红包',
- 'activation_num' => "",
- 'activation_time' => "",
- 'transfer_status' => 2,
- 'transfer_red_type' => Json::encode([RedpackEnum::WALLET_REDPACK_FROZEN, RedpackEnum::WALLET_REDPACK]),
- 'auth_status' => 1,
- 'transfer_percentage' => 0,
- 'transfer_out_status' => 2,
- 'transfer_out_type' => Json::encode([RedpackEnum::WALLET_REDPACK_FROZEN, RedpackEnum::WALLET_REDPACK]),
- 'transfer_out_mode' => "[1]",
- 'transfer_out_percentage' => "",
- 'transfer_out_service' => "",
- ];
- // 保存设置
- $res = Yii::$app->services->setting->addons->set($mall_id, $addons_name, $config);
- if ($res == false) throw new Exception('基础设置保存失败');
- return true;
- }
- }
|