示例#1
0
 public function smssendtest()
 {
     if (strlen($_GET['mp']) != 11) {
         $this->error('请输入正确的手机号');
     }
     $this->error(Sms::sendSms('admin', 'hello,你好', $_GET['mp']));
 }
示例#2
0
 public function index($orderid, $paytype, $third_id)
 {
     $product_cart_model = M('product_cart');
     $out_trade_no = $orderid;
     $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find();
     if (!$this->wecha_id) {
         $this->wecha_id = $order['wecha_id'];
     }
     $sepOrder = 0;
     if (!$order) {
         $order = $product_cart_model->where(array('id' => $out_trade_no))->find();
         $sepOrder = 1;
     }
     if ($order) {
         if ($order['paid'] != 1) {
             exit('该订单还未支付');
         }
         /************************************************/
         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);
     }
 }
示例#3
0
 public function index()
 {
     $set_id = $this->_get('id', 'intval');
     $formData = $this->_createForms($this->token, $set_id);
     if (IS_POST) {
         $limit_info = $this->limit_db->where(array('limit_id' => $this->thisForm['limit_id']))->find();
         if ($limit_info['enddate']) {
             if ($limit_info['enddate'] < time()) {
                 $this->error('抱歉,时间已过期,无法提交');
             }
         }
         if (0 < $limit_info['today_total']) {
             $time = strtotime(date('Y-m-d'));
             $total = $this->info_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'set_id' => $this->thisForm['set_id'], 'add_time' => array('gt', $time)))->count();
             if ($limit_info['today_total'] <= $total) {
                 $this->error('抱歉,今日只能提交' . $limit_info['today_total'] . '次');
             }
         }
         if (0 < $limit_info['sub_total']) {
             $total = $this->info_db->where(array('token' => $this->token, 'set_id' => $this->thisForm['set_id'], 'wecha_id' => $this->wecha_id))->count();
             if ($limit_info['sub_total'] <= $total) {
                 $this->error('抱歉,提交总数已经超过' . $limit_info['sub_total'] . '次');
             }
         }
         $data['token'] = $this->token;
         $data['wecha_id'] = $this->wecha_id;
         $data['set_id'] = $set_id;
         $data['add_time'] = time();
         $data['user_name'] = empty($this->fans['wechaname']) ? '匿名' : $this->fans['wechaname'];
         $data['phone'] = empty($this->fans['tel']) ? '匿名' : $this->fans['tel'];
         $array = array();
         foreach ($this->_request() as $key => $value) {
             if ($value == '') {
                 $array[] = array($key => '未填写');
             }
         }
         $arr = array();
         foreach ($array as $k => $v) {
             foreach ($v as $key => $value) {
                 $arr[$key] = $value;
             }
         }
         $b = $this->_request();
         $request = array_merge($b, $arr);
         $data['sub_info'] = $this->_serializeSubInfo($request, $set_id);
         if ($this->info_db->add($data)) {
             Sms::sendSms($this->token, '你的表单“' . $this->thisForm['title'] . '”中有新的信息');
             $this->success($this->thisForm['succ_info']);
         } else {
             $this->error($this->thisForm['err_info']);
         }
     } else {
         $spoor = $this->info_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'set_id' => $set_id))->count();
         $this->assign('spoor', $spoor);
         $this->assign('verify', $formData['verify']);
         $this->assign('formData', $formData['string']);
         $this->display();
     }
 }
 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('抱歉,订单信息出错');
     }
 }
示例#5
0
 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(){
		$set_id 	= $this->_get('id','intval');
		$formData 	= $this->_createForms($this->token,$set_id);

		if(IS_POST){
			$limit_info = $this->limit_db->where(array('limit_id'=>$this->thisForm['limit_id']))->find();

			if($limit_info['enddate']){
				if($limit_info['enddate']<time()){
					$this->error('抱歉,时间已过期,无法提交');
				}
			}

			if($limit_info['today_total'] >0){
				$time 		= strtotime(date('Y-m-d')); //凌晨时间
				$total 		= $this->info_db->where(array('wecha_id'=>$this->token,'wecha_id'=>$this->wecha_id,'add_time'=>array('gt',$time)))->count();
				if($total >= $limit_info['today_total']){
					$this->error('抱歉,今日只能提交'.$limit_info['today_total'].'次');
				}
			}		

			if($limit_info['sub_total'] >0){
				$total 		= $this->info_db->where(array('wecha_id'=>$this->token,'wecha_id'=>$this->wecha_id))->count();
				if($total >= $limit_info['sub_total']){
					$this->error('抱歉,提交总数已经超过'.$limit_info['sub_total'].'次');
				}
			}
	
			$data['token']		= $this->token;
			$data['wecha_id']	= $this->wecha_id;
			$data['set_id']		= $set_id;
			$data['add_time']	= time();		
			$data['user_name']	= empty($this->fans['wechaname'])?'匿名':$this->fans['wechaname'];
			$data['phone']		= empty($this->fans['tel'])?'匿名':$this->fans['tel'];
			$data['sub_info']	= $this->_serializeSubInfo($this->_request(),$set_id);
			if($this->info_db->add($data)){
				Sms::sendSms($this->token, '你的表单“'.$this->thisForm['title'].'”中有新的信息'); //发送商家短信
				$this->success($this->thisForm['succ_info']);
			}else{
				$this->error($this->thisForm['err_info']);
			}
		}else{
			//提交记录
			$spoor = $this->info_db->where(array('token'=>$this->token,'wecha_id'=>$this->wecha_id,'set_id'=>$set_id))->count();
			$this->assign('spoor',$spoor);
			//dump($formData['verify']);
			$this->assign('verify',$formData['verify']);
			$this->assign('formData',$formData['string']);
			$this->display();
		}
	}
