修復bug的12個關鍵步驟
posted @ 2014-11-21 10:50 順其自然EVO 閱讀(201) | 評論 (0) | 編輯 收藏
blog已經轉移至github,大家請訪問 http://qaseven.github.io/
posted @ 2014-11-21 10:50 順其自然EVO 閱讀(201) | 評論 (0) | 編輯 收藏
/** *支付訂單 */ publicfunctionpay(){ header("Content-Type:text/html;charset=utf-8"); $id=I('post.oid','','htmlspecialchars'); $DAO=M('order'); $order=$DAO->where("id=".$id)->find(); $error=""; if(!isset($order)){ $error="訂單不存在"; }elseif($order['PaymentStatus']==1){ $error="此訂單已經完成,無需再次支付!"; }elseif($order['PaymentStatus']==2){ $error="此訂單已經取消,無法支付,請重新下單!"; } if($error!=""){ $this->_FAIL("系統錯誤",$error,$this->getErrorLinks()); return; } $payType=I('post.payType','','htmlspecialchars'); #支付寶 if($payType=='alipay'){ $this->payWithAlipay($order); } } |
/** *以支付寶形式支付 *@paramunknown_type$order */ privatefunctionpayWithAlipay($order){ //引入支付寶相關的文件 require_once(VENDOR_PATH."Alipay/alipay.config.php"); require_once(VENDOR_PATH."Alipay/lib/alipay_submit.class.php"); //支付類型 $payment_type="1"; //必填,不能修改 //服務器異步通知頁面路徑 $notify_url=C("HOST")."index.php/Alipay/notifyOnAlipay"; //頁面跳轉同步通知頁面路徑 $return_url=C("HOST")."index.php/Pay/ok"; //賣家支付寶帳戶 $seller_email=$alipay_config['seller_email']; //必填 //商戶訂單號,從訂單對象中獲取 $out_trade_no=$order['OrderNum']; //商戶網站訂單系統中唯一訂單號,必填 //訂單名稱 $subject="物流服務"; //必填 //付款金額 #正常金額 $price=$order['Price']; #測試金額 #$price=0.1; //必填 $body=$subject; //商品展示地址 $show_url=C('HOST'); //構造要請求的參數數組,無需改動 $parameter=array( "service"=>"create_direct_pay_by_user", "partner"=>trim($alipay_config['partner']), "payment_type"=>$payment_type, "notify_url"=>$notify_url, "return_url"=>$return_url, "seller_email"=>$seller_email, "out_trade_no"=>$out_trade_no, "subject"=>$subject, "total_fee"=>$price, "body"=>$body, "show_url"=>$show_url, "_input_charset"=>trim(strtolower($alipay_config['input_charset'])) ); Log::write('支付寶訂單參數:'.var_export($parameter,true),Log::DEBUG); //建立請求 $alipaySubmit=newAlipaySubmit($alipay_config); $html_text=$alipaySubmit->buildRequestForm($parameter,"get","去支付"); echo$html_text; } 支付寶回調接口 <?php /** *支付寶回調接口 */ classAlipayActionextendsAction{ /** *支付寶異步通知 */ publicfunctionnotifyOnAlipay(){ Log::write("notify:".print_r($_REQUEST,true),Log::DEBUG); require_once(VENDOR_PATH."Alipay/alipay.config.php"); require_once(VENDOR_PATH."Alipay/lib/alipay_notify.class.php"); $orderLogDao=M('orderlog'); //計算得出通知驗證結果 $alipayNotify=newAlipayNotify($alipay_config); $verify_result=$alipayNotify->verifyNotify(); Log::write('verify_result:'.var_export($verify_result,true),Log::DEBUG); if($verify_result){//驗證成功 //商戶訂單號 $out_trade_no=$_POST['out_trade_no']; //支付寶交易號 $trade_no=$_POST['trade_no']; //根據訂單號獲取訂單 $DAO=M('order'); $order=$DAO->where("OrderNum='".$out_trade_no."'")->find(); //如果訂單不存在,設置為0 if(!isset($order)){ $orderId=0; } else{ $orderId=$order['id']; } //交易狀態 $trade_status=$_POST['trade_status']; $log="notifyfromAlipay,trade_status=".$trade_status."alipaysign=".$_POST['sign'].'price='.$_POST['total_fee']; $orderLog['o_id']=$orderId; if($_POST['trade_status']=='TRADE_FINISHED'||$_POST['trade_status']=='TRADE_SUCCESS'){ #修改訂單狀態 if((float)$order['Price']!=(float)$_POST['total_fee']){ $data['PaymentStatus']='2'; }else{ $data['PaymentStatus']='1'; } $DAO->where('id='.$orderId)->save($data); } $orderLog['pay_id']=$trade_no; $orderLog['pay_log']=$log; $orderLog['pay_type']='alipay'; $orderLog['pay_result']='success'; $orderLogDao->add($orderLog); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo"success";//返回成功標記給支付寶 } else{ //驗證不通過時,也記錄下來 $orderLog['pay_log']="notifyfromAlipay,但是驗證不通過,sign=".$_POST['sign']; $orderLog['o_id']=-1; $orderLog['pay_type']='alipay'; $orderLog['pay_result']='fail'; $orderLogDao->add($orderLog); //驗證失敗 echo"fail"; } } } ?> |
posted @ 2014-11-21 10:50 順其自然EVO 閱讀(521) | 評論 (0) | 編輯 收藏
posted @ 2014-11-21 10:43 順其自然EVO 閱讀(240) | 評論 (0) | 編輯 收藏
#import "MainViewController.h" //用延展隱藏我們的組件 @interface MainViewController () @property (nonatomic, strong) UIView *subView; @end //-------實現部分----------- @implementation MainViewController //主視圖加載后要做的事情 -(void)viewDidLoad { //實例化view并添加到mainView self.subView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 150)]; self.subView.backgroundColor = [UIColor brownColor]; [self.view addSubview:self.subView]; } @end |
posted @ 2014-11-21 09:38 順其自然EVO 閱讀(197) | 評論 (0) | 編輯 收藏
#import "MainViewController.h" //用延展隱藏我們的組件 @interface MainViewController () @property (nonatomic, strong) UIView *subView; @end //-------實現部分----------- @implementation MainViewController //主視圖加載后要做的事情 -(void)viewDidLoad { //實例化view并添加到mainView self.subView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 150)]; self.subView.backgroundColor = [UIColor brownColor]; [self.view addSubview:self.subView]; } @end |
posted @ 2014-11-21 09:38 順其自然EVO 閱讀(147) | 評論 (0) | 編輯 收藏
posted @ 2014-11-21 09:26 順其自然EVO 閱讀(636) | 評論 (0) | 編輯 收藏
public class BreaklFor { public static void main(String args[]){ OK: //設置一個標記 使用帶此標記的break語句跳出多重循環體 for(int i=1;i<100;i++){ //讓i循環99次 for(int j=1;j<=i;j++){ if(i==10){ break OK ; } System.out.print(i + "*" + j + "=" + i*j) ; System.out.print(" ") ; } System.out.println() ; } } } |
public class BreaklFor { public static void main(String args[]) { int array[][] = { { 5, 7, 6, 4, 9 }, { 1, 2, 8, 3, 2 } }; boolean flag = false; for (int i = 0; i < array.length && !flag; i++) { //當flag為true時跳出循環 for (int j = 0; j < array[i].length; j++) { if (array[i][j] == 8) { flag = true; break; } } } System.out.println(flag); } } |
posted @ 2014-11-21 09:25 順其自然EVO 閱讀(200) | 評論 (0) | 編輯 收藏
posted @ 2014-11-21 09:24 順其自然EVO 閱讀(229) | 評論 (0) | 編輯 收藏
posted @ 2014-11-21 09:24 順其自然EVO 閱讀(269) | 評論 (0) | 編輯 收藏
posted @ 2014-11-21 09:20 順其自然EVO 閱讀(176) | 評論 (0) | 編輯 收藏