1
This commit is contained in:
parent
324985ddb3
commit
04c8272dce
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
||||
Subproject commit 6efb9d7831e4e69a2f7e7b75ce44ccfb13b9b685
|
||||
Subproject commit 3fc9e3c7657803eed51f7c2ee34af6185855409b
|
@ -8,11 +8,13 @@ require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\ShopBuyRecord;
|
||||
|
||||
class ShopController extends BaseAuthedController {
|
||||
|
||||
@ -29,10 +31,51 @@ class ShopController extends BaseAuthedController {
|
||||
));
|
||||
return;
|
||||
}
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$goodsDtoList1 = array();
|
||||
$goodsDtoList2 = array();
|
||||
foreach ($goodsList as $goods) {
|
||||
|
||||
$itemMeta = mt\Item::get($goods['goods_id']);
|
||||
if ($itemMeta) {
|
||||
$goodsDto = array(
|
||||
'goods_id' => $goods['goods_id'],
|
||||
'item_id' => $itemMeta['id'],
|
||||
'price_info' => null,
|
||||
'flag_icon' => $goods['tag'],
|
||||
'limit_type' => $itemMeta['limit_type'],
|
||||
'bought_times' => 0,
|
||||
'total_buy_times' => $itemMeta['limit_num'],
|
||||
);
|
||||
switch ($itemMeta['limit_type']) {
|
||||
case mt\Item::DAILY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||
if (!empty($priceInfo)) {
|
||||
$goodsDto['price_info'] = $priceInfo;
|
||||
array_push($goodsDtoList1, $goodsDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'info' => array(
|
||||
|
@ -29,7 +29,7 @@ class ShopBuyRecord extends BaseModel {
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
)
|
||||
);
|
||||
return array_map($rows, function($val) {
|
||||
return array_map(function($val) {
|
||||
$nowDaySeconds = myself()->_getNowDaySeconds();
|
||||
if (!($row['last_buy_time'] >= $nowDaySeconds && $row['last_buy_time'] <= $nowDaySeconds)) {
|
||||
$val['this_day_buy_times'] = 0;
|
||||
@ -39,7 +39,17 @@ class ShopBuyRecord extends BaseModel {
|
||||
$val['this_week_buy_times'] = 0;
|
||||
}
|
||||
return $val;
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
public static function allToHash()
|
||||
{
|
||||
$rows = self::all();
|
||||
$buyRecordHash = array();
|
||||
array_walk($rows, function ($val) use(&$buyRecordHash) {
|
||||
$buyRecordHash[$val['item_id']] = $val;
|
||||
});
|
||||
return $buyRecordHash;
|
||||
}
|
||||
|
||||
public static function toDto($row)
|
||||
|
@ -53,6 +53,10 @@ class Item {
|
||||
const GUILD_RENAME_CARD_TYPE = 20;
|
||||
const HERO_EXP_TYPE = 21;
|
||||
|
||||
const DAILY_BUY_LIMIT = 1;
|
||||
const WEEKLY_BUY_LIMIT = 2;
|
||||
const TOTAL_BUY_LIMIT = 3;
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id, null);
|
||||
|
@ -42,8 +42,8 @@ class ShopGoods {
|
||||
'goodsHash' => array()
|
||||
);
|
||||
}
|
||||
self::$shopGoodsHash['shop_id']['goodsHash'][$meta['goods_id']] = $meta;
|
||||
array_push(self::$shopGoodsHash['shop_id']['goodsList'], $meta);
|
||||
self::$shopGoodsHash[$meta['shop_id']]['goodsHash'][$meta['goods_id']] = $meta;
|
||||
array_push(self::$shopGoodsHash[$meta['shop_id']]['goodsList'], $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user