| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace addons\ScoreExpansion\common\services;
- use common\enums\AddonsEnum;
- use common\services\mall\BaseAdsSettingService;
- /**
- * SettingService class
- */
- class SettingService extends BaseAdsSettingService
- {
- /**
- * 默认设置
- * ['foo' => 'boo']
- *
- * @return array
- */
- public function defaultSetting(): array
- {
- return [
- 'frozen_status' => 2, 'transfer_status' => 2, 'activation_method' => 1, 'activation_num' => 0,
- 'give_type' => 2, 'transfer_out_status' => 2, 'transfer_red_type' => '[]', 'transfer_out_mode' => '[]',
- 'transfer_out_type' => '[]', 'integral_name' => '拓客积分', 'reward_period' => 0, 'reward_frozen_score' => 0,
- 'reward_person_count' => 0, 'loop_num' => 0, 'level_condition' => [], 'gift_method' => 0, 'score_reward_invert_freeze_points' => 0,
- 'is_enable_buy_goods_give_frozen_score' => 0, 'inactive_dates' => [], 'change_activation_integral' => 2
- ];
- }
- /**
- * 返回插件名称
- *
- * @return string
- */
- public function getAddosName(): string
- {
- return AddonsEnum::ADDONS_NAME_SCORE_EXPANSION;
- }
- /**
- * @param array $setting
- * @return array
- */
- public function beforeGetSetting(array $setting): array
- {
- isset($setting['buy_frozen_integral']) && $setting['buy_frozen_integral'] = json_decode($setting['buy_frozen_integral'], true);
- isset($setting['buy_integral']) && $setting['buy_integral'] = json_decode($setting['buy_integral'], true);
- isset($setting['parent_frozen_integral']) && $setting['parent_frozen_integral'] = json_decode($setting['parent_frozen_integral'], true);
- isset($setting['parent_integral']) && $setting['parent_integral'] = json_decode($setting['parent_integral'], true);
- isset($setting['store_frozen_integral']) && $setting['store_frozen_integral'] = json_decode($setting['store_frozen_integral'], true);
- isset($setting['store_integral']) && $setting['store_integral'] = json_decode($setting['store_integral'], true);
- isset($setting['parent_store_frozen_integral']) && $setting['parent_store_frozen_integral'] = json_decode($setting['parent_store_frozen_integral'], true);
- isset($setting['parent_store_integral']) && $setting['parent_store_integral'] = json_decode($setting['parent_store_integral'], true);
- isset($setting['level_condition']) && $setting['level_condition'] = json_decode($setting['level_condition'], true) ?: [];
- isset($setting['inactive_dates']) && $setting['inactive_dates'] = json_decode($setting['inactive_dates'], true) ?: [];
- return $setting;
- }
- /**
- * @return string
- */
- public function getTimeLimit()
- {
- return $this->getSetting()['time_limit'] ?? 0;
- }
- /**
- * 按最新冻结余额激活(等比)
- *
- * @return boolean
- */
- public function isEqualEatio()
- {
- return $this->getSetting()['activation_method'] == 1;
- }
- /**
- * 按初始冻结余额激活(递减)
- *
- * @return boolean
- */
- public function isDecrement()
- {
- return $this->getSetting()['activation_method'] == 2;
- }
- /**
- * 按固定数量激活(递减)
- *
- * @return boolean
- */
- public function isFixed()
- {
- return $this->getSetting()['activation_method'] == 3;
- }
-
- /**
- * 每日激活比例
- *
- * @return float
- */
- public function getActivationNum()
- {
- return $this->getSetting()['activation_num'];
- }
- }
|