From 236246701dab60e0ad022ee28d7720d186e13c56 Mon Sep 17 00:00:00 2001 From: zengyyh Date: Thu, 4 Jul 2024 22:36:12 +0800 Subject: [PATCH] 20240704 --- app/admin/controller/Course.php | 17 ++++++++++++++++- app/admin/model/Course.php | 30 ++++++++++++++++++++++++++++-- app/api/controller/Checkout.php | 10 ++++++++-- app/api/service/order/Checkout.php | 1 + 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/Course.php b/app/admin/controller/Course.php index cd0d25a3..10358056 100644 --- a/app/admin/controller/Course.php +++ b/app/admin/controller/Course.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 diff --git a/app/admin/model/Course.php b/app/admin/model/Course.php index 985683cd..fa4424c1 100644 --- a/app/admin/model/Course.php +++ b/app/admin/model/Course.php @@ -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; + } } \ No newline at end of file diff --git a/app/api/controller/Checkout.php b/app/api/controller/Checkout.php index a19b3d42..66ae4727 100644 --- a/app/api/controller/Checkout.php +++ b/app/api/controller/Checkout.php @@ -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 "
";
+        // 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'];
diff --git a/app/api/service/order/Checkout.php b/app/api/service/order/Checkout.php
index ebe07bbb..94406e9b 100644
--- a/app/api/service/order/Checkout.php
+++ b/app/api/service/order/Checkout.php
@@ -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'],