setName('FlwOpen')->setDescription('福利屋开奖'); } protected function execute(Input $input, Output $output) { //php /www/wwwroot/xinglanmh.shequtuangou.vip think FlwOpen $time = date('Y-m-d H:i:s', time()); Log::info('福利屋开奖' . $time); Log::info('福利屋开奖' . $time); Log::info('福利屋开奖' . $time); print('福利屋开奖' . $time); print('福利屋开奖' . $time); print_r(time()); // $notify=new Notify(); //cd /www/wwwroot/xinglanmh.shequtuangou.vip && php think FlwOpen $goodslist = Goods::where('status', 1)->where('is_flw', 1)->where('is_open', 0)->select()->toArray(); foreach ($goodslist as $k => $v) { Log::info('福利屋开奖$goods_id' . $v['id']); Log::info('福利屋开奖open_time' . date('Y-m-d H:i:s', $v['open_time'])); print_r('福利屋开奖open_time' . date('Y-m-d H:i:s', $v['open_time'])); if($v['open_time']special_prize_notice_time($v['id']); } } $time = date('Y-m-d H:i:s', time()); $output->writeln('success' . $time); } /** * 特殊奖品开奖 LAST 最终赏 全局赏 到时间开奖修改此处 * @param $order 订单信息 * @param $first_count */ protected function special_prize_notice_time($goods_id) { $res = []; // $goods_id = $order['goods_id']; // $num = $order['num']; // $order_type = $order['order_type']; // $goods_id=request()->param('goods_id/d', 0); // $num = request()->param('goods_num/d', 0); #第几箱 $num = 1; #第几箱 $order_type =6; print_r('$goods_id'.$goods_id); #特殊奖品存在 $special_prize = GoodsList::where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('surplus_stock', '>', 0) ->where('shang_id', 'in', self::$shang_give_arr) ->select()->toArray(); $surplus_give_stock = $special_prize ? array_sum(array_column($special_prize, 'surplus_stock')) : 0; if ($special_prize && $surplus_give_stock > 0) { #所有奖品信息 $all_order_list = OrderList::field('id,user_id') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('order_type', '=', $order_type) ->where('shang_id', 'between', self::$shang_prize_id) ->order('id asc') ->select()->toArray(); $order_goods = []; foreach ($special_prize as $k => $v) { if ($v['shang_id'] == 4) {#全局赏 for ($surplus_stock_i = 0; $surplus_stock_i < $v['surplus_stock']; $surplus_stock_i++) { $overall_order_list = $all_order_list; shuffle($overall_order_list); shuffle($overall_order_list); $prize_info = $overall_order_list[0]; $user_id = $prize_info['user_id']; #特殊赏中奖订单id $order_list_id = $prize_info['id']; #中奖奖项 $ordinary_prize_info = $v; $order_goods[] = [ 'order_id' => 0, 'user_id' => $user_id, 'status' => 0,#0未操作 1选择兑换 2选择发货 'goods_id' => $goods_id, 'num' => $num, 'shang_id' => $ordinary_prize_info['shang_id'], 'goodslist_id' => $ordinary_prize_info['id'], 'goodslist_title' => $ordinary_prize_info['title'], 'goodslist_imgurl' => $ordinary_prize_info['imgurl'], 'goodslist_price' => $ordinary_prize_info['price'], 'goodslist_money' => $ordinary_prize_info['money'], 'goodslist_type' => $ordinary_prize_info['goods_type'], 'goodslist_sale_time' => $ordinary_prize_info['sale_time'], 'addtime' => time(), 'prize_code' => $ordinary_prize_info['prize_code'], 'order_type' => $order_type, 'order_list_id' => $order_list_id, ]; print_r($user_id.'中奖'.$goods_id.'商品'.$v['title']); #减少库存 $res[] = GoodsList::field('surplus_stock') ->where(['id' => $ordinary_prize_info['id']]) ->dec('surplus_stock') ->update(); } } } #新增奖品列表 $res[] = OrderList::insertAll($order_goods); Goods::where(['id' => $goods_id])->update([ 'is_open' => 1 ]); Log::info('福利屋开奖$goods_idupdate_is_open' . $goods_id); } else { $res[] = 1; } return $res; } }