1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace app\common\model;
- /**
- * 推广监控模型
- * @package app\common\model
- */
- class PromotionMonitor extends BaseModel
- {
- //首页:pages/tabBar/index/index
- //商品列表页:pages/tabBar/allGoods/allGoods
- //商品详情页、N件X折活动、满件送活动、满就送活动:pages/cart/pages/goodsDetail/goodsDetail
- //拼团活动:pages/activity/pages/groupShopping/groupGoodsDetail/groupGoodsDetail
- //砍价活动:pages/activity/pages/bargain/bargainDetail/bargainDetail
- //页面参数:sourceId(渠道来源id)
- // 页面类型
- const PAGE_TYPE_OPTIONS = [
- 1 => '首页',
- 2 => '商品列表页',
- 3 => '商品详情页',
- 4 => '拼团活动',
- 5 => '砍价活动',
- 6 => 'N件X折活动',
- 7 => '满件送活动',
- 8 => '满就送活动',
- 9 => '秒杀活动'
- ];
- // 页面路径
- const PAGE_PATH_OPTIONS = [
- 1 => '/pages/tabBar/index/index',
- 2 => '/pages/tabBar/allGoods/allGoods',
- 3 => '/pages/cart/pages/goodsDetail/goodsDetail',
- 4 => '/pages/activity/pages/groupShopping/groupGoodsDetail/groupGoodsDetail',
- 5 => '/pages/activity/pages/bargain/index/index',
- 6 => '/pages/cart/pages/goodsDetail/goodsDetail',
- 7 => '/pages/cart/pages/goodsDetail/goodsDetail',
- 8 => '/pages/cart/pages/goodsDetail/goodsDetail',
- 9 => '/pages/activity/pages/seckill/index/index',
- ];
- protected $name = 'promotion_monitor';
- /**
- * 获取记录
- * @param int $id
- * @param array $with
- * @return static
- */
- public static function detail(int $id, array $with = [])
- {
- return static::get($id, $with);
- }
- /**
- * 获取推广监控小程序码
- *
- * @param int $monitorId 推广监控id
- * @param int $pageType 页面类型
- * @param int $pageTypeId 页面类型ID
- * @return string
- */
- public static function getPageQrcode(int $monitorId, int $pageType, int $pageTypeId = 0)
- {
- $pagePath = self::PAGE_PATH_OPTIONS[$pageType] ?? '';
- if ($pagePath == '') {
- return '';
- }
- $path = "$pagePath?sourceId=$monitorId&publicId=$pageTypeId&share=xcx";
- $qrcode = request()->domain()."/api/mp_wx/qrcode?path=".urlencode($path);
- return $qrcode;
- }
-
- }
|