Example #1
0
    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 ='******'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++) {
                                    $new_codes[$i] = 1000000 + $i;
                                }
                                shuffle($new_codes);
                                $new_codes = serialize($new_codes);
                                $data1['uniacid'] = $_W['uniacid'];
                                $data1['s_id'] = $id;
                                $data1['s_len'] = $CountNum;
                                $data1['s_codes'] = $new_codes;
                                $data1['s_codes_tmp'] = $new_codes;
                                $ret = pdo_insert('feng_goodscodes', $data1);
                                unset($new_codes);
                            }
                            if ($fee == $c_number) {
                                //执行数据库操作
                                pdo_update('feng_goodscodes', $r_codes, array('id' => $codes['id']));
                                pdo_update('feng_goodslist', $sid_mess, array('id' => $sidm['id']));
                                $result_mess = '支付成功!';
                            } else {
                                $data['count'] = $c_number;
                                $reprice = $fee - $c_number;
                                load()->model('mc');
                                $result_c = mc_credit_update($_W['member']['uid'], 'credit2', $reprice);
                                //执行数据库操作
                                pdo_update('feng_goodscodes', $r_codes, array('id' => $codes['id']));
                                pdo_update('feng_goodslist', $sid_mess, array('id' => $sidm['id']));
                                $result_mess = '支付成功!';
                            }
                        }
                    } else {
                        $reprice = $fee;
                        $data['status'] = 0;
                        load()->model('mc');
                        $result_c = mc_credit_update($_W['member']['uid'], 'credit2', $reprice);
                        $result_mess = '支付失败,已退款!';
                    }
                }
                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('myorder');
                //点击模板详情跳转的地址url2
                $time = date("Y-m-d H:i:s", time());
                $openid = trim($_W['openid']);
                $msg_json = '{
	               	"touser":"******",
	               	"template_id":"' . $this->module['config']['succ_mess'] . '",
	               	"url":"' . $url2 . '",
	               	"topcolor":"#FF0000",
	               	"data":{
	                   	"first":{
	                       "value":"恭喜您,成功参与一元夺宝!",
	                       "color":"#0099FF"
	                   	},
	                   	"orderMoneySum":{
							"value":"' . $fee . '元",
	                   	    "color":"#0099FF"
						},
						"orderProductName":{
							"value":"' . $sidm['title'] . '",
	                   		"color":"#0099FF"
						},
	                   	"Remark":{
	                       "value":"点击查看订单详情",
	                       "color":"#0099FF"
	                   	}
	               	}
           		}';
                include_once 'message.php';
                $sendmessage = new WX_message();
                $res = $sendmessage->WX_request($url, $msg_json);
                pdo_update('feng_record', $data, array('id' => $params['tid']));
            }
        }
        if ($params['from'] == 'return') {
            $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 ='******'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++) {
                                    $new_codes[$i] = 1000000 + $i;
                                }
                                shuffle($new_codes);
                                $new_codes = serialize($new_codes);
                                $data1['uniacid'] = $_W['uniacid'];
                                $data1['s_id'] = $id;
                                $data1['s_len'] = $CountNum;
                                $data1['s_codes'] = $new_codes;
                                $data1['s_codes_tmp'] = $new_codes;
                                $ret = pdo_insert('feng_goodscodes', $data1);
                                unset($new_codes);
                            }
                            if ($fee == $c_number) {
                                //执行数据库操作
                                pdo_update('feng_goodscodes', $r_codes, array('id' => $codes['id']));
                                pdo_update('feng_goodslist', $sid_mess, array('id' => $sidm['id']));
                                $result_mess = '支付成功!';
                            } else {
                                $data['count'] = $c_number;
                                $reprice = $fee - $c_number;
                                load()->model('mc');
                                $result_c = mc_credit_update($_W['member']['uid'], 'credit2', $reprice);
                                //执行数据库操作
                                pdo_update('feng_goodscodes', $r_codes, array('id' => $codes['id']));
                                pdo_update('feng_goodslist', $sid_mess, array('id' => $sidm['id']));
                                $result_mess = '支付成功!';
                            }
                        }
                    } else {
                        $reprice = $fee;
                        $data['status'] = 0;
                        load()->model('mc');
                        $result_c = mc_credit_update($_W['member']['uid'], 'credit2', $reprice);
                        $result_mess = '支付失败,已退款!';
                    }
                }
                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('myorder');
                //点击模板详情跳转的地址url2
                $time = date("Y-m-d H:i:s", time());
                $openid = trim($_W['openid']);
                $msg_json = '{
	               	"touser":"******",
	               	"template_id":"' . $this->module['config']['succ_mess'] . '",
	               	"url":"' . $url2 . '",
	               	"topcolor":"#FF0000",
	               	"data":{
	                   	"first":{
	                       "value":"恭喜您,成功参与一元夺宝!",
	                       "color":"#0099FF"
	                   	},
	                   	"orderMoneySum":{
							"value":"' . $fee . '元",
	                   	    "color":"#0099FF"
						},
						"orderProductName":{
							"value":"' . $sidm['title'] . '",
	                   		"color":"#0099FF"
						},
	                   	"Remark":{
	                       "value":"点击查看订单详情",
	                       "color":"#0099FF"
	                   	}
	               	}
           		}';
                include_once 'message.php';
                $sendmessage = new WX_message();
                $res = $sendmessage->WX_request($url, $msg_json);
                pdo_update('feng_record', $data, array('id' => $params['tid']));
            }
            $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
            $credit = $setting['creditbehaviors']['currency'];
            if ($params['type'] == $credit) {
                message('支付成功!', $this->createMobileUrl('myorder'), 'success');
            } else {
                message('支付成功!', '../../app/' . $this->createMobileUrl('myorder'), 'success');
            }
        }
    }
Example #2
0
    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;
                }
            }
        }
    }
Example #3
0
        $add = $address['province '] . $address['city '] . $address['county'] . $address['detailed_address'];
        $ret = pdo_update('tg_order', array('status' => 9), array('orderno' => $orderno));
        $tip = 9999;
        $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());
        $data['touser'] = trim($_W['openid']);
        $openid = trim($_W['openid']);
        $msg_json = '{
                       "touser":"******",
                       "template_id":"f3EMOh59tLWHGUGwSrpl_HYTlQCHjuKZVGOuLGTSlH8",
                       "url":"' . $url2 . '",
                       "topcolor":"#FF0000",
                       "data":{
                           "first":{
                               "value":"\\n' . $content . '\\n\\n",
                               "color":"#000000"
                           },
                           "orderProductPrice":{
								"value":"' . $order['price'] . '\\n\\n",
                           		"color":"#000000"
							},
                           "orderProductName":{
								 "value":"' . $goods['gname'] . '\\n\\n",
                           	     "color":"#000000"
							},