示例#7
0
	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)
 {
     $product_cart_model = M('product_cart');
     $out_trade_no = $orderid;
     $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find();
     if (!$this->wecha_id) {
         $this->wecha_id = $order['wecha_id'];
     }
     $sepOrder = 0;
     if (!$order) {
         $order = $product_cart_model->where(array('id' => $out_trade_no))->find();
         $sepOrder = 1;
     }
     if ($order) {
         if ($order['paid'] != 1) {
             exit('该订单还未支付');
         }
         if (!empty($order['sn']) && empty($order['sn_content'])) {
             $where['sendstutas'] = 0;
             $where['order_id'] = 0;
             $where['token'] = $this->token;
             $where['pid'] = $order['productid'];
             $productSn = M('ProductSn');
             $models = $productSn->where($where)->limit($order['total'])->order('id ASC')->select();
             foreach ($models as $key => $model) {
                 $model['order_id'] = $order['id'];
                 $model['sendstutas'] = 1;
                 $model['sendtime'] = time();
                 $model['wecha_id'] = $order['wecha_id'];
                 $updateWhere['id'] = $model['id'];
                 $updateWhere['sendstutas'] = 0;
                 unset($model['id']);
                 $productSn->where($updateWhere)->save($model);
                 $models[$key] = $model;
             }
             $order['sent'] = 1;
             $order['handled'] = 1;
             $order['sn_content'] = serialize($models);
             $product_cart_model->save($order);
         } else {
             M('Product')->where(array('id' => $order['productid']))->setDec('groupon_num', $order['total']);
         }
         /************************************************/
         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);
     }
 }
示例#9
0
 public function leave()
 {
     //留言信息插入处理
     $leave_model = M("leave");
     $message = $this->_get('message');
     $name = $this->_get('name');
     $msgarr = array();
     $msgarr['checked'] = 1 - intval($this->needCheck);
     $msgarr['name'] = $name;
     $msgarr['message'] = $message;
     $msgarr['wecha_id'] = $this->wecha_id;
     $msgarr['token'] = $this->token;
     $msgarr['time'] = time();
     //根据token 来确定同一用户60秒以后才能留言
     $lasttime = $leave_model->where(array("token" => $this->token))->getField("max(time)");
     //获得准备数据 是否与数据库中数据留言是同一人
     $timeres = time() - $lasttime;
     if ($timeres < $this->sepTime) {
         $this->ajaxReturn("", "您已留言,请60秒以后再留言", 0);
         exit;
     } else {
         $res = $leave_model->add($msgarr);
         //echo $res;exit;
         if ($res) {
             Sms::sendSms($this->token, '留言板有新的留言');
             $msgarr['id'] = $res;
             if ($msgarr['checked'] == 1) {
                 $msgarr['time'] = date("Y-m-d H:i:s", $msgarr['time']);
                 $data['data'] = $msgarr;
                 $data['info'] = "留言成功";
                 $data['status'] = 1;
                 $this->ajaxReturn($data);
                 exit;
             } else {
                 $data['data'] = $msgarr;
                 $data['info'] = "留言成功,正在审核中";
                 $data['status'] = 2;
                 $this->ajaxReturn($data);
                 exit;
             }
         } else {
             $data['data'] = "";
             $data['info'] = "留言失败";
             $data['status'] = 0;
             $this->ajaxReturn($data);
             exit;
         }
     }
 }
示例#10
0
	/**
	 * 订单详情
	 */
	public function orderInfo() {
		$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
		$hotelOrder = M('Hotels_order');
		if ($thisOrder = $hotelOrder->where(array('id' => $id, 'token' => $this->token, 'cid' => $this->_cid))->find()) {
			if (IS_POST) {
				$status = isset($_POST['status']) ? intval($_POST['status']) : 0;
				$paid = isset($_POST['paid']) ? intval($_POST['paid']) : 0;
				$hotelOrder->where(array('id' => $thisOrder['id']))->save(array('status' => $status, 'paid' => $paid));
				$company = M('Company')->where(array('token' => $this->token, 'id' => $thisOrder['cid']))->find();
				if ($paid && empty($thisOrder['paid'])) {
					$sort = M('Hotels_house_sort')->where(array('id' => $thisOrder['sid'], 'token' => $this->token))->find();
					$days = (strtotime($thisOrder['enddate']) - strtotime($thisOrder['startdate'])) / 86400;
					$price = $this->fans['getcardtime'] > 0 ? ($sort['vprice'] ? $sort['vprice'] : $sort['price']) : $sort['price'];
					$op = new orderPrint();
					$msg = array('companyname' => $company['name'], 'companytel' => $company['tel'], 'truename' => $thisOrder['name'], 'tel' => $thisOrder['tel'], 'address' => '', 'buytime' => $thisOrder['time'], 'orderid' => $thisOrder['orderid'], 'sendtime' => '', 'price' => $thisOrder['price'], 'total' => $thisOrder['nums'], 'list' => array(array('name' => $sort['name'], 'day' => $days, 'price' => $price, 'num' => $thisOrder['nums'], 'startdate' => $thisOrder['startdate'], 'enddate' => $thisOrder['enddate'])));
					$msg = ArrayToStr::array_to_str($msg, 1);
					$op->printit($this->token, $this->_cid, 'Hotel', $msg, 1);
				}
				
				Sms::sendSms($this->token, "{$company['name']}欢迎您,本店对您的订单号为:{$thisOrder['orderid']}的订单状态进行了修改,如有任何疑意,请您及时联系本店!", $thisOrder['tel']);
				$this->success('修改成功',U('Hotels/orderInfo',array('token'=>session('token'),'id'=>$thisOrder['id'])));
			} else {
				$sort = M('Hotels_house_sort')->where(array('cid' => $this->_cid, 'token' => $this->token, 'id' => $thisOrder['sid']))->find();
				$thisOrder['housename'] = isset($sort['name']) ? $sort['name'] : '';
				$this->assign('thisOrder', $thisOrder);
				$this->display();
			}
		}
	}
示例#11
0
 /**
  * 支付成功后的回调函数
  */
 public function payReturn()
 {
     $orderid = $_GET['orderid'];
     if ($order = M('Hotels_order')->where(array('orderid' => $orderid, 'token' => $this->token))->find()) {
         //TODO 发货的短信提醒
         if ($order['paid']) {
             //Sms::sendSms($this->token, "您刚刚对订单号:{$orderid}的订单进行了支付,欢迎您的入住!", $order['tel']);
             Sms::sendSms($this->token . "_" . $order['cid'], "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理");
         }
         $this->redirect(U('Hotels/my', array('token' => $this->token, 'wecha_id' => $this->wecha_id)));
     } else {
         exit('订单不存在');
     }
 }
