laravel console handle 传参方法
<?php namespace App\Console\Commands; use Illuminate\Console\Command;
use App\Libs\wxpay\CLogFileHandler;
use App\Libs\wxpay\Log;
use App\Helpers\ReportHelper;
use App\Helpers\CommonHelper;
use App\Models\Ecg_customer;
use App\Models\Ecg_report;
use App\Models\Order;
use App\Models\Order_good;
use App\Models\Goods; 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';
} }
}
laravel console handle 传参方法的更多相关文章
- 学习chrome 插件 DHC ,http请求传参方法
DHC的简介 DHC是一款可以帮助用户使用chrome插件模拟HTTP客户端发送测试数据到服务器的谷歌浏览器插件,在chrome中安装了DHC插件以后,就可在服务器端代码初步完成的时候,使用DHC进行 ...
- jquery-uploadify传参方法
jquery-uploadify传参方法$(document).ready(function () { $("#uploadify").uploadify({ 'uploader' ...
- js方法之间的调用之——传参方法
在最近项目需求中发现,完成一些功能的时候总是要调很多结构类似的方法,写起来很繁琐,所以就想写一个“万能”方法,是的代码更简洁.即:把一个方法作为参数传给这个“万能”方法,让它去执行你给定的方法,就类似 ...
- 定时器setTimeout()的传参方法
更具体的代码:http://www.cnblogs.com/3body/p/5416830.html // 由于setTimeout()的延迟执行特性,所以在执行的函数中直接使用外部函数的变量是无法获 ...
- AngularJS中页面传参方法
1.基于ui-router的页面跳转传参 (1) 用ui-router定义路由,比如有两个页面,一个页面(producers.html)放置了多个producers,点击其中一个目标,页面跳转到对应的 ...
- TKinter当Label绑定bind事件时传参方法
记录下tkinter的 当在label绑定bind事件时,遇到需要传参时的解决方法(因为有event存在 所以不能直接传参) https://www.cnblogs.com/liyuanhong/ar ...
- 不用Ajax时的传参方法
不用Ajax时的怎么传参 创建一个form表单 function test(){ var params = { "参数名": "参数值" }; postExce ...
- unittest改写传参方法
Python主要讲究简洁简单使用,所以它不像junit一样支持参数化测试,需要改装一下也可以传参.直接上代码实例 import unittest class ParametrizedTestCase( ...
- tp5闭包子查询传参方法
在channel表中查询status,channel_id,channel_name,account_level这些字段,且这些字段的channel_id不在adv_id为$id的表adv_chann ...
随机推荐
- Java中ClassLoader浅析.
一.问题 请在Eclipse中新建如下类,并运行它: 1 package java.lang; 2 3 public class Long { 4 public static void main(St ...
- rsync详细解读
本文通过示例详细分析rsync算法原理和rsync的工作流程,是对rsync官方技术报告和官方推荐文章的解释.本文不会介绍如何使用rsync命令(见rsync基本用法),而是详细解释它如何实现高效的增 ...
- 你应该知道的16个linux命令
Linux常用命令很多比如cd.ls.pwd.du.df.tail.head.yum.mv.touch.mkdir.cp.tar等,根据工作内容不同,经常使用的命令也不同,比如运维人员使用tail.h ...
- BZOJ 3636 教义问答手册 (分治)
题意 一个整数数列,多次询问某段区间[li,ri][l_i,r_i][li,ri]内,选出若干个长度为LLL且不相交的连续段使选出来的数和最大. 分析 首先想朴素的区间DPDPDP 设f[i][j ...
- 004_软件安装之_Altium Designer
文件中有软件简单视频教程,安装有pdf教程 链接:https://pan.baidu.com/s/1ow-OHdsPuAyXCevjCVqEsg 提取码:l2rt 复制这段内容后打开百度网盘手机App ...
- Linq找不到行或行已更改
1.发生这种情况第一时间是确认了database明明存在这条数据 2.然后确认了Linq查找的条件中是否有连接条件使得连续更新中发生变化 3.最后发现原来是Linq使用的表实际中有个field由not ...
- HDU4254 A Famous Game
luogu嘟嘟嘟 这题刚开始特别容易理解错:直接枚举所有\(n + 1\)种情况,然后算哪一种情况合法,再统计答案. 上述思想的问题就在于我们从已知的结果出发,默认这种每一种情况中取出\(q\)个红球 ...
- 区间连续长度的线段树——洛谷P2894 [USACO08FEB]酒店Hotel
https://www.luogu.org/problem/P2894 #include<cstdio> #include<iostream> using namespace ...
- Web前端-JavaScript基础教程下
Web前端-JavaScript基础教程下 <script>有6个属性: async对外部脚本有效,可以用来异步操作,下载东西,不妨碍其他操作. charset为src属性指定字符集. d ...
- CentOS7 升级Python2.x到3.x
CentOS 7 中默认安装了 Python,版本比较低(2.7.5),为了使用新版 3.x,需要对旧版本进行升级.由于很多基本的命令.软件包都依赖旧版本,比如:yum.所以,在更新 Python 时 ...