72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
|
|
/**
|
|
* 打赏模型
|
|
*@author NetLife <40150501@qq.com>
|
|
**/
|
|
class Bonus extends Base{
|
|
/***打赏****/
|
|
public function bonus() {
|
|
|
|
}
|
|
/*打赏统计*/
|
|
public function report($model,$bookid,$bookname,$saleprice) {
|
|
//打赏日统计
|
|
$reportday = db('reportday')->where('articleid='.$bookid.' and day='.strtotime(date('Y-m-d')))->find();
|
|
if($reportday){
|
|
$data = array(
|
|
'update_time' =>time(),
|
|
'bonusnum' =>['exp','bonusnum+1'],
|
|
'bonus' =>['exp','bonus+'.$saleprice]
|
|
);
|
|
db('reportday')->where('id', $reportday['id'])->update($data);
|
|
}else{
|
|
$data = array(
|
|
'siteid' =>get_novel($bookid,'siteid'),
|
|
'model' =>$model,
|
|
'articleid' =>$bookid,
|
|
'articlename' =>$bookname,
|
|
'authorid' =>get_novel($bookid,'authorid'),
|
|
'create_time' =>time(),
|
|
'update_time' =>time(),
|
|
'day' =>strtotime(date('Y-m-d')),
|
|
'subsnum' =>0,
|
|
'subscription' =>0,
|
|
'bonusnum' =>1,
|
|
'bonus' =>$saleprice
|
|
);
|
|
db('reportday')->insert($data);
|
|
}
|
|
|
|
//订阅月统计
|
|
$reportday = db('reportmonth')->where('articleid='.$bookid.' and month='.strtotime(date('Y-m')))->find();
|
|
if($reportday){
|
|
$data = array(
|
|
'update_time' =>time(),
|
|
'bonusnum' =>['exp','bonusnum+1'],
|
|
'bonus' =>['exp','bonus+'.$saleprice]
|
|
);
|
|
db('reportmonth')->where('id', $reportday['id'])->update($data);
|
|
}else{
|
|
$data = array(
|
|
'siteid' =>get_novel($bookid,'siteid'),
|
|
'model' =>$model,
|
|
'articleid' =>$bookid,
|
|
'articlename' =>$bookname,
|
|
'authorid' =>get_novel($bookid,'authorid'),
|
|
'create_time' =>time(),
|
|
'update_time' =>time(),
|
|
'month' =>strtotime(date('Y-m')),
|
|
'subsnum' =>0,
|
|
'subscription' =>0,
|
|
'bonusnum' =>1,
|
|
'bonus' =>$saleprice
|
|
);
|
|
db('reportmonth')->insert($data);
|
|
}
|
|
}
|
|
|
|
} |