Esempio n. 1
0
 /**
  * 向支付宝提交数据
  */
 public function actionGotopay()
 {
     if (isset($_POST['chongzhi_form']) && isset($_POST['chongzhi_form']['chongzhimoney'])) {
         #判断传输的资金是否正确
         if (is_numeric($_POST['chongzhi_form']['chongzhimoney']) && $_POST['chongzhi_form']['chongzhimoney'] > 0.01) {
             #生成订单
             $user_id = Yii::app()->user->getId();
             $trade_no = time() . $user_id . rand(10000, 99999);
             $money = $_POST['chongzhi_form']['chongzhimoney'];
             $banktype = "ZFB";
             $remark = "赚赚乐在线充值服务";
             if (isset($_POST['chongzhi_form']['bank'])) {
                 $banktype = $_POST['chongzhi_form']['bank'];
             }
             $newRecharge = new Recharge();
             $newRecharge->setAttributes(array('trade_no' => $trade_no, 'user_id' => $user_id, 'money' => $money, 'payment' => 1, 'type' => 1, 'fee' => 0, 'bankcode' => $banktype, 'remark' => $remark));
             if ($newRecharge->validate() && $newRecharge->save()) {
                 $alipay = Yii::app()->alipay;
                 // If starting a guaranteed payment, use AlipayGuaranteeRequest instead
                 $request = new AlipayDirectRequest();
                 $request->out_trade_no = $trade_no;
                 $request->subject = "赚赚乐充值";
                 $request->body = $remark;
                 $request->total_fee = $money;
                 $request->defaultbank = $banktype;
                 // Set other optional params if needed
                 $form = $alipay->buildForm($request);
                 echo $form;
                 exit;
             }
         }
     }
     $this->redirect("/index.html");
 }
 public function postRecharge()
 {
     try {
         $voucher_type = Input::get('voucher_type', NULL);
         $pin = Input::get('pin', NULL);
         if ($voucher_type == NULL) {
             throw new Exception("Select Voucher Type.");
         }
         if ($pin == NULL) {
             throw new Exception("Please enter a valid PIN");
         }
         switch ($voucher_type) {
             case 'prepaid':
                 Recharge::viaPin($pin, Auth::id());
                 $this->notifySuccess('Recharge Successful.');
                 break;
             case 'refill':
                 Refillcoupons::viaPin($pin, Auth::id());
                 $this->notifySuccess('Refill Applied.');
                 break;
         }
         return Redirect::route(self::HOME);
     } catch (Exception $e) {
         $this->notifyError($e->getMessage());
         return Redirect::back();
     }
 }
 public function prepaidResponse()
 {
     $response = DP::response(Input::all());
     DirecpayTransaction::updateResponse($response);
     if ($response->txnSucceed()) {
         $details = $response->getDetails();
         switch ($details['type']) {
             case 'recharge':
                 Recharge::online(Auth::id(), $details['plan_id']);
                 $this->notifySuccess('Account Recharged.');
                 break;
             case 'refill':
                 try {
                     Refillcoupons::refillOnline(Auth::id(), $details);
                     $this->notifySuccess('Quota Refilled.');
                 } catch (Exception $e) {
                     $this->notifyError($e->getMessage());
                     return Redirect::route('prepaid.dashboard');
                 }
                 break;
         }
     } else {
         $this->notifyError('Transaction Failed.');
     }
     return Redirect::route('prepaid.dashboard');
 }
 public static function now($pin, $uid, $method = 'pin')
 {
     $voucher = Voucher::where('pin', $pin)->firstOrFail();
     $rc['voucher_id'] = $voucher->id;
     $rc['recharged_on'] = date('Y-m-d H:i:s');
     $rc['aq_invocked'] = 0;
     $rc['expiration'] = AccessManager::makeExpiry($voucher->validity, $voucher->validity_unit, 'd M Y H:i');
     $rc['time_limit'] = NULL;
     $rc['data_limit'] = NULL;
     if ($voucher->plan_type == 1) {
         //if limited
         $limit = $voucher->limits;
         // $rc['limit_type'] = $limit->limit_type;
         if ($limit->limit_type == 0 || $limit->limit_type == 2) {
             $rc['time_limit'] = $limit->time_limit * constant($limit->time_unit);
         }
         if ($limit->limit_type == 1 || $limit->limit_type == 2) {
             $rc['data_limit'] = $limit->data_limit * constant($limit->data_unit);
         }
     }
     $recharge = Recharge::firstOrNew(['user_id' => $uid]);
     $recharge->fill($rc);
     if (!$recharge->save()) {
         return FALSE;
     }
     $voucher->fill(['user_id' => $uid, 'method' => $method]);
     if (!$voucher->save()) {
         return FALSE;
     }
     return TRUE;
 }
 public function postRecharge()
 {
     $input = Input::all();
     $v = Validator::make($input, Config::get('validations.recharge_account'));
     $v->setAttributeNames(Config::get('attributes.recharge_account'));
     if ($v->fails()) {
         return Redirect::back()->withInput()->withErrors($v);
     }
     Recharge::viaAdmin($input);
     return Redirect::route(self::HOME);
 }
