Files
shopxo/application/api/controller/Buy.php

104 lines
3.1 KiB
PHP
Raw Normal View History

2018-12-28 18:58:37 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2019-02-18 13:52:07 +08:00
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\service\GoodsService;
use app\service\UserService;
use app\service\PaymentService;
use app\service\BuyService;
2020-01-03 19:28:33 +08:00
use app\service\PluginsService;
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;
$buy_ret = BuyService::BuyTypeGoodsList($params);
2018-12-28 18:58:37 +08:00
// 商品校验
if(isset($buy_ret['code']) && $buy_ret['code'] == 0)
2018-12-28 18:58:37 +08:00
{
// 基础信息
$buy_base = $buy_ret['data']['base'];
$buy_goods = $buy_ret['data']['goods'];
2018-12-28 18:58:37 +08:00
// 支付方式
$payment_list = PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]);
// 数据返回组装
$result = [
'goods_list' => $buy_goods,
2018-12-28 18:58:37 +08:00
'payment_list' => $payment_list,
'base' => $buy_base,
2018-12-28 18:58:37 +08:00
'common_order_is_booking' => (int) MyC('common_order_is_booking', 0),
'common_site_type' => (int) $buy_base['common_site_type'],
2018-12-28 18:58:37 +08:00
];
2020-01-03 19:28:33 +08:00
// 优惠劵
2020-08-20 12:47:42 +08:00
$ret = PluginsService::PluginsControlCall('coupon', 'coupon', 'buy', 'api', ['order_goods'=>$buy_goods, 'params'=>$params]);
2020-01-03 19:28:33 +08:00
if($ret['code'] == 0 && isset($ret['data']['code']) && $ret['data']['code'] == 0)
{
$result['plugins_coupon_data'] = $ret['data']['data'];
}
2019-03-20 17:14:44 +08:00
return DataReturn('操作成功', 0, $result);
2018-12-28 18:58:37 +08:00
}
return $ret;
}
/**
* 订单添加
* @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;
2019-11-20 18:35:38 +08:00
return BuyService::OrderInsert($params);
2018-12-28 18:58:37 +08:00
}
}
?>