2023-01-29 10:26:52 +08:00

115 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\common\model;
use think\Db;
/**
* 日统计 月统计
*@author NetLife <40150501@qq.com>
**/
class Report extends Base{
/**
* actday [订阅日统计]
*
* @param type $model [模型 1小说 2漫画]
* @param type $articleid [小说ID]
* @param type $day [日期]
* @param type $saleprice [销售价格]
* @param type $sumvipegold [VIP订阅价格]
*
* @return type
**/
public function actday($model=1,$articleid,$day=0,$saleprice=0,$sumvipegold=0) {
$map['articleid'] = $articleid;
$map['day'] = $day?strtotime($day):strtotime(date('Y-m-d'));
$reportday = db('reportday')->where($map)->find();
if($reportday){
if($saleprice){
$data = array(
'update_time' =>time(),
'subsnum' =>['exp','subsnum+1'],
'subscription' =>['exp','subscription+'.$saleprice]
);
}else{
$data = array(
'update_time' =>time(),
'sumvipegold' =>$sumvipegold
);
}
db('reportday')->where('id', $reportday['id'])->update($data);
}else{
$data = array(
'siteid' =>get_novel($articleid,'siteid'),
'model' =>$model,
'articleid' =>$articleid,
'articlename' =>get_novel($articleid,'title'),
'authorid' =>get_novel($articleid,'authorid'),
'create_time' =>time(),
'update_time' =>time(),
'day' =>$day?strtotime($day):strtotime(date('Y-m-d')),
'subsnum' =>$saleprice?1:0,
'subscription' =>$saleprice,
'sumvipegold' =>$sumvipegold,
'bonusnum' =>0,
'bonus' =>0
);
db('reportday')->insert($data);
}
}
/**
* actmonth [订阅月统计]
*
* @param type $model [模型 1小说 2漫画]
* @param type $articleid [小说ID]
* @param type $month [月份]
* @param type $saleprice [销售价格]
* @param type $sumvipegold [VIP订阅价格]
*
* @return type
**/
public function actmonth($model=1,$articleid,$month,$saleprice=0,$sumvipegold=0) {
$map['articleid'] = $articleid;
$map['month'] = $month?strtotime($month):strtotime(date('Y-m'));
$reportday = db('reportmonth')->where($map)->find();
if($reportday){
if($saleprice){
$data = array(
'update_time' =>time(),
'subsnum' =>['exp','subsnum+1'],
'subscription' =>['exp','subscription+'.$saleprice]
);
}else{
$data = array(
'update_time' =>time(),
'sumvipegold' =>$sumvipegold
);
}
db('reportmonth')->where('id',$reportday['id'])->update($data);
}else{
$data = array(
'siteid' =>get_novel($articleid,'siteid'),
'model' =>$model,
'articleid' =>$articleid,
'articlename' =>get_novel($articleid,'title'),
'authorid' =>get_novel($articleid,'authorid'),
'create_time' =>time(),
'update_time' =>time(),
'month' =>$month?strtotime($month):strtotime(date('Y-m')),
'subsnum' =>$saleprice?1:0,
'subscription' =>$saleprice,
'sumvipegold' =>$sumvipegold,
'bonusnum' =>0,
'bonus' =>0
);
db('reportmonth')->insert($data);
}
}
}