• laravel console handle 传参方法


    <?php
    
    namespace AppConsoleCommands;
    
    use IlluminateConsoleCommand;
    use AppLibswxpayCLogFileHandler;
    use AppLibswxpayLog;
    use AppHelpersReportHelper;
    use AppHelpersCommonHelper;
    use AppModelsEcg_customer;
    use AppModelsEcg_report;
    use AppModelsOrder;
    use AppModelsOrder_good;
    use AppModelsGoods;
    
    class AddUserCombo extends Command
    {
        
        /**
         * The name and signature of the console command.
         *
         * @var string
         */
         
        protected $signature = 'add_user_combo:run {--uid=} {--spe_goo_id=}'; //传参
    
        /**
         * The console command description.
         *
         * @var string
         */
        protected $description = 'Command description';
    
        /**
         * Create a new command instance.
         *
         * @return void
         */
        public function __construct()
        {
            parent::__construct();
        }
    
        /**
         * php artisan add_user_combo:run --uid=88 --spe_goo_id=9
         *
         * Execute the console command.
         *
         * @return mixed
         */
        public function handle()
        {
            
            //$uid = 219;
            $ord_typ_id = 1;
            //$spe_goo_id = 8;
            
            $uid = $this->option('uid');
            $spe_goo_id = $this->option('spe_goo_id');
            
            $info = array(
                'ord_typ_id'=>$ord_typ_id,
                'out_trade_no'=>CommonHelper::get_order_sn(),
                'use_id'=>$uid, 
                'ord_sta_id'=>1, 
                'ord_display'=>0, 
                'ord_pay_sta_id'=>1, 
                'ord_pay_typ_id'=>1, 
                'ord_cre_date'=>date('Y-m-d H:i:s', time()) 
            );
            $obj = Order::create($info);
            
            $ord_id = $obj->id;
            $info = array(
                'ord_id'=>$ord_id,
                'goo_id'=>$spe_goo_id,
                'goo_quantity'=>1
                
            );
            $obj_order_good = Order_good::create($info);
            
            
            $add_quantity = 0;
            $list = Goods::where(['goo_id'=>$spe_goo_id])->get()->toArray();
            foreach($list as $v) {
                $add_quantity = $v['goo_quantity'];
            }
    
            var_dump('Order insert id:'.$obj->id);
            var_dump('Order_good insert id:'.$obj_order_good->id);
            
            if($add_quantity) {
                $ret = Ecg_customer::where(['ecg_cus_id'=>$uid])->increment('ecg_cus_ava_times', $add_quantity);
                if($ret) {
                    echo 'increment add_quantity '.$add_quantity.' success!';
                } else {
                    echo 'increment add_quantity '.$add_quantity.' fail!';
                }
            } else {
                echo 'the goo_id :'.$spe_goo_id.' of quantity is 0';
            }
            
        }
    }
  • 相关阅读:
    SourceForge上发布dedup util 收藏
    IBM快速整合Diligent 触动了谁的神经?
    Data Domain揭开其神秘面纱 加速中国业务发展
    Java NIO原理和使用
    用PDB库调试Python程序
    windows下配置eclipse + Python + PyDev + tornado,并使用pylint进行静态检测
    函数fork与vfork的区别与联系详解
    关于C++中友元类和友元函数的示例讲解
    const成员函数
    pthread_cond_wait()深入解析
  • 原文地址:https://www.cnblogs.com/dongruiha/p/6322658.html
Copyright © 2020-2023  润新知