Product.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\controller\plus\bargain;
  3. use app\api\controller\Controller;
  4. use app\api\model\settings\Setting as SettingModel;
  5. use app\common\service\product\BaseProductService;
  6. use app\api\model\plus\bargain\Active as ActiveModel;
  7. use app\api\model\plus\bargain\Product as ProductModel;
  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($bargain_activity_id)
  26. {
  27. $detail = ActiveModel::detailWithTrans($bargain_activity_id);
  28. $detail['start_time'] =strtotime($detail['start_time']);
  29. $detail['end_time'] =strtotime($detail['end_time']);
  30. $list = (new ProductModel())->getActivityList($bargain_activity_id);
  31. return $this->renderSuccess('', compact('detail','list'));
  32. }
  33. /**
  34. * 砍价商品详情
  35. */
  36. public function detail($bargain_product_id, $url = '')
  37. {
  38. $model = new ProductModel();
  39. //详情
  40. $detail = $model->getBargainDetail($bargain_product_id);
  41. //活动
  42. $active = ActiveModel::detailWithTrans($detail['bargain_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. $setting = SettingModel::getBargain();
  49. // 微信公众号分享参数
  50. $share = $this->getShareParams($url, $detail['product']['product_name'], $detail['product']['product_name'], '/pages/plus/assemble/detail/detail', $detail['product']['image'][0]['file_path']);
  51. return $this->renderSuccess('', compact('detail', 'active', 'specData', 'setting', 'share'));
  52. }
  53. }