shopxo/app/api/controller/Buy.php

96 lines
2.7 KiB
PHP
Raw Normal View History

2018-12-28 18:58:37 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Licensed ( https://opensource.org/licenses/mit-license.php )
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\api\controller;
2021-07-20 23:45:54 +08:00
use app\service\ApiService;
2021-04-11 15:51:06 +08:00
use app\service\SystemBaseService;
use app\service\GoodsService;
use app\service\UserService;
use app\service\PaymentService;
use app\service\BuyService;
2018-12-28 18:58:37 +08:00
/**
* 购买
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Buy extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-30
* @desc description
*/
public function __construct()
{
parent::__construct();
// 是否登录
2019-03-02 23:17:30 +08:00
$this->IsLogin();
2018-12-28 18:58:37 +08:00
}
/**
* [Index 首页]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-02-22T16:50:32+0800
*/
public function Index()
{
// 获取商品列表
$params = $this->data_post;
$params['user'] = $this->user;
2021-07-20 23:45:54 +08:00
$ret = BuyService::BuyTypeGoodsList($params);
2018-12-28 18:58:37 +08:00
// 商品校验
2021-07-20 23:45:54 +08:00
if(isset($ret['code']) && $ret['code'] == 0)
2018-12-28 18:58:37 +08:00
{
// 基础信息
2021-07-20 23:45:54 +08:00
$buy_base = $ret['data']['base'];
$buy_goods = $ret['data']['goods'];
2018-12-28 18:58:37 +08:00
// 支付方式
$payment_list = PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]);
// 数据返回组装
$result = [
2021-01-06 21:26:19 +08:00
'goods_list' => $buy_goods,
'payment_list' => $payment_list,
'base' => $buy_base,
'common_site_type' => (int) $buy_base['common_site_type'],
2018-12-28 18:58:37 +08:00
];
2021-07-20 23:45:54 +08:00
$ret = SystemBaseService::DataReturn($result);
2018-12-28 18:58:37 +08:00
}
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn($ret);
2018-12-28 18:58:37 +08:00
}
/**
* 订单添加
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-25
* @desc description
*/
public function Add()
{
$params = $this->data_post;
$params['user'] = $this->user;
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(BuyService::OrderInsert($params));
2018-12-28 18:58:37 +08:00
}
}
?>