Bonus.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 红包控制器
  15. */
  16. class Bonus extends MobileMall {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path().'home/lang/'.config('lang.default_lang').'/bonus.lang.php');
  20. }
  21. /**
  22. * @api {POST} api/Bonus/detail 活动红包详情
  23. * @apiVersion 1.0.0
  24. * @apiGroup Memberbonus
  25. *
  26. * @apiHeader {String} X-DS-KEY 用户授权token
  27. *
  28. * @apiParam {Int} bonus_id 活动ID
  29. *
  30. * @apiSuccess {String} code 返回码,10000为成功
  31. * @apiSuccess {String} message 返回消息
  32. * @apiSuccess {Object} result 返回数据
  33. */
  34. public function detail() {
  35. $bonus_id = intval(input('param.bonus_id'));
  36. if ($bonus_id <= 0) {
  37. ds_json_encode(10001, lang('param_error'));
  38. }
  39. $bonus_model = model('bonus');
  40. $condition=array();
  41. $condition[] = array('bonus_id','=',$bonus_id);
  42. $condition[] = array('bonus_type','=',1);
  43. $condition[] = array('bonus_state','=',1);
  44. $condition[] = array('bonus_begintime','<',TIMESTAMP);
  45. $condition[] = array('bonus_endtime','>',TIMESTAMP);
  46. $bonus = $bonus_model->getOneBonus($condition);
  47. if(!$bonus){
  48. ds_json_encode(10001, lang('bonus_not_exist'));
  49. }
  50. $bonus['bonus_begintime_text'] = date('Y-m-d H:i:s',$bonus['bonus_begintime']);
  51. $bonus['bonus_endtime_text'] = date('Y-m-d H:i:s',$bonus['bonus_endtime']);
  52. $result['bonus'] = $bonus;
  53. //获取最近10条领取记录
  54. $condition=array();
  55. $condition[] = array('bonus_id','=',$bonus_id);
  56. $condition[] = array('member_id','>',0);
  57. $result['bonusreceive_list'] = $bonus_model->getBonusreceiveList($condition, '', 10);
  58. ds_json_encode(10000, '', $result);
  59. }
  60. }