public function method() { if (!empty($this->_params['template_id']) && !empty($this->_params['template_data'])) { $template = new templateNews(); return $template->sendTempMsg(strtoupper($this->_params['template_id']), $this->_params['template_data']); } }
public function doOutOrder() { if ($_GET["unitaryid"] != "") { $where_unitary["id"] = (int) $_GET["unitaryid"]; $where_unitary["token"] = $this->token; $find_unitary = $this->m_unitary->where($where_unitary)->find(); if ($find_unitary["state"] != 2) { $where_lucknum_num["token"] = $this->token; $where_lucknum_num["unitary_id"] = (int) $_GET["unitaryid"]; $pay_count = $this->m_lucknum->where($where_lucknum_num)->count(); if ($find_unitary["price"] <= $pay_count) { $where_lucknum_all["token"] = $this->token; $lucknum_all_count = $this->m_lucknum->where($where_lucknum_all)->count(); if ($lucknum_all_count < 100) { $save_unitary["lastnum"] = $lucknum_all_count; } else { $save_unitary["lastnum"] = 100; } $lucknum_all = $this->m_lucknum->where($where_lucknum_all)->order("addtime desc")->limit($save_unitary["lastnum"])->select(); $save_unitary["lasttime"] = $lucknum_all[0]["id"]; $sum = 0; foreach ($lucknum_all as $avo ) { $thistime = floor($avo["addtime"] / 1000); $ms = substr($avo["addtime"], -3); $sum = $sum + (date("h", $thistime) . date("i", $thistime) . date("s", $thistime) . $ms); } $lucknum = fmod($sum, $find_unitary["price"]); $save_unitary["lucknum"] = $lucknum; $save_unitary["state"] = 2; $save_unitary["endtime"] = time() + $find_unitary["opentime"]; $where_cart3["state"] = 0; $where_cart3["token"] = $this->token; $where_cart3["unitary_id"] = (int) $_GET["unitaryid"]; $del_cart3 = $this->m_cart->where($where_cart3)->delete(); $save_unitary["proportion"] = 100; $update_unitary = $this->m_unitary->where($where_unitary)->save($save_unitary); $where_lucknum2["unitary_id"] = (int) $_GET["unitaryid"]; $where_lucknum2["token"] = $this->token; $where_lucknum2["lucknum"] = $lucknum; $where_lucknum2["state"] = 0; $save_lucknum2["state"] = 1; $update_lucknum2 = $this->m_lucknum->where($where_lucknum2)->save($save_lucknum2); $where_lucknum2["state"] = 1; $find_lucknum2 = $this->m_lucknum->where($where_lucknum2)->find(); require_once "./PigCms/Lib/ORG/templateNews.class.php"; $model = new templateNews(); $model->sendTempMsg("TM00695", array("href" => $this->siteUrl . U("Wap/Unitary/goodswhere", array("token" => $this->token, "unitaryid" => (int) $_GET["unitaryid"])), "wecha_id" => $find_lucknum2["wecha_id"], "title" => "一元夺宝中奖通知", "headinfo" => "恭喜您在一元夺宝中获得【" . $find_unitary["name"] . "】点击查看", "program" => $find_unitary["name"], "result" => date("Y年m月d日H时i分s秒"), "remark" => "")); } } } }
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 index($orderid, $paytype = '', $third_id = '') { if ($order = M('Product_cart')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $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)); } } } $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); $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); Sms::sendSms($order['token'], "您的顾客{$userInfo['truename']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $model = new templateNews(); $model->sendTempMsg('OPENTM202521011', array('href' => U('Store/my', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'twid' => $order['twid']), true, false, true), 'wecha_id' => $order['wecha_id'], 'first' => '购买商品提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '购买成功,感谢您的光临,欢迎下次再次光临!')); } 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('订单不存在'); } }
public function index() { if (IS_POST) { $data = array(); $data['tempkey'] = $_REQUEST['tempkey']; $data['name'] = $_REQUEST['name']; $data['content'] = $_REQUEST['content']; $data['topcolor'] = $_REQUEST['topcolor']; $data['textcolor'] = $_REQUEST['textcolor']; $data['status'] = $_REQUEST['status']; $data['tempid'] = $_REQUEST['tempid']; foreach ($data as $key => $val) { foreach ($val as $k => $v) { $info[$k][$key] = $v; } } foreach ($info as $kk => $vv) { if ($vv['tempid'] == '') { $info[$kk]['status'] = 0; } $info[$kk]['token'] = session('token'); $where = array('token' => session('token'), 'tempkey' => $info[$kk]['tempkey']); if (M('Tempmsg')->where($where)->getField('id')) { M('Tempmsg')->where($where)->save($info[$kk]); } else { M('Tempmsg')->add($info[$kk]); } } $this->success('操作成功'); } else { $model = new templateNews(); $templs = $model->templates(); $list = M('Tempmsg')->where(array('token' => session('token')))->select(); $keys = array_keys($list); $i = count($list); $j = 0; foreach ($templs as $k => $v) { $dbtempls = M('Tempmsg')->where(array('token' => session('token'), 'tempkey' => $k))->find(); if ($dbtempls == '') { $list[$i]['tempkey'] = $k; $list[$i]['name'] = $v['name']; $list[$i]['content'] = $v['content']; $list[$i]['topcolor'] = '#029700'; $list[$i]['textcolor'] = '#000000'; $list[$i]['status'] = 0; $i++; } else { $list[$j]['name'] = $v['name']; $list[$j]['content'] = $v['content']; $j++; } } $this->assign('list', $list); $this->display(); } }
public function api_msg() { if ($_POST["type"] == 3) { $now_user = D("User")->get_user($_POST["wecha_id"]); if ($now_user && !empty($now_user["openid"])) { $model = new templateNews(C("config.wechat_appid"), C("config.wechat_appsecret")); $model->sendTempMsg("OPENTM202521011", array("href" => $_POST["href"], "wecha_id" => $now_user["openid"], "first" => "尊敬的用户您好,您的订单已完成。", "keyword1" => $_POST["order_detail"]["order_no"], "keyword2" => date("m月d日,H:i", $_POST["order_detail"]["complate_time"]), "remark" => "如有任何疑问,请您及时联系商家")); } } }
public function index($orderid, $paytype = '', $third_id = '') { $where = array('orderid' => $orderid); $order = M('Member_card_pay_record')->where($where)->find(); if ($order) { $wecha_id = $order['wecha_id']; $token = $order['token']; if ($order['paid'] == 1) { M('Member_card_pay_record')->where($where)->setField('paytime', time()); if ($order['type'] == 1) { M('Userinfo')->where("wecha_id = '{$wecha_id}' AND token = '{$token}'")->setInc('balance', self::_calculate($order['price'], $token, $order['cardid'])); } else { $lastid = M('Member_card_use_record')->where(array('token' => $token, 'wecha_id' => $wecha_id))->order('id DESC')->getField('id'); if ($this->_get('type') == 'coupon') { M('Member_card_coupon')->where(array('token' => $token, 'id' => (int) $this->_get('itemid')))->setInc('usetime', (int) $this->_get('usecount')); M('Member_card_use_record')->where(array('token' => $token, 'id' => $lastid))->setField(array('usecount' => (int) $this->_get('usecount'), 'cat' => 6)); } elseif ($this->_get('type') == 'privelege') { M('Member_card_vip')->where(array('token' => $token, 'id' => (int) $this->_get('itemid')))->setInc('usetime'); M('Member_card_use_record')->where(array('token' => $token, 'id' => $lastid))->setField('cat', 4); } } /* if(empty($act)){ header('Location:'.U('Card/card',array('token'=>$token,'wecha_id'=>$wecha_id,'cardid'=>$order['cardid']))); }else{ header('Location:'.U('Card/'.$act,array('token'=>$token,'wecha_id'=>$wecha_id,'cardid'=>$order['cardid']))); } */ $info = M('Member_card_set')->where(array('token' => $token, 'cardid' => $order['cardid']))->find(); $cardinfo = M('Member_card_create')->where(array('token' => $token, 'cardid' => $order['cardid'], 'wecha_id' => $wecha_id))->find(); $href = $this->siteUrl . '/index.php?' . http_build_query(array('g' => 'Wap', 'm' => 'Card', 'a' => 'card', 'token' => $token, 'wecha_id' => $wecha_id, 'cardid' => $order['cardid'])); //模板消息 $model = new templateNews(); if ('CardPay' == $_GET['paytype']) { // 消费 $dataKey = 'OPENTM202183094'; $dataArr = array('href' => $href, 'wecha_id' => $wecha_id, 'first' => '您好,你已经支付成功。', 'keyword1' => $order['price'], 'keyword2' => '会员卡消费', 'keyword3' => '会员卡支付', 'keyword4' => $orderid, 'keyword5' => date('Y-m-d H:i:s'), 'remark' => '会员卡消费'); } else { $dataKey = 'TM00009'; $dataArr = array('href' => $href, 'wecha_id' => $wecha_id, 'first' => '您好,你已经成功充值。', 'accountType' => $info['cardname'], 'account' => $cardinfo['number'], 'amount' => $order['price'], 'result' => '充值成功', 'remark' => '会员充值'); } $model->sendTempMsg($dataKey, $dataArr); header('Location:' . U('Card/card', array('token' => $token, 'wecha_id' => $wecha_id, 'cardid' => $order['cardid']))); } else { exit('支付未完成'); } } else { exit('订单不存在'); } }
public function index($orderid, $paytype = '', $third_id = ''){ if ($order = M('Hotels_order')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $sort = M('Hotels_house_sort')->where(array('id' => $order['sid'], 'token' => $order['token']))->find(); $days = (strtotime($order['enddate']) - strtotime($order['startdate'])) / 86400; $price = $userInfo['getcardtime'] > 0 ? ($sort['vprice'] ? $sort['vprice'] : $sort['price']) : $sort['price']; $company = M('Company')->where(array('id' => $order['cid'], 'token' => $order['token']))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $order['name'], 'tel' => $order['tel'], 'address' => '', 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => '', 'price' => $order['price'], 'total' => $order['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $order['nums'], 'startdate' => $order['startdate'], 'enddate' => $order['enddate']))); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($order['token'], $order['cid'], 'Hotel', $msg, 1); Sms::sendSms($order['token'] . "_" . $order['cid'], "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $model = new templateNews(); $href = C('site_url').'/index.php?g=Wap&m=Hotels&a=my&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'] . '&cid=' . $order['cid']; $model->sendTempMsg('OPENTM202521011', array('href' => $href, 'wecha_id' => $order['wecha_id'], 'first' => '预订房间提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); } header('Location:/index.php?g=Wap&m=Hotels&a=my&token='.$order['token'].'&wecha_id='.$order['wecha_id'].'&cid='.$order['cid']); // $this->redirect(U('Hotels/my', array('token'=>$this->token, 'wecha_id' => $this->wecha_id))); }else{ exit('订单不存在'); } // $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('该订单还未支付');} // /************************************************/ // Sms::sendSms($this->token,'您的微信里有团购订单已经付款'); // /************************************************/ // header('Location:/index.php?g=Wap&m=Groupon&a=myOrders&token='.$order['token'].'&wecha_id='.$order['wecha_id']); // }else{ // exit('订单不存在:'.$out_trade_no); // } }
public function index($orderid, $paytype = '', $third_id = '') { $where = array('orderid' => $orderid); $order = M('Member_card_pay_record')->where($where)->find(); if ($order) { $wecha_id = $order['wecha_id']; $token = $order['token']; if ($order['paid'] == 1) { M('Member_card_pay_record')->where($where)->setField('paytime', time()); if ($order['type'] == 1) { M('Userinfo')->where("wecha_id = '{$wecha_id}' AND token = '{$token}'")->setInc('balance', $order['price']); } else { $lastid = M('Member_card_use_record')->where(array('token' => $token, 'wecha_id' => $wecha_id))->order('id DESC')->getField('id'); if ($this->_get('type') == 'coupon') { M('Member_card_coupon')->where(array('token' => $token, 'id' => (int) $this->_get('itemid')))->setInc('usetime', (int) $this->_get('usecount')); M('Member_card_use_record')->where(array('token' => $token, 'id' => $lastid))->setField(array('usecount' => (int) $this->_get('usecount'), 'cat' => 6)); } elseif ($this->_get('type') == 'privelege') { M('Member_card_vip')->where(array('token' => $token, 'id' => (int) $this->_get('itemid')))->setInc('usetime'); M('Member_card_use_record')->where(array('token' => $token, 'id' => $lastid))->setField('cat', 4); } } if (empty($act)) { header('Location:' . U('Card/card', array('token' => $token, 'wecha_id' => $wecha_id, 'cardid' => $order['cardid']))); } else { header('Location:' . U('Card/' . $act, array('token' => $token, 'wecha_id' => $wecha_id, 'cardid' => $order['cardid']))); } $info = M('Member_card_set')->where(array('token' => $token, 'cardid' => $order['cardid']))->find(); $cardinfo = M('Member_card_create')->where(array('token' => $token, 'cardid' => $order['cardid'], 'wecha_id' => $wecha_id))->find(); $href = $this->siteUrl . U('Card/card', array('token' => $token, 'wecha_id' => $wecha_id, 'cardid' => $order['cardid'])); //模板消息 $model = new templateNews(); $dataKey = 'TM00009'; $dataArr = array('href' => $href, 'wecha_id' => $wecha_id, 'first' => '您好,你已经成功充值。', 'accountType' => $info['cardname'], 'account' => $cardinfo['number'], 'amount' => $order['price'], 'result' => '充值成功', 'remark' => '会员充值'); $model->sendTempMsg($dataKey, $dataArr); } else { exit('支付未完成'); } } else { exit('订单不存在'); } }
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); } }
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(); $model->sendTempMsg('OPENTM202521011', array('href' => $this->siteUrl . U('Seckill/my_cart', array('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' => '订单完成!')); //给商户发短信 //Sms::sendSms($token, "顾客{$order['true_name']}刚刚对订单号:{$order_id}的订单进行了支付,请您注意查看并处理"); //M('seckill_book')->where(array('orderid'=>$order_id))->save($data); 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); } }
public function index() { $data['app_id'] = $_POST['app_id']; $data['from_openid'] = $_POST['from_openid']; $data['from_nickname'] = $_POST['from_nickname']; $data['from_avatar'] = $_POST['from_avatar']; $data['to_openid'] = $_POST['to_openid']; $data['msg'] = $_POST['msg']; $data['time'] = $_POST['time']; $data['url'] = htmlspecialchars_decode($_POST['url']); $post_key = $_POST['key']; $create_key = $this->get_im_encrypt_key($data, $this->config['im_appkey']); if ($post_key == $create_key) { $model = new templateNews($this->config['wechat_appid'], $this->config['wechat_appsecret']); $model->sendTempMsg('TM00356', array('href' => $data['url'], 'wecha_id' => $data['to_openid'], 'first' => '您的好友“' . $data['from_nickname'] . '”给您发来了一条新消息!', 'work' => '请点击查看', 'remark' => '')); echo 'success'; } else { $html = ''; foreach ($data as $key => $value) { $html .= $key . '=>' . $value; } echo 'error'; } }
/** * 提交订单 */ public function saveorder() { $dataBase = D('Hotels_order'); if (IS_POST) { $price = 0; if ($sort = M('Hotels_house_sort')->where(array('cid' => $this->_cid, 'token' => $this->token, 'id' => $_POST['sid']))->find()) { if ($this->fans['getcardtime'] > 0) { $price = $sort['vprice'] ? $sort['vprice'] : $sort['price']; } else { $price = $sort['price']; } } $days = (strtotime($_POST['enddate']) - strtotime($_POST['startdate'])) / 86400; $sday = date("Y年m月d日", strtotime($_POST['startdate'])); $eday = date("Y年m月d日", strtotime($_POST['enddate'])); if ($_POST['startdate'] < date("Ymd") || $days < 1) { $this->error('您预定的时间不正确'); } //处理预定房间的数量 $in = date("Ymd", strtotime($_POST['startdate'])); $etime = strtotime($_POST['enddate']); $hotelSort = M("Hotels_house_sort")->where(array('id' => $_POST['sid'], 'token' => $this->token))->find(); $time = strtotime($_POST['startdate']); for (; $time < $etime;) { $order = M('Hotels_order')->field('sum(nums) as num')->where(array('startdate' => array('ELT', date('Ymd', $time)), 'enddate' => array('GT', date('Ymd', $time)), 'token' => $this->token, 'cid' => $this->_cid, 'sid' => $_POST['sid'], 'status' => array('ELT', 1)))->find(); $oldnum = isset($order['num']) ? $order['num'] : 0; $total = $_POST['nums'] + $oldnum; if ($total > $hotelSort['houses']) { $this->error('您预定的房间数在' . date('Y年m月d日', strtotime($time)) . '超出总房间数了,请重新预定'); } else { $time += 86400; } } $_POST['orderid'] = $orderid = substr($this->wecha_id, -1, 4) . date("YmdHis"); $_POST['price'] = $_POST['nums'] * $days * $price; $_POST['time'] = time(); //保存个人信息 $userinfo_model = M('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find(); if (empty($thisUser)) { $userRow = array('tel' => $_POST['tel'], 'truename' => $_POST['name'], 'address' => ''); $userRow['token'] = $this->token; $userRow['wecha_id'] = $this->wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = -1; $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); } if ($dataBase->create() !== false) { $action = $dataBase->add(); if ($action != false) { $info = M('deliemail')->where(array('token' => $_POST['token']))->find(); $mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $emailstatus = $info['jdbg']; $emailreceive = $info['receive']; $content = $this->sms(); if ($info['type'] == 1) { $emailsmtpserver = $info['smtpserver']; $emailport = $info['port']; $emailsend = $info['name']; $emailpassword = $info['password']; } else { $emailsmtpserver = C('email_server'); $emailport = C('email_port'); $emailsend = C('email_user'); $emailpassword = C('email_pwd'); } $emailuser = explode('@', $emailsend); $emailuser = $emailuser[0]; if ($emailstatus == 1) { if ($content) { date_default_timezone_set('PRC'); require "class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "{$emailsmtpserver}"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $mail->From = $emailsend; $mail->FromName = C('site_name'); $mail->AddAddress("{$emailreceive}", "商户"); //$mail->AddAddress("*****@*****.**"); // name is optional $mail->AddReplyTo($emailsend, "Information"); $mail->WordWrap = 50; // set word wrap to 50 characters //$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(false); // set email format to HTML $mail->Subject = '您有新的房间订单产生'; $mail->Body = $content; $mail->AltBody = ""; if (!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } //echo "Message has been sent"; } } $company = M('Company')->where(array('id' => $this->_cid, 'token' => $this->token))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $_POST['name'], 'tel' => $_POST['tel'], 'address' => '', 'buytime' => time(), 'orderid' => $_POST['orderid'], 'sendtime' => '', 'price' => $_POST['price'], 'total' => $_POST['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $_POST['nums'], 'startdate' => $_POST['startdate'], 'enddate' => $_POST['enddate']))); $msg = ArrayToStr::array_to_str($msg); $op->printit($this->token, $this->_cid, 'Hotel', $msg, 0); Sms::sendSms($this->token . "_" . $this->_cid, "顾客{$_POST['name']}刚刚预定了{$sday}到{$eday},{$days}天的{$sort['name']},请您注意查看并处理"); // $alipayConfig = M('Alipay_config')->where(array('token' => $this->token))->find(); // if ($_POST['paymode'] == 1 && $alipayConfig['open']) { // $this->success('正在提交中...', U('Alipay/pay',array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from'=> 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); // } elseif ($_POST['paymode'] == 4 && $this->fans['balance']) { // $this->success('正在提交中...', U('CardPay/pay',array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from'=> 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); // } else { // $model = new templateNews(); // $model->sendTempMsg('TM00820', array('href' => U('Hotels/my',array('token' => $this->token, 'wecha_id' => $this->wecha_id)), 'wecha_id' => $this->wecha_id, 'first' => '预订房间提醒', 'keynote1' => '订单未支付', 'keynote2' => date("Y年m月d日H时i分s秒"), 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); // $this->success('预定成功,进入您的订单页', U('Hotels/my',array('token' => $this->token, 'wecha_id' => $this->wecha_id))); // } $config = M('Alipay_config')->where(array('token' => $this->token))->find(); $model = new templateNews(); $model->sendTempMsg('TM00184', array('href' => U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id), true, false, true), 'wecha_id' => $this->wecha_id, 'first' => '预订房间提醒', 'ordertape' => date("Y年m月d日H时i分s秒"), 'ordeID' => $orderid, 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); if ($_POST['paymode'] == 4 && $this->fans['balance']) { $this->success('正在提交中...', U('CardPay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from' => 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); } elseif ($config['open']) { $this->success('正在提交中...', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from' => 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); } else { $this->success('预定成功,进入您的订单页', U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id))); } } else { $this->error('操作失败'); } } else { $this->error($dataBase->getError()); } } }
public function ajax() { switch ($_POST['type']) { case 'fahuo': $where_order['token'] = $_POST['token']; $where_order['tp_id'] = $_POST['orderid'] * 1; $save_order['fahuo'] = 1; $save_order['fahuoname'] = $_POST['fahuoname']; $save_order['fahuoid'] = $_POST['fahuoid']; $update_order = $this->m_order->where($where_order)->save($save_order); $order = $this->m_order->where($where_order)->find(); $model = new templateNews(); $model->sendTempMsg('OPENTM200565259', array('href' => $this->siteUrl . U('Cutprice/myorder', array('token' => $this->token)), 'wecha_id' => $order['wecha_id'], 'first' => '您的订单' . $order['orderid'] . '已发货', 'keyword1' => $order['orderid'], 'keyword2' => $order['fahuoname'], 'keyword3' => $order['fahuoid'], 'remark' => date('Y年m月d日H时i分s秒'))); $data['error'] = 0; $this->ajaxReturn($data, 'JSON'); break; } }
public function paifa() { $m_cart = M("unitary_cart"); $m_user = M("unitary_user"); $m_lucknum = M("unitary_lucknum"); $m_unitary = M("unitary"); $where_lucknum['id'] = $_GET['lucknumid']; $where_lucknum['token'] = $this->token; $find_lucknum = $m_lucknum->where($where_lucknum)->find(); $where_unitary['token'] = $this->token; $where_unitary['id'] = $find_lucknum['unitary_id']; $find_unitary = $m_unitary->where($where_unitary)->find(); $model = new templateNews(); if ($find_lucknum['paifa'] == 1) { //$model->sendTempMsg('TM00820', array('href' => U('Unitary/goodswhere',array('token' => $this->token, 'unitaryid' => $find_lucknum['unitary_id'])), 'wecha_id' => $find_lucknum['wecha_id'], 'first' => '一元夺宝奖品发货通知', 'keynote1' => '商家取消发货', 'keynote2' => date("Y年m月d日H时i分s秒"), 'remark' => '您在一元夺宝中获得的【'.$find_unitary['name'].'】被取消发货')); $save_lucknum['paifa'] = 0; } elseif ($find_lucknum['paifa'] == 0) { $model->sendTempMsg('OPENTM200565259', array('href' => $this->siteUrl . U('Unitary/goodswhere', array('token' => $this->token, 'unitaryid' => $find_lucknum['unitary_id'])), 'wecha_id' => $find_lucknum['wecha_id'], 'first' => '一元夺宝奖品发货通知', 'keyword1' => '恭喜您在一元夺宝中获得的【' . $find_unitary['name'] . '】已发货', 'keyword2' => '无', 'keyword3' => '无', 'remark' => date("Y年m月d日H时i分s秒"))); $save_lucknum['paifa'] = 1; } $update_lucknum = $m_lucknum->where($where_lucknum)->save($save_lucknum); if ($update_lucknum > 0) { $this->redirect("Unitary/data", array("token" => $this->token, "unitaryid" => $find_lucknum['unitary_id'])); } }
/** * 支付成功后的回调函数 */ public function payReturn() { $orderid = $_GET['orderid']; if ($order = M('Hotels_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $sort = M('Hotels_house_sort')->where(array('id' => $order['sid'], 'token' => $this->token))->find(); $days = (strtotime($order['enddate']) - strtotime($order['startdate'])) / 86400; $price = $this->fans['getcardtime'] > 0 ? $sort['vprice'] ? $sort['vprice'] : $sort['price'] : $sort['price']; $company = M('Company')->where(array('id' => $order['cid'], 'token' => $this->token))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $order['name'], 'tel' => $order['tel'], 'address' => '', 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'sendtime' => '', 'price' => $order['price'], 'total' => $order['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $order['nums']))); $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($this->token, $this->_cid, 'Hotel', $msg, 1); Sms::sendSms($this->token . "_" . $order['cid'], "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $model = new templateNews(); $model->sendTempMsg('TM00820', array('href' => U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id)), 'wecha_id' => $this->wecha_id, 'first' => '预订房间提醒', 'keynote1' => '订单已支付', 'keynote2' => date("Y年m月d日H时i分s秒"), 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); } $this->redirect(U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id))); } else { exit('订单不存在'); } }
public function index($orderid, $paytype = '', $third_id = '') { if ($order = M('New_product_cart')->where(array('orderid' => $orderid))->find()) { //TODO 发货的短信提醒 if ($order['paid']) { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); if ($order['jingpai'] == 0) { $carts = unserialize($order['info']); $tdata = $this->getCat($carts, $order['token'], $order['cid'], $userInfo['getcardtime']); $list = array(); 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']; } D("New_product")->where(array('id' => $va['id']))->setInc('salecount', $salecount); } } else { //竞拍内容 $order = M('New_product_cart')->where(array('token' => $order['token'], 'cid' => $order['cid'], 'id' => $order['id']))->find(); $orderlist = M('New_product_cart_list')->where(array('token' => $order['token'], 'cid' => $order['cid'], 'cartid' => $order['id']))->find(); if ($order['jingpai'] == 1) { $produtcdb = M("New_product_jingpai"); } else { if ($order['groupon'] == 1) { $produtcdb = M("New_product"); } } $jingpai = $produtcdb->where(array('token' => $order['token'], 'cid' => $order['cid'], 'id' => $orderlist['productid']))->find(); $list = array($orderlist['productid'] => array('num' => '1', 'price' => $jingpai['price'], 'name' => $jingpai['name'])); if ($order['jingpai'] == 1) { $order['note'] = '' . $order['note'] . '(竞拍订单)'; } else { if ($order['groupon'] == 1) { $order['note'] = '' . $order['note'] . '(团购订单)'; //修改团购记录已付款 M('New_product_groupon')->where(array('orderid' => $order['orderid']))->setField('paid', 1); } } } if ($order['twid']) { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $twid = $order['twid']; if ($twid == $userInfo['fromtwid']) { $addtwid = $userInfo['addtwid']; } else { $addtwid = $userInfo['fromtwid']; } } else { $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); $twid = $userInfo['fromtwid']; $addtwid = $userInfo['addtwid']; } //dump($twid); //die; if ($twid && $twid != $userInfo['twid']) { $token = $order['token']; $cid = $order['cid']; $orderid = $order['orderid']; $totalprice = $order['totalprice']; $type = 3; $param = 1; $set = M("New_twitter_set")->where(array('token' => $token, 'cid' => $cid))->find(); if (empty($set)) { return false; } //获取单一产品的1、2级佣金 $yongjinlist = M('New_product_cart_list')->where(array('token' => $token, 'cid' => $cid, 'cartid' => $order['id']))->select(); foreach ($yongjinlist as $key => $row) { $products = M('New_product')->where(array('token' => $this->token, 'cid' => $this->_cid, 'id' => $row['productid']))->find(); if ($products['allow_distribution'] == '1') { //一级佣金 switch ($products['commission_type']) { default: $yongjinlist[$key]['commission'] = $set['percent'] * 0.01 * $products['price'] * $row['total']; break; case 'fixed': $yongjinlist[$key]['commission'] = $products['commission'] * $row['total']; break; case 'float': $products['commission'] = $products['price'] * ($products['commission'] * 0.01) * $row['total']; $yongjinlist[$key]['commission'] = $products['commission']; break; } //二级佣金 switch ($products['addcommission_type']) { default: $yongjinlist[$key]['addcommission'] = $set['addpercent'] * 0.01 * $products['price'] * $row['total']; break; case 'fixed': $yongjinlist[$key]['addcommission'] = $products['addcommission'] * $row['total']; break; case 'float': $products['addcommission'] = $products['price'] * ($products['addcommission'] * 0.01) * $row['total']; $yongjinlist[$key]['addcommission'] = $products['addcommission']; break; } //产品总佣金 $commission += $yongjinlist[$key]['commission']; $addcommission += $yongjinlist[$key]['addcommission']; } else { $yongjinlist[$key]['addcommission'] = '0'; $yongjinlist[$key]['commission'] = '0'; $commission += $yongjinlist[$key]['commission']; $addcommission += $yongjinlist[$key]['addcommission']; } } //佣金判断结束 if ($twid && $token && $cid && $commission != '0' && $addcommission != '0') { $db = D("New_twitter_log"); // 1.点击, 2.注册会员, 3.购买商品 //判断佣金分成 $price = $commission; $addprice = $addcommission; //上级分成记录 if ($type == 3) { //购买商品,上级分成 $db->add(array('token' => $token, 'cid' => $cid, 'twid' => $twid, 'addtwid' => $addtwid, 'orderid' => $orderid, 'type' => 3, 'dateline' => time(), 'param' => $param, 'price' => $price, 'wecha_id' => $order['wecha_id'], 'orderprice' => $order['price'])); //上级的上级参与分成记录 if (!empty($addtwid) && $addtwid != $twid) { $db->add(array('token' => $token, 'cid' => $cid, 'twid' => $addtwid, 'type' => 4, 'orderid' => $orderid, 'dateline' => time(), 'param' => $param, 'price' => $addprice, 'wecha_id' => $order['wecha_id'], 'orderprice' => $order['price'])); } } //统计总收入 if ($count = M("New_twitter_count")->where(array('token' => $token, 'cid' => $cid, 'twid' => $twid))->find()) { D("New_twitter_count")->where(array('id' => $count['id']))->setInc('total', $price); } else { D("New_twitter_count")->add(array('twid' => $twid, 'fromtwid' => $fromtwid, 'token' => $token, 'cid' => $cid, 'total' => $price, 'remove' => 0)); } //上级的上级参与分成记录,统计总收入 if (!empty($addtwid) && $addtwid != $twid) { if ($count = M("New_twitter_count")->where(array('token' => $token, 'cid' => $cid, 'twid' => $addtwid))->find()) { D("New_twitter_count")->where(array('id' => $count['id']))->setInc('total', $addprice); } else { D("New_twitter_count")->add(array('twid' => $addtwid, 'token' => $token, 'cid' => $cid, 'total' => $addprice, 'remove' => 0)); } } //分佣写入结束 //查询分销人的信息,如果没有直接写入 $twiduserinfo = D('Userinfo')->where(array('token' => $order['token'], 'twid' => $twid))->find(); $twiduser = D('New_twitter_userinfo')->where(array('token' => $order['token'], 'twid' => $twid))->find(); if (empty($twiduser)) { $userdata = array('token' => $order['token'], 'cid' => $order['cid'], 'wecha_id' => $twiduserinfo['wecha_id'], 'twid' => $twiduserinfo['twid'], 'truename' => $twiduserinfo['truename'], 'status' => '0', 'dateline' => time()); D("New_twitter_userinfo")->add($userdata); } //查询分销人的上家的上家信息,如果没有直接写入 $addtwiduserinfo = D('Userinfo')->where(array('token' => $order['token'], 'twid' => $addtwid))->find(); $addtwiduser = D('New_twitter_userinfo')->where(array('token' => $order['token'], 'twid' => $addtwid))->find(); if (empty($addtwiduser)) { $adduserdata = array('token' => $order['token'], 'cid' => $order['cid'], 'wecha_id' => $addtwiduserinfo['wecha_id'], 'twid' => $addtwiduserinfo['twid'], 'truename' => $addtwiduserinfo['truename'], 'status' => '0', 'dateline' => time()); D("New_twitter_userinfo")->add($adduserdata); } } //$this->savelog(3, $order['twid'], $order['token'], $order['cid'], $order['totalprice']); } //分佣判断END $userInfo = D('Userinfo')->where(array('token' => $order['token'], 'wecha_id' => $order['wecha_id']))->find(); //获取配置信息 $where = array('token' => $order['token']); $this->thisWxUser = M('Wxuser')->where($where)->find(); $url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->thisWxUser['appid'] . '&secret=' . $this->thisWxUser['appsecret']; $access_token = json_decode($this->curlGet($url_get)); $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token->access_token; //获取用户openID $where = array('token' => $order['token'], 'cid' => $order['cid']); $sendwecha_id = M('New_product_set_reply')->where($where)->field('wecha_id')->find(); //准备发送请求的数据 $data = '{"touser":"******","msgtype":"text", "text":{"content":"您的用户:' . $userInfo['truename'] . '订购了商品,电话:' . $order['tel'] . ',收货地址:' . $order['address'] . ',备注信息:' . $order['note'] . ',订单号:' . $orderid . ',订单金额:' . $order['price'] . '元,已经付款成功!"}}'; $this->postCurl($url, $data); //打印请求 $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'], 'des' => $order['note'], 'ptype' => $order['paytype'], '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(); $model->sendTempMsg('OPENTM202521011', array('href' => U('Storenew/myinfo', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'twid' => $order['twid']), true, false, true), 'wecha_id' => $order['wecha_id'], 'first' => '购买商品提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '购买成功,感谢您的光临,欢迎下次再次光临!')); } header('Location:/index.php?g=Wap&m=Storenew&a=myinfo&token=' . $order['token'] . '&wecha_id=' . $order['wecha_id'] . '&twid=' . $order['twid']); } else { exit('订单不存在:' . $out_trade_no); exit('订单不存在'); } }
public function paifa() { $m_cart = M("unitary_cart"); $m_user = M("unitary_user"); $m_lucknum = M("unitary_lucknum"); $m_unitary = M("unitary"); $where_lucknum["id"] = $_GET["lucknumid"]; $where_lucknum["token"] = $this->token; $find_lucknum = $m_lucknum->where($where_lucknum)->find(); $where_unitary["token"] = $this->token; $where_unitary["id"] = $find_lucknum["unitary_id"]; $find_unitary = $m_unitary->where($where_unitary)->find(); $model = new templateNews(); if ($find_lucknum["paifa"] == 1) { $save_lucknum["paifa"] = 0; } else if ($find_lucknum["paifa"] == 0) { $model->sendTempMsg("OPENTM200565259", array("href" => $this->siteUrl . U("Wap/Unitary/goodswhere", array("token" => $this->token, "unitaryid" => $find_lucknum["unitary_id"])), "wecha_id" => $find_lucknum["wecha_id"], "first" => "一元夺宝奖品发货通知", "keyword1" => "恭喜您在一元夺宝中获得的【" . $find_unitary["name"] . "】已发货", "keyword2" => "无", "keyword3" => "无", "remark" => date("Y年m月d日H时i分s秒"))); $save_lucknum["paifa"] = 1; } $update_lucknum = $m_lucknum->where($where_lucknum)->save($save_lucknum); if (0 < $update_lucknum) { $this->redirect("Unitary/data", array("token" => $this->token, "unitaryid" => $find_lucknum["unitary_id"])); } }
private function _yiyuanduobao($now_activity, $quantity, $record_id) { //此处有三种方法,采用最简单的一种。 //第一种 按上一次的号码累加 //第二种 将号码输入号码池里,然后从号码池里取用户购买的数量出来 //第三种 采用与彩票联合的方式,需要后台计划任务计算开奖时间 $database_extension_yiyuanduobao_record = D('Extension_yiyuanduobao_record'); $last_number = $database_extension_yiyuanduobao_record->where(array('activity_id' => $now_activity['pigcms_id']))->order('`pigcms_id` DESC')->limit(1)->getField('number'); if (empty($last_number)) { $last_number = 1; } else { $last_number++; } $data_all_extension_yiyuanduobao_record = array(); $data_extension_yiyuanduobao_record['record_id'] = $record_id; $data_extension_yiyuanduobao_record['activity_id'] = $now_activity['pigcms_id']; for ($i = 0; $i < $quantity; $i++) { $data_extension_yiyuanduobao_record['number'] = $last_number + $i; array_push($data_all_extension_yiyuanduobao_record, $data_extension_yiyuanduobao_record); } $database_extension_yiyuanduobao_record->addAll($data_all_extension_yiyuanduobao_record); //抽奖 //取50条最新购买记录进行判断抽奖 if ($now_activity['all_count'] - $now_activity['part_count'] > $quantity) { return false; } $database_extension_activity_record = D('Extension_activity_record'); $condition_extension_activity_record['activity_list_id'] = $now_activity['pigcms_id']; $activity_record_list = $database_extension_activity_record->field('`time`,`msec`')->where($condition_extension_activity_record)->order('`pigcms_id` DESC')->limit(50)->select(); $allCount = 0; foreach ($activity_record_list as $value) { $tmp_time = date('His', $value['time']) . $value['msec']; $allCount += $tmp_time; } $lottery_number = fmod($allCount, $now_activity['all_count']); //找到数字对应的行 $now_yiyuan_record = D('Extension_yiyuanduobao_record')->field('`record_id`')->where(array('activity_id' => $now_activity['pigcms_id'], 'number' => $lottery_number))->find(); //找到数字对应的购买列 $now_activity_record = $database_extension_activity_record->field('`pigcms_id`,`uid`,`activity_list_id`')->where(array('pigcms_id' => $now_yiyuan_record['record_id']))->find(); //修改中奖信息 $database_extension_activity_list = D('Extension_activity_list'); $database_extension_activity_list->where(array('pigcms_id' => $now_activity_record['activity_list_id']))->data(array('lottery_id' => $now_activity_record['pigcms_id'], 'lottery_uid' => $now_activity_record['uid'], 'lottery_number' => $lottery_number, 'is_finish' => '1', 'finish_time' => $_SERVER['REQUEST_TIME']))->save(); $lottery_user = D('User')->field('`openid`,`phone`,`nickname`')->where(array('uid' => $now_activity_record['uid']))->find(); //模板消息通知、短信通知 if ($lottery_user['openid']) { $href = $this->config['site_url'] . '/wap.php'; $model = new templateNews($this->config['wechat_appid'], $this->config['wechat_appsecret']); $model->sendTempMsg('TM00785', array('href' => $href, 'wecha_id' => $lottery_user['openid'], 'first' => '恭喜您,您中奖了', 'program' => '一元夺宝【' . $now_activity['name'] . '】', 'result' => '开奖号码:' . $lottery_number, 'remark' => '请及时上线联系商家进行兑奖!')); } //得到商家信息 $now_merchant = D('Merchant')->field('`mer_id`,`phone`')->where(array('mer_id' => $now_activity['mer_id']))->find(); $sms_data = array('mer_id' => $now_merchant['mer_id'], 'store_id' => 0, 'type' => 'activity'); $sms_data['uid'] = $lottery_user['uid']; $sms_data['mobile'] = $lottery_user['phone']; $sms_data['sendto'] = 'user'; $sms_data['content'] = '您参与的一元夺宝[' . $now_activity['name'] . ']中奖了,幸运号码为:' . $lottery_number . ' ,请及时上线联系商家进行兑奖!'; Sms::sendSms($sms_data); $sms_data['uid'] = $lottery_user['uid']; $sms_data['mobile'] = $now_merchant['phone']; $sms_data['sendto'] = 'merchant'; $sms_data['content'] = '您发布的一元夺宝[' . $now_activity['name'] . ']于 ' . date('m-d H时', $_SERVER['REQUEST_TIME']) . ' 出售成功,中奖用户手机号码为:' . $lottery_user['phone'] . ',请及时联系用户领取!'; Sms::sendSms($sms_data); }
public function recharge() { $db = M('Userinfo'); $uid = (int) $_GET['uid']; $cardid = $this->_get('cardid', 'intval'); $uinfo = $db->where(array('token' => $this->token, 'id' => $uid))->field('wechaname,wecha_id,truename,id,balance')->find(); $cardinfo = M('Member_card_set')->where(array('token' => $this->token, 'cardid' => $cardid))->find(); $mycard = M('Member_card_create')->where(array('token' => $this->token, 'cardid' => $cardid, 'wecha_id' => $uinfo['wecha_id']))->find(); if (IS_POST) { if ($db->create() === false) { $this->error($db->getError()); } $id = (int) $_POST['uid']; if ($db->where(array('token' => $this->token, 'id' => $id))->setInc('balance', $_POST['price'])) { $orderid = date('YmdHis', time()) . mt_rand(1000, 9999); M('Member_card_pay_record')->add(array('orderid' => $orderid, 'ordername' => '后台手动充值', 'createtime' => time(), 'token' => $this->token, 'wecha_id' => $uinfo['wecha_id'], 'price' => $_POST['price'], 'type' => 1, 'paid' => 1, 'module' => 'Card', 'paytime' => time(), 'paytype' => 'recharge', 'cardid' => $cardid)); /*模板消息*/ $model = new templateNews(); $dataKey = 'OPENTM201231580'; $dataArr = array('wecha_id' => $uinfo['wecha_id'], 'first' => '您好,你已经成功充值。', 'keyword1' => $cardinfo['cardname'], 'keyword2' => $mycard['number'], 'keyword3' => $_POST['price'], 'keyword4' => time(), 'keyword5' => $uinfo['balance'], 'remark' => '后台手动充值'); $model->sendTempMsg($dataKey, $dataArr); $this->success('充值成功'); } else { $this->error('充值失败,请稍后再试~'); } } else { $this->assign('cardid', $cardid); $this->assign('uinfo', $uinfo); $this->display(); } }
public function index($orderid, $paytype = '', $third_id = '') { $wecha_id = ''; $token = ''; $cid = 0; $dish_order_db = M('dish_order'); if ($order = $dish_order_db->where(array('tmporderid' => $orderid))->find()) { //TODO 发货的短信提醒 $token = $order['token']; $wecha_id = $order['wecha_id']; $cid = $order['cid']; $company = M('Company')->where(array('token' => $token, 'id' => $cid))->find(); $Dishcompany = M('Dish_company')->where(array('cid' => $cid))->find(); $kconoff = $Dishcompany['kconoff']; $orderid = $order['orderid']; if (empty($company) || !is_array($company)) { header('Location:' . U('Repast/myOrders', array('token' => $token, 'wecha_id' => $wecha_id))); } $temp = !empty($order['info']) ? unserialize($order['info']) : array(); $temp = isset($temp['list']) ? $temp['list'] : $temp; //$order['paid'] = 1; if ($order['paid']) { if (!empty($temp) && is_array($temp)) { $log_db = M('Dishout_salelog'); $tmparr = array('token' => $token, 'cid' => $order['cid'], 'order_id' => $order['id'], 'paytype' => $order['paytype']); $DishDb = M('Dish'); $mDishSet = ThirdPayRepast::getDishMainCompany($token); foreach ($temp as $kk => $vv) { $did = isset($vv['did']) ? $vv['did'] : $kk; if ($did > 0) { $flag = isset($vv['flag']) ? $vv['flag'] : ''; $newk = $flag . 'jc' . $did; if (!($order['paycount'] > 0) || $kk == $newk) { $dishofcid = $cid; if ($mDishSet['cid'] != $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' => $did, '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' => 1); $savelogarr = array_merge($tmparr, $logarr); $log_db->add($savelogarr); } } } $dish_order_db->where(array('id' => $order['id'], 'cid' => $order['cid']))->setInc('paycount', 1); } if ($order['takeaway'] == 2 && $order['isover'] == 2) { M('Dining_table')->where(array('id' => $order['tableid'], 'cid' => $order['cid']))->save(array('status' => 0)); } elseif ($order['takeaway'] == 2 && $order['isover'] == 1) { $dish_order_db->where(array('id' => $order['id'], 'cid' => $order['cid']))->save(array('paid' => 0)); } if ((empty($temp) || count($temp) == 1 && isset($temp['table'])) && $temp['total'] == 0) { $temp = false; $order['total'] = 1; $bookTable = $order['price']; } elseif ($order['takeaway'] == 2 && $order['advancepay'] > 0) { $bookTable = false; if ($order['paycount'] == 1) { $realpay = $myorder['price'] - $myorder['havepaid']; } elseif ($order['paycount'] == 0) { $advancepay = $order['advancepay']; } $dish_order_db->where(array('id' => $order['id'], 'cid' => $order['cid']))->save(array('havepaid' => $order['advancepay'], 'advancepay' => 0)); } else { $bookTable = false; if (isset($temp['table']) && !empty($temp['table'])) { $bookTable = $temp['table']['price']; unset($temp['table']); } $realpay = $myorder['price'] - $myorder['havepaid']; } $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'des' => $order['des'], 'companytel' => $company['tel'], 'truename' => $order['name'], 'tel' => $order['tel'], 'address' => $order['address'], 'buytime' => $order['time'], 'orderid' => $order['orderid'], 'bookTable' => $bookTable, 'price' => $order['price'], 'total' => $order['total'], 'ptype' => $order['paytype'], 'list' => $temp, 'advancepay' => isset($advancepay) ? $advancepay : false, 'realpay' => isset($realpay) ? $realpay : false); $msg['typename'] = $order['takeaway'] == 2 ? '现场点餐' : '预约点餐'; if ($order['takeaway'] == 1) { $msg['sendtime'] = $order['reservetime']; $msg['typename'] = '外卖'; } elseif ($order['takeaway'] == 0) { $tmpstr = ThirdPayRepast::GetCanTimeByoid($cid, $order['id'], $order['tableid']); $msg['reservestr'] = $tmpstr ? date('Y-m-d', $order['reservetime']) . ' ' . $tmpstr : date('Y-m-d H:i', $order['reservetime']); } if ($order['tableid']) { $t_table = M("Dining_table")->where(array('id' => $order['tableid']))->find(); $msg['tablename'] = isset($t_table['name']) ? $t_table['name'] : ''; } $msg = ArrayToStr::array_to_str($msg, 1); $op->printit($token, $cid, 'Repast', $msg, 1); Sms::sendSms($token . "_" . $cid, "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理"); $siteurl = $_SERVER['HTTP_HOST']; $siteurl = strtolower($siteurl); if (strpos($siteurl, "http:") === false && strpos($siteurl, "https:") === false) { $siteurl = 'http://' . $siteurl; } $siteurl = rtrim($siteurl, '/'); $model = new templateNews(); /*$model->sendTempMsg('OPENTM202521011', array('href' =>U('Repast/myOrders', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $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=Repast&a=myOrders&token=' . $token . '&wecha_id=' . $wecha_id . '&cid=' . $cid, 'wecha_id' => $wecha_id, 'first' => '餐饮订餐交易提醒', 'keyword1' => $orderid, 'keyword2' => date("Y年m月d日H时i分s秒"), 'remark' => '支付成功,感谢您的光临,欢迎下次再次光临!')); } header('Location:' . U('Repast/myOrders', array('token' => $token, 'wecha_id' => $wecha_id, 'cid' => $cid))); } else { exit('订单不存在'); } }
/** * 保存订单 */ public function saveorder() { if (empty($this->user_session)) { exit(json_encode(array('status' => 1, 'message' => '请先进行登录!', 'url' => U('Login/index')))); } $orid = isset($_REQUEST['orid']) ? intval($_REQUEST['orid']) : 0; $total = $price = $tmpprice = 0; $disharr = unserialize($_SESSION[$this->session_index]); $idarr = array_keys($disharr); $store_meal = D('Merchant_store_meal')->where(array('store_id' => $this->store_id))->find(); if ($old_order = $this->check_order($orid)) { //加菜 $info = $old_order['info'] ? unserialize($old_order['info']) : array(); $isadd = empty($info) ? 0 : 1; if ($idarr) { $dish = M("Meal")->where(array('store_id' => $this->store_id, 'meal_id' => array('in', $idarr), 'status' => 1))->select(); foreach ($dish as $val) { $num = isset($disharr[$val['meal_id']]['num']) ? intval($disharr[$val['meal_id']]['num']) : 0; $omark = isset($disharr[$val['meal_id']]['omark']) ? htmlspecialchars($disharr[$val['meal_id']]['omark']) : ''; $info[] = array('id' => $val['meal_id'], 'name' => $val['name'], 'price' => $val['price'], 'num' => $num, 'omark' => $omark, 'isadd' => $isadd); $total += $num; $tmpprice += $val['price'] * $num; // $price += $val['price'] * $num; } //会员等级优惠 $level_off = false; $finaltotalprice = 0; if (!empty($this->user_level) && !empty($this->leveloff) && !empty($this->user_session) && isset($this->user_session['level'])) { /****type:0无优惠 1百分比 2立减*******/ if (isset($this->leveloff[$this->user_session['level']]) && isset($this->user_level[$this->user_session['level']])) { $level_off = $this->leveloff[$this->user_session['level']]; if ($level_off['type'] == 1) { $finaltotalprice = $tmpprice * ($level_off['vv'] / 100); $finaltotalprice = $finaltotalprice > 0 ? $finaltotalprice : 0; $level_off['offstr'] = '按此次总价' . $level_off['vv'] . '%来结算'; } elseif ($level_off['type'] == 2) { $finaltotalprice = $tmpprice - $level_off['vv']; $finaltotalprice = $finaltotalprice > 0 ? $finaltotalprice : 0; $level_off['offstr'] = '此次总价立减' . $level_off['vv'] . '元'; } } } if (!empty($old_order['leveloff'])) { $leveloff = unserialize($old_order['leveloff']); $price = $finaltotalprice > 0 ? $leveloff['totalprice'] + $finaltotalprice : $leveloff['totalprice'] + $tmpprice; $price = round($price, 2); is_array($level_off) && ($level_off['totalprice'] = $price); } else { foreach ($info as $v) { $price += $v['price'] * $v['num']; } $price = max($price, $old_order['price']); } $total_price = $price; $minus_price = 0; if ($store_meal && !empty($store_meal['minus_money']) && $price > $store_meal['full_money']) { $price = $price - $store_meal['minus_money']; $minus_price = $store_meal['minus_money']; } $data = array('total' => $total + $old_order['total'], 'price' => $price, 'dateline' => time()); $data['orderid'] = date("YmdHis") . sprintf("%08d", $this->user_session['uid']); $data['info'] = $info ? serialize($info) : ''; $data['total_price'] = $total_price; $data['minus_price'] = $minus_price; $data['paid'] = $old_order['paid'] == 1 ? 2 : 0; !empty($level_off) && ($data['leveloff'] = serialize($level_off)); if ($return = D("Meal_order")->where(array('order_id' => $orid, 'uid' => $this->user_session['uid']))->save($data)) { $_SESSION[$this->session_index] = null; $_SESSION["allmark" . $this->store_id . $this->mer_id] = null; redirect(U('Pay/check', array('order_id' => $orid, 'type' => 'food'))); } else { $this->error('服务器繁忙,稍后重试'); } } else { $jumpurl = U('Food/menu', array('mer_id' => $this->mer_id, 'store_id' => $this->store_id, 'orid' => $orid)); $this->error('还没有加菜呢', $jumpurl); } } else { //点菜的新单信息 $phone = isset($_POST['tel']) ? htmlspecialchars($_POST['tel']) : ''; $name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : ''; $address = isset($_POST['address']) ? htmlspecialchars($_POST['address']) : ''; $note = isset($_POST['mark']) ? htmlspecialchars($_POST['mark']) : ''; $date = isset($_POST['date']) ? htmlspecialchars($_POST['date']) : ''; $time = isset($_POST['time']) ? htmlspecialchars($_POST['time']) : ''; $sex = isset($_POST['sex']) ? intval($_POST['sex']) : 1; $num = isset($_POST['num']) ? intval($_POST['num']) : 2; $tableid = isset($_POST['seattype']) ? intval($_POST['seattype']) : 0; if (empty($date)) { exit(json_encode(array('status' => 1, 'message' => '就餐日期不能为空'))); } if (empty($time)) { exit(json_encode(array('status' => 1, 'message' => '就餐时间不能为空'))); } if (empty($name)) { exit(json_encode(array('status' => 1, 'message' => '您的姓名不能为空'))); } if (empty($phone)) { exit(json_encode(array('status' => 1, 'message' => '您的电话不能为空'))); } $arrive_time = strtotime($date . ' ' . $time . ":00"); $info = array(); if ($idarr) { //点餐 $dish = M("Meal")->where(array('store_id' => $this->store_id, 'meal_id' => array('in', $idarr), 'status' => 1))->select(); foreach ($dish as $val) { $num = isset($disharr[$val['meal_id']]['num']) ? intval($disharr[$val['meal_id']]['num']) : 0; $omark = isset($disharr[$val['meal_id']]['omark']) ? htmlspecialchars($disharr[$val['meal_id']]['omark']) : ''; $info[] = array('id' => $val['meal_id'], 'name' => $val['name'], 'price' => $val['price'], 'num' => $num, 'omark' => $omark, 'isadd' => 0); $total += $num; $price += $val['price'] * $num; } //会员等级优惠 $level_off = false; $finaltotalprice = 0; if (!empty($this->user_level) && !empty($this->leveloff) && !empty($this->user_session) && isset($this->user_session['level'])) { /****type:0无优惠 1百分比 2立减*******/ if (isset($this->leveloff[$this->user_session['level']]) && isset($this->user_level[$this->user_session['level']])) { $level_off = $this->leveloff[$this->user_session['level']]; if ($level_off['type'] == 1) { $finaltotalprice = $price * ($level_off['vv'] / 100); $finaltotalprice = $finaltotalprice > 0 ? $finaltotalprice : 0; $level_off['offstr'] = '按此次总价' . $level_off['vv'] . '%来结算'; } elseif ($level_off['type'] == 2) { $finaltotalprice = $price - $level_off['vv']; $finaltotalprice = $finaltotalprice > 0 ? $finaltotalprice : 0; $level_off['offstr'] = '此次总价立减' . $level_off['vv'] . '元'; } } } $price = $finaltotalprice > 0 ? round($finaltotalprice, 2) : $price; $level_off && is_array($level_off) && ($level_off['totalprice'] = $price); } else { //预定 $price = $this->_store['deposit']; } $total_price = $price; $minus_price = 0; if ($store_meal && !empty($store_meal['minus_money']) && $price > $store_meal['full_money']) { $price = $price - $store_meal['minus_money']; $minus_price = $store_meal['minus_money']; } $isdeposit = isset($_POST['isdeposit']) ? intval($_POST['isdeposit']) : 0; /***isdeposit 1 支付预定经***/ $price = $isdeposit ? $this->_store['deposit'] : $price; if (isset($level_off) && $isdeposit && $level_off['totalprice'] < $price) { $level_off['totalprice'] = $price; } $data = array('mer_id' => $this->mer_id, 'tableid' => $tableid, 'store_id' => $this->store_id, 'name' => $name, 'phone' => $phone, 'address' => $address, 'note' => $note, 'dateline' => time(), 'total' => $total, 'price' => $price, 'arrive_time' => $arrive_time); $data['orderid'] = date("YmdHis") . sprintf("%08d", $this->user_session['uid']); $data['uid'] = $this->user_session['uid']; $data['sex'] = $sex; $data['num'] = $num; $data['info'] = $info ? serialize($info) : ''; $data['total_price'] = $total_price; $data['minus_price'] = $minus_price; isset($level_off) && !empty($level_off) && ($data['leveloff'] = serialize($level_off)); $orderid = D("Meal_order")->add($data); if ($orderid) { $_SESSION[$this->session_index] = null; $_SESSION["allmark" . $this->store_id . $this->mer_id] = null; if ($this->user_session['openid']) { $keyword2 = ''; $pre = ''; foreach (unserialize($data['info']) as $menu) { $keyword2 .= $pre . $menu['name'] . ':' . $menu['price'] . '*' . $menu['num']; $pre = '\\n\\t\\t\\t'; } $href = C('config.site_url') . '/wap.php?c=Food&a=order_detail&order_id=' . $orderid . '&mer_id=' . $data['mer_id'] . '&store_id=' . $data['store_id']; $model = new templateNews(C('config.wechat_appid'), C('config.wechat_appsecret')); $model->sendTempMsg('OPENTM201682460', array('href' => $href, 'wecha_id' => $this->user_session['openid'], 'first' => '您好,您的订单已生成', 'keyword3' => $orderid, 'keyword1' => date('Y-m-d H:i:s'), 'keyword2' => $keyword2, 'remark' => '您的该次' . $this->config['meal_alias_name'] . '下单成功,感谢您的使用!')); } $msg = array(); $msg['user_name'] = $data['name']; $msg['user_phone'] = $data['phone']; $msg['user_address'] = $data['address']; $msg['user_message'] = $data['note']; $msg['buy_time'] = date("Y-m-d H:i:s", $data['dateline']); $msg['goods_list'] = $info; $msg['goods_count'] = $data['total']; $msg['goods_price'] = $data['price']; $msg['orderid'] = $orderid; $msg['pay_status'] = ''; $msg['pay_type'] = ''; $msg['store_name'] = $this->_store['name']; $msg['store_phone'] = $this->_store['phone']; $msg['store_address'] = $this->_store['adress']; $msg = ArrayToStr::array_to_str($msg, 0, $this->config['print_format']); $op = new orderPrint($this->config['print_server_key'], $this->config['print_server_topdomain']); $op->printit($this->mer_id, $this->store_id, $msg, 0); $sms_data = array('mer_id' => $this->mer_id, 'store_id' => $this->store_id, 'type' => 'food'); if ($this->config['sms_place_order'] == 1 || $this->config['sms_place_order'] == 3) { $sms_data['uid'] = $this->user_session['uid']; $sms_data['mobile'] = $data['phone']; $sms_data['sendto'] = 'user'; $sms_data['content'] = '您在' . $this->_store['name'] . '中预定的用餐的订单生产成功,订单号:' . $orderid; Sms::sendSms($sms_data); } if ($this->config['sms_place_order'] == 2 || $this->config['sms_place_order'] == 3) { $sms_data['uid'] = 0; $sms_data['mobile'] = $this->_store['phone']; $sms_data['sendto'] = 'merchant'; $sms_data['content'] = '顾客' . $data['name'] . '刚刚下了一个订单,订单号:' . $orderid . '请您注意查看并处理'; Sms::sendSms($sms_data); } /* 粉丝行为分析 */ $this->behavior(array('mer_id' => $this->mer_id, 'biz_id' => $orderid)); exit(json_encode(array('status' => 0, 'url' => U('Pay/check', array('order_id' => $orderid, 'type' => 'food'))))); } else { exit(json_encode(array('status' => 1, 'message' => '服务器繁忙,稍后重试'))); } } // ( // [date] => 2015-05-23 // [time] => 10:11 // [num] => 2 // [seattype] => 1 // [tel] => 15209838315 // [name] => hf // [sex] => 1 // [mark] => 55 // [table_fee] => 0 // [dishes_status] => 1 // [order_sn] => // [utype] => 1 // ) }
public function add() { $agent = $_SERVER['HTTP_USER_AGENT']; if (!strpos($agent, "icroMessenger")) { //exit('此功能只能在微信浏览器中使用'); } $da['token'] = strval($this->_get('token')); $da['wecha_id'] = strval($this->_post('wecha_id')); $da['rid'] = (int) $this->_post('rid'); $da['truename'] = strval($this->_post("truename")); $da['dateline'] = strval($this->_post("dateline")); $da['timepart'] = strval($this->_post("timepart")); $da['info'] = strval($this->_post("info")); $da['tel'] = strval($this->_post("tel")); $da['type'] = strval($this->_post('type')); //$da['fieldsigle'] =$this->_post('fieldsigle'); $da['housetype'] = $this->_post('housetype'); $da['booktime'] = time(); $das['id'] = (int) $this->_post('id'); if ($da['type'] == 'maintain') { $da['carnum'] = strval($this->_post("carnum")); $da['km'] = (int) $this->_post('km'); } $book = M('Reservebook'); // $where = array('id'=>$das['id'],'token'=>$da['token']); // $info = M('Reservation')->where($where)->find(); // $arr=array('errno'=>1,'msg'=>$da['type'],'housetype'=>$da['housetype']); // echo json_encode($arr); // exit; $token = strval($this->_get('token')); $wecha_id = strval($this->_get('wecha_id')); $url = 'http://' . $_SERVER['HTTP_HOST']; $url .= U('Reservation/mylist', array('token' => $token, 'wecha_id' => $wecha_id, 'id' => (int) $this->_post('rid'))); if ($das['id'] != '') { $o = $book->where(array('id' => $das['id']))->save($da); if ($o) { $arr = array('errno' => 0, 'msg' => '修改成功', 'url' => $url, 'token' => $token, 'wecha_id' => $wecha_id); echo json_encode($arr); exit; } else { $arr = array('errno' => 1, 'msg' => '修改失败', 'url' => $url, 'token' => $token, 'wecha_id' => $wecha_id); echo json_encode($arr); exit; } } $ok = $book->data($da)->add(); if (!empty($ok)) { $model = new templateNews(); if ($da['type'] == 'house_book') { $estate = M('Estate')->where(array('token' => $token, 'id' => $this->_post('eid', 'intval')))->field('title,place')->find(); $dataKey = 'TM00130'; $dataArr = array('href' => $url, 'wecha_id' => $wecha_id, 'first' => '您好,您已成功预约看房。', 'apartmentName' => $estate['title'], 'roomNumber' => $da['housetype'], 'address' => $estate['place'], 'time' => $da['dateline'] . ' ' . $da['timepart'], 'remark' => '请您准时到达看房。'); } $model->sendTempMsg($dataKey, $dataArr); $arr = array('errno' => 0, 'msg' => '恭喜预约成功', 'token' => $token, 'wecha_id' => $wecha_id, 'url' => $url); echo json_encode($arr); exit; } else { $arr = array('errno' => 1, 'msg' => '预约失败,请重新预约', 'token' => $token, 'wecha_id' => $wecha_id, 'url' => $url); echo json_encode($arr); exit; } }
protected function check($id) { if (empty($id)) { return json_encode(array('err_code' => 1005, 'err_msg' => '网站内部异常,请重试')); } $now_user = d('User')->get_user($this->user_session['uid']); $now_order = d('Service_order')->field(true)->where(array('order_id' => $id))->find(); if (2 == $now_order['status']) { return json_encode(array('err_code' => 1006, 'err_msg' => '该订单已经缴费到帐')); } if (3 == $now_order['status']) { return json_encode(array('err_code' => 1007, 'err_msg' => '该订单充值失败,钱已经回到您的帐户余额中')); } $api_data = array(); $api_data['app_id'] = $this->config['live_service_appid']; $api_data['order_id'] = $now_order['third_id']; $api_data['key'] = $this->get_encrypt_key($api_data, $this->config['live_service_appkey']); $return = $this->curl_post($this->api_path . 'app_check.php', $api_data); $returnArr = json_decode($return, true); if (!(true == isset($returnArr['err_code']))) { return json_encode(array('err_code' => 1003, 'err_msg' => '请求查询失败,请重试')); } if (0 == $returnArr['err_code']) { d('Service_order')->where(array('order_id' => $id))->data(array('status' => $returnArr['status'], 'transfer_time' => $returnArr['transfer_time']))->save(); if ($now_user['openid']) { $href = $this->config['site_url'] . '/wap.php?c=My&a=lifeservice_detail&id=' . $id; $model = new templateNews($this->config['wechat_appid'], $this->config['wechat_appsecret']); $model->sendTempMsg('TM01008', array('href' => $href, 'wecha_id' => $now_user['openid'], 'first' => $this->get_type_txt($now_order['type']) . '缴费成功提醒', 'keynote1' => $returnArr['unitName'], 'keynote2' => '户号 ' . $returnArr['account'], 'remark' => '缴费时间:' . date('Y年n月j日 H:i', $returnArr['transfer_time']) . '\\n' . '缴费金额:¥' . $now_order['pay_money'])); } return json_encode(array('err_code' => 0, 'err_msg' => '充值成功,缴费已到帐!')); } else { if (10001 == $returnArr['err_code']) { if (d('Service_order')->where(array('order_id' => $id))->data(array('status' => 3, 'error_time' => $returnArr['err_msg']))->save()) { $money_pay_result = d('User')->add_money($now_user['uid'], $now_order['pay_money'], '充值 ' . $this->get_type_txt($now_order['type']) . '失败,返回到帐户中'); } return json_encode(array('err_code' => 10001, 'err_msg' => '充值失败,钱已经回到您的帐户余额中')); } } return $return; }
/** * 提交订单 */ public function saveorder() { $dataBase = D('Hotels_order'); if (IS_POST) { $price = 0; if ($sort = M('Hotels_house_sort')->where(array('cid' => $this->_cid, 'token' => $this->token, 'id' => $_POST['sid']))->find()) { if ($this->fans['getcardtime'] > 0) { $price = $sort['vprice'] ? $sort['vprice'] : $sort['price']; } else { $price = $sort['price']; } } $days = (strtotime($_POST['enddate']) - strtotime($_POST['startdate'])) / 86400; $sday = date("Y年m月d日", strtotime($_POST['startdate'])); $eday = date("Y年m月d日", strtotime($_POST['enddate'])); if ($_POST['startdate'] < date("Ymd") || $days < 1) { $this->error('您预定的时间不正确'); } //处理预定房间的数量 $in = date("Ymd", strtotime($_POST['startdate'])); $etime = strtotime($_POST['enddate']); $hotelSort = M("Hotels_house_sort")->where(array('id' => $_POST['sid'], 'token' => $this->token))->find(); $time = strtotime($_POST['startdate']); for (; $time < $etime;) { $order = M('Hotels_order')->field('sum(nums) as num')->where(array('startdate' => array('ELT', date('Ymd', $time)), 'enddate' => array('GT', date('Ymd', $time)), 'token' => $this->token, 'cid' => $this->_cid, 'sid' => $_POST['sid'], 'status' => array('ELT', 1)))->find(); $oldnum = isset($order['num']) ? $order['num'] : 0; $total = $_POST['nums'] + $oldnum; if ($total > $hotelSort['houses']) { $this->error('您预定的房间数在' . date('Y年m月d日', strtotime($time)) . '超出总房间数了,请重新预定'); } else { $time += 86400; } } $_POST['orderid'] = $orderid = substr($this->wecha_id, -1, 4) . date("YmdHis"); $_POST['price'] = $_POST['nums'] * $days * $price; $_POST['time'] = time(); //保存个人信息 $userinfo_model = M('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find(); if (empty($thisUser)) { $userRow = array('tel' => $_POST['tel'], 'truename' => $_POST['name'], 'address' => ''); $userRow['token'] = $this->token; $userRow['wecha_id'] = $this->wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = -1; $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); } if ($dataBase->create() !== false) { $action = $dataBase->add(); if ($action != false) { $company = M('Company')->where(array('id' => $this->_cid, 'token' => $this->token))->find(); $op = new orderPrint(); $msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $_POST['name'], 'tel' => $_POST['tel'], 'address' => '', 'buytime' => time(), 'orderid' => $_POST['orderid'], 'sendtime' => '', 'price' => $_POST['price'], 'total' => $_POST['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $_POST['nums'], 'startdate' => $_POST['startdate'], 'enddate' => $_POST['enddate']))); $msg = ArrayToStr::array_to_str($msg); $op->printit($this->token, $this->_cid, 'Hotel', $msg, 0); Sms::sendSms($this->token . "_" . $this->_cid, "顾客{$_POST['name']}刚刚预定了{$sday}到{$eday},{$days}天的{$sort['name']},请您注意查看并处理"); // $alipayConfig = M('Alipay_config')->where(array('token' => $this->token))->find(); // if ($_POST['paymode'] == 1 && $alipayConfig['open']) { // $this->success('正在提交中...', U('Alipay/pay',array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from'=> 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); // } elseif ($_POST['paymode'] == 4 && $this->fans['balance']) { // $this->success('正在提交中...', U('CardPay/pay',array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from'=> 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); // } else { // $model = new templateNews(); // $model->sendTempMsg('TM00820', array('href' => U('Hotels/my',array('token' => $this->token, 'wecha_id' => $this->wecha_id)), 'wecha_id' => $this->wecha_id, 'first' => '预订房间提醒', 'keynote1' => '订单未支付', 'keynote2' => date("Y年m月d日H时i分s秒"), 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); // $this->success('预定成功,进入您的订单页', U('Hotels/my',array('token' => $this->token, 'wecha_id' => $this->wecha_id))); // } $config = M('Alipay_config')->where(array('token' => $this->token))->find(); $model = new templateNews(); $model->sendTempMsg('TM00184', array('href' => U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id), true, false, true), 'wecha_id' => $this->wecha_id, 'first' => '预订房间提醒', 'ordertape' => date("Y年m月d日H时i分s秒"), 'ordeID' => $orderid, 'remark' => '预订房间成功,感谢您的光临,欢迎下次再次光临!')); if ($_POST['paymode'] == 4 && $this->fans['balance']) { $this->success('正在提交中...', U('CardPay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from' => 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); } elseif ($config['open']) { $this->success('正在提交中...', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'from' => 'Hotels', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $_POST['price']))); } else { $this->success('预定成功,进入您的订单页', U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id))); } } else { $this->error('操作失败'); } } else { $this->error($dataBase->getError()); } } }
public function cart() { $this->wapIsLogin(); if (IS_POST) { $phone = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : ''; $name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : ''; $address = isset($_POST['address']) ? htmlspecialchars($_POST['address']) : ''; $note = isset($_POST['note']) ? htmlspecialchars($_POST['note']) : ''; if (empty($name)) { $this->error('联系人不能为空'); } if (empty($phone)) { $this->error('联系电话不能为空'); } $goodsData = isset($_POST['goodsData']) ? htmlspecialchars($_POST['goodsData']) : ''; if (empty($goodsData)) { $this->error('您还没有点菜'); } $products = explode(";", $goodsData); $dish = array(); $meal = array(); foreach ($products as $p) { $t = explode(",", $p); $dish[$t[0]] = $t[1]; $meal[] = $t[0]; } $total = $price = 0; if ($meal) { $meals = M("Meal")->where(array('meal_id' => array('in', $meal), 'store_id' => $this->store_id))->select(); $info = array(); foreach ($meals as $m) { $info[] = array('id' => $m['meal_id'], 'name' => $m['name'], 'num' => $dish[$m['meal_id']], 'price' => $m['price']); $total += $dish[$m['meal_id']]; $price += $dish[$m['meal_id']] * $m['price']; } } $data = array('mer_id' => $this->mer_id, 'store_id' => $this->store_id, 'name' => $name, 'phone' => $phone, 'address' => $address, 'note' => $note, 'info' => serialize($info), 'dateline' => time(), 'total' => $total, 'price' => $price); $data['orderid'] = $this->mer_id . $this->store_id . date("YmdHis") . rand(1000000, 9999999); // $data['wecha_id'] = $this->wecha_id; $data['uid'] = $this->user_session['uid']; $data['note'] = isset($_POST['note']) ? htmlspecialchars($_POST['note']) : ''; $orderid = D("Meal_order")->add($data); if ($orderid) { if ($this->user_session['openid']) { $keyword2 = ''; $pre = ''; foreach (unserialize($data['info']) as $menu) { $keyword2 .= $pre . $menu['name'] . ':' . $menu['price'] . '*' . $menu['num']; $pre = '\\n\\t\\t\\t'; } $href = C('config.site_url') . '/wap.php?c=Meal&a=detail&orderid=' . $orderid . '&mer_id=' . $data['mer_id'] . '&store_id=' . $data['store_id']; $model = new templateNews(C('config.wechat_appid'), C('config.wechat_appsecret')); $model->sendTempMsg('OPENTM201682460', array('href' => $href, 'wecha_id' => $this->user_session['openid'], 'first' => '您好,您的订单已生成', 'keyword3' => $orderid, 'keyword1' => date('Y-m-d H:i:s'), 'keyword2' => $keyword2, 'remark' => '您的该次' . $this->config['meal_alias_name'] . '下单成功,感谢您的使用!')); } $msg = array(); $msg['user_name'] = $data['name']; $msg['user_phone'] = $data['phone']; $msg['user_address'] = $data['address']; $msg['user_message'] = $data['note']; $msg['buy_time'] = date("Y-m-d H:i:s", $data['dateline']); $msg['goods_list'] = $info; $msg['goods_count'] = $data['total']; $msg['goods_price'] = $data['price']; $msg['orderid'] = $orderid; $msg['pay_status'] = ''; $msg['pay_type'] = ''; $msg['store_name'] = $this->_store['name']; $msg['store_phone'] = $this->_store['phone']; $msg['store_address'] = $this->_store['adress']; $msg = ArrayToStr::array_to_str($msg, 0, $this->config['print_format']); $op = new orderPrint($this->config['print_server_key'], $this->config['print_server_topdomain']); $op->printit($this->mer_id, $this->store_id, $msg, 0); /* 粉丝行为分析 */ $this->behavior(array('mer_id' => $this->mer_id, 'biz_id' => $orderid)); redirect(U('Pay/check', array('order_id' => $orderid, 'type' => 'meal'))); //$this->success('订餐成功', U("Meal/detail", array('mer_id' => $this->mer_id, 'store_id' => $this->store_id, 'orderid' => $orderid))); } } else { $now_group['user_adress'] = D('User_adress')->get_one_adress($this->user_session['uid'], intval($_GET['adress_id'])); $this->assign('now_group', $now_group); $sorts = M("Meal_sort")->where(array('store_id' => $this->store_id))->select(); $temp = array(); foreach ($sorts as $sort) { $temp[$sort['sort_id']] = $sort['sort_name']; } $this->assign("categories", json_encode($temp)); $this->assign('class', 3); $this->assign('title', '购物车'); $this->display(); } }
protected function get_prize($Lottery, $wecha_id) { $id = intval($Lottery['id']); $lottery_db = M('Lottery'); $joinNum = $Lottery['joinnum']; // $firstNum = intval($Lottery['fistnums']) - intval($Lottery['fistlucknums']); $secondNum = intval($Lottery['secondnums']) - intval($Lottery['secondlucknums']); $thirdNum = intval($Lottery['thirdnums']) - intval($Lottery['thirdlucknums']); $fourthNum = intval($Lottery['fournums']) - intval($Lottery['fourlucknums']); $fifthNum = intval($Lottery['fivenums']) - intval($Lottery['fivelucknums']); $sixthNum = intval($Lottery['sixnums']) - intval($Lottery['sixlucknums']); $multi = intval($Lottery['canrqnums']); //最多抽奖次数 $prize_arr = array('0' => array('id' => 1, 'prize' => '一等奖', 'v' => $firstNum, 'start' => 0, 'end' => $firstNum), '1' => array('id' => 2, 'prize' => '二等奖', 'v' => $secondNum, 'start' => $firstNum, 'end' => $firstNum + $secondNum), '2' => array('id' => 3, 'prize' => '三等奖', 'v' => $thirdNum, 'start' => $firstNum + $secondNum, 'end' => $firstNum + $secondNum + $thirdNum), '3' => array('id' => 4, 'prize' => '四等奖', 'v' => $fourthNum, 'start' => $firstNum + $secondNum + $thirdNum, 'end' => $firstNum + $secondNum + $thirdNum + $fourthNum), '4' => array('id' => 5, 'prize' => '五等奖', 'v' => $fifthNum, 'start' => $firstNum + $secondNum + $thirdNum + $fourthNum, 'end' => $firstNum + $secondNum + $thirdNum + $fourthNum + $fifthNum), '5' => array('id' => 6, 'prize' => '六等奖', 'v' => $sixthNum, 'start' => $firstNum + $secondNum + $thirdNum + $fourthNum + $fifthNum, 'end' => $firstNum + $secondNum + $thirdNum + $fourthNum + $fifthNum + $sixthNum), '6' => array('id' => 7, 'prize' => '谢谢参与', 'v' => intval($Lottery['allpeople']) * $multi - ($firstNum + $secondNum + $thirdNum + $fourthNum + $fifthNum + $sixthNum), 'start' => $firstNum + $secondNum + $thirdNum + $fourthNum + $fifthNum + $sixthNum, 'end' => intval($Lottery['allpeople']) * $multi)); // foreach ($prize_arr as $key => $val) { $arr[$val['id']] = $val; } //------------------------------- //随机抽奖[如果预计活动的人数为1为各个奖项100%中奖] //------------------------------- if ($Lottery['allpeople'] == 1) { if ($Lottery['fistlucknums'] <= $Lottery['fistnums']) { $prizetype = 1; } else { $prizetype = 7; } } else { $prizetype = $this->get_rand($arr, intval($Lottery['allpeople']) * $multi - $joinNum); } //$winprize = $prize_arr[$rid-1]['prize']; switch ($prizetype) { case 1: if ($Lottery['fistlucknums'] >= $Lottery['fistnums']) { $prizetype = ''; //$winprize = '谢谢参与'; } else { $prizetype = 1; //$lottery_db->where(array('id'=>$id))->setInc('fistlucknums'); } break; case 2: if ($Lottery['secondlucknums'] >= $Lottery['secondnums']) { $prizetype = ''; //$winprize = '谢谢参与'; } else { //判断是否设置了2等奖&&数量 if (empty($Lottery['second']) && empty($Lottery['secondnums'])) { $prizetype = ''; //$winprize = '谢谢参与'; } else { //输出中了二等奖 $prizetype = 2; //$lottery_db->where(array('id'=>$id))->setInc('secondlucknums'); } } break; case 3: if ($Lottery['thirdlucknums'] >= $Lottery['thirdnums']) { $prizetype = ''; // $winprize = '谢谢参与'; } else { if (empty($Lottery['third']) && empty($Lottery['thirdnums'])) { $prizetype = ''; // $winprize = '谢谢参与'; } else { $prizetype = 3; //$lottery_db->where(array('id'=>$id))->setInc('thirdlucknums'); } } break; case 4: if ($Lottery['fourlucknums'] >= $Lottery['fournums']) { $prizetype = ''; // $winprize = '谢谢参与'; } else { if (empty($Lottery['four']) && empty($Lottery['fournums'])) { $prizetype = ''; //$winprize = '谢谢参与'; } else { $prizetype = 4; //$lottery_db->where(array('id'=>$id))->setInc('fourlucknums'); } } break; case 5: if ($Lottery['fivelucknums'] >= $Lottery['fivenums']) { $prizetype = ''; //$winprize = '谢谢参与'; } else { if (empty($Lottery['five']) && empty($Lottery['fivenums'])) { $prizetype = ''; //$winprize = '谢谢参与'; } else { $prizetype = 5; //$lottery_db->where(array('id'=>$id))->setInc('fivelucknums'); } } break; case 6: if ($Lottery['sixlucknums'] >= $Lottery['sixnums']) { $prizetype = ''; // $winprize = '谢谢参与'; } else { if (empty($Lottery['six']) && empty($Lottery['sixnums'])) { $prizetype = ''; //$winprize = '谢谢参与'; } else { $prizetype = 6; //$lottery_db->where(array('id'=>$id))->setInc('sixlucknums'); } } break; default: $prizetype = ''; //$winprize = '谢谢参与'; break; } if (intval($prizetype) && $prizetype < 7 && $prizetype > 0) { //中奖了 - 模板消息通知 $model = new templateNews(); $tempKey = 'TM00785'; foreach ($prize_arr as $kk => $vv) { if ($vv['id'] == $prizetype) { $result = '恭喜您在本次活动中获得了' . $prize; } } $href = C('site_url') . U('Wap/Lottery/index', array('token' => $this->_get('token'), 'wecha_id' => $wecha_id, 'id' => $Lottery['id'])); $dataArr = array('href' => '', 'wecha_id' => $wecha_id, 'first' => '恭喜您中奖了!', 'program' => $Lottery['title'], 'result' => $result, 'remark' => '请您尽快来领奖!'); $model->sendTempMsg($tempKey, $dataArr); } return $prizetype; }
public function payReturn() { $this->wxregister(); $where_order["orderid"] = $_GET["orderid"]; $where_order["token"] = $this->token; $find_order = $this->m_order->where($where_order)->find(); if ($find_order["paid"] == 1) { $where_cart["token"] = $this->token; $where_cart["wecha_id"] = $this->wecha_id; $where_cart["order_id"] = $_GET["orderid"]; $save_cart["state"] = 1; $update_cart = $this->m_cart->where($where_cart)->save($save_cart); if (0 < $update_cart) { $where_cart["state"] = 1; } $cart_list = $this->m_cart->where($where_cart)->select(); foreach ($cart_list as $vo ) { $where_cart2["unitary_id"] = $vo["unitary_id"]; $where_cart2["token"] = $this->token; $where_cart2["state"] = 1; $cart_list2 = $this->m_cart->where($where_cart2)->select(); $pay_count = 0; foreach ($cart_list2 as $cvo ) { $pay_count = $pay_count + $cvo["count"]; } $where_unitary["id"] = $vo["unitary_id"]; $where_unitary["token"] = $this->token; $find_unitary = $this->m_unitary->where($where_unitary)->find(); for ($j = 0; $j < $find_unitary["price"]; $j++) { $price[$vo["unitary_id"]][] = $j; } for ($i = 0; $i < $vo["count"]; $i++) { $add_lucknum["token"] = $this->token; $add_lucknum["wecha_id"] = $this->wecha_id; $add_lucknum["order_id"] = $_GET["orderid"]; $add_lucknum["cart_id"] = $vo["id"]; $add_lucknum["unitary_id"] = $vo["unitary_id"]; list($s1, $s2) = explode(" ", microtime()); $mtime = (double) sprintf("%.0f", (floatval($s1) + floatval($s2)) * 1000); $add_lucknum["addtime"] = $mtime; $where_lucknum["unitary_id"] = $vo["unitary_id"]; $lucknum_list = $this->m_lucknum->where($where_lucknum)->select(); foreach ($lucknum_list as $lvo ) { if (in_array($lvo["lucknum"], $price[$vo["unitary_id"]])) { $k = array_search($lvo["lucknum"], $price[$vo["unitary_id"]]); array_splice($price[$vo["unitary_id"]], $k, 1); } } $mylucknum = $price[$vo["unitary_id"]][rand(0, count($price[$vo["unitary_id"]]) - 1)]; $add_lucknum["lucknum"] = $mylucknum; $add_lucknum["state"] = 0; $id_lucknum = $this->m_lucknum->add($add_lucknum); } $save_unitary = NULL; $save_unitary["proportion"] = ($pay_count / $find_unitary["price"]) * 100; if ($find_unitary["price"] <= $pay_count) { $where_lucknum_all["token"] = $this->token; $lucknum_all_count = $this->m_lucknum->where($where_lucknum_all)->count(); if ($lucknum_all_count < 100) { $save_unitary["lastnum"] = $lucknum_all_count; } else { $save_unitary["lastnum"] = 100; } $lucknum_all = $this->m_lucknum->where($where_lucknum_all)->order("addtime desc")->limit($save_unitary["lastnum"])->select(); $save_unitary["lasttime"] = $lucknum_all[0]["id"]; $sum = 0; foreach ($lucknum_all as $avo ) { $thistime = floor($avo["addtime"] / 1000); $ms = substr($avo["addtime"], -3); $sum = $sum + (date("h", $thistime) . date("i", $thistime) . date("s", $thistime) . $ms); } $lucknum = fmod($sum, $find_unitary["price"]); $save_unitary["lucknum"] = $lucknum; $save_unitary["state"] = 2; $save_unitary["endtime"] = time() + $find_unitary["opentime"]; $where_cart3["state"] = 0; $where_cart3["token"] = $this->token; $where_cart3["unitary_id"] = $vo["unitary_id"]; $del_cart3 = $this->m_cart->where($where_cart3)->delete(); $save_unitary["proportion"] = 100; $where_lucknum2["unitary_id"] = $vo["unitary_id"]; $where_lucknum2["token"] = $this->token; $where_lucknum2["lucknum"] = $lucknum; $where_lucknum2["state"] = 0; $save_lucknum2["state"] = 1; $update_lucknum2 = $this->m_lucknum->where($where_lucknum2)->save($save_lucknum2); $where_lucknum2["state"] = 1; $find_lucknum2 = $this->m_lucknum->where($where_lucknum2)->find(); $model = new templateNews(); $model->sendTempMsg("TM00785", array("href" => U("Unitary/goodswhere", array("token" => $this->token, "unitaryid" => $vo["unitary_id"])), "wecha_id" => $find_lucknum2["wecha_id"], "first" => "一元夺宝中奖通知", "program" => $find_unitary["name"], "result" => date("Y年m月d日H时i分s秒"), "remark" => "恭喜您在一元夺宝中获得【" . $find_unitary["name"] . "】点击查看")); } $update_unitary = $this->m_unitary->where($where_unitary)->save($save_unitary); } $this->redirect("Unitary/payend", array("token" => $this->token, "orderid" => $_GET["orderid"])); } else { $where_cart["token"] = $this->token; $where_cart["wecha_id"] = $this->wecha_id; $where_cart["order_id"] = $_GET["orderid"]; $save_cart["state"] = 0; $save_cart["order_id"] = 0; $update_cart = $this->m_cart->where($where_cart)->save($save_cart); $del_order = $this->m_order->where($where_order)->delete(); $this->error("支付失败", U("Unitary/cart", array("token" => $this->token))); } }
public function notify() { $data = $_POST; unset($data['sign_key']); unset($data['request_time']); $data['salt'] = $this->SALT; ksort($data); $sign_key = sha1(http_build_query($data)); if ($sign_key != $_POST['sign_key']) { echo '{"status":"-1","msg":"签名错误"}'; exit; } $token = $data['token']; switch ($data['type']) { case '1': $buyer_content = NULL; $seller_content = NULL; $key = 'TM00184'; $tempData = array('wecha_id' => $data['wecha_id'], 'href' => $data['href'], 'first' => $data['title'], 'ordertape' => $data['order_detail']['add_time'], 'ordeID' => $data['order_detail']['order_no'], 'remark' => $data['remark']); break; case '2': $buyer_content = '您好,我们已经收到您的订单:' . $data['order_detail']['order_no'] . '的款项,我们会以最快的速度安排发货,请您耐心静候。'; $seller_content = '您好,您的商铺有新订单,请注意安排及时发货。订单号:' . $data['order_detail']['order_no']; $key = 'OPENTM205160490'; $tempData = array('wecha_id' => $data['wecha_id'], 'href' => $data['href'], 'first' => $data['title'], 'keyword1' => $data['order_detail']['total'], 'keyword2' => implode(',', $data['products']['name']), 'keyword3' => $data['order_detail']['payment_method'], 'keyword4' => $data['order_detail']['trade_no'], 'keyword5' => $data['order_detail']['paid_time'], 'remark' => $data['remark']); break; case '3': $buyer_content = '您好,您的订单:' . $data['order_detail']['order_no'] . '已完成,感谢您的光临,祝您生活愉快,下次再来。'; $seller_content = NULL; $key = 'OPENTM202531033'; $tempData = array('wecha_id' => $data['wecha_id'], 'href' => $data['href'], 'first' => $data['title'], 'keyword1' => $data['order_detail']['order_no'], 'keyword2' => date('Y-m-d H:i:s', time()), 'remark' => $data['remark']); break; } if ($seller_content) { Sms::sendSms($token, $seller_content, $data['seller_tel']); } if ($buyer_content) { Sms::sendSms($token, $buyer_content, $data['buyer_tel']); } $template = new templateNews(); $template->sendTempMsg($key, $tempData); echo '{"status":"0","msg":"执行成功"}'; }
public function grouponordersave() { //TODO 发货的短信提醒 if (IS_POST) { $row = array(); $wecha_id = $this->wecha_id ? $this->wecha_id : session('twid'); $row['truename'] = $this->_post('truename'); $row['tel'] = $this->_post('tel'); $row['address'] = $this->_post('address'); $row['token'] = $this->token; $row['note'] = $this->_post('note'); $row['wecha_id'] = $wecha_id; $row['paymode'] = isset($_POST['paymode']) ? intval($_POST['paymode']) : 0; $row['cid'] = $cid = $this->_isgroup ? $this->mainCompany['id'] : $this->_cid; $score = isset($_POST['score']) ? intval($_POST['score']) : 0; $orid = $this->_post('orderid'); $product_cart_model = M('New_product_cart'); if ($cartObj = $product_cart_model->where(array('token' => $this->token, 'wecha_id' => $wecha_id, 'orderid' => $orid))->find()) { $carts = $cartObj; } else { $this->error('未找到订单信息,请联系商家'); } //保存订单信息 $row['time'] = $time = time(); $saverow = $product_cart_model->where(array('orderid' => $orid))->save($row); $userinfo_model = M('Userinfo'); $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $wecha_id))->find(); //保存个人信息 if ($_POST['saveinfo']) { $this->assign('thisUser', $thisUser); $userRow = array('tel' => $row['tel'], 'truename' => $row['truename'], 'address' => $row['address']); if ($thisUser) { $userinfo_model->where(array('id' => $thisUser['id']))->save($userRow); F('fans_token_wechaid', NULL); } else { $userRow['token'] = $this->token; $userRow['wecha_id'] = $wecha_id; $userRow['wechaname'] = ''; $userRow['qq'] = 0; $userRow['sex'] = -1; $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); } } //保存个人信息end $orderid = $orid; $paymode = $row['paymode']; $totalprice = $_POST['totalCount']; if (empty($_POST['address'])) { $this->error('未填写收货地址'); } if (empty($_POST['tel'])) { $this->error('未填写联系电话'); } if (empty($_POST['truename'])) { $this->error('未填写收货人姓名'); } $model = new templateNews(); $model->sendTempMsg('TM00184', array('href' => U('Storenew/myinfo', array('token' => $this->token, 'wecha_id' => $wecha_id), true, false, true), 'wecha_id' => $wecha_id, 'first' => '购买商品提醒', 'ordertape' => date("Y年m月d日H时i分s秒"), 'ordeID' => $orid, 'remark' => '' . $row['truename'] . '你参与团购成功,订单信息收货人:' . $row['truename'] . ',电话:' . $row['tel'] . ',收获地址:' . $row['address'] . ',备注信息:' . $row['note'] . ',付款金额:' . $totalprice . '元,请及时付款,谢谢!')); //测试消息服务 $where = array('token' => $this->token); $this->thisWxUser = M('Wxuser')->where($where)->find(); $url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $this->thisWxUser['appid'] . '&secret=' . $this->thisWxUser['appsecret']; $access_token = json_decode($this->curlGet($url_get)); $a = $access_token->access_token; //客服接口,24小时内发送过内容的用户才有 //$url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='.$a; //消息预览接口 $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $a; //获取用户openID $where2 = array('token' => $row['token'], 'cid' => $row['cid']); $sendwecha_id = M('New_product_set_reply')->where($where2)->field('wecha_id')->find(); //开始发送消息到商家微信 $data = '{"touser":"******","msgtype":"text", "text":{"content":"您的用户:' . $row['truename'] . '参与团购,收货人:' . $row['truename'] . ',电话:' . $row['tel'] . ',收获地址:' . $row['address'] . ',备注信息:' . $row['note'] . ',付款金额:' . $totalprice . '元。(当您看到此信息表示用户已经提交团购订单,等待付款)"}}'; $this->postCurl($url, $data); // //dump($orderid); //die; if ($totalprice) { if ($paymode == 4) { $this->success('正在提交中...', U('CardPay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'from' => 'Storenew', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $totalprice))); die; } else { $notOffline = $setting['paymode'] == 1 ? 0 : 1; $this->success('正在提交中...', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'from' => 'Storenew', 'orderName' => $orderid, 'single_orderid' => $orderid, 'price' => $totalprice, 'notOffline' => $notOffline))); die; } } $this->success('预定成功,进入您的订单页', U('Storenew/myinfo', array('token' => $_GET['token'], 'wecha_id' => $wecha_id, 'success' => 1, 'twid' => $this->_twid))); } else { $this->error('订单生产失败'); } }