Commit e1d42b42 authored by clone's avatar clone

1

parent 494e29e7
......@@ -418,6 +418,18 @@ class Shop extends Basic
$result['shop_videos'] = $s_house->getHouseVideoList($params["id"]);
$result['shop_videos_length'] = $s_house->getHouseVideoLength();
$lookShopArr = $this->lookShopService_->addUserLookShop((int)$params["user_id"], (int)$params["id"]);
//判断看铺数量是否上限
if ($lookShopArr) {
if ($lookShopArr["residue_num"] == 0 && !$lookShopArr["isExist"] && !$lookShopArr["isPanParty"]) {
Log::record('info ----countLookShopNum------121113-', "info");
return $this->response("102", "您今天的看铺数量已达上限!");
}
$result["lookShopArr"] = $lookShopArr;
}
return $this->response("200", 'request success', $result);
}
......
......@@ -6,6 +6,7 @@ use app\extra\RedisExt;
use app\model\AAgents;
use app\model\GHousesToAgents;
use app\model\SystemConfig;
use app\model\TLookShopUser;
use RedisException;
use think\Exception;
use think\Log;
......@@ -25,6 +26,7 @@ class LookShopService
private $agentsModel;
private $systemConfigModel;
const LOOK_SHOP = "look_shop_";//存入已看的楼盘id
const LOOK_SHOP_USER = "look_shop_user_";//会员user
const LOOK_TOTAL = "look_total_";//记录每个经纪人的看铺总数
const LOOK_UP_NUM = "look_up_num_";//记录每个经纪人的看铺升级次数
......@@ -57,12 +59,12 @@ class LookShopService
return [];
}
//todo 过滤掉店长以上的经纪人 0824所有的都看铺限制
/* $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 [];
}*/
/* $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;
......@@ -80,7 +82,7 @@ class LookShopService
$this->incrementLookNum($agent_id);
}
$totalNum = $this->redis->hGet(self::LOOK_UP_NUM . $this->nowTime, $agent_id) * $this->redis->get("lookNum");
return [ "total_num" => $totalNum, "residue_num" => $lookShopNum, "isExist" => $isExist, "isPanParty" => $isPanParty ];
return ["total_num" => $totalNum, "residue_num" => $lookShopNum, "isExist" => $isExist, "isPanParty" => $isPanParty];
}
......@@ -135,7 +137,7 @@ class LookShopService
$lookNum = 50;//默认50看铺数量
if (!$this->redis->get("lookNum")) {
//数据库查询
$data = $this->systemConfigModel->getSetting([ "config_type" => 40 ], "rule");
$data = $this->systemConfigModel->getSetting(["config_type" => 40], "rule");
if ($data && $data["agent_shop_num"] > 0) {
$lookNum = $data["agent_shop_num"];
}
......@@ -183,10 +185,10 @@ class LookShopService
return false;
}
$agentUpNum = $this->redis->hGet(self::LOOK_UP_NUM . $this->nowTime, $agent_id);
if($agentUpNum >= 2){
if ($agentUpNum >= 2) {
return false;
}
$upLookNum = (int)$agentUpNum + 1;
$upLookNum = (int)$agentUpNum + 1;
$this->redis->hSet(self::LOOK_UP_NUM . $this->nowTime, $agent_id, $upLookNum);
return true;
}
......@@ -202,6 +204,32 @@ class LookShopService
return $agentUpNum;
}
/**
* @param int $user_id
* @param int $house_id
* @return bool
*/
public function addUserLookShop(int $user_id, int $house_id): bool
{
$day = date("Y-m-d", time());
$tModel = new TLookShopUser();
$params["user_id"] = $user_id;
$params["house_id"] = $house_id;
$params["look_day"] = $day;
$result = $tModel->getList($params,"id",1,1);
if(count($result) > 0){
return false;
}
$arr = array(
"user_id" => $user_id,
"house_id" => $house_id,
"look_day" => $day,
"create_time" => date("Y-m-d H:i:s", time()),
"update_time" => date("Y-m-d H:i:s", time()),
);
$tModel->addLookShop($arr);
return true;
}
}
\ No newline at end of file
......@@ -9,8 +9,10 @@ namespace app\index\controller;
* Time : 14:37
* Intro:
*/
use app\index\extend\Basic;
use app\model\TLookShopModel;
use app\model\TLookShopUser;
class LookShop extends Basic
{
......@@ -43,19 +45,19 @@ class LookShop extends Basic
$condition = [];
if (!empty($params["start_time"]) && !empty($params["end_time"])) {
$condition["a.look_time"] = array( "between", array( $params["start_time"], $params["end_time"] . " 23:59:59" ) );
$condition["a.look_time"] = array("between", array($params["start_time"], $params["end_time"] . " 23:59:59"));
}
if (!empty($params["house_id"])) {
$condition["a.house_id"] = $params["house_id"];
}
if (!empty($params["house_name"])) {
$condition["b.internal_title"] = array( "like", "%" . trim($params["house_name"]) . "%" );
$condition["b.internal_title"] = array("like", "%" . trim($params["house_name"]) . "%");
}
if (!empty($params["agent_name"])) {
$condition["a.agent_name"] = array( "like", "%" . trim($params["agent_name"]) . "%" );
$condition["a.agent_name"] = array("like", "%" . trim($params["agent_name"]) . "%");
}
if (!empty($params["agent_phone"])) {
$condition["a.agent_phone"] = array( "like", "%" . trim($params["agent_phone"]) . "%" );
$condition["a.agent_phone"] = array("like", "%" . trim($params["agent_phone"]) . "%");
}
if ($this->userId != 1) {
......@@ -71,4 +73,52 @@ class LookShop extends Basic
return $this->response("200", "success", $list);
}
public function lookShopUser()
{
$params = $this->params;
/*$params = array(
"start_time" => '2018-07-30',
"end_time" => '2018-07-31',
"house_id" => 3084,
"house_name" => "",
"user_name" => "",
"user_phone" => "",
"page_no" => 1,
"page_size" => 15
);*/
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 25 : $params['page_size'];
$condition = [];
if (!empty($params["start_time"]) && !empty($params["end_time"])) {
$condition["a.create_time"] = array("between", array($params["start_time"], $params["end_time"] . " 23:59:59"));
}
if (!empty($params["house_id"])) {
$condition["a.house_id"] = $params["house_id"];
}
if (!empty($params["house_name"])) {
$condition["b.internal_title"] = array("like", "%" . trim($params["house_name"]) . "%");
}
if (!empty($params["user_name"])) {
$condition["c.user_name"] = array("like", "%" . trim($params["user_name"]) . "%");
}
if (!empty($params["user_phone"])) {
$condition["a.user_phone"] = array("like", "%" . trim($params["user_phone"]) . "%");
}
if ($this->userId != 1) {
$condition["b.city"] = $this->city;
}
$field = "a.id,a.create_time,a.house_id,b.internal_title,c.user_name,c.user_phone";
$tLookShopUser = new TLookShopUser();
$result = $tLookShopUser->getList($condition, $field, $pageNo, $pageSize);
//$total = $this->tLookShopModel->getListCount($condition, $field);
$list["list"] = $result;
$list["total"] = 150;
return $this->response("200", "success", $list);
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/4/29
* Time: 17:25
*/
use think\Db;
use think\Model;
class TLookShopUser extends Model
{
protected $table = "t_look_shop_user";
private $db_;
function __construct()
{
$this->db_ = Db::name($this->table);
}
public function addLookShop($params)
{
Db::startTrans();
try {
$this->db_->insertAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
public function getList($condition, $field, $pageNo, $pageSize)
{
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id=b.id","left")
->join("u_users c", "a.user_id=c.id", "left")
->where($condition)
->page($pageNo)
->limit($pageSize)
//->order("id desc")
->select();
}
public function getListCount($condition, $field)
{
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id=b.id","left")
->join("u_users c", "a.user_id=c.id", "left")
->where($condition)
->count();
}
}
\ No newline at end of file
......@@ -355,6 +355,8 @@ Route::group('index', [
'operationalData' => ['index/OperationalData/operationalDataList', ['method' => 'POST|GET']],//运营数据统计liu
'siteList' => ['index/site/siteLogList', ['method' => 'POST|GET']],//站点列表liu
'lookShopIndex' => ['index/LookShop/lookShopIndex', ['method' => 'GET']],//商铺查看日志
'lookShopUser' => ['index/LookShop/lookShopUser', ['method' => 'GET']],//用户商铺查看日志
'selectDistrictPerformance' => ['index/Performance/selectDistrictPerformance', ['method' => 'POST|GET']], //区域业绩排行 朱伟 2018-07-31
'selectStorePerformance' => ['index/Performance/selectStorePerformance', ['method' => 'POST|GET']], //门店业绩排行 朱伟 2018-07-31
'selectIndividualPerformance' => ['index/Performance/selectIndividualPerformance', ['method' => 'POST|GET']], //个人业绩排行 朱伟 2018-07-31
......
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