Esempio n. 6
0
 public function recharge($phone)
 {
     $msg = array("result" => 0, "error" => 1, "data" => "系统错误,请重试");
     $common = new Common();
     $admin = new Admin();
     $json = new Services_JSON();
     $orderid = $common->get_orderid(0);
     $recharge = new Recharge(APIX_PHONE_APPKEY);
     $check = $recharge->recharge_check($phone, $this->valifycode['money_num']);
     if ($check['Code'] == '0') {
         $res = $recharge->phone_recharge($phone, $this->valifycode['money_num'], $orderid, "http://hd.bxcjy.com/rechargecallback.php");
         $data = array('orderid' => $orderid, 'activity_id' => $this->valifycode['activity_id'], 'activity_name' => $this->valifycode['activity_name'], 'valifycode' => $this->valifycode['valifycode'], 'money_num' => $this->valifycode['money_num'], 'tradeplat' => 'APIX', 'tradeaccount' => $phone, 'tradestatus' => $res['Code'] == '0' ? 0 : intval($res['Code']), 'message' => preg_replace("#\\\\u([0-9a-f]+)#ie", "iconv('UCS-2','UTF-8', pack('H4', '\\1'))", $json->encode($res)), 'add_time' => date('Y-m-d H:i:s'));
         $table = $GLOBALS['Base']->table('rechargerecord');
         $GLOBALS['Mysql']->insert($data, $table);
         if ($res && $res['Code'] == '0') {
             $msg = array("result" => 1, "error" => 0, "data" => "充值成功");
         } else {
             $msg = array("result" => 0, "error" => 1, "data" => "充值失败");
         }
     } else {
         $msg = array("result" => 0, "error" => 1, "data" => $check['Msg']);
     }
     return $msg;
 }
 public static function refillPrepaid($coupon, $recharge)
 {
     $limit = VoucherLimit::findOrFail($recharge->limit_id);
     $balance = Recharge::findOrFail($recharge->id);
     if ($coupon->have_time && $coupon->have_data && $limit->limit_type != BOTH_LIMITS) {
         throw new Exception("Coupon having both Time and Data can only be applied to account having both limits.");
     }
     if ($coupon->have_time && !$coupon->have_data && $limit->limit_type != TIME_LIMIT) {
         throw new Exception("Time Balance coupons can only be applied to accounts with Time Limit.");
     }
     if ($coupon->have_data && !$coupon->have_time && $limit->limit_type != DATA_LIMIT) {
         throw new Exception("Data Balance coupons can only be applied to account with Data Limit");
     }
     $result = FALSE;
     if ($coupon->have_time && ($limit->limit_type == TIME_LIMIT || $limit->limit_type == BOTH_LIMITS)) {
         if ($limit->time_limit >= 0) {
             $balance->increment('time_limit', $coupon->time_limit * constant($coupon->time_unit));
         } else {
             $balance->time_limit = $coupon->time_limit * constant($coupon->time_unit);
             $balance->save();
         }
         $result = TRUE;
     }
     if ($coupon->have_data && ($limit->limit_type == DATA_LIMIT || $limit->limit_type == BOTH_LIMITS)) {
         if ($limit->data_limit >= 0) {
             $balance->increment('data_limit', $coupon->data_limit * constant($coupon->data_unit));
         } else {
             $balance->data_limit = $coupon->data_limit * constant($coupon->data_unit);
             $balance->save();
         }
         $result = TRUE;
     }
     if ($result == TRUE && $recharge->aq_access == ALLOWED) {
         DB::table('user_recharges')->where(['user_id' => $recharge->id])->update(['aq_invocked' => 0]);
         $this->_invokeCoA($recharge->uname);
     }
     return $result;
 }
 public function postDelete($id)
 {
     $this->notifyError("Operation Not Permitted.");
     return Redirect::back();
     //////////////////////////////////////////////////////
     try {
         DB::transaction(function () use($id) {
             if (!Subscriber::destroy($id) || Recharge::where('user_id', $id)->count() && !Recharge::where('user_id', $id)->delete()) {
                 throw new Exception("Account could not be deleted, please try again.");
             }
         });
         $this->notifySuccess("Account Successfully deleted.");
         return Redirect::route(self::HOME);
     } catch (Exception $e) {
         $this->notifyError($e->getMessage());
         return Redirect::route(self::HOME);
     }
 }
Esempio n. 9
0
<table class="table table-bordered table-striped">
    <tr>
        <th>序号</th>
        <th>提现金额</th>
        <th>到帐金额</th>
        <th>手续费</th>
        <th>申请时间</th>
        <th>状态</th>
        <th>操作<span class="pull-right"><a href="/member/index/log.html?tab=tab1">更多记录</a></span></th>
    </tr>
    <?php 
#获得最新的提现记录
$tixianlogs = Recharge::model()->findAll(array('condition' => 'user_id=:user_id', 'order' => 'id desc', 'limit' => '8', 'params' => array(':user_id' => Yii::app()->user->getState("_user_id"))));
?>
    <?php 
if ($tixianlogs) {
    foreach ($tixianlogs as $value) {
        ?>
            <tr>
                <td><?php 
        echo $value->id;
        ?>
</td>
                <td><?php 
        echo $value->total;
        ?>
</td>
                <td><?php 
        echo $value->credited;
        ?>
</td>
 public function getStatus()
 {
     $getbalance = Rechargeurl::status();
     if ($getbalance) {
         $new_array = Commonmodel::arr($getbalance);
         $finalarray = $new_array['RESPONSERECHARGEINFO']['SOPERATOR'];
         foreach ($finalarray as $new_arrays) {
             $status = $new_arrays['DESCRIPTION'];
             if ($status = 'APPAN DUKAN MARKETING') {
                 $input = array('rd_result' => 'Success');
                 Recharge::where('rd_trans_id', '=', $new_arrays['RESPONSEID'])->update($input);
             }
         }
         return Response::json(array('status' => 'Success', 'message' => 'Status Updated Successfully'));
     } else {
         return Response::json(array('status' => 'failure', 'message' => 'No Transaction History'));
     }
 }
Esempio n. 11
0
 public static function recharge($pin, $account_id)
 {
     $voucher = Recharge::build($pin);
 }