Commit 44437b60 authored by clone's avatar clone

自动下架逻辑更新

parent 6b2e6d12
...@@ -825,25 +825,20 @@ class GHouses extends BaseModel ...@@ -825,25 +825,20 @@ class GHouses extends BaseModel
{ {
$where_ = []; $where_ = [];
if (isset($params["status"])) { if (isset($params["status"])) {
$where_["a.status"] = $params["status"]; $where_["status"] = $params["status"];
} }
if (isset($params["update_time"])) { if (isset($params["update_time"])) {
$where_["a.update_time"] = $params["update_time"]; $where_["update_time"] = $params["update_time"];
}
if (isset($params["is_execute"])) {
$where_["a.is_execute"] = $params["is_execute"];
} }
if (isset($params["is_exclusive_type"])) { if (isset($params["is_exclusive_type"])) {
$where_["a.is_exclusive_type"] = $params["is_exclusive_type"]; $where_["is_exclusive_type"] = $params["is_exclusive_type"];
} }
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->alias("a")
->join("o_order b", "a.id = b.house_id", "left")
->join("g_houses_follow_up c", "a.id = c.house_id", "left")
->where($where_) ->where($where_)
->group("a.id ")
->select(); ->select();
echo $this->getLastSql();
return $result; return $result;
} }
......
...@@ -106,16 +106,17 @@ class GHousesFollowUp extends Model ...@@ -106,16 +106,17 @@ class GHousesFollowUp extends Model
->limit($pageSize) ->limit($pageSize)
->page($p) ->page($p)
->select(); ->select();
// echo $this->getLastSql(); // echo $this->getLastSql();
return $data; return $data;
} }
/** /**
* 首页商铺跟进搜索 * 首页商铺跟进搜索
* @param $join * @param $join
* @param $where * @param $where
* @return int * @return int
*/ */
public function getSearchCount( $join, $where) public function getSearchCount($join, $where)
{ {
$data = $this $data = $this
->alias('f') ->alias('f')
...@@ -124,4 +125,23 @@ class GHousesFollowUp extends Model ...@@ -124,4 +125,23 @@ class GHousesFollowUp extends Model
->count("f.id"); ->count("f.id");
return $data; return $data;
} }
public function getFollowUpByHouseId(array $params): bool
{
$where_ = [];
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
if (isset($params["house_id"])) {
$where_["house_id"] = $params["house_id"];
}
$follow_list = $this
->field("id")
->where($where_)
->select();
if (count($follow_list) > 0) {
return true;
}
return false;
}
} }
\ No newline at end of file
...@@ -101,19 +101,20 @@ class OrderModel extends Model ...@@ -101,19 +101,20 @@ class OrderModel extends Model
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function searchOrder($field,$params,$where_){ public function searchOrder($field, $params, $where_)
{
/* $result = $this->db_
->field($field) /* $result = $this->db_
->alias("a") ->field($field)
->join("o_report b","a.f_id = b.id","left") ->alias("a")
->union('SELECT '.$field.' FROM o_order a left join o_report b on a.f_id = b.id where '.$params) ->join("o_report b","a.f_id = b.id","left")
->where($params) ->union('SELECT '.$field.' FROM o_order a left join o_report b on a.f_id = b.id where '.$params)
->select();*/ ->where($params)
->select();*/
/* dump($params); /* dump($params);
dump($where_);*/ dump($where_);*/
//$where_ = $where_ ." and " . $params; //$where_ = $where_ ." and " . $params;
$sql = "SELECT * FROM $sql = "SELECT * FROM
( (
( (
SELECT SELECT
...@@ -135,10 +136,10 @@ class OrderModel extends Model ...@@ -135,10 +136,10 @@ class OrderModel extends Model
$where_ $where_
) )
) AS aaa"; ) AS aaa";
$result = $this->db_->query($sql); $result = $this->db_->query($sql);
//echo $this->db_->getLastSql(); //echo $this->db_->getLastSql();
return $result ; return $result;
} }
...@@ -150,9 +151,10 @@ class OrderModel extends Model ...@@ -150,9 +151,10 @@ class OrderModel extends Model
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getOrderById($field, $order_id) { public function getOrderById($field, $order_id)
{
return $this->field($field) return $this->field($field)
->where('id',$order_id) ->where('id', $order_id)
->find(); ->find();
} }
...@@ -162,14 +164,14 @@ class OrderModel extends Model ...@@ -162,14 +164,14 @@ class OrderModel extends Model
*/ */
function getTurnover() function getTurnover()
{ {
$timeArr = Time::lastWeek(); $timeArr = Time::lastWeek();
$signStartTime = date("Y-m-d H:i:s", $timeArr[0]); $signStartTime = date("Y-m-d H:i:s", $timeArr[0]);
$signEndTime = date("Y-m-d H:i:s", $timeArr[1]); $signEndTime = date("Y-m-d H:i:s", $timeArr[1]);
$where_['a.create_time'] = array( "between", array( $signStartTime, $signEndTime ) ); $where_['a.create_time'] = array( "between", array( $signStartTime, $signEndTime ) );
$where_['b.father_id'] = array( "eq", 0); $where_['b.father_id'] = array( "eq", 0 );
return $this->db_ return $this->db_
->alias("a") ->alias("a")
->join("o_bargain b","a.id = b.order_id","left") ->join("o_bargain b", "a.id = b.order_id", "left")
->where($where_) ->where($where_)
->count(); ->count();
} }
...@@ -184,11 +186,12 @@ class OrderModel extends Model ...@@ -184,11 +186,12 @@ class OrderModel extends Model
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getHouseInfoByOrderId($field,$params){ public function getHouseInfoByOrderId($field, $params)
{
return $this->db_ return $this->db_
->field($field) ->field($field)
->alias("a") ->alias("a")
->join("g_houses b","a.house_id = b.id","left") ->join("g_houses b", "a.house_id = b.id", "left")
->where($params) ->where($params)
->select(); ->select();
} }
...@@ -203,12 +206,51 @@ class OrderModel extends Model ...@@ -203,12 +206,51 @@ class OrderModel extends Model
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getHouseInfoByOrderIdOne($field, $params) { public function getHouseInfoByOrderIdOne($field, $params)
{
return $this->db_ return $this->db_
->field($field) ->field($field)
->alias("a") ->alias("a")
->join("g_houses b","a.house_id = b.id","left") ->join("g_houses b", "a.house_id = b.id", "left")
->where($params) ->where($params)
->find(); ->find();
} }
public function getOrderByHouseId(array $params): bool
{
$where_ = $select_ = [];
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
$select_["b.create_time"] = $params["create_time"];
}
if (isset($params["house_id"])) {
$where_["house_id"] = $params["house_id"];
$select_["a.house_id"] = $params["house_id"];
}
//判断此楼盘10天内是否有订单记录
$orderResult = $this->db_
->field("id")
->where($where_)
->limit(1)
->select();
echo $this->getLastSql();
if (count($orderResult) > 0) {
return true;
}
//判断此楼盘10天内是否有跟进记录
$marchIn = $this->db_
->field("b.id")
->alias("a")
->join("o_march_in b", "a.id = b.order_id", "left")
->where($select_)
->limit(1)
->select();
echo $this->getLastSql();
if (count($marchIn) > 0) {
return true;
}
return false;
}
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace app\task\controller; namespace app\task\controller;
use app\model\GHouses; use app\model\GHouses;
use app\model\GHousesFollowUp;
use app\model\OrderModel;
use app\model\SystemConfig; use app\model\SystemConfig;
...@@ -46,22 +48,30 @@ class UpdateShopStatusTask ...@@ -46,22 +48,30 @@ class UpdateShopStatusTask
} else { } else {
return null; return null;
} }
$field = "a.id,b.id as order_id"; $field = "id";
$params = []; $params = [];
$time_ = date('Y-m-d', strtotime("-$day day")); $time_ = date('Y-m-d', strtotime("-$day day"));
$params["status"] = 1; $params["status"] = 1;
$params["update_time"] = array( 'lt', $time_ . " 23:59:59" ); $params["update_time"] = array( 'lt', $time_ . " 23:59:59" );
$params["is_execute"] = 0; //过滤掉有动态的商铺
$params["is_exclusive_type"] = 0; $params["is_exclusive_type"] = 0;
//所有修改时间大于10天的商铺
$result = $this->shopModel->getShopListByTime($field, $params); $result = $this->shopModel->getShopListByTime($field, $params);
$orderModel = new OrderModel();
$followMole = new GHousesFollowUp();
$select_["create_time"] = array( "between", array( $time_, date("Y-m-d H:i:s", time()) ) );
$update_arr = []; $update_arr = [];
foreach ($result as $key => $item) { foreach ($result as $key => $item) {
if ($item["order_id"]) { $select_["house_id"] = $item["id"];
$update_arr[$key]["id"] = $item["id"]; $is_ok = $orderModel->getOrderByHouseId($select_);
$update_arr[$key]["is_execute"] = 1; $is_follow = $followMole->getFollowUpByHouseId($select_);
} else {
//10天内无动态则下架
if (!$is_ok && !$is_follow) {
$update_arr[$key]["id"] = $item["id"]; $update_arr[$key]["id"] = $item["id"];
$update_arr[$key]["status"] = 2; $update_arr[$key]["status"] = 2;
} }
......
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