Merge branch 'star' of git.kingsome.cn:server/game2006api into star

This commit is contained in:
hujiabin 2023-07-16 14:43:20 +08:00
commit a458be812e

View File

@ -365,6 +365,7 @@ class ShopController extends BaseAuthedController
$id = $order['id']; $id = $order['id'];
$goods_num = $order['goods_num']; $goods_num = $order['goods_num'];
$o_status = $order['status']; $o_status = $order['status'];
$address = $order['address'];
if ($o_status != 0) { if ($o_status != 0) {
$this->_rspErr(1, "order status error, status: {$o_status}"); $this->_rspErr(1, "order status error, status: {$o_status}");
@ -375,6 +376,8 @@ class ShopController extends BaseAuthedController
switch ($status) { switch ($status) {
case "9": case "9":
$buyStatus = 1; $buyStatus = 1;
// 充值成功,开始首充奖励
$this->beginFirstTupop($address);
break; break;
case "99": case "99":
case "98": case "98":
@ -398,7 +401,7 @@ class ShopController extends BaseAuthedController
$meta = mt\Item::get($item_id); $meta = mt\Item::get($item_id);
error_log("buyGoodsDirect---" . $item_id . "---" . $item_num . "---" . $bundle_size . "---" . $meta['name']); error_log("buyGoodsDirect---" . $item_id . "---" . $item_num . "---" . $bundle_size . "---" . $meta['name']);
if ($meta && $item_num > 0) { if ($meta && $item_num > 0) {
$address = $order['address']; // $address = $order['address'];
$account_id = $this->getAccountId($address); $account_id = $this->getAccountId($address);
if ($item_id == V_ITEM_DIAMOND) { if ($item_id == V_ITEM_DIAMOND) {
@ -844,10 +847,10 @@ class ShopController extends BaseAuthedController
public function buyGoodsNormal() public function buyGoodsNormal()
{ {
$address = $this->_getAddress(); $address = $this->_getAddress();
// if (empty($address)) { if (empty($address)) {
// $this->_rspErr(4, 'address is empty'); $this->_rspErr(4, 'address is empty');
// return; return;
// } }
$id = getReqVal('id', 0); $id = getReqVal('id', 0);
$token_type = getReqVal('token_type', ''); $token_type = getReqVal('token_type', '');
$goods_num = getReqVal('goods_num', 0); $goods_num = getReqVal('goods_num', 0);
@ -1132,6 +1135,15 @@ class ShopController extends BaseAuthedController
public function buyDiamond() public function buyDiamond()
{ {
$num = getReqVal('num', 0); $num = getReqVal('num', 0);
if (!is_numeric($num)) {
$this->_rspErr(1, "num is invalid, {$num}");
return;
}
if ($num <= 0) {
$this->_rspErr(1, "num is invalid, {$num}");
return;
}
$price = $this->normalizeWeb3Price($num); $price = $this->normalizeWeb3Price($num);
$item_id = V_ITEM_DIAMOND; $item_id = V_ITEM_DIAMOND;
$item_count = $num; $item_count = $num;
@ -1170,14 +1182,23 @@ class ShopController extends BaseAuthedController
public function buyGoodsDS() public function buyGoodsDS()
{ {
$idx = getReqVal('idx', 0); $idx = getReqVal('idx', 0);
$grid = getReqVal('grid', 0); if ($idx <= 0) {
$count = getReqVal('count', 0); $this->_rspErr(2, 'idx is invalid');
return;
}
$grid = getReqVal('grid', 0);
if ($grid < 1 || $grid > 6) { if ($grid < 1 || $grid > 6) {
$this->_rspErr(2, 'grid is invalid'); $this->_rspErr(2, 'grid is invalid');
return; return;
} }
$count = getReqVal('count', 0);
if ($count<=0) {
$this->_rspErr(2, 'count is invalid');
return;
}
$conn = $this->_getMysql(''); $conn = $this->_getMysql('');
$row = SqlHelper::selectOne( $row = SqlHelper::selectOne(
@ -1647,12 +1668,6 @@ class ShopController extends BaseAuthedController
if ($this->_isVirtualItem($itemMeta['id'])) { if ($this->_isVirtualItem($itemMeta['id'])) {
$this->_addVirtualItem($itemMeta['id'], $count, null, $propertyChgService); $this->_addVirtualItem($itemMeta['id'], $count, null, $propertyChgService);
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
// 充值就尝试开启首充活动
if ($sysAdd != 1) {
if ($itemMeta['id'] == 10001) {
$this->beginFirstTupop();
}
}
} else { } else {
Bag::addItem($itemMeta['id'], $count); Bag::addItem($itemMeta['id'], $count);
$propertyChgService->addBagChg(); $propertyChgService->addBagChg();
@ -1702,15 +1717,18 @@ class ShopController extends BaseAuthedController
return true; return true;
} }
private function beginFirstTupop() private function beginFirstTupop($address = null)
{ {
if (!$address) {
$address = myself()->_getAddress();
}
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$exist = SqlHelper::selectOne( $exist = SqlHelper::selectOne(
$conn, $conn,
't_first_topup', 't_first_topup',
array('address'), array('address'),
array('address' => myself()->_getAddress()) array('address' => $address)
); );
if ($exist) { if ($exist) {
return; return;
@ -1721,7 +1739,7 @@ class ShopController extends BaseAuthedController
$conn, $conn,
't_first_topup', 't_first_topup',
array( array(
'address' => myself()->_getAddress(), 'address' => $address,
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
'status1' => 0, 'status1' => 0,
'status2' => 0, 'status2' => 0,
@ -1848,10 +1866,10 @@ class ShopController extends BaseAuthedController
} }
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
if ($item['item_type'] == 2) { if ($item['item_type'] == 2) {
$this->internalAddItem($propertyChgService, $itemMeta, $item['num'], 1, $grade); $this->internalAddItem($propertyChgService, $itemMeta, $item['num'], 0, $grade);
} else { } else {
for ($j = 0; $j < $item['num']; $j++) { for ($j = 0; $j < $item['num']; $j++) {
$this->internalAddItem($propertyChgService, $itemMeta, 1, 1, $grade); $this->internalAddItem($propertyChgService, $itemMeta, 1, 0, $grade);
} }
} }
$record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']); $record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']);