Exemplo n.º 1
0
 public function go_pay_()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $pay_money = floatval($_REQUEST['pay_money']);
     $paypassword = strim($_REQUEST['paypassword']);
     if ($paypassword == '') {
         showErr("请输入支付密码", 0);
     }
     if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) {
         showErr("支付密码错误", 0);
     }
     $credit = floatval($_REQUEST['credit']);
     $pay_score = intval($_REQUEST['pay_score']);
     if ($pay_score > 0) {
         $score_array = score_to_money($pay_score);
         $pay_score_money = $score_array['score_money'];
         $pay_score = $score_array['score'];
     } else {
         $pay_score_money = 0;
     }
     $is_tg = intval($_REQUEST['is_tg']);
     if ($is_tg) {
         if (!$GLOBALS['is_user_tg']) {
             $jump_url = APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $GLOBALS['user_info']['id'];
             showErr("您未绑定第三方接口无法支付,点击确定后跳转到绑定页面", 0, $jump_url);
         }
     }
     $payment_id = intval($_REQUEST['payment']);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $id);
     if (!$deal_info) {
         app_redirect(url("index"));
     } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) {
         app_redirect(url("deal#show", array("id" => $deal_item['deal_id'])));
     }
     /*$buy_right_number = 0;
     		if($deal_info['type']==3||$deal_info['type']==4){//企业众筹和币创投
     			$rights = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_right where deal_id = ".$deal_info["id"]." and user_id = ".intval($GLOBALS['user_info']['id'])."");
     			if(count($rights)>0){ 
     				foreach ($rights as $k=>$v){
     					$buy_right_number += $v["right_amount"] + $v["frozen_right_amount"];
     			}
     			}  
     		}*/
     $buy_right_number = get_zc_right_number($deal_info["id"], intval($GLOBALS['user_info']['id']));
     $zc_amount = $pay_money / $deal_info["price_per_right"];
     if ($deal_info["zc_amount_limit"] > 0 && $zc_amount + $buy_right_number > $deal_info["zc_amount_limit"]) {
         showErr("对不起,您众筹数字权益份额已经超过上限!", 0, url("deal#show", array("id" => $deal_info["id"])));
     }
     $zc_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order where deal_id = " . $deal_info["id"] . " and user_id = " . $GLOBALS['user_info']['id']);
     if ($deal_info["zc_count_limit"] != 0 and $zc_count >= $deal_info["zc_count_limit"]) {
         showErr("对不起,您参与次数超过上限,已经无法继续参与本项目!", 0, url("deal#show", array("id" => $deal_info["id"])));
     }
     $order_info['type'] = 0;
     //普通众筹
     $order_info['is_tg'] = $is_tg;
     $order_info['deal_id'] = $deal_info['id'];
     $order_info['deal_item_id'] = 0;
     $order_info['user_id'] = intval($GLOBALS['user_info']['id']);
     $order_info['user_name'] = $GLOBALS['user_info']['user_name'];
     $order_info['total_price'] = floatval($_REQUEST['pay_money']);
     $order_info['delivery_fee'] = 0;
     $order_info['deal_price'] = floatval($_REQUEST['pay_money']);
     //$order_info['support_memo'] = $memo;
     $order_info['payment_id'] = $payment_id;
     $order_info['bank_id'] = strim($_REQUEST['bank_id']);
     $order_info['share_fee'] = 0;
     if (!$is_tg) {
         $credit_score_money = $pay_score_money + $credit;
         if ($credit > $GLOBALS['user_info']['money']) {
             showErr("余额最多只能用" . format_price($GLOBALS['user_info']['money']), 0);
         }
         if ($pay_score > $GLOBALS['user_info']['score']) {
             showErr("积分最多只能用" . $GLOBALS['user_info']['score']);
         }
         if ($credit_score_money > $order_info['total_price']) {
             showErr("支付超出");
         }
         if (intval(($order_info['total_price'] - $credit_score_money) * 100) > 0 && $payment_id == 0) {
             showErr("请选择支付方式");
         }
     }
     if ($credit > 0) {
         $order_info['credit_pay'] = $credit;
     }
     if ($pay_score > 0) {
         $order_info['score'] = $pay_score;
         $order_info['score_money'] = $pay_score_money;
     }
     $order_info['online_pay'] = 0;
     $order_info['deal_name'] = $deal_info['name'];
     $order_info['order_status'] = 0;
     $order_info['create_time'] = NOW_TIME;
     $order_info['is_success'] = $deal_info['is_success'];
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info);
     $order_id = $GLOBALS['db']->insert_id();
     if ($order_id > 0) {
         if ($is_tg) {
             $sign = md5(md5($paypassword) . $order_id);
             $url = APP_ROOT . "/index.php?ctl=collocation&act=RegisterCreditor&order_id=" . $order_id . "&sign=" . $sign;
             //showSuccess("",0,$url);
             app_redirect($url);
         }
         $result = pay_order($order_id);
         if ($result['status'] == 0) {
             $money = $result['money'];
             $payment_notice['create_time'] = NOW_TIME;
             $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
             $payment_notice['payment_id'] = $payment_id;
             $payment_notice['money'] = $money;
             $payment_notice['bank_id'] = strim($_REQUEST['bank_id']);
             $payment_notice['order_id'] = $order_id;
             $payment_notice['memo'] = $memo;
             $payment_notice['deal_id'] = $deal_info['id'];
             $payment_notice['deal_item_id'] = 0;
             $payment_notice['deal_name'] = $deal_info['name'];
             do {
                 $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymdhi") . rand(10000, 99999);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                 $notice_id = $GLOBALS['db']->insert_id();
             } while ($notice_id == 0);
             app_redirect(url("cart#jump", array("id" => $notice_id)));
         } elseif ($result['status'] == 1 || $result['status'] == 2) {
             app_redirect(url("account#credit"));
         } elseif ($result['status'] == 5) {
             showErr("很遗憾,订单支付失败");
         } else {
             app_redirect(url("account"));
         }
     } else {
         showErr("下单失败", 0, get_gopreview());
     }
 }
