aField; $aInsert = []; foreach ($aField as $key => $value) { if(isset($aParam[$value])){ $aInsert[$value] = $aParam[$value]; } } $result = 0; if(!empty($aInsert)){ $result = DB::name('wechat_queue_logs')->insertGetId($aParam); } return $result; } // 记录任务成功 public function updateLog($aParam = []) { $iLogId = empty($aParam['log_id']) ? 0 : $aParam['log_id']; if(empty($iLogId)){ return false; } //数据处理 $aField = $this->aField; $aUpdate = []; foreach ($aField as $key => $value) { if(isset($aParam[$value])){ $aUpdate[$value] = $aParam[$value]; } } unset($aParam['log_id']); $result = DB::name('wechat_queue_logs')->where('log_id',$iLogId)->limit(1)->update($aUpdate); return $result; } /** * 写入Reids 防止1小时内重复操作 */ public function setRedisLabel($aParam = []){ //判断数据是否为空 if(empty($aParam['redis_key'])){ return false; } //获取值 $sValue = $this->getRedisLabel($aParam['redis_key']); if(!empty($sValue)){ return false; } //写入 return Cache::set($aParam['redis_key'], $aParam['redis_key'], 3600); } /** * 获取Reids值 */ public function getRedisLabel($sRedisKey = ''){ if(empty($sRedisKey)){ return ''; } return Cache::get($sRedisKey); } } ?>