Commit b73937b9 authored by rlgy's avatar rlgy

update

parent 31eca27c
......@@ -13,7 +13,6 @@ namespace common\models\psources;
*
* @property int $id
* @property int $aid
* @property int $amount
* @property string $device_id
* @property string $address
* @property string $txhash
......@@ -30,4 +29,16 @@ class CoinMidGuess extends BaseActiveRecord
{
return self::findOne(['device_id' => $device_id, 'address' => $address]);
}
/**
* 获取记录条数
*
* @param string $device_id
* @param string $address
* @return int|string
*/
public static function existsCount($device_id, $address)
{
return self::find()->where(['device_id' => $device_id, 'address' => $address])->count();
}
}
\ No newline at end of file
......@@ -44,8 +44,8 @@ class GuessController extends BaseController
$coin_activity = CoinActivity::isValiable($activity);
if ($coin_activity) {
$new_user = CoinMidGuess::isExists($deviceId, $address);
if ($new_user && $new_user->amount >= 3) {
$count = CoinMidGuess::existsCount($deviceId, $address);
if ($count >= 3) {
$response->build(-1, '用户经参次数达到上限');
} else {
//打币,返回txhash
......@@ -57,19 +57,13 @@ class GuessController extends BaseController
$amount = intval($config['amount'] * 1e8);
$note = $guessNumber . ' ' . $address;
$result = Chain33Business::transToken($from, $to, $amount, $note, $isToken, $token);
if (is_string($result)) {
if (true) {
//添加数据库记录
if ($new_user) {
$model = $new_user;
} else {
$model = new CoinMidGuess();
$model->amount = 0;
}
$model->device_id = $deviceId;
$model->address = $address;
$model->txhash = $result;
$model->aid = $coin_activity->id;
$model->amount += 1;
if ($model->save()) {
$response->build(ResponseBuild::STATUS_SUCCEED, '', $result);
}
......@@ -101,9 +95,9 @@ class GuessController extends BaseController
return $response;
}
$info = CoinMidGuess::findOne(['address' => $address, 'aid' => $coin_activity->id]);
$info = CoinMidGuess::find()->where(['address' => $address, 'aid' => $coin_activity->id])->asArray()->all();
if ($info) {
$txhash = $info->txhash;
$txhash = array_column($info, 'txhash');
$response->build(ResponseBuild::STATUS_SUCCEED, '', $txhash);
} else {
$response->build(1, '记录不存在');
......
......@@ -39,7 +39,6 @@ class JugdeAwardJob extends BaseObject implements JobInterface
// $trans_normal = Chain33Business::getTxByAddrInRange($config['from_normal'], 2, 0, $guess_result->start_height, $guess_result->end_height);
$trans_normal = Chain33Business::getTxByAddrInRange('14o9MHrrLfpsXf7wu4H4YRwvy84fjd7uaj', 2, 0, 710900, 715345);
$trans_new = Chain33Business::getTxByAddrInRange($config['to'], 2, 0, $guess_result->start_height, $guess_result->end_height);
$trans = array_merge($trans_normal, $trans_new);
$txhashs = array_column($trans, 'hash');
$trans_info = Chain33Business::getTxByHashs($txhashs);
......
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