From d1c918598795d55d92c0572b85b4d3e4df25e0ab Mon Sep 17 00:00:00 2001 From: "1213317725@qq.com" <1213317725@qq.com> Date: Tue, 20 May 2025 17:09:42 +0800 Subject: [PATCH] 1 --- admin/src/app/api/order_table.ts | 33 +- ...rce_changes.customer_resource_changes.json | 3 + ...customer_resources.customer_resources.json | 20 +- .../lang/zh-cn/order_table.order_table.json | 54 +- .../customer_resources/customer_resources.vue | 623 ++++++++++-------- .../components/order-table-edit.vue | 610 ++++++++--------- .../src/app/views/order_table/order_table.vue | 607 +++++++---------- .../customer_resources/CustomerResources.php | 6 +- .../controller/order_table/OrderTable.php | 49 +- niucloud/app/adminapi/route/order_table.php | 10 + niucloud/app/model/class_grade/ClassGrade.php | 226 +++++++ niucloud/app/model/order_table/OrderTable.php | 166 +---- .../CustomerResourcesService.php | 40 +- .../admin/order_table/OrderTableService.php | 42 +- .../app/validate/order_table/OrderTable.php | 12 +- 15 files changed, 1277 insertions(+), 1224 deletions(-) create mode 100644 niucloud/app/model/class_grade/ClassGrade.php diff --git a/admin/src/app/api/order_table.ts b/admin/src/app/api/order_table.ts index dbf4e14f..0b7a02fd 100644 --- a/admin/src/app/api/order_table.ts +++ b/admin/src/app/api/order_table.ts @@ -1,5 +1,9 @@ import request from '@/utils/request' + + + + // USER_CODE_BEGIN -- order_table /** * 获取订单列表 @@ -7,7 +11,7 @@ import request from '@/utils/request' * @returns */ export function getOrderTableList(params: Record) { - return request.get(`order_table/order_table`, { params }) + return request.get(`order_table/order_table`, {params}) } /** @@ -16,7 +20,7 @@ export function getOrderTableList(params: Record) { * @returns */ export function getOrderTableInfo(id: number) { - return request.get(`order_table/order_table/${id}`) + return request.get(`order_table/order_table/${id}`); } /** @@ -25,10 +29,7 @@ export function getOrderTableInfo(id: number) { * @returns */ export function addOrderTable(params: Record) { - return request.post('order_table/order_table', params, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.post('order_table/order_table', params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -38,10 +39,7 @@ export function addOrderTable(params: Record) { * @returns */ export function editOrderTable(params: Record) { - return request.put(`order_table/order_table/${params.id}`, params, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.put(`order_table/order_table/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -50,10 +48,17 @@ export function editOrderTable(params: Record) { * @returns */ export function deleteOrderTable(id: number) { - return request.delete(`order_table/order_table/${id}`, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.delete(`order_table/order_table/${id}`, { showErrorMessage: true, showSuccessMessage: true }) +} + +export function getWithCustomerResourcesList(params: Record){ + return request.get('order_table/customer_resources_all', {params}) +}export function getWithCourseList(params: Record){ + return request.get('order_table/course_all', {params}) +}export function getWithClassGradeList(params: Record){ + return request.get('order_table/class_grade_all', {params}) +}export function getWithPersonnelList(params: Record){ + return request.get('order_table/personnel_all', {params}) } // USER_CODE_END -- order_table diff --git a/admin/src/app/lang/zh-cn/customer_resource_changes.customer_resource_changes.json b/admin/src/app/lang/zh-cn/customer_resource_changes.customer_resource_changes.json index cc01945e..514deb3e 100644 --- a/admin/src/app/lang/zh-cn/customer_resource_changes.customer_resource_changes.json +++ b/admin/src/app/lang/zh-cn/customer_resource_changes.customer_resource_changes.json @@ -18,4 +18,7 @@ "customerResourceChangesDeleteTips": "确定要删除该数据吗?", "startDate": "请选择开始时间", "endDate": "请选择结束时间" + + + } diff --git a/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json b/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json index 57befe1e..31b75bc5 100644 --- a/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json +++ b/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json @@ -34,5 +34,23 @@ "updateCustomerResources":"编辑客户资源", "customerResourcesDeleteTips":"确定要删除该数据吗?", "startDate":"请选择开始时间", - "endDate":"请选择结束时间" + "endDate":"请选择结束时间", + + + "resourceId":"资源", + "resourceIdPlaceholder":"请输入资源", + "orderStatus":"订单状态", + "orderStatusPlaceholder":"请输入订单状态", + "paymentType":"付款类型", + "paymentTypePlaceholder":"请输入付款类型", + "orderAmount":"订单金额", + "orderAmountPlaceholder":"请输入订单金额", + "courseId":"课程", + "courseIdPlaceholder":"请输入课程", + "classId":"班级", + "classIdPlaceholder":"请输入班级", + "staffId":"人员", + "paymentTime":"支付时间", + "addOrderTable":"添加订单", + "updateOrderTable":"编辑订单" } \ No newline at end of file diff --git a/admin/src/app/lang/zh-cn/order_table.order_table.json b/admin/src/app/lang/zh-cn/order_table.order_table.json index 7e371d1d..70f0dc1f 100644 --- a/admin/src/app/lang/zh-cn/order_table.order_table.json +++ b/admin/src/app/lang/zh-cn/order_table.order_table.json @@ -1,35 +1,21 @@ { - "id": "订单编号", - "idPlaceholder": "请输入订单编号", - "paymentId": "支付编号", - "paymentIdPlaceholder": "请输入支付编号", - "orderStatus": "订单状态: pending-待支付, paid-已支付", - "orderStatusPlaceholder": "请输入订单状态: pending-待支付, paid-已支付", - "paymentType": "付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付", - "paymentTypePlaceholder": "请输入付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付", - "orderAmount": "订单金额", - "orderAmountPlaceholder": "请输入订单金额", - "courseId": "课程ID", - "courseIdPlaceholder": "请输入课程ID", - "classId": "班级ID", - "classIdPlaceholder": "请输入班级ID", - "staffId": "人员ID", - "staffIdPlaceholder": "请输入人员ID", - "resourceId": "资源ID", - "resourceIdPlaceholder": "请输入资源ID", - "afterSalesStatus": "售后状态", - "afterSalesStatusPlaceholder": "请输入售后状态", - "afterSalesReason": "售后原因", - "afterSalesReasonPlaceholder": "请输入售后原因", - "afterSalesTime": "售后时间", - "afterSalesTimePlaceholder": "请输入售后时间", - "paymentTime": "支付时间", - "paymentTimePlaceholder": "请输入支付时间", - "subscriptionPaymentTime": "订阅支付生成时间", - "subscriptionPaymentTimePlaceholder": "请输入订阅支付生成时间", - "addOrderTable": "添加订单", - "updateOrderTable": "编辑订单", - "orderTableDeleteTips": "确定要删除该数据吗?", - "startDate": "请选择开始时间", - "endDate": "请选择结束时间" -} + "resourceId":"资源", + "resourceIdPlaceholder":"请输入资源", + "orderStatus":"订单状态", + "orderStatusPlaceholder":"请输入订单状态", + "paymentType":"付款类型", + "paymentTypePlaceholder":"请输入付款类型", + "orderAmount":"订单金额", + "orderAmountPlaceholder":"请输入订单金额", + "courseId":"课程", + "courseIdPlaceholder":"请输入课程", + "classId":"班级", + "classIdPlaceholder":"请输入班级", + "staffId":"人员", + "paymentTime":"支付时间", + "addOrderTable":"添加订单", + "updateOrderTable":"编辑订单", + "orderTableDeleteTips":"确定要删除该数据吗?", + "startDate":"请选择开始时间", + "endDate":"请选择结束时间" +} \ No newline at end of file diff --git a/admin/src/app/views/customer_resources/customer_resources.vue b/admin/src/app/views/customer_resources/customer_resources.vue index 9521d2a0..ed81108e 100644 --- a/admin/src/app/views/customer_resources/customer_resources.vue +++ b/admin/src/app/views/customer_resources/customer_resources.vue @@ -1,270 +1,353 @@ - - - - - + + + + + \ No newline at end of file diff --git a/admin/src/app/views/order_table/components/order-table-edit.vue b/admin/src/app/views/order_table/components/order-table-edit.vue index df702bf9..91d48266 100644 --- a/admin/src/app/views/order_table/components/order-table-edit.vue +++ b/admin/src/app/views/order_table/components/order-table-edit.vue @@ -1,343 +1,267 @@ - - - - - - + + + + + + diff --git a/admin/src/app/views/order_table/order_table.vue b/admin/src/app/views/order_table/order_table.vue index f569d1dc..8129b146 100644 --- a/admin/src/app/views/order_table/order_table.vue +++ b/admin/src/app/views/order_table/order_table.vue @@ -1,369 +1,238 @@ - - - - - + + + + + diff --git a/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php b/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php index e125a7a4..0564a1e4 100644 --- a/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php +++ b/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php @@ -29,8 +29,12 @@ class CustomerResources extends BaseAdminController public function lists(){ $data = $this->request->params([ ["name",""], + ["age",""], + ["gender",""], ["phone_number",""], - ["type","khzy"] + ["type","khzy"], + ["created_at",[]], + ["updated_at",[]], ]); return success((new CustomerResourcesService())->getPage($data)); } diff --git a/niucloud/app/adminapi/controller/order_table/OrderTable.php b/niucloud/app/adminapi/controller/order_table/OrderTable.php index a7ff3a05..567bc89f 100644 --- a/niucloud/app/adminapi/controller/order_table/OrderTable.php +++ b/niucloud/app/adminapi/controller/order_table/OrderTable.php @@ -28,19 +28,8 @@ class OrderTable extends BaseAdminController */ public function lists(){ $data = $this->request->params([ - ["payment_id",""], ["order_status",""], - ["payment_type",""], - ["order_amount",""], - ["course_id",""], - ["class_id",""], - ["staff_id",""], - ["resource_id",""], - ["after_sales_status",""], - ["after_sales_reason",""], - ["after_sales_time",""], - ["payment_time",""], - ["subscription_payment_time",""] + ["payment_type",""] ]); return success((new OrderTableService())->getPage($data)); } @@ -60,19 +49,13 @@ class OrderTable extends BaseAdminController */ public function add(){ $data = $this->request->params([ - ["payment_id",""], + ["resource_id",0], ["order_status",""], ["payment_type",""], ["order_amount",0.00], ["course_id",0], ["class_id",0], - ["staff_id",0], - ["resource_id",0], - ["after_sales_status",""], - ["after_sales_reason",""], - ["after_sales_time",1747388736], - ["payment_time",1747388736], - ["subscription_payment_time",1747388736] + ]); $this->validate($data, 'app\validate\order_table\OrderTable.add'); $id = (new OrderTableService())->add($data); @@ -86,19 +69,13 @@ class OrderTable extends BaseAdminController */ public function edit(int $id){ $data = $this->request->params([ - ["payment_id",""], + ["resource_id",0], ["order_status",""], ["payment_type",""], ["order_amount",0.00], ["course_id",0], ["class_id",0], - ["staff_id",0], - ["resource_id",0], - ["after_sales_status",""], - ["after_sales_reason",""], - ["after_sales_time",1747388736], - ["payment_time",1747388736], - ["subscription_payment_time",1747388736] + ]); $this->validate($data, 'app\validate\order_table\OrderTable.edit'); (new OrderTableService())->edit($id, $data); @@ -116,4 +93,20 @@ class OrderTable extends BaseAdminController } + public function getCustomerResourcesAll(){ + return success(( new OrderTableService())->getCustomerResourcesAll()); + } + + public function getCourseAll(){ + return success(( new OrderTableService())->getCourseAll()); + } + + public function getClassGradeAll(){ + return success(( new OrderTableService())->getClassGradeAll()); + } + + public function getPersonnelAll(){ + return success(( new OrderTableService())->getPersonnelAll()); + } + } diff --git a/niucloud/app/adminapi/route/order_table.php b/niucloud/app/adminapi/route/order_table.php index 92a20d47..831b1170 100644 --- a/niucloud/app/adminapi/route/order_table.php +++ b/niucloud/app/adminapi/route/order_table.php @@ -14,6 +14,8 @@ use think\facade\Route; use app\adminapi\middleware\AdminCheckRole; use app\adminapi\middleware\AdminCheckToken; use app\adminapi\middleware\AdminLog; + + // USER_CODE_BEGIN -- order_table Route::group('order_table', function () { @@ -29,6 +31,14 @@ Route::group('order_table', function () { //删除订单 Route::delete('order_table/:id', 'order_table.OrderTable/del'); + Route::get('customer_resources_all','order_table.OrderTable/getCustomerResourcesAll'); + + Route::get('course_all','order_table.OrderTable/getCourseAll'); + + Route::get('class_grade_all','order_table.OrderTable/getClassGradeAll'); + + Route::get('personnel_all','order_table.OrderTable/getPersonnelAll'); + })->middleware([ AdminCheckToken::class, AdminCheckRole::class, diff --git a/niucloud/app/model/class_grade/ClassGrade.php b/niucloud/app/model/class_grade/ClassGrade.php new file mode 100644 index 00000000..7df2cbcf --- /dev/null +++ b/niucloud/app/model/class_grade/ClassGrade.php @@ -0,0 +1,226 @@ +where("id", $value); + } + } + + /** + * 搜索器:班级校区ID + * @param $value + * @param $data + */ + public function searchCampusIdAttr($query, $value, $data) + { + if ($value) { + $query->where("campus_id", $value); + } + } + + /** + * 搜索器:班级校区名称 + * @param $value + * @param $data + */ + public function searchCampusNameAttr($query, $value, $data) + { + if ($value) { + $query->where("campus_name", $value); + } + } + + /** + * 搜索器:班级班级名称 + * @param $value + * @param $data + */ + public function searchClassNameAttr($query, $value, $data) + { + if ($value) { + $query->where("class_name", $value); + } + } + + /** + * 搜索器:班级班级主教练 + * @param $value + * @param $data + */ + public function searchHeadCoachAttr($query, $value, $data) + { + if ($value) { + $query->where("head_coach", $value); + } + } + + /** + * 搜索器:班级班级授课年龄段 + * @param $value + * @param $data + */ + public function searchAgeGroupAttr($query, $value, $data) + { + if ($value) { + $query->where("age_group", $value); + } + } + + /** + * 搜索器:班级班级类型 + * @param $value + * @param $data + */ + public function searchClassTypeAttr($query, $value, $data) + { + if ($value) { + $query->where("class_type", $value); + } + } + + /** + * 搜索器:班级班级助教 + * @param $value + * @param $data + */ + public function searchAssistantCoachAttr($query, $value, $data) + { + if ($value) { + $query->where("assistant_coach", $value); + } + } + + /** + * 搜索器:班级创建时间 + * @param $value + * @param $data + */ + public function searchCreatedAtAttr($query, $value, $data) + { + if ($value) { + $query->where("created_at", $value); + } + } + + /** + * 搜索器:班级修改时间 + * @param $value + * @param $data + */ + public function searchUpdatedAtAttr($query, $value, $data) + { + if ($value) { + $query->where("updated_at", $value); + } + } + + /** + * 搜索器:班级逻辑删除时间 + * @param $value + * @param $data + */ + public function searchDeletedAtAttr($query, $value, $data) + { + if ($value) { + $query->where("deleted_at", $value); + } + } + + /** + * 搜索器:班级班级状态 + * @param $value + * @param $data + */ + public function searchStatusAttr($query, $value, $data) + { + if ($value) { + $query->where("status", $value); + } + } + + /** + * 搜索器:班级班级排序 + * @param $value + * @param $data + */ + public function searchSortOrderAttr($query, $value, $data) + { + if ($value) { + $query->where("sort_order", $value); + } + } + + /** + * 搜索器:班级班级备注 + * @param $value + * @param $data + */ + public function searchRemarksAttr($query, $value, $data) + { + if ($value) { + $query->where("remarks", $value); + } + } + + + + + + +} diff --git a/niucloud/app/model/order_table/OrderTable.php b/niucloud/app/model/order_table/OrderTable.php index 8be65af4..04532570 100644 --- a/niucloud/app/model/order_table/OrderTable.php +++ b/niucloud/app/model/order_table/OrderTable.php @@ -16,6 +16,14 @@ use think\model\concern\SoftDelete; use think\model\relation\HasMany; use think\model\relation\HasOne; +use app\model\customer_resources\CustomerResources; + +use app\model\course\Course; + +use app\model\class_grade\ClassGrade; + +use app\model\personnel\Personnel; + /** * 订单模型 * Class OrderTable @@ -43,31 +51,7 @@ class OrderTable extends BaseModel /** - * 搜索器:订单订单编号 - * @param $value - * @param $data - */ - public function searchIdAttr($query, $value, $data) - { - if ($value) { - $query->where("id", $value); - } - } - - /** - * 搜索器:订单支付编号 - * @param $value - * @param $data - */ - public function searchPaymentIdAttr($query, $value, $data) - { - if ($value) { - $query->where("payment_id", $value); - } - } - - /** - * 搜索器:订单订单状态: pending-待支付, paid-已支付 + * 搜索器:订单订单状态 * @param $value * @param $data */ @@ -79,7 +63,7 @@ class OrderTable extends BaseModel } /** - * 搜索器:订单付款类型: cash-现金支付, scan_code-扫码支付, subscription-订阅支付 + * 搜索器:订单付款类型 * @param $value * @param $data */ @@ -90,129 +74,25 @@ class OrderTable extends BaseModel } } - /** - * 搜索器:订单订单金额 - * @param $value - * @param $data - */ - public function searchOrderAmountAttr($query, $value, $data) - { - if ($value) { - $query->where("order_amount", $value); - } - } - - /** - * 搜索器:订单课程ID - * @param $value - * @param $data - */ - public function searchCourseIdAttr($query, $value, $data) - { - if ($value) { - $query->where("course_id", $value); - } - } - - /** - * 搜索器:订单班级ID - * @param $value - * @param $data - */ - public function searchClassIdAttr($query, $value, $data) - { - if ($value) { - $query->where("class_id", $value); - } - } - - /** - * 搜索器:订单人员ID - * @param $value - * @param $data - */ - public function searchStaffIdAttr($query, $value, $data) - { - if ($value) { - $query->where("staff_id", $value); - } - } - - /** - * 搜索器:订单资源ID - * @param $value - * @param $data - */ - public function searchResourceIdAttr($query, $value, $data) - { - if ($value) { - $query->where("resource_id", $value); - } - } - /** - * 搜索器:订单售后状态 - * @param $value - * @param $data - */ - public function searchAfterSalesStatusAttr($query, $value, $data) - { - if ($value) { - $query->where("after_sales_status", $value); - } - } + - /** - * 搜索器:订单售后原因 - * @param $value - * @param $data - */ - public function searchAfterSalesReasonAttr($query, $value, $data) - { - if ($value) { - $query->where("after_sales_reason", $value); - } - } + - /** - * 搜索器:订单售后时间 - * @param $value - * @param $data - */ - public function searchAfterSalesTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("after_sales_time", $value); - } + public function customerResources(){ + return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']); } - - /** - * 搜索器:订单支付时间 - * @param $value - * @param $data - */ - public function searchPaymentTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("payment_time", $value); - } + + public function course(){ + return $this->hasOne(Course::class, 'id', 'course_id')->joinType('left')->withField('course_name,id')->bind(['course_id_name'=>'course_name']); } - - /** - * 搜索器:订单订阅支付生成时间 - * @param $value - * @param $data - */ - public function searchSubscriptionPaymentTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("subscription_payment_time", $value); - } + + public function classGrade(){ + return $this->hasOne(ClassGrade::class, 'id', 'class_id')->joinType('left')->withField('class_name,id')->bind(['class_id_name'=>'class_name']); } - - - + public function personnel(){ + return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']); + } - } diff --git a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php index e47c4a70..6f549033 100644 --- a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php +++ b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php @@ -42,6 +42,7 @@ class CustomerResourcesService extends BaseAdminService */ public function getPage(array $data = []) { +// dump($data);die; $field = 'a.*,b.id as shared_id'; $order = 'a.id desc'; $where = []; @@ -53,16 +54,39 @@ class CustomerResourcesService extends BaseAdminService $where[] = ['a.name','=',$data['name']]; } + if($data['age']){ + $where[] = ['a.age','=',$data['age']]; + } + + if($data['gender']){ + $where[] = ['a.gender','=',$data['gender']]; + } + if($data['type'] == 'yjfp'){ $where[] = ['b.shared_by','=',0]; } + + + + + $search_model = $this->model ->alias("a") ->join(['school_resource_sharing' => 'b'],'a.id = b.resource_id','left') ->where($where) ->with(['personnel'])->field($field)->order($order); + + if (isset($data['created_at'][0]) && isset($data['created_at'][1])) { + $search_model->whereBetweenTime('created_at', $data['created_at'][0]."00:00:00", $data['created_at'][1]."23:59:59"); + } + + if (isset($data['updated_at'][0]) && isset($data['updated_at'][1])) { + $search_model->whereBetweenTime('updated_at', $data['updated_at'][0]."00:00:00", $data['updated_at'][1]."23:59:59"); + } + + $list = $this->pageQuery($search_model); @@ -152,19 +176,19 @@ class CustomerResourcesService extends BaseAdminService public function edit(int $id, array $data) { $personnel = new Personnel(); - $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); - if(!$data['consultant']){ - return fail("操作失败"); - } +// $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); +// if(!$data['consultant']){ +// return fail("操作失败"); +// } -// $data['consultant'] = 1; + $data['consultant'] = 1; $res = $this->model->where([['id', '=', $id]])->findOrEmpty()->toArray(); $this->model->where([['id', '=', $id]])->update([ 'source' => $data['source'], 'source_channel' => $data['source_channel'], - 'consultant' => $data['consultant'], +// 'consultant' => $data['consultant'], 'name' => $data['name'], 'age' => $data['age'], 'gender' => $data['gender'], @@ -201,7 +225,7 @@ class CustomerResourcesService extends BaseAdminService if($data['purchase_power']){ $sixSpeedModificationLog = new SixSpeedModificationLog(); $six_id = $sixSpeed->where(['resource_id' => $id])->value("id"); - $data['staff_id'] = $data['consultant']; +// $data['staff_id'] = $data['consultant']; @@ -217,7 +241,7 @@ class CustomerResourcesService extends BaseAdminService 'first_visit_status' => $data['first_visit_status'], 'second_visit_status' => $data['second_visit_status'], 'is_closed' => $data['is_closed'], - 'staff_id' => $data['staff_id'], +// 'staff_id' => $data['staff_id'], 'resource_id' => $id ]; if($six_id){ diff --git a/niucloud/app/service/admin/order_table/OrderTableService.php b/niucloud/app/service/admin/order_table/OrderTableService.php index 665ce71b..82adfc4a 100644 --- a/niucloud/app/service/admin/order_table/OrderTableService.php +++ b/niucloud/app/service/admin/order_table/OrderTableService.php @@ -12,6 +12,10 @@ namespace app\service\admin\order_table; use app\model\order_table\OrderTable; +use app\model\customer_resources\CustomerResources; +use app\model\course\Course; +use app\model\class_grade\ClassGrade; +use app\model\personnel\Personnel; use core\base\BaseAdminService; @@ -36,10 +40,10 @@ class OrderTableService extends BaseAdminService */ public function getPage(array $where = []) { - $field = 'id,payment_id,order_status,payment_type,order_amount,course_id,class_id,staff_id,resource_id,after_sales_status,after_sales_reason,after_sales_time,created_at,updated_at,payment_time,subscription_payment_time'; + $field = 'id,resource_id,payment_id,order_status,payment_type,order_amount,course_id,class_id,staff_id,after_sales_status,after_sales_reason,after_sales_time,created_at,updated_at,payment_time,subscription_payment_time'; $order = 'id desc'; - $search_model = $this->model->withSearch(["id","payment_id","order_status","payment_type","order_amount","course_id","class_id","staff_id","resource_id","after_sales_status","after_sales_reason","after_sales_time","payment_time","subscription_payment_time"], $where)->field($field)->order($order); + $search_model = $this->model->withSearch(["order_status","payment_type"], $where)->with(['customerResources','course','classGrade','personnel'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } @@ -51,9 +55,9 @@ class OrderTableService extends BaseAdminService */ public function getInfo(int $id) { - $field = 'id,payment_id,order_status,payment_type,order_amount,course_id,class_id,staff_id,resource_id,after_sales_status,after_sales_reason,after_sales_time,created_at,updated_at,payment_time,subscription_payment_time'; + $field = 'id,resource_id,payment_id,order_status,payment_type,order_amount,course_id,class_id,staff_id,after_sales_status,after_sales_reason,after_sales_time,created_at,updated_at,payment_time,subscription_payment_time'; - $info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray(); + $info = $this->model->field($field)->where([['id', "=", $id]])->with(['customerResources','course','classGrade','personnel'])->findOrEmpty()->toArray(); return $info; } @@ -64,6 +68,14 @@ class OrderTableService extends BaseAdminService */ public function add(array $data) { + $personnel = new Personnel(); + $data['staff_id'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); + if(!$data['staff_id']){ + return fail("操作失败"); + } + +// $data['staff_id'] = 1; + $res = $this->model->create($data); return $res->id; @@ -94,6 +106,26 @@ class OrderTableService extends BaseAdminService return $res; } - + + public function getCustomerResourcesAll(){ + $customerResourcesModel = new CustomerResources(); + return $customerResourcesModel->select()->toArray(); + } + + public function getCourseAll(){ + $courseModel = new Course(); + return $courseModel->select()->toArray(); + } + + public function getClassGradeAll(){ + $classGradeModel = new ClassGrade(); + return $classGradeModel->select()->toArray(); + } + + public function getPersonnelAll(){ + $personnelModel = new Personnel(); + return $personnelModel->select()->toArray(); + } + } diff --git a/niucloud/app/validate/order_table/OrderTable.php b/niucloud/app/validate/order_table/OrderTable.php index 70ec8b69..e027bebf 100644 --- a/niucloud/app/validate/order_table/OrderTable.php +++ b/niucloud/app/validate/order_table/OrderTable.php @@ -20,30 +20,26 @@ class OrderTable extends BaseValidate { protected $rule = [ - 'payment_id' => 'require', + 'resource_id' => 'require', 'order_status' => 'require', 'payment_type' => 'require', 'order_amount' => 'require', 'course_id' => 'require', 'class_id' => 'require', - 'staff_id' => 'require', - 'resource_id' => 'require', ]; protected $message = [ - 'payment_id.require' => ['common_validate.require', ['payment_id']], + 'resource_id.require' => ['common_validate.require', ['resource_id']], 'order_status.require' => ['common_validate.require', ['order_status']], 'payment_type.require' => ['common_validate.require', ['payment_type']], 'order_amount.require' => ['common_validate.require', ['order_amount']], 'course_id.require' => ['common_validate.require', ['course_id']], 'class_id.require' => ['common_validate.require', ['class_id']], - 'staff_id.require' => ['common_validate.require', ['staff_id']], - 'resource_id.require' => ['common_validate.require', ['resource_id']], ]; protected $scene = [ - "add" => ['payment_id', 'order_status', 'payment_type', 'order_amount', 'course_id', 'class_id', 'staff_id', 'resource_id', 'after_sales_status', 'after_sales_reason', 'after_sales_time', 'payment_time', 'subscription_payment_time'], - "edit" => ['payment_id', 'order_status', 'payment_type', 'order_amount', 'course_id', 'class_id', 'staff_id', 'resource_id', 'after_sales_status', 'after_sales_reason', 'after_sales_time', 'payment_time', 'subscription_payment_time'] + "add" => ['resource_id', 'order_status', 'payment_type', 'order_amount', 'course_id', 'class_id'], + "edit" => ['resource_id', 'order_status', 'payment_type', 'order_amount', 'course_id', 'class_id'] ]; }