Pintuan.php 2.5 KB

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