diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 77e830d7..5ea82668 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -157,66 +157,33 @@ class ShopController extends BaseAuthedController { public function outappPurchase() { - $id = getReqVal('id', 0); - $tokenType = getReqVal('token_type', ''); + $goodsId = getReqVal('goods_id', 0); $goodsNum = getReqVal('goods_num', 1); - if ($goodsNum <= 0) { - $this->_rspErr(1, 'goods_num is invalid'); - return; - } - - $goods = mt\ShopGoods::get($id); - if (!$goods) { - $this->_rspErr(1, "id is invalid. {$id}"); - return; - } - - if ($goods['shop_id'] == 9 && $goodsNum > 1) { - $this->_rspErr(1, 'goods_num is invalid'); - return; - } - - $conn = myself()->_getSelfMysql(); + $network = getReqVal('network', ''); + $crypto = getReqVal('crypto', ''); + $fiat = getReqVal('fiat', ''); + $fiatAmount = getReqVal('fiatAmount', ''); + $payWayCode = getReqVal('payWayCode', ''); + $country = getReqVal('country', ''); $address = myself()->_getAddress(); - if (!$address) { + if (empty($address)) { $this->_rspErr(1, 'address is empty'); return; } - - $chk = SqlHelper::insert( - $conn, - 't_shop_buy_order', - array( - 'address' => $address, - 'createtime' => myself()->_getNowTime(), - 'id' => $id, - 'item_id' => $goods['goods_id'] ? $goods['goods_id'] : 0, - 'goods_num' => $goodsNum, - 'status' => 0, // 0-客户端申请了订单 1-订单完成 2-订单失败 - ) - ); - if ($chk) { - $lastId = $this->lastInsertId($conn); - $order_id = $this->genOrderId($lastId); - SqlHelper::update( - $conn, - 't_shop_buy_order', - array( - 'idx' => $lastId, - ), - array( - 'order_id' => $order_id, - ) - ); - $this->_rspData( - array( - 'order_id' => $order_id, - ) - ); - } else { - $this->_rspErr(1, "insert error, id: {$id}, token_type: {$tokenType}, goods_num: {$goodsNum}"); + if ($goodsNum != 1) { + $this->_rspErr(1, 'goods_num is invalid'); + return; + } + $goodsMeta = mt\ShopGoods::get($goodsId); + if (!$goodsMeta) { + $this->_rspErr(1, "goods_id is invalid."); + return; + } + if ($goodsMeta['shop_id'] != mt\Shop::OUTAPP_SHOP) { + $this->_rspErr(1, 'goods_num is invalid'); + return; } } diff --git a/webapp/mt/Shop.php b/webapp/mt/Shop.php index 323d797d..c2fdaf53 100644 --- a/webapp/mt/Shop.php +++ b/webapp/mt/Shop.php @@ -43,6 +43,7 @@ class Shop { const WEEKLY_BUY_LIMIT = 2; const TOTAL_BUY_LIMIT = 3; + const OUTAPP_SHOP = 7; const INAPP_SHOP_DIAMOND = 9; const OUTSIDE_SHOP = 100;