Commit 1545908b authored by hujun's avatar hujun

11

parent 0194976d
......@@ -15,6 +15,7 @@ use app\model\ABindingDevice;
use app\model\AStore;
use app\model\GHouses;
use app\model\GHousesToAgents;
use app\model\MPushMessage;
use app\model\OrderModel;
use app\model\OReportModel;
use app\model\PushFeed;
......@@ -307,4 +308,28 @@ class PushMessageService
}
return false;
}
/**
* 记录需要推送的消息
*
* @param $type
* @param $house_id
* @param $agent_id
* @param $operation_id
* @param $data
* @return bool
*/
public function record($type, $house_id, $agent_id, $operation_id, $data = []) {
$result = false;
$m_push = new MPushMessage();
switch ($type) {
case 0 :
$result = $m_push->addData( $data, $operation_id, $type);break;
case 1 :
$result = $m_push->addHouseIdArray( $house_id, $operation_id, $type, $data);break;
case 2 :
$result = $m_push->addAgentIdArray( $agent_id, $operation_id, $type, $data);break;
}
return $result;
}
}
\ No newline at end of file
......@@ -315,17 +315,23 @@ class GHousesToAgents extends BaseModel
* @param string $field
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseAgent(string $field = '', array $where = []): array
public function getHouseAgent(string $field = '', array $where = []) : array
{
return $this->alias('a')
->field($field)
->join('a_agents b', 'a.agents_id=b.id', 'left')
->where($where)
->select();
try {
$where['a.is_del'] = 0;
$result['data'] = $this->alias('a')
->field($field)
->join('a_agents b', 'a.agents_id=b.id', 'left')
->where($where)
->select();
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['data'] = [];
$result['status'] = 'fail';
}
return $result;
}
/**
......@@ -355,4 +361,19 @@ class GHousesToAgents extends BaseModel
->limit(1)
->select();
}
/**
* @param $agent_id
* @param int $type
* @return int|string
*/
public function getAgentHouseNum($agent_id, $type = 3) {
return $this->alias('a')
->field('a.id')
->join('a_agents b', 'a.agents_id=b.id', 'left')
->where('a.is_del', 0)
->where('a.type', $type)
->where('a.agents_id', $agent_id)
->count();
}
}
......@@ -104,7 +104,7 @@ class UpdateShopStatusTask
$update_arr[$k]["status"] = 2;
$this->house_id[] = $item['id'];
}
$this->shopModel->updateHouse($update_arr);
// $this->shopModel->updateHouse($update_arr);
}
/**
......@@ -133,11 +133,15 @@ class UpdateShopStatusTask
}
public function __destruct() {
//处理下架推送消息
/**
* 记录需要推送的消息
*/
public function recordPushMessage() {
$push_service = new PushMessageService();
foreach ($this->house_id as $k=>$v) {
$push_service->pushHouseDownMessage($v);
}
$push_service->record(1, $this->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