'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'store_id' => 'Store ID', 'level' => 'Level', 'commission' => 'Commission', 'promote_commission' => 'Promote Commission', 'manage_commission' => 'Manage Commission', 'total_commission' => 'Total Commission', 'is_enable_manage_reward' => 'Is Enable Manage Reward', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'total_num' => 'Total Num', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,mobile,nickname,avatar_url,parent_id'); } public function getLevel(){ return $this->hasOne(WriteOffLevel::class, ['level' => 'level','mall_id'=>'mall_id'])->andWhere(['<>','status',StatusEnum::DELETE]); } public static function setData(array $params){ try{ if(!empty($params['user_id'])){ $model = self::findOne(['user_id' => $params['user_id'],'mall_id' => $params['mall_id'], 'status' => StatusEnum::ENABLED]); if(empty($model)) { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $params['mall_id']; } }elseif(!empty($params['id'])){ $model = self::findOne($params['id']); if(empty($model)) throw new \Exception('数据不存在或已删除'); } else { throw new \Exception('数据不存在或已删除'); } if(!$model->load($params,'') || !$model->save()){ throw new \Exception($model->getErrorMessage()); } return $model; }catch(\Exception $e){ self::setStaticError($e->getMessage()); return false; } } /** * @desc:推广中心-调用 * @return array */ public static function getIncomeInfo(array $params){ $is_install = MallAddons::isInstall($params['mall_id'], $params['addons_name']); $data['total_commission'] = 0; $data['is_install'] = 0; $data['is_show_at_center'] = 1; if($is_install){ $model = self::findOne(['user_id'=>$params['user_id'],'mall_id'=>$params['mall_id'],'status'=>[StatusEnum::ENABLED,StatusEnum::DISABLED]]); $data['total_commission'] = $model['total_commission']??0; $data['is_install'] = $is_install; } return $data; } }