9
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace app\model;
|
||||
|
||||
/**
|
||||
* 相册模型
|
||||
* @property integer $id 主键(ID)
|
||||
* @property integer $user_id 用户ID
|
||||
* @property integer $group_id 内容
|
||||
* @property string $url 图片
|
||||
* @property string $title 标题
|
||||
* @property integer $created_at 创建时间
|
||||
* @property integer $updated_at 更新时间
|
||||
* @property integer $status 状态(0:隐藏 1:正常)
|
||||
*/
|
||||
class Album extends Base
|
||||
{
|
||||
protected $name = 'album';
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return array_merge(parent::getOptions(), [
|
||||
'insert' => [
|
||||
'status' => 1,
|
||||
],
|
||||
]);
|
||||
}
|
||||
public static function onAfterInsert($row){
|
||||
$changeData = $row->getChangedData();
|
||||
if(isset($changeData['url'])) {
|
||||
Files::where('path',$changeData['url'])->inc('use_count');
|
||||
};
|
||||
}
|
||||
|
||||
public static function onAfterUpdate($row){
|
||||
$OrgData = $row->getOrigin();
|
||||
$changeData = $row->getChangedData();
|
||||
if(isset($OrgData['url']) && $OrgData['url']) {
|
||||
\support\Log::info('OrgData string');
|
||||
Files::where('path',$OrgData['url'])->dec('use_count');
|
||||
};
|
||||
if(isset($changeData['url']) && $changeData['url']) {
|
||||
\support\Log::info('changeData string');
|
||||
Files::where('path',$changeData['url'])->inc('use_count');
|
||||
};
|
||||
}
|
||||
|
||||
public static function onAfterDelete($row){
|
||||
Files::where('path',$row->url)->dec('use_count');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class BalanceLog extends Base
|
||||
{
|
||||
$model = new static();
|
||||
if(isset($data['currency'])){
|
||||
if(in_array($data['currency'],Config('site.allow_balance_log'))){
|
||||
if(in_array($data['currency'],Config('site.allow_currency_logs'))){
|
||||
$data['status']=isset($data['status']) ? $data['status']:1;
|
||||
$data['user_id'] = intval($data['user_id']);
|
||||
$data['amount'] = floatval($data['amount']);
|
||||
@@ -56,8 +56,8 @@ class BalanceLog extends Base
|
||||
public static function createAllIndexes(): array
|
||||
{
|
||||
$results = [];
|
||||
$allow_balance_log = Config('site.allow_balance_log');
|
||||
foreach ($allow_balance_log as $currency) {
|
||||
$allow_currency_logs = Config('site.allow_currency_logs');
|
||||
foreach ($allow_currency_logs as $currency) {
|
||||
$results[$currency] = self::createTableIndexes($currency);
|
||||
}
|
||||
return $results;
|
||||
@@ -115,8 +115,8 @@ class BalanceLog extends Base
|
||||
public static function archiveData(int $days = 3): array
|
||||
{
|
||||
$results = [];
|
||||
$allow_balance_log = Config('site.allow_balance_log');
|
||||
foreach ($allow_balance_log as $currency) {
|
||||
$allow_currency_logs = Config('site.allow_currency_logs');
|
||||
foreach ($allow_currency_logs as $currency) {
|
||||
$results[$currency] = self::archiveCurrencyData($currency, $days);
|
||||
}
|
||||
return $results;
|
||||
@@ -175,17 +175,7 @@ class BalanceLog extends Base
|
||||
->order('created_at', 'desc');
|
||||
|
||||
if ($type) {
|
||||
if($type == '99999'){
|
||||
$query->whereIn('type', [
|
||||
\app\enum\BalanceType::OUTPUT_REWARD->value,
|
||||
\app\enum\BalanceType::WITHDRAW_REWARD->value,
|
||||
\app\enum\BalanceType::PRODUCT_INCOME->value,
|
||||
\app\enum\BalanceType::AGENT_COMMISSION->value,
|
||||
\app\enum\BalanceType::DIFFERENTIAL_COMMISSION->value
|
||||
]);
|
||||
}else{
|
||||
$query->where('type', intval($type));
|
||||
}
|
||||
$query->whereIn('type', $type);
|
||||
}
|
||||
|
||||
if ($startTime) {
|
||||
|
||||
@@ -57,6 +57,12 @@ class FriendCircle extends Base
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static function onAfterDelete($row){
|
||||
FriendCircleLike::whereIn('circle_id',$row->id)->delete();
|
||||
FriendCircleComment::whereIn('circle_id',$row->id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联用户
|
||||
*/
|
||||
|
||||
+6
-7
@@ -75,9 +75,9 @@ use support\think\Db;
|
||||
*/
|
||||
class User extends Base
|
||||
{
|
||||
use \think\model\concern\SoftDelete;
|
||||
//use \think\model\concern\SoftDelete;
|
||||
public static function onAfterInsert($row){
|
||||
$res = request()->IM->user->userRegister($row->id,$row->nickname,cdnurl($row->avatar));
|
||||
$res = request()->IM->user->userRegister(idEncode($row->id),$row->nickname,cdnurl($row->avatar));
|
||||
}
|
||||
public static function onAfterUpdate($row){
|
||||
$changeData = $row->getChangedData();
|
||||
@@ -87,25 +87,24 @@ class User extends Base
|
||||
'nickname' => $row->nickname,
|
||||
'faceURL' => cdnurl($row->avatar)
|
||||
];
|
||||
request()->IM->user->updateUserInfo($row->id,$sdata);
|
||||
request()->IM->user->updateUserInfo(idEncode($row->id),$sdata);
|
||||
}
|
||||
if(isset($changeData['status']) || $changeData['status'] == '0'){
|
||||
request()->IM->user->forceLogout($row->id);
|
||||
request()->IM->user->forceLogout(idEncode($row->id));
|
||||
}
|
||||
}
|
||||
public static function onAfterDelete($row)
|
||||
{
|
||||
Db::name('address')->where('user_id',$row->id)->delete();
|
||||
Db::name('recharge')->where('user_id',$row->id)->delete();
|
||||
Db::name('record')->where('user_id',$row->id)->delete();
|
||||
//Db::name('record')->where('user_id',$row->id)->delete();
|
||||
Db::name('withdrawl')->where('user_id',$row->id)->delete();
|
||||
Db::name('user_extend')->where('user_id',$row->id)->delete();
|
||||
Db::name('user_team')->where('descendant_id|ancestor_id','=',$row->id)->delete();
|
||||
Db::name('withdrawl')->where('user_id',$row->id)->delete();
|
||||
foreach(Config('site.allow_currencys') as $currency){
|
||||
(new \app\model\BalanceLog)->setSuffix('_'.$currency)->where('user_id',(int)$row->id)->delete();
|
||||
}
|
||||
request()->IM->user->forceLogout($row->id);
|
||||
request()->IM->user->forceLogout(idEncode($row->id));
|
||||
}
|
||||
public function role()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user