This commit is contained in:
aozhiwei 2023-07-25 19:16:30 +08:00
commit cc0128f155
10 changed files with 106 additions and 29 deletions

View File

@ -279,6 +279,7 @@ class Shop(object):
['idx', 0, '每日精选的索引'],
['grid', 0, '商品在每日精选中的位置索引'],
['count', 0, '购买数量,始终是1'],
['token_type', '', "选用币种,只能选择一种"],
],
'response': [
_common.RspHead(),

View File

@ -450,8 +450,9 @@ class DailySelectionGoods(object):
['goods_num', 0, '商品堆叠数量'],
['shop_icon', "", '商品图标'],
['weight', 0, '权重'],
['discount', 0, '折扣'],
['price', 0, '价格'],
['token_type', '', '代币类型(4|0)'],
['discount', '', '折扣(95|80)'],
['price', '', '价格(100|100000)'],
['pending', 0, '购买中...'],
]

View File

@ -0,0 +1,5 @@
UPDATE t_user o JOIN (
SELECT owner_address, item_id, SUM(amount) as t FROM t_market_store WHERE `status`=3 AND item_id=10001 GROUP BY owner_address
) t ON o.address = t.owner_address
SET o.gold = o.gold + t.t;
UPDATE t_market_store SET `status`=1 WHERE `status`=3;

View File

