This commit is contained in:
azw 2023-07-30 09:07:23 +08:00
parent 2307d68d6b
commit 4c195789ae
2 changed files with 29 additions and 10 deletions

View File

@ -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()

View File

@ -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();