SettingService.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace addons\ScoreExpansion\common\services;
  3. use common\enums\AddonsEnum;
  4. use common\services\mall\BaseAdsSettingService;
  5. /**
  6. * SettingService class
  7. */
  8. class SettingService extends BaseAdsSettingService
  9. {
  10. /**
  11. * 默认设置
  12. * ['foo' => 'boo']
  13. *
  14. * @return array
  15. */
  16. public function defaultSetting(): array
  17. {
  18. return [
  19. 'frozen_status' => 2, 'transfer_status' => 2, 'activation_method' => 1, 'activation_num' => 0,
  20. 'give_type' => 2, 'transfer_out_status' => 2, 'transfer_red_type' => '[]', 'transfer_out_mode' => '[]',
  21. 'transfer_out_type' => '[]', 'integral_name' => '拓客积分', 'reward_period' => 0, 'reward_frozen_score' => 0,
  22. 'reward_person_count' => 0, 'loop_num' => 0, 'level_condition' => [], 'gift_method' => 0, 'score_reward_invert_freeze_points' => 0,
  23. 'is_enable_buy_goods_give_frozen_score' => 0, 'inactive_dates' => [], 'change_activation_integral' => 2
  24. ];
  25. }
  26. /**
  27. * 返回插件名称
  28. *
  29. * @return string
  30. */
  31. public function getAddosName(): string
  32. {
  33. return AddonsEnum::ADDONS_NAME_SCORE_EXPANSION;
  34. }
  35. /**
  36. * @param array $setting
  37. * @return array
  38. */
  39. public function beforeGetSetting(array $setting): array
  40. {
  41. isset($setting['buy_frozen_integral']) && $setting['buy_frozen_integral'] = json_decode($setting['buy_frozen_integral'], true);
  42. isset($setting['buy_integral']) && $setting['buy_integral'] = json_decode($setting['buy_integral'], true);
  43. isset($setting['parent_frozen_integral']) && $setting['parent_frozen_integral'] = json_decode($setting['parent_frozen_integral'], true);
  44. isset($setting['parent_integral']) && $setting['parent_integral'] = json_decode($setting['parent_integral'], true);
  45. isset($setting['store_frozen_integral']) && $setting['store_frozen_integral'] = json_decode($setting['store_frozen_integral'], true);
  46. isset($setting['store_integral']) && $setting['store_integral'] = json_decode($setting['store_integral'], true);
  47. isset($setting['parent_store_frozen_integral']) && $setting['parent_store_frozen_integral'] = json_decode($setting['parent_store_frozen_integral'], true);
  48. isset($setting['parent_store_integral']) && $setting['parent_store_integral'] = json_decode($setting['parent_store_integral'], true);
  49. isset($setting['level_condition']) && $setting['level_condition'] = json_decode($setting['level_condition'], true) ?: [];
  50. isset($setting['inactive_dates']) && $setting['inactive_dates'] = json_decode($setting['inactive_dates'], true) ?: [];
  51. return $setting;
  52. }
  53. /**
  54. * @return string
  55. */
  56. public function getTimeLimit()
  57. {
  58. return $this->getSetting()['time_limit'] ?? 0;
  59. }
  60. /**
  61. * 按最新冻结余额激活(等比)
  62. *
  63. * @return boolean
  64. */
  65. public function isEqualEatio()
  66. {
  67. return $this->getSetting()['activation_method'] == 1;
  68. }
  69. /**
  70. * 按初始冻结余额激活(递减)
  71. *
  72. * @return boolean
  73. */
  74. public function isDecrement()
  75. {
  76. return $this->getSetting()['activation_method'] == 2;
  77. }
  78. /**
  79. * 按固定数量激活(递减)
  80. *
  81. * @return boolean
  82. */
  83. public function isFixed()
  84. {
  85. return $this->getSetting()['activation_method'] == 3;
  86. }
  87. /**
  88. * 每日激活比例
  89. *
  90. * @return float
  91. */
  92. public function getActivationNum()
  93. {
  94. return $this->getSetting()['activation_num'];
  95. }
  96. }