예제 #1
0
파일: print.php 프로젝트: noikiy/mygit
    $id = intval($_GPC['id']);
    pdo_delete('daijia_print', array('uniacid' => $_W['uniacid'], 'id' => $id));
    message('删除打印机成功', referer(), 'success');
} elseif ($op == 'log_del') {
    $id = intval($_GPC['id']);
    pdo_delete('daiaji_order_print', array('uniacid' => $_W['uniacid'], 'id' => $id));
    message('删除打印记录成功', referer(), 'success');
} elseif ($op == 'print_log') {
    $id = intval($_GPC['id']);
    $item = pdo_fetch('SELECT * FROM ' . tablename('daijia_print') . ' WHERE uniacid = :uniacid AND id = :id', array(':uniacid' => $_W['uniacid'], ':id' => $id));
    if (empty($item)) {
        message('打印机不存在或已删除', $this->createWebUrl('print', array('op' => 'print_list')), 'success');
    }
    if (!empty($item['print_no']) && !empty($item['key'])) {
        include 'wprint.class.php';
        $wprint = new wprint();
        $status = $wprint->QueryPrinterStatus($item['print_no'], $item['key']);
        if (is_error($status)) {
            $status = '查询打印机状态失败。请刷新页面重试';
        }
    }
    $condition = ' WHERE a.uniacid = :aid AND a.sid = :sid AND a.pid = :pid';
    $params[':aid'] = $_W['uniacid'];
    $params[':sid'] = $sid;
    $params[':pid'] = $id;
    if (!empty($_GPC['oid'])) {
        $oid = trim($_GPC['oid']);
        $condition .= ' AND a.oid = :oid';
        $params[':oid'] = $oid;
    }
    $pindex = max(1, intval($_GPC['page']));
예제 #2
0
파일: site.php 프로젝트: noikiy/mygit
 public function payResult($params)
 {
     global $_W;
     $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['result'] == 'success') {
         $data['pay_time'] = TIMESTAMP;
     }
     pdo_update('daijia_orders', $data, array('ordersn' => $params['tid']));
     if ($params['from'] == 'return') {
         $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
         $credit = $setting['creditbehaviors']['currency'];
         //支付成功,打印订单
         $order = pdo_fetch("SELECT * FROM " . tablename('daijia_orders') . "where ordersn={$params['tid']}");
         //获取所有打印机
         $prints = pdo_fetchall('SELECT * FROM ' . tablename('daijia_print') . ' WHERE uniacid = :aid AND status = 1', array(':aid' => $_W['uniacid']));
         if (empty($prints)) {
             // exit('没有有效的打印机');
         }
         $paytype = $order['paytype'] == '3' ? '货到付款' : '已付款';
         $ordertype = $order['type'] == 'daijia' ? '代驾' : '代劳、代步';
         //邮件提醒
         $orderinfo = '';
         $orderinfo .= '订单编号  起始地址   目的地址 价格   备注<BR>';
         $orderinfo .= '--------------------------------<BR>';
         $orderInfo .= "{$order['ordersn']}{$order['start_address']}{$order['end_address']}{$order['price']}{$order['remark']}<br />";
         $orderInfo .= '--------------------------------<BR>';
         $orderinfo .= "合计:{$order['price']}元<BR>";
         $orderinfo .= "联系电话:{$order['mobile']}<BR>";
         $orderinfo .= "支付方式:{$paytype}<BR>";
         //微信提醒
         $sendinfo = '您的订单支付成功,请等待处理:\\n';
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "{$ordertype}详情:\n";
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "订单编号:{$order['ordersn']}\n";
         $sendinfo .= "起始地址: {$order['start_address']}\n";
         $sendinfo .= "目的地址: {$order['end_address']}\n";
         $sendinfo .= "备注: {$order['remark']}\n";
         $sendinfo .= '--------------------\\n';
         $sendinfo .= "合计:{$order['price']}元\n";
         $sendinfo .= "联系电话:{$order['mobile']}\n";
         $sendinfo .= "支付方式:{$paytype}\n";
         //发送微信提醒
         $send['msgtype'] = 'text';
         $send['text'] = array('content' => urlencode($sendinfo));
         $acc = WeAccount::create($_W['account']['acid']);
         $send['touser'] = trim($_W['openid']);
         $s_mess = $acc->sendCustomNotice($send);
         include 'wprint.class.php';
         //遍历所有打印机
         foreach ($prints as $li) {
             if (!empty($li['qrcode_link'])) {
                 $orderinfo .= "<QR>{$li['qrcode_link']}</QR>";
             }
             if (!empty($li['print_no']) && !empty($li['key'])) {
                 $wprint = new wprint();
                 $status = $wprint->StrPrint($li['print_no'], $li['key'], $orderinfo, 1);
                 if (!is_error($status)) {
                     $i++;
                     $data2 = array('uniacid' => $_W['uniacid'], 'sid' => $sid, 'pid' => $li['id'], 'oid' => $id, 'status' => 1, 'aid' => $status, 'addtime' => TIMESTAMP);
                     pdo_insert('daijia_order_print', $data2);
                 }
             }
         }
         // if($i > 0) {
         // 	 pdo_query('UPDATE ' . tablename('str_order') . " SET print_nums = print_nums + {$i} WHERE uniacid = {$_W['uniacid']} AND id = {$id}");
         // } else {
         // 	exit('发送打印指令失败。没有有效的机器号');
         // }
         // exit('success');
         //打印结束
         if ($params['type'] == $credit) {
             message('支付成功!', $this->createMobileUrl('daijia', array('op' => 'yes')), 'success');
         } else {
             message('支付成功!', '../../app/' . $this->createMobileUrl('daijia', array('op' => 'yes')), 'success');
         }
     }
 }
예제 #3
0
파일: site.php 프로젝트: noikiy/mygit
 public function doWebPrint()
 {
     global $_W, $_GPC;
     $id = intval($_GPC['id']);
     //订单ID
     $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'print_list';
     if ($op == 'print_post') {
         if ($id > 0) {
             $item = pdo_fetch('SELECT * FROM ' . tablename('shopping_print') . ' WHERE uniacid = :uniacid AND id = :id', array(':uniacid' => $_W['uniacid'], ':id' => $id));
         }
         if (empty($item)) {
             $item = array('status' => 1, 'print_nums' => 1);
         }
         if (checksubmit('submit')) {
             $data['status'] = intval($_GPC['status']);
             $data['name'] = !empty($_GPC['name']) ? trim($_GPC['name']) : message('打印机名称不能为空', '', 'error');
             $data['print_no'] = !empty($_GPC['print_no']) ? trim($_GPC['print_no']) : message('机器号不能为空', '', 'error');
             $data['key'] = !empty($_GPC['key']) ? trim($_GPC['key']) : message('打印机key不能为空', '', 'error');
             $data['print_nums'] = intval($_GPC['print_nums']) ? intval($_GPC['print_nums']) : 1;
             if (!empty($_GPC['qrcode_link']) && (strexists($_GPC['qrcode_link'], 'http://') || strexists($_GPC['qrcode_link'], 'https://'))) {
                 $data['qrcode_link'] = trim($_GPC['qrcode_link']);
             }
             $data['uniacid'] = $_W['uniacid'];
             $data['sid'] = $sid;
             if (!empty($item) && $id) {
                 pdo_update('shopping_print', $data, array('uniacid' => $_W['uniacid'], 'id' => $id));
             } else {
                 pdo_insert('shopping_print', $data);
             }
             message('更新打印机设置成功', $this->createWebUrl('print', array('op' => 'print_list')), 'success');
         }
     } elseif ($op == 'print_list') {
         $data = pdo_fetchall('SELECT * FROM ' . tablename('shopping_print') . ' WHERE uniacid = :uniacid ', array(':uniacid' => $_W['uniacid']));
         // include $this->template('print');
     } elseif ($op == 'print_del') {
         $id = intval($_GPC['id']);
         pdo_delete('shopping_print', array('uniacid' => $_W['uniacid'], 'id' => $id));
         message('删除打印机成功', referer(), 'success');
     } elseif ($op == 'log_del') {
         $id = intval($_GPC['id']);
         pdo_delete('shopping_order_print', array('uniacid' => $_W['uniacid'], 'id' => $id));
         message('删除打印记录成功', referer(), 'success');
     } elseif ($op == 'print_log') {
         $id = intval($_GPC['id']);
         $item = pdo_fetch('SELECT * FROM ' . tablename('shopping_print') . ' WHERE uniacid = :uniacid AND id = :id', array(':uniacid' => $_W['uniacid'], ':id' => $id));
         if (empty($item)) {
             message('打印机不存在或已删除', $this->createWebUrl('print', array('op' => 'print_list')), 'success');
         }
         if (!empty($item['print_no']) && !empty($item['key'])) {
             include 'wprint.class.php';
             $wprint = new wprint();
             $status = $wprint->QueryPrinterStatus($item['print_no'], $item['key']);
             if (is_error($status)) {
                 $status = '查询打印机状态失败。请刷新页面重试';
             }
         }
         $condition = ' WHERE a.uniacid = :aid AND a.sid = :sid AND a.pid = :pid';
         $params[':aid'] = $_W['uniacid'];
         $params[':sid'] = $sid;
         $params[':pid'] = $id;
         if (!empty($_GPC['oid'])) {
             $oid = trim($_GPC['oid']);
             $condition .= ' AND a.oid = :oid';
             $params[':oid'] = $oid;
         }
         $pindex = max(1, intval($_GPC['page']));
         $psize = 20;
         $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('shopping_order_print') . ' AS a ' . $condition, $params);
         $data = pdo_fetchall('SELECT a.*,b.* FROM ' . tablename('shopping_order_print') . ' AS a LEFT JOIN' . tablename('shopping_order') . ' AS b ON a.oid = b.id' . $condition . ' ORDER BY addtime DESC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, $params);
         $pager = pagination($total, $pindex, $psize);
         // include $this->template('print');
     }
     include $this->template('print');
 }
