Commit 88e6de41 authored by clone's avatar clone

新增修改楼盘

parent 34022770
......@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use app\api\untils\GeTuiUntils;
use app\api_broker\extend\Basic;
use app\api_broker\service\HouseNumUpdateService;
use app\api_broker\service\OrderLogService;
use app\model\AAgents;
use app\model\Agents;
......@@ -291,7 +292,7 @@ class OrderLog extends Basic
$params = $this->params;
/* $params = array(
"id" => 1,
"type" => 210 //20撤销 21已撤销 30已审核
"type" => 20 //20撤销 21已撤销 30已审核
);*/
if (!isset($params["id"])) {
return $this->response("101", "请求参数错误");
......@@ -307,6 +308,8 @@ class OrderLog extends Basic
$is_ok = $obm->updateBargainById($params["id"], $save_param);
if ($is_ok > 0) {
$houseNumUpdateService = new HouseNumUpdateService();
$houseNumUpdateService->updateHouseNumByRevocationBargain($params["id"]);
return $this->response("200", "request success", [ "msg" => "状态修改成功" ]);
} else {
return $this->response("101", "request error");
......
......@@ -149,10 +149,15 @@ class OrderLogService
}
}
if ($father_id > 0) { //修改楼盘
$houseNumUpdateService = new HouseNumUpdateService();
$houseNumUpdateService->updateHouseNumByBargain($order_id);
}
//todo if bill_arr not null, save database table
if (!empty($bargain_arr)) {
return $this->bargainModel->addBargain($bargain_arr);
}
return $father_id;
}
......@@ -704,13 +709,13 @@ class OrderLogService
$where_["order_id"] = $order_id;
$result = $orderModel->selectOrderDetail($field, $where_);
//dump($result);
if (count($result) <= 0 || $result["house_id"] <=0 || $result["user_id"] <= 0) {
if (count($result) <= 0 || $result["house_id"] <= 0 || $result["user_id"] <= 0) {
return null;
}
$houseAgents = new GHousesToAgents();
$field = "b.id,b.phone,b.name";
switch ($type) {//0盘方,1客方,2反签,3独家,4合作方
switch ($type) {//1盘方,2客方,3反签,4独家,5合作方
case 1:
$params["a.house_id"] = $result["house_id"];
$params["a.type"] = 2;
......@@ -718,17 +723,16 @@ class OrderLogService
$list = $houseAgents->getAgentsByHouseId($field, $params);
break;
case 2:
$userModel = new Users();
$userModel = new Users();
$params["a.id"] = $result["user_id"];
$params["b.status"] = 0;
$list = $userModel->getAgentByUserId($field, $params);
break;
case 3: //反签 == 报备人
$reportModel = new OReportModel();
$params["a.order_id"] = $result["id"];
$params["b.status"] = 0;
$list = $reportModel->getAgentByOrderId($field, $params);
$reportModel = new OReportModel();
$params["a.order_id"] = $result["id"];
$params["b.status"] = 0;
$list = $reportModel->getAgentByOrderId($field, $params);
break;
case 4:
$params["a.house_id"] = $result["house_id"];
......
......@@ -619,6 +619,25 @@ class GHouses extends BaseModel
return $averagePrice;
}
/**
* 修改楼盘数量
* @param $id
* @param $params
* @return int
*/
public function updateHouseNum($id,$params){
$params["update_time"] = date("Y-m-d H:i:s", time());
Db::startTrans();
try {
Db::table($this->table)->where('id', $id)->update($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/******zw end ************/
......
......@@ -431,4 +431,20 @@ class OBargainModel extends Model
->where($where_)
->select();
}
/**
* 判断同一个订单是否有多个成交报告
*/
public function ifBargainNumByOrderId($params){
return Db::table($this->table)
->select($params)
->count();
}
public function getBargainDetail($field,$params){
return Db::table($this->table)
->field($field)
->where($params)
->select();
}
}
\ No newline at end of file
......@@ -173,4 +173,19 @@ class OrderModel extends Model
->where($where_)
->count();
}
/**
* 根据订单id获取楼盘info
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getHouseInfoByOrderId($field,$params){
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id = b.id","left")
->where($params)
->select();
}
}
\ No newline at end of file
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