示例#12
0
 protected function payReturn()
 {
     // $data       = D('busines_second');
     // $t_busines  = D('busines');
     $tb_resbook = D('reservebook');
     $orderid = filter_var($this->_get('orderid'), FILTER_SANITIZE_STRING);
     $token = filter_var($this->_get('token'), FILTER_SANITIZE_STRING);
     $checkOrder = $tb_resbook->where(array('orderid' => $orderid, 'token' => $token))->find();
     //根据订单号查出$order
     if ($checkOrder) {
         //如果订单存在
         if ($checkOrder['paid'] === 1) {
             //支付成功,发信息,跳转到订单别表页面
             $this->assign('type', $checkOrder['type']);
             $this->assign('token', $checkOrder['token']);
             $this->assign('wecha_id', $checkOrder['wecha_id']);
             //发送给商家
             Sms::sendSms($checkOrder['token'], "亲爱的,您的会员 {$checkOrder['truename']},已经购买了{$checkOrder['orderName']} 并付款成功,金额为{$checkOrder['payprice']},订单号为{$checkOrder['orderid']}. " . date('Y-m-d H:i:s', time()));
             //发给单个连锁商家
             // Sms::sendSms(token_商家ID, 短信内容);
             //发送给粉丝
             Sms::endSms($checkOrder['token'], "亲爱的 {$checkOrder['truename']},您购买的{$checkOrder['orderName']} 已经付款成功,金额为{$checkOrder['payprice']},订单号为{$checkOrder['orderid']},感谢您惠顾! " . date('Y-m-d H:i:s', time()), $checkOrder['tel']);
             self::mylist();
             exit;
         } else {
             //如果没支付,则进入另外一个判断,如果订单没有支付,这里应该回滚库存.setInc()
             M('busines_second')->where(array('sid' => $checkOrder['rid'], 'type' => $checkOrder['type'], 'token' => $checkOrder['token']))->setInc('googsnumber');
         }
     } else {
         // $this->redirect('Business/index', array('token'=>$this->_get('token'),
         //                                         'wecha_id'=>$this->_get('wecha_id'),'type'=>$this->_get('type'),'bid'=>$this->_get('bid'),
         //                                         'sid'=>$this->_get('sid')), 2, '您好,系统里没有该订单...');
         exit('订单不存在!');
     }
 }
示例#13
0
 /**
  * 提交订单
  */
 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());
         }
     }
 }
示例#14
0
 public function index()
 {
     $agent = $_SERVER['HTTP_USER_AGENT'];
     if (!strpos($agent, "icroMessenger")) {
         //echo '此功能只能在微信浏览器中使用';exit;
     }
     $cardid = intval($this->_get('cardid'));
     //$sql=D('Userinfo');
     $card = D('Member_card_create');
     $data['wecha_id'] = $this->_get('wecha_id');
     $data['token'] = $this->_get('token');
     //
     $cardInfoRow['wecha_id'] = $this->_get('wecha_id');
     $cardInfoRow['token'] = $this->_get('token');
     $cardInfoRow['cardid'] = $this->_get('cardid');
     $cardinfo = $card->where($cardInfoRow)->find();
     //是否领取过
     $this->assign('cardInfo', $cardinfo);
     //
     $member_card_set_db = M('Member_card_set');
     $thisCard = $member_card_set_db->where(array('token' => $this->_get('token'), 'id' => intval($_GET['cardid'])))->find();
     if (!$thisCard && $cardid) {
         exit;
     }
     //
     $sql = D('Userinfo');
     $userinfo = $sql->where($data)->find();
     if ($thisCard['memberinfo'] != false) {
         $img = $thisCard['memberinfo'];
     } else {
         $img = 'tpl/Wap/default/common/images/userinfo/fans.jpg';
     }
     $this->assign('cardnum', $cardinfo['number']);
     $this->assign('homepic', $img);
     $this->assign('info', $userinfo);
     $this->assign('cardid', $cardid);
     //redirect url
     if (isset($_GET['redirect'])) {
         $urlinfo = explode('|', $_GET['redirect']);
         $parmArr = explode(',', $urlinfo[1]);
         $parms = array('token' => $cardInfoRow['token'], 'wecha_id' => $cardInfoRow['wecha_id']);
         if ($parmArr) {
             foreach ($parmArr as $pa) {
                 $pas = explode(':', $pa);
                 $parms[$pas[0]] = $pas[1];
             }
         }
         $redirectUrl = U($urlinfo[0], $parms);
         $this->assign('redirectUrl', $redirectUrl);
     }
     //
     if (IS_POST) {
         //如果有post提交,说明是修改
         $data['wechaname'] = $this->_post('wechaname');
         $data['tel'] = $this->_post('tel');
         if (empty($data['tel'])) {
             $this->error("手机号必填。");
             exit;
         }
         $data['truename'] = $this->_post('truename');
         $data['qq'] = $this->_post('qq');
         $data['sex'] = $this->_post('sex');
         $data['bornyear'] = $this->_post('bornyear');
         $data['bornmonth'] = $this->_post('bornmonth');
         $data['bornday'] = $this->_post('bornday');
         $data['portrait'] = $this->_post('portrait');
         //如果会员卡不为空[更新]
         //写入两个表 Userinfo Member_card_create
         if ($cardid == 0) {
             $infoWhere = array();
             $infoWhere['wecha_id'] = $data['wecha_id'];
             $infoWhere['token'] = $data['token'];
             $userInfoExist = M('Userinfo')->where($infoWhere)->find();
             if ($userInfoExist) {
                 M('Userinfo')->where($infoWhere)->save($data);
             } else {
                 M('Userinfo')->add($data);
             }
             S('fans_' . $this->token . '_' . $this->wecha_id, NULL);
             echo 1;
             exit;
         } else {
             if ($cardinfo) {
                 //如果Member_card_create 不为空,说明领过卡,但是可以修改会员信息
                 $update['wecha_id'] = $data['wecha_id'];
                 $update['token'] = $data['token'];
                 unset($data['wecha_id']);
                 unset($data['token']);
                 if (M('Userinfo')->where($update)->save($data)) {
                     S('fans_' . $this->token . '_' . $this->wecha_id, NULL);
                     echo 1;
                     exit;
                 } else {
                     echo 0;
                     exit;
                 }
             } else {
                 Sms::sendSms($this->token, '有新的会员领了会员卡');
                 $card = M('Member_card_create')->field('id,number')->where("token='" . $this->_get('token') . "' and cardid=" . intval($_POST['cardid']) . " and wecha_id = ''")->order('id ASC')->find();
                 //
                 $userinfo_db = M('Userinfo');
                 $userInfos = $userinfo_db->where(array('token' => $this->_get('token'), 'wecha_id' => $this->_get('wecha_id')))->select();
                 $userScore = 0;
                 if ($userInfos) {
                     $userScore = intval($userInfos[0]['total_score']);
                     $userInfo = $userInfos[0];
                 }
                 if (!$card) {
                     echo 3;
                     exit;
                 } else {
                     //
                     if (intval($thisCard['miniscore']) == 0 || $userScore > intval($thisCard['minscore'])) {
                         M('Member_card_create')->where(array('token' => $this->_get('token'), 'wecha_id' => $this->_get('wecha_id')))->delete();
                         $card_up = M('Member_card_create')->where(array('id' => $card['id']))->save(array('wecha_id' => $this->_get('wecha_id')));
                         $data['getcardtime'] = time();
                         if ($userinfo) {
                             $update['wecha_id'] = $data['wecha_id'];
                             $update['token'] = $data['token'];
                             M('Userinfo')->where($update)->save($data);
                         } else {
                             M('Userinfo')->data($data)->add();
                         }
                         S('fans_' . $this->token . '_' . $this->wecha_id, NULL);
                         echo 2;
                         exit;
                     } else {
                         echo 4;
                         exit;
                     }
                 }
             }
             //post
         }
     } else {
         $this->display();
     }
 }
