zoukankan      html  css  js  c++  java
  • do { xxx }while(false); 是什么操作

    这个主要用于有逻辑判断的代码。
    比如 里面要处理一些内容,但是又要控制一些输出或者什么逻辑的。
    XXX 代码又是一个整体,里面可以直接break等处理的时候,就很有用

    <?php
    do{
        if(is_fail($balance_result)){
            $response = $balance_result;
            break;
        }
        $balance = $balance_result["data"]["balance"];
        if($balance < $order["diamond_num"]){
            if(! $is_retry){
                Model_Failorder::instance()->insert(array(
                    'order_id' => $order['order_id'],
                ), true);
            }
            $money_as_str = Common_Money::format_money(self::balance2money($balance));
            $response = fail(__(sprintf("余额不足(余额只有%s元)", $money_as_str)));
            break;
        }
        $consume_result = $this->consume($user, $yyb_user, $order);
        if(is_fail($consume_result)){
            $response = $consume_result;
            if($response['data']['yyb_code'] == Common_Yyb::YYB_CODE_AUTH_FAIL){
                Model_Loginretryorder::instance()-> ins_by_ignore(array(
                    'order_id' => $order['order_id'],
                    'user_id' => $order['user_id'],
                ));
            }
            break;
        }
        $channel_status = Common_Pay::CS_SUCCESS;
        Model_Order::instance()->update_by_order_num($order_num, array(
            'channel_status' => $channel_status,
        ));
        $response = Common_Pay::complete_order_by_order_num($order_num, $is_inject);
        Common_Yyb::on_gdt_complete_order($order);
        $response['data']['consume_success'] = true;
    }while(false);
    
    if(is_fail($response)){
        //记录订单失败原因
        Model_Order::instance()->update_by_order_num($order_num, array(
            'channel_status' => $channel_status,
            'fail_reason' => $response['msg'],
        ));
    }
    return $response;
  • 相关阅读:
    HDU 5363 Key Set(快速幂取模)
    HDU 5339 Untitled(暴搜)
    POJ 2406 Power Strings
    Dedecms备份还原网站有效方法
    DEDECMS文章列表每隔8行文章添加分隔虚线
    DEDECMS突破TAG和关键字长度的限制
    为织梦dedecms制作全文RSS订阅源
    DedeCms中Channel用typeid无效
    织梦CMS/Dedecms添加自定义函数
    sql批量换dedecms文章来源和作者
  • 原文地址:https://www.cnblogs.com/batsing/p/11595947.html
Copyright © 2011-2022 走看看