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