示例#15
0
 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('订单不存在');
     }
 }
示例#16
0
 /**
  * 订单详情
  */
 public function orderInfo()
 {
     $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $hotelOrder = M('Hotels_order');
     if ($thisOrder = $hotelOrder->where(array('id' => $id, 'token' => $this->token, 'cid' => $this->_cid))->find()) {
         if (IS_POST) {
             $status = isset($_POST['status']) ? intval($_POST['status']) : 0;
             $paid = isset($_POST['paid']) ? intval($_POST['paid']) : 0;
             $hotelOrder->where(array('id' => $thisOrder['id']))->save(array('status' => $status, 'paid' => $paid));
             $company = M('Company')->where(array('token' => $this->token, 'id' => $this->_cid))->find();
             Sms::sendSms($this->token, "{$company['name']}欢迎您,本店对您的订单号为:{$thisOrder['orderid']}的订单状态进行了修改,如有任何疑意,请您及时联系本店!", $thisOrder['tel']);
             $this->success('修改成功', U('Hotels/orderInfo', array('token' => session('token'), 'id' => $thisOrder['id'])));
         } else {
             $sort = M('Hotels_house_sort')->where(array('cid' => $this->_cid, 'token' => $this->token, 'id' => $thisOrder['sid']))->find();
             $thisOrder['housename'] = isset($sort['name']) ? $sort['name'] : '';
             $this->assign('thisOrder', $thisOrder);
             $this->display();
         }
     }
 }
示例#17
0
 public function checkreg()
 {
     $db = D('Users');
     $info = M('User_group')->find(1);
     $verifycode = $this->_post('verifycode', 'intval,md5', 0);
     if (isset($_POST['verifycode'])) {
         if ($verifycode != $_SESSION['verify']) {
             $this->error('验证码错误', U('Index/login'));
         }
     }
     if (isset($_POST['mp'])) {
         if (!preg_match('/^13[0-9]{9}$|^15[0-9]{9}$|^18[0-9]{9}$/', trim($_POST['mp']))) {
             $this->error('手机号填写不正确', U('Index/login'));
         }
     }
     if ($this->isAgent) {
         $_POST['agentid'] = $this->thisAgent['id'];
     }
     if (isset($_POST['invitecode'])) {
         //$_POST['invitecode']=$this->_get('invitecode');
         $inviteCode = $this->_post('invitecode');
         if ($inviteCode && !ctype_alpha($inviteCode)) {
             exit('invitecode colud not include other letter');
         }
         $inviter = $db->where(array('invitecode' => $inviteCode))->find();
         $_POST['inviter'] = intval($inviter['id']);
     } else {
         $_POST['inviter'] = 0;
     }
     $_POST['invitecode'] = $this->randStr(6);
     if ($db->create()) {
         $id = $db->add();
         if ($id) {
             Sms::sendSms('admin', '有新用户注册了', $this->adminMp);
             if ($this->isAgent) {
                 $usercount = M('Users')->where(array('agentid' => $this->thisAgent['id']))->count();
                 M('Agent')->where(array('id' => $this->thisAgent['id']))->save(array('usercount' => $usercount));
             }
             if ($this->reg_needCheck) {
                 $gid = $this->minGroupid;
                 if (C('demo')) {
                     session('preuid', $id);
                     $this->success('注册成功,请关注我们公众号获取使用权限', U('Index/qrcode'));
                     exit;
                 } else {
                     $this->success('注册成功,请联系在线客服审核帐号', U('User/Index/index'));
                     exit;
                 }
             } else {
                 $viptime = time() + intval($this->reg_validDays) * 24 * 3600;
                 $gid = $this->minGroupid;
                 if ($this->reg_groupid) {
                     $gid = intval($this->reg_groupid);
                 }
                 $db->where(array('id' => $id))->save(array('viptime' => $viptime, 'status' => 1, 'gid' => $gid));
             }
             session('uid', $id);
             session('gid', $gid);
             session('uname', $_POST['username']);
             session('diynum', 0);
             session('connectnum', 0);
             session('activitynum', 0);
             session('gname', $info['name']);
             // $smtpserver = C('email_server');
             // $port = C('email_port');
             // $smtpuser = C('email_user');
             // $smtppwd = C('email_pwd');
             // $mailtype = "TXT";
             // $sender = C('email_user');
             // $smtp = new Smtp($smtpserver,$port,true,$smtpuser,$smtppwd,$sender);
             // $to = $list['email'];
             // $subject = C('reg_email_title');
             // $code = C('site_url').U('User/Index/checkFetchPass?uid='.$list['id'].'&code='.md5($list['id'].$list['password'].$list['email']));
             // $fetchcontent = C('reg_email_content');
             // $fetchcontent = str_replace('{username}',$where['username'],$fetchcontent);
             // $fetchcontent = str_replace('{time}',date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']),$fetchcontent);
             // $fetchcontent = str_replace('{code}',$code,$fetchcontent);
             // $body=$fetchcontent;
             //$body = iconv('UTF-8','gb2312',$fetchcontent);
             // $send=$smtp->sendmail($to,$sender,$subject,$body,$mailtype);
             $this->success('注册成功', U('User/Index/index'));
         } else {
             $this->error('注册失败', U('Index/login'));
         }
     } else {
         $this->error($db->getError(), U('Index/login'));
     }
 }
