Commit b6913b64 authored by clone's avatar clone

1

parent cede883a
......@@ -4,6 +4,11 @@ use app\api_broker\extend\Basic;
use app\api_broker\service\OfficeOrderLogService;
use app\api_broker\service\OrderLogService;
use app\api_broker\service\VerifyRepetitionService;
use app\api_broker\service\VipService;
use app\model\OfficeGRoom;
use app\model\OfficeOBargainModel;
use app\model\OfficeOImg;
use app\model\OfficeOMarchInModel;
use app\model\OMarchInModel;
/**
......@@ -17,13 +22,15 @@ class OfficeOrderLog extends Basic{
private $o_march_in_model;
private $service_;
private $verifyService_;
private $o_img_model;
function __construct($request = null)
{
parent::__construct($request);
$this->o_march_in_model = new OMarchInModel();
$this->o_march_in_model = new OfficeOMarchInModel();
$this->service_ = new OfficeOrderLogService();
$this->verifyService_ = new VerifyRepetitionService();
$this->o_img_model = new OfficeOImg();
}
/**
......@@ -61,15 +68,14 @@ class OfficeOrderLog extends Basic{
unset($params["march_in_img"]);
$insert_id = $this->o_march_in_model->addMarchIn($params);
if ($insert_id > 0) {
$oImgModel = new OImg();
$oImgModel->addImgAll($insert_id, 1, $march_in_img);
$this->o_img_model->addImgAll($insert_id, 1, $march_in_img);
$pushMarchIn = new PushMessageService();
$pushMarchIn->pushMarchInMessage($params["report_id"], 1, $this->agentId); //推送
/*$pushMarchIn = new PushMessageService();
$pushMarchIn->pushMarchInMessage($params["report_id"], 1, $this->agentId); //推送*/
//评价经纪人
/* //评价经纪人
$push_client = new PushClientService();
$push_client->record((int)$params["report_id"], (int)$params["order_id"], 0, '', (int)$this->agentId);
$push_client->record((int)$params["report_id"], (int)$params["order_id"], 0, '', (int)$this->agentId);*/
//对客户发送短信通知 7151
// $this->sendSMSForUser($params["report_id"]);
......@@ -79,24 +85,6 @@ class OfficeOrderLog extends Basic{
}
}
/**
* 对客户发送短信通知
* @param $report_id
* @return bool
*/
public function sendSMSForUser($report_id)
{
$report = new OReportModel();
$messageUntil = new MessageUntils();
$user_phone = $report->getFieldValue('user_phone', ['id' => $report_id]);
$result = $messageUntil->sendSMSForUser($user_phone, [SMS_TEMPLATE_URL], '415209');
if ($result == 'true') {
return true;
} else {
return false;
}
}
/**
* 收款
......@@ -447,14 +435,14 @@ class OfficeOrderLog extends Basic{
if (!isset($params["type"]) || $params["type"] != 20 && $params["type"] != 21 && $params["type"] != 30) {
return $this->response("101", "要修改的状态类型错误");
}
$obm = new OBargainModel();
$obm = new OfficeOBargainModel();
$save_param["status"] = $params["type"];
$is_ok = $obm->updateBargainById($params["id"], $save_param);
if ($is_ok > 0) {
$houseNumUpdateService = new HouseNumUpdateService();
$houseNumUpdateService = new OfficeGRoom();
$houseNumUpdateService->updateHouseNumByRevocationBargain($params["id"]);
return $this->response("200", "request success", ["msg" => "状态修改成功"]);
} else {
......
......@@ -13,6 +13,7 @@ use app\model\FollowUpLogModel;
use app\model\GHousesFollowUp;
use app\model\GHousesToAgents;
use app\model\OBargainModel;
use app\model\OfficeOImg;
use app\model\OImg;
use app\model\OMarchInModel;
use app\model\OPayLogAdjustment;
......@@ -33,11 +34,13 @@ class OfficeOrderLogService
{
private $payLogModel;
private $bargainModel;
private $o_img_model;
function __construct()
{
$this->payLogModel = new OPayLogModel();
$this->bargainModel = new OBargainModel();
$this->o_img_model = new OfficeOImg();
}
/**
......@@ -110,8 +113,7 @@ class OfficeOrderLogService
if ($father_id > 0) {
//保存图片
if ($transfer_img) {
$oImgModel = new OImg();
$oImgModel->addImgAll($father_id, 2, $transfer_img);
$this->o_img_model->addImgAll($father_id, 2, $transfer_img);
}
if ($pay_id > 0) {
......
......@@ -16,4 +16,7 @@ class OfficeGRoom extends BaseModel
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
public function updateHouseNumByRevocationBargain($room_id){
}
}
This diff is collapsed.
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 11:26 AM
* Intro:
*/
class OfficeODaily extends BaseModel
{
protected $table = "office_o_daily";
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $params
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDailyList($field, $params, $page_no, $page_size)
{
$where_ = [];
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
if (isset($params["daily_date"])) {
$where_["daily_date"] = $params["daily_date"];
}
if (isset($params["store_id"])) {
$where_["store_id"] = $params["store_id"];
}
if (isset($params['id'])) {
$where_["id"] = $params['id'];
}
$where_["is_del"] = 0;
return $this->db_
->field($field)
->where($where_)
->page($page_no)
->limit($page_size)
->select();
}
/**
* @param $params
* @return int
*/
public function addDaily($params)
{
Db::startTrans();
try {
$this->db_->insert($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/**
* @param $where
* @param $params
* @return int
*/
public function updateDaily($where,$params)
{
Db::startTrans();
try {
$this->where($where)->update($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDailyLogList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->alias('a')
->field($field)
->join('o_daily_log b', 'a.id=b.daily_id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
->group('a.id')
->page($pageNo)
->select();
}
/**
* @param $params
* @return int|string
*/
public function getDailyLogTotal($params) {
return $this->alias('a')
->join('o_daily_log b', 'a.id=b.daily_id', 'left')
->where($params)
->group('a.id')
->count();
}
public function getFieldValue($filed, $where) {
return $this->where($where)->value($filed);
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/12/17
* Time : 2:36 PM
* Intro:
*/
class OfficeODailyLog extends BaseModel
{
protected $table = "office_o_daily_log";
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $params
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDailyLogList($field,$params,$page_no,$page_size){
$where_ = [];
if(isset($params["daily_id"])){
$where_["daily_id"] = $params["daily_id"];
}
if(isset($params["operation_id"])){
$where_["operation_id"] = $params["operation_id"];
}
if(isset($params["operation_status"])){
$where_["operation_status"] = $params["operation_status"];
}
if(isset($params["is_del"])){
$where_["is_del"] = $params["is_del"];
}
return $this->db_
->field($field)
->where($where_)
->order("create_time desc")
->page($page_no)
->limit($page_size)
->select();
}
/**
* @param $params
* @return int
*/
public function addDailyCheck($params){
Db::startTrans();
try {
$this->db_->insert($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/7/4
* Time : 10:15
* Intro:
*/
use think\Db;
use think\Exception;
use Think\Log;
class OfficeOImg extends BaseModel
{
protected $table = "office_o_imgs";
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* 新增图片一张
* @param $params
* @return int|string
* @throws Exception xx
*/
public function addImgOnce(array $params): int
{
$imgBin = $this->imgBin($params);
Db::startTrans();
try {
$id = $this->insertGetId($imgBin);
Db::commit();
return $id;
} catch (Exception $exception) {
Db::rollback();
throw $exception;
}
}
/**
* 新增多张图片
* @param $params
* @param $img_id
* @param $img_type
* @return int|string
* @throws Exception xx
*/
public function addImgAll(int $img_id, int $img_type, array $params): int
{
$imgBin = [];
foreach ($params as $item) {
$insert_["img_id"] = $img_id;
$insert_["img_type"] = $img_type;
$insert_["img_name"] = $item;
$insert_["img_status"] = 0;
array_push($imgBin, $this->imgBin($insert_));
}
Db::startTrans();
try {
$this->saveAll($imgBin);
Db::commit();
return 1;
} catch (Exception $exception) {
Db::rollback();
throw $exception;
}
}
/**
* 修改图片单张
* @param array $params
* @return int
* @throws Exception
*/
public function updateImgStatus(array $params): int
{
$imgBin = $this->imgBin($params);
Db::startTrans();
try {
$this->update($imgBin);
Db::commit();
return $params["id"];
} catch (Exception $exception) {
Db::rollback();
throw $exception;
}
}
/**
* 批量删除
* @param $where
* @param $params
* @return int|string
*/
public function updateImgs($where,$params)
{
Db::startTrans();
try {
$id = $this->db_->where($where)->update($params);
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/**
* 根据id和类型获取图片
* @param array $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public function getImgList(array $params, string $field = "id,img_name")
{
if (isset($params["img_id"])) {
$where_["img_id"] = $params["img_id"];
}
if (isset($params["img_type"])) {
$where_["img_type"] = $params["img_type"];
}
$where_["img_status"] = 0;
$data = $this->db_
->field($field)
->where($where_)
->select();
// echo $this->getLastSql();
return $data;
}
/**
* bin
* @param $params
* @return array
*/
private function imgBin($params)
{
$arr = [];
if (isset($params["id"])) {
$arr["id"] = $params["id"];
} else {
$arr["create_time"] = date("Y-m-d H:i:s", time());
}
if (isset($params["img_id"])) {
$arr["img_id"] = $params["img_id"];
}
if (isset($params["img_type"])) {
$arr["img_type"] = $params["img_type"];
}
if (isset($params["img_name"])) {
$arr["img_name"] = $params["img_name"];
}
if (isset($params["img_status"])) {
$arr["img_status"] = $params["img_status"];
}
$arr["update_time"] = date("Y-m-d H:i:s", time());
return $arr;
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
namespace app\model;
use think\Db;
use think\helper\Time;
use think\Model;
/**
* Created by PhpStorm.
* User: zw
* Date: 2018/1/29
* Time: 下午5:47
*/
class OfficeOrderModel extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'office_o_order';
protected $db_;
public function __construct()
{
$this->db_ = Db::name($this->table);
}
public function insertOrderByAll($params)
{
Db::startTrans();
try {
$this->db_->insertAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/**
* @param $filed
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectOrderByOrderId($filed, $params)
{
$where_ = [];
if (isset($params["order_id"])) {
$where_["a.id"] = $params["order_id"];
}
if (isset($params["f_id"])) {
$where_["a.f_id"] = $params["f_id"];
}
if (isset($params["house_id"])) {
$where_["a.house_id"] = $params["house_id"];
}
$result = $this->db_
->field($filed)
->alias("a")
->join("g_houses b", "a.house_id = b.id", "left")
->where($where_)
->select();
//echo $this->db_->getLastSql();
return $result;
}
/**
* @param $ids
* @return false|\PDOStatement|string|\think\Collection
*/
public function selectSign($ids)
{
return $this->db_
->field('id as order_id,1 as type')
->where("id", "in", 0)
->union('SELECT order_id,2 as type FROM o_march_in where order_id in (' . $ids . ') group by order_id')
->union('SELECT order_id,3 as type FROM o_paylog where order_id in (' . $ids . ') group by order_id')
->union('SELECT order_id,4 as type FROM o_bargain where order_id in (' . $ids . ') group by order_id')
->select();
}
/**
* 订单详情主要信息
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function selectOrderDetail($field, $params)
{
$where_ = [];
if (isset($params["order_id"])) {
$where_["a.id"] = $params["order_id"];
}
$where_["a.is_del"] = 0;
$where_["b.status"] = 0;
return $this->db_
->field($field)
->alias("a")
->join("o_report b", "a.f_id = b.id", "left")
->join("u_users c", "b.user_id = c.id", "left")
->join("g_houses d", "d.id = a.house_id", "left")
->where($where_)
->select();
}
/**
* @param $field
* @param $params
* @param $where_
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function searchOrder($field, $params, $where_,$pageNo,$pageSize)
{
$start_index = ($pageNo - 1) * $pageSize;
$sql = "SELECT * FROM
(
(
SELECT
$field
FROM
`o_order` `a`
LEFT JOIN `o_report` `b` ON `a`.`f_id` = `b`.`id`
LEFT JOIN `g_houses` `c` ON `a`.`house_id` = `c`.`id`
WHERE
$params
)
UNION
(
SELECT
$field
FROM
`o_order` `a`
LEFT JOIN `o_report` `b` ON `a`.`f_id` = `b`.`id`
LEFT JOIN `g_houses` `c` ON `a`.`house_id` = `c`.`id`
WHERE
$where_
)
) AS aaa order by aaa.id desc LIMIT $start_index,$pageSize";
$result = $this->db_->query($sql);
//echo $this->getLastSql();
return $result;
}
/**
* @param $field
* @param $params
* @param $pageNo
* @param $pageSize
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchOrderAll($field, $params,$pageNo,$pageSize)
{
return $this
->field($field)
->alias("a")
->join("o_report b","a.f_id = b.id","left")
->join("g_houses c","a.house_id = c.id","left")
->where($params)
->order("a.id desc")
->page($pageNo)
->limit($pageSize)
->select();
}
/**
* @param $field
* @param $order_id
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getOrderById($field, $order_id)
{
return $this->field($field)
->where('id', $order_id)
->find();
}
/**
* 获取月均价
* @return float
*/
function getTurnover()
{
$timeArr = Time::lastWeek();
$signStartTime = date("Y-m-d H:i:s", $timeArr[0]);
$signEndTime = date("Y-m-d H:i:s", $timeArr[1]);
$where_['a.create_time'] = array( "between", array( $signStartTime, $signEndTime ) );
$where_['b.father_id'] = array( "eq", 0 );
return $this->db_
->alias("a")
->join("o_bargain b", "a.id = b.order_id", "left")
->where($where_)
->count();
}
/**
* 根据订单id获取楼盘info
*
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
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();
}
/**
* 根据订单id获取楼盘info
*
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseInfoByOrderIdOne($field, $params)
{
return $this->db_
->field($field)
->alias("a")
->join("g_houses b", "a.house_id = b.id", "left")
->where($params)
->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;
}
/**
* 获取7日30日次数
*/
public function getCountByHouseId($params)
{
$result = Db::table($this->table)
->field("id")
->where($params)
->count();
//echo Db::table($this->table)->getLastSql();
//dump($this->getLastSql());
return $result;
}
/**
* @param $field
* @param $where
* @return mixed
*/
public function getFieldValue($field, $where) {
return $this->db_->where($where)->value($field);
}
}
\ 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