Pintuan.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\api\controller;
  3. /**
  4. *
  5. *
  6. * ----------------------------------------------------------------------------
  7. *
  8. * 拼团控制器
  9. */
  10. class Pintuan extends MobileMall
  11. {
  12. public function initialize()
  13. {
  14. parent::initialize();
  15. }
  16. /**
  17. * @api {POST} api/Pintuan/index 获取拼团列表
  18. * @apiVersion 1.0.0
  19. * @apiGroup Pintuan
  20. *
  21. * @apiHeader {String} X-DS-KEY 用户授权token
  22. *
  23. * @apiParam {Int} page 页码
  24. * @apiParam {Int} per_page 每页数量
  25. *
  26. * @apiSuccess {String} code 返回码,10000为成功
  27. * @apiSuccess {String} message 返回消息
  28. * @apiSuccess {Object} result 返回数据
  29. * @apiSuccess {Object[]} result.pintuan_list 拼团列表 (返回字段参考ppintuan表)
  30. * @apiSuccess {Int} result.page_total 总页数
  31. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  32. */
  33. public function index()
  34. {
  35. $ppintuan_model = model('ppintuan');
  36. $goods_model = model('goods');
  37. $condition = array(
  38. array('pintuan_state', '=', 1),
  39. array('pintuan_starttime', '<', TIMESTAMP),
  40. array('pintuan_end_time', '>', TIMESTAMP),
  41. );
  42. $pintuan_list = $ppintuan_model->getPintuanList($condition, 10, 'pintuan_state desc, pintuan_end_time desc');
  43. foreach ($pintuan_list as $key => $pintuan) {
  44. $goods_info = $goods_model->getGoodsInfoByID($pintuan['pintuan_goods_id']);
  45. if (!$goods_info || $goods_info['goods_state'] != 1 || $goods_info['goods_verify'] != 1) {
  46. unset($pintuan_list[$key]);
  47. continue;
  48. }
  49. $pintuan_list[$key]['pintuan_image'] = goods_cthumb($pintuan['pintuan_image'], 240);
  50. $pintuan_list[$key]['pintuan_zhe_price'] = round($pintuan['pintuan_goods_price'] * $pintuan['pintuan_zhe'] / 10, 2);
  51. }
  52. $page_count = $ppintuan_model->page_info;
  53. $result = array_merge(array('pintuan_list' => $pintuan_list,), mobile_page($page_count));
  54. ds_json_encode(10000, '', $result);
  55. }
  56. }