Product.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\api\controller\plus\assemble;
  3. use app\api\controller\Controller;
  4. use app\api\model\plus\assemble\Product as ProductModel;
  5. use app\api\model\plus\assemble\Active as ActiveModel;
  6. use app\common\service\product\BaseProductService;
  7. use app\api\model\plus\assemble\Bill as BillModel;
  8. /**
  9. * 拼团控制器
  10. */
  11. class Product extends Controller
  12. {
  13. /**
  14. * 拼团活动
  15. */
  16. public function active()
  17. {
  18. $model = new ActiveModel();
  19. $list = $model->activityList();
  20. return $this->renderSuccess('', compact('list'));
  21. }
  22. /**
  23. * 拼团商品
  24. */
  25. public function product($assemble_activity_id)
  26. {
  27. $detail = ActiveModel::detailWithTrans($assemble_activity_id);
  28. $detail['start_time'] =strtotime($detail['start_time']);
  29. $detail['end_time'] =strtotime($detail['end_time']);
  30. $list = (new ProductModel())->getActivityList($assemble_activity_id);
  31. return $this->renderSuccess('', compact('detail','list'));
  32. }
  33. /**
  34. * 拼团商品详情
  35. */
  36. public function detail($assemble_product_id, $url = '')
  37. {
  38. $model = new ProductModel();
  39. //详情
  40. $detail = $model->getAssembleDetail($assemble_product_id);
  41. //活动
  42. $active = ActiveModel::detailWithTrans($detail['assemble_activity_id']);
  43. $active['start_time'] =strtotime($active['start_time']);
  44. $active['end_time'] =strtotime($active['end_time']);
  45. //规格
  46. $specData = BaseProductService::getSpecData($detail['product']);
  47. //拼团订单
  48. $model = new BillModel();
  49. $bill = $model->getBill($detail['assemble_product_id'], $detail['assemble_activity_id'], $detail['assemble_num']);
  50. // 微信公众号分享参数
  51. $share = $this->getShareParams($url, $detail['product']['product_name'], $detail['product']['product_name'], '/pages/plus/assemble/detail/detail', $detail['product']['image'][0]['file_path']);
  52. return $this->renderSuccess('', compact('detail', 'active', 'specData', 'bill', 'share'));
  53. }
  54. }