Commit 6bc1d846 authored by clone's avatar clone

金额处理

parent 4f0edd6c
...@@ -16,7 +16,6 @@ use app\model\Regions; ...@@ -16,7 +16,6 @@ use app\model\Regions;
* Time : 10:36 * Time : 10:36
* Intro: * Intro:
*/ */
class Shop extends Basic class Shop extends Basic
{ {
private $gHousesModel; private $gHousesModel;
...@@ -40,23 +39,23 @@ class Shop extends Basic ...@@ -40,23 +39,23 @@ class Shop extends Basic
*/ */
public function getShopList() public function getShopList()
{ {
/*$params = array( /*$params = array(
"site_area" => 4, //来源 1c首页 2c搜索 3b首页 4b搜索 "site_area" => 4, //来源 1c首页 2c搜索 3b首页 4b搜索
"title" => "vv", //1,2 external_title ,3,4internal_title "title" => "vv", //1,2 external_title ,3,4internal_title
"house_id" => 1, "house_id" => 1,
"is_carefully_chosen" => 0, //精选商铺--0否1是 "is_carefully_chosen" => 0, //精选商铺--0否1是
"shop_type" => 0, //商铺类型(0商场,1街铺) "shop_type" => 0, //商铺类型(0商场,1街铺)
"disc" => "黄浦区", "disc" => "黄浦区",
"industry_type" => "休闲娱乐", "industry_type" => "休闲娱乐",
"shop_area_start" => 45,//面积起始范围 街铺start和end面积一样 "shop_area_start" => 45,//面积起始范围 街铺start和end面积一样
"shop_area_end" => 65,//面积结束范围 "shop_area_end" => 65,//面积结束范围
"rent_price_start" => 1000,//租金 rent_price "rent_price_start" => 1000,//租金 rent_price
"rent_price_end" => 10000,//租金 "rent_price_end" => 10000,//租金
"shop_sign" => "临近地铁,临近地铁2", "shop_sign" => "临近地铁,临近地铁2",
"agent_id" => 630, //添加经纪人id "agent_id" => 630, //添加经纪人id
"pageNo" => 1, "pageNo" => 1,
"pageSize" => 15 "pageSize" => 15
);*/ );*/
$params = $this->params; $params = $this->params;
$conditions = []; $conditions = [];
...@@ -84,7 +83,7 @@ class Shop extends Basic ...@@ -84,7 +83,7 @@ class Shop extends Basic
} else if (isset($params['title'])) { } else if (isset($params['title'])) {
$conditions['internal_title'] = array( "like", "%" . trim($params['title']) . "%" ); $conditions['internal_title'] = array( "like", "%" . trim($params['title']) . "%" );
} }
if(isset($params['house_id'])){ if (isset($params['house_id'])) {
$conditions['id'] = array( "eq", $params['house_id'] ); $conditions['id'] = array( "eq", $params['house_id'] );
} }
$order_ = ""; $order_ = "";
...@@ -112,11 +111,11 @@ class Shop extends Basic ...@@ -112,11 +111,11 @@ class Shop extends Basic
} }
//我的商铺 代表我是盘方的商铺 //我的商铺 代表我是盘方的商铺
if(isset($params['agent_id'])){ if (isset($params['agent_id'])) {
$verifyService = new VerifyService(); $verifyService = new VerifyService();
$ids = $verifyService->getPanpartyByAgentId($params['agent_id']); $ids = $verifyService->getPanpartyByAgentId($params['agent_id']);
//$conditions['upload_id'] = array( "eq", $params['agent_id'] ); //$conditions['upload_id'] = array( "eq", $params['agent_id'] );
$conditions['id'] = array("in",$ids); $conditions['id'] = array( "in", $ids );
} }
$area_start = isset($params['shop_area_start']) ? $params['shop_area_start'] : -1; $area_start = isset($params['shop_area_start']) ? $params['shop_area_start'] : -1;
...@@ -126,7 +125,7 @@ class Shop extends Basic ...@@ -126,7 +125,7 @@ class Shop extends Basic
$conditions['shop_area_end'] = array( 'between', array( $area_start, $area_end ) ); $conditions['shop_area_end'] = array( 'between', array( $area_start, $area_end ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积 } else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['shop_area_start'] = array( 'egt', $area_start ); $conditions['shop_area_start'] = array( 'egt', $area_start );
$conditions['shop_area_end'] = array( 'egt', $area_start ); $conditions['shop_area_end'] = array( 'egt', $area_start );
} }
$price_start = isset($params['rent_price_start']) ? $params['rent_price_start'] : -1; $price_start = isset($params['rent_price_start']) ? $params['rent_price_start'] : -1;
...@@ -150,27 +149,27 @@ class Shop extends Basic ...@@ -150,27 +149,27 @@ class Shop extends Basic
$order_ = "id desc"; $order_ = "id desc";
break; break;
default: default:
return $this->response("101", "请求数据异常"); return $this->response("101", "请求数据异常");
} }
if (!empty($conditions) ) { if (!empty($conditions)) {
$conditions['status'] = array( 'eq', 1 ); //只显示上架 $conditions['status'] = array( 'eq', 1 ); //只显示上架
if ($params['site_area'] == 1 || $params['site_area'] == 2) if ($params['site_area'] == 1 || $params['site_area'] == 2)
$conditions['is_show'] = array( 'eq', 0 ); //c端只显示可显示的楼盘 $conditions['is_show'] = array( 'eq', 0 ); //c端只显示可显示的楼盘
} }
//如果有传经纪人id则代表我的商铺不区分状态 //如果有传经纪人id则代表我的商铺不区分状态
if( isset($params['agent_id'])){ if (isset($params['agent_id'])) {
unset($conditions['status']); unset($conditions['status']);
} }
$result = $this->gHousesModel->getHousesList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr); $result = $this->gHousesModel->getHousesList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr);
//获取图片信息 //获取图片信息
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$result[$key]["api_path"] = CK_IMG_URL; $result[$key]["api_path"] = CK_IMG_URL;
$result[$key]["rent_price"] = $result[$key]["rent_price"] * 0.01; $result[$key]["rent_price"] = $result[$key]["rent_price"] * 0.01;
$param["house_id"] = $val["id"]; $param["house_id"] = $val["id"];
$param["img_type"] = 1; //默认主图 $param["img_type"] = 1; //默认主图
$result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1); $result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1);
} }
...@@ -192,11 +191,11 @@ class Shop extends Basic ...@@ -192,11 +191,11 @@ class Shop extends Basic
public function getShopDetail() public function getShopDetail()
{ {
/* $params = array( /* $params = array(
"id" => 5, "id" => 5,
"site_area" => 1, //1.c端 3.b端 "site_area" => 1, //1.c端 3.b端
"user_id" => 2 //if c端 用户登录后传入user_id "user_id" => 2 //if c端 用户登录后传入user_id
);*/ );*/
$params = $this->params; $params = $this->params;
$conditions = []; $conditions = [];
...@@ -227,10 +226,10 @@ class Shop extends Basic ...@@ -227,10 +226,10 @@ class Shop extends Basic
$conditions['a.id'] = array( "eq", $params["id"] ); $conditions['a.id'] = array( "eq", $params["id"] );
$result = $this->gHousesModel->getHouseDetailById($field, $conditions); $result = $this->gHousesModel->getHouseDetailById($field, $conditions);
$result["rent_price"] = $result["rent_price"] * 0.01;
$result["api_path"] = IMG_PATH; $result["api_path"] = IMG_PATH;
$param["house_id"] = $params['id']; $param["house_id"] = $params['id'];
//todo 这里的是否要更改成b端后台上传的类型 //todo 这里的是否要更改成b端后台上传的类型
$param["img_type"] = 2; $param["img_type"] = 2;
$result["images"] = $this->gHousesImgModel->getHouseImages($param, 15); $result["images"] = $this->gHousesImgModel->getHouseImages($param, 15);
...@@ -245,12 +244,12 @@ class Shop extends Basic ...@@ -245,12 +244,12 @@ class Shop extends Basic
$attention["user_id"] = array( "eq", $params['user_id'] ); $attention["user_id"] = array( "eq", $params['user_id'] );
$attention["house_id"] = array( "eq", $params["id"] ); $attention["house_id"] = array( "eq", $params["id"] );
$attention["is_del"] = array( "eq", 0 ); $attention["is_del"] = array( "eq", 0 );
$attResult = $this->attentionModel->getAttentionByUserIdAndHouseId($attention); $attResult = $this->attentionModel->getAttentionByUserIdAndHouseId($attention);
if (count($attResult) > 0) if (count($attResult) > 0)
$result ["attention"] = $attResult[0]["id"]; $result ["attention"] = $attResult[0]["id"];
} }
$verify = new VerifyService(); $verify = new VerifyService();
$agentId = $verify->getPanpartyAgentsByHouseId($params["id"]); $agentId = $verify->getPanpartyAgentsByHouseId($params["id"]);
$result["panParty"] = $agentId; $result["panParty"] = $agentId;
return $this->response("200", 'request success', $result); return $this->response("200", 'request success', $result);
...@@ -266,7 +265,8 @@ class Shop extends Basic ...@@ -266,7 +265,8 @@ class Shop extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function edit() { public function edit()
{
$result['code'] = 200; $result['code'] = 200;
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
...@@ -274,15 +274,15 @@ class Shop extends Basic ...@@ -274,15 +274,15 @@ class Shop extends Basic
if ($this->request->isPost()) { if ($this->request->isPost()) {
$this->gHousesModel->startTrans(); $this->gHousesModel->startTrans();
$this->params['userId'] = $this->agentId; $this->params['userId'] = $this->agentId;
$house_id = $this->gHousesModel->app_add($this->params); //添加或编辑商铺 $house_id = $this->gHousesModel->app_add($this->params); //添加或编辑商铺
if ($house_id) { if ($house_id) {
$this->gHousesModel->commit(); $this->gHousesModel->commit();
$result['data']['house_id'] = $house_id; $result['data']['house_id'] = $house_id;
$result['data']['internal_title'] = $this->params['internal_title']; $result['data']['internal_title'] = $this->params['internal_title'];
} else { } else {
$this->gHousesModel->rollback(); $this->gHousesModel->rollback();
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Add houses failure'; $data['msg'] = 'Add houses failure';
} }
} else { } else {
if (empty($this->params['id'])) { if (empty($this->params['id'])) {
...@@ -302,28 +302,29 @@ class Shop extends Basic ...@@ -302,28 +302,29 @@ class Shop extends Basic
* *
* @return \think\Response * @return \think\Response
*/ */
public function uploadHouseFile() { public function uploadHouseFile()
{
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = ''; $data['msg'] = '';
$data['data'] = ''; $data['data'] = '';
$file = request()->file('file'); $file = request()->file('file');
if($file){ if ($file) {
$path = ROOT_PATH . 'public' . DS . 'resource'. DS . 'lib'. DS .'Attachments'. DS .'images'; $path = ROOT_PATH . 'public' . DS . 'resource' . DS . 'lib' . DS . 'Attachments' . DS . 'images';
$info = $file->validate(['size'=>1024000,'ext'=>'jpg,png'])->move($path); $info = $file->validate([ 'size' => 1024000, 'ext' => 'jpg,png' ])->move($path);
if($info){ if ($info) {
$img_path = $info->getSaveName(); //生成的图片路径 $img_path = $info->getSaveName(); //生成的图片路径
$data['img_type'] = $this->params['img_type']; $data['img_type'] = $this->params['img_type'];
$data['img_name'] = $img_path; $data['img_name'] = $img_path;
$img = new GHousesImgs(); $img = new GHousesImgs();
$img->addHouseImg($data,$this->params['house_id']); $img->addHouseImg($data, $this->params['house_id']);
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = '上传成功'; $data['msg'] = '上传成功';
$data['data'] = [ $data['data'] = [
'file_name' => CK_IMG_URL .'images'. DS . $img_path, 'file_name' => CK_IMG_URL . 'images' . DS . $img_path,
'save_path' => $img_path 'save_path' => $img_path
]; ];
}else{ } else {
// 上传失败获取错误信息 // 上传失败获取错误信息
$data['msg'] = $file->getError(); $data['msg'] = $file->getError();
} }
...@@ -342,28 +343,29 @@ class Shop extends Basic ...@@ -342,28 +343,29 @@ class Shop extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function delHouseFile() { public function delHouseFile()
{
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = ''; $data['msg'] = '';
$data['data'] = ''; $data['data'] = '';
if(empty($this->params['save_path']) || empty($this->params['house_id'])){ if (empty($this->params['save_path']) || empty($this->params['house_id'])) {
return $this->response($data['status'], 'Save_path or id house_id is null', $data['data']); return $this->response($data['status'], 'Save_path or id house_id is null', $data['data']);
} }
$img = new GHousesImgs(); $img = new GHousesImgs();
$id = $img->getHouseImagesInfo('id',[ $id = $img->getHouseImagesInfo('id', [
'house_id' => $this->params['house_id'], 'house_id' => $this->params['house_id'],
'img_name' => $this->params['save_path'], 'img_name' => $this->params['save_path'],
'img_status' => 0 'img_status' => 0
]); ]);
if (empty($id['id'])) { if (empty($id['id'])) {
$data['msg'] = '没有该文件'; $data['msg'] = '没有该文件';
} else { } else {
$path = ROOT_PATH . 'public' . DS . 'resource'. DS . 'lib'. DS .'Attachments'. DS .'Images/'; $path = ROOT_PATH . 'public' . DS . 'resource' . DS . 'lib' . DS . 'Attachments' . DS . 'Images/';
@unlink($path.$this->params['save_path']); @unlink($path . $this->params['save_path']);
$img->editData(['img_status'=>1],$id['id'], 'id'); $img->editData([ 'img_status' => 1 ], $id['id'], 'id');
$data['status'] = 200; $data['status'] = 200;
} }
...@@ -378,10 +380,11 @@ class Shop extends Basic ...@@ -378,10 +380,11 @@ class Shop extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAddress() { public function getAddress()
{
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$regions = new Regions(); $regions = new Regions();
$data = $regions->getRegionsCity(); $data = $regions->getRegionsCity();
return $this->response(200, '', $data); return $this->response(200, '', $data);
} }
...@@ -393,10 +396,11 @@ class Shop extends Basic ...@@ -393,10 +396,11 @@ class Shop extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getRegions() { public function getRegions()
{
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$regions = new Regions(); $regions = new Regions();
$data = $regions->getRegions($this->params['code'], $this->params['parent_code']); $data = $regions->getRegions($this->params['code'], $this->params['parent_code']);
return $this->response(200, '', $data); return $this->response(200, '', $data);
} }
} }
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