Exemplo n.º 2
0
 public function show()
 {
     //get_mortgate();
     //获取项目的ID
     $id = intval($_REQUEST['id']);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))");
     if (!$deal_info) {
         app_redirect(url("index"));
     }
     $access = get_level_access($GLOBALS['user_info'], $deal_info);
     $GLOBALS['tmpl']->assign("access", $access);
     $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']);
     $deal_info['login_time'] = $GLOBALS['db']->getOne("select login_time from " . DB_PREFIX . "user where id=" . $deal_info['user_id']);
     $deal_info['user_icon'] = $GLOBALS['user_level'][$deal_info['user_level']]['icon'];
     $deal_info['is_investor'] = $GLOBALS['db']->getOne("select is_investor from " . DB_PREFIX . "user where id=" . $deal_info['user_id']);
     //权益交易相关参数
     //程超 2015-11-13
     $deal_info['deal_title'] = "【" . $deal_info['deal_code'] . "】" . $deal_info['name'];
     $deal_info["repaid_day"] = $GLOBALS['db']->getOne("select repaid_day from " . DB_PREFIX . "deal_item where deal_id = " . $deal_info["id"] . " limit 0,1");
     //$trade_begin_time = intval($deal_info["end_time"])+24*3600;
     $delivery_begin_time = intval($deal_info["trade_end_time"]);
     $GLOBALS['tmpl']->assign("trade_begin_time", to_date($deal_info["trade_begin_time"], "Y年m月d日H时i分"));
     $GLOBALS['tmpl']->assign("delivery_begin_time", to_date($delivery_begin_time, "Y年m月d日H时i分"));
     //添加结束
     /*$buy_right_number = 0;
      		if($deal_info['type']==3||$deal_info['type']==4){//企业众筹和币创投
      			$rights = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_right where deal_id = ".$deal_info["id"]." and user_id = ".intval($GLOBALS['user_info']['id'])."");
      			if(count($rights)>0){ 
      				foreach ($rights as $k=>$v){
      					$buy_right_number += $v["right_amount"] + $v["frozen_right_amount"];
     
      				}
      			}  
      		}*/
     $buy_right_number = get_zc_right_number($deal_info["id"], intval($GLOBALS['user_info']['id']));
     $deal_info["zc_amount_limit"] = intval($deal_info["zc_amount_limit"]);
     $GLOBALS['tmpl']->assign("buy_right_number", intval($buy_right_number));
     $GLOBALS['tmpl']->assign("can_buy_right_number", intval($deal_info["zc_amount_limit"] - $buy_right_number));
     if ($deal_info['is_effect'] == 1) {
         log_deal_visit($deal_info['id']);
     }
     if ($deal_info['type'] == 1) {
         //跟投人数
         $gen_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where  type=2 and  deal_id=" . $id);
         $GLOBALS['tmpl']->assign('gen_num', intval($gen_num));
         //询价人数
         $xun_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where  type=0 and  deal_id=" . $id);
         $GLOBALS['tmpl']->assign('xun_num', intval($xun_num));
     }
     $deal_info = cache_deal_extra($deal_info);
     //获取正在进行的活动(收益活动,赠金券活动)   后期必须加入状态
     $profit_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "profit where deal_id =" . $id);
     $ticket_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "ticket where deal_id =" . $id);
     $activity_count = $profit_count + $ticket_count;
     $GLOBALS['tmpl']->assign("activity_count", $activity_count);
     $comment_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1");
     $GLOBALS['tmpl']->assign('comment_count', $comment_count);
     $this->init_deal_page(@$deal_info);
     if (app_conf("INVEST_STATUS") == 2 && $deal_info['type'] == 0) {
         showErr("产品众筹已经关闭");
     }
     if ($deal_info['type'] == 1) {
         $GLOBALS['tmpl']->assign('deal_type', 'gq_type');
     } else {
         $GLOBALS['tmpl']->assign('deal_type', 'product_type');
     }
     if ($deal_info['type'] == 1) {
         if (app_conf("INVEST_STATUS") == 1) {
             showErr("股权众筹已经关闭");
         }
         set_deal_status($deal_info);
         $GLOBALS['tmpl']->assign("id", $id);
         $user_name = $GLOBALS['user_info']['user_name'];
         $GLOBALS['tmpl']->assign("user_name", $user_name);
         $deal_info['business_create_time'] = to_date($deal_info['business_create_time'], 'Y-m-d');
         $cate = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id =" . $deal_info['cate_id']);
         $GLOBALS['tmpl']->assign("cate", $cate);
         //编辑及管理团队
         $stock_list = unserialize($deal_info['stock']);
         $GLOBALS['tmpl']->assign("stock_list", $stock_list);
         $unstock_list = unserialize($deal_info['unstock']);
         $GLOBALS['tmpl']->assign("unstock_list", $unstock_list);
         //项目历史执行资料
         $history_list = unserialize($deal_info['history']);
         $GLOBALS['tmpl']->assign("history_list", $history_list);
         $total_history_income = 0;
         $total_history_out = 0;
         $total_history = 0;
         foreach ($history_list as $key => $v) {
             $total_history_income += floatval($v["info"]["item_income"]);
             $total_history_out += floatval($v["info"]["item_out"]);
             $total_history = $total_history_income - $total_history_out;
         }
         $GLOBALS['tmpl']->assign("total_history_income", $total_history_income);
         $GLOBALS['tmpl']->assign("total_history_out", $total_history_out);
         $GLOBALS['tmpl']->assign("total_history", $total_history);
         //未来三年内计划
         $plan_list = unserialize($deal_info['plan']);
         $GLOBALS['tmpl']->assign("plan_list", $plan_list);
         $total_plan_income = 0;
         $total_plan_out = 0;
         $total_plan = 0;
         foreach ($plan_list as $key => $v) {
             $total_plan_income += floatval($v["info"]["item_income"]);
             $total_plan_out += floatval($v["info"]["item_out"]);
             $total_plan = $total_plan_income - $total_plan_out;
         }
         $GLOBALS['tmpl']->assign("total_plan_income", $total_plan_income);
         $GLOBALS['tmpl']->assign("total_plan_out", $total_plan_out);
         $GLOBALS['tmpl']->assign("total_plan", $total_plan);
         //项目附件
         $attach_list = unserialize($deal_info['attach']);
         $GLOBALS['tmpl']->assign("attach_list", $attach_list);
         //资质证明
         $audit_data_list = unserialize($deal_info['audit_data']);
         $GLOBALS['tmpl']->assign("audit_data_list", $audit_data_list);
         //跟投、领投信息列表
         get_investor_info($id);
         //var_dump($deal_info);
         $GLOBALS['tmpl']->assign("deal_item", $deal_info);
         //热门的项目
         $deal_hot_result = get_deal_list($limit, 'is_hot=1', 'support_count desc');
         $GLOBALS['tmpl']->assign("deal_hot_list", $deal_hot_result['list']);
         $GLOBALS['tmpl']->display("deal_investor_show.html");
     } else {
         //普通众筹
         $GLOBALS['tmpl']->display("deal_show.html");
     }
 }