123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
-
- namespace App\Http\Controllers\Api;
-
- use App\Common\Api;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
-
- use App\Models\Prizes;
- use App\Models\Lotterys;
- use App\Services\PrizeService;
-
- class PrizeController extends Controller
- {
- public function __construct()
- {
- //加载中间键
- $this->middleware('CheckLogin');
- $this->middleware('Logs');
- $this->middleware('CacheClear');
- }
-
- /**
- * 宝箱——添加/修改奖品
- */
- public function postPrize(Request $request){
- try {
- $params = $request->all();
-
- $keys = array('activity_id', 'corp_id', 'lottery_level', 'prize_name', 'prize_day_rule', 'prize_count', 'prize_weights', 'prize_image_url');
- foreach ($keys as $key) {
- if (!isset($params[$key])) {
- return Api::json(config('code.params_error'), trans('params.'.$key) . trans('msg.params_not_null'));
- }
- }
-
- $res = PrizeService::prizeDetail($params);
-
- return Api::json($res['code'], $res['msg'], $res['data']);
- }catch(\Exception $e) {
- return Api::serviceError($e);
- }
- }
-
- /**
- * 获取宝箱内的奖品列表
- * @param Request $request
- * @return string
- */
- public function getPrizeList(Request $request){
- try {
- $params = $request->all();
-
- $keys = array('activity_id', 'lottery_level', 'corp_id');
- foreach ($keys as $key) {
- if (empty($params[$key])) {
- return Api::json(config('code.params_error'), trans('params.'.$key) . trans('msg.params_not_null'));
- }
- }
-
- $res = PrizeService::getPrizeList($params['corp_id'], $params['activity_id'], $params['lottery_level']);
-
- return Api::json($res['code'], $res['msg'], $res['data']);
- }catch(\Exception $e) {
- return Api::serviceError($e);
- }
- }
-
- /**
- * 奖品删除
- * @param Request $request
- * @return string
- */
- public function postPrizeDelete(Request $request){
- try {
- $params = $request->all();
-
- $keys = array('activity_id', 'lottery_level', 'corp_id', 'prize_id');
- foreach ($keys as $key) {
- if (empty($params[$key])) {
- return Api::json(config('code.params_error'), trans('params.'.$key) . trans('msg.params_not_null'));
- }
- }
-
- $res = PrizeService::prizeDelete($params);
-
- return Api::json($res['code'], $res['msg'], $res['data']);
- }catch(\Exception $e) {
- return Api::serviceError($e);
- }
- }
- }
- ?>
|