Commit 36259fb8 authored by zw's avatar zw

个人中心升级看铺数

parent 1dbd7428
......@@ -70,15 +70,20 @@ class LookShop extends Basic{
if(count($agentList) <= 0){
return $this->response("101","request null");
}
$showArr = [];
$noShowArr = [];
foreach ($agentList as $key=>$item){
$residue_num = $this->lookShopService_->isLookShop($item["id"]);
if($residue_num <= 0){
$agentList[$key]["is_show_button"] = true;
$item["is_show_button"] = true;
array_push($showArr,$item);
}else{
$agentList[$key]["is_show_button"] = false;
$item["is_show_button"] = false;
array_push($noShowArr,$item);
}
}
return $this->response("200","request success",$agentList);
array_push($showArr,$noShowArr);
return $this->response("200","request success",$showArr);
}
}
\ No newline at end of file
......@@ -176,7 +176,7 @@ class Shop extends Basic
$param["img_type"] = 1; //默认主图
$result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1);
if ($params["site_area"] == 3) {
$isLook = $this->lookShopService_->isLooked($this->agentId,$val["id"]);
$isLook = $this->lookShopService_->isLooked($this->agentId, $val["id"]);
$result[$key]["is_look"] = $isLook;
}
}
......@@ -282,10 +282,15 @@ class Shop extends Basic
if ($params["site_area"] == 3 && $result) {
$lookShopArr = $this->lookShopService_->countLookShopNum((int)$this->agentId, (int)$params["id"]);
//判断看铺数量是否上限
if ($lookShopArr["residue_num"] == 0 && !$lookShopArr["isExist"] && !$lookShopArr["isPanParty"]) {
return $this->response("102", "您今天的看铺数量已达上限!");
if ($lookShopArr) {
if ($lookShopArr["residue_num"] == 0 && !$lookShopArr["isExist"] && !$lookShopArr["isPanParty"]) {
Log::record('info ----countLookShopNum------121113-', "info");
return $this->response("102", "您今天的看铺数量已达上限!");
}
$result["lookShopArr"] = $lookShopArr;
}
$result["lookShopArr"] = $lookShopArr;
}
return $this->response("200", 'request success', $result);
}
......
......@@ -3,6 +3,7 @@
namespace app\api_broker\service;
use app\extra\RedisExt;
use app\model\AAgents;
use app\model\GHousesToAgents;
use think\Log;
......@@ -18,6 +19,7 @@ class LookShopService
private $redis;
private $nowTime;
private $gHousesToAgentsModel;
private $agentsModel;
const LOOK_SHOP = "look_shop_";//存入已看的楼盘id
const LOOK_TOTAL = "look_total_";//记录每个经纪人的看铺总数
......@@ -27,13 +29,31 @@ class LookShopService
$this->redis = RedisExt::getRedis();
$this->nowTime = date("Y-m-d", time());
$this->gHousesToAgentsModel = new GHousesToAgents();
$this->agentsModel = new AAgents();
}
/**
* 验证数量
* @param int $agent_id
* @param int $house_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function countLookShopNum(int $agent_id, int $house_id): array
{
//todo 1.取读控制里面的看铺数量,2.取出此经济人已看数量和商铺 3.判断时间,每天刷新看铺数量
// todo 4.判断是否到达上限,if 上限 return false else return true
//todo 过滤掉店长以上的经纪人
$agentInfo = $this->agentsModel->getAgentById("id,level",["agent_id"=>$agent_id]);
Log::record('info ----countLookShopNum-------' . json_encode($agentInfo), "info");
if($agentInfo && $agentInfo[0]["level"] > 10){
Log::record('info ----countLookShopNum------123-' , "info");
return [];
}
//过滤掉盘方为自己的
$params["houses_id"] = $house_id;
$params["agents_id"] = $agent_id;
......
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