修复:进入文章详情报错

修复:违规次数到达限制后,只进行了惩罚未减少违规次数
This commit is contained in:
wuhui_zzw 2023-03-07 14:12:36 +08:00
parent 3420f4ecd9
commit 2ca9152040
4 changed files with 76 additions and 11 deletions

View File

@ -7,8 +7,6 @@ use addon\article\model\ArticleFabulous;
use addon\article\model\ArticleHistory; use addon\article\model\ArticleHistory;
use addon\article\model\ArticleShareRecord; use addon\article\model\ArticleShareRecord;
use addon\article\model\ArticleShareRewardRecord; use addon\article\model\ArticleShareRewardRecord;
use addon\businesscard\model\Record;
use addon\fenxiao\newModel\Fenxiao;
use app\api\controller\BaseApi; use app\api\controller\BaseApi;
use addon\article\model\Article; use addon\article\model\Article;
use app\model\newModel\Config; use app\model\newModel\Config;
@ -100,9 +98,6 @@ class Index extends BaseApi{
$info['member'] = (new Member())->getArticleMemberInfo($this->member_id); $info['member'] = (new Member())->getArticleMemberInfo($this->member_id);
// 文章浏览信息处理 // 文章浏览信息处理
(new ArticleHistory())->addInfo($this->member_id,$id); (new ArticleHistory())->addInfo($this->member_id,$id);
// 记录用户浏览信息
if($this->member_id != $sourceMember) (new Record())->addInfo($this->member_id,$sourceMember);
if(empty($info['data'])) return $this->response($this->error('', '文章不存在')); if(empty($info['data'])) return $this->response($this->error('', '文章不存在'));
return $this->response($info); return $this->response($info);
@ -195,11 +190,11 @@ class Index extends BaseApi{
if($isHas > 0 && !$isGet){ if($isHas > 0 && !$isGet){
// 正常领取奖励 // 正常领取奖励
$res = $ArticleShareRewardRecordModel->shareReward($articleId,$this->member_id,$sourceMember,(float)$set['integral']); $res = $ArticleShareRewardRecordModel->shareReward($articleId,$this->member_id,$sourceMember,(float)$set['integral']);
if($set['parent_integral'] > 0 && $res['code'] == 0){ // if($set['parent_integral'] > 0 && $res['code'] == 0){
// 上级领取奖励 // // 上级领取奖励
$parentMemberId = (new Fenxiao())->getParentMemberId($sourceMember); // $parentMemberId = (new Fenxiao())->getParentMemberId($sourceMember);
$res = $ArticleShareRewardRecordModel->shareReward($articleId,$this->member_id,$parentMemberId,(float)$set['parent_integral'],1); // $res = $ArticleShareRewardRecordModel->shareReward($articleId,$this->member_id,$parentMemberId,(float)$set['parent_integral'],1);
} // }
return $this->response($res); return $this->response($res);
} }

View File

@ -310,7 +310,10 @@ class Futures extends BaseModel{
$startTime = $futuresUserInfo['punish_time'] > time() ? $futuresUserInfo['punish_time'] : time(); $startTime = $futuresUserInfo['punish_time'] > time() ? $futuresUserInfo['punish_time'] : time();
Db::name('futures_user') Db::name('futures_user')
->where('member_id',$date['member_id']) ->where('member_id',$date['member_id'])
->update(['punish_time' => strtotime("+{$violationHour} hours", $startTime)]); ->update([
'punish_time' => strtotime("+{$violationHour} hours", $startTime),// 添加惩罚时间
'violation_num' => Db::raw("violation_num - {$violationUnpaid}")// 减少违规次数
]);
} }
return $this->success(); return $this->success();

View File

@ -98,4 +98,71 @@ class NewBaseModel extends \think\Model{
return $lang; return $lang;
} }
/**
* Common: 获取单条信息
* Author: wu-hui
* Time: 2022/10/14 15:41
* @param $id
* @param array $fields
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function singleInfo($id,$fields = []):array{
//根据id获取数据信息
$info = $this->field($fields)->find($id);
if(!$info) return [];
//处理相关数据信息
$info = $info ? $info->toArray() : [];
return $this->success($info);
}
/**
* Common: 添加/编辑内容(公共)
* Author: wu-hui
* Time: 2022/10/14 11:25
* @param $info
* @return array
*/
public function editInfo($info){
$this->startTrans();
try{
// 判断是添加还是修改
if((int)$info[$this->pk] > 0) self::update($info, [$this->pk => $info[$this->pk]]);// 修改内容
else self::create($info);
$this->commit();
return $this->success();
}catch(\Exception $e){
$this->rollback();
return $this->error('',$e->getMessage());
}
}
/**
* Common: 删除信息(公共)
* Author: wu-hui
* Time: 2022/10/14 12:01
* @param $id
* @return array
*/
public function delInfo($id){
// id 不存在,返回
if((int)$id <= 0) return $this->error('','删除失败,参数错误!');
// 删除操作
$this->startTrans();
try{
$this->where($this->pk,$id)
->useSoftDelete('delete_time',time())
->delete();
$this->commit();
return $this->success();
}catch(\Exception $e){
$this->rollback();
return $this->error('',$e->getMessage());
}
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB