... 每日精选增加金币购买支持

This commit is contained in:
songliang 2023-07-19 17:02:20 +08:00
parent 3d1c737fbf
commit 2674dcc27a

View File

@ -1201,6 +1201,16 @@ class ShopController extends BaseAuthedController
return; 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(''); $conn = $this->_getMysql('');
$row = SqlHelper::selectOne( $row = SqlHelper::selectOne(
@ -1234,17 +1244,29 @@ class ShopController extends BaseAuthedController
$goods = mt\Dailyselection::get($sel_id); $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); $costItemId = $this->getCostItemIdByTokenType($token_type);
$costItems = $this->makeCostItems($costItemId, $count * $goods['price']); $costItems = $this->makeCostItems($costItemId, $count * $need_price);
$lackItem = null; $lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) { if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem)); $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
return; return;
} }
$item_id = $goods['goods_id']; $item_id = $goods['goods_id'];
$item_num = $goods['goods_num']; $item_num = $goods['goods_num'];
@ -1264,7 +1286,18 @@ class ShopController extends BaseAuthedController
'name' => LogService::SHOP_BUY_ITEM_DAILY, 'name' => LogService::SHOP_BUY_ITEM_DAILY,
'val' => $costItems[0]['item_num'] '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( $goodsDto = array(
'goods_id' => $sel_id, 'goods_id' => $sel_id,
@ -1275,12 +1308,14 @@ class ShopController extends BaseAuthedController
), ),
'bought_times' => 0, 'bought_times' => 0,
'total_buy_times' => 0, 'total_buy_times' => 0,
); { );
{
$priceInfo = mt\Item::getPriceInfo($itemMeta); $priceInfo = mt\Item::getPriceInfo($itemMeta);
if (!empty($priceInfo)) { if (!empty($priceInfo)) {
$goodsDto['price_info'] = $priceInfo['price_info']; $goodsDto['price_info'] = $priceInfo['price_info'];
} }
} }
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$this->_rspData( $this->_rspData(