1
This commit is contained in:
parent
a86bebddd2
commit
d5c6cf57d2
@ -93,7 +93,6 @@ class MallController extends BaseAuthedController {
|
|||||||
'ignore_empty' => true,
|
'ignore_empty' => true,
|
||||||
'custom_func' => function () use ($queryData) {
|
'custom_func' => function () use ($queryData) {
|
||||||
$priceFilters = $queryData['price_filter'];
|
$priceFilters = $queryData['price_filter'];
|
||||||
error_log($priceFilters);
|
|
||||||
$arrPriceFilter = explode('|', $priceFilters);
|
$arrPriceFilter = explode('|', $priceFilters);
|
||||||
$priceLow = $arrPriceFilter[0];
|
$priceLow = $arrPriceFilter[0];
|
||||||
$priceHigh = $arrPriceFilter[1];
|
$priceHigh = $arrPriceFilter[1];
|
||||||
@ -123,17 +122,12 @@ class MallController extends BaseAuthedController {
|
|||||||
$itemId = getReqVal('item_id', '');
|
$itemId = getReqVal('item_id', '');
|
||||||
$amount = getReqVal('amount', '');
|
$amount = getReqVal('amount', '');
|
||||||
$currency = getReqVal('currency', '');
|
$currency = getReqVal('currency', '');
|
||||||
$price = getReqVal('price', '');
|
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
|
||||||
if ($itemId != V_ITEM_GOLD) {
|
if ($itemId != V_ITEM_GOLD) {
|
||||||
$this->_rspErr(1, 'only support gold');
|
$this->_rspErr(1, 'only support gold');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (empty($price)) {
|
if (!$this->checkPrice($priceBn)) {
|
||||||
$this->_rspErr(1, 'price not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($price <= 0) {
|
|
||||||
$this->_rspErr(1, 'price must > 0');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (empty($amount)) {
|
if (empty($amount)) {
|
||||||
@ -186,7 +180,7 @@ class MallController extends BaseAuthedController {
|
|||||||
$itemId,
|
$itemId,
|
||||||
$amount,
|
$amount,
|
||||||
$currency,
|
$currency,
|
||||||
$price
|
phpcommon\bnToStr($priceBn)
|
||||||
);
|
);
|
||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
@ -243,17 +237,8 @@ class MallController extends BaseAuthedController {
|
|||||||
public function modifyPrice()
|
public function modifyPrice()
|
||||||
{
|
{
|
||||||
$goodsUuid = getReqVal('goods_uuid', '');
|
$goodsUuid = getReqVal('goods_uuid', '');
|
||||||
$price = getReqVal('price', '');
|
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
|
||||||
if (empty($price)) {
|
if (!$this->checkPrice($priceBn)) {
|
||||||
myself()->_rspErr(1, 'price not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($price <= 0) {
|
|
||||||
myself()->_rspErr(1, 'price must > 0');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!is_numeric($price)) {
|
|
||||||
myself()->_rspErr(1, 'price must be number');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
||||||
@ -266,8 +251,25 @@ class MallController extends BaseAuthedController {
|
|||||||
myself()->_rspErr(1, 'cant modify price');
|
myself()->_rspErr(1, 'cant modify price');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Mall::modifyPrice($goodsDto['goods_uuid'], $price);
|
Mall::modifyPrice($goodsDto['goods_uuid'], phpcommon\bnToStr($priceBn));
|
||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkPrice($priceBn)
|
||||||
|
{
|
||||||
|
if ($priceBn === false) {
|
||||||
|
myself()->_rspErr(1, 'price format error1');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (phpcommon\bnCmp($this->priceLowBn, $priceBn) > 0) {
|
||||||
|
myself()->_rspErr(1, 'price format error2');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (phpcommon\bnCmp($this->priceHighBn, $priceBn) < 0) {
|
||||||
|
myself()->_rspErr(1, 'price format error3');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user