'自增id', 'mall_id' => '商城id', 'user_id' => '增加库存代理商用户id', 'level' => '等级', 'self_num' => '自身补货数量', 'direct_num' => '直推们的数量,等级一致', 'indirect_num' => '间推们数量,等级一致', 'start' => 'Start', 'end' => 'End', 'money' => '奖励金额', 'award_proportion_settlement_type' => 'Is Award Proportion Settlement', 'is_upgrade_bag_give_goods' => 'Is Upgrade Bag Give Goods', 'is_equal_2_step' => 'Is Equal 2 Step', 'award_proportion' => 'award_proportion', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,mobile,nickname,avatar_url,parent_id'); } public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new \Exception('服务不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }