...
This commit is contained in:
parent
063d24c9c8
commit
672c754579
31
doc/Shop.py
31
doc/Shop.py
@ -177,6 +177,37 @@ class Shop(object):
|
||||
['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'startInappPurchase',
|
||||
'desc': '发起一个内购(购买钻石)',
|
||||
'group': 'Shop',
|
||||
'url': 'webapp/index.php?c=Shop&a=startInappPurchase',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['id', 0, '商品唯一id,参见shopGoods表'],
|
||||
['goods_num', 0, '商品数量'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['order_id', '', '订单id'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'statusInappPurchase',
|
||||
'desc': '查询内购(购买钻石)状态',
|
||||
'group': 'Shop',
|
||||
'url': 'webapp/index.php?c=Shop&a=statusInappPurchase',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['order_id', '', '订单id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['item_id', '', '商品id'],
|
||||
['item_num', 0, '商品数量'],
|
||||
['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'getPayMethods',
|
||||
'desc': '获取支付方式',
|
||||
|
@ -50,6 +50,10 @@ use models\BcOrder;
|
||||
use services\LogService;
|
||||
use services\ShopAddItemService;
|
||||
|
||||
use function phpcommon\bnAdd_s;
|
||||
use function phpcommon\bnDiv_s;
|
||||
use function phpcommon\bnInit;
|
||||
|
||||
if (!function_exists('array_column')) {
|
||||
function array_column($arr2, $column_key)
|
||||
{
|
||||
@ -367,6 +371,79 @@ class ShopController extends BaseAuthedController
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function startInappPurchase()
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) {
|
||||
$this->_rspErr(1, "start purchase failed");
|
||||
return;
|
||||
}
|
||||
|
||||
$id = getReqVal('id', 0);
|
||||
$goods = mt\ShopGoods::get($id);
|
||||
if (!$goods) {
|
||||
$this->_rspErr(2, "start purchase failed");
|
||||
return;
|
||||
}
|
||||
if ($goods['shop_id'] != 9) {
|
||||
$this->_rspErr(3, "start purchase failed");
|
||||
return;
|
||||
}
|
||||
|
||||
$goods_num = getReqVal('goods_num', 1);
|
||||
|
||||
$account_id = $self->_getAccountId();
|
||||
$address = $self->_getAddress();
|
||||
|
||||
$item_id = $goods['goods_id'];
|
||||
$item_num = $goods['goods_num'] * $goods_num;
|
||||
|
||||
$conn = $self->_getMysql('');
|
||||
|
||||
$chk = SqlHelper::insert($conn, 't_web2_order', array(
|
||||
'status' => 0,
|
||||
'createtime' => $self->_getNowTime(),
|
||||
'account_id' => $account_id,
|
||||
'address' => $address,
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
'id' => $id,
|
||||
'goods_num' => $goods_num,
|
||||
'price' => $goods['price'],
|
||||
));
|
||||
|
||||
if (!$chk) {
|
||||
$this->_rspErr(4, "start purchase failed");
|
||||
return;
|
||||
}
|
||||
$lastId = $this->lastInsertId($conn);
|
||||
// gen order id
|
||||
$order_id_base = date('YmdHis') . "10000000";
|
||||
$divIdx = ($lastId) % 9999999;
|
||||
|
||||
$order_id = bnAdd_s($order_id_base, $divIdx);
|
||||
$test = SqlHelper::update($conn, 't_web2_order', array('idx' => $lastId), array('order_id' => $order_id));
|
||||
if (!$test) {
|
||||
$this->_rspErr(5, "start purchase failed");
|
||||
return;
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'order_id' => $order_id,
|
||||
));
|
||||
}
|
||||
|
||||
public function statusInappPurchase()
|
||||
{
|
||||
$order_id = getReqVal('order_id', '');
|
||||
$conn = myself()->_getMysql('');
|
||||
$order = SqlHelper::selectOne($conn, 't_web2_order', array('item_id', 'item_num', 'status'), array('order_id' => $order_id));
|
||||
if (!$order) {
|
||||
$this->_rspErr(1, "order not found");
|
||||
return;
|
||||
}
|
||||
$this->_rspData($order);
|
||||
}
|
||||
|
||||
public function inappPurchaseDiamonds()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user