public static function ad_delete(\ApiParam $params) { $user = User::user_show($params); $ad = self::loadAndCheck($params->adId, $user, false, $params->udid); $bakStatus = $ad->status; $ad->status = \Ad::STATUS_DELETED_BY_SELF; $ad->set('userDeletedTime', time()); $ad->set('bakStatus', $bakStatus); //保存删除前的状态以备用户误删恢复时用 if ($bakStatus == \Ad::STATUS_DELETED_BY_SELF) { //final delete $ad->set('final_delete', 1); } $ad->save(); \AdLogger::log($user, $ad, $ad->get('bakStatus'), \Ad::STATUS_DELETED_BY_SELF, 'via API: ' . $params->api_key, \AdLogger::TYPE_DELETE_BY_SELF); return true; }
public static function mobile_ad_refresh(\ApiParam $params) { //这个需要和Ad.php里面的ad_refresh合起来! @todo yubing self::mobile_ad_counter($params); if (!$params->mobile) { throw new \Exception('请下载最新版', 123); } $user = User::user_show($params); $ad = Ad::loadAndCheck($params->adId, $user, true, $params->udid); //1.刷新之前弹出alert框,询问用户“刷新可以让该信息重回顶部,您本月还能刷新该信息 N 次。” (N为用户当前在该类目的刷新限额) //确定刷新之后提示“刷新成功”。 if ($params->pay && $params->pay == '1') { //借用这个pay 参数来作为用户确认刷新(兼容老客户端) if ($ad->quotaRefresh()) { \AdLogger::log($user, $ad, null, null, '手机端刷新', \AdLogger::TYPE_REFRESH); return self::composeResponse(0, '刷新成功'); } else { return self::composeResponse(1, '免费刷新额度已经用完,手机端暂不支持余额刷新。'); } } else { //提示用户刷新额度 $quota = new \RefreshQuota($ad->userId, $ad->categoryEnglishName, $ad->cityEnglishName()); if ($quota->unused() > 0) { $message = '刷新可以让该信息重回顶部,您本月还能刷新该信息' . $quota->unused() . '次'; return self::composeResponse(2, $message); //2 -> 对话框提示 } else { return self::composeResponse(1, '无法刷新!本月免费刷新额度已经用完,请下月再试。'); } } }