$code]) ->find('id,title,code,value,last_time'); } /** * 累计增加奖池金额 * @return float|int|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getAddAward(){ $award = self::where(['code'=> 'award_add_total']) ->field('id,title,code,value,last_time') ->find(); if(empty($award)){ $data = ['title'=>'累计增加奖池金额/USDT','code'=>'award_add_total','value'=>0,'last_time'=>time(),'update_time'=>time(),'create_time'=>time()]; self::insertGetId($data); return 0; } // 今日未增加过则自动计算增加 $lastTIme = isset($award['last_time'])? $award['last_time'] : ''; $awardAddTotal = isset($award['value'])? $award['value'] : 0; if(empty($lastTIme) || strtotime($lastTIme) < strtotime(date('Y-m-d'))){ // 总营业额业绩 $total = Trade::where(['status'=> 3,'on_resale'=>2]) ->where('pay_time','>=',strtotime(date('Y-m-d')) - 86400) ->where('pay_time','<', strtotime(date('Y-m-d'))) ->sum('endnums'); $config = Config::getConfigByGroup('trade'); $awardRate = isset($config['award_rate'])? floatval($config['award_rate']['value']) : 0; $addAward = round($total*$awardRate/100, 2); $usdt = CoinRate::transfer($addAward); $award->value += $usdt; $award->last_time = date('Y-m-d H:i:s'); $award->remark = '累计增加奖池,营业额:'.$total.',增加金额:'.$addAward.'/'.$usdt.'usdt,时间:'.date('Y-m-d H:i:s'); $award->save(); if($award->save()){ $awardAddTotal += $usdt; } } return $awardAddTotal; } }