<?php if ($user_id > 0) { //$access_token = access_token($db); $weixin_config_rows = $GLOBALS['db']->getRow("select * from " . $GLOBALS['hhs']->table('weixin_config') . ""); $appid = $weixin_config_rows['appid']; $appsecret = $weixin_config_rows['appsecret']; $timestamp = gmtime(); $class_weixin = new class_weixin($appid, $appsecret); $signature = $class_weixin->getSignature($timestamp); $access_token = $class_weixin->getAccessToken(); $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token; $query_sql = "SELECT openid FROM " . $hhs->table('users') . " WHERE user_id = '{$user_id}'"; $ret_w = $db->getRow($query_sql); $wxid = $ret_w['openid']; /* $sql = "SELECT * FROM hhs_wxch_order WHERE order_name = '$wxch_order_name'"; $cfg_order = $db->getRow($sql); */ /**/ $cfg_baseurl = $db->getOne("SELECT cfg_value FROM " . $hhs->table("weixin_cfg") . " WHERE cfg_name = 'baseurl'"); //$cfg_murl = $db->getOne("SELECT cfg_value FROM hhs_weixin_cfg WHERE cfg_name = 'murl'"); //$cfg_baseurl="http://" . $_SERVER['HTTP_HOST'] . "/"; preg_match("/^(http:\\/\\/)?([^\\/]+)/i", $cfg_baseurl, $matches); $cfg_baseurl = $matches[0] . "/"; if ($wxch_order_name == 'pay') { $w_title = '付款成功'; //$cfg_order['title']; $w_url = $cfg_baseurl . 'share.php?team_sign=' . $team_sign; $w_description = "恭喜您荣升为团长!马上叫小伙伴来参团,组团成功才能享受优惠哦~"; $picurl = '';
<?php require_once '../system/model/db_fns.php'; require_once '../system/model/weixin.class.php'; $weixin = new class_weixin(); $result = $weixin->getUserList(null); // var_dump($result); echo $result; if ($result) { echo "<script>alert('获取成功');history.back();</script>"; } else { echo "<script>alert('获取失败');history.back();</script>"; }
<!DOCTYPE html> <?php session_start(); include_once "system/model/db_fns.php"; //lj+ include_once 'system/model/wood.php'; require_once 'system/model/weixin.class.php'; $weixin = new class_weixin(); $signPackage = $weixin->GetSignPackage(); $portid = $_SESSION['portid']; $phone = $_SESSION['phone']; $username = $_SESSION['username']; //error_log(date('Y-m-d H:i:s').'万里'."\n",3,$_SERVER['DOCUMENT_ROOT']."/log/run.log"); $wood = new wood($portid); $wood->realrelease(); $stuff_array = $wood->stuff; $from_array = $wood->from; ?> <html> <head> <meta http-equiv="Content-Type"content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <title>散货发布</title> <meta name="description" content=""> <meta name="keywords" content=""> <link rel="stylesheet" type="text/css" href="statics/css/yumleeM.css" /> <link rel="stylesheet" type="text/css" href="statics/css/mcr.css" /> <link rel="stylesheet" type="text/css" href="com/icomoon/style.css" /> <link rel="stylesheet" type="text/css" href="css/reminder.css" />
if (is_array($compic)) { foreach ($compic as $drow) { if (!unlink($drow["productpic"])) { $deleted = false; } if (!unlink(str_replace('.jpg', 's.jpg', $drow["productpic"]))) { $tdeleted = false; } } $query = "delete from t_productpic where cdkey = '" . $cdkey . "'"; $result = $conn->query($query); if (!$result) { $delfromdb = false; } } $weixin = new class_weixin(); //微信类, for ($i = 0; $i < $count_json; $i++) { $mediaid = $mypics[$i]; $filename = date('YmdHis') . rand(1000, 9999) . $userid; //产生一个随机文件名 $tfilename = $filename . 's'; $streamFileRand = $path . $filename . '.jpg'; //大图文件名 $tfilename = $path . $tfilename . '.jpg'; //缩略图文件名 $savepicresult = $weixin->downloadWeixinFile($mediaid, $streamFileRand, $tfilename); //$pic =($mypics[$i]['base64']); //$streamFileRand = $path.date('YmdHis').rand(1000,9999).$userid.'.jpg'; //产生一个随机文件名 //preg_match('/(?<=base64,)[\S|\s]+/',$pic,$streamForW); //处理base64文本,用正则把第一个base64,之前的部分砍掉 if ($savepicresult) {
$smarty->assign('buy_num',$sales_num); } else {*/ $smarty->assign('buy_num', get_buy_sum($goods_id) + $sales_num); //} $smarty->assign('now_time', gmtime()); // 当前系统时间 $sql = "select * from " . $hhs->table('users') . " where user_id=" . $_SESSION['user_id']; $user_info = $db->getRow($sql); //$appid=$weixin_config_rows['appid']; //$secret= $weixin_config_rows['appsecret']; $timestamp = time(); $smarty->assign('timestamp', $timestamp); $smarty->assign('appid', $appid); $class_weixin = new class_weixin($appid, $appsecret); $signature = $class_weixin->getSignature($timestamp); $smarty->assign('signature', $signature); //$smarty->assign('jssdk', jssdk($appid,$secret,$timestamp)); $smarty->assign('imgUrl', 'http://' . $_SERVER['HTTP_HOST'] . '/' . $goods['goods_thumb']); $smarty->assign('title', $goods['goods_name']); $smarty->assign('desc', mb_substr($_CFG['goods_share_dec'], 0, 30, 'utf-8')); $link = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER[REQUEST_URI]; $smarty->assign('link', $link); $smarty->assign('link2', urlencode($link)); $smarty->display('goods.dwt', $cache_id); /*------------------------------------------------------ */ //-- PRIVATE FUNCTION /*------------------------------------------------------ */ function get_buy_sum($goods_id) {
<?php require_once '/system/model/weixin.class.php'; require_once '/system/model/db_fns.php'; $weixin = new class_weixin(); $cdkey = '1393454493115070616183179801'; $carnum = '88888888'; $wxid = 'oikUKt1666QxU9gZrUu7OgpbP9OE'; $arrivetime = date("m月d日 H时i分"); $arriveposition = "西客站"; $username = '******'; $kindname = '原木'; //public function sendtemplatemsg($wxid,$cdkey,$username,$carnum,$arrivetime,$kindname,$arriveposition) $result = $weixin->sendtemplatemsg($wxid, $cdkey, $username, $carnum, $arrivetime, $kindname, $arriveposition); if ($result) { echo "<script> alert('scuccess');</script>;"; } else { echo "<script> alert('error');</script>;"; }
function sendwxmsg() { $cdkey = $this->cdkey; $carnum = $this->carnum; if ($this->contactphone != 0) { if ($this->getusername($this->contactphone)) { $wxid = $this->wxid; $username = $this->username; $this->getspotpositionname($this->spotpositionid); $arriveposition = $this->spotpositionname; $arrivetime = date("m月d日 H时i分"); $kindname = ''; if ($this->kindid != 0) { if ($this->getkindname($this->kindid)) { $kindname = $this->kindname; } } $weixin = new class_weixin(); $result = $weixin->sendtemplatemsg($wxid, $cdkey, $username, $carnum, $arrivetime, $kindname, $arriveposition); if ($result) { return true; } else { $result = $weixin->sendtemplatemsg($wxid, $cdkey, $username, $carnum, $arrivetime, $kindname, $arriveposition); if ($result) { return true; } else { return false; } } } else { return false; } } else { return false; } }
function pay_team_action($orsn) { /*是团购改变订单*/ $sql = "select * from " . $GLOBALS['hhs']->table('order_info') . " where order_sn='" . $orsn . "'"; $order_info = $GLOBALS['db']->getRow($sql); include_once ROOT_PATH . "languages/zh_cn/wx_msg.php"; if (!empty($order_info) && $order_info['extension_code'] == 'team_goods') { $team_sign = $order_info['team_sign']; $weixin = new class_weixin($GLOBALS['appid'], $GLOBALS['appsecret']); $openid = $GLOBALS['db']->getOne("select openid from " . $GLOBALS['hhs']->table('users') . " where user_id=" . $order_info['user_id']); $t_openid = $GLOBALS['db']->getOne("select u.openid from " . $GLOBALS['hhs']->table('order_info') . " as oi left join " . $GLOBALS['hhs']->table('users') . " as u on oi.user_id=u.user_id where oi.team_first=1 and oi.team_sign=" . $team_sign); $sql = "select team_num,discount_type,discount_amount from " . $GLOBALS['hhs']->table('goods') . " where goods_id=" . $order_info['extension_id']; $rs = $GLOBALS['db']->getRow($sql); $team_num = $rs['team_num']; $discount_type = $rs['discount_type']; $discount_amount = $rs['discount_amount']; if ($order_info['team_first'] == 1) { //若是团长记录下团的人数 if ($discount_type == 1 && $order_info['refund_sign'] == 0) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}',discount_type ='{$discount_type}',discount_amount=money_paid+order_amount WHERE order_id=" . $order_info['order_id']; } elseif ($discount_type == 2 && $order_info['refund_sign'] == 0) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}',discount_type ='{$discount_type}', discount_amount='{$discount_amount}' WHERE order_id=" . $order_info['order_id']; } else { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_num='{$team_num}', discount_amount=0 WHERE order_id=" . $order_info['order_id']; } $GLOBALS['db']->query($sql); } $sql = "select team_num from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $order_info['team_sign']; $team_num = $GLOBALS['db']->getOne($sql); //团共需人数和状态 $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_status=1,team_num='{$team_num}' WHERE order_id=" . $order_info['order_id']; $GLOBALS['db']->query($sql); //实际人数 $sql = "select count(*) from " . $GLOBALS['hhs']->table('order_info') . " where team_sign=" . $team_sign . " and team_status>0 "; $rel_num = $GLOBALS['db']->getOne($sql); //存储实际人数 $sql = "update " . $GLOBALS['hhs']->table('order_info') . " set teammen_num='{$rel_num}' where team_sign=" . $team_sign; $GLOBALS['db']->query($sql); if ($team_num <= $rel_num) { $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET team_status=2 WHERE team_status=1 and team_sign=" . $team_sign; $GLOBALS['db']->query($sql); //取消未参团订单 $sql = "UPDATE " . $GLOBALS['hhs']->table('order_info') . " SET order_status=2 WHERE team_status=0 and team_sign=" . $team_sign; $GLOBALS['db']->query($sql); //判断团长是否有优惠,要重新取数据 $sql = "select order_id,user_id,refund_sign,discount_type, discount_amount, money_paid,order_amount,order_sn from " . $GLOBALS['hhs']->table('order_info') . " where order_id=" . $team_sign; $r = $GLOBALS['db']->getRow($sql); //目前只有微信可以退款 $payment = payment_info($order_info['pay_id']); if ($payment['pay_code'] == 'wxpay') { if ($r['discount_type'] == 1 && $r['refund_sign'] == 0) { //团长免单 $f = refund($r['order_sn'], $r['money_paid'] * 100); if ($f) { $arr['pay_status'] = 3; $arr['refund_sign'] = 1; $arr['money_paid'] = 0; $arr['order_amount'] = $r['money_paid'] + $r['order_amount']; update_order($team_sign, $arr); $weixin->send_wxmsg($t_openid, $_team_msg['refund_team_first']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['refund_team_first']['desc']); } } elseif ($r['discount_type'] == 2 && $r['refund_sign'] == 0) { $f = refund($r['order_sn'], $r['discount_amount'] * 100); if ($f) { $arr['refund_sign'] = 1; $arr['money_paid'] = $r['money_paid'] - $r['discount_amount']; $arr['order_amount'] = $r['discount_amount'] + $r['order_amount']; update_order($team_sign, $arr); $weixin->send_wxmsg($t_openid, $_team_msg['refund_team_discount']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['refund_team_discount']['desc']); } } } } if ($order_info['team_first'] == 1) { $weixin->send_wxmsg($openid, $_team_msg['pay']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['pay']['desc']); //$weixin->send_wxmsg($t_openid, $_team_msg['team_suc_first']['title'] , 'share.php?team_sign='.$team_sign , $_team_msg['team_suc_first']['title'] ); } elseif ($order_info['team_first'] == 2) { if ($team_num <= $rel_num) { $weixin->send_wxmsg($openid, $_team_msg['team_suc_mem']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['team_suc_mem']['desc']); $weixin->send_wxmsg($t_openid, $_team_msg['team_suc_first']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['team_suc_first']['title']); } else { $weixin->send_wxmsg($openid, $_team_msg['mem_pay']['title'], 'share.php?team_sign=' . $team_sign, $_team_msg['mem_pay']['title']); } } } }
} //$_SESSION['xaphp_sopenid']='onSWAuOcOaSJgGidvKTJoj6u0rCc'; if (!empty($_SESSION['xaphp_sopenid'])) { require_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/user.php'; $sql = "select * from " . $hhs->table('users') . " where openid='" . trim($_SESSION['xaphp_sopenid']) . "'"; $rs = $db->getRow($sql); if (!empty($_SESSION['A_token'])) { //echo $_SESSION['A_token']; define("ACCESS_TOKEN", $_SESSION['A_token']); // $userinfo_back_arr = getUserInfo($_SESSION['xaphp_sopenid']); //获取头像 $headimgurl = $userinfo_back_arr["headimgurl"]; } //单单为了获取是否关注 $weixin = new class_weixin($appid, $appsecret); $access_token = $weixin->getAccessToken(); if (!empty($access_token)) { $userinfo_back_arr2 = getUserInfo($_SESSION['xaphp_sopenid'], 2); $userinfo_back_arr['subscribe'] = $userinfo_back_arr2["subscribe"]; $smarty->assign("subscribe", $userinfo_back_arr['subscribe']); } if (empty($rs)) { include_once ROOT_PATH . 'includes/lib_passport.php'; $ychar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; $list = explode(",", $ychar); $password = ''; for ($i = 0; $i < 6; $i++) { $randnum = rand(0, 35); $password .= $list[$randnum]; }
private function receiveEvent($object) { $content = ""; switch ($object->Event) { case "subscribe": $content = "欢迎关注方倍工作室"; case "unsubscribe": break; case "CLICK": switch ($object->EventKey) { case "在线客服": $staffs = array("oQW8FuFKL0530Qhp3rh0HciHkTL0"); $mmc = memcache_init(); require_once 'weixin.class.php'; $weixin = new class_weixin(); //客服点击,结束会话 if (in_array($object->FromUserName, $staffs)) { $relation = json_decode(memcache_get($mmc, "service"), true); $from = strval($object->FromUserName); $to = $relation['from']; $weixin->send_custom_msg($from, "text", "你已结束本次对话!"); $weixin->send_custom_msg($to, "text", "感谢您的咨询。期待下次再会!"); memcache_delete($mmc, "service"); } else { $from = strval($object->FromUserName); $to = $staffs[0]; memcache_set($mmc, "service", '{"from":"' . $from . '","to":"' . $to . '"}'); $weixin->send_custom_msg($from, "text", "正在为您接入客服,请稍候..."); $weixin->send_custom_msg($to, "text", "有用户请求接入,请响应!"); } return; default: $content = "菜单默认回复"; break; } break; default: break; } if (is_array($content)) { $result = $this->transmitNews($object, $content); } else { $result = $this->transmitText($object, $content); } return $result; }