This commit is contained in:
aozhiwei 2023-07-28 19:24:34 +08:00
parent af85a43182
commit 76e1076f45

View File

@ -90,30 +90,36 @@ class ShopController extends BaseAuthedController
{
$shop_id = getReqVal('shop_id', 0);
if ($shop_id == 0) {
$goodsList = mt\ShopGoods::all();
$goodsMetaList = mt\ShopGoods::all();
} else {
$goodsList = mt\ShopGoods::getGoodsList($shop_id);
$goodsMetaList = mt\ShopGoods::getGoodsList($shop_id);
}
$goodsList = $goodsList ? $goodsList : array();
$goodsMetaList = $goodsMetaList ? $goodsMetaList : array();
$buyRecordHash = ShopBuyRecord::allToHash();
foreach ($goodsList as &$goods) {
$goods['bought_times'] = 0;
switch ($goods['limit_type']) {
$goodsList = array();
foreach ($goodsMetaList as $goodsMeta) {
$goodsDto = array(
'goods_meta' => $this->goodsMetaToInfo($goodsMeta),
'bought_times' => 0,
'free_num' => 0,
);
array_push($goodsList, $goodsDto);
switch ($goodsMeta['limit_type']) {
case mt\Item::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goods['id']);
$goods['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
$buyRecord = getXVal($buyRecordHash, $goodsMeta['id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
}
break;
case mt\Item::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goods['id']);
$goods['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
$buyRecord = getXVal($buyRecordHash, $goodsMeta['id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
}
break;
case mt\Item::TOTAL_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goods['id']);
$goods['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
$buyRecord = getXVal($buyRecordHash, $goodsMeta['id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
}
break;
default: {
@ -121,8 +127,8 @@ class ShopController extends BaseAuthedController
break;
}
$goods_id = $goods['goods_id'];
$itemMeta = mt\Item::get($goods_id);
$goodsId = $goodsMeta['goods_id'];
$itemMeta = mt\Item::get($goodsId);
if ($itemMeta) {
// 如果是皮肤,判断是否已经拥有,如果已经拥有,不能购买
if ($itemMeta['type'] == mt\Item::HERO_SKIN_TYPE) {
@ -136,23 +142,16 @@ class ShopController extends BaseAuthedController
}
} else {
// error !!!!!!
error_log('item not found:' . $goods_id);
error_log('item not found:' . $goodsId);
}
if (empty($goods['goods_num'])) {
$goods['goods_num'] = 1;
}
if (!empty($goods['free_type'])) {
$count = $this->countFreeBuyTimes($goods['free_type'], $goods['id'], $goods['goods_id']);
$count = $this->countFreeBuyTimes($goodsMeta['free_type'],
$goodsMeta['id'],
$goodsMeta['goods_id']);
$goods['free_num'] = $goods['free_num'] - $count;
// error_log('free_num:' . $goods['free_num']);
}
$address = $this->_getAddress();
if ($address) {
// $goods['pending'] = $this->checkPendingBuyGoodsNormal($address, $goods['goods_id'], $goods['shop_id'], $goods['id']);
$goods['pending'] = 0;
}
}
$this->_rspData(
@ -905,9 +904,7 @@ class ShopController extends BaseAuthedController
private function countFreeBuyTimes($free_type, $id, $goods_id)
{
$conn = myself()->_getMysql('');
$account = myself()->_getAccountId();
return 0;
switch ($free_type) {
case 1: {
$dayTime = myself()->_getNowDaySeconds();
@ -948,4 +945,10 @@ class ShopController extends BaseAuthedController
}
}
private function goodsMetaToInfo($goodsMeta) {
return array(
);
}
}