This commit is contained in:
aozhiwei 2023-08-08 16:45:09 +08:00
parent a86bebddd2
commit d5c6cf57d2

View File

@ -93,7 +93,6 @@ class MallController extends BaseAuthedController {
'ignore_empty' => true,
'custom_func' => function () use ($queryData) {
$priceFilters = $queryData['price_filter'];
error_log($priceFilters);
$arrPriceFilter = explode('|', $priceFilters);
$priceLow = $arrPriceFilter[0];
$priceHigh = $arrPriceFilter[1];
@ -123,17 +122,12 @@ class MallController extends BaseAuthedController {
$itemId = getReqVal('item_id', '');
$amount = getReqVal('amount', '');
$currency = getReqVal('currency', '');
$price = getReqVal('price', '');
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
if ($itemId != V_ITEM_GOLD) {
$this->_rspErr(1, 'only support gold');
return;
}
if (empty($price)) {
$this->_rspErr(1, 'price not found');
return;
}
if ($price <= 0) {
$this->_rspErr(1, 'price must > 0');
if (!$this->checkPrice($priceBn)) {
return;
}
if (empty($amount)) {
@ -186,7 +180,7 @@ class MallController extends BaseAuthedController {
$itemId,
$amount,
$currency,
$price
phpcommon\bnToStr($priceBn)
);
myself()->_rspOk();
}
@ -243,17 +237,8 @@ class MallController extends BaseAuthedController {
public function modifyPrice()
{
$goodsUuid = getReqVal('goods_uuid', '');
$price = getReqVal('price', '');
if (empty($price)) {
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');
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
if (!$this->checkPrice($priceBn)) {
return;
}
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
@ -266,8 +251,25 @@ class MallController extends BaseAuthedController {
myself()->_rspErr(1, 'cant modify price');
return;
}
Mall::modifyPrice($goodsDto['goods_uuid'], $price);
Mall::modifyPrice($goodsDto['goods_uuid'], phpcommon\bnToStr($priceBn));
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;
}
}