Commit ccff1ab9 authored by zw's avatar zw

看铺数量控制

parent 548c4d55
......@@ -275,11 +275,12 @@ class Shop extends Basic
$lookShopService_ = new LookShopService();
//todo 计数开始
//todo 判断盘方是否是自己
if($params["site_area"] == 3 && $result){
$lookShopArr = $lookShopService_->countLookShopNum((int)$this->agentId,(int)$params["id"]);
if($lookShopArr["residue_num"] == 0 && !$lookShopArr["isExist"]){
//todo 判断看铺数量是否上限
return $this->response("101", "您今天的看铺数量已达上限!");
return $this->response("102", "您今天的看铺数量已达上限!");
}
$result["lookShopArr"] = $lookShopArr;
}
......
......@@ -3,6 +3,7 @@
namespace app\api_broker\service;
use app\extra\RedisExt;
use app\model\GHousesToAgents;
use think\Log;
/**
......@@ -16,6 +17,7 @@ class LookShopService
{
private $redis;
private $nowTime;
private $gHousesToAgentsModel;
const LOOK_SHOP = "look_shop_";//存入已看的楼盘id
const LOOK_TOTAL = "look_total_";//记录每个经纪人的看铺总数
......@@ -24,6 +26,7 @@ class LookShopService
$this->redis = RedisExt::getRedis();
$this->nowTime = date("Y-m-d", time());
$this->gHousesToAgentsModel = new GHousesToAgents();
}
......@@ -31,16 +34,23 @@ class LookShopService
{
//todo 1.取读控制里面的看铺数量,2.取出此经济人已看数量和商铺 3.判断时间,每天刷新看铺数量
// todo 4.判断是否到达上限,if 上限 return false else return true
//过滤掉盘方为自己的
$params["houses_id"] = $house_id;
$params["agents_id"] = $agent_id;
$params["type"] = 2;
$params["is_del"] = 1;
$housesToAgents = $this->gHousesToAgentsModel->getHouseToAgents("id",$params);
$isPanParty = count($housesToAgents) > 0 ? true : false;
//判断楼盘是否看过,看过了则不判断数量
$isExist = $this->isLooked($agent_id,$house_id);
$lookShopNum = $this->isLookShop($agent_id);
if ($lookShopNum > 0 && !$isExist) {
if ($lookShopNum > 0 && !$isExist && !$isPanParty) {
$this->redis->sAdd(self::LOOK_SHOP . $this->nowTime . $agent_id, $house_id);//存入楼盘信息
$this->incrementLookNum($agent_id);
}
$totalNum = $this->redis->hGet(self::LOOK_TOTAL . $this->nowTime, $agent_id);
return [ "total_num" => $totalNum, "residue_num" => $lookShopNum ,"isExist"=>$isExist];
return [ "total_num" => $totalNum, "residue_num" => $lookShopNum ,"isExist"=>$isExist ,"isPanParty"=>$isPanParty];
}
......
......@@ -262,4 +262,13 @@ class GHousesToAgents extends BaseModel
public function updateUserAll($data) {
return $this->saveAll($data);
}
public function getHouseToAgents($field,$params){
return Db::table($this->table)
->field($field)
->where($params)
->limit(1)
->select();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment