|
- <?php
- if (!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- require_once libfile('function/mail');
- $ac=isset($_GET['ac'])?daddslashes($_GET['ac']):'';
- if(!in_array($ac, array('pay_window','checkpay')) && !empty($ac)){
- exit('Access Denied');
- }
- $goods_number=isset($_GET['goods_number'])?intval($_GET['goods_number']):1;
- $myconf = $_G['cache']['plugin']['yc88_faka'];
- $payway=unserialize($myconf['payway']);
- $goods_id=intval($_GET['goods_id']);
- if(in_array(1, $payway)){
- $myconf_yc88_pay = $_G['cache']['plugin']['yc88_pay'];
- $payway_yc88_pay=unserialize($myconf_yc88_pay['payway']);
- if(empty($myconf_yc88_pay['mchid']) || empty($myconf_yc88_pay['secret']) || empty($myconf_yc88_pay['integral_type'])){
- showmessage('yc88_pay:config_err');
- return;
- }
- }
-
- $orderid=daddslashes($_GET['orderid']);
- if($ac=='checkpay'){
- $info_order=DB::fetch_first("select status,goods_id from ".DB::table('yc88_faka_order')." where no='{$orderid}'");
- $code=DB::result_first("select content from ".DB::table('yc88_faka_kami')." where order_no='{$orderid}'");
- if(!$code){
- $code=DB::result_first("select content from ".DB::table('yc88_faka_kami')." where goods_id='{$info_order['goods_id']}'");
- }
- header("Content-Type:application/json; charset=utf-8");
- $re=array(
- 'status'=>$info_order['status'],
- 'code'=>$code
- );
- echo json_encode($re);
- die;
- }
-
-
-
- //积分
- $integral_type=$myconf['integral_type'];
- switch ($integral_type) {
- case 1:
- $jifen=DB::fetch_first("select extcredits1 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits1'];
- break;
- case 2:
- $jifen=DB::fetch_first("select extcredits2 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits2'];
- break;
- case 3:
- $jifen=DB::fetch_first("select extcredits3 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits3'];
- break;
- case 4:
- $jifen=DB::fetch_first("select extcredits4 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits4'];
- break;
- case 5:
- $jifen=DB::fetch_first("select extcredits5 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits5'];
- break;
- case 6:
- $jifen=DB::fetch_first("select extcredits6 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits6'];
- break;
- case 7:
- $jifen=DB::fetch_first("select extcredits7 from ".DB::table('common_member_count')." where uid=".$_G['uid']);
- $jifen=$jifen['extcredits7'];
- break;
- }
- $goods_info=DB::fetch_first("select * from ".DB::table('yc88_faka_goods')." where id=".$goods_id);
- $amount=$goods_info["integral"]*$goods_number;
- //库存
- $goods_kucun=DB::result_first("select count(1) from ".DB::table('yc88_faka_kami')." where goods_id={$goods_id} and status=0");
- if($goods_info['faka_type']==1){
- $goods_kucun=999;
- }
- if($goods_kucun<intval($_GET['goods_number'])){
- showmessage(lang('plugin/yc88_faka','pay_001'));
- }
- if(submitcheck('paysubmit')){
- $order_no = date('YmdHis') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
- if(daddslashes($_GET['bankid'])=='JIFEN' && $amount<=$jifen){
- $data=array(
- 'no'=>$order_no,
- 'status'=>1,
- 'uid'=>$_G['uid'],
- 'goods_id'=>$goods_id,
- 'goods_name'=>$goods_info["name"],
- 'goods_price'=>$goods_info["price"],
- 'goods_number'=>intval($_GET['goods_number']),
- 'ctime'=>time(),
- 'paytime'=>time(),
- 'email'=>daddslashes($_GET["email"]),
- 'integral'=>$goods_info["integral"]*intval($_GET['goods_number'])
- );
- $re=DB::insert('yc88_faka_order', $data);
- //发卡
- $faka_type=DB::result_first("select faka_type from ".DB::table('yc88_faka_goods')." where id=".$goods_id);
- if($faka_type==1){
- $kami_list_str=DB::result_first("select content from ".DB::table('yc88_faka_kami')." where goods_id=".$goods_id);
- }else{
- $kami_ids=DB::fetch_all("select id from ".DB::table('yc88_faka_kami')." where goods_id=".$goods_id." and order_no='' limit 0,".intval($_GET['goods_number']));
- $kami_ids_str='';
- foreach ($kami_ids as $k => $v) {
- if($k==0){
- $kami_ids_str=$v['id'];
- }else{
- $kami_ids_str.=','.$v['id'];
- }
- }
- $kami_ids_str=empty($kami_ids_str)?'0':$kami_ids_str;
- DB::query("update ".DB::table('yc88_faka_kami')." set status=1,order_no='".$order_no."' where id in({$kami_ids_str})");
- $kami_list=DB::fetch_all("select content from ".DB::table('yc88_faka_kami')." where id in({$kami_ids_str})");
- $kami_list_str='';
- foreach ($kami_list as $k => $v) {
- if($k==0){
- $kami_list_str=$v['content'];
- }else{
- $kami_list_str.='<br>'.$v['content'];
- }
- }
- }
-
-
- $email_content="<p class='summary'>".lang('plugin/yc88_faka', 'callback_001').":<span>{$order_no}</span></p><p class='summary'>".lang('plugin/yc88_faka', 'callback_002').":<span>{$kami_list_str}</span></p>";
- sendmail(daddslashes($_GET["email"]),lang('plugin/yc88_faka', 'callback_003'),$email_content);
- updatemembercount($_G['uid'], array($myconf['integral_type'] => -$goods_info['integral']*intval($_GET['goods_number'])),true,'',1,'', lang('plugin/yc88_faka', 'callback_004'));
- notification_add($_G['uid'], 'system', lang('plugin/yc88_faka', 'callback_003')."<p class='summary'>".lang('plugin/yc88_faka', 'callback_001').": <span>{$order_no}</span></p><p class='summary'>".lang('plugin/yc88_faka', 'callback_002').": <span>{$kami_list_str}</span></p>");
- header ("location:../../../home.php?mod=space&do=notice&view=system");
- }else if(in_array(1, $payway)){
- $data=array(
- 'no'=>$order_no,
- 'status'=>0,
- 'uid'=>$_G['uid'],
- 'amount'=>$goods_info["price"]*intval($_GET['goods_number']),
- 'goods_id'=>$goods_id,
- 'goods_name'=>$goods_info["name"],
- 'goods_price'=>$goods_info["price"],
- 'goods_number'=>intval($_GET['goods_number']),
- 'ctime'=>time(),
- 'email'=>daddslashes($_GET["email"]),
- );
- $re=DB::insert('yc88_faka_order', $data);
- $parter = $myconf_yc88_pay['mchid'];
- $key = $myconf_yc88_pay['secret'];
- $submiturl = 'http://api.a8tg.com/interface/chargebank.aspx';
- $callbackurl = trim($_G['siteurl'] . 'source/plugin/yc88_faka/notify.php');
- $value = $goods_info["price"]*intval($_GET['goods_number']);
- $type = daddslashes($_GET["bankid"]);
- $attach = "123";
- $sign = "parter=".$parter."&type=".$type."&orderid=".$order_no."&callbackurl=".$callbackurl;
- $sign = md5($sign.$key);
- $re=wd_http($submiturl, array(
- 'parter'=>$parter,
- 'type'=>$type,
- 'value'=>$value,
- 'orderid'=>$order_no,
- 'callbackurl'=>$callbackurl,
- 'attach'=>$attach,
- 'sign'=>$sign,
- ));
- $re=json_decode($re,true);
- switch ($type) {
- case 'ALQR':
- $pay_name=lang('plugin/yc88_pay', 'alipay');
- $pay_name_en='alipay-wechat';
- break;
- case 'WXQR':
- $pay_name=lang('plugin/yc88_pay', 'wxpay');
- $pay_name_en='wxpay-wechat';
- break;
- case 'QQQR':
- $pay_name=lang('plugin/yc88_pay', 'qqpay');
- $pay_name_en='qqpay-wechat';
- break;
- }
- include template('yc88_faka:pay_show');
- }
-
-
-
- }
-
- if($ac=='pay_window'){
- include template('yc88_faka:pay');
- }
-
-
-
- function wd_http($url, $param, $data = '', $method = 'GET',$header=''){
- return dfsockopen($url,0,$param);
- }
复制代码
修复文件与完整插件下载
|
|