lszyh
zengyyh 9 months ago
parent 42467e693c
commit 236246701d
  1. 17
      app/admin/controller/Course.php
  2. 30
      app/admin/model/Course.php
  3. 10
      app/api/controller/Checkout.php
  4. 1
      app/api/service/order/Checkout.php

@ -28,7 +28,7 @@ class Course extends Controller{
}
//分页查询课程列表
public function getCourseList(): Json
public function list(): Json
{
$courseCategoryId =input('courseCategoryId');
$pageSize = input('pageSize');
@ -44,6 +44,21 @@ class Course extends Controller{
return $this->renderSuccess(compact('list'));
}
//分页查询课程列表
public function getCourseList(): Json
{
$model = new CourseModel();
$list = $model->list($this->request->param());
if(empty($list)){
return $this->renderError("没有课程");
}
foreach($list as $value){
$value['image_url'] = UploadFile::withoutGlobalScope()->where('file_id', '=',$value['image_id'])->find();
$value['video_url'] = UploadFile::withoutGlobalScope()->where('file_id', '=',$value['video_id'])->find();
}
return $this->renderSuccess(compact('list'));
}
//新增课程
public function add(): Json

@ -25,13 +25,39 @@ class Course extends CourseModel
public function getList(int $courseCategoryId, int $pageSize ): \think\Paginator
{
if(empty($courseCategoryId)){
$list = $this->order(['sort' => 'asc', 'create_time' => 'desc'])->paginate($pageSize);
$list = $this->order(['course_id' => 'desc'])->paginate($pageSize);
} else {
$list = $this->where('course_category_id',$courseCategoryId)
->order(['sort' => 'asc', 'create_time' => 'desc'])->paginate($pageSize);
->order(['course_id' => 'desc'])->paginate($pageSize);
}
return $list;
}
public function list(array $param = []): \think\Paginator
{
$pageSize = isset($param['pageSize']) && !empty($param['pageSize']) ? (int)$param['pageSize'] : 15;
// 检索查询条件
$filter = $this->getFilter($param);
$list = $this->where($filter)
->order(['course_id' => 'desc'])
->paginate($pageSize);
return $list;
}
/**
* 获取查询条件
* @param array $param
* @return array
*/
private function getFilter(array $params= []): array
{
// 检索查询条件
$filter = [];
!empty($params['search']) && $filter[] = ['course_name|course_subheading', 'like', "%{$params['search']}%"];
isset($params['courseCategory']) && $filter[] = ['course_category_id', 'in', explode(",", $params['courseCategory'])];
return $filter;
}
}

@ -38,7 +38,7 @@ class Checkout extends Controller
* @throws \cores\exception\BaseException
*/
public function order(string $mode = 'buyNow'): Json
{
{
if ($mode === 'buyNow') {
return $this->buyNow();
} elseif ($mode === 'cart') {
@ -79,6 +79,7 @@ class Checkout extends Controller
'goodsSkuId' => '',
'goodsNum' => 0,
]));
// print_r($params);
// 表单验证
if (!$this->getValidate()->scene('buyNow')->check($params)) {
return $this->renderError($this->getValidate()->getError(), ['isCreated' => false]);
@ -91,11 +92,16 @@ class Checkout extends Controller
(int)$params['goodsNum']
);
$merchantId = 0;
foreach ($goodsList as $g) {
$merchantId = $g['merchant_id'];
}
// 获取订单确认信息
$orderInfo = $Checkout->onCheckout($goodsList);
// echo "<pre>";
// print_r($orderInfo['goodsList']->toArray());
// exit;
// print_r($this->request->isGet());
if ($this->request->isGet()) {
return $this->renderSuccess([
'order' => $orderInfo,
@ -108,7 +114,7 @@ class Checkout extends Controller
return $this->renderError($Checkout->getError(), ['isCreated' => false]);
}
// 创建订单 增加订单
$orderInfo['merchantId'] = $merchantId;
$orderInfo['merchantId'] = $merchantId;
if ($merchantId) {
$model = \app\store\model\Merchant::detail($merchantId, $this->storeId);
$orderInfo['commission_ratio'] = $model['commission_ratio'];

@ -932,6 +932,7 @@ class Checkout extends BaseService
'goods_sku_id' => $goods['skuInfo']['goods_sku_id'],
'goods_props' => $goods['skuInfo']['goods_props'] ?: '',
'content' => $goods['content'] ?? '',
'is_check'=>$goods['is_check'],
'goods_sku_no' => $goods['skuInfo']['goods_sku_no'] ?: '',
'goods_price' => $goods['skuInfo']['goods_price'],
'line_price' => $goods['skuInfo']['line_price'],

Loading…
Cancel
Save