From 4c195789aec69cc9dc9bf762d9c95dc44c1e8428 Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 30 Jul 2023 09:07:23 +0800 Subject: [PATCH] 1 --- webapp/controller/ShopController.class.php | 34 +++++++++++++++------- webapp/mt/ShopGoods.php | 5 ++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d69b551f..5b868568 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -61,7 +61,7 @@ class ShopController extends BaseAuthedController { public function buyGoods() { - $id = getReqVal('id', 0); + $goodsUuid = getReqVal('goods_uuid', 0); $tokenType = getReqVal('token_type', ''); $goodsNum = getReqVal('goods_num', 0); @@ -70,7 +70,7 @@ class ShopController extends BaseAuthedController { return; } - $goodsMeta = mt\ShopGoods::get($id); + $goodsMeta = mt\ShopGoods::getByGoodsUuid($id); if (!$goodsMeta) { $this->_rspErr(1, 'goods not found'); return; @@ -114,18 +114,18 @@ class ShopController extends BaseAuthedController { } } - $price_array = splitStr1($goodsMeta['price']); - $discount_array = splitStr1($goodsMeta['discount']); + $priceArray = splitStr1($goodsMeta['price']); + $discountArray = splitStr1($goodsMeta['discount']); - $need_price = $price_array[$token_pos]; - $discount = $discount_array[$token_pos]; + $needPrice = $priceArray[$tokenPos]; + $discount = $discountArray[$tokenPos]; - $discount_begin = strtotime($goodsMeta['discount_begin']); - $discount_end = strtotime($goodsMeta['discount_end']); + $discountBegin = strtotime($goodsMeta['discount_begin']); + $discountEnd = strtotime($goodsMeta['discount_end']); $nowTime = $this->_getNowTime(); - if ($nowTime >= $discount_begin && $nowTime < $discount_end) { - $need_price = ceil($need_price * ($discount / 100.0)); + if ($nowTime >= $discountBegin && $nowTime < $discountEnd) { + $needPrice = ceil($needPrice * ($discount / 100.0)); } $costItemId = $this->getCostItemIdByTokenType($tokenType); @@ -145,6 +145,20 @@ class ShopController extends BaseAuthedController { $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem)); return; } + ShopBuyRecord::add($id, $goodsNum); + $this->_decItems($costItems); + $propertyChgService = new services\PropertyChgService(); + for ($i = 0; $i < $goodsNum; $i++) { + $this->internalAddItem($propertyChgService, $itemMeta, $goodsCount, 0); + } + $propertyChgService->addUserChg(); + $this->_rspData( + array( + 'award' => $awardService->toDto(), + 'property_chg' => $propertyChgService->toDto(), + //'goods_chg' => $goodsDto + ) + ); } public function outappPurchase() diff --git a/webapp/mt/ShopGoods.php b/webapp/mt/ShopGoods.php index dd9ef143..010dca95 100644 --- a/webapp/mt/ShopGoods.php +++ b/webapp/mt/ShopGoods.php @@ -12,6 +12,11 @@ class ShopGoods return getXVal(self::getMetaList(), $id); } + public static function getByGoodsUuid($goodsUuid) + { + return getXVal(self::getMetaList(), $goodsUuid); + } + public static function getGoodsList($shopId) { self::mustBeShopGoodsHash();