예제 #4
0
파일: site.php 프로젝트: eduNeusoft/weixin
 public function doWebCron()
 {
     global $_W, $_GPC;
     $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'limit';
     if ($op == 'limit') {
         $paytime_limit = pdo_fetchcolumn('SELECT paytime_limit FROM ' . tablename('str_config') . ' WHERE uniacid = :aid', array(':aid' => $_W['uniacid']));
         if (empty($paytime_limit)) {
             $paytime_limit = 3600;
         } else {
             $paytime_limit = $paytime_limit * 60;
         }
         pdo_query('UPDATE ' . tablename('str_order') . ' SET status = 5 WHERE uniacid = :aid AND addtime < :limittime', array(':aid' => $_W['uniacid'], ':limittime' => TIMESTAMP - $paytime_limit));
     } elseif ($op == 'print') {
         $data = pdo_fetchall('SELECT a.foid, b.print_no, b.key FROM ' . tablename('str_order_print') . ' AS a LEFT JOIN ' . tablename('str_print') . ' AS b ON a.pid = b.id WHERE a.uniacid = :aid AND a.sid = :sid AND a.status = 0 ORDER BY addtime ASC LIMIT 5', array(':aid' => $_W['uniacid'], ':sid' => $sid));
         if (!empty($data)) {
             include 'wprint.class.php';
             foreach ($data as $da) {
                 if (!empty($da['foid']) && !empty($da['print_no']) && !empty($da['key'])) {
                     $print = new wprint();
                     $status = $print->QueryOrderState($da['print_no'], $da['key'], $da['foid']);
                     if (!is_error($status)) {
                         pdo_update('str_order_print', array('status' => $status), array('uniacid' => $_W['uniacid'], 'sid' => $sid, 'foid' => $da['foid']));
                     }
                 }
             }
         }
     }
 }
예제 #5
0
파일: site.php 프로젝트: ChainBoy/wxfx
    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":"******",

               	"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));
                }
            }
            $order_out = pdo_fetch("select * from" . tablename('tg_order') . "where orderno = '{$params['tid']}'");
            //判断人数,是否团购成功
            $sql = "SELECT * FROM" . tablename('tg_order') . "where tuan_id=:tuan_id and status =:status ";
            $params = array(':tuan_id' => $tuan_id['tuan_id'], ':status' => 1);
            $alltuan = pdo_fetchall($sql, $params);
            $item = array();
            foreach ($alltuan as $num => $all) {
                $item[$num] = $all['id'];
                if ($all['tuan_first'] == 1) {
                    $tuan_firstopenid = $all['openid'];
                }
            }
            $profile = pdo_fetch("SELECT * FROM " . tablename('tg_member') . " WHERE uniacid ='{$_W['uniacid']}' and from_user = '******'");
            $n = $goodsInfo['groupnum'] - count($item);
            if ($n == 0) {
                pdo_update('tg_order', array('success' => 0), array('tuan_id' => $tuan_id['tuan_id'], 'status' => 1));
                //组团成功模板消息提醒
                $m_tuan = $this->module['config']['m_tuan'];
                $tuan_suc = $this->module['config']['tuan_suc'];
                $tuan_remark = $this->module['config']['tuan_remark'];
                $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 = "";
                //点击模板详情跳转的地址url2
                $time = date("Y-m-d H:i:s", time());
                foreach ($alltuan as $num => $all) {
                    $openid = trim($all['openid']);
                    $msg_json = '{

	                   	"touser":"******",

	                   	"template_id":"' . $m_tuan . '",

	                   	"url":"' . $url2 . '",

	                   	"topcolor":"#FF0000",

	                   	"data":{

	                       	"first":{

	                           "value":"\\n' . $tuan_suc . '\\n",

	                           "color":"#000000"

	                       	},

	                       	"Pingou_ProductName":{

								"value":"' . $goodsInfo['gname'] . '\\n",

	                       		"color":"#000000"

							},

	                       	"Weixin_ID":{

								"value":"' . $profile['nickname'] . '\\n",

	                       	    "color":"#000000"

							},

	                       	"remark":{

	                           "value":"\\n\\n' . $tuan_remark . '",

	                           "color":"#0099FF"

	                       	}

	                   	}

	               	}';
                    $sendme = new WX_message();
                    $res = $sendme->WX_request($url, $msg_json);
                    //获取所有打印机
                    $prints = pdo_fetchall('SELECT * FROM ' . tablename('tg_print') . ' WHERE uniacid = :aid AND status = 1', array(':aid' => $_W['uniacid']));
                    if (!empty($prints)) {
                        include_once 'wprint.class.php';
                        //遍历所有打印机
                        foreach ($prints as $li) {
                            if (!empty($li['print_no']) && !empty($li['key'])) {
                                $wprint = new wprint();
                                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) {
                                        $user = pdo_fetch("select * from" . tablename('tg_address') . "where id='{$row['addressid']}'");
                                        $orderinfo .= "用户名:{$user['cname']}<BR>";
                                        $orderinfo .= "手机号:{$user['tel']}<BR>";
                                        $orderinfo .= "地址:{$user['province']}{$user['city']}{$user['county']}{$user['detailed_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) {
                                        $user = pdo_fetch("select * from" . tablename('tg_address') . "where id='{$row['addressid']}'");
                                        $orderinfo .= "用户名:{$user['cname']}";
                                        $orderinfo .= "手机号:{$user['tel']}";
                                        $orderinfo .= "地址:{$user['province']}{$user['city']}{$user['county']}{$user['detailed_address']}";
                                        $orderinfo .= '------------------------------';
                                    }
                                    $status = $wprint->testSendFreeMessage($li['member_code'], $li['print_no'], $li['key'], $orderinfo);
                                }
                                if (!is_error($status)) {
                                    $i++;
                                    $data = array('uniacid' => $_W['uniacid'], 'sid' => $sid, 'pid' => $li['id'], 'oid' => $id, 'status' => 1, 'foid' => $status, 'addtime' => TIMESTAMP);
                                    pdo_insert('tg_order_print', $data);
                                }
                            }
                        }
                    }
                }
            } elseif ($n < 0) {
                echo "<script>location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('more_refund', array('transid' => $order_out['transid'])) . "';</script>";
                exit;
            }
            if ($params['type'] == $credit) {
                if ($tuan_id['is_tuan'] == 0) {
                    //					message('支付成功!', $this->createMobileUrl('myorder'), 'success');
                    echo "<script>alert('支付成功!');location.href='" . $this->createMobileUrl('myorder') . "';</script>";
                    exit;
                } else {
                    //					message('支付成功!', $this->createMobileUrl('group',array('tuan_id' => $tuan_id['tuan_id'])), 'success');
                    echo "<script>alert('支付成功!');location.href='" . $this->createMobileUrl('group', array('tuan_id' => $tuan_id['tuan_id'])) . "';</script>";
                    exit;
                }
            } else {
                if ($tuan_id['is_tuan'] == 0) {
                    //					message('支付成功!', '../../app/' . $this->createMobileUrl('myorder'), 'success');
                    echo "<script>alert('支付成功!');location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('myorder') . "';</script>";
                    exit;
                } else {
                    //			   		message('支付成功!', '../../app/' . $this->createMobileUrl('group',array('tuan_id' => $tuan_id['tuan_id'])), 'success');
                    echo "<script>alert('支付成功!');location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('group', array('tuan_id' => $tuan_id['tuan_id'])) . "';</script>";
                    exit;
                }
            }
        }
    }
예제 #6
0
파일: site.php 프로젝트: noikiy/mygit
 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 .= '------------------------------';
                             }
                             $status = $wprint->testSendFreeMessage($li['member_code'], $li['print_no'], $li['key'], $orderinfo);
                         }
                     }
                 }
             }
         }
     }
     //前台通知
     if ($params['from'] == 'return') {
         $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
         $credit = $setting['creditbehaviors']['currency'];
         if ($params['type'] == $credit) {
             if ($order_out['is_tuan'] == 0) {
                 echo "<script> location.href='" . $this->createMobileUrl('myorder', array('payreslut' => 'success')) . "';</script>";
                 exit;
             } else {
                 echo "<script>  location.href='" . $this->createMobileUrl('group', array('tuan_id' => $order_out['tuan_id'], 'payreslut' => 'success')) . "';</script>";
                 exit;
             }
         } else {
             if ($order_out['is_tuan'] == 0) {
                 echo "<script>  location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('myorder', array('payreslut' => 'success')) . "';</script>";
                 exit;
             } else {
                 echo "<script>  location.href='" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('group', array('tuan_id' => $order_out['tuan_id'], 'payreslut' => 'success')) . "';</script>";
                 exit;
             }
         }
     }
 }