...
This commit is contained in:
parent
b0e722bf6b
commit
c4dc220559
@ -812,6 +812,11 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
public function buyGoodsNormal()
|
public function buyGoodsNormal()
|
||||||
{
|
{
|
||||||
|
$address = $this->_getAddress();
|
||||||
|
if (empty($address)) {
|
||||||
|
$this->_rspErr(2, 'address is empty');
|
||||||
|
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);
|
||||||
@ -864,6 +869,7 @@ class ShopController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ShopController::TOTAL_BUY_LIMIT: {
|
case ShopController::TOTAL_BUY_LIMIT: {
|
||||||
|
$sendingTimes = $this->countBuyGoodsRequestTimesByGoodsId($address, $row['goods_id']);
|
||||||
$buyRecord = getXVal($buyRecordHash, $id);
|
$buyRecord = getXVal($buyRecordHash, $id);
|
||||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $row['limit_num']) {
|
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $row['limit_num']) {
|
||||||
@ -899,6 +905,51 @@ class ShopController extends BaseAuthedController
|
|||||||
$costItemId = $this->getCostItemIdByTokenType($token_type);
|
$costItemId = $this->getCostItemIdByTokenType($token_type);
|
||||||
|
|
||||||
switch ($token_type) {
|
switch ($token_type) {
|
||||||
|
case ShopController::TOKEN_TYPE_GOLD:
|
||||||
|
$costItems = $this->makeCostItems($costItemId, $goods_num * $need_price);
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemMeta = mt\Item::get($row['goods_id']);
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
for ($i = 0; $i < $goods_num; $i++) {
|
||||||
|
$this->internalAddItem($propertyChgService, $itemMeta, $goods_count);
|
||||||
|
}
|
||||||
|
$awardService = new services\AwardService();
|
||||||
|
$awardService->addItem($row['goods_id'], $goods_num);
|
||||||
|
ShopBuyRecord::add($id, $goods_num);
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
$goodsDto = array(
|
||||||
|
'goods_id' => $id,
|
||||||
|
'item_id' => $row['goods_id'],
|
||||||
|
'price_info' => array(
|
||||||
|
'item_id' => $row['goods_id'],
|
||||||
|
'cost_list' => array(),
|
||||||
|
'discount_begin_time' => phpcommon\datetimeToTimestamp($row['discount_begin']),
|
||||||
|
'discount_end_time' => phpcommon\datetimeToTimestamp($row['discount_end'])
|
||||||
|
),
|
||||||
|
'flag_icon' => $row['tag'],
|
||||||
|
'limit_type' => $row['limit_type'],
|
||||||
|
'bought_times' => $boughtTimes,
|
||||||
|
'total_buy_times' => $row['limit_num'],
|
||||||
|
); {
|
||||||
|
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||||
|
if (!empty($priceInfo)) {
|
||||||
|
$goodsDto['price_info'] = $priceInfo['price_info'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$this->_rspData(
|
||||||
|
array(
|
||||||
|
'award' => $awardService->toDto(),
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
'goods_chg' => $goodsDto
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
case ShopController::TOKEN_TYPE_CEG:
|
case ShopController::TOKEN_TYPE_CEG:
|
||||||
case ShopController::TOKEN_TYPE_CEC:
|
case ShopController::TOKEN_TYPE_CEC:
|
||||||
|
|
||||||
@ -1145,6 +1196,20 @@ class ShopController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function countBuyGoodsRequestTimesByGoodsId($address, $goodsId)
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) return;
|
||||||
|
|
||||||
|
$conn = $self->_getMysql('');
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(*) AS cnt FROM t_bc_order WHERE address = '$address' AND item_id = '$goodsId'";
|
||||||
|
|
||||||
|
$row = $conn->execQuery($sql);
|
||||||
|
|
||||||
|
return $row[0]['cnt'];
|
||||||
|
}
|
||||||
|
|
||||||
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
||||||
{
|
{
|
||||||
$propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user