12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\store\model;
- use app\common\library\helper;
- use app\common\model\PromotionMonitor as PromotionMonitorModel;
- /**
- * 推广监控模型
- * @package app\store\model
- */
- class PromotionMonitor extends PromotionMonitorModel
- {
- public function getList($params = [])
- {
- $filter = [];
- $query = self::alias('m')
- ->where($filter)
- ->leftJoin('promotion_monitor_statistics stat', 'stat.monitor_id=m.id')
- ->field("m.*,sum(stat.pv) as pv,sum(stat.uv) as uv,sum(stat.uv_new) as uv_new,
- sum(stat.pay_order_count) as pay_order_count,sum(stat.pay_user_count) as pay_user_count,
- sum(stat.pay_amount) as pay_amount,convert((sum(stat.pay_user_count)/sum(stat.uv))*100,decimal(10,2)) as ratio")
- ->group('m.id')
- ->order('m.id', 'desc');
- return $query->paginate(15)
- ->each(function ($item) {
- $item['qrcode'] = self::getPageQrcode($item['id'], $item['page_type'], $item['page_id']);
- $item['pv'] = (int)$item['pv'];
- $item['uv'] = (int)$item['uv'];
- $item['uv_new'] = (int)$item['uv_new'];
- $item['pay_order_count'] = (int)$item['pay_order_count'];
- $item['pay_user_count'] = (int)$item['pay_user_count'];
- $item['pay_amount'] = helper::number2($item['pay_amount']);
- $item['ratio'] = helper::number2($item['ratio']);
- });
- }
- /**
- * 新增记录
- * @param array $data
- * @return bool
- */
- public function add(array $data)
- {
- $this->transaction(function () use ($data) {
- $this->save($data);
- });
- return true;
- }
- /**
- * 更新记录
- * @param array $data
- * @return bool
- */
- public function edit(array $data)
- {
- $this->transaction(function () use ($data) {
- $this->save($data);
- });
- return true;
- }
-
- }
|