<?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. django Error: HINT: Add or change a related_name argument to the definition for 'UserProfile.groups' or 'User.groups'.

    # 解决方案: 因自己重新封装user为UserProfile故在 settings中 添加自己的

  2. Accounts Merge

    Description Given a list accounts, each element accounts[i] is a list of strings, where the first el ...

  3. input 限制输入数字和小数

    //input 限制输入数字和小数 <input type="text" name="demo" value="" onkeyup=& ...

  4. Python爬虫:BeautifulSoup用法总结

    原文 BeautifulSoup是一个解析HTML或XML文件的第三方库.HTML或XML文件可以用DOM模型解释.一般包含三种节点: 元素节点 - 通常指HTML 或 XML的标签 文本节点 - 标 ...

  5. PHP 对参数签名

    对参数进行签名防止参数劫持 加入timestamp, 防止DOS攻击(但这次没有实现这个功能,后续再实现) interface BaseToken { /** * @param params arra ...

  6. 洛谷 P2615 神奇的幻方 题解

    每日一题系列day1 打卡 Analysis 水货模拟,不多说了 #include<iostream> #include<cstdio> #include<cstring ...

  7. spring boot 扫描 其他jar包里面的 mapper xml

    启动类配置扫描 goods.mapper为当前项目mapper路径 ,common.mpper为其他jar包. 1. 2.mybatis.mapper-locations=classpath*:map ...

  8. java继承内存分配

    java继承内存分配 继承的基本概念: * Java不支持多继承,也就是说子类至多只能有一个父类. * 子类继承了其父类中不是私有的成员变量和成员方法,作为自己的成员变量和方法. * 子类中定义的成员 ...

  9. ansible 交互提示、tags和block

    1.交互提示:使用关键字:vars_prompt 例:使用ansible的交互式功能创建用户和给定一个密码. --- - hosts: test50 remote_user: root vars_pr ...

  10. 怎么样使用vuex

    https://www.cnblogs.com/songrimin/p/7815850.html