Commit 31eca27c authored by rlgy's avatar rlgy

update

parent 54a4caa2
......@@ -13,6 +13,7 @@ namespace common\models\psources;
*
* @property int $id
* @property int $aid
* @property int $amount
* @property string $device_id
* @property string $address
* @property string $txhash
......
......@@ -44,8 +44,9 @@ class GuessController extends BaseController
$coin_activity = CoinActivity::isValiable($activity);
if ($coin_activity) {
if (CoinMidGuess::isExists($deviceId, $address)) {
$response->build(-1, '用户已经参与过该活动');
$new_user = CoinMidGuess::isExists($deviceId, $address);
if ($new_user && $new_user->amount >= 3) {
$response->build(-1, '用户经参次数达到上限');
} else {
//打币,返回txhash
$config = Yii::$app->params['h5_activity'][$activity];
......@@ -58,11 +59,17 @@ class GuessController extends BaseController
$result = Chain33Business::transToken($from, $to, $amount, $note, $isToken, $token);
if (is_string($result)) {
//添加数据库记录
$model = new CoinMidGuess();
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);
}
......
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