123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- /**
- * 红包控制器
- */
- class Bonus extends MobileMall
- {
- public function initialize()
- {
- parent::initialize();
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/bonus.lang.php');
- }
- /**
- * @api {POST} api/Bonus/detail 活动红包详情
- * @apiVersion 1.0.0
- * @apiGroup Memberbonus
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} bonus_id 活动ID
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- */
- public function detail()
- {
- $bonus_id = intval(input('param.bonus_id'));
- if ($bonus_id <= 0) {
- ds_json_encode(10001, lang('param_error'));
- }
- $bonus_model = model('bonus');
- $condition = array();
- $condition[] = array('bonus_id', '=', $bonus_id);
- $condition[] = array('bonus_type', '=', 1);
- $condition[] = array('bonus_state', '=', 1);
- $condition[] = array('bonus_begintime', '<', TIMESTAMP);
- $condition[] = array('bonus_endtime', '>', TIMESTAMP);
- $bonus = $bonus_model->getOneBonus($condition);
- if (!$bonus) {
- ds_json_encode(10001, lang('bonus_not_exist'));
- }
- $bonus['bonus_begintime_text'] = date('Y-m-d H:i:s', $bonus['bonus_begintime']);
- $bonus['bonus_endtime_text'] = date('Y-m-d H:i:s', $bonus['bonus_endtime']);
- $result['bonus'] = $bonus;
- //获取最近10条领取记录
- $condition = array();
- $condition[] = array('bonus_id', '=', $bonus_id);
- $condition[] = array('member_id', '>', 0);
- $result['bonusreceive_list'] = $bonus_model->getBonusreceiveList($condition, '', 10);
- ds_json_encode(10000, '', $result);
- }
- }
|