Commit 6bc1d846 authored by clone's avatar clone

金额处理

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