', time()]; //且结束时间大于当前时间 $_where[] = ['r.end_time', '<>', '']; } $_where[] = ['r.is_del', '=', 0]; $_data = Db::name($this->table_room)->alias('r')->leftJoin('cloud_house_tenant t', 'r.id = t.room_id')->where($_where)->field('r.*,t.phone,t.name')->select(); $this->send($_data); } /** * 到期一手房源提醒 * @param int $day 默认3天 */ public function house($day = 3) { if ($day && is_numeric($day)) { //计算指定天数后的时间戳 $day_time = strtotime('+' . $day . ' day'); $_where[] = ['create_time', '<', $day_time]; //结束时间小于当前时间+30天 $_where[] = ['create_time', '>', time()]; //且结束时间大于当前时间 $_where[] = ['create_time', '<>', '']; } $_data = Db::name($this->table_house_crontab)->where($_where)->select(); $this->sendHouse($_data); } /** * 执行短信发送 * @param $_arr * */ private function send($_arr) { if (empty($_arr)) { return; } $curr_month = date('Y-m'); $_sms = new \app\api\controller\Sms(); foreach ($_arr as $k => $v) { $_str = [ '{url}' => $this->url . '?roomid=' . $v['id'] . '&phone=' . $v['phone'] . '&name=' . $v['name'] ]; //判断本月是否发送过,已发送不再发送 $_data = Db::name($this->table_sms_log)->where('mobile', $v['phone'])->where('month', $curr_month)->find(); if (empty($_data)) { $_sms::sendNotify($v['phone'], $_str, 23); } } } /** * 执行短信发送 * @param $_arr * */ private function sendHouse($_arr) { if (empty($_arr)) { return; } $curr_month = date('Y-m'); $_sms = new \app\api\controller\Sms(); foreach ($_arr as $k => $v) { $_str = [ '{address}' => $v['address'] . $v['house_name'] . $v['door_number'] ]; //判断本月是否发送过,已发送不再发送 $_data = Db::name($this->table_sms_log)->whereLike('text', '%' . $v["house_name"] . '%')->where('mobile', $v['phone'])->where('month', $curr_month)->find(); if (empty($_data)) { $_sms::sendNotify($v['phone'], $_str, 24); } } } }