本文整理汇总了PHP中WeAccount::token方法的典型用法代码示例。如果您正苦于以下问题:PHP WeAccount::token方法的具体用法?PHP WeAccount::token怎么用?PHP WeAccount::token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeAccount
的用法示例。
在下文中一共展示了WeAccount::token方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defined
/**
* [WeEngine System] Copyright (c) 2014 WE7.CC
* WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
*/
defined('IN_IA') or exit('Access Denied');
$dos = array('display', 'change', 'qr', 'chat');
$do = !empty($_GPC['do']) && in_array($do, $dos) ? $do : 'display';
load()->model('account');
if ($do == 'display') {
template('platform/url2qr');
}
if ($do == 'change') {
if ($_W['ispost']) {
load()->func('communication');
$longurl = trim($_GPC['longurl']);
$token = WeAccount::token(WeAccount::TYPE_WEIXIN);
$url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token={$token}";
$send = array();
$send['action'] = 'long2short';
$send['long_url'] = $longurl;
$response = ihttp_request($url, json_encode($send));
if (is_error($response)) {
$result = error(-1, "访问公众平台接口失败, 错误: {$response['message']}");
}
$result = @json_decode($response['content'], true);
if (empty($result)) {
$result = error(-1, "接口调用失败, 元数据: {$response['meta']}");
} elseif (!empty($result['errcode'])) {
$result = error(-1, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}");
}
if (is_error($result)) {
示例2: doMobilepayweixin
public function doMobilepayweixin()
{
global $_W, $_GPC;
$op = $_GPC['op'];
$tid = $_GPC['tid'];
$title = '二维码支付';
//获取商城标题
load()->model('account');
if (empty($op)) {
if (empty($tid)) {
message('订单错误, 请重新下单支付!', '', 'error');
}
$value = $this->GetPrePayUrl($tid);
///44.生成扫描支付URL,模式一。
include $this->template('payweixin');
}
if ($op == 'change') {
if ($_W['ispost']) {
load()->func('communication');
$longurl = trim($_GPC['longurl']);
$token = WeAccount::token(WeAccount::TYPE_WEIXIN);
$url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token={$token}";
$send = array();
$send['action'] = 'long2short';
$send['long_url'] = $longurl;
$response = ihttp_request($url, json_encode($send));
if (is_error($response)) {
$result = error(-1, "访问公众平台接口失败, 错误: {$response['message']}");
}
$result = @json_decode($response['content'], true);
if (empty($result)) {
$result = error(-1, "接口调用失败, 元数据: {$response['meta']}");
} elseif (!empty($result['errcode'])) {
$result = error(-1, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}");
}
if (is_error($result)) {
exit(json_encode(array('errcode' => -1, 'errmsg' => $result['message'])));
}
exit(json_encode($result));
} else {
exit('err');
}
}
if ($op == 'qr') {
$url = $_GPC['url'];
require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
$errorCorrectionLevel = "L";
$matrixPointSize = "5";
QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize);
exit;
}
}
示例3: sendtempmsg
public function sendtempmsg($template_id, $url, $data, $topcolor, $tousers = '')
{
load()->func('communication');
load()->classs('weixin.account');
$access_token = WeAccount::token();
if (empty($access_token)) {
return;
}
$postarr = '{"touser":"' . $tousers . '","template_id":"' . $template_id . '","url":"' . $url . '","topcolor":"' . $topcolor . '","data":' . $data . '}';
$res = ihttp_post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $access_token, $postarr);
return true;
}
示例4: payResult
//.........这里部分代码省略.........
$smsSetting = pdo_fetch("SELECT * FROM " . tablename($this->table_sms_setting) . " WHERE weid=:weid AND storeid=:storeid LIMIT 1", array(':weid' => $weid, ':storeid' => $storeid));
$sendInfo = array();
if (!empty($smsSetting)) {
if ($smsSetting['sms_enable'] == 1 && !empty($smsSetting['sms_mobile'])) {
//模板
if (empty($smsSetting['sms_business_tpl'])) {
$smsSetting['sms_business_tpl'] = '您有新的订单:[sn],收货人:[name],电话:[tel],请及时确认订单!';
}
//订单号
$smsSetting['sms_business_tpl'] = str_replace('[sn]', $order['ordersn'], $smsSetting['sms_business_tpl']);
//用户名
$smsSetting['sms_business_tpl'] = str_replace('[name]', $order['username'], $smsSetting['sms_business_tpl']);
//就餐时间
$smsSetting['sms_business_tpl'] = str_replace('[date]', $order['meal_time'], $smsSetting['sms_business_tpl']);
//电话
$smsSetting['sms_business_tpl'] = str_replace('[tel]', $order['tel'], $smsSetting['sms_business_tpl']);
$smsSetting['sms_business_tpl'] = str_replace('[totalnum]', $order['totalnum'], $smsSetting['sms_business_tpl']);
$smsSetting['sms_business_tpl'] = str_replace('[totalprice]', $order['totalprice'], $smsSetting['sms_business_tpl']);
$smsSetting['sms_business_tpl'] = str_replace('[address]', $order['address'], $smsSetting['sms_business_tpl']);
$smsSetting['sms_business_tpl'] = str_replace('[remark]', $order['remark'], $smsSetting['sms_business_tpl']);
$smsSetting['sms_business_tpl'] = str_replace('[goods]', $goods_str, $smsSetting['sms_business_tpl']);
$sendInfo['username'] = $smsSetting['sms_username'];
$sendInfo['pwd'] = $smsSetting['sms_pwd'];
$sendInfo['mobile'] = $smsSetting['sms_mobile'];
$sendInfo['content'] = $smsSetting['sms_business_tpl'];
//debug
if ($data['status'] == 1) {
if ($order['issms'] == 0) {
pdo_update($this->table_order, array('issms' => 1), array('id' => $orderid));
$return_result_code = $this->_sendSms($sendInfo);
$smsStatus = $this->sms_status[$return_result_code];
}
}
}
}
$store = pdo_fetch("SELECT * FROM " . tablename($this->table_stores) . " WHERE weid=:weid AND id=:id LIMIT 1", array(':weid' => $weid, ':id' => $storeid));
if (!empty($emailSetting) && !empty($emailSetting['email'])) {
$email_tpl = str_replace('[store]', $store['title'], $email_tpl);
$email_tpl = str_replace('[sn]', $order['ordersn'], $email_tpl);
$email_tpl = str_replace('[name]', $order['username'], $email_tpl);
//用户名
$email_tpl = str_replace('[name]', $order['username'], $email_tpl);
//就餐时间
$email_tpl = str_replace('[mealtime]', $order['meal_time'], $email_tpl);
//电话
$email_tpl = str_replace('[tel]', $order['tel'], $email_tpl);
$email_tpl = str_replace('[tables]', $order['tables'], $email_tpl);
$email_tpl = str_replace('[goods]', $goods_str, $email_tpl);
$email_tpl = str_replace('[totalnum]', $order['totalnum'], $email_tpl);
$email_tpl = str_replace('[totalprice]', $order['totalprice'], $email_tpl);
$email_tpl = str_replace('[address]', $order['address'], $email_tpl);
$email_tpl = str_replace('[remark]', $order['remark'], $email_tpl);
if ($emailSetting['email_host'] == 'smtp.qq.com' || $emailSetting['email_host'] == 'smtp.gmail.com') {
$secure = 'ssl';
$port = '465';
} else {
$secure = 'tls';
$port = '25';
}
$mail_config = array();
$mail_config['host'] = $emailSetting['email_host'];
$mail_config['secure'] = $secure;
$mail_config['port'] = $port;
$mail_config['username'] = $emailSetting['email_user'];
$mail_config['sendmail'] = $emailSetting['email_send'];
$mail_config['password'] = $emailSetting['email_pwd'];
$mail_config['mailaddress'] = $emailSetting['email'];
$mail_config['subject'] = '订单提醒';
$mail_config['body'] = $email_tpl;
if ($data['status'] == 1) {
if ($order['isemail'] == 0) {
pdo_update($this->table_order, array('isemail' => 1), array('id' => $orderid));
$result = $this->sendmail($mail_config);
}
}
}
$setting = pdo_fetch("select * from " . tablename($this->table_setting) . " where weid =:weid LIMIT 1", array(':weid' => $weid));
if (!empty($setting) && $setting['istplnotice'] == 1) {
$templateid = $setting['tplneworder'];
$noticeuser = $setting['tpluser'];
$template = array('touser' => $noticeuser, 'template_id' => $templateid, 'url' => '', 'topcolor' => "#FF0000", 'data' => array('first' => array('value' => urlencode("您有一个新的订单"), 'color' => '#000'), 'keyword1' => array('value' => urlencode($order['ordersn']), 'color' => '#000'), 'keyword2' => array('value' => urlencode($order['username'] . ' ' . $order['tel']), 'color' => '#000'), 'keyword3' => array('value' => urlencode($goods_tplstr), 'color' => '#000'), 'keyword4' => array('value' => urlencode($order['address']), 'color' => '#000'), 'keyword5' => array('value' => urlencode($order['meal_time']), 'color' => '#000'), 'remark' => array('value' => urlencode('总金额:' . $order['totalprice'] . '元'), 'color' => '#f00')));
if ($data['status'] == 1) {
if ($order['istpl'] == 0) {
pdo_update($this->table_order, array('istpl' => 1), array('id' => $orderid));
$templateMessage = new class_templateMessage($this->_appid, $this->_appsecret);
$access_token = WeAccount::token();
$templateMessage->send_template_message($template, $access_token);
}
}
}
$this->feiyinSendFreeMessage($orderid);
$setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
$credit = $setting['creditbehaviors']['currency'];
if ($params['type'] == $credit) {
message('支付成功!' . $smsStatus, $this->createMobileUrl('order', array('storeid' => $storeid, 'status' => 1), true), 'success');
} else {
message('支付成功!' . $smsStatus, '../../app/' . $this->createMobileUrl('order', array('storeid' => $storeid), true), 'success');
}
}
}
示例5: array
}
} else {
if (isset($avatar) && isset($nickname) && isset($from_user)) {
$shareuserdata = $_W['siteroot'] . 'app/' . $this->createMobileUrl('shareuserdata', array('rid' => $rid, 'fromuser' => $fromuser, 'duli' => $_GPC['duli'], 'tfrom_user' => $tfrom_user));
header("location:{$shareuserdata}");
exit;
} else {
$from_user = $_W['openid'];
if ($from_user) {
//取得openid后查询是否为高级号
if ($serverapp == 4) {
//认证服务号查询是否关注
$profile = pdo_fetch("SELECT follow FROM " . tablename('mc_mapping_fans') . " WHERE uniacid = :uniacid and openid = :from_user", array(':uniacid' => $uniacid, ':from_user' => $from_user));
if ($_W['fans']['follow'] || $profile['follow']) {
//已关注直接获取信息
$access_token = WeAccount::token();
$oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN";
$content = ihttp_get($oauth2_url);
$info = @json_decode($content['content'], true);
if (empty($info) || !is_array($info) || empty($info['openid']) || empty($info['nickname'])) {
echo '<h1>分享获取微信公众号授权失败[无法取得info], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>';
exit;
} else {
$avatar = $info['headimgurl'];
$nickname = $info['nickname'];
$sex = $info['sex'];
//设置cookie信息
setcookie("user_oauth2_avatar", $avatar, time() + 3600 * 24 * 7);
setcookie("user_oauth2_nickname", $nickname, time() + 3600 * 24 * 7);
setcookie("user_oauth2_sex", $sex, time() + 3600 * 24 * 7);
setcookie("user_oauth2_openid", $from_user, time() + 3600 * 24 * 7);
示例6: SendTpl
/**
* 模板消息
* 接口已开放
*
*/
private function SendTpl($openid, $info, $type, $res)
{
load()->func('communication');
require_once 'template_conf_ap.php';
require_once 'template_conf_auth.php';
require_once 'template_conf_re.php';
require_once 'template_conf_cd.php';
require_once 'template_conf_fl.php';
global $_W;
$access_token = WeAccount::token();
$apply = json_decode($apply, true);
// $this->saveSettings($apply);
$auth = json_decode($auth, true);
// $this->saveSettings(auth);
$refu = json_decode($refu, true);
// $this->saveSettings($refu);
$credit = json_decode($credit, true);
// $this->saveSettings($credit);
$full = json_decode($full, true);
// $this->saveSettings($full);
//post URL
$url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $access_token;
//POST data
if ($type == 'apply') {
$data = array('touser' => $openid, 'template_id' => $apply['apply_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjindex&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => $apply['apply_first'], 'color' => $apply['apply_fcolor']), 'keynote1' => array('value' => $apply['apply_keynote1'], 'color' => $apply['apply_kfcolor']), 'keynote2' => array('value' => '请联系雇主确认....', 'color' => '#000'), 'remark' => array('value' => $apply['apply_remark'], 'color' => $apply['apply_mkcolor'])));
} else {
if ($type == 'auth') {
$date = date('Y-m-d H:i');
$data = array('touser' => $openid, 'template_id' => $auth['auth_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjindex&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => $auth['auth_first'], 'color' => $apply['auth_first']), 'keyword1' => array('value' => $info['name'], 'color' => '#000'), 'keyword2' => array('value' => $info['phone'], 'color' => '#000'), 'keyword3' => array('value' => $date, 'color' => '#000'), 'remark' => array('value' => $auth['auth_remark'], 'color' => $auth['auth_mkcolor'])));
} else {
if ($type == 'refuse') {
$date = date('Y-m-d H:i');
$data = array('touser' => $openid, 'template_id' => $refu['refu_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjindex&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => $refu['refu_first'], 'color' => $refu['refu_fcolor']), 'keyword1' => array('value' => $info['name'], 'color' => '#000'), 'keyword2' => array('value' => $info['phone'], 'color' => '#000'), 'keyword3' => array('value' => $date, 'color' => '#000'), 'remark' => array('value' => $refu['refu_remark'], 'color' => $refu['refu_mkcolor'])));
} else {
if ($type == 'credit1') {
$date = date('Y-m-d H:i:s');
$data = array('touser' => $openid, 'template_id' => $credit['credit_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjindex&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => $credit['credit_first'], 'color' => $credit['credit_fcolor']), 'account' => array('value' => $info['name'], 'color' => '#000'), 'time' => array('value' => $date, 'color' => '#000'), 'type' => array('value' => $credit['credit_type'], 'color' => $credit['credit_tpcolor']), 'creditChange' => array('value' => '支出', 'color' => '#000'), 'number' => array('value' => '100', 'color' => '#000'), 'creditName' => array('value' => '账户积分', 'color' => '#000'), 'amount' => array('value' => $res, 'color' => '#000'), 'remark' => array('value' => $credit['credit_remark'], 'color' => $credit['crefit_mkcolor'])));
} else {
if ($type == 'full') {
$data = array('touser' => $openid, 'template_id' => $full['full_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjmyinfo&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => $full['full_first'], 'color' => $full['full_fcolor']), 'keyword1' => array('value' => $info['title'], 'color' => '#000'), 'keyword2' => array('value' => "待办", 'color' => 'red'), 'remark' => array('value' => $full['full_remark'], 'color' => $full['full_mkcolor'])));
} else {
if ($type == 'first_third') {
$data = array('touser' => $openid, 'template_id' => $full['full_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjmyinfo&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => '请尽快去录取应答者,完成本次招募。', 'color' => '#000'), 'keyword1' => array('value' => $info['title'], 'color' => '#000'), 'keyword2' => array('value' => '待办', 'color' => 'red'), 'remark' => array('value' => '帖子有人认领啦,快去看看.', 'color' => '#0542FA')));
} else {
if ($type == 'second_third') {
$data = array('touser' => $openid, 'template_id' => $full['full_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjmyinfo&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => '请尽快去录取应聘者,完成本次招聘。', 'color' => '#000'), 'keyword1' => array('value' => $info['title'], 'color' => '#000'), 'keyword2' => array('value' => '待办', 'color' => 'red'), 'remark' => array('value' => '招聘帖子人数快满了,请速去验收.', 'color' => '#0542FA')));
} else {
if ($type == 'admit') {
$data = array('touser' => $openid, 'template_id' => $apply['apply_tid'], 'url' => $_W['siteroot'] . 'app/index.php?i=1&c=entry&do=ptjindex&m=hypernet_iptj', 'topcolor' => '#FF0000', 'data' => array('first' => array('value' => 'congrats!你已被' . $info['name'] . '招募', 'color' => '#FF0000'), 'keynote1' => array('value' => $info['name'] . '欢迎你的加入~', 'color' => '#000'), 'keynote2' => array('value' => '请联系雇主确认....', 'color' => '#000'), 'remark' => array('value' => '要愉快地玩耍哦~~~~', 'color' => '#000')));
}
}
}
}
}
}
}
}
return ihttp_post($url, json_encode($data));
}
示例7: payResult
public function payResult($params)
{
global $_W, $_GPC;
$fee = intval($params['fee']);
$data = array('status' => $params['result'] == 'success' ? 1 : 0);
$paytype = array('credit' => 1, 'wechat' => 2, 'alipay' => 2, 'delivery' => 3);
$data['pay_type'] = $paytype[$params['type']];
if ($params['type'] == 'wechat') {
$data['transid'] = $params['tag']['transaction_id'];
}
$goodsId = pdo_fetchcolumn("SELECT `g_id` FROM" . tablename('tg_order') . "WHERE `orderno` = :orderid ", array(':orderid' => $params['tid']));
$goodsInfo = pdo_fetch("SELECT * FROM" . tablename('tg_goods') . "WHERE `id` = :id ", array(':id' => $goodsId));
// //货到付款
if ($params['type'] == 'delivery') {
$data['status'] = 1;
$data['starttime'] = TIMESTAMP;
$data['ptime'] = TIMESTAMP;
}
if ($params['result'] == 'success') {
$data['ptime'] = TIMESTAMP;
$data['starttime'] = TIMESTAMP;
}
$tuan_id = pdo_fetch("select * from" . tablename('tg_order') . "where orderno = '{$params['tid']}'");
$goods = pdo_fetch("select * from" . tablename('tg_order') . "where id = '{$tuan_id['g_id']}'");
if ($params['from'] == 'return') {
$pay_suc = $this->module['config']['pay_suc'];
$pay_remark = $this->module['config']['pay_remark'];
$m_pay = $this->module['config']['m_pay'];
//支付成功模板消息提醒
$content = "";
if ($tuan_id['tuan_first'] == 1) {
$content .= "您已成功付款开团,恭喜您荣升团长,组团成功才会享受优惠哦";
} else {
$content .= "您已成功付款参团,组团成功才会享受优惠哦";
}
load()->func('communication');
load()->model('account');
$access_token = WeAccount::token();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token . "";
$url2 = $_W['siteroot'] . 'app/' . $this->createMobileUrl('orderdetails', array('id' => $params['tid']));
//点击模板详情跳转的地址url2
$time = date("Y-m-d H:i:s", time());
$openid = trim($_W['openid']);
$msg_json = '{
"touser":"' . $openid . '",
"template_id":"' . $m_pay . '",
"url":"' . $url2 . '",
"topcolor":"#FF0000",
"data":{
"first":{
"value":"\\n' . $pay_suc . '\\n",
"color":"#000000"
},
"orderProductName":{
"value":"' . $goodsInfo['gname'] . '\\n",
"color":"#000000"
},
"orderMoneySum":{
"value":"' . $tuan_id['price'] . '\\n",
"color":"#000000"
},
"remark":{
"value":"\\n\\n' . $pay_remark . '",
"color":"#0099FF"
}
}
}';
include_once 'message.php';
$sendmessage = new WX_message();
$res = $sendmessage->WX_request($url, $msg_json);
$setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
$credit = $setting['creditbehaviors']['currency'];
if ($tuan_id['status'] != 1) {
pdo_update('tg_order', $data, array('orderno' => $params['tid']));
// 更改库存
if (!empty($goodsInfo['gnum'])) {
pdo_update('tg_goods', array('gnum' => $goodsInfo['gnum'] - 1, 'salenum' => $goodsInfo['salenum'] + 1), array('id' => $goodsId));
//.........这里部分代码省略.........
示例8: payResult
public function payResult($params)
{
global $_W, $_GPC;
$uniacid = $_W['uniacid'];
$fee = intval($params['fee']);
$data = array('status' => $params['result'] == 'success' ? 1 : 0);
$paytype = array('credit' => '1', 'wechat' => '3', 'alipay' => '2');
$data['paytype'] = $paytype[$params['type']];
if ($params['type'] == 'wechat') {
$data['transid'] = $params['tag']['transaction_id'];
}
if ($params['result'] == 'success' && $params['from'] == 'notify') {
$order = pdo_fetch("SELECT * FROM " . tablename('feng_record') . " WHERE id ='{$params['tid']}'");
//获取商品ID
if ($order['status'] != 1) {
if ($params['result'] == 'success') {
$data['status'] = 1;
$codes = pdo_fetch("SELECT * FROM " . tablename('feng_goodscodes') . " WHERE s_id ='{$order['sid']}'");
//获取商品code
$sidm = pdo_fetch("SELECT * FROM " . tablename('feng_goodslist') . " WHERE id ='{$order['sid']}'");
//获取商品详情
$s_codes = unserialize($codes['s_codes']);
//转换商品code
$c_number = intval($codes['s_len']);
if ($c_number > 0) {
if ($fee < $c_number) {
//计算购买的夺宝码
$data['s_codes'] = array_slice($s_codes, 0, $fee);
$data['s_codes'] = serialize($data['s_codes']);
$r_codes['s_len'] = $c_number - $fee;
$r_codes['s_codes'] = array_slice($s_codes, $fee, $r_codes['s_len']);
$r_codes['s_codes'] = serialize($r_codes['s_codes']);
$sid_mess['canyurenshu'] = $sidm['canyurenshu'] + $fee;
$sid_mess['shengyurenshu'] = $sidm['shengyurenshu'] - $fee;
$sid_mess['scale'] = round($sid_mess['canyurenshu'] / $sidm['zongrenshu'] * 100);
//执行数据库更新
pdo_update('feng_goodscodes', $r_codes, array('id' => $codes['id']));
pdo_update('feng_goodslist', $sid_mess, array('id' => $sidm['id']));
$result_mess = '支付成功!';
} elseif ($fee >= $c_number) {
$data['s_codes'] = $codes['s_codes'];
/*$data['s_codes']=serialize($data['s_codes']);*/
$r_codes['s_len'] = 0;
$r_codes['s_codes'] = NULL;
//计算获奖的code和获奖人
$s_record = pdo_fetchall("SELECT * FROM " . tablename('feng_record') . " WHERE uniacid = '{$_W['uniacid']}' and sid ='{$order['sid']}'");
//获取商品所有交易记录
if (empty($sidm['q_user_code'])) {
$wincode = mt_rand(1, $sidm['zongrenshu']);
$wincode = $wincode + 1000000;
} else {
$wincode = $sidm['q_user_code'];
}
//计算获奖人
foreach ($s_record as $value) {
$ss_codes = unserialize($value['s_codes']);
//转换商品code
for ($i = 0; $i < count($ss_codes); $i++) {
if ($ss_codes[$i] == $wincode) {
$sid_mess['q_user'] = $value['from_user'];
break;
}
}
}
if (empty($sid_mess['q_user'])) {
$ss_codes = unserialize($data['s_codes']);
//转换商品code
for ($i = 0; $i < count($ss_codes); $i++) {
if ($ss_codes[$i] == $wincode) {
$sid_mess['q_user'] = $_W['fans']['from_user'];
break;
}
}
}
$sid_mess['canyurenshu'] = $sidm['zongrenshu'];
$sid_mess['shengyurenshu'] = 0;
$sid_mess['q_user_code'] = $wincode;
$pro_m = pdo_fetch("SELECT * FROM " . tablename('feng_member') . " WHERE uniacid = '{$_W['uniacid']}' and from_user ='{$sid_mess['q_user']}'");
//用户信息
$sid_mess['q_uid'] = $pro_m['nickname'];
$sid_mess['status'] = 1;
$sid_mess['q_end_time'] = TIMESTAMP;
$sid_mess['scale'] = 100;
//模板消息推送
load()->model('account');
$access_token = WeAccount::token();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token . "";
$json_data = array('touser' => $sid_mess['q_user'], 'template_id' => $this->module['config']['win_mess'], 'url' => $_W['siteroot'] . 'app/' . $this->createMobileUrl('prize'), 'topcolor' => '#FF0000', "data" => array("title" => array('value' => '尊敬的客户', 'color' => '#173177'), "headinfo" => array('value' => '恭喜您,中奖啦!', 'color' => '#FF0000'), "program" => array('value' => '一元夺宝', 'color' => '#FF0000'), "result" => array('value' => '获得了我们的大奖', 'color' => '#FF0000'), "remark" => array('value' => '点击进入查看中奖详情,祝你生活愉快!', 'color' => '#173177')));
$msg_json = json_encode($json_data);
include_once 'message.php';
$sendmessage = new WX_message();
$res = $sendmessage->WX_request($url, $msg_json);
//生成新一期商品
if ($sidm['periods'] <= $sidm['maxperiods']) {
$new_sid = array('uniacid' => $_W['uniacid'], 'sid' => $sidm['sid'], 'title' => $sidm['title'], 'price' => $sidm['price'], 'zongrenshu' => $sidm['zongrenshu'], 'canyurenshu' => 0, 'shengyurenshu' => $sidm['zongrenshu'], 'periods' => $sidm['periods'] + 1, 'maxperiods' => $sidm['maxperiods'], 'picarr' => $sidm['picarr'], 'content' => $sidm['content'], 'createtime' => TIMESTAMP, 'pos' => $sidm['pos'], 'status' => $sidm['status']);
pdo_insert('feng_goodslist', $new_sid);
$id = pdo_insertid();
$CountNum = intval($sidm['price']);
$new_codes = array();
for ($i = 1; $i <= $CountNum; $i++) {
//.........这里部分代码省略.........
示例9: payResult
public function payResult($params)
{
global $_W, $_GPC;
$fee = intval($params['fee']);
$data = array('status' => $params['result'] == 'success' ? 1 : 0);
$paytype = array('credit' => 1, 'wechat' => 2, 'alipay' => 2, 'delivery' => 3);
$data['pay_type'] = $paytype[$params['type']];
if ($params['type'] == 'wechat') {
$data['transid'] = $params['tag']['transaction_id'];
}
$data['ptime'] = TIMESTAMP;
$data['starttime'] = TIMESTAMP;
$order_out = pdo_fetch("select * from" . tablename('tg_order') . "where orderno = '{$params['tid']}'");
$goodsInfo = pdo_fetch("SELECT * FROM" . tablename('tg_goods') . "WHERE `id` = :id ", array(':id' => $order_out['g_id']));
$nowtuan = pdo_fetch("select * from" . tablename('tg_group') . "where groupnumber = '{$order_out['tuan_id']}'");
if (!empty($nowtuan)) {
if ($nowtuan['lacknum'] == 0 && $order_out['status'] == 0) {
$data['status'] = 6;
$data['is_tuan'] = 2;
echo "<script>location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('more_refund', array('data' => $data, 'orderno' => $params['tid'])) . "';</script>";
exit;
}
}
//后台通知,修改状态
if ($params['result'] == 'success' && $params['from'] == 'notify') {
/*支付成功消息模板*/
require_once MB_ROOT . '/source/Message.class.php';
load()->model('account');
$access_token = WeAccount::token();
$url1 = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token . "";
$url2 = $_W['siteroot'] . 'app/' . $this->createMobileUrl('myorder', array('id' => $order_out['id']));
$sendmessage = new Message();
$res = $sendmessage->pay_success($order_out['openid'], $order_out['orderno'], $goodsInfo['gname'], $this, $url1, $url2);
/*支付成功模板消息*/
if ($order_out['status'] == 0) {
pdo_update('tg_order', $data, array('orderno' => $params['tid']));
if ($order_out['is_tuan'] == 0) {
pdo_update('tg_order', array('status' => 2), array('orderno' => $params['tid']));
} else {
if ($nowtuan['lacknum'] > 0) {
pdo_update('tg_group', array('lacknum' => $nowtuan['lacknum'] - 1), array('groupnumber' => $order_out['tuan_id']));
}
}
// 更改库存
if ($goodsInfo['gnum'] == 1) {
pdo_update('tg_goods', array('gnum' => $goodsInfo['gnum'] - 1, 'salenum' => $goodsInfo['salenum'] + 1, 'isshow' => 0), array('id' => $order_out['g_id']));
} elseif (!empty($goodsInfo['gnum'])) {
pdo_update('tg_goods', array('gnum' => $goodsInfo['gnum'] - 1, 'salenum' => $goodsInfo['salenum'] + 1), array('id' => $order_out['g_id']));
}
}
$now = pdo_fetch("select * from" . tablename('tg_group') . "where groupnumber = '{$order_out['tuan_id']}'");
if (!empty($now) && $now['lacknum'] == 0) {
pdo_update('tg_group', array('groupstatus' => 2), array('groupnumber' => $now['groupnumber']));
pdo_update('tg_order', array('status' => 2), array('tuan_id' => $now['groupnumber'], 'status' => 1));
/*组团成功成功消息模板*/
require_once MB_ROOT . '/source/Message.class.php';
load()->model('account');
$access_token = WeAccount::token();
$url1 = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token . "";
$url2 = '';
$sendmessage = new Message();
$res = $sendmessage->group_success($order_out['tuan_id'], $this, $url1, $url2);
/*组团成功模板消息*/
//获取所有打印机
$prints = pdo_fetchall('SELECT * FROM ' . tablename('tg_print') . ' WHERE uniacid = :aid AND status = 1', array(':aid' => $_W['uniacid']));
if (!empty($prints)) {
include_once MB_ROOT . '/source/wprint.class.php';
//遍历所有打印机
foreach ($prints as $li) {
if (!empty($li['print_no']) && !empty($li['key'])) {
$wprint = new wprint();
$alltuan = pdo_fetchall("select * from" . tablename('tg_order') . "where tuan_id = '{$now['groupnumber']}' and status = 2 ");
if ($li['mode'] == 1) {
$orderinfo .= "<CB>组团成功</CB><BR>";
$orderInfo .= "商品信息:<BR>";
$orderinfo .= '------------------------------<BR>';
$orderinfo .= "商品名称:{$goodsInfo['gname']}<BR>";
$orderinfo .= '------------------------------<BR>';
$orderinfo .= "用户信息:<BR>";
$orderinfo .= '------------------------------<BR>';
foreach ($alltuan as $row) {
$orderinfo .= "用户名:{$row['addname']}<BR>";
$orderinfo .= "手机号:{$row['mobile']}<BR>";
$orderinfo .= "地址:{$row['address']}<BR>";
$orderinfo .= '------------------------------<BR>';
}
$status = $wprint->StrPrint($li['print_no'], $li['key'], $orderinfo, $li['print_nums']);
} else {
$orderinfo .= "组团成功";
$orderInfo .= "商品信息:";
$orderinfo .= '------------------------------';
$orderinfo .= "商品名称:{$goodsInfo['gname']}";
$orderinfo .= '------------------------------';
$orderinfo .= "用户信息:";
$orderinfo .= '------------------------------';
foreach ($alltuan as $row) {
$orderinfo .= "用户名:{$row['addname']}";
$orderinfo .= "手机号:{$row['mobile']}";
$orderinfo .= "地址:{$row['address']}";
$orderinfo .= '------------------------------';
//.........这里部分代码省略.........
示例10: doMobilet
public function doMobilet()
{
global $_W, $_GPC, $codeca, $codeset, $luckset, $ckey, $settings, $webset;
$settings = $this->module['config'];
$batch = array();
load()->classs('weixin.account');
$access_token = WeAccount::token();
load()->func('communication');
if (strlen($settings['wapcss']) < 1) {
$settings['wapcss'] = 'default';
}
if (empty($_W['openid'])) {
$appid = $_W['account']['key'];
$oauth2_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . urlencode($_W['siteurl']) . "&response_type=code&scope=snsapi_userinfo&state=0#wechat_redirect";
header("location:{$oauth2_code}");
exit;
}
if (empty($_W['fans']['follow'])) {
$oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $_W['openid'] . "&lang=zh_CN";
$content = ihttp_get($oauth2_url);
$info = @json_decode($content['content'], true);
if (empty($info) || !is_array($info) || empty($info['openid'])) {
$_W['fans']['follow'] = 0;
} else {
$_W['fans']['follow'] = $info['subscribe'];
$_W['fans']['nickname'] = $info['nickname'];
}
}
if (empty($_W['fans']['follow'])) {
if (empty($settings['link'])) {
$settings['link'] = $_W['account']['qrcode'];
} else {
$settings['link'] = $_W['attachurl'] . $settings['link'];
}
include $this->template($settings['wapcss'] . '/comeon');
exit;
}
$content = $_GPC['co'];
$openid = $_W['openid'];
if ($_GPC['u'] == 'i') {
$casel = "微站";
$ctapy = 6;
} else {
$casel = "扫一扫";
$ctapy = 3;
}
$fans = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE uniacid=:uniacid AND openid=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
$member = pdo_fetch("SELECT * FROM " . tablename('mc_members') . " WHERE uniacid=:uniacid AND uid=:uid", array(':uniacid' => $_W['uniacid'], ':uid' => $fans['uid']));
if (empty($member['resideprovince']) && !empty($info['province'])) {
$member['resideprovince'] = $info['province'];
}
if (empty($member['residecity']) && !empty($info['city'])) {
$member['residecity'] = $info['city'];
}
if (empty($member['gender']) && !empty($info['sex'])) {
$member['gender'] = $info['sex'];
}
if ((int) $settings['ischuanhuo'] > 0 && !empty($_W['clientip'])) {
}
$fgltxt = "查询失败,你输入的不是有效的防伪码!";
$mm = strtoupper($content);
$mm = str_replace("-", "", str_replace(" ", "", str_replace("-", "", str_replace(" ", "", str_replace(".", "", $mm)))));
$fglact = 0;
$fglnum = 0;
$fglttt = 0;
$a = substr($mm, 2, $codeset['m'][5] - 2);
if (empty($settings['welcome'])) {
$settings['welcome'] = '欢迎您进入本公司商品防伪查询!';
}
if (empty($settings['con_msg'])) {
$settings['con_msg'] = '查询失败,查不到该防伪码!请仔细核对!';
}
if (empty($settings['luckname'])) {
$settings['luckname'] = "积分";
}
if (empty($settings['welcometxt'])) {
$settings['welcometxt'] = "现在请刮开防伪标上的涂层,\n直接在微信回复" . $codeset['m'][5] . "位防伪密码\n(英文字母要区分大小写,不要输入空格),\n您将可以参加" . $settings['luckname'] . "活动!\n";
}
if ($mm == "微信防伪") {
$fgltle = $settings['welcome'];
$fgltxt = $settings['welcometxt'];
$fglurl = "";
$fglttt = 1;
} elseif ($mm == $codeset['m'][1] . "000") {
$fgltle = $settings['welcome'];
$fgltxt = $settings['welcometxt'];
$fglurl = "";
$fglttt = 1;
} elseif (strlen($mm) != (int) $codeset['m'][5] && strlen($mm) != 18) {
$fgltxt = $settings['con_msg'] . "\n";
$fglttt = 1;
} elseif (!is_numeric($a)) {
$fgltxt = $settings['con_msg'] . "\n";
$fglttt = 1;
}
if ($fglttt == 0) {
$insert = array('cid' => $_W['uniacid'], 'cod' => $mm);
$a = ihttp_post($codeca . '&ac=5', $insert);
if (strlen($a['content']) > 5) {
$a = @json_decode($a['content'], true);
//.........这里部分代码省略.........