public function autofahuo($id) { /*更改为自动收货*/ M("Order")->where(array('orderid' => $id))->save(array('order_status' => 2)); //自动设置为已发货状态 $order_info = M("Order")->where(array('orderid' => $id))->find(); //传输过来订单ID,查询到userid $user_info = M("User")->where(array('id' => $order_info['user_id']))->find(); //更改上级状态为已收货 $active_time = date('Y-m-d H:i:s'); M("Order_level")->where(array('order_id' => $id))->save(array('status' => 2, 'active_time' => $active_time)); if (!empty($user_info)) { $order_info = json_decode($result['order_info'], true); $data = array(); $data['touser'] = $user_info['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '恭喜您成功购买软件,现在您可以使用微商云订单全部功能。 点击 <a href="http://' . $_SERVER['SERVER_NAME'] . '/index.php?g=App&m=Index&a=goods"> 微商云订单</a> 点击<a href="http://' . $_SERVER['SERVER_NAME'] . '/index.php?g=App&m=Index&a=member">我的主页</a>'; import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $weObj->sendCustomMessage($data); } }
public function autofahuo($id) { M("Order")->where(array('orderid' => $id))->save(array('order_status' => 1)); //自动设置为已发货状态 $order_info = M("Order")->where(array('orderid' => $id))->find(); //传输过来订单ID,查询到userid $user_info = M("User")->where(array('id' => $order_info['user_id']))->find(); if (!empty($user_info)) { $order_info = json_decode($result['order_info'], true); $data = array(); $data['touser'] = $user_info['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '恭喜您成功购买软件,今天起作自己的老板,现在您可以使用您的特权,可以分享赚米。点击生成【<a href="http://' . $_SERVER['SERVER_NAME'] . '/index.php?a=my_ticket">推广二维码</a>】,在【我的订单】中点击【确认收货】后,您才可以进行积分兑换。 您代理的产品达成交易后,您将获得【12积分】 您的一级员工达成交易后,您将获得【3积分】 您的二级员工达成交易后,您将获得【2积分】'; import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $weObj->sendCustomMessage($data); } }
function register() { if (IS_POST) { if (!$_POST['login']) { $this->error("请输入用户名"); exit; } else { $map['login'] = $_POST['login']; $check = M("User")->where($map)->find(); if (!empty($check)) { $this->error("该用户名已存在!请重新输入"); exit; } } if (!$_POST['password']) { $this->error("请输入登陆密码"); exit; } $_POST['uid'] = rand(); $_POST['password'] = md5($_POST['password']); $id = M("User")->add($_POST); $new_user_id = $id; $user = array(); $user['uid'] = $id; $wx_info = json_encode(array('nickname' => $map['login'], 'subscribe_time' => time())); $user['wx_info'] = $wx_info; if ($_GET['mid']) { $m = M("User"); include dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/Public/Conf/button_config.php'; $where = array(); $where["id"] = (int) $_GET['mid']; $results = $m->where($where)->find(); if (!empty($results['id'])) { import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $user["l_id"] = $results['id']; //增加分销人 $a_info = array(); $a_info['id'] = $results['id']; $a_info['a_cnt'] = $results['a_cnt'] + 1; $user_id = M("User")->save($a_info); if (strlen($results['uid']) > 10) { $data = array(); $data['touser'] = $results['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $map[login] . '】通过分享链接,成为您的' . $message_name . '家族成员!'; $weObj->sendCustomMessage($data); } if ($results['l_id']) { $where = array(); $where["id"] = $results['l_id']; $b_results = $m->where($where)->find(); if (!empty($b_results)) { $b_info = array(); $b_info['id'] = $b_results['id']; $b_info['b_cnt'] = $b_results['b_cnt'] + 1; $user_id = M("User")->save($b_info); $user["l_b"] = $b_results['id']; if (strlen($b_results['uid']) > 10) { $data = array(); $data['touser'] = $b_results["uid"]; $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $map[login] . '】通过分享链接,成为您的' . $message_name . '家族成员!'; $weObj->sendCustomMessage($data); } if ($b_results['l_id']) { $where = array(); $where["id"] = $b_results['l_id']; $c_results = $m->where($where)->find(); if (!empty($c_results)) { $c_info = array(); $c_info['id'] = $c_results['id']; $c_info['c_cnt'] = $c_results['c_cnt'] + 1; $user_id = M("User")->save($c_info); $user["l_c"] = $c_results['id']; if (strlen($c_results['uid']) > 10) { $data = array(); $data['touser'] = $c_results["uid"]; $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $map[login] . '】通过分享链接,成为您的' . $message_name . '家族成员!'; $weObj->sendCustomMessage($data); } } } } } } } M("User")->where($map)->save($user); $_SESSION["uid"] = $new_user_id; $this->success("登陆成功!", U('App/Index/member', array("uid" => $id))); exit; } $this->display("./default/Index/member_register"); }
/** * 推送积分 */ public function pushpoints() { $id = $_GET["id"]; import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $userinfo = M("User")->where(array('id' => $id))->find(); if ($userinfo['member'] == 1) { $this->error("该会员已经推送过积分不支持该操作"); } $info = json_decode($userinfo['wx_info'], true); //一级成员信息 $data['id'] = $id; $data['member'] = 1; M('User')->save($data); //会员添加订单 $orderid = date("YmdHis") . mt_rand(1, 9); $cartdata = '[{"name":"微商云订单","num":"1","price":"29.9","id":"22"}]'; $data["user_id"] = $id; $data["orderid"] = $orderid; $data["totalprice"] = "29.9"; $data["pay_style"] = "微信支付"; $data["pay_status"] = "1"; $data["note"] = '虚拟用户推送'; $data["order_status"] = '3'; $data["time"] = date("Y/m/d H:i:s"); $data["cartdata"] = $cartdata; $data['adress'] = ""; $data['phone'] = ""; $data['shouhuoname'] = $info['nickname']; M("Order")->add($data); if ($userinfo['l_id']) { //增加一级人数 $where["id"] = $userinfo['l_id']; $results = M("User")->where($where)->find(); if (strlen($results['uid']) > 10 && $results['dummy'] == 0) { $user_order_level = array(); $user_order_level['order_id'] = $orderid; $user_order_level['status'] = 3; $user_order_level['level_id'] = $results['id']; $user_order_level['level_type'] = 1; $user_order_level['price'] = 12; $user_order_level['active_time'] = date("Y-m-d H:i:s"); M("Order_level")->add($user_order_level); $a_info['id'] = $results['id']; $a_info['price'] = $results['price'] + 12; $a_info['pay_time'] = date('Y-m-d H:i:s'); $user_id = M("User")->save($a_info); $data = array(); $data['touser'] = $results["uid"]; $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $info['nickname'] . '】在' . date('Y-m-d H:i:s') . '加入您的队伍,已经成为您的一级员工,从此开始为您赚米,您获得的【¥12】积分,详情点击个人中心,我的主页查看。'; $weObj->sendCustomMessage($data); } } if ($userinfo['l_b']) { $where["id"] = $userinfo['l_b']; $b_results = M("User")->where($where)->find(); if (strlen($b_results['uid']) > 10 && $b_results['dummy'] == 0) { $user_order_level = array(); $user_order_level['order_id'] = $orderid; $user_order_level['status'] = 3; $user_order_level['level_id'] = $results['id']; $user_order_level['level_type'] = 2; $user_order_level['price'] = 3; $user_order_level['active_time'] = date("Y-m-d H:i:s"); M("Order_level")->add($user_order_level); $b_info['id'] = $b_results['id']; $b_info['price'] = $b_results['price'] + 3; $b_info['pay_time'] = date('Y-m-d H:i:s'); $user_id = M("User")->save($b_info); $data = array(); $data['touser'] = $b_results["uid"]; $b_info = json_encode($b_results['wx_info']); //一级成员信息 $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $info['nickname'] . '】在' . date('Y-m-d H:i:s') . '加入您的队伍,已经成为您的二级员工,从此开始为您赚米,您获得的【¥3】积分,详情点击个人中心,我的主页查看。'; $weObj->sendCustomMessage($data); } } if ($userinfo['l_c']) { $where["id"] = $userinfo['l_c']; $c_results = M("User")->where($where)->find(); if (strlen($c_results['uid']) > 10 && $c_results['dummy'] == 0) { $user_order_level = array(); $user_order_level['order_id'] = $orderid; $user_order_level['status'] = 3; $user_order_level['level_id'] = $results['id']; $user_order_level['level_type'] = 1; $user_order_level['price'] = 2; $user_order_level['active_time'] = date("Y-m-d H:i:s"); M("Order_level")->add($user_order_level); $c_info['id'] = $c_results['id']; $c_info['price'] = $c_results['price'] + 2; $c_info['pay_time'] = date('Y-m-d H:i:s'); $user_id = M("User")->save($c_info); $data = array(); $data['touser'] = $c_results["uid"]; $c_info = json_encode($c_results['wx_info']); //一级成员信息 $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $info['nickname'] . '】在' . date('Y-m-d H:i:s') . '加入您的队伍,已经成为您的三级员工,从此开始为您赚米,您获得的【¥2】积分,详情点击个人中心,我的主页查看。'; $weObj->sendCustomMessage($data); } } $this->success("推送积分成功"); }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ include_once "../wechat.class.php"; $options = array(); $weObj = new Wechat($options); $customData = array('touser' => 'o9po1uAqPgS8Hr2BsVPsQzAuaQNE', 'msgtype' => 'news', 'news' => array('articles' => array(array('title' => '测试标题1', 'description' => "测试项目1的描述", 'url' => 'http://www.baidu.com/', 'picurl' => 'http://www.52mba.com/file_news/20122210278268.jpg'), array('title' => '测试标题1', 'description' => "测试项目1的描述", 'url' => 'http://www.baidu.com/', 'picurl' => 'http://jsk.sanyue.com/userfiles/201011494947(1).jpg'), array('title' => '测试标题1', 'description' => "测试项目1的描述", 'url' => 'http://www.baidu.com/', 'picurl' => 'http://res.fashion.ifeng.com/d39093c37ac8c664/2012/0104/rdn_4f03a5f2f2c23.jpg')))); $result = $weObj->sendCustomMessage($customData); if ($result) { echo 'create menu success'; } else { echo 'create menu failed'; echo $weObj->errCode; echo $weObj->errMsg; }
public function qunmessage() { $result = M("Wxmessage")->where(array("id" => $_GET["id"]))->find(); $users = M("User")->field('uid')->where(array('dummy' => 0))->select(); if ($result['type'] == 1) { //此为发送文本消息 if (!empty($result['picurl'])) { //发送图片消息 exit; } } else { import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $newsArr[0] = array('title' => $result["title"], 'description' => $result["description"], 'picurl' => 'http://' . $this->_server('HTTP_HOST') . __ROOT__ . '/Public/Uploads/' . $result["picurl"], 'url' => $result["url"]); foreach ($users as $val) { $data = array(); $data['touser'] = $val["uid"]; $data['msgtype'] = 'news'; $data['news']['articles'] = $newsArr; $weObj->sendCustomMessage($data); } } if ($result) { $this->success("推送成功"); } }
public function payover() { /*if(empty($_SESSION['uid'])) { exit('请先关注该公众号'); }*/ if (empty($_SESSION['uid'])) { $uid = $_GET['uid']; } else { $uid = $_SESSION['uid']; } if (!$uid) { exit('请先关注该公众号'); } $out_trade_no = $_GET['out_trade_no']; $order_info = M("Order")->where(array('orderid' => $out_trade_no))->find(); if (empty($order_info)) { exit('未找到订单信息'); } $userdata = M("User")->where(array("uid" => $uid, "id" => $uid, '_logic' => 'or'))->find(); if (!$userdata) { exit('未找到用户信息'); } $user_data = $userdata; //R ( "Api/Api/orderover", array ($out_trade_no) ); $Order_level_info = M("Order_level")->where(array('order_id' => $out_trade_no))->select(); if (!empty($Order_level_info)) { import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); foreach ($Order_level_info as $info) { if ($info['level_type'] == 1) { $level_text = '一'; } if ($info['level_type'] == 2) { $level_text = '二'; } if ($info['level_type'] == 3) { $level_text = '三'; } $level_id = $info['level_id']; $user_info = M('User')->where(array('id' => $level_id))->find(); $wx_info = json_decode($userdata['wx_info'], true); if (strlen($user_info['uid']) > 10) { /*更新付款时间*/ $where = array(); $where['id'] = $user_info['id']; $where['pay_time'] = date("Y-m-d H:i:s"); M('User')->where($where)->save(); $data = array(); $data['touser'] = $user_info['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '【' . $wx_info['nickname'] . '】在' . date('Y-m-d H:i:s') . '加入您的队伍,已经成为您的' . $level_text . '级员工,从此开始为您赚米,您获得的【¥' . $info['price'] . '】积分,详情点击个人中心,我的主页查看。'; $weObj->sendCustomMessage($data); } } } if ($userdata["member"] != 1) { $user_id = $userdata["id"]; $member_obj = D("Member"); $result = $member_obj->add_meber($user_id); //生成分享图片 $url = 'http://' . $_SERVER['SERVER_NAME'] . U('App/Index/get_pic', array('uid' => $uid)); $oCurl = curl_init(); curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($oCurl, CURLOPT_TIMEOUT, 1); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); } $data['id'] = $userdata['id']; $data['jifen'] = $order_info['totalprice']; $data['pay_time'] = date("Y-m-d H:i:s"); $userdata = M("User")->save($data); if (!empty($out_trade_no)) { M("Order")->where(array('orderid' => $out_trade_no))->save(array('pay_status' => 1)); M("Order_level")->where(array('order_id' => $out_trade_no))->save(array('status' => 1)); //----------------- //微云莱网络默认自动发货 有问题请联系QQ 53867784 //如果是会员商品自动发货 $cart_info = json_decode($order_info['cartdata']); R("Api/Api/autofahuo", array($out_trade_no)); /** lbh 修该用户 级别 和到期时间 每份30天 , 购买3个月 赠一个月 **/ if ($order_info[order_status] == 0) { $this_time = time(); $add_time = ($cart_info[0]->num + floor($cart_info[0]->num / 3)) * 300 * 240 * 600 * 600; $data = array(); $data['member'] = 1; $data['id'] = $user_data['id']; $data['limit_time'] = $user_data['limit_time'] > $this_time ? $user_data['limit_time'] + $add_time : $this_time + $add_time; M("User")->save($data); } //end自动发货 } if (strpos($agent, "icroMessenger")) { $this->redirect('App/Index/member', array('uid' => $uid, 'page_type' => 'order')); } else { echo "<script>alert('支付成功');location.href='index.php?g=App&m=Index&a=member' </script>"; //$this->redirect('App/Index/member', array('uid'=>$uid)); //redirect('http://' . $_SERVER ['SERVER_NAME'].'/paysuccess/success.html'); } }
public function payover() { if (empty($_SESSION['uid'])) { exit('请先关注该公众号'); } $out_trade_no = $_GET['out_trade_no']; $order_info = M("Order")->where(array('orderid' => $out_trade_no))->find(); if (empty($order_info)) { exit('未找到订单信息'); } $userdata = M("User")->where(array("uid" => $_SESSION['uid']))->find(); $Order_level_info = M("Order_level")->where(array('order_id' => $out_trade_no))->select(); if (!empty($Order_level_info)) { import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); foreach ($Order_level_info as $info) { if ($info['level_type'] == 1) { $level_text = '一'; } if ($info['level_type'] == 2) { $level_text = '二'; } if ($info['level_type'] == 3) { $level_text = '三'; } $level_id = $info['level_id']; $user_info = M('User')->where(array('id' => $level_id))->find(); $wx_info = json_decode($userdata['wx_info'], true); if (strlen($user_info['uid']) > 10) { $data = array(); $data['touser'] = $user_info['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '您的' . $level_text . '级会员【' . $wx_info['nickname'] . '】在' . date('Y-m-d H:i:s') . '已付款,订单号为:' . $out_trade_no . ';订单金额为:' . $order_info['totalprice'] . '元;您已获得的佣金为:' . $info['price'] . '元。'; $weObj->sendCustomMessage($data); $cartdata = json_decode($order_info['cartdata'], true); $data = array(); $data['touser'] = $userdata['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '您的' . $cartdata[0]['name'] . '已付款成功,等待卖家发货。'; $weObj->sendCustomMessage($data); } } } if ($userdata["member"] != 1) { $user_id = $userdata["id"]; $member_obj = D("Member"); $result = $member_obj->add_meber($user_id); //生成分享图片 $url = 'http://' . $_SERVER['SERVER_NAME'] . U('App/Index/get_pic', array('uid' => $_SESSION['uid'])); $oCurl = curl_init(); curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($oCurl, CURLOPT_TIMEOUT, 1); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); } $data['id'] = $userdata['id']; $data['jifen'] = $order_info['totalprice']; $userdata = M("User")->save($data); if (!empty($out_trade_no)) { M("Order")->where(array('orderid' => $out_trade_no))->save(array('pay_status' => 1)); M("Order_level")->where(array('order_id' => $out_trade_no))->save(array('status' => 1)); } $this->redirect('App/Index/member', array('uid' => $_SESSION['uid'], 'page_type' => 'order')); }
public function publish($id) { $result = M("Order")->where(array('id' => $id))->find(); if (!empty($result)) { $data["id"] = $id; $data["order_status"] = 1; $data["time"] = date('Y-m-d H:i:s'); M("Order")->save($data); $user_info = M("User")->where(array('id' => $result['user_id']))->find(); if (!empty($user_info)) { $order_info = json_decode($result['order_info'], true); $data = array(); $data['touser'] = $user_info['uid']; $data['msgtype'] = 'text'; $data['text']['content'] = '您的订单(' . $result['orderid'] . ')已经发货,快递单号:' . $order_info['num'] . ',快递公司:' . $order_info['name'] . ',请注意查收,客服热线:400-0899-512,微信查询:gtsactos '; import('Wechat', APP_PATH . 'Common/Wechat', '.class.php'); $config = M("Wxconfig")->where(array("id" => "1"))->find(); $options = array('token' => $config["token"], 'encodingaeskey' => $config["encodingaeskey"], 'appid' => $config["appid"], 'appsecret' => $config["appsecret"], 'partnerid' => $config["partnerid"], 'partnerkey' => $config["partnerkey"], 'paysignkey' => $config["paysignkey"]); $weObj = new Wechat($options); $weObj->sendCustomMessage($data); } } if ($reuslt) { return $reuslt; } }