| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace Modules\InnerApi\Services;
- use App\Constants\RedisKeysConstant;
- use App\Models\Mysql\AgentModel;
- use App\Models\Mysql\ConfigModel;
- use App\Models\Mysql\UsersRulesModel;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Cache;
- class DeductionService
- {
- /**
- * 缓存时间
- * @var int
- */
- private $cacheTiem = 300;
- /**
- * 获取扣量配置
- * @param $agentUserId
- * @return mixed
- * @directions
- * 思路:1.如果渠道app是代理开出来的,那么就需要再查推广的规则配置
- * 2.如果渠道app是推广开出来的,那就只有一级直接把规则返回
- */
- public function rulesInfo($agentUserId)
- {
- $res = Cache::remember(
- RedisKeysConstant::CANNEL_USER_RULES.$agentUserId,
- $this->cacheTiem,
- function () {
- $data = ConfigModel::where(['sgroup' => 'sys', 'skey' => 'global_deduction_rules'])->first();
- $arrData = !empty($data->svalue) ? json_decode($data->svalue, true) : [];
- return ['deductionRule' => $arrData];
- }
- );
- return $res;
- }
- }
|