/** * 提醒打印店下载或者打印 * @method notifyPrinters * @return [type] [description] * @author xuzhang[xuzhang@yunyin.org] */ public function notifyPrinters() { $verify_key = I('get.key'); if ($verify_key != C('VERIFY_KEY')) { $this->{$this}->error('验证失效'); } /*查询*/ $condition1['status'] = 1; $condition2['status'] = 2; $condition2['copies'] = array('gt', 0); $NotifyPrinted = D('NotifyPrinter'); $to_download = $NotifyPrinted->where($condition1)->group('pri_name')->select(); $to_print = $NotifyPrinted->where($condition2)->group('pri_name')->select(); /*合并结果*/ $result = array(); foreach ($to_download as $d) { $result[$d['pri_id']] = array('pri_name' => $d['pri_name'], 'no_download' => $d['count'], 'unprinted' => 0, 'phone' => $d['phone']); } foreach ($to_print as $p) { if (isset($result[$p['pri_id']])) { $result['to_print'] = $p['count']; } else { //如果这个店之前没有创建在此创建 $result[$p['pri_id']] = array('pri_name' => $p['pri_name'], 'no_download' => 0, 'unprinted' => $p['count'], 'phone' => $p['phone']); } } if (!empty($result)) { /*逐个店通知*/ $SMS = new \Vendor\Sms(); foreach ($result as $i => $notice) { echo '[', $i, ']:', $notice['pri_name'], $notice['no_download'], ',', $notice['unprinted'], ':'; if ($SMS->noticePrinter($notice['phone'], $notice)) { echo '1'; } else { echo $notice['phone']; } } } }