sendOne($key, $project_id, $touser); } # 发送单条模板消息 public function sendOne($key, $project_id, $touser, $state = true) { if ($project_id > 0 && $key && $touser) { $info = Dever::db('youzan/card')->one(array('option_key' => $key, 'option_project_id' => $project_id)); if ($info) { Dever::setInput('mobile', $touser); Dever::load('youzan/user.reg'); $update = array(); $update['project_id'] = $info['project_id']; $update['card_id'] = $info['id']; $update['touser'] = $touser; $where = array(); $where['option_card_id'] = $info['id']; //$where['option_project_id'] = $info['project_id']; $where['option_touser'] = $update['touser']; $id = Dever::upinto('youzan/card_log', $where, $update); return Core::run($info['project_id'], 'card', 'card.sendAction', 'card.sendLog', 'youzan', $id, $state); } } return false; } public function sendAction($id) { $info = Dever::db('youzan/card_log')->one($id); if ($info) { $msg = Dever::db('youzan/card')->one($info['card_id']); $info['mobile'] = $info['touser']; $info['coupon_group_id'] = $msg['card_id']; return $info; } else { die; } } public function sendLog($project_id, $data, $id = false) { $info = Dever::db('youzan/card_log')->one($id); if ($info) { $update['where_id'] = $info['id']; $update['result'] = json_encode($data); if (!isset($data['error_response'])) { $update['status'] = 2; } else { $update['status'] = 3; } $update['num'] = $info['num'] + 1; Dever::db('youzan/card_log')->update($update); } } }