@ -388,10 +388,15 @@ class ShopController extends BaseAuthedController
default:
error_log("buyGoodsDirect--- " . $order_id . " --- " . $status);
$this->_rspErr(1, "status error, status: {$status}");
break;
return;
}
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
SqlHelper::update($conn, 't_shop_buy_order', array('order_id' => $order_id), array('status' => $buyStatus));
if ($buyStatus == 2) {
$this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}");
return;
}
// 以下是看商品表中是否配置了充值额外奖励
$goods = mt\ShopGoods::get($id);
@ -411,7 +416,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_CEBG_BONUS,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num);
@ -622,7 +627,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(
@ -674,7 +679,7 @@ class ShopController extends BaseAuthedController
'name' => LogService::RECHARGE_DIAMOND,
'val' => -$item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_decGoods($address, array(
@ -1201,6 +1206,16 @@ class ShopController extends BaseAuthedController
return;
}
$token_type = getReqVal('token_type', '');
switch ($token_type) {
case ShopController::TOKEN_TYPE_GOLD:
case ShopController::TOKEN_TYPE_DIAMOND:
break;
default:
$this->_rspErr(1, "token_type is unsupport, {$token_type}");
return;
}
$conn = $this->_getMysql('');
$row = SqlHelper::selectOne(
@ -1234,17 +1249,32 @@ class ShopController extends BaseAuthedController
$goods = mt\Dailyselection::get($sel_id);
$token_type = $goods['token_type'];
$desired_token_type = $goods['token_type'];
$check_token_type = splitStr1($desired_token_type);
if (!in_array($token_type, $check_token_type)) {
$this->_rspErr(1, "token_type parameter error, desired_token_type: {$desired_token_type}");
return;
}
$token_pos = array_search($token_type, $check_token_type, true);
$price_array = splitStr1($goods['price']);
$discount_array = splitStr1($goods['discount']);
$need_price = $price_array[$token_pos];
$discount = $discount_array[$token_pos];
$costItemId = $this->getCostItemIdByTokenType($token_type);
$costItems = $this->makeCostItems($costItemId, $count * $goods['price']);
$costItems = $this->makeCostItems($costItemId, $count * $need_price);
error_log("buyGoodsDS costItems " . json_encode($costItems));
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
return;
}
$item_id = $goods['goods_id'];
$item_num = $goods['goods_num'];
@ -1264,7 +1294,18 @@ class ShopController extends BaseAuthedController
'name' => LogService::SHOP_BUY_ITEM_DAILY,
'val' => $costItems[0]['item_num']
];
LogService::consumeDiamond($event);
switch ($token_type) {
case ShopController::TOKEN_TYPE_GOLD:
LogService::consumeGold($event);
break;
case ShopController::TOKEN_TYPE_DIAMOND:
LogService::consumeDiamond($event);
break;
default:
// 这里不应该出现,出现了说明配置表新增了一种货币,但是这里没有处理
error_log("buyGoodsDS token_type is invalid, token_type: {$token_type}");
return;
}
$goodsDto = array(
'goods_id' => $sel_id,
@ -1275,12 +1316,14 @@ class ShopController extends BaseAuthedController
),
'bought_times' => 0,
'total_buy_times' => 0,
); {
);
{
$priceInfo = mt\Item::getPriceInfo($itemMeta);
if (!empty($priceInfo)) {
$goodsDto['price_info'] = $priceInfo['price_info'];
}
}
$propertyChgService->addUserChg();
$this->_rspData(

View File

@ -173,7 +173,7 @@ class BlockChainService {
private static function getWeb3ServiceUrl()
{
if (SERVER_ENV == _DEBUG) {
return 'https://login-test.kingsome.cn/webapp/index.php';
return 'https://192.144.140.87/webapp/index.php';
}
if (SERVER_ENV == _TEST) {
return 'http://127.0.0.1:7672/webapp/index.php';

View File

@ -46,7 +46,7 @@ class LogService extends BaseService
public static function consumeGold($event,$param = [])
{
$logInfo = self::goldRecord($param);
$logInfo = self::goldRecord(myself()->_getAccountId());
$data = self::userInfo();
$data['type'] = self::CONSUME_TYPE;
$data['event_name'] = $event['name'];
@ -76,7 +76,7 @@ class LogService extends BaseService
public static function productGold($event,$param = [])
{
$logInfo = self::goldRecord($param);
$logInfo = self::goldRecord(myself()->_getAccountId());
$data = self::userInfo();
$data['type'] = self::PRODUCT_TYPE;
$data['event_name'] = $event['name'];
@ -87,8 +87,22 @@ class LogService extends BaseService
$logInfo['properties'] = array_merge($data,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
}
public static function productGoldCallback($base, $event,$param = [])
{
$logInfo = self::goldRecord($base['account_id']);
$data = self::userInfoByAccountId($base['account_id']);
$data['type'] = self::PRODUCT_TYPE;
$data['event_name'] = $event['name'];
$data['event_type'] = self::GOLD_TYPE;
$data['event_product'] = 'gold';
$data['event_product_val'] = $event['val'];
public static function productDiamond($base, $event,$param = [])
$logInfo['properties'] = array_merge($data,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
}
public static function productDiamondCallback($base, $event,$param = [])
{
$logInfo = self::diamondRecord($base['account_id']);
$data = self::userInfoByAccountId($base['account_id']);
@ -141,14 +155,8 @@ class LogService extends BaseService
);
return $info;
}
private static function goldRecord($params = [])
private static function goldRecord($account_id)
{
if (isset($params['account_id']) && !empty($params['account_id'])) {
$account_id = $params['account_id'];
} else {
$account_id = myself()->_getAccountId();
}
// $logInfo['log_class'] = $logInfo['log_class'];
// unset($logInfo['log_class']);
$data = array(

View File

@ -90,7 +90,7 @@ class BuyShopGoodsCbService
'name' => LogService::CEBG_TO_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(

View File

@ -116,6 +116,7 @@ class GameItemMarketBuyOk
private function buyFromMarket($order, $idx)
{
$address = $order['address'];
$account_id = $this->getAccountId($address);
$goods = $this->getMarketGoods($address, $idx);
$this->markMarketGoodsSold($address, $idx);
@ -126,7 +127,7 @@ class GameItemMarketBuyOk
'name' => LogService::MARKET_BUY_GOLD,
'val' => $goods['amount']
];
LogService::productGold($event, ['account_id' => $address]);
LogService::productGoldCallback(['account_id' => $account_id], $event );
}
}
@ -182,4 +183,17 @@ class GameItemMarketBuyOk
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
}
}
private function getAccountId($address){
$row = SqlHelper::ormSelectOne
(myself()->_getMysql($address),
't_user',
array(
'address' => $address
)
);
return $row['account_id'];
}
}

View File

@ -101,7 +101,12 @@ class ShopBuyGoodsDirect
break;
}
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
SqlHelper::update($conn, 't_shop_buy_order', array('order_id' => $order_id), array('status' => $buyStatus));
if ($buyStatus == 2) {
$this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}");
return;
}
// 以下是看商品表中是否配置了充值额外奖励
$goods = ShopGoods::get($id);
@ -121,7 +126,7 @@ class ShopBuyGoodsDirect
'name' => LogService::RECHARGE_CEBG_BONUS,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num);

View File

@ -130,7 +130,7 @@ class ShopInappPurchaseDiamonds
'name' => LogService::RECHARGE_DIAMOND,
'val' => $item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_addGoods($address, array(
@ -182,7 +182,7 @@ class ShopInappPurchaseDiamonds
'name' => LogService::RECHARGE_DIAMOND,
'val' => -$item_num
];
LogService::productDiamond(['account_id' => $account_id], $event);
LogService::productDiamondCallback(['account_id' => $account_id], $event);
}
$this->_decGoods($address, array(