Exemple #1
0
 function groupon()
 {
     /**
      * 团购清理
      */
     $t = regiment::time_limit();
     $join_time = time() - $t * 60;
     $join_time = date("Y-m-d H:i:s", $join_time);
     $tb = new IModel("regiment_user_relation");
     $list = $tb->query("join_time<'{$join_time}'");
     $order_no = array();
     if ($list) {
         foreach ($list as $key => $value) {
             if ($value['order_no'] != "") {
                 $order_no[] = trim($value['order_no']);
             }
         }
         $order_no = array_unique($order_no);
         //找出没有付款的订单
         $order_no = "'" . implode("','", $order_no) . "'";
         $tb = new IModel("order");
         $tb->setData(array('if_del' => 1));
         $list = $tb->update("pay_status=0 AND order_no IN ({$order_no})");
     }
     /**
      * 团购清理结束
      */
     $id = IReq::get("id");
     $regiment_list = Regiment::getList($id);
     $regiment_list = $regiment_list['list'];
     $i = 1;
     foreach ($regiment_list as $key => $value) {
         $regiment_list[$key]['order_num'] = sprintf("%02s", $i);
         $i++;
     }
     $this->regiment_list = $regiment_list;
     //往期团购
     $this->ever_list = Regiment::getEverList();
     $this->redirect("groupon");
 }
Exemple #2
0
 /**
  * @brief 获取订单中的支付信息
  * @payment_id   支付方式信息
  * @type         信息获取方式 order:订单支付;recharge:在线充值;
  * @argument     参数
  * @return array 支付提交信息
  * R表示店铺 ; P表示用户;
  */
 public function getPaymentInfo($payment_id, $type, $argument)
 {
     if ($type == 'order') {
         $order_id = $argument;
         //获取订单信息
         $orderObj = new IModel('order');
         $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
         if (empty($orderRow)) {
             IError::show(403, '订单信息不正确,不能进行支付');
         }
         //团购
         if ($orderRow['type'] == 1) {
             $regimentRelationObj = new IModel('regiment_user_relation');
             $relationRow = $regimentRelationObj->getObj('order_no = "' . $orderRow['order_no'] . '"');
             if (empty($relationRow)) {
                 IError::show(403, '团购订单已经失效');
                 exit;
             } else {
                 if (abs(ITime::getDiffSec($relationRow['join_time'])) > regiment::time_limit() * 60) {
                     IError::show(403, '支付时间已经过期');
                     exit;
                 }
             }
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $orderRow['order_amount'];
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
         $payment['P_Email'] = '';
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Block::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['payment_type'], 'status' => 0);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Def_Amount'] = 0.01;
     $payment['M_Time'] = time();
     $payment['M_Goods'] = '';
     $payment['M_Language'] = "zh_CN";
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     $payment['R_Postcode'] = '';
     $payment['R_Email'] = '';
     return $payment;
 }