PromotionMonitor.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 推广监控模型
  5. * @package app\common\model
  6. */
  7. class PromotionMonitor extends BaseModel
  8. {
  9. //首页:pages/tabBar/index/index
  10. //商品列表页:pages/tabBar/allGoods/allGoods
  11. //商品详情页、N件X折活动、满件送活动、满就送活动:pages/cart/pages/goodsDetail/goodsDetail
  12. //拼团活动:pages/activity/pages/groupShopping/groupGoodsDetail/groupGoodsDetail
  13. //砍价活动:pages/activity/pages/bargain/bargainDetail/bargainDetail
  14. //页面参数:sourceId(渠道来源id)
  15. // 页面类型
  16. const PAGE_TYPE_OPTIONS = [
  17. 1 => '首页',
  18. 2 => '商品列表页',
  19. 3 => '商品详情页',
  20. 4 => '拼团活动',
  21. 5 => '砍价活动',
  22. 6 => 'N件X折活动',
  23. 7 => '满件送活动',
  24. 8 => '满就送活动',
  25. 9 => '秒杀活动'
  26. ];
  27. // 页面路径
  28. const PAGE_PATH_OPTIONS = [
  29. 1 => '/pages/tabBar/index/index',
  30. 2 => '/pages/tabBar/allGoods/allGoods',
  31. 3 => '/pages/cart/pages/goodsDetail/goodsDetail',
  32. 4 => '/pages/activity/pages/groupShopping/groupGoodsDetail/groupGoodsDetail',
  33. 5 => '/pages/activity/pages/bargain/index/index',
  34. 6 => '/pages/cart/pages/goodsDetail/goodsDetail',
  35. 7 => '/pages/cart/pages/goodsDetail/goodsDetail',
  36. 8 => '/pages/cart/pages/goodsDetail/goodsDetail',
  37. 9 => '/pages/activity/pages/seckill/index/index',
  38. ];
  39. protected $name = 'promotion_monitor';
  40. /**
  41. * 获取记录
  42. * @param int $id
  43. * @param array $with
  44. * @return static
  45. */
  46. public static function detail(int $id, array $with = [])
  47. {
  48. return static::get($id, $with);
  49. }
  50. /**
  51. * 获取推广监控小程序码
  52. *
  53. * @param int $monitorId 推广监控id
  54. * @param int $pageType 页面类型
  55. * @param int $pageTypeId 页面类型ID
  56. * @return string
  57. */
  58. public static function getPageQrcode(int $monitorId, int $pageType, int $pageTypeId = 0)
  59. {
  60. $pagePath = self::PAGE_PATH_OPTIONS[$pageType] ?? '';
  61. if ($pagePath == '') {
  62. return '';
  63. }
  64. $path = "$pagePath?sourceId=$monitorId&publicId=$pageTypeId&share=xcx";
  65. $qrcode = request()->domain()."/api/mp_wx/qrcode?path=".urlencode($path);
  66. return $qrcode;
  67. }
  68. }