'ID', 'mall_id' => '商城ID', 'user_id' => '服务商ID', 'direct_num' => '好友人数', 'achievement' => '服务商团队业绩,单位:元', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public static function setData($mall_id, $user_id, $direct_num = 0, $achievement = 0) { try { $model = self::findOne(['user_id' => $user_id, 'status' => StatusEnum::ENABLED]); if (empty($model)) { $model = new self(); $model->mall_id = $mall_id; $model->user_id = $user_id; $model->loadDefaultValues(); } !empty($direct_num) && $model->direct_num += $direct_num; !empty($achievement) && $model->achievement += $achievement; if (!$model->save()) throw new Exception($model->getErrorMessage()); return true; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } }