123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * Created by PhpStorm.
- * User: 15051
- * Date: 2018/11/22
- * Time: 10:33
- */
- namespace App\Services;
-
- use App\Models\LotteryBoxs;
- use App\Models\Prizes;
-
- class DdService{
- public function __construct()
- {
- }
-
- /**
- *
- * @param $activity_id
- * @param $corp_id
- * @return mixed
- */
- public static function ExampleActBox($activity_id, $corp_id){
- $boxs = [1,2,3,4];
- $querys = [];
- foreach($boxs as $k=>$v){
- $query = [];
- $queryPrize = [];
- $query['open_mode'] = 'km';
- $query['activity_id'] = $queryPrize['activity_id'] = $activity_id;
- $query['corp_id'] = $queryPrize['corp_id'] = $corp_id;
- $query['lottery_level'] = $queryPrize['lottery_level'] = $v;
- $query['create_time'] = $query['update_time'] = $queryPrize['update_time'] = $queryPrize['create_time'] = time();
- switch($v){
- case 1:
- $query['open_rule'] = 100;
- $query['status'] = 1;
- $query['lottery_name'] = '铜宝箱';
- $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_one.png';
-
- //示例铜宝箱奖品
- $queryPrize['prize_name'] = '铜质奖章';
- $queryPrize['prize_day_rule'] = 10;
- $queryPrize['prize_count'] = 10;
- $queryPrize['prize_weights'] = 1000;
- $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/b4b94f2a3a2c6b6b32cf8a8e6a3178f9c6b036e5.png';
-
- //参数组装
- $querys[] = $query;
- $queryPrizes[] = $queryPrize;
- break;
- case 2:
- $query['open_rule'] = 200;
- $query['status'] = 1;
- $query['lottery_name'] = '银宝箱';
- $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_two.png';
-
- //示例银宝箱奖品
- $queryPrize['prize_name'] = '银质奖章';
- $queryPrize['prize_day_rule'] = 20;
- $queryPrize['prize_count'] = 20;
- $queryPrize['prize_weights'] = 800;
- $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/b0bb22a2d9f68fd484154e867fc7ac50eb7b0c49.png';
-
- //参数组装
- $querys[] = $query;
- $queryPrizes[] = $queryPrize;
- break;
- case 3:
- $query['open_rule'] = 500;
- $query['status'] = 1;
- $query['lottery_name'] = '金宝箱';
- $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_three.png';
-
- //示例金宝箱奖品
- $queryPrize['prize_name'] = '金质奖章';
- $queryPrize['prize_day_rule'] = 30;
- $queryPrize['prize_count'] = 30;
- $queryPrize['prize_weights'] = 500;
- $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/85be5acc8c0dcab4d572a78d7281674ff316e86a.png';
-
- //参数组装
- $querys[] = $query;
- $queryPrizes[] = $queryPrize;
- break;
- case 4:
- $query['lottery_level'] = 4;
- $query['open_rule'] = 0;
- $query['status'] = 0;
- $query['lottery_name'] = '幸运宝箱';
- $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_four.png';
-
- //参数组装(幸运宝箱无示例奖品)
- $querys[] = $query;
- break;
- }
- }
- $res = LotteryBoxs::insert($querys);
- $res_prize = Prizes::insert($queryPrizes);
- if($res && $res_prize){
- return true;
- } else {
- return false;
- }
- }
- }
|