DdService.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 15051
  5. * Date: 2018/11/22
  6. * Time: 10:33
  7. */
  8. namespace App\Services;
  9. use App\Models\LotteryBoxs;
  10. use App\Models\Prizes;
  11. class DdService{
  12. public function __construct()
  13. {
  14. }
  15. /**
  16. *
  17. * @param $activity_id
  18. * @param $corp_id
  19. * @return mixed
  20. */
  21. public static function ExampleActBox($activity_id, $corp_id){
  22. $boxs = [1,2,3,4];
  23. $querys = [];
  24. foreach($boxs as $k=>$v){
  25. $query = [];
  26. $queryPrize = [];
  27. $query['open_mode'] = 'km';
  28. $query['activity_id'] = $queryPrize['activity_id'] = $activity_id;
  29. $query['corp_id'] = $queryPrize['corp_id'] = $corp_id;
  30. $query['lottery_level'] = $queryPrize['lottery_level'] = $v;
  31. $query['create_time'] = $query['update_time'] = $queryPrize['update_time'] = $queryPrize['create_time'] = time();
  32. switch($v){
  33. case 1:
  34. $query['open_rule'] = 100;
  35. $query['status'] = 1;
  36. $query['lottery_name'] = '铜宝箱';
  37. $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_one.png';
  38. //示例铜宝箱奖品
  39. $queryPrize['prize_name'] = '铜质奖章';
  40. $queryPrize['prize_day_rule'] = 10;
  41. $queryPrize['prize_count'] = 10;
  42. $queryPrize['prize_weights'] = 1000;
  43. $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/b4b94f2a3a2c6b6b32cf8a8e6a3178f9c6b036e5.png';
  44. //参数组装
  45. $querys[] = $query;
  46. $queryPrizes[] = $queryPrize;
  47. break;
  48. case 2:
  49. $query['open_rule'] = 200;
  50. $query['status'] = 1;
  51. $query['lottery_name'] = '银宝箱';
  52. $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_two.png';
  53. //示例银宝箱奖品
  54. $queryPrize['prize_name'] = '银质奖章';
  55. $queryPrize['prize_day_rule'] = 20;
  56. $queryPrize['prize_count'] = 20;
  57. $queryPrize['prize_weights'] = 800;
  58. $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/b0bb22a2d9f68fd484154e867fc7ac50eb7b0c49.png';
  59. //参数组装
  60. $querys[] = $query;
  61. $queryPrizes[] = $queryPrize;
  62. break;
  63. case 3:
  64. $query['open_rule'] = 500;
  65. $query['status'] = 1;
  66. $query['lottery_name'] = '金宝箱';
  67. $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_three.png';
  68. //示例金宝箱奖品
  69. $queryPrize['prize_name'] = '金质奖章';
  70. $queryPrize['prize_day_rule'] = 30;
  71. $queryPrize['prize_count'] = 30;
  72. $queryPrize['prize_weights'] = 500;
  73. $queryPrize['prize_image_url'] = '//s1-hn.aghcdn.com/management/20181025/85be5acc8c0dcab4d572a78d7281674ff316e86a.png';
  74. //参数组装
  75. $querys[] = $query;
  76. $queryPrizes[] = $queryPrize;
  77. break;
  78. case 4:
  79. $query['lottery_level'] = 4;
  80. $query['open_rule'] = 0;
  81. $query['status'] = 0;
  82. $query['lottery_name'] = '幸运宝箱';
  83. $query['lottery_icon'] = '//s1-hn.aghcdn.com/brainstorming/prize/prize_four.png';
  84. //参数组装(幸运宝箱无示例奖品)
  85. $querys[] = $query;
  86. break;
  87. }
  88. }
  89. $res = LotteryBoxs::insert($querys);
  90. $res_prize = Prizes::insert($queryPrizes);
  91. if($res && $res_prize){
  92. return true;
  93. } else {
  94. return false;
  95. }
  96. }
  97. }