1
This commit is contained in:
parent
eb3ab5d87d
commit
05fba50801
@ -30,8 +30,8 @@ class FirstTopupController extends BaseAuthedController {
|
||||
for ($i = 1; $i <= 3; ++$i) {
|
||||
if ($dbInfo['status' . $i] != 2) {
|
||||
$complete = 0;
|
||||
break;
|
||||
}
|
||||
$status[$i] = $dbInfo['status' . $i];
|
||||
}
|
||||
if ($complete == 1 && myself()->_getV(TN_FIRST_TUPOP_STATUS, 0) == 0) {
|
||||
myself()->_setV(TN_FIRST_TUPOP_STATUS, 0, 1);
|
||||
@ -48,36 +48,32 @@ class FirstTopupController extends BaseAuthedController {
|
||||
public function get()
|
||||
{
|
||||
$group = getReqVal('group', 1);
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
|
||||
$address = myself()->_getAddress();
|
||||
if (!$address) {
|
||||
$this->_rspErr(1, 'you have not a web3 address');
|
||||
if ($group < 1 || $group > 3) {
|
||||
$this->_rspErr(1, "not yet to receive the reward, group: $group");
|
||||
return;
|
||||
}
|
||||
$dbInfo = FirstTopup::get();
|
||||
if (!$dbInfo) {
|
||||
$this->_rspErr(1, "not yet to receive the reward, group: $group");
|
||||
return;
|
||||
}
|
||||
FirstTopup::adjustStatus($dbInfo);
|
||||
if ($dbInfo['status' . $group] == 2) {
|
||||
$this->_rspErr(2, "already received the reward, group: $group");
|
||||
return;
|
||||
}
|
||||
if ($dbInfo['status' . $group] != 1) {
|
||||
$this->_rspErr(1, "not yet to receive the reward, group: $group");
|
||||
return;
|
||||
}
|
||||
|
||||
$status = $this->getStatusFromDB($conn);
|
||||
|
||||
$test = $status[$group - 1];
|
||||
|
||||
if ($test == 1) {
|
||||
$status[$group - 1] = 2;
|
||||
$chk = SqlHelper::update(
|
||||
$conn,
|
||||
't_first_topup',
|
||||
array(
|
||||
'address' => myself()->_getAddress(),
|
||||
),
|
||||
array(
|
||||
'status' . $group => 2,
|
||||
)
|
||||
);
|
||||
FirstTopup::update(array(
|
||||
'status' . $group => 2
|
||||
));
|
||||
$dbInfo['status' . $group] = 2;
|
||||
// 发放奖励
|
||||
$reward = mt\FirstTopup::getByGroup($group);
|
||||
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
|
||||
for ($i = 0; $i < count($reward); $i++) {
|
||||
$item = $reward[$i];
|
||||
$itemMeta = mt\Item::get($item['goods_id']);
|
||||
@ -85,24 +81,23 @@ class FirstTopupController extends BaseAuthedController {
|
||||
$this->internalAddItem($propertyChgService, $itemMeta, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$complete = ($status[0] == 2 && $status[1] == 2 && $status[2] == 2) ? 1 : 0;
|
||||
if ($complete == 1) {
|
||||
$this->_setV(TN_FIRST_TUPOP_STATUS, 0, 1);
|
||||
$complete = 1;
|
||||
for ($i = 1; $i <= 3; ++$i) {
|
||||
if ($dbInfo['status' . $i] != 2) {
|
||||
$complete = 0;
|
||||
}
|
||||
|
||||
$this->_rspData(
|
||||
$status[$i] = $dbInfo['status' . $i];
|
||||
}
|
||||
if ($complete == 1 && myself()->_getV(TN_FIRST_TUPOP_STATUS, 0) == 0) {
|
||||
myself()->_setV(TN_FIRST_TUPOP_STATUS, 0, 1);
|
||||
}
|
||||
myself()->_rspData(
|
||||
array(
|
||||
'group' => $group,
|
||||
'status' => $status,
|
||||
'reward' => $reward,
|
||||
)
|
||||
);
|
||||
} else if ($test >= 2) {
|
||||
$this->_rspErr(2, "already received the reward, group: $group");
|
||||
} else if ($test < 1) {
|
||||
$this->_rspErr(1, "not yet to receive the reward, group: $group");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class FirstTopup extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function update($orderId, $fieldsKv)
|
||||
public static function update($fieldsKv)
|
||||
{
|
||||
SqlHelper::update(
|
||||
myself()->_getSelfMysql(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user