<?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 传参方法的更多相关文章

  1. 学习chrome 插件 DHC ,http请求传参方法

    DHC的简介 DHC是一款可以帮助用户使用chrome插件模拟HTTP客户端发送测试数据到服务器的谷歌浏览器插件,在chrome中安装了DHC插件以后,就可在服务器端代码初步完成的时候,使用DHC进行 ...

  2. jquery-uploadify传参方法

    jquery-uploadify传参方法$(document).ready(function () { $("#uploadify").uploadify({ 'uploader' ...

  3. js方法之间的调用之——传参方法

    在最近项目需求中发现,完成一些功能的时候总是要调很多结构类似的方法,写起来很繁琐,所以就想写一个“万能”方法,是的代码更简洁.即:把一个方法作为参数传给这个“万能”方法,让它去执行你给定的方法,就类似 ...

  4. 定时器setTimeout()的传参方法

    更具体的代码:http://www.cnblogs.com/3body/p/5416830.html // 由于setTimeout()的延迟执行特性,所以在执行的函数中直接使用外部函数的变量是无法获 ...

  5. AngularJS中页面传参方法

    1.基于ui-router的页面跳转传参 (1) 用ui-router定义路由,比如有两个页面,一个页面(producers.html)放置了多个producers,点击其中一个目标,页面跳转到对应的 ...

  6. TKinter当Label绑定bind事件时传参方法

    记录下tkinter的 当在label绑定bind事件时,遇到需要传参时的解决方法(因为有event存在 所以不能直接传参) https://www.cnblogs.com/liyuanhong/ar ...

  7. 不用Ajax时的传参方法

    不用Ajax时的怎么传参 创建一个form表单 function test(){ var params = { "参数名": "参数值" }; postExce ...

  8. unittest改写传参方法

    Python主要讲究简洁简单使用,所以它不像junit一样支持参数化测试,需要改装一下也可以传参.直接上代码实例 import unittest class ParametrizedTestCase( ...

  9. tp5闭包子查询传参方法

    在channel表中查询status,channel_id,channel_name,account_level这些字段,且这些字段的channel_id不在adv_id为$id的表adv_chann ...

随机推荐

  1. SQL SERVER 语句转换格式函数Cast、Convert

    CAST.CONVERT都可以执行数据类型转换.在大部分情况下,两者执行同样的功能,不同的是CONVERT还提供一些特别的日期格式转换,而CAST没有这个功能. CAST是ANSI兼容的,推荐使用CO ...

  2. shell 学习笔记 LinuxShell脚本攻略(第2版)

    注释用#号:多条命令通过分号或回车来分隔 echo会自动换行,若不想换行,则加上-n参数,如 echo -n "nice to meet you" echo后面的内容可以不带引号, ...

  3. redis 发展史 应用场景

    引言 在Web应用发展的初期,那时关系型数据库受到了较为广泛的关注和应用, 原因是因为那时候Web站点基本上访问和并发不高.交互也较少. 而在后来,随着访问量的提升,使用关系型数据库的Web站点多多少 ...

  4. jquery限定文字超出用省略号

    都知道用css3可以做到一行超出显示省略号,但多行的用css3很麻烦还要考虑兼容,今天用jquery判断字数来限制出现省略号 $(".ftlt_lt_wzne").each(fun ...

  5. HTML 007 链接

    HTML 链接 HTML 使用超级链接与网络上的另一个文档相连.几乎可以在所有的网页中找到链接.点击链接可以从一张页面跳转到另一张页面. 尝试一下 - 实例 HTML 链接如何在HTML文档中创建链接 ...

  6. Time 时间格式处理方法

    一般时间调用都会精确到年   月  日    时  分 秒 怎么调用时去掉时  分 秒呢 用以下格式来处理 //时间格式处理 var time = new Date(data.FTime); var ...

  7. 万年历SQL Server中实现

    参照C#版万年历实现而做 http://www.cnblogs.com/txw1958/archive/2013/01/27/csharp-calendar.html 在sql server中实现公历 ...

  8. Oracle的dual是什么东西啊??(答:伪表)

    1. dual 确实是一张表.是一张只有一个字段,一行记录的表.2.习惯上,我们称之为'伪表'.因为他不存储主题数据.3. 他的存在,是为了操作上的方便.因为select 都是要有特定对象的.如:se ...

  9. python3 中的bytes类型

  10. Spring - 环境安装

    安装IDEA的非Community版本和Java的包之后就可以用Java来HelloWorld了. 然后去这个链接:https://github.com/spring-guides/gs-rest-s ...