_confirmHandle('tb'); break; case 'tk': $url = "asset/cash-out"; $message = $this->_confirmHandle('tk'); break; default: throw new MinerException('无效参数'); } } catch (MinerException $e) { $error = "【error】 {$e->getMessage()}"; } catch (\yii\db\Exception $e) { $error = "【DB错误】 {$e->getMessage()}"; } return $this->render('confirm', [ 'url' => $url, 'message' => $message, 'error' => $error ]); } /** * _confirmHandle * @param $key * @return string * @throws MinerException */ private function _confirmHandle($key) { $char = $key == 'tk' ? '提款' : '提币'; $sign = $key == 'tk' ? "####################" : "***************************"; $request = Yii::$app->request; $count = $request->get('count'); $maxId = $request->get('maxId'); $minId = $minTemp = $request->get('minId'); if (!is_numeric($count) || !is_numeric($maxId)) { throw new MinerException('错误的请求参数'); } $cache = Cache::getData("weChat_{$key}_max"); if ($cache > $minId && $cache < $maxId) { $minId = $cache; } if (is_numeric($cache) && $maxId <= $cache) { $str = "

" . "
已被确认过!

" . "确认数量:{$count}

" . "流水编号范围:
{$minId} - {$maxId}
"; } else { Cache::setData("weChat_{$key}_history", 0); Cache::setData("weChat_{$key}_max", $maxId); Cache::setData("weChat_{$key}_min", $maxId); $str = "

" . "
确认成功!

" . "确认数量:{$count}

" . "流水编号范围:
{$minId} - {$maxId}
"; if ($request->get('handle', 'handle') == 'auto' && $minTemp >= $cache) { $msg = "{$char}申请已确认\n" . "$sign\n" . " 确认数:{$count}\n" . " 流水编号范围:\n" . " {$minId} - {$maxId}\n{$sign}"; $chat = Yii::$app->getWeChat()->compose(); $chat->setSendType(4); $chat->setTo($this->groupChat); $chat->setSendBody($msg); $chat->send(); } } return $str; } }