示例#18
0
 public function orderInfo()
 {
     $this->product_model = M('Product');
     $this->product_cat_model = M('Product_cat');
     $product_cart_model = M('product_cart');
     $thisOrder = $product_cart_model->where(array('id' => intval($_GET['id'])))->find();
     //检查权限
     if (strtolower($thisOrder['token']) != strtolower($this->_session('token'))) {
         exit;
     }
     if (IS_POST) {
         if (intval($_POST['sent'])) {
             $_POST['handled'] = 1;
         }
         $product_cart_model->where(array('id' => $thisOrder['id']))->save(array('sent' => intval($_POST['sent']), 'paid' => intval($_POST['paid']), 'logistics' => $_POST['logistics'], 'logisticsid' => $_POST['logisticsid'], 'handled' => 1));
         //TODO 发货的短信提醒
         if ($_POST['sent']) {
             $company = D('Company')->where(array('token' => $thisOrder['token'], 'isbranch' => 0))->find();
             $userInfo = D('Userinfo')->where(array('token' => $thisOrder['token'], 'wecha_id' => $thisOrder['wecha_id']))->find();
             Sms::sendSms($this->token, "您在{$company['name']}商城购买的商品,商家已经给您发货了,请您注意查收", $userInfo['tel']);
         }
         //
         /************************************************/
         if (intval($_POST['paid']) && intval($thisOrder['price'])) {
             $member_card_create_db = M('Member_card_create');
             $wecha_id = $thisOrder['wecha_id'];
             $userCard = $member_card_create_db->where(array('token' => $this->token, 'wecha_id' => $wecha_id))->find();
             $member_card_set_db = M('Member_card_set');
             $thisCard = $member_card_set_db->where(array('id' => intval($userCard['cardid'])))->find();
             $set_exchange = M('Member_card_exchange')->where(array('cardid' => intval($thisCard['id'])))->find();
             //
             $arr['token'] = $this->token;
             $arr['wecha_id'] = $wecha_id;
             $arr['expense'] = $thisOrder['price'];
             $arr['time'] = time();
             $arr['cat'] = 99;
             $arr['staffid'] = 0;
             $arr['score'] = intval($set_exchange['reward']) * $order['price'];
             M('Member_card_use_record')->add($arr);
             $userinfo_db = M('Userinfo');
             $thisUser = $userinfo_db->where(array('token' => $thisCard['token'], 'wecha_id' => $arr['wecha_id']))->find();
             $userArr = array();
             $userArr['total_score'] = $thisUser['total_score'] + $arr['score'];
             $userArr['expensetotal'] = $thisUser['expensetotal'] + $arr['expense'];
             $userinfo_db->where(array('token' => $thisCard['token'], 'wecha_id' => $arr['wecha_id']))->save($userArr);
         }
         /************************************************/
         //
         $this->success('修改成功', U('Store/orderInfo', array('token' => session('token'), 'id' => $thisOrder['id'])));
     } else {
         //订餐信息
         $product_diningtable_model = M('product_diningtable');
         if ($thisOrder['tableid']) {
             $thisTable = $product_diningtable_model->where(array('id' => $thisOrder['tableid']))->find();
             $thisOrder['tableName'] = $thisTable['name'];
         }
         //
         $this->assign('thisOrder', $thisOrder);
         $carts = unserialize($thisOrder['info']);
         //
         $totalFee = 0;
         $totalCount = 0;
         $data = $this->getCat($carts);
         if (isset($data[1])) {
             foreach ($data[1] as $pid => $row) {
                 $totalCount += $row['total'];
                 $totalFee += $row['totalPrice'];
                 $listNum[$pid] = $row['total'];
             }
         }
         $list = $data[0];
         //			print_r($list);die;
         $this->assign('products', $list);
         //
         $this->assign('totalFee', $totalFee);
         //
         $this->assign('totalCount', $totalCount);
         $this->display();
     }
 }
示例#19
0
 /**
  * 订单详情
  */
 public function orderInfo()
 {
     $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $dishOrder = M('Dish_order');
     if ($thisOrder = $dishOrder->where(array('id' => $id, 'token' => $this->token))->find()) {
         if (IS_POST) {
             $isuse = isset($_POST['isuse']) ? intval($_POST['isuse']) : 0;
             $paid = isset($_POST['paid']) ? intval($_POST['paid']) : 0;
             $dishOrder->where(array('id' => $thisOrder['id']))->save(array('isuse' => $isuse, 'paid' => $paid));
             if ($thisOrder['tableid'] && $isuse) {
                 D('Dish_table')->where(array('orderid' => $thisOrder['id']))->save(array('isuse' => 1));
             }
             $company = M('Company')->where(array('token' => $this->token, 'id' => $this->_cid))->find();
             Sms::sendSms($this->token, "{$company['name']}欢迎您,本店对您的订单号为:{$thisOrder['orderid']}的订单状态进行了修改,如有任何疑意,请您及时联系本店!", $thisOrder['tel']);
             $this->success('修改成功', U('Repast/orderInfo', array('token' => session('token'), 'id' => $thisOrder['id'])));
         } else {
             $dishList = unserialize($thisOrder['info']);
             $this->assign('thisOrder', $thisOrder);
             $this->assign('dishList', $dishList);
             $this->display();
         }
     }
 }
示例#20
0
 public function payReturn(){
     $orderid = $_GET['orderid'];
     if ($order = M('dish_order') -> where(array('orderid' => $orderid, 'token' => $this -> token)) -> find()){
         if ($order['paid']){
             Sms :: sendSms($this -> token . "_" . $this -> _cid, "顾客{$order['name']}刚刚对订单号:{$orderid}的订单进行了支付,请您注意查看并处理【云信使】");
         }
         $this -> redirect(U('Repast/myOrder', array('token' => $this -> token, 'wecha_id' => $this -> wecha_id, 'cid' => $this -> _cid)));
     }else{
         exit('订单不存在');
     }
 }
示例#21
0
 public function payReturn()
 {
     $tb_resbook = D('reservebook');
     $orderid = filter_var($this->_get('orderid'), FILTER_SANITIZE_STRING);
     $token = filter_var($this->_get('token'), FILTER_SANITIZE_STRING);
     $checkOrder = $tb_resbook->where(array('orderid' => $orderid, 'token' => $token))->find();
     //根据订单号查出$order
     if ($checkOrder) {
         if ($checkOrder['paid'] === 1) {
             $this->assign('type', $checkOrder['type']);
             $this->assign('token', $checkOrder['token']);
             $this->assign('wecha_id', $checkOrder['wecha_id']);
             Sms::sendSms($checkOrder['token'], "您的会员 {$checkOrder['truename']},已经购买了{$checkOrder['orderName']} 并付款成功,金额为{$checkOrder['payprice']},订单号为{$checkOrder['orderid']}。" . date('Y-m-d H:i:s', time()));
             Sms::sendSms($checkOrder['token'], "尊敬的 {$checkOrder['truename']},您购买的{$checkOrder['orderName']} 已经付款成功,金额为{$checkOrder['payprice']},订单号为{$checkOrder['orderid']}。 " . date('Y-m-d H:i:s', time()), $checkOrder['tel']);
             self::mylist();
             exit;
         } else {
             M('busines_second')->where(array('sid' => $checkOrder['rid'], 'type' => $checkOrder['type'], 'token' => $checkOrder['token']))->setInc('googsnumber');
             //货到付款、店到支付直接跳转
             redirect(U('Business/mylist', array('type' => $checkOrder['type'], 'token' => $checkOrder['token'])));
         }
     } else {
         exit('订单不存在!');
     }
 }
示例#22
0
 public function payReturn()
 {
     $tb_resbook = D('Medical_user');
     $orderid = filter_var($this->_get('orderid'), FILTER_SANITIZE_STRING);
     $token = filter_var($this->_get('token'), FILTER_SANITIZE_STRING);
     $checkOrder = $tb_resbook->where(array('orderid' => $orderid, 'token' => $token))->find();
     //根据订单号查出$order
     if ($checkOrder) {
         //如果订单存在
         if ($checkOrder['paid'] == '1') {
             //支付成功,发信息,跳转到订单别表页面
             $this->assign('token', $checkOrder['token']);
             $this->assign('wecha_id', $checkOrder['wecha_id']);
             Sms::sendSms($checkOrder['token'], "您的会员 {$checkOrder['truename']},已经预约了{$checkOrder['orderName']} 并付款成功,金额为{$checkOrder['price']},订单号为{$checkOrder['orderid']}. " . date('Y-m-d H:i:s', time()));
             Sms::sendSms($checkOrder['token'], " {$checkOrder['truename']},您购买的{$checkOrder['orderName']} 已经付款成功,金额为{$checkOrder['price']},订单号为{$checkOrder['orderid']}! " . date('Y-m-d H:i:s', time()), $checkOrder['utel']);
             $this->redirect('Medical/ReserveBooking', array('token' => $token, 'wecha_id' => $wecha_id), 1, '恭喜预约成功,请不要重复刷新页面...');
             exit;
         } else {
             $this->redirect('Medical/registered', array('token' => $token, 'wecha_id' => $checkOrder['wecha_id']), 3, '您好,支付失败,请重新下单,请不要重复刷新页面,请耐心等待...');
         }
     } else {
         exit('订单不存在!');
     }
 }
示例#23
0
 public function get_code()
 {
     $code_db = M('Sms_code');
     $code = $this->_create_code();
     $phone = $this->_post('phone');
     $data['code'] = $code;
     $data['token'] = $this->token;
     $data['wecha_id'] = $this->wecha_id;
     $data['create_time'] = time();
     $data['action'] = 'userCard';
     $result = array();
     $where = array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'action' => $data['action']);
     $last_info = $code_db->where($where)->order('create_time desc')->find();
     if (time() < $last_info['create_time'] + 60) {
         $result['error'] = -1;
         $result['info'] = '请不要频繁获取效验码';
     } else {
         $code_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'action' => $data['action'], 'is_use' => '0'))->save(array('is_use' => '1'));
         if ($code_db->add($data)) {
             $msg = '您的领卡效验码为:' . $code . ',验证码5分钟内有效,如非本人操作,请无视这条消息。';
             $result['error'] = 0;
             $result['info'] = '';
             Sms::sendSms($this->token, $msg, $phone);
         }
     }
     echo json_encode($result);
 }
示例#24
0
	public function method()
	{
		if (!empty($this->_params['mobile'])) {
			return Sms::sendSms($this->_params['token'], $this->_params['content'], $this->_params['mobile']);
		}
	}
示例#25
0
 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);
 }
