Commit e56edec1 authored by hujun's avatar hujun

商铺下架推送消息

parent 1c234755
......@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\LookShopService;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\VerifyService;
use app\api_broker\service\VipService;
use app\index\validate\HouseValidate;
......@@ -465,6 +466,11 @@ class Shop extends Basic
$result['data']['house_id'] = $house_id['house_id'];
$result['data']['internal_title'] = empty($this->params['internal_title']) ? "" : $this->params['internal_title'];
$result['msg'] = '新增或编辑成功';
if (isset($house_id['status']) && $house_id['status'] == 2) {
$push_service = new PushMessageService();
$push_service->pushHouseDownMessage($house_id['house_id']);
}
} else {
$data['code'] = 101;
$data['msg'] = 'Add houses failure';
......
......@@ -244,6 +244,31 @@ class PushMessageService
return ;
}
/**
* 根据商铺id 推送下架消息
*
* @param $house_id
* @return bool|void
*/
public function pushHouseDownMessage($house_id) {
$house = new GHouses();
try {
$house_data = $house->getHouseInfoById('internal_title',['id'=>$house_id]);
$content = '你的【'.$house_data['internal_title'].'】商铺下架,如需要上架,请编辑提交该商铺';
$house_agent = new GHousesToAgents();
$house_agent_data = $house_agent->getAgentList($house_id, 2, 'a.agents_id');
} catch (\Exception $e) {
return false;
}
foreach ($house_agent_data as $k=>$v) {
$this->pushAgentAllDeviceId($v['agents_id'], '商铺下架', $content, 'house_info',$house_id);
}
return ;
}
/**
* @param $id
* @param $title
......@@ -251,9 +276,6 @@ class PushMessageService
* @param null $type
* @param null $user_id
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function pushAgentAllDeviceId($id, $title, $content, $type = null, $user_id = null)
{
......
......@@ -65,14 +65,19 @@ class Houses extends Basic
if (!empty($this->params['sublet_id']) && $this->params['source'] == 'transfer_list') {
$m_sublet = new SubletModel();
$sublet_data['house_id'] = $house_id;
$sublet_data['house_id'] = $house_id['house_id'];
$sublet_data['status'] = 2;
$sublet_data['agents_id'] = $this->userId;
$m_sublet->editData($sublet_data, $this->params['sublet_id']);
}
if ($house_id) {
$return = $this->response($result['code'], $result['msg'], [ 'id', $house_id ]);
if ($house_id['house_id']) {
$return = $this->response($result['code'], $result['msg'], [ 'id', $house_id['house_id'] ]);
if (isset($house_id['status']) && $house_id['status'] == 2) {
$push_service = new PushMessageService();
$push_service->pushHouseDownMessage($house_id['house_id']);
}
} else {
$return = $this->response(101, 'add houses is error');
}
......
......@@ -64,9 +64,6 @@ class ABindingDevice extends BaseModel
* @param array $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDeviceByAgentId(array $params, string $field = "id,agent_id,device_id,is_forbidden,model,push_id,is_pc")
{
......@@ -83,11 +80,17 @@ class ABindingDevice extends BaseModel
if (isset($params["is_pc"])) {
$where_["is_pc"] = $params["is_pc"];
}
$data = $this
->field($field)
->where($where_)
->order("create_time desc")
->select();
try {
$data = $this
->field($field)
->where($where_)
->order("create_time desc")
->select();
} catch (\Exception $e) {
$data = [];
}
return $data;
}
......
......@@ -474,6 +474,7 @@ class GHouses extends BaseModel
$params['operation_id'] = $params['userId'];
$this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]);
$house_id = $this->id;
$result['status'] = $params['status'];
}
$params['house_id'] = $house_id;
......@@ -543,8 +544,8 @@ class GHouses extends BaseModel
} else {
$this->rollback();
}
return $house_id;
$result['house_id'] = $house_id;
return $result;
}
/**
......@@ -1054,6 +1055,7 @@ class GHouses extends BaseModel
}
$result['internal_title'] = $house_data['internal_title'];
$result['house_id'] = $house_id;
$result['status'] = $params['status'];
}
$params['house_id'] = $house_id;
......
......@@ -2,6 +2,7 @@
namespace app\task\controller;
use app\api_broker\service\PushMessageService;
use app\model\GHouses;
use app\model\GHousesFollowUp;
use app\model\OrderModel;
......@@ -19,6 +20,7 @@ class UpdateShopStatusTask
{
private $shopModel;
public $house_id = [];
function __construct()
{
$this->shopModel = new GHouses();
......@@ -74,6 +76,7 @@ class UpdateShopStatusTask
if (!$is_ok && !$is_follow) {
$update_arr[$key]["id"] = $item["id"];
$update_arr[$key]["status"] = 2;
$this->house_id[] = $item['id'];
}
}
if (count($update_arr) > 0) {
......@@ -99,6 +102,7 @@ class UpdateShopStatusTask
foreach ($result as $k => $item) {
$update_arr[$k]["id"] = $item["id"];
$update_arr[$k]["status"] = 2;
$this->house_id[] = $item['id'];
}
$this->shopModel->updateHouse($update_arr);
}
......@@ -121,10 +125,19 @@ class UpdateShopStatusTask
foreach ($result as $key => $item) {
$update_arr[$key]["id"] = $item["id"];
$update_arr[$key]["status"] = 2;
$this->house_id[] = $item['id'];
}
if (count($update_arr) > 0) {
$this->shopModel->updateHouse($update_arr);
}
}
public function __destruct() {
//处理下架推送消息
$push_service = new PushMessageService();
foreach ($this->house_id as $k=>$v) {
$push_service->pushHouseDownMessage($v);
}
}
}
\ 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