Bonus.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 红包控制器
  14. */
  15. class Bonus extends MobileMall {
  16. public function initialize() {
  17. parent::initialize();
  18. Lang::load(base_path().'home/lang/'.config('lang.default_lang').'/bonus.lang.php');
  19. }
  20. /**
  21. * @api {POST} api/Bonus/detail 活动红包详情
  22. * @apiVersion 1.0.0
  23. * @apiGroup Memberbonus
  24. *
  25. * @apiHeader {String} X-DS-KEY 用户授权token
  26. *
  27. * @apiParam {Int} bonus_id 活动ID
  28. *
  29. * @apiSuccess {String} code 返回码,10000为成功
  30. * @apiSuccess {String} message 返回消息
  31. * @apiSuccess {Object} result 返回数据
  32. */
  33. public function detail() {
  34. $bonus_id = intval(input('param.bonus_id'));
  35. if ($bonus_id <= 0) {
  36. ds_json_encode(10001, lang('param_error'));
  37. }
  38. $bonus_model = model('bonus');
  39. $condition=array();
  40. $condition[] = array('bonus_id','=',$bonus_id);
  41. $condition[] = array('bonus_type','=',1);
  42. $condition[] = array('bonus_state','=',1);
  43. $condition[] = array('bonus_begintime','<',TIMESTAMP);
  44. $condition[] = array('bonus_endtime','>',TIMESTAMP);
  45. $bonus = $bonus_model->getOneBonus($condition);
  46. if(!$bonus){
  47. ds_json_encode(10001, lang('bonus_not_exist'));
  48. }
  49. $bonus['bonus_begintime_text'] = date('Y-m-d H:i:s',$bonus['bonus_begintime']);
  50. $bonus['bonus_endtime_text'] = date('Y-m-d H:i:s',$bonus['bonus_endtime']);
  51. $result['bonus'] = $bonus;
  52. //获取最近10条领取记录
  53. $condition=array();
  54. $condition[] = array('bonus_id','=',$bonus_id);
  55. $condition[] = array('member_id','>',0);
  56. $result['bonusreceive_list'] = $bonus_model->getBonusreceiveList($condition, '', 10);
  57. ds_json_encode(10000, '', $result);
  58. }
  59. }