This commit is contained in:
commie
2026-02-21 08:21:05 +08:00
parent 1a7f4bc98a
commit 6586f27c9e
21 changed files with 245 additions and 967 deletions
+5 -2
View File
@@ -170,12 +170,15 @@ class BalanceLog extends Base
public static function queryLogs($userId, $currency, $type = null, $startTime = null, $endTime = null)
{
$model = new static;
$query = $model->setSuffix('_'.strtolower($currency))->where('currency', $currency)
$query = $model->setSuffix('_'.strtolower($currency))
//->where('currency', $currency)
->where('user_id', intval($userId))
->order('created_at', 'desc');
if ($type) {
$query->whereIn('type', $type);
$temp_arr = explode(',', $type); // 得到 ["1", "2", "3", "4"]
$arr = array_map('intval', $temp_arr); // 得到 [1, 2, 3, 4]
$query->whereIn('type', $arr);
}
if ($startTime) {
-67
View File
@@ -1,67 +0,0 @@
<?php
namespace app\model;
use app\model\Base;
/**
* @property integer $id 主键(ID) - 无注释
* @property integer $category_id 分类ID
* @property string $country 国别
* @property integer $score 积分
* @property integer $start_time 开始时间
* @property integer $end_time 结束时间
* @property string $title 标题
* @property integer $total 题目数量
* @property string $body 题目详情
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态
*/
class Questionnaire extends Base
{
function setBodyAttr($v='',$row=[]){
if(is_array($v) || is_object($v)){
return json_encode($v,JSON_UNESCAPED_UNICODE);
}
return '[]';
}
function setStartTimeAttr($v='',$row=[]){
if($v){
return strtotime($v);
}
return $v;
}
// function getStartTimeAttr($v='',$row=[]){
// if($v){
// return is_numeric($v) ? date('Y-m-d H:i:s',$v) : $v;
// }
// return '';
// }
function setEndTimeAttr($v='',$row=[]){
if($v){
return strtotime($v);
}
return $v;
}
// function getEndTimeAttr($v='',$row=[]){
// if($v){
// return is_numeric($v) ? date('Y-m-d H:i:s',$v) : $v;
// }
// return '';
// }
public function getCategoryOptions(){
return Category::where('status','1')->where('type','questionnaire')->column('id,title');
}
function getBodyAttr($v='',$row=[]){
if($v){
return json_decode($v,true);
}
return [];
}
public function category()
{
return $this->belongsTo('Category', 'category_id', 'id');//->setEagerlyType(0);
}
}
+42 -3
View File
@@ -6,8 +6,13 @@ use app\model\Base;
* @property integer $id 主键(ID) - 无注释
* @property string $title 名称
* @property float $price 价格
* @property float $org_price 原价
* @property integer $duration 时长
* @property number $role_id 关联角色
* @property number $month_discount 月折扣
* @property number $quarter_discount 季折扣
* @property number $year_discount 年折扣
* @property number $month_price 月价
* @property number $quarter_price 季价
* @property number $year_price 年价
* @property string $label 标签
* @property integer $status 0:禁用,1启用
* @property integer $created_at 创建时间
@@ -20,7 +25,41 @@ class Thali extends Base
{
// 所有的参数配置统一返回
return array_merge(parent::getOptions(),[
'append' => []
'append' => [
'month_price',
'quarter_price',
'year_price'
],
]);
}
/**
* 月价
*/
public function getMonthPriceAttr($value,$row)
{
return bcmul($row['price'],$row['month_discount'],2);
}
/**
* 季价
*/
public function getQuarterPriceAttr($value,$row)
{
return bcmul($row['price'],$row['quarter_discount'],2);
}
/**
* 年价
*/
public function getYearPriceAttr($value,$row)
{
return bcmul($row['price'],$row['year_discount'],2);
}
function Role(){
return $this->hasOne('UserRole','id','role_id')->bind([
'name'=>'role_name',
'max_send_msg_count'=>'max_send_msg_count',
'max_friend_count'=>'max_friend_count',
'max_group_join_count'=>'max_group_join_count',
'max_gourp_create_count'=>'max_gourp_create_count'
]);
}
-53
View File
@@ -1,53 +0,0 @@
<?php
namespace app\model;
/**
* @property integer $id 主键(ID) - 无注释
* @property integer $user_id 用户ID
* @property string $files 文件列表
* @property string $type 类型
* @property string $memo 原因
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态
*/
class UserXuanchuan extends Base{
protected $name = 'user_xuanzhuan';
protected $autoWriteTimestamp = true;
protected function getOptions(): array{
return array_merge(parent::getOptions(),[
'insert' => [
'status' => 0
],
]);
}
public static function onAfterUpdate($row)
{
$changedData = $row->getChangedData();
if (isset($changedData['status']) && $changedData['status']==1) {
if($row->type == 'pyq'){
\app\model\User::currency1($row->user_id,70,\app\enum\BalanceType::POSTPYQ);
}else{
\app\model\User::currency1($row->user_id,70,\app\enum\BalanceType::POSTGROUP);
}
}
}
function getStatusList(){
return [
'0' => '等待审核',
'1' => '审核通过',
'-1' => '审核失败',
];
}
function getTypeList(){
return [
'pyq' => '朋友圈',
'group' => 'QQ群'
];
}
public function user()
{
return $this->belongsTo('User', 'user_id', 'id');//->setEagerlyType(0);
}
}