public function index($orderid, $paytype = '', $third_id = '') { $wecha_id = ''; $token = ''; if ($order = M('dish_order')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 $token = $order['token']; $wecha_id = $order['wecha_id']; //$order['paid']=1; $Dishcompany = M('Dish_company')->where(array('cid' => $order['cid']))->find(); $kconoff = $Dishcompany['kconoff']; if ($order['paid']) { $temp = unserialize($order['info']); $tmparr = array('token' => $token, 'cid' => $order['cid'], 'order_id' => $order['id'], 'paytype' => $order['paytype']); $log_db = M('Dishout_salelog'); if (!empty($temp) && is_array($temp)) { $DishDb = M('Dish'); $mDishSet = ThirdPayDishOut::getDishMainCompany($token); foreach ($temp as $kk => $vv) { $did = isset($vv['did']) ? $vv['did'] : $kk; $dishofcid = $order['cid']; if ($mDishSet['cid'] != $order['cid'] && $mDishSet['dishsame'] == 1) { $dishofcid = $mDishSet['cid']; $kconoff = $mDishSet['kconoff']; } $tmpdish = $DishDb->where(array('id' => $did, 'cid' => $dishofcid))->find(); if ($kconoff && !empty($tmpdish) && $tmpdish['instock'] > 0) { $DishDb->where(array('id' => $did, 'cid' => $dishofcid))->setDec('instock', $vv['num']); } $logarr = array('did' => isset($vv['did']) ? $vv['did'] : $kk, 'nums' => $vv['num'], 'unitprice' => $vv['price'], 'money' => $vv['num'] * $vv['price'], 'dname' => $vv['name'], 'addtime' => $order['time'], 'addtimestr' => date('Y-m-d H:i:s', $order['time']), 'comefrom' => 0); $savelogarr = array_merge($tmparr, $logarr); $log_db->add($savelogarr); } } $company = M('Company')->where(array('token' => $token, 'id' => $order['cid']))->find(); if (empty($company) || !is_array($company)) { header('Location:' . U('DishOut/index', array('token' => $token, 'wecha_id' => $wecha_id))); } Sms::sendSms($token, "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理", $company['mp']); $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' =>U('DishOut/myOrder', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $order['cid']), true, false, true), 'wecha_id' => $wecha_id, 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!'));*/ $model->sendTempMsg('OPENTM202521011', array('href' => $siteurl . '/index.php?g=Wap&m=DishOut&a=myOrder&token=' . $token . '&wecha_id=' . $wecha_id . '&cid=' . $order['cid'], 'wecha_id' => $wecha_id, 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!')); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => htmlspecialchars_decode($order['des'], ENT_QUOTES), 'companytel' => $company['tel'], 'truename' => htmlspecialchars_decode($order['name'], ENT_QUOTES), 'tel' => $order['tel'], 'address' => htmlspecialchars_decode($order['address'], ENT_QUOTES), 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => $order['reservetime'] > 0 ? $order['reservetime'] : '尽快送达', 'price' => $order['price'], 'total' => $order['total'], 'typename' => '外卖', 'ptype' => $order['paytype'], 'list' => $temp); $msg = ArrayToStr::array_to_str($msg, $order['paid']); $op->printit($token, $order['cid'], 'DishOut', $msg, $order['paid']); } header('Location:' . U('DishOut/myOrder', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $order['cid']))); } else { exit('抱歉,订单信息出错'); } }
/** * 支付成功后的回调函数 */ public function payReturn() { $orderid = trim($_GET['orderid']); if (isset($_GET['nohandle'])) { $order = M('dish_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find(); /* $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.U('DishOut/myOrder', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'cid' => $order['cid'])), 'wecha_id' => $order['wecha_id'], 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!')); */ $this->redirect(U('DishOut/myOrder', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'cid' => $order['cid']))); //已经异步处理过了 } else { ThirdPayDishOut::index($orderid); } /* * 原来的代码 先注释 防止有问题 可以随时改回来 if ($order = M('dish_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find()) { //TODO 发货的短信提醒 if ($order['paid'] || $order['paytype'] == 'daofu' || $order['paytype'] == 'dianfu') { $temp = unserialize($order['info']); $tmparr = array('token' => $this->token, 'cid' => $order['cid'], 'order_id' => $order['id'], 'paytype' => $order['paytype']); $log_db = M('Dishout_salelog'); if (!empty($temp) && is_array($temp)) { foreach ($temp as $kk => $vv) { $logarr = array( 'did' => isset($vv['did']) ? $vv['did'] : $kk, 'nums' => $vv['num'], 'unitprice' => $vv['price'], 'money' => $vv['num'] * $vv['price'], 'dname' => $vv['name'], 'addtime' => $order['time'], 'addtimestr' => date('Y-m-d H:i:s', $order['time']),'comefrom'=>0 ); $savelogarr = array_merge($tmparr, $logarr); $log_db->add($savelogarr); } } $company = $this->getCompany($order['cid']); Sms::sendSms($this->token, "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理",$company['mp']); $model = new templateNews(); $model->sendTempMsg('TM00820', array('href' => U('DishOut/myOrder',array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'cid' => $order['cid'])), 'wecha_id' => $this->wecha_id, 'first' => '订餐交易提醒', 'keynote1' => '订单已支付', 'keynote2' => date("Y年m月d日H时i分s秒"), 'remark' => '下单成功,感谢您的光临,欢迎下次再次光临!')); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => htmlspecialchars_decode($order['des'], ENT_QUOTES), 'companytel' => $company['tel'], 'truename' => htmlspecialchars_decode($order['name'], ENT_QUOTES), 'tel' => $order['tel'], 'address' => htmlspecialchars_decode($order['address'], ENT_QUOTES), 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => $order['reservetime'], 'price' => $order['price'], 'total' => $order['total'], 'typename' => '外卖', 'ptype'=>$thisOrder['paytype'],'list' => $temp); $msg = ArrayToStr::array_to_str($msg, $order['paid']); $op->printit($this->token, $order['cid'], 'DishOut', $msg, $order['paid']); } $this->redirect(U('DishOut/myOrder', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'cid' => $order['cid']))); } else { $jumpurl = U('DishOut/index', array('token' => $this->token, 'wecha_id' => $this->wecha_id)); $this->exitdisplay('订单信息中店面信息出错', $jumpurl); } */ }
public function payReturn() { $orderid = trim($_GET['orderid']); if (isset($_GET['nohandle'])) { $order = M('dish_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find(); $this->redirect(U('DishOut/myOrder', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'cid' => $order['cid']))); } else { ThirdPayDishOut::index($orderid); } }
public function payReturn() { $orderid = trim($_GET['orderid']); if (isset($_GET['nohandle'])) { $order = M('dish_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find(); $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 . U('DishOut/myOrder', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'cid' => $order['cid'])), 'wecha_id' => $order['wecha_id'], 'first' => '外卖订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date('Y年m月d日H时i分s秒'), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!')); $this->redirect(U('DishOut/myOrder', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'cid' => $order['cid']))); } else { ThirdPayDishOut::index($orderid); } }