示例#26
0
 public function orderCart()
 {
     $this->noaccess();
     $userinfo_model = D('Userinfo');
     $thisUser = $userinfo_model->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
     $this->assign('thisUser', $thisUser);
     //是否要支付
     $alipay_config_db = M('Alipay_config');
     $alipayConfig = $alipay_config_db->where(array('token' => $this->token))->find();
     $this->assign('alipayConfig', $alipayConfig);
     //
     if (IS_POST) {
         $row = array();
         //2015-05-30 创建订单之前判断虚拟商品是否足够
         $row['sn'] = 0;
         $sn = M('Product')->where(array('token' => $this->token, 'id' => (int) $_POST['productid']))->getField('sn');
         if ($sn) {
             $where['sendstutas'] = 0;
             $where['order_id'] = 0;
             $where['pid'] = (int) $_POST['productid'];
             $where['token'] = $this->token;
             $count = M('ProductSn')->where($where)->count();
             if ($count < (int) $_POST['quantity']) {
                 $this->error('虚拟商品库存不足');
                 exit;
             }
             $row['sn'] = 1;
         } else {
             $num = M('Product')->where(array('token' => $this->token, 'id' => (int) $_POST['productid']))->getField('groupon_num');
             if ($_POST['quantity'] > $num) {
                 $this->error('商品库存不足');
                 exit;
             }
         }
         $orderid = $this->randStr(4) . time();
         $row['orderid'] = $orderid;
         //
         $row['truename'] = $this->_post('truename');
         $row['tel'] = $this->_post('tel');
         $row['address'] = $this->_post('address');
         $row['token'] = $this->token;
         $row['wecha_id'] = $this->wecha_id;
         if (!$row['wecha_id']) {
             $row['wecha_id'] = 'null';
         }
         $time = time();
         $row['time'] = $time;
         //分别加入3类订单
         $product_cart_model = M('product_cart');
         $row['total'] = intval($_POST['quantity']);
         $row['price'] = $row['total'] * floatval($_POST['price']);
         $row['diningtype'] = 0;
         $row['productid'] = intval($_POST['productid']);
         $row['code'] = substr($row['wecha_id'], 0, 6) . $time;
         $row['tableid'] = 0;
         $row['info'] = serialize(array(intval($_POST['productid']) => array('count' => $row['total'], 'price' => intval($_POST['price']))));
         $row['groupon'] = 1;
         $row['dining'] = 0;
         $product_cart_model->add($row);
         //。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
         $product_model = M('product');
         $product_cart_list_model = M('product_cart_list');
         $product_model->where(array('id' => intval($_POST['productid'])))->setInc('salecount', $_POST['quantity']);
         $productName = $product_model->where(array('id' => intval($_POST['productid'])))->getField('name');
         //保存个人信息
         if ($_POST) {
             $userRow = array('tel' => $row['tel'], 'truename' => $row['truename'], 'address' => $row['address']);
             if ($thisUser) {
                 $userinfo_model->where(array('id' => $thisUser['id']))->save($userRow);
             } else {
                 $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);
             }
         }
         $orderName = '团购-' . $productName;
         if ($this->_post('paytype') == 1) {
             $this->redirect(U('CardPay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'single_orderid' => $orderid)));
             Sms::sendSms($this->token, '您在微信上有新的团购订单');
             exit;
         }
         if ($alipayConfig['open']) {
             //$this->printOrder($orderid);
             if ($row['sn'] == 1) {
                 $this->success('提交成功,转向支付页面', U('Alipay/pay', array('notOffline' => 1, 'token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'orderid' => $orderid)));
             } else {
                 $this->success('提交成功,转向支付页面', U('Alipay/pay', array('token' => $this->token, 'wecha_id' => $this->wecha_id, 'success' => 1, 'price' => $row['price'], 'from' => 'Groupon', 'orderName' => $orderName, 'orderid' => $orderid)));
             }
         } else {
             Sms::sendSms($this->token, '您在微信上有新的团购订单');
             //$this->printOrder($orderid);
             $this->redirect(U('Groupon/my', array('token' => $_GET['token'], 'wecha_id' => $_GET['wecha_id'], 'success' => 1)));
         }
     } else {
         $where = array('token' => $this->token);
         if (isset($_GET['id'])) {
             $id = intval($_GET['id']);
             $where['id'] = $id;
         }
         if ($this->wxuser['winxintype'] == 3 && $this->wxuser['oauth'] == 1) {
             $addr = new WechatAddr($this->wxuser);
             $this->assign('addrSign', $addr->addrSign());
         }
         $product = $this->product_model->where($where)->find();
         $this->assign('product', $product);
         $this->display('orderCart_' . $this->tplid);
     }
 }
示例#27
0
 public function saveorder()
 {
     //判断登录
     if (empty($this->user_session)) {
         $this->assign('jumpUrl', U('Index/Login/index'));
         $this->error('请先登录!');
     }
     $store_id = intval($_POST['store_id']);
     $store = D('Merchant_store')->where(array('store_id' => $store_id))->find();
     if (empty($store)) {
         exit(json_encode(array('error_code' => 1, 'msg' => '您查看的餐厅不存在!')));
     }
     if (empty($this->user_session)) {
         exit(json_encode(array('error_code' => 1, 'msg' => '请先进行登录!', 'data' => U('Login/index'))));
     }
     // 		$phone = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '';
     // 		$name = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
     $address_id = isset($_POST['address_id']) ? intval($_POST['address_id']) : 0;
     $note = isset($_POST['note']) ? htmlspecialchars($_POST['note']) : '';
     if (empty($address_id)) {
         exit(json_encode(array('error_code' => 1, 'msg' => '联系信息不能为空')));
     }
     $now_adress = D('User_adress')->get_one_adress($this->user_session['uid'], $address_id);
     if (empty($now_adress)) {
         exit(json_encode(array('error_code' => 1, 'msg' => '请先添加联系信息!')));
     }
     $products = isset($_POST['products']) ? $_POST['products'] : '';
     if (empty($products)) {
         exit(json_encode(array('error_code' => 1, 'msg' => '您还没有点菜')));
     }
     $total = $price = 0;
     if ($products) {
         // 			$info = array();
         // 			foreach ($products as $m) {
         // 				$info[] = array('id' => $m['id'],'name' => $m['name'], 'num' => $m['number'], 'price' => $m['price']);
         // 				$total += $m['number'];
         // 				$price += $m['number'] * $m['price'];
         // 			}
         $temp = explode(":", $products);
         $store_id = $temp[0];
         $menus = explode("|", $temp[1]);
         $ids = $list = array();
         $food_count = 0;
         foreach ($menus as $m) {
             $t = explode(",", $m);
             $ids[] = $t[0];
             $list[$t[0]] = $t[1];
             $food_count += $t[1];
         }
         $meals = D("Meal")->field(true)->where(array('store_id' => $store_id, 'meal_id' => array('in', $ids)))->select();
         $info = array();
         foreach ($meals as $m) {
             $info[] = array('id' => $m['meal_id'], 'name' => $m['name'], 'num' => $list[$m['meal_id']], 'price' => $m['price']);
             $total += $list[$m['meal_id']];
             $price += $list[$m['meal_id']] * $m['price'];
         }
     }
     //用户等级 优惠
     $finaltotalprice = 0;
     $level_off = false;
     $store_meal = D('Merchant_store_meal')->where(array('store_id' => $store_id))->find();
     if (!empty($this->user_level) && !empty($store_meal) && !empty($store_meal['leveloff'])) {
         $leveloff = unserialize($store_meal['leveloff']);
         if (!empty($this->user_session) && isset($this->user_session['level'])) {
             /****type:0无优惠 1百分比 2立减*******/
             if (!empty($leveloff) && is_array($leveloff) && isset($this->user_level[$this->user_session['level']]) && isset($leveloff[$this->user_session['level']])) {
                 $level_off = $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'] . '元';
                 }
             }
         }
         unset($leveloff);
     }
     $price = $finaltotalprice > 0 ? round($finaltotalprice, 2) : $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'];
     }
     is_array($level_off) && ($level_off['totalprice'] = $price);
     $data = array('mer_id' => $store['mer_id'], 'store_id' => $store_id, 'name' => $now_adress['name'], 'phone' => $now_adress['phone'], 'address' => $now_adress['province_txt'] . $now_adress['city_txt'] . $now_adress['area_txt'] . $now_adress['adress'], 'note' => $note, 'info' => serialize($info), 'dateline' => time(), 'total' => $total, 'price' => $price);
     $data['total_price'] = $total_price;
     $data['minus_price'] = $minus_price;
     $data['orderid'] = $store['mer_id'] . $store_id . date("YmdHis") . rand(1000000, 9999999);
     $data['uid'] = $this->user_session['uid'];
     $level_off && is_array($level_off) && ($data['leveloff'] = serialize($level_off));
     $orderid = D("Meal_order")->add($data);
     if ($orderid) {
         $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'] = $store['name'];
         $msg['store_phone'] = $store['phone'];
         $msg['store_address'] = $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($store['mer_id'], $store['store_id'], $msg, 0);
         $sms_data = array('mer_id' => $store['mer_id'], 'store_id' => $store['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'] = '您在' . $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'] = $store['phone'];
             $sms_data['sendto'] = 'merchant';
             $sms_data['content'] = '客户' . $data['name'] . '刚刚下了一个订单,订单号:' . $orderid . ',请您注意查看并处理';
             Sms::sendSms($sms_data);
         }
         session('shop_cart', null);
         exit(json_encode(array('error_code' => 0, 'msg' => '', 'data' => U('Index/Pay/check', array('order_id' => $orderid, 'type' => 'meal')))));
     } else {
         exit(json_encode(array('error_code' => 1, 'msg' => D("Meal_order")->getError())));
     }
 }
示例#28
0
 /**
  * 订单详情
  */
 public function orderInfo()
 {
     $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $fd = $this->_get('fd') ? $this->_get('fd', 'trim') : '';
     $cidd = $this->_get('cidd') ? intval($this->_get('cidd', 'trim')) : 0;
     $cid = $this->_cid;
     if ($fd == 'on' && $cidd > 0) {
         $cid = $cidd;
         $this->assign('isfd', true);
     }
     $dishOrder = M('Dish_order');
     if ($thisOrder = $dishOrder->where(array('id' => $id, 'cid' => $cid, 'token' => $this->token, 'comefrom' => 'dish'))->find()) {
         if (IS_POST) {
             $isuse = isset($_POST['isuse']) ? intval($_POST['isuse']) : 0;
             $paid = isset($_POST['paid']) ? intval($_POST['paid']) : 0;
             $dishOrder->where(array('id' => $thisOrder['id']))->save(array('isuse' => $isuse, 'paid' => $paid));
             if ($thisOrder['tableid'] && $isuse) {
                 D('Dish_table')->where(array('orderid' => $thisOrder['id']))->save(array('isuse' => 1));
             }
             $company = M('Company')->where(array('token' => $this->token, 'id' => $thisOrder['cid']))->find();
             if ($paid && empty($thisOrder['paid'])) {
                 $temp = unserialize($thisOrder['info']);
                 $temp = isset($temp['list']) ? $temp['list'] : $temp;
                 $this->saleLog(array('cid' => $cid, 'oid' => $thisOrder['id'], 'paytype' => $thisOrder['paytype'], 'dish' => $temp, 'time' => $thisOrder['time'], 'paycount' => $thisOrder['paycount']));
                 $takeAwayPrice = isset($temp['takeAwayPrice']) ? $temp['takeAwayPrice'] : '';
                 $bookTable = false;
                 if (isset($temp['table']) && !empty($temp['table'])) {
                     $bookTable = $temp['table']['price'];
                     unset($temp['table']);
                 }
                 $op = new orderPrint();
                 $msg = array('companyname' => $company['name'], 'des' => $thisOrder['des'], 'companytel' => $company['tel'], 'truename' => $thisOrder['name'], 'tel' => $thisOrder['tel'], 'takeAwayPrice' => $takeAwayPrice, 'address' => $thisOrder['address'], 'buytime' => $thisOrder['time'], 'orderid' => $thisOrder['orderid'], 'price' => $thisOrder['price'], 'total' => $thisOrder['nums'], 'ptype' => $thisOrder['paytype'], 'list' => $temp, 'bookTable' => $bookTable);
                 $msg['typename'] = $thisOrder['takeaway'] == 1 ? '外卖' : ($thisOrder['takeaway'] == 2 ? '现在点餐' : '预约点餐');
                 if ($thisOrder['takeaway'] == 0) {
                     $tmpstr = $this->GetCanTimeByoid($cid, $thisOrder['id'], $thisOrder['tableid']);
                     $msg['reservestr'] = $tmpstr ? date('Y-m-d', $order['reservetime']) . ' ' . $tmpstr : date('Y-m-d H:i', $thisOrder['reservetime']);
                 }
                 if ($thisOrder['tableid']) {
                     $t_table = M("Dining_table")->where(array('id' => $thisOrder['tableid']))->find();
                     $msg['tablename'] = isset($t_table['name']) ? $t_table['name'] : '';
                 }
                 $msg = ArrayToStr::array_to_str($msg, 1);
                 $op->printit($this->token, $this->_cid, 'Repast', $msg, 1);
             }
             Sms::sendSms($this->token, "{$company['name']}欢迎您,本店对您的订单号为:{$thisOrder['orderid']}的订单状态进行了修改,如有任何疑意,请您及时联系本店!", $thisOrder['tel']);
             $this->success('修改成功', U('Repast/orderInfo', array('token' => session('token'), 'id' => $thisOrder['id'])));
         } else {
             $payarr = array('alipay' => '支付宝', 'weixin' => '微信支付', 'tenpay' => '财付通[wap手机]', 'tenpaycomputer' => '财付通[即时到帐]', 'yeepay' => '易宝支付', 'allinpay' => '通联支付', 'daofu' => '货到付款', 'dianfu' => '到店付款', 'chinabank' => '网银在线');
             $paystr = strtolower($thisOrder['paytype']);
             $thisOrder['paystr'] = !empty($paystr) && array_key_exists($paystr, $payarr) ? $payarr[$paystr] : '其他';
             $dishList = unserialize($thisOrder['info']);
             $dishList = isset($dishList['list']) ? $dishList['list'] : $dishList;
             $this->assign('thisOrder', $thisOrder);
             $this->assign('dishList', $dishList);
             $this->display();
         }
     }
 }
示例#29
0
 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":"执行成功"}';
 }
示例#30
0
 /**
  * 提交订单
  */
 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());
         }
     }
 }