You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.7 KiB
120 lines
3.7 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\apiController;
|
|
|
|
use app\Request;
|
|
use app\service\api\apiService\CampusService;
|
|
use app\service\api\apiService\ChatService;
|
|
use app\service\api\apiService\CommonService;
|
|
use app\service\api\apiService\CourseService;
|
|
use app\service\api\apiService\OrderTableService;
|
|
use core\base\BaseApiService;
|
|
|
|
/**
|
|
* 订单-控制器相关接口
|
|
* Class Personnel
|
|
* @package app\api\controller\apiController
|
|
*/
|
|
class OrderTable extends BaseApiService
|
|
{
|
|
|
|
//订单-列表
|
|
public function index(Request $request)
|
|
{
|
|
$resource_id = $request->param('resource_id', '');//客户资源表school_customer_resources表id(两个参数2选1)
|
|
$staff_id = $request->param('staff_id', '');//员工表school_personnel表id(两个参数2选1)
|
|
if (empty($resource_id) && empty($staff_id)) {
|
|
return fail('缺少参数');
|
|
}
|
|
|
|
$where = [
|
|
'resource_id' => $resource_id,
|
|
'staff_id' => $staff_id,
|
|
];
|
|
|
|
$res = (new OrderTableService())->getList($where);
|
|
|
|
return success($res);
|
|
}
|
|
|
|
//订单-详情
|
|
public function info(Request $request)
|
|
{
|
|
$resource_id = $request->param('resource_id', '');//客户资源表school_customer_resources表id(两个参数2选1)
|
|
$staff_id = $request->param('staff_id', '');//员工表school_personnel表id(两个参数2选1)
|
|
if (empty($resource_id) && empty($staff_id)) {
|
|
return fail('缺少参数');
|
|
}
|
|
|
|
$where = [
|
|
'resource_id' => $resource_id,
|
|
'staff_id' => $staff_id,
|
|
];
|
|
|
|
$res = (new OrderTableService())->getInfo($where);
|
|
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success($res['data']);
|
|
}
|
|
|
|
//订单-创建
|
|
public function add(Request $request)
|
|
{
|
|
|
|
$params = $request->params([
|
|
["payment_type", ""], // 付款类型必填验证
|
|
["course_id", ""], // 课程ID必填验证
|
|
["class_id", ""], // 班级ID必填验证
|
|
["staff_id", ""], // 员工ID必填验证
|
|
["resource_id", ""], // 客户资源表ID必填验证
|
|
]);
|
|
|
|
foreach($params as $k=>$v){
|
|
if(empty($v)){
|
|
return fail('缺少参数');
|
|
}
|
|
}
|
|
|
|
|
|
$course = \app\model\course\Course::where('id', $params['course_id'])->find();
|
|
if (!$course) {
|
|
return fail('课程不存在');
|
|
}
|
|
$course = $course->toArray();
|
|
$order_amount = $course['price'];//课程的价格
|
|
|
|
|
|
$data = [
|
|
'payment_type' => $params['payment_type'],//付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付
|
|
'order_amount' => $order_amount,//订单金额
|
|
'course_id' => $params['course_id'],//课程ID
|
|
'class_id' => $params['class_id'],//班级ID
|
|
'staff_id' => $params['staff_id'],//员工表ID
|
|
'resource_id' => $params['resource_id'],//客户资源表id
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$res = (new OrderTableService())->addData($data);
|
|
|
|
if (!$res['code']) {
|
|
return fail($res['msg']);
|
|
}
|
|
|
|
return success([]);
|
|
}
|
|
}
|
|
|