/** * Method to get an array of data items. * * @return mixed An array of data items on success, false on failure. * @since 1.6 */ public function getItems() { $items = array(); $news_id = JRequest::getInt('news_id', 0); if ($news_id != 0) { jincimport('core.newsletterfactory'); $ninstance = NewsletterFactory::getInstance(); if ($newsletter = $ninstance->loadNewsletter($news_id, false)) { $items = $newsletter->getTagsList(); } } $msg_id = JRequest::getInt('msg_id', 0); if ($msg_id != 0) { jincimport('core.messagefactory'); $minstance = MessageFactory::getInstance(); if ($message = $minstance->loadMessage($msg_id)) { $news_id = $message->get('news_id'); jincimport('core.newsletterfactory'); $ninstance = NewsletterFactory::getInstance(); if ($newsletter = $ninstance->loadNewsletter($news_id, false)) { $items = $newsletter->getTagsList(); if ($message->getType() == MESSAGE_TYPE_MASSIVE) { unset($items['USER']); } unset($items['OPTIN']); } } } return $items; }
public function setParams($params) { $this->_params = MessageFactory::mergeParams($params, $params[self::TYPE], array('template_id', 'template_data')); if (empty($this->_params['template_data']['wecha_id'])) { $this->_params['template_data']['wecha_id'] = $params['wecha_id']; } }
function getData() { jincimport('core.messagefactory'); $msg_id = JRequest::getInt('id', 0, 'GET'); $minstance = MessageFactory::getInstance(); if (!($message = $minstance->loadMessage($msg_id))) { $this->setError('COM_JINC_ERR035'); return false; } return $message; }
function loadcss() { $doc = JFactory::getDocument(); // $doc->setMimeEncoding('text/css'); $tem_id = JRequest::getInt('id', 0); jincimport('core.messagefactory'); $minstance = MessageFactory::getInstance(); if (!($template = $minstance->loadTemplate($tem_id))) { return ''; } if (!($cssfile_content = $template->getCSSFileContent())) { return ''; } echo $cssfile_content; }
/** * @covers ICANS\Component\IcansLoggingComponent\Transport\MessageFactory::createMessageWithPulseId */ public function testCreateMessageWithPulseIdWithExistingHttpHost() { $oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; $_SERVER['HTTP_HOST'] = 'my-dummy-hostname'; $actual = $this->object->createMessageWithPulseId('message type', 'message handle', 1, array('Body item 1', 'Body item 2'), 'app', 'origin service type', 'origin service component', 'origin service instance', 'pulse ID', 1234, 'log level name'); // Additionally, when createMessage() is called, a random pulse ID is // created. As we cannot predict it and neither can perform any test // without relying on internals, we simply verify it's a non-empty // string and do nothing more. $rawData = $actual->getRawData(); $this->assertInternalType('string', $rawData['origin_host']); $this->assertSame(gethostname(), $rawData['origin_host']); $_SERVER['HTTP_HOST'] = $oldhost; // Reset to initial state }
function getTemplateInfo() { header("Content-Type: text/plain; charset=UTF-8"); jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); $tem_id = JRequest::getInt('id', 0); $minstance = MessageFactory::getInstance(); if (!($template = $minstance->loadTemplate($tem_id))) { $template = new MessageTemplate(0); } // Building JSON response $response = new JSONResponse(); $response->set('subject', $template->get('subject')); $response->set('body', $template->get('body')); echo $response->toString(); }
public function index($order_id, $paytype = '', $third_id = '') { $wecha_id = ''; $token = ''; $order = M('seckill_book')->where(array('orderid' => $order_id))->find(); if (!empty($order)) { $wecha_id = $order['wecha_id']; $token = $order['token']; if ($order['paid']) { $model = new templateNews(); $siteurl = $_SERVER['HTTP_HOST']; $siteurl = strtolower($siteurl); if ((strpos($siteurl, 'http:') === false) && (strpos($siteurl, 'https:') === false)) { $siteurl = 'http://' . $siteurl; } $siteurl = rtrim($siteurl, '/'); $model->sendTempMsg('OPENTM202521011', array('href' => $siteurl . '/index.php?g=Wap&m=Seckill&a=my_cart&token=' . $token . '&wecha_id=' . $wecha_id . '&id=' . $order['book_aid'], 'wecha_id' => $wecha_id, 'first' => '秒杀交易提醒', 'keyword1' => $order_id, 'keyword2' => date('Y年m月d日H时i分s秒'), 'remark' => '订单完成!')); $params = array(); $params['site'] = array('token' => $token, 'from' => '微秒杀消息', 'content' => '顾客' . $order['true_name'] . '刚刚对订单号:' . $order_id . '的订单进行了支付,请您注意查看并处理'); MessageFactory::method($params, 'SiteMessage'); $shop_info = M('seckill_base_shop')->where(array('shop_id' => $order['book_sid']))->find(); if (1 <= $shop_info['shop_num']) { M('seckill_base_shop')->where(array('shop_id' => $order['book_sid']))->save(array( 'shop_num' => array('exp', 'shop_num-1') )); } header('Location:' . U('Seckill/my_cart', array('token' => $token, 'wecha_id' => $wecha_id, 'id' => $order['book_aid']))); } else { header('Location:' . U('Seckill/my_cart', array('token' => $token, 'wecha_id' => $wecha_id, 'id' => $order['book_aid']))); } } else { exit('订单不存在:' . $order_id); } }
function deleteReport($proc_id) { jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); jincimport('utility.servicelocator'); $servicelocator = ServiceLocator::getInstance(); $logger = $servicelocator->getLogger(); $response = new JSONResponse(); $minstance = MessageFactory::getInstance(); if ($minstance->deleteReport($proc_id)) { $response->set('status', 0); } else { $response->set('status', -1); } $logger->debug('JSON: ' . $response->toString()); return $response->toString(); }
if (!$permission->Check('message', 'enabled') or !($permission->Check('message', 'view') or $permission->Check('message', 'view_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Message List')); // See index.php BreadCrumb::setCrumb($title); /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'filter_folder_id', 'ids'))); $sort_array = NULL; if ($sort_column != '') { $sort_array = array($sort_column => $sort_order); } $mf = new MessageFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'new_message': Redirect::Page(URLBuilder::getURL(NULL, 'EditMessage.php', FALSE)); break; case 'delete': case 'undelete': //Debug::setVerbosity( 11 ); if (strtolower($action) == 'delete') { $delete = TRUE; } else { $delete = FALSE; } if (is_array($ids) and count($ids) > 0 and ($permission->Check('message', 'delete') or $permission->Check('message', 'delete_own'))) { $mlf = new MessageListFactory();
/** * Este m�todo es llamado antes de la primera carga del formulario. Debe ser sobreescrito de acuerdo a las necesidades. * Por defecto esta implementaci�n carga los mensajes que estt�n dirigidos a la acci�n. * * @access protected * @return void */ function defaults() { // Asignar el mensaje if (!empty($_GET['m'])) { $error = $_GET['error'] == '1'; $this->asignar('mensaje', MessageFactory::getMensaje($_GET['m'], $error)); } }
public function commonSmsVerify(){ $mobile = $this->_post('mobile'); $token = $this->_post('token','trim'); $wecha_id = $this->_post('wecha_id','trim'); if(empty($mobile) || empty($token)){ exit('参数错误'); } $userinfoWhere = array('token'=>$token,'wecha_id'=>$wecha_id); $userinfo = M('Userinfo')->where($userinfoWhere)->find(); if(!empty($userinfo) && $userinfo['isverify'] == 1){ exit('您已经验证过手机号了,请勿重复验证'); } $_SESSION['c_rand_num'][$mobile]=''; $_SESSION['c_send_time'][$mobile] = ''; $rand_num = rand(100000,999999); $_SESSION['c_rand_num'][$mobile] = $rand_num; $_SESSION['c_send_time'][$mobile] = $_SERVER['REQUEST_TIME']; $params = array(); $params['sms'] = array('token'=>$this->token, 'mobile'=>$mobile,'content'=>'您的验证码是:'.$rand_num.'。 此验证码30分钟内有效,请不要把验证码泄露给其他人。如非本人操作,可不用理会!'); $return_status = MessageFactory::method($params, 'SmsMessage'); if($return_status == 0 && strlen($return_status) == 1){exit('done');}elseif($return_status == null){exit('not_buy');}else{exit('短信发送失败,请稍后再试');} }
public function sms() { if ($_POST['tel'] != '') { $is_tel = M('userinfo')->where(array('token' => $_POST['token'], 'tel' => $_POST['tel'], 'isverify' => 1))->find(); if ($is_tel == '') { $params = array(); $session_sms = session($_POST['wecha_id'] . 'code' . $_POST['token'] . $_POST['id']); if ((time() < $session_sms['time']) && ($session_sms['tel'] == $_POST['tel'])) { $code = $session_sms['code']; } else { session($_POST['wecha_id'] . 'code' . $_POST['token'] . $_POST['id'], NULL); $code = rand(100000, 999999); $session_sms['tel'] = $_POST['tel']; $session_sms['code'] = $code; $session_sms['time'] = time() + (60 * 30); session($_POST['wecha_id'] . 'code' . $_POST['token'] . $_POST['id'], $session_sms); } $params['sms'] = array('token' => $this->token, 'mobile' => $_POST['tel'], 'content' => '您的验证码是:' . $code . '。 此验证码30分钟内有效,请不要把验证码泄露给其他人。如非本人操作,可不用理会!'); $data['error'] = MessageFactory::method($params, 'SmsMessage'); $this->ajaxReturn($data, 'JSON'); } else { $data['error'] = 'tel'; $this->ajaxReturn($data, 'JSON'); } } }
*/ require_once '../../includes/global.inc.php'; require_once Environment::getBasePath() . 'includes/Interface.inc.php'; //Debug::setVerbosity(11); if (!$permission->Check('message', 'enabled') or !($permission->Check('message', 'view') or $permission->Check('message', 'view_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Message List')); // See index.php //BreadCrumb::setCrumb($title); /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'object_type_id', 'object_id', 'parent_id', 'message_data', 'template', 'close'))); $mf = new MessageFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'submit_message': //Debug::setVerbosity(11); if (!$permission->Check('message', 'enabled') or !$permission->Check('message', 'add')) { $permission->Redirect(FALSE); //Redirect } if (isset($object_type_id) and isset($object_id)) { if (!isset($parent_id)) { $parent_id = 0; } $mf->setObjectType($object_type_id); $mf->setObject($object_id); $mf->setParent($parent_id);
/** * 分佣记录 */ private function savelog($type, $twid, $token, $cid, $param = 1) { if ($twid && $token && $cid) { if ($this->mytwid == $twid) return false; $set = M("Twitter_set")->where(array('token' => $token, 'cid' => $cid))->find(); if (empty($set)) return false; $db = D("Twitter_log"); // 1.点击, 2.注册会员, 3.购买商品 $stime = strtotime(date("Y-m-d")); $etime = $stime + 86400; // if ($type == 3) {//购买商品 // $price = $set['percent'] * 0.01 * $param; // $db->add(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'type' => 3, 'dateline' => time(), 'param' => $param, 'price' => $price, 'wecha_id' => $this->wecha_id, 'info' => $info)); // } elseif ($type == 2) {//注册会员 // $price = $set['registerprice']; // $count = $db->where(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'type' => $type, 'dateline' => array('gt', $stime), 'dateline' => array('lt', $etime)))->sum('param'); // if ($count < $set['registermax']) { // $db->add(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'type' => 2, 'dateline' => time(), 'param' => $param, 'price' => $set['registerprice'])); // } // } else {//点击 $price = $set['clickprice']; $twitter = $db->where(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'wecha_id' => $this->wecha_id))->order('id DESC')->limit('0, 1')->find(); if ($twitter && (date("Ymd") == date("Ymd", $twitter['dateline']))) { return false; } $count = $db->where(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'type' => $type, 'dateline' => array('gt', $stime), 'dateline' => array('lt', $etime)))->sum('param'); if ($count < $set['clickmax']) { $actions = array('index' => '商城首页', 'cats' => '商城首页', 'products' => '商品列表', 'product' => '商品页', 'cart' => '购物车列表', 'orderCart' => '购物车结算', 'my' => '我的订单', 'myDetail' => '订单详情', 'updateOrder' => '修改订单', 'comment' => '评论', 'myinfo' => '我的个人信息', 'detail' => '佣金获取记录', 'remove' => '提现记录'); $info = isset($actions[ACTION_NAME]) ? '点击【' . $actions[ACTION_NAME] . '】获得' : '点击获得'; $db->add(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'type' => 1, 'dateline' => time(), 'param' => $param, 'price' => $set['clickprice'], 'wecha_id' => $this->wecha_id, 'info' => $info)); } else return false; // } //获取佣金时候消息提醒获得者 $messages = $params = array(); $userinfo = D('Userinfo')->where(array('twid' => $twid))->find(); if ($userinfo['tel']) { $messages[] = 'SmsMessage'; $params['sms'] = array('token' => $token, 'content' => '您分享的商城被您的朋友点击查看,您将从商家哪儿获得' . $price . '元的佣金,请您查看', 'moblie' => $userinfo['tel']); } $messages[] = 'TemplateMessage'; $params['template'] = array(); $params['template']['template_id'] = 'OPENTM201812627'; $params['template']['template_data']['href'] = U('Store/detail',array('token' => $token, 'wecha_id' => $userinfo['wecha_id'], 'twid' => $twid), true, false, true); $params['template']['template_data']['wecha_id'] = $userinfo['wecha_id']; $params['template']['template_data']['first'] = '您获得了一笔新的佣金'; $params['template']['template_data']['keyword1'] = $price; $params['template']['template_data']['keyword2'] = date("Y年m月d日 H:i"); $params['template']['template_data']['remark'] = '请进入店铺查看详情'; MessageFactory::method($params, $messages); //统计总收入 if ($count = M("Twitter_count")->where(array('token' => $token, 'cid' => $cid, 'twid' => $twid))->find()) { D("Twitter_count")->where(array('id' => $count['id']))->setInc('total', $price); } else { D("Twitter_count")->add(array('twid' => $twid, 'token' => $token, 'cid' => $cid, 'total' => $price, 'remove' => 0)); } } }
* $Date: 2008-08-21 12:16:38 -0700 (Thu, 21 Aug 2008) $ */ require_once '../../includes/global.inc.php'; require_once Environment::getBasePath() . 'includes/Interface.inc.php'; //Debug::setVerbosity(11); if (!$permission->Check('message', 'enabled') or !($permission->Check('message', 'view') or $permission->Check('message', 'view_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'View Message')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'object_type_id', 'object_id', 'parent_id', 'id', 'message_data', 'ack_message_id'))); $mf = new MessageFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'acknowledge_message': $mf->setId($ack_message_id); $mf->setAckDate(TTDate::getTime()); $mf->setAckBy($current_user->getId()); if ($mf->isValid()) { $mf->Save(); Redirect::Page(URLBuilder::getURL(array('object_type_id' => $object_type_id, 'object_id' => $object_id, 'id' => $parent_id), 'ViewMessage.php')); } break; case 'submit_message': //Debug::setVerbosity(11); if (!$permission->Check('message', 'enabled') or !$permission->Check('message', 'add')) { $permission->Redirect(FALSE);
public function saveOrderAndToPay() { $sessionDK = "session_Ordishs{$this->_cid}_{$this->token}"; $tmpOrderdata = $_SESSION[$sessionDK]; $tmpOrderdata = !empty($tmpOrderdata) ? unserialize($tmpOrderdata) : false; $DishC = $this->getDishCompany($this->_cid); $isjiacai = false; if (is_array($tmpOrderdata)) { $orid = $this->_get('orid') ? intval($this->_get('orid', "trim")) : 0; $sessionoridK = "session_orid{$this->_cid}_{$this->token}"; $sessionorid = $_SESSION[$sessionoridK]; $allmark = $_SESSION["allmark" . $this->_cid . $this->token]; if (($orid > 0) && ($orid == $sessionorid)) { $takeaway = 2; $Dish_order = D('Dish_order'); $myorder = $Dish_order->where(array('id' => $orid, 'token' => $this->token, 'cid' => $this->_cid))->find(); if ($myorder) { $orderdish = array(); $takeaway = $myorder['takeaway']; $myorderinfo = !empty($myorder['info']) ? unserialize($myorder['info']) : false; if ((empty($myorderinfo) || ((count($myorderinfo) == 1) && isset($myorderinfo['table']))) && ($myorder['total'] == 0)) { $orderdish = $tmpOrderdata['orderdish']; $orderdish['table'] = array('tableid' => $myorder['tableid'], 'num' => 1, 'price' => $myorder['price']); } else { $myorderinfo = unserialize($myorder['info']); $mc = count($myorderinfo); $mc = $mc > 0 ? $mc : 1; foreach ($tmpOrderdata['orderdish'] as $key => $val) { $val['j_c'] = 1; $val['flag'] = $mc; $myorderinfo[$mc . 'jc' . $key] = $val; } $orderdish = $myorderinfo; } $orderid = $myorder['orderid']; $tmporderid = 'order' . date("YmdHis"); $tmpOrderarr = array('total' => $tmpOrderdata['totalnum'] + $myorder['total'], 'price' => $tmpOrderdata['totalmoney'] + $myorder['price'], 'info' => serialize($orderdish), 'paid' => 0, 'allmark' => $allmark, 'tmporderid' => $tmporderid); if ($myorder['paid'] == 1) { //$tmpOrderarr['havepaid'] = $myorder['price'] + $myorder['havepaid']; 注销此处, $tmpOrderarr['paid'] = 0; } $Dish_order->where(array('id' => $orid, 'token' => $this->token, 'cid' => $this->_cid))->save($tmpOrderarr); $Orderarr = array('nums' => $myorder['nums'], 'time' => time(), 'allmark' => $allmark, 'orderid' => $myorder['orderid'], 'name' => $myorder['name'], 'tel' => $myorder['tel'], 'wecha_id' => $myorder['wecha_id'], 'tableid' => $myorder['tableid'], 'des' => '', 'sex' => $myorder['sex'], 'tmporderid' => $tmporderid); unset($myorder, $orderdish); $_SESSION[$sessionoridK] = ''; $isjiacai = true; } else { $jumpurl = U('Repast/dishMenu', array('token' => $this->token, 'cid' => $this->_cid, 'wecha_id' => $this->wecha_id, 'orid' => $orid)); $this->error('订单信息出错了', $jumpurl); } } else { $data = $_POST; $takeaway = intval($data['takeaway']); $youtel = htmlspecialchars(trim($data['youtel']), ENT_QUOTES); $youname = htmlspecialchars(trim($data['youname']), ENT_QUOTES); $youremark = htmlspecialchars(trim($data['youremark']), ENT_QUOTES); $youtableid = isset($data['youtable']) ? intval(trim($data['youtable'])) : 0; $isallpay = isset($_POST['isallpay']) ? intval($_POST['isallpay']) : 1; /* * 是否要立刻全额支付0不是1是* */ if (empty($youtel) || empty($youname)) { $this->error('手机号码或顾客姓名没有填写!'); } if (!($youtableid > 0) && ($DishC['offtable'] == 0)) { $this->error('请选择一个餐桌!'); } $wecha_id = $this->wecha_id ? $this->wecha_id : 'Repastm_' . $youtel; $orderid = substr($wecha_id, -5) . date("YmdHis"); $Orderarr = array('cid' => $this->_cid, 'wecha_id' => $wecha_id, 'token' => $this->token, 'total' => $tmpOrderdata['totalnum'], 'price' => $tmpOrderdata['totalmoney'], 'tmporderid' => $orderid); if ($takeaway == 0) { /* $date=trim($data['date']); $time=trim($data['time']); $number=intval(trim($data['number'])); if(empty($date) || empty($time)){ $this->error('就餐时间没有填写完整!'); } if(!($number>0)){ $this->error('就餐人数填写有误!'); } */ $Orderarr['nums'] = $number; $Orderarr['reservetime'] = strtotime($date . ' ' . $time); } else { $Orderarr['nums'] = 1; $Orderarr['reservetime'] = time(); } $Orderarr['info'] = serialize($tmpOrderdata['orderdish']); $Orderarr['name'] = $youname; $Orderarr['sex'] = intval(trim($data['yousex'])); $Orderarr['tel'] = $youtel; $Orderarr['address'] = ''; $Orderarr['tableid'] = $youtableid; $Orderarr['time'] = time(); $Orderarr['stype'] = 0; $Orderarr['paid'] = 0; $Orderarr['isuse'] = 0; $Orderarr['orderid'] = $orderid; $Orderarr['printed'] = 0; $Orderarr['des'] = $youremark; $Orderarr['allmark'] = $allmark; $Orderarr['takeaway'] = $takeaway; $Orderarr['advancepay'] = !($isallpay > 0) ? $DishC['advancepay'] : 0; $Orderarr['isover'] = !($isallpay > 0) ? 1 : 0; /* * 订单支付是否结束1进行2结束* */ $orid = M('Dish_order')->add($Orderarr); $datas['wechaname'] = $this->_POST('youname'); $datas['sex'] = $this->_POST('yousex'); $datas['tel'] = $this->_POST('youtel'); $wheres['token']=$this->token; $wheres['wecha_id']=$this->wecha_id; $dbs=M('Userinfo'); $find=$dbs->where($where)->find(); if($find == null){ $dbs->add($datas); }else{ $dbs->where($wheres)->save($datas); } } if ($orid) { $_SESSION[$sessionDK] = ''; $sessionK = "session_dishs{$this->_cid}_{$this->token}"; $_SESSION[$sessionK] = ''; /* * 更新餐桌状态* */ if ($takeaway == 2) { M('Dining_table')->where(array('cid' => $this->_cid, 'id' => $Orderarr['tableid']))->save(array('status' => 1)); } $t_table = M("Dining_table")->where(array('cid' => $this->_cid, 'id' => $Orderarr['tableid']))->find(); //TODO 短信提示 $company = $this->getCompany($this->_cid); $msgstr = "顾客{$youname}他刚刚点了一份餐,订单号:{$orderid},请您注意查看并处理"; if ($isjiacai) $msgstr = "顾客{$youname}他刚刚在订单号为 {$orderid} 里加了菜,请您注意查看并处理"; Sms::sendSms($this->token, $msgstr, $company['mp']); //给商家发站内信 $params = array(); if($isjiacai){ $siteMessage = "顾客{$youname}他刚刚在订单号为 {$orderid} 里加了菜,请您注意查看并处理"; }else{ $siteMessage = "顾客{$youname}他刚刚点了一份餐,订单号:{$orderid},请您注意查看并处理"; } $params['site'] = array('token'=>$this->token, 'from'=>'微餐饮消息','content'=>$siteMessage); MessageFactory::method($params, 'SiteMessage'); // $printer_set = $this->getPrinter_set($this->_cid); // if (!empty($printer_set) && ($printer_set['paid'] == 0)) { $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => $Orderarr['allmark'] ? $Orderarr['allmark'] : $Orderarr['des'], 'companytel' => $company['tel'], 'truename' => $Orderarr['name'], 'tel' => $Orderarr['tel'], 'address' => '', 'buytime' => $Orderarr['time'], 'orderid' => $Orderarr['orderid'], 'price' => $tmpOrderdata['totalmoney'], 'total' => $tmpOrderdata['totalnum'], 'typename' => $takeaway == 2 ? '现场点餐' : '预约点餐', 'tablename' => $t_table['name'], 'list' => $tmpOrderdata['orderdish']); if (isset($isallpay) && ($isallpay == 0)) { $advancepay = $msg['advancepay'] = $DishC['advancepay']; } $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $this->_cid, 'Repast', $msg, 0); /*厨房打印菜单*/ if ($kitchens_list = D('Dish_kitchen')->where(array('cid' => $this->_cid))->select()) { $t_list = array(); foreach ($tmpOrderdata['orderdish'] as $dish) $t_list[$dish['kitchen_id']][] = $dish; $kitchens = array(); foreach ($kitchens_list as $kit_row) $kitchens[$kit_row['id']] = $kit_row; $print_msg = array('des' => $Orderarr['allmark'] ? $Orderarr['allmark'] : $Orderarr['des'], 'truename' => $Orderarr['name'], 'buytime' => $Orderarr['time'], 'orderid' => $Orderarr['orderid'], 'typename' => $takeaway == 2 ? '现场点餐' : '预约点餐', 'tablename' => $t_table['name']); foreach ($t_list as $k => $rowset) { if ($k) { if (isset($kitchens[$k]) && $kitchens[$k]['status']) { for ($i = 0; $i < count($rowset); $i++) { $msg = $print_msg; $msg['list'][] = $rowset[$i]; $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $this->_cid, 'Repast', $msg, 0, '', $k); } } else { $msg = $print_msg; $msg['list'] = $rowset; $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $this->_cid, 'Repast', $msg, 0, '', $k); } } } } /*厨房打印菜单*/ // } $alipayConfig = M('Alipay_config')->where(array('token' => $this->token))->find(); if ($alipayConfig['open']) { $msgstr = isset($advancepay) ? '需要支付 ' . $advancepay . ' 元就餐预定金<br/>正在提交中...' : '正在提交中...'; $paydata = array('token' => $this->token, 'wecha_id' => $Orderarr['wecha_id'], 'success' => 1, 'from' => 'Repast', 'orderName' => $Orderarr['tmporderid'], 'single_orderid' => $Orderarr['tmporderid'], 'price' => $tmpOrderdata['totalmoney']); if (isset($advancepay) && ($advancepay > 0)) { $paydata['price'] = $advancepay; $paydata['advancepay'] = 1; } $this->success($msgstr, U('Alipay/pay', $paydata)); } /* elseif ($this->fans['balance']) { $this->success('正在提交中...', U('CardPay/pay',array('token' => $this->token, 'wecha_id' => $wecha_id, 'success' => 1, 'from'=> 'Repast', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $tmpOrderdata['totalmoney']))); } */ else { $this->error('商家尚未开启支付功能', $jumpurl); } } else { $this->error('订单录入系统出错,抱歉给您的带来了不便。请重新下单吧', $jumpurl); } if (!empty($this->wecha_id)) { /* 保存个人信息 */ $userinfo_model = M('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find(); if (empty($thisUser)) { $userRow = array('tel' => $Orderarr['tel'], 'truename' => $Orderarr['name'], 'address' => ''); $userRow['token'] = $this->token; $userRow['wecha_id'] = $this->wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = $Orderarr['sex'] == 1 ? 1 : 2; $userRow['age'] = 0; $userRow['birthday'] = ''; $userRow['info'] = ''; $userRow['total_score'] = 0; $userRow['sign_score'] = 0; $userRow['expend_score'] = 0; $userRow['continuous'] = 0; $userRow['add_expend'] = 0; $userRow['add_expend_time'] = 0; $userRow['live_time'] = 0; $userinfo_model->add($userRow); } } } else { $jumpurl = U('Repast/index', array('token' => $this->token, 'wecha_id' => $this->wecha_id)); $this->error('没有点菜', $jumpurl); } }
public function sms() { if ($_POST["tel"] != "") { $is_tel = M("userinfo")->where(array("token" => $_POST["token"], "tel" => $_POST["tel"], "isverify" => 1))->find(); if ($is_tel == "") { $params = array(); $session_sms = session($_POST["wecha_id"] . "codeSentiment" . $_POST["token"] . $_POST["id"]); if ((time() < $session_sms["time"]) && ($session_sms["tel"] == $_POST["tel"])) { $code = $session_sms["code"]; } else { session($_POST["wecha_id"] . "codeSentiment" . $_POST["token"] . $_POST["id"], NULL); $code = rand(100000, 999999); $session_sms["tel"] = $_POST["tel"]; $session_sms["code"] = $code; $session_sms["time"] = time() + (60 * 30); session($_POST["wecha_id"] . "codeSentiment" . $_POST["token"] . $_POST["id"], $session_sms); } $params["sms"] = array("token" => $this->token, "mobile" => $_POST["tel"], "content" => "您的验证码是:" . $code . "。 此验证码30分钟内有效,请不要把验证码泄露给其他人。如非本人操作,可不用理会!"); $data["error"] = MessageFactory::method($params, "SmsMessage"); $this->ajaxReturn($data, "JSON"); } else { $data["error"] = "tel"; $this->ajaxReturn($data, "JSON"); } } }
/** * 保存订餐人的信息到session */ public function OrderPay() { $disharr = $_POST['dish']; /* * 菜品id 数组*id 份数 */ $shopid = intval($_POST['mycid']); $shopidd = $shopid; //下单时写回自己的分店ID /////自行 $Mcompany = $this->getDishMainCompany(); if (($Mcompany['cid'] != $shopid) && ($Mcompany['dishsame'] == 1)) { $dishofcid = $Mcompany['cid']; /* * *开启分店统一主店 菜品功能** */ $shopid = $dishofcid; } //// $totalmoney = floatval(trim($_POST['totalmoney'])); $totalnum = intval(trim($_POST['totalnum'])); $ouserName = htmlspecialchars(trim($_POST['ouserName']), ENT_QUOTES); $ouserSex = intval(trim($_POST['ouserSex'])); $ouserTel = htmlspecialchars(trim($_POST['ouserTel']), ENT_QUOTES); $ouserAddres = htmlspecialchars(trim($_POST['ouserAddres']), ENT_QUOTES); $oarrivalTime = htmlspecialchars(trim($_POST['oarrivalTime']), ENT_QUOTES); $omark = htmlspecialchars(trim($_POST['omark']), ENT_QUOTES); if ($shopid > 0) { $jumpurl = U('DishOut/dishMenu', array('token' => $this->token, 'cid' => $shopid, 'wecha_id' => $this->wecha_id)); if (empty($disharr) || !($totalmoney > 0) || !($totalnum > 0)) { $this->exitdisplay('订单信息出错!', $jumpurl); } if (empty($ouserName) || empty($ouserTel) || empty($ouserAddres)) { $this->exitdisplay('订单中相关联系地址:姓名或联系电话或送货地址有没写的', $jumpurl); } if (preg_match('/\-\d{2}\s\d{2}\:/', $oarrivalTime)) { /** **如果选择了明日的时间 是带上日期的** */ $oarrivalTime = strtotime($oarrivalTime); } else { $oarrivalTime = $oarrivalTime ? strtotime(date('Y-m-d ') . $oarrivalTime) : 0; } $tmparr = array(); $tmpsubnum = 0; $tmpsubmoney = 0; /**************************************************/ $disharr && $idarr = array_keys($disharr); if ($idarr) { $dishs = M('Dish')->where(array('id' => array('in', $idarr), 'cid' => $shopid, 'isopen' => 1))->select(); foreach ($dishs as $dh) { if (isset($disharr[$dh['id']]['num']) && $disharr[$dh['id']]['num']) { $tmpnum = $disharr[$dh['id']]['num']; $discount = trim($disharr[$dh['id']]['discount']); if ($discount > 0) { $tmpprice = ($discount * $dh['price']) / 10; } else { $tmpprice = $dh['price']; } //$tmpprice = $discount > 0 ? $discount * floatval($dv['price']) / 10 : floatval($dv['price']); $tmparr[$dh['id']] = array(); $tmparr[$dh['id']]['did'] = $dh['id']; $tmparr[$dh['id']]['num'] = $tmpnum; $tmparr[$dh['id']]['discount'] = $discount; $tmparr[$dh['id']]['price'] = $tmpprice; $tmparr[$dh['id']]['name'] = $dh['name']; $tmparr[$dh['id']]['kitchen_id'] = $dh['kitchen_id']; $tmparr[$dh['id']]['omark'] = htmlspecialchars(trim($disharr[$dh['id']]['omark']), ENT_QUOTES); $tmpsubnum += $tmpnum; $tmpsubmoney += ($tmpprice * $tmpnum); } } } /**************************************************/ /*foreach ($disharr as $dk => $dv) { if (!empty($dv)) { $tmpnum = intval($dv['num']); if ($tmpnum > 0) { $tmpprice = floatval($dv['price']); $tmparr[$dk] = array(); $tmparr[$dk]['did'] = $dk; $tmparr[$dk]['num'] = $tmpnum; $tmparr[$dk]['price'] = $tmpprice; $tmparr[$dk]['name'] = $dv['name']; $tmpsubnum+=$tmpnum; $tmpsubmoney+=($tmpprice * $tmpnum); } } }*/ if (empty($tmparr)) { $this->exitdisplay('没有订单信息', $jumpurl); } $tmpsubmoney=number_format($tmpsubmoney,2); $t_tmpsubmoney = (int) ($tmpsubmoney * 10000); $t_totalmoney = (int) ($totalmoney * 10000); if (($tmpsubnum != $totalnum) || ($t_tmpsubmoney != $t_totalmoney)) { $this->error('订单的金额或点的菜的份数不对', $jumpurl); } $outset = $this->outManage($shopid); if (($outset['stype'] == 2) && ($tmpsubmoney < $outset['pricing'])) { $tmpsubmoney = $outset['pricing']; /* * 处理起步价方式订单金额不足起步价按起步价收取* */ } $wecha_id = $this->wecha_id ? $this->wecha_id : 'DishOutm_' . $ouserTel; $orderid = substr($wecha_id, -5) . date("YmdHis"); $Orderarr = array('cid' => $shopidd, 'wecha_id' => $wecha_id, 'token' => $this->token, 'total' => $tmpsubnum, 'price' => $tmpsubmoney, 'nums' => 1, 'info' => serialize($tmparr), 'name' => $ouserName, 'sex' => $ouserSex, 'tel' => $ouserTel, 'address' => $ouserAddres, 'tableid' => 0, 'time' => time(), 'reservetime' => $oarrivalTime, 'stype' => $outset['stype'], 'paid' => 0, 'isuse' => 0, 'orderid' => $orderid, 'printed' => 0, 'des' => $omark, 'takeaway' => 1, 'comefrom' => 'dishout' );//$cid => $shopidd $orid = D('Dish_order')->add($Orderarr); if ($orid) { $_SESSION[$this->session_dish_info] = ''; //TODO 短信提示 $company = $this->getCompany($shopid); Sms::sendSms($this->token, "顾客{$ouserName}刚刚叫了一份外卖,订单号:{$orderid},请您注意查看并处理", $company['mp']); //给商家发站内信 $params = array(); $params['site'] = array('token'=>$this->token, 'from'=>'微外卖消息','content'=>"顾客{$ouserName}刚刚叫了一份外卖,订单号:{$orderid},请您注意查看并处理"); MessageFactory::method($params, 'SiteMessage'); // $printer_set = $this->getPrinter_set($shopid); // if (!empty($printer_set) && ($printer_set['paid'] == 0)) { $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => trim($_POST['omark']), 'companytel' => $company['tel'], 'truename' => trim($_POST['ouserName']), 'tel' => trim($_POST['ouserTel']), 'address' => trim($_POST['ouserAddres']), 'buytime' => $Orderarr['time'], 'orderid' => $Orderarr['orderid'], 'sendtime' => $oarrivalTime > 0 ? $oarrivalTime : '尽快送达', 'price' => $Orderarr['price'], 'total' => $Orderarr['total'], 'typename' => '外卖', 'list' => $tmparr); $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $shopid, 'DishOut', $msg, 0); /*厨房打印菜单*/ if ($kitchens_list = D('Dish_kitchen')->where(array('cid' => $this->_cid))->select()) { $t_list = array(); foreach ($tmparr as $dish) $t_list[$dish['kitchen_id']][] = $dish; $kitchens = array(); foreach ($kitchens_list as $kit_row) $kitchens[$kit_row['id']] = $kit_row; $print_msg = array('des' => trim($_POST['omark']), 'truename' => trim($_POST['ouserName']), 'tel' => trim($_POST['ouserTel']), 'address' => trim($_POST['ouserAddres']), 'buytime' => $Orderarr['time'], 'orderid' => $Orderarr['orderid'], 'sendtime' => $oarrivalTime > 0 ? $oarrivalTime : '尽快送达'); foreach ($t_list as $k => $rowset) { if ($k) { if (isset($kitchens[$k]) && $kitchens[$k]['status']) { for ($i = 0; $i < count($rowset); $i++) { $msg = $print_msg; $msg['list'][] = $rowset[$i]; $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $this->_cid, 'DishOut', $msg, 0, '', $k); } } else { $msg = $print_msg; $msg['list'] = $rowset; $msg = ArrayToStr::array_to_str($msg, 0); $op->printit($this->token, $this->_cid, 'DishOut', $msg, 0, '', $k); } } } } /*厨房打印菜单*/ // } $alipayConfig = M('Alipay_config')->where(array('token' => $this->token))->find(); if ($alipayConfig['open']) { $this->success('正在提交中...', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $wecha_id, 'success' => 1, 'from' => 'DishOut', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $tmpsubmoney))); } /* elseif ($this->fans['balance']) { $this->success('正在提交中...', U('CardPay/pay',array('token' => $this->token, 'wecha_id' => $wecha_id, 'success' => 1, 'from'=> 'DishOut', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $tmpsubmoney))); } */ else { $this->exitdisplay('商家尚未开启支付功能', $jumpurl); } } else { $this->exitdisplay('订单录入系统出错,抱歉给您的带来了不便。请重新下单吧', $jumpurl); } if (!empty($this->wecha_id)) { /* 保存个人信息 */ $userinfo_model = M('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find(); if (empty($thisUser)) { $userRow = array('tel' => $ouserTel, 'truename' => $ouserName, 'address' => $ouserAddres); $userRow['token'] = $this->token; $userRow['wecha_id'] = $this->wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = $ouserSex; $userRow['age'] = 0; $userRow['birthday'] = ''; $userRow['info'] = ''; $userRow['total_score'] = 0; $userRow['sign_score'] = 0; $userRow['expend_score'] = 0; $userRow['continuous'] = 0; $userRow['add_expend'] = 0; $userRow['add_expend_time'] = 0; $userRow['live_time'] = 0; $userinfo_model->add($userRow); } } } else { $jumpurl = U('DishOut/index', array('token' => $this->token, 'wecha_id' => $this->wecha_id)); $this->exitdisplay('订单信息中店面信息出错', $jumpurl); } }
public function orderInfo() { $this->product_model = M('Product'); $this->product_cat_model = M('Product_cat'); $product_cart_model = M('product_cart'); $thisOrder = $product_cart_model->where(array('id' => intval($_GET['id']), 'token' => $this->token))->find(); if (strtolower($thisOrder['token']) != strtolower($this->_session('token'))) { exit(); } if (IS_POST) { if (intval($_POST['sent'])) { $_POST['handled'] = 1; } $company = M('Company')->where(array('token' => $this->token, 'isbranch' => 0))->find(); $save = array('sent' => intval($_POST['sent']), 'logistics' => $_POST['logistics'], 'logisticsid' => $_POST['logisticsid'], 'handled' => 1); if ($company['id'] != $this->_cid) { empty($thisOrder['paid']) && $save['paid'] = intval($_POST['paid']); } else { $save['paid'] = intval($_POST['paid']); } $product_cart_model->where(array('id' => $thisOrder['id']))->save($save); $company = D('Company')->where(array('token' => $thisOrder['token'], 'id' => $thisOrder['cid']))->find(); if ($_POST['sent']) { $userInfo = D('Userinfo')->where(array('token' => $thisOrder['token'], 'wecha_id' => $thisOrder['wecha_id']))->find(); Sms::sendSms($this->token, '您在' . $company['name'] . '商城购买的商品,商家已经给您发货了,请您注意查收', $userInfo['tel']); } $carts = unserialize($thisOrder['info']); $tdata = $this->getCat($carts); if (intval($_POST['paid']) && empty($thisOrder['paid'])) { $list = array(); $info = ''; $pre = ''; foreach ($tdata[0] as $va) { $t = array(); if (!empty($va['detail'])) { foreach ($va['detail'] as $v) { $t = array('num' => $v['count'], 'colorName' => $v['colorName'], 'formatName' => $v['formatName'], 'price' => $v['price'], 'name' => $va['name']); $list[] = $t; } } else { $t = array('num' => $va['count'], 'price' => $va['price'], 'name' => $va['name']); $list[] = $t; } $info .= $pre . $va['name']; $pre = ','; } if (intval($thisOrder['price'])) { $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $thisOrder['truename'], 'tel' => $thisOrder['tel'], 'address' => $thisOrder['address'], 'buytime' => $thisOrder['time'], 'orderid' => $thisOrder['orderid'], 'sendtime' => '', 'price' => $thisOrder['price'], 'total' => $thisOrder['total'], 'list' => $list); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($this->token, $this->_cid, 'Store', $msg, 1); } if ($thisOrder['twid']) { if ($set = M('Twitter_set')->where(array('token' => $this->token, 'cid' => $thisOrder['cid']))->find()) { $price = $set['percent'] * 0.01 * $thisOrder['totalprice']; $info = ($info ? '购买' . $info . '等产品,订单号:' . $thisOrder['orderid'] : '购买订单号:' . $thisOrder['orderid']); D('Twitter_log')->add(array('token' => $this->token, 'cid' => $thisOrder['cid'], 'twid' => $thisOrder['twid'], 'type' => 3, 'dateline' => time(), 'param' => $thisOrder['totalprice'], 'price' => $price, 'wecha_id' => $thisOrder['wecha_id'], 'info' => $info)); if ($count = M('Twitter_count')->where(array('token' => $this->token, 'cid' => $thisOrder['cid'], 'twid' => $thisOrder['twid']))->find()) { D('Twitter_count')->where(array('id' => $count['id']))->setInc('total', $price); } else { D('Twitter_count')->add(array('token' => $this->token, 'cid' => $thisOrder['cid'], 'twid' => $thisOrder['twid'], 'total' => $price, 'remove' => 0)); } $userinfo = D('Userinfo')->where(array('twid' => $thisOrder['twid']))->find(); $messages = $params = array(); if ($userinfo['tel']) { $messages[] = 'SmsMessage'; $params['sms'] = array('token' => $this->token, 'content' => '您分享的商城被您的朋友点击查看,您将从商家哪儿获得' . $price . '元的佣金,请您查看', 'moblie' => $userinfo['tel']); } $messages[] = 'TemplateMessage'; $params['template'] = array(); $params['template']['template_id'] = 'OPENTM201812627'; $params['template']['template_data']['href'] = C('site_url') . '/index.php?g=Wap&m=Store&a=detail&token=' . $this->token . '&wecha_id=' . $userinfo['wecha_id'] . '&twid=' . $userinfo['twid']; $params['template']['template_data']['wecha_id'] = $userinfo['wecha_id']; $params['template']['template_data']['first'] = '您获得了一笔新的佣金'; $params['template']['template_data']['keyword1'] = $price; $params['template']['template_data']['keyword2'] = date('Y年m月d日 H:i'); $params['template']['template_data']['remark'] = '请进入店铺查看详情'; MessageFactory::method($params, $messages); } } } if (intval($_POST['paid']) && empty($thisOrder['paid'])) { foreach ($carts as $k => $c) { $this->product_model->where(array('id' => $k))->setInc('salecount', $tdata[1][$k]['total']); } } $this->success('修改成功', U('Store/orderInfo', array('token' => session('token'), 'id' => $thisOrder['id']))); } else { $product_diningtable_model = M('product_diningtable'); if ($thisOrder['tableid']) { $thisTable = $product_diningtable_model->where(array('id' => $thisOrder['tableid']))->find(); $thisOrder['tableName'] = $thisTable['name']; } $this->assign('thisOrder', $thisOrder); $carts = unserialize($thisOrder['info']); $totalFee = 0; $totalCount = 0; $data = $this->getCat($carts); if (isset($data[1])) { foreach ($data[1] as $pid => $row) { $totalCount += $row['total']; $totalFee += $row['totalPrice']; $listNum[$pid] = $row['total']; } } $list = $data[0]; $this->assign('products', $list); $this->assign('totalFee', $totalFee); $this->assign('totalCount', $totalCount); $this->assign('mailprice', $data[2]); $this->display(); } }
public function index($orderid, $paytype = '', $third_id = ''){ if ($order = M('Product_cart')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $siteurl=$_SERVER['HTTP_HOST']; $siteurl=strtolower($siteurl); if(strpos($siteurl,"http:")===false && strpos($siteurl,"https:")===false) $siteurl='http://'.$siteurl; $siteurl=rtrim($siteurl,'/'); $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $carts = unserialize($order['info']); $tdata = self::getCat($carts, $order['token'], $order['cid'], $userInfo['getcardtime']); $list = array(); $info = ''; $pre = ''; foreach ($tdata[0] as $va) { $t = array(); $salecount = 0; if (!empty($va['detail'])) { foreach ($va['detail'] as $v) { $t = array('num' => $v['count'], 'colorName' => $v['colorName'], 'formatName' => $v['formatName'], 'price' => $v['price'], 'name' => $va['name']); $list[] = $t; $salecount += $v['count']; } } else { $t = array('num' => $va['count'], 'price' => $va['price'], 'name' => $va['name']); $list[] = $t; $salecount = $va['count']; } $info .= $pre . $va['name']; $pre = ','; D("Product")->where(array('id' => $va['id']))->setInc('salecount', $salecount); } if ($order['twid']) { if ($set = M("Twitter_set")->where(array('token' => $order['token'], 'cid' => $order['cid']))->find()) { $price = $set['percent'] * 0.01 * $order['totalprice']; $info = $info ? '购买' . $info .'等产品,订单号:' . $orderid : '购买订单号:' . $orderid; D("Twitter_log")->add(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid'], 'type' => 3, 'dateline' => time(), 'param' => $order['totalprice'], 'price' => $price, 'wecha_id' => $order['wecha_id'], 'info' => $info)); if ($count = M("Twitter_count")->where(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid']))->find()) { D("Twitter_count")->where(array('id' => $count['id']))->setInc('total', $price); } else { D("Twitter_count")->add(array('token' => $order['token'], 'cid' => $order['cid'], 'twid' => $order['twid'], 'total' => $price, 'remove' => 0)); } //获取佣金时候消息提醒获得者 $usinfo = D('Userinfo')->where(array('twid' => $order['twid']))->find(); $messages = $params = array(); if ($usinfo['tel']) { $messages[] = 'SmsMessage'; $params['sms'] = array('token' => $order['token'], 'content' => '您分享的商城被您的朋友点击查看,您将从商家哪儿获得' . $price . '元的佣金,请您查看', 'moblie' => $usinfo['tel']); } $messages[] = 'TemplateMessage'; $params['template'] = array(); $params['template']['template_id'] = 'OPENTM201812627'; $params['template']['template_data']['href'] = $siteurl .'/index.php?g=Wap&m=Store&a=detail&token=' . $order['token'] . '&wecha_id=' . $usinfo['wecha_id'] . '&twid=' . $order['twid']; $params['template']['template_data']['wecha_id'] = $usinfo['wecha_id']; $params['template']['template_data']['first'] = '您获得了一笔新的佣金'; $params['template']['template_data']['keyword1'] = $price; $params['template']['template_data']['keyword2'] = date("Y年m月d日 H:i"); $params['template']['template_data']['remark'] = '请进入店铺查看详情'; MessageFactory::method($params, $messages); } } $company = D('Company')->where(array('token' => $order['token'], 'id' => $order['cid']))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $order['truename'], 'tel' => $order['tel'], 'address' => $order['address'], 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => '', 'price' => $order['price'], 'total' => $order['total'], 'list' => $list); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($order['token'], $order['cid'], 'Store', $msg, 1); Sms::sendSms($order['token'], "您的顾客{$userInfo['truename']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理",$company['mp']);//自行增加 $model = new templateNews(); $href = $siteurl .'/index.php?g=Wap&m=Store&a=my&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'] . '&twid=' . $order['twid']; $model->sendTempMsg('OPENTM202521011', array('href' => $href, 'wecha_id' => $order['wecha_id'], 'first' => '购买商品提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '购买成功,感谢您的光临,欢迎下次再次光临!')); $params['token'] = $this->token; $params['wecha_id'] = $this->wecha_id; $messageUrl = $siteurl .'/index.php?g=User&m=Store&a=orderInfo&dining=0&token='.$order['token'].'&id='.$order['id']; $params['content'] = '您的商城里有新的订单,请注意查看。订单号:'.$order['orderid'].'。'; $params['site'] = array('content'=>$params['content'].' <a href="'.$messageUrl.'">点我击查看订单详情</a>'); $return = MessageFactory::method($params, array('SiteMessage')); } header('Location:/index.php?g=Wap&m=Store&a=my&token='.$order['token'].'&wecha_id='.$order['wecha_id'] . '&twid='.$order['twid']); }else{ exit('订单不存在:'.$out_trade_no); exit('订单不存在'); } }
/** * The template loader. It load template associated to the message * * @access public * @param boolean $reload true to force newsletter info reloading * @return The loaded template * @since 1.0 * @see MessageFactory */ function loadTemplate($reload = false) { if (is_null($this->_template) || $reload) { $minstance = MessageFactory::getInstance(); $this->_template = $minstance->loadTemplate($this->get('tem_id')); if (!$this->_template) { $this->_template = null; } } return $this->_template; }
public function SmsSend() { $mobile = $this->_post("mobile"); if (empty($mobile)) { exit("手机号不能为空"); } $_SESSION["coin_rand_num"][$mobile] = ""; $_SESSION["coin_send_time"][$mobile] = ""; $rand_num = rand(100000, 999999); $_SESSION["coin_rand_num"][$mobile] = $rand_num; $_SESSION["coin_send_time"][$mobile] = $_SERVER["REQUEST_TIME"]; $params = array(); $params["sms"] = array("token" => $this->token, "mobile" => $mobile, "content" => "您的验证码是:" . $rand_num . "。 此验证码30分钟内有效,请不要把验证码泄露给其他人。如非本人操作,可不用理会!"); $return_status = MessageFactory::method($params, "SmsMessage"); if (($return_status == 0) && (strlen($return_status) == 1)) { exit("done"); } else if ($return_status == NULL) { exit("not_buy"); } else { exit("短信发送失败,请稍后再试"); } }
public function setParams($params) { $this->_params = MessageFactory::mergeParams($params, $params[self::TYPE], array('token', 'wecha_id', 'content')); }
public function index($orderid, $paytype, $third_id) { $product_cart_model = M('product_cart'); $out_trade_no = $orderid; $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find(); if (!$this->wecha_id) { $this->wecha_id = $order['wecha_id']; } $sepOrder = 0; if (!$order) { $order = $product_cart_model->where(array('id' => $out_trade_no))->find(); $sepOrder = 1; } if ($order) { if ($order['paid'] != 1) { exit('该订单还未支付'); } if (!empty($order['sn']) && empty($order['sn_content'])) { $where['sendstutas'] = 0; $where['order_id'] = 0; $where['token'] = $order['token']; $where['pid'] = $order['productid']; $productSn = M('ProductSn'); $models = $productSn->where($where)->limit($order['total'])->order('id ASC')->select(); foreach ($models as $key => $model) { $model['order_id'] = $order['id']; $model['sendstutas'] = 1; $model['sendtime'] = time(); $model['wecha_id'] = $order['wecha_id']; $updateWhere['id'] = $model['id']; $updateWhere['sendstutas'] = 0; unset($model['id']); $productSn->where($updateWhere)->save($model); $models[$key] = $model; $flag = 1; } $order['sent'] = 1; $order['handled'] = 1; $order['sn_content'] = serialize($models); $product_cart_model->save($order); } else { M('Product')->where(array('id' => $order['productid']))->setDec('groupon_num', $order['total']); } $params['token'] = $order['token']; $params['wecha_id'] = $order['wecha_id']; $messageUrl = C('site_url') . '/index.php?g=User&m=Product&a=orderInfo&type=groupon&token=' . $order['token'] . '&id=' . $order['id']; $params['content'] = '您的微信里有团购订单已经付款,请注意查看。订单号:' . $order['orderid'] . '。'; $params['site'] = array('content' => $params['content'] . ' <a href="' . $messageUrl . '">点我击查看订单详情</a>'); $template_data = array('href' => C('site_url') . '/index.php?g=Wap&m=Groupon&a=myOrders&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'], 'first' => '您好,你已经支付成功。', 'keyword1' => $order['price'], 'keyword2' => '团购 - ' . M('Product')->where(array('id' => $order['productid']))->getField('name'), 'keyword3' => getPayType($order['paytype']), 'keyword4' => $order['orderid'], 'keyword5' => date('Y-m-d H:i:s'), 'remark' => '团购'); $params['template'] = array('template_id' => 'OPENTM202183094', 'template_data' => $template_data); $params['sms'] = array('mobile' => M('Company')->where(array('token' => $order['token'], 'isbranch' => '0'))->getField('mp')); $return = MessageFactory::method($params, array('SmsMessage', 'TemplateMessage')); $flagContent = ($flag ? '已经发货,' : '正在准备发货,'); $params['sms'] = array('content' => '亲爱的 ' . $order['truename'] . ',您购买的商品 已经付款成功,金额为' . $order['price'] . ',订单号为' . $order['orderid'] . ',感谢您惠顾!', 'mobile' => $order['tel']); MessageFactory::method($params, array('SmsMessage')); header('Location:/index.php?g=Wap&m=Groupon&a=myOrders&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id']); } else { exit('订单不存在:' . $out_trade_no); } }
/** * Play the process. It execute the next process step sending the message * to the next subscriber(s) * * @param string $client_id Client identifier * @return false if something wrong * @since 0.7 */ function play($client_id = '', $restart = false, $continue_on_error = false) { jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); jincimport('utility.servicelocator'); $servicelocator = ServiceLocator::getInstance(); $logger = $servicelocator->getLogger(); $dbo = JFactory::getDBO(); if ($this->status == PROCESS_STATUS_RUNNING && $this->client_id != $client_id) { $this->setError('COM_JINC_ERR042'); return false; } $start_time = 0; if ($this->status != PROCESS_STATUS_RUNNING) { if ($this->client_id == '') { $start_time = time(); $this->start_time = $start_time; } if ($this->status == PROCESS_STATUS_STOPPED) { $start_time = time(); $this->start_time = $start_time; $this->last_subscriber_time = 0; $this->last_update_time = 0; $this->sent_messages = 0; $this->sent_success = 0; } if ($this->client_id != $client_id) { if (!$this->updateStatus(PROCESS_STATUS_RUNNING, $client_id)) { return false; } } } $msg_id = $this->msg_id; $minstance = MessageFactory::getInstance(); if ($message = $minstance->loadMessage($msg_id)) { if ($newsletter = $message->loadNewsletter()) { $this->tot_recipients = $newsletter->countSubscribers(); if ($this->tot_recipients < 0) { $this->setError('COM_JINC_ERR007'); return false; } } else { $this->setError('COM_JINC_ERR001'); return false; } } else { $this->setError('COM_JINC_ERR035'); return false; } $logger->finer('Sending process: ' . $this->last_subscriber_time . ' - ' . $this->last_subscriber_id); $news_id = $newsletter->get('id'); if ($send_result = $message->send($this->last_subscriber_time, $this->last_subscriber_id, $continue_on_error)) { $this->storeReportData($message->reported_recipients); $last_time = $send_result['last_time']; $last_id = $send_result['last_id']; $this->sent_messages = $this->sent_messages + $send_result['nmessages']; $this->sent_success = $this->sent_success + $send_result['nsuccess']; if ($send_result['nmessages'] == 0) { $this->updateStatus(PROCESS_STATUS_FINISHED); $logger->finer('Process: triggering message sent event'); $dispatcher = JDispatcher::getInstance(); $params = array('news_id' => $news_id, 'msg_id' => $msg_id); $result = $dispatcher->trigger('jinc_sent', $params); } $query = 'UPDATE #__jinc_process ' . 'SET last_subscriber_time = FROM_UNIXTIME(' . $last_time . '), ' . 'last_update_time = NOW(), ' . 'last_subscriber_id = ' . $last_id . ', ' . 'sent_success = ' . $this->sent_success . ', ' . 'sent_messages = ' . $this->sent_messages . ' '; if ($start_time > 0) { $query .= ', start_time = FROM_UNIXTIME(' . $start_time . ') '; } $query .= 'WHERE id = ' . $this->id; $dbo->setQuery($query); $logger->debug('Process: executing query: ' . $query); if (!$dbo->query()) { $this->setError('COM_JINC_ERR039'); return false; } if (!$this->reloadStatus()) { $this->setError('COM_JINC_ERR039'); return false; } $this->last_subscriber_time = $last_time; $this->last_subscriber_id = $last_id; $this->mail_system_error = $message->get('mail_system_error'); } else { $this->storeReportData($message->reported_recipients); $logger->finer('StandardProcess: Error sending messages.'); if (!$this->updateStatus(PROCESS_STATUS_PAUSED)) { $this->setError('COM_JINC_ERR040'); } $this->setError($message->getError()); $this->mail_system_error = $message->get('mail_system_error'); return false; } return true; }
function postSave() { //Save message here after we have the request_id. //if ( $this->isNew() == TRUE ) { if ($this->getMessage() !== FALSE) { $mf = new MessageFactory(); $mf->setObjectType(50); //Request $mf->setObject($this->getID()); $mf->setParent(0); $mf->setPriority(); $mf->setStatus('UNREAD'); $mf->setBody($this->getMessage()); if ($mf->isValid()) { return $mf->Save(); } } return TRUE; }