public static function mobiletoken_update(\ApiParam $params) { if ($params->mobile) { try { $user = User::user_show($params); $userId = $user->id; $userMobile = $user->mobile; } catch (\Exception $e) { $userId = ''; $userMobile = ''; } } if ($params->userId) { try { $user = new \User(); $user->load($params->userId); $userId = $params->userId; $userMobile = $user->mobile; } catch (\Exception $e) { $userId = ''; $userMobile = ''; } } \NotificationToken::updateDevice($params->appType, $params->appVersion, $params->deviceUniqueIdentifier, $params->deviceToken, $userId, $userMobile); return true; }
public static function ad_refresh(\ApiParam $params) { $user = User::user_show($params); $ad = self::loadAndCheck($params->adId, $user, false, $params->udid); if ($user->id != $ad->userId) { return array('msg' => '您没有权限进行此操作'); } //免费刷新 if (\Business::ableToFreeRefresh($ad)) { \Ad::refresh($ad->id); return array('msg' => '免费刷新成功'); } if (\Business::maintainingMessage() && \Business::stopWrite()) { throw new \Exception(\Business::maintainingMessage()); } //余额刷新 if ($user->money() >= f2y(\Business::refreshPrice($ad->cityEnglishName(), $ad->categoryEnglishName, $ad->userId))) { $oid = \Business::createOrder($ad->id, \Order::TYPE_REFRESH); \Business::pay($oid); return array('msg' => '余额刷新成功'); } return array('msg' => '刷新失败', 'x' => "{$ad->posterType()}", 'time' => "{$ad->createdTime}"); }
public static function mobile_remove_favourites(\ApiParam $params) { $user = User::user_show($params); $class = "Follow\\Favorite"; $loader = new $class($user); $follow = $loader->exists($params->adId); if (!$follow || empty($follow)) { throw new \Exception('不是已收藏信息', 222); } $loader->destory($params->adId); $success = !$loader->exists($params->adId); return self::composeResponse($success ? 0 : 1, $success ? '取消收藏成功' : '取消收藏失败'); }