Commit 78661cff authored by shajiaiming's avatar shajiaiming

优化

parent de243275
......@@ -15,8 +15,6 @@ class CrossChainController extends BaseController
public function actionTransfer()
{
$code = -1;
$msg = 'fail';
$request = Yii::$app->request;
if (!$request->isPost) {
$msg = '请求错误!';
......@@ -32,22 +30,22 @@ class CrossChainController extends BaseController
$data['address'] = $post['address'];
$data['transfer_number'] = date('YmdHis') . self::getrandnums();
// $redis = Yii::$app->redis;
// if ($redis->exists($post['address'] . '_' . $data['is_with_draw'])) {
// $msg = '存在未完成的交易!';
// goto doEnd;
// }
// $redis->set($post['address'] . '_' . $data['is_with_draw'], $post['address'] . '_' . $data['is_with_draw']);
$isExist = CoinCrossChain::find()
->where(['address' => $post['address'], 'is_with_draw' => $data['is_with_draw']])
->andWhere(['<>', 'query_result', 'success'])
->asArray()->all();
if ($isExist) {
$redis = Yii::$app->redis;
if ($redis->exists($post['address'] . '_' . $data['is_with_draw'])) {
$msg = '存在未完成的交易!';
goto doEnd;
}
$redis->set($post['address'] . '_' . $data['is_with_draw'], $post['address'] . '_' . $data['is_with_draw']);
// $isExist = CoinCrossChain::find()
// ->where(['address' => $post['address'], 'is_with_draw' => $data['is_with_draw']])
// ->andWhere(['<>', 'query_result', 'success'])
// ->asArray()->all();
//
// if ($isExist) {
// $msg = '存在未完成的交易!';
// goto doEnd;
// }
foreach ($post['txs'] as $key => $val) {
$model = new CoinCrossChain();
......@@ -89,7 +87,6 @@ class CrossChainController extends BaseController
}
sort($model);
foreach ($model as $key => $val) {
//未交易
if ('0' == $val['send_result'] && '0' == $val['query_result'] && '0' == $val['msg']) {
......
......@@ -100,7 +100,17 @@ class CrossChainController extends Controller
$currentModel->query_result = $query_result;
$currentModel->msg = $msg;
$currentModel->save();
$count = CoinCrossChain::find()->where(['transfer_number' => $val['transfer_number']])->andWhere(['query_result' => 'success'])->count();
if (3 == $count) {
$redis = Yii::$app->redis;
$key = $val['address'] . '_' . $val['is_with_draw'];
if ($redis->exists($key)) {
$redis->del($key);
}
}
}
echo date('Y-m-d H:i:s') . '查询成功' . PHP_EOL;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment