where('is_complete_set', 1)->pluck('activity_id')->toArray(); $prizeOpenIds = Configs::where('is_open_prize', 1)->whereIn('activity_id', $actIds)->pluck('activity_id'); $i = 0; foreach($prizeOpenIds as $k=>$v){ $actConfig = Configs::where('activity_id', $v)->first()->toArray(); $levels = [1,2,3,4]; $querys = []; foreach($levels as $key=>$val){ $query['activity_id'] = $actConfig['activity_id']; $query['corp_id'] = $actConfig['corp_id']; switch($val){ case 1: $query['lottery_level'] = 1; $query['lottery_name'] = '铜宝箱'; $query['status'] = 1; $query['open_rule'] = $actConfig['copper_box_km']; $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_one.png'; break; case 2: $query['lottery_level'] = 2; $query['lottery_name'] = '银宝箱'; $query['status'] = 1; $query['open_rule'] = $actConfig['silver_box_km']; $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_two.png'; break; case 3: $query['lottery_level'] = 3; $query['lottery_name'] = '金宝箱'; $query['status'] = 1; $query['open_rule'] = $actConfig['gold_box_km']; $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_three.png'; break; case 4: $query['lottery_level'] = 4; $query['lottery_name'] = '幸运宝箱'; $query['status'] = 0; $query['open_rule'] = 0; $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_four.png'; break; } $query['open_mode'] = 'km'; $query['create_time'] = time(); $query['update_time'] = time(); $box = LotteryBoxs::where('activity_id', $actConfig['activity_id']) ->where('corp_id', $actConfig['corp_id']) ->where('lottery_level', $query['lottery_level']) ->first(); if(!$box){ $querys[] = $query; } } $res = LotteryBoxs::insert($querys); if($res){ echo $v.'=======成功'.PHP_EOL; } else { echo $v.'=======失败'.PHP_EOL; } $i++; } echo $i.'个活动同步成功'; } }