1
This commit is contained in:
parent
c052489fac
commit
a59372c478
@ -157,66 +157,33 @@ class ShopController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function outappPurchase()
|
public function outappPurchase()
|
||||||
{
|
{
|
||||||
$id = getReqVal('id', 0);
|
$goodsId = getReqVal('goods_id', 0);
|
||||||
$tokenType = getReqVal('token_type', '');
|
|
||||||
$goodsNum = getReqVal('goods_num', 1);
|
$goodsNum = getReqVal('goods_num', 1);
|
||||||
|
|
||||||
if ($goodsNum <= 0) {
|
$network = getReqVal('network', '');
|
||||||
$this->_rspErr(1, 'goods_num is invalid');
|
$crypto = getReqVal('crypto', '');
|
||||||
return;
|
$fiat = getReqVal('fiat', '');
|
||||||
}
|
$fiatAmount = getReqVal('fiatAmount', '');
|
||||||
|
$payWayCode = getReqVal('payWayCode', '');
|
||||||
$goods = mt\ShopGoods::get($id);
|
$country = getReqVal('country', '');
|
||||||
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();
|
|
||||||
|
|
||||||
$address = myself()->_getAddress();
|
$address = myself()->_getAddress();
|
||||||
if (!$address) {
|
if (empty($address)) {
|
||||||
$this->_rspErr(1, 'address is empty');
|
$this->_rspErr(1, 'address is empty');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($goodsNum != 1) {
|
||||||
$chk = SqlHelper::insert(
|
$this->_rspErr(1, 'goods_num is invalid');
|
||||||
$conn,
|
return;
|
||||||
't_shop_buy_order',
|
}
|
||||||
array(
|
$goodsMeta = mt\ShopGoods::get($goodsId);
|
||||||
'address' => $address,
|
if (!$goodsMeta) {
|
||||||
'createtime' => myself()->_getNowTime(),
|
$this->_rspErr(1, "goods_id is invalid.");
|
||||||
'id' => $id,
|
return;
|
||||||
'item_id' => $goods['goods_id'] ? $goods['goods_id'] : 0,
|
}
|
||||||
'goods_num' => $goodsNum,
|
if ($goodsMeta['shop_id'] != mt\Shop::OUTAPP_SHOP) {
|
||||||
'status' => 0, // 0-客户端申请了订单 1-订单完成 2-订单失败
|
$this->_rspErr(1, 'goods_num is invalid');
|
||||||
)
|
return;
|
||||||
);
|
|
||||||
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}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class Shop {
|
|||||||
const WEEKLY_BUY_LIMIT = 2;
|
const WEEKLY_BUY_LIMIT = 2;
|
||||||
const TOTAL_BUY_LIMIT = 3;
|
const TOTAL_BUY_LIMIT = 3;
|
||||||
|
|
||||||
|
const OUTAPP_SHOP = 7;
|
||||||
const INAPP_SHOP_DIAMOND = 9;
|
const INAPP_SHOP_DIAMOND = 9;
|
||||||
|
|
||||||
const OUTSIDE_SHOP = 100;
|
const OUTSIDE_SHOP = 100;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user