Commit 5c647c76 authored by hujun's avatar hujun

推送记录

parent d12541be
......@@ -326,7 +326,7 @@ class PushMessageService
case 0 :
$result = $m_push->addData( $data, $operation_id, $type);break;
case 1 :
$result = $m_push->addHouseIdArray( $house_id, $operation_id, $type, $data);break;
$result = $m_push->addHouseIdArray( $house_id, 0,$type, $data);break;
case 2 :
$result = $m_push->addAgentIdArray( $agent_id, $operation_id, $type, $data);break;
}
......
......@@ -144,6 +144,14 @@ class HouseService
}
}
if (!empty($data['id'])) {
//剩余商铺为0下架
if (empty($data['residue_num']) || empty($data['total'])) {
$push = new PushMessageService();
$push->record(1, [0 => $house_id], 0, $agent_id); //记录推送信息
}
}
$result['data']['house_id'] = $house_id;
$result['status'] = 'successful';
$result['msg'] = '新增或编辑成功!';
......
......@@ -70,12 +70,13 @@ class MPushMessage
* @param $data
* @return bool
*/
public function addHouseIdArray(array $house_id, int $type, $data)
public function addHouseIdArray(array $house_id, $operation_id,int $type, $data)
{
if (!is_array($house_id)) {
return false;
}
$m_house = new GHouses();
$insert_data = [];
foreach ($house_id as $k => $v) {
......@@ -83,24 +84,13 @@ class MPushMessage
foreach ($agent_id as $k2=>$v2) {
$insert_data[$k2]['house_id'] = $v;
if (isset($data['message'])) {
$insert_data[$k2]['message'] = $data['message'];
}
if (isset($data['user_id'])) {
$insert_data[$k2]['user_id'] = $data['user_id'];
}
if (isset($data['addressee_id'])) {
$insert_data[$k2]['addressee_id'] = $data['addressee_id'];
}
$internal_title = $m_house->where('id',$v)->value('internal_title');
$insert_data[$k2]['message'] = '你的【'.$internal_title.'】商铺下架,如需要上架,请编辑提交该商铺.';
$insert_data[$k2]['addressee_id'] = $v2;
$insert_data[$k2]['type'] = $type;
$insert_data[$k2]['status'] = 0;
$insert_data[$k2]['operation_id'] = $v2;
$insert_data[$k2]['operation_id'] = $operation_id;
}
}
$num = $this->db_->insertAll($insert_data);
......@@ -169,13 +159,13 @@ class MPushMessage
$where['a.type'] = 2;
$result = $m_house->getHouseAgent('agents_id', $where);
$data = [];
$agent_id = [];
if ($result['status'] != 'fail') {
foreach ($result['agents_id'] as $k=>$v) {
$data[] = $v;
foreach ($result['data'] as $k=>$v) {
$agent_id[] = $v['agents_id'];
}
}
return $data;
return $agent_id;
}
}
\ No newline at end of file
......@@ -20,7 +20,6 @@ class UpdateShopStatusTask
{
private $shopModel;
public $house_id = [];
function __construct()
{
$this->shopModel = new GHouses();
......@@ -54,7 +53,7 @@ class UpdateShopStatusTask
$params = [];
$time_ = date('Y-m-d', strtotime("-$day day"));
$params["status"] = 1;
$params["update_time"] = array( 'lt', $time_ . " 23:59:59" );
$params["update_time"] = [ 'lt', $time_ . " 23:59:59" ];
$params["is_exclusive_type"] = 0;
//所有修改时间大于10天的商铺
......@@ -63,9 +62,9 @@ class UpdateShopStatusTask
$orderModel = new OrderModel();
$followMole = new GHousesFollowUp();
$select_["create_time"] = array( "between", array( $time_, date("Y-m-d H:i:s", time()) ) );
$select_["create_time"] = [ "between", [ $time_, date("Y-m-d H:i:s", time()) ] ];
$update_arr = [];
$update_arr = $house_id = [];
foreach ($result as $key => $item) {
$select_["house_id"] = $item["id"];
......@@ -76,14 +75,13 @@ class UpdateShopStatusTask
if (!$is_ok && !$is_follow) {
$update_arr[$key]["id"] = $item["id"];
$update_arr[$key]["status"] = 2;
$this->house_id[] = $item['id'];
$house_id[] = $item['id'];
}
}
if (count($update_arr) > 0) {
$this->shopModel->updateHouse($update_arr);
$this->recordPushMessage($house_id);
}
}
/**
......@@ -94,17 +92,21 @@ class UpdateShopStatusTask
$field = "id,residue_num";
$params = [];
$params["status"] = 1;
$params["residue_num"] = array( "lt", 1 );
$params["residue_num"] = [ "lt", 1 ];
$result = $this->shopModel->getShopListByNum($field, $params);
$update_arr = [];
$update_arr = $house_id = [];
foreach ($result as $k => $item) {
$update_arr[$k]["id"] = $item["id"];
$update_arr[$k]["status"] = 2;
$this->house_id[] = $item['id'];
$house_id[] = $item['id'];
}
if (count($update_arr) > 0) {
$this->shopModel->updateHouse($update_arr);
$this->recordPushMessage($house_id);
}
$this->shopModel->updateHouse($update_arr);
}
/**
......@@ -113,11 +115,11 @@ class UpdateShopStatusTask
private function updateStatusByPact()
{
$field = "a.id";
$params = [];
$params = $house_id = [];
$time_ = date('Y-m-d', time());
$params["status"] = 1;
$params["is_exclusive_type"] = 1;
$params["agent_end_time"] = array( 'lt', $time_ );
$params["agent_end_time"] = [ 'lt', $time_ ];
$result = $this->shopModel->getShopListByPact($field, $params);
......@@ -125,23 +127,20 @@ class UpdateShopStatusTask
foreach ($result as $key => $item) {
$update_arr[$key]["id"] = $item["id"];
$update_arr[$key]["status"] = 2;
$this->house_id[] = $item['id'];
$house_id[] = $item['id'];
}
if (count($update_arr) > 0) {
$this->shopModel->updateHouse($update_arr);
$this->recordPushMessage($house_id);
}
}
/**
* 记录需要推送的消息
*/
public function recordPushMessage() {
public function recordPushMessage($house_id)
{
$push_service = new PushMessageService();
$push_service->record(1, $this->house_id, 0, 0);
$push_service->record(1, $house_id, 0, 0);
}
// public function __destruct() {
// $this->recordPushMessage();
// }
}
\ 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