1
This commit is contained in:
parent
697d845658
commit
ec8231e4eb
@ -115,10 +115,12 @@ class ShopController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
switch ($itemMeta['limit_type']) {
|
||||
case mt\Item::DAILY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, '已达今日限购上限次数');
|
||||
return;
|
||||
@ -132,6 +134,7 @@ class ShopController extends BaseAuthedController {
|
||||
case mt\Item::WEEKLY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, '已达本周限购上限次数');
|
||||
return;
|
||||
@ -145,7 +148,8 @@ class ShopController extends BaseAuthedController {
|
||||
case mt\Item::TOTAL_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, '已达限购上限次数');
|
||||
return;
|
||||
}
|
||||
@ -188,11 +192,32 @@ class ShopController extends BaseAuthedController {
|
||||
$awardService = new services\AwardService();
|
||||
$awardService->addItem($itemId, $itemNum);
|
||||
ShopBuyRecord::add($itemId, $itemNum);
|
||||
$goodsDto = array(
|
||||
'goods_id' => $itemMeta['id'],
|
||||
'item_id' => $itemMeta['id'],
|
||||
'price_info' => array(
|
||||
'item_id' => $itemMeta['id'],
|
||||
'cost_list' => array(),
|
||||
'discount_begin_time' => phpcommon\datetimeToTimestamp($itemMeta['discount_begin']),
|
||||
'discount_end_time' => phpcommon\datetimeToTimestamp($itemMeta['discount_end'])
|
||||
),
|
||||
'flag_icon' => $goodsMeta['tag'],
|
||||
'limit_type' => $itemMeta['limit_type'],
|
||||
'bought_times' => $boughtTimes,
|
||||
'total_buy_times' => $itemMeta['limit_num'],
|
||||
);
|
||||
{
|
||||
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||
if (!empty($priceInfo)) {
|
||||
$goodsDto['price_info'] = $priceInfo;
|
||||
}
|
||||
}
|
||||
$this->rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => array(
|
||||
'user_info' => User::info($this->_getOrmUserInfo())
|
||||
)
|
||||
),
|
||||
'goods_chg' => $goodsDto
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,14 @@ use phpcommon\SqlHelper;
|
||||
|
||||
class ShopBuyRecord extends BaseModel {
|
||||
|
||||
public static function find($heroId)
|
||||
public static function find($itemId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero',
|
||||
't_shop_buy_record',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'hero_id' => $heroId,
|
||||
'item_id' => $itemId,
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
|
Loading…
x
Reference in New Issue
Block a user