1
This commit is contained in:
parent
2307d68d6b
commit
4c195789ae
@ -61,7 +61,7 @@ class ShopController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function buyGoods()
|
public function buyGoods()
|
||||||
{
|
{
|
||||||
$id = getReqVal('id', 0);
|
$goodsUuid = getReqVal('goods_uuid', 0);
|
||||||
$tokenType = getReqVal('token_type', '');
|
$tokenType = getReqVal('token_type', '');
|
||||||
$goodsNum = getReqVal('goods_num', 0);
|
$goodsNum = getReqVal('goods_num', 0);
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class ShopController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$goodsMeta = mt\ShopGoods::get($id);
|
$goodsMeta = mt\ShopGoods::getByGoodsUuid($id);
|
||||||
if (!$goodsMeta) {
|
if (!$goodsMeta) {
|
||||||
$this->_rspErr(1, 'goods not found');
|
$this->_rspErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
@ -114,18 +114,18 @@ class ShopController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$price_array = splitStr1($goodsMeta['price']);
|
$priceArray = splitStr1($goodsMeta['price']);
|
||||||
$discount_array = splitStr1($goodsMeta['discount']);
|
$discountArray = splitStr1($goodsMeta['discount']);
|
||||||
|
|
||||||
$need_price = $price_array[$token_pos];
|
$needPrice = $priceArray[$tokenPos];
|
||||||
$discount = $discount_array[$token_pos];
|
$discount = $discountArray[$tokenPos];
|
||||||
|
|
||||||
$discount_begin = strtotime($goodsMeta['discount_begin']);
|
$discountBegin = strtotime($goodsMeta['discount_begin']);
|
||||||
$discount_end = strtotime($goodsMeta['discount_end']);
|
$discountEnd = strtotime($goodsMeta['discount_end']);
|
||||||
$nowTime = $this->_getNowTime();
|
$nowTime = $this->_getNowTime();
|
||||||
|
|
||||||
if ($nowTime >= $discount_begin && $nowTime < $discount_end) {
|
if ($nowTime >= $discountBegin && $nowTime < $discountEnd) {
|
||||||
$need_price = ceil($need_price * ($discount / 100.0));
|
$needPrice = ceil($needPrice * ($discount / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
$costItemId = $this->getCostItemIdByTokenType($tokenType);
|
$costItemId = $this->getCostItemIdByTokenType($tokenType);
|
||||||
@ -145,6 +145,20 @@ class ShopController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||||
return;
|
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()
|
public function outappPurchase()
|
||||||
|
@ -12,6 +12,11 @@ class ShopGoods
|
|||||||
return getXVal(self::getMetaList(), $id);
|
return getXVal(self::getMetaList(), $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getByGoodsUuid($goodsUuid)
|
||||||
|
{
|
||||||
|
return getXVal(self::getMetaList(), $goodsUuid);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getGoodsList($shopId)
|
public static function getGoodsList($shopId)
|
||||||
{
|
{
|
||||||
self::mustBeShopGoodsHash();
|
self::mustBeShopGoodsHash();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user