1,员工端接口:订单列表,订单详情,订单数量统计

2,对接支付接口,支付已调通
3,课时预约单预下单计算
4,课时预约单订单创建
5,课时预约单更改课时规格
This commit is contained in:
15090180611 2024-11-11 18:42:55 +08:00
parent 8c91a1e794
commit 50d6e7a296
15 changed files with 1196 additions and 73 deletions

View File

@ -2,11 +2,10 @@
namespace app\api\controller\school;
use app\common\model\school\classes\order\Order as OrderModel;
use app\common\model\school\classes\Teacher as Teachermodel;
use app\common\model\school\classes\hourorder\Order as OrderModel;
/**
* 课时订单接口
* 课时预约订单接口
*/
class HourOrder extends Base
{
@ -15,6 +14,7 @@ class HourOrder extends Base
protected $model = null;
/**
* 初始化操作
* @access protected
@ -30,9 +30,9 @@ class HourOrder extends Base
/**
* @ApiTitle( 订单详情)
* @ApiSummary(订单详情)
* @ApiRoute(/api/school/order/detail)
* @ApiTitle( 课时订单详情)
* @ApiSummary(课时订单详情)
* @ApiRoute(/api/school/hour_order/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
* @ApiReturn({
@ -60,63 +60,72 @@ class HourOrder extends Base
/**
* @ApiTitle( 订单确认/订单计算接口)
* @ApiSummary(订单确认/订单计算接口【有过期时间】)
* @ApiRoute(/api/school/order/confirm)
* @ApiMethod(POST)
* @ApiParams(name = "classes_lib_id", type = "int",required=true,description = "订单id或订单号")
* @ApiParams(name = "order_no", type = "string",required=false,description = "缓存key")
* @ApiParams(name = "is_compute", type = "int",required=false,description = "是否重新计算并更新缓存 默认传1")
* @ApiTitle( 我的课时订单列表接口)
* @ApiSummary(我的课时订单列表接口)
* @ApiRoute(/api/school/hour_order/order_list)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function confirm(){
public function order_list()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$classes_lib_id = $this->request->post('classes_lib_id/d', 0); //课程id
// $param = urldecode($this->request->post('param/s', "{}")); //参数
$param = []; //参数
$order_no = $this->request->post('order_no/s', ''); //订单号
$is_compute = $this->request->post('is_compute/d', 1); //是否重新计算并更新缓存
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model->confirm($user_id, $classes_lib_id,$order_no,$param, $is_compute);
$res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_order_id,$classes_lib_ids);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
$this->error($e->getMessage());
}
$this->success('执行成功可用缓存key下单', $res);
$this->success('查询成功', $res);
}
/**
* @ApiTitle( 订单下单接口)
* @ApiSummary(订单下单接口)
* @ApiRoute(/api/school/order/create)
* @ApiMethod(POST)
* @ApiParams(name = "order_no", type = "string",required=true,description = "缓存key")
* @ApiTitle( 我的课时订单数量接口)
* @ApiSummary(返回课时订单各个数量)
* @ApiRoute(/api/school/hour_order/order_count)
* @ApiMethod(GET)
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function create(){
public function order_count(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$order_no = $this->request->post('order_no/s', ''); //订单号
$remark = $this->request->post('remark/s', ''); //下单备注
// repeat_filter("appointment\order\create".$user_id, 2);
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
try{
//当前申请状态
$res = $this->model->cacheCreateOrder($order_no,$user_id,$remark,true);
$res = $this->model::orderCount($user_id,$classes_order_id,$classes_lib_ids);
}catch (\Throwable $e){
// file_put_contents("test.txt",$e->getMessage().$e->getFile().$e->getLine());//写入文件,一般做正式环境测试
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);;
$this->error($e->getMessage());
}
$this->success('订单创建成功缓存key被消耗', $res);
$this->success('查询成功', $res);
}
}

View File

@ -64,7 +64,7 @@ class Order extends Base
* @ApiSummary(订单确认/订单计算接口【有过期时间】)
* @ApiRoute(/api/school/order/confirm)
* @ApiMethod(POST)
* @ApiParams(name = "classes_lib_id", type = "int",required=true,description = "订单id或订单号")
* @ApiParams(name = "classes_lib_id", type = "int",required=true,description = "课程id")
* @ApiParams(name = "order_no", type = "string",required=false,description = "缓存key")
* @ApiParams(name = "is_compute", type = "int",required=false,description = "是否重新计算并更新缓存 默认传1")
* @ApiReturn({
@ -119,5 +119,74 @@ class Order extends Base
$this->success('订单创建成功缓存key被消耗', $res);
}
/**
* @ApiTitle( 我的订单列表接口)
* @ApiSummary(我的订单列表接口)
* @ApiRoute(/api/school/order/order_list)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "状态搜索条件:-3=已取消,0=待支付,3=使用中,6=已退款,9=已完成")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_list()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$classes_lib_id);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
/**
* @ApiTitle( 我的订单数量接口)
* @ApiSummary(返回订单各个数量)
* @ApiRoute(/api/school/order/order_count)
* @ApiMethod(GET)
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_count(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字
try{
$res = $this->model::orderCount($user_id,$classes_lib_id);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}

View File

@ -108,7 +108,9 @@ class Pay extends Base
$response = Service::submitOrder($amount, $out_trade_no, $type, $title, $notifyurl, $returnurl, $method, $openid);
return $response;
$this->success('查询成功', ["paydata"=>$response]);
// return $response;
}
/**
@ -208,7 +210,7 @@ class Pay extends Base
'platform' => $platform,
];
$this->model->paySuccess($order['order_sn'],$notify,$pay_fee,true,true);
$this->model->paySuccess($order['order_no'],$notify,$pay_fee,true,true);

View File

@ -3,10 +3,15 @@
namespace app\api\controller\school\worker;
use app\common\controller\Api;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\Teacher;
use app\common\model\school\classes\Verification;
class Base extends Api
{
protected $classes_lib_ids = [];
/**
* 初始化操作
* @access protected
@ -14,9 +19,20 @@ class Base extends Api
protected function _initialize()
{
parent::_initialize();
// 判断员工权限
$this->check_worker_auth();
}
protected function check_worker_auth(){
//判断登录用户是否是员工
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
if(!$user_id)$this->error("请登录后再访问该接口!",['errcode'=>30002], 401);
$this->classes_lib_ids = (new ClassesLib)->getClassesAuthIds($user_id);
//如果没有任何可管理的classes_lib_id 则返回错误
if(!$this->classes_lib_ids)$this->error("您没有员工权限访问该接口!",['errcode'=>30003]);
}

View File

@ -0,0 +1,129 @@
<?php
namespace app\api\controller\school\worker;
use app\common\model\school\classes\hourorder\Order as OrderModel;
/**
* 员工端:课时订单管理接口
*/
class HourOrder extends Base
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new OrderModel;
parent::_initialize();
//判断登录用户是否是员工
}
/**
* @ApiTitle( 课时订单详情)
* @ApiSummary(课时订单详情)
* @ApiRoute(/api/school/worker/hour_order/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
* @ApiReturn({
*
*})
*/
public function detail(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = OrderModel::getDetail($id,$this->classes_lib_ids);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/**
* @ApiTitle( 我的课时订单列表接口)
* @ApiSummary(我的课时订单列表接口)
* @ApiRoute(/api/school/worker/hour_order/order_list)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
* @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_list()
{
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
/**
* @ApiTitle( 课时订单数量接口)
* @ApiSummary(课时订单各个数量)
* @ApiRoute(/api/school/worker/hour_order/order_count)
* @ApiMethod(GET)
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_count(){
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
try{
$res = $this->model::workCount($this->classes_lib_ids,$classes_lib_ids,$classes_order_id);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}

View File

@ -0,0 +1,129 @@
<?php
namespace app\api\controller\school\worker;
use app\common\model\school\classes\order\Order as OrderModel;
use app\common\model\school\classes\Teacher as Teachermodel;
/**
* 员工端:课程订单管理接口
*/
class Order extends Base
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new OrderModel;
parent::_initialize();
//判断登录用户是否是员工
}
/**
* @ApiTitle( 订单详情)
* @ApiSummary(订单详情)
* @ApiRoute(/api/school/order/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
* @ApiReturn({
*
*})
*/
public function detail(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = OrderModel::getDetail($id,$this->classes_lib_ids);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/**
* @ApiTitle( 我的订单列表接口)
* @ApiSummary(我的订单列表接口)
* @ApiRoute(/api/school/order/order_list)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "状态搜索条件:-3=已取消,0=待支付,3=使用中,6=已退款,9=已完成")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_list()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::workList($user_id,$page, $limit,$keywords,$status,$classes_lib_id,$this->classes_lib_ids);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
/**
* @ApiTitle( 我的订单数量接口)
* @ApiSummary(返回订单各个数量)
* @ApiRoute(/api/school/order/order_count)
* @ApiMethod(GET)
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_count(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$classes_lib_id = $this->request->get('classes_lib_id/s', ''); //搜索关键字
try{
$res = $this->model::workCount($classes_lib_id,$this->classes_lib_ids);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}

View File

@ -119,7 +119,7 @@ class Api
$this->auth->init($token);
//检测是否登录
if (!$this->auth->isLogin()) {
$this->error(__('Please login first'), null, 401);
$this->error(__('Please login first'), ['errcode'=>30002], 401);
}
// 判断是否需要验证权限
if (!$this->auth->match($this->noNeedRight)) {

View File

@ -0,0 +1,34 @@
<?php
namespace app\common\listener\classeshourorder;
class OrderHook
{
// 订单创建成功前(订单计算)
public function classeshourOrderCreateBefore(&$params)
{
}
// 订单创建成功后
public function classeshourOrderCreateAfter(&$params)
{
}
// // 订单支付成功后
// public function classeshourOrderPayedAfter(&$params)
// {
//
// }
// 订单取消成功后
public function classeshourOrderCancelAfter(&$params)
{
}
}

View File

@ -33,7 +33,14 @@ class BaseModel extends Model
$tableFields = (new static)->getTableFields();
foreach ($tableFields as $fields)
{
if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
if (isset($whereData[$fields]) && $whereData[$fields]){
if(is_array($whereData[$fields])){
$model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
}else{
$model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
}
}
}
return $model;
}

View File

@ -2,12 +2,14 @@
namespace app\common\model\school\classes;
use app\common\model\BaseModel;
use app\common\model\dyqc\ManystoreShop;
use app\common\model\User;
use think\Model;
use traits\model\SoftDelete;
class ClassesLib extends Model
class ClassesLib extends BaseModel
{
use SoftDelete;
@ -25,6 +27,8 @@ class ClassesLib extends Model
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected $classes_lib_ids = [];
// 追加属性
protected $append = [
'add_type_text',
@ -350,4 +354,33 @@ class ClassesLib extends Model
return $spec_data;
}
/** 管理的课程ids
* @param $user_id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getClassesAuthIds($user_id){
$classes_lib_ids = Verification::where("user_id",$user_id)->where("status",'1')->column("classes_lib_ids");
if($classes_lib_ids){
//遍历课程ids
foreach ($classes_lib_ids as $classes_lib_id){
$classes_lib_id_arr = explode(",",$classes_lib_id)?:[];
foreach ($classes_lib_id_arr as $v){
$this->classes_lib_ids[] = $v;
}
}
}
//判断是否有老师身份
$teacher = Teacher::where("user_id",$user_id)->find();
if($teacher){
$lib_ids = ClassesLib::where("teacher_id",$teacher['id'])->column('id');
$this->classes_lib_ids = array_merge($this->classes_lib_ids,$lib_ids);
}
$this->classes_lib_ids = array_unique($this->classes_lib_ids);
return $this->classes_lib_ids;
}
}

View File

@ -2,10 +2,16 @@
namespace app\common\model\school\classes\hourorder;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\ClassesSpec;
use app\common\model\User;
use bw\Common;
use fast\Random;
use think\Cache;
use think\Model;
use traits\model\SoftDelete;
class Order extends Model
use app\common\model\BaseModel;
class Order extends BaseModel
{
use SoftDelete;
@ -111,30 +117,536 @@ class Order extends Model
public function classesorder()
{
return $this->belongsTo('app\admin\model\school\classes\Order', 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\common\model\school\classes\order\Order', 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function spec()
{
return $this->belongsTo('app\admin\model\school\classes\lib\Spec', 'classes_lib_spec_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\common\model\school\classes\ClassesSpec', 'classes_lib_spec_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function detail()
{
return $this->belongsTo('app\admin\model\school\classes\order\Detail', 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\common\model\school\classes\order\OrderDetail', 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function lib()
{
return $this->belongsTo('app\admin\model\school\classes\Lib', 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo(ClassesLib::class, 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
/**得到基础条件
* @param $status
* @param null $model
* @param string $alisa
*/
public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
{
if (!$model) {
$model = new static;
if ($alisa&&!$with) $model = $model->alias($alisa);
}
if ($alisa) $alisa = $alisa . '.';
$tableFields = (new static)->getTableFields();
foreach ($tableFields as $fields)
{
if(in_array($fields, ['status','classes_lib_id']))continue;
// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
if (isset($whereData[$fields]) && $whereData[$fields]){
if(is_array($whereData[$fields])){
$model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
}else{
$model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
}
}
}
if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}id", '=', $whereData['keywords']);
if (isset($whereData['time'])&&$whereData['time']){
$model = $model->time($whereData['time']);
}
if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']);
if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']);
if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']);
return $model;
}
/**展示订单信息
* @param $order_no
* @param $price_info
* @return array
*/
public static function showInfo($order_no, $price_info = []){
$data = [];
$data['order_no'] =$order_no;
$data['order_info'] = self::getDetail($order_no);
return array_merge($data,$price_info);
}
/**得到订单详情
* @param $order_no
*/
public static function getDetail($order_no,$classes_lib_id = [],$classes_lib_ids = []){
$model = self::where('order_no|id',$order_no);
if($classes_lib_id)$model = $model->where("classes_lib_id","in",$classes_lib_id);
if($classes_lib_ids)$model = $model->where("classes_lib_id","in",$classes_lib_ids);
$data = $model->find();
if(!$data) return $data;
//加载订单详情
$data->detail->teacher;
//订单用户
$data->user->visible(['id','nickname','mobile','avatar','realname']);
//订单机构
$data->classesorder;
// //得到二维码
// $data->code_url = Common::getQrcode([
// 'text' => $data['code'],
// 'size' => 200,
// ]);
// $data->one_code_url = Common::getBarcode([
// 'text' => $data['code'],
// 'size' => 200,
// ]);
return $data;
}
public static function allList($user_id,$page, $limit,$keywords,$status,$classes_order_id=0,$classes_lib_id = []){
$with_field = [
'user'=>['nickname','mobile','avatar','realname'],
'base'=>['*'],
'classesorder'=>['*'],
'detail'=>['*'],
];
$CANCEL = '-3';
$NOAUDIT = '-1';
$HAVE = '0';
$FINISH = '3';
$alisa = (new self)->getWithAlisaName();
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,'classes_lib_id'=>$classes_lib_id];
// if($type)$serch_where['type'] = $type;
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
}
public static function baseCount($where = []){
$CANCEL = '-3';
$NOAUDIT = '-1';
$HAVE = '0';
$FINISH = '3';
$cancel_number = self::getBaseWhere(array_merge(['status'=>$CANCEL],$where))->count();
$noaudit_number = self::getBaseWhere(array_merge(['status'=>$NOAUDIT],$where))->count();
$have_number = self::getBaseWhere(array_merge(['status'=>$HAVE],$where))->count();
$finish_number = self::getBaseWhere(array_merge(['status'=>$FINISH],$where))->count();
return compact('cancel_number','noaudit_number','have_number','finish_number');
}
/**订单数量统计
* @param int $user_id
* @return array
*/
public static function orderCount($user_id = 0,$classes_order_id=0,$classes_lib_id=[]){
return self::baseCount(['user_id'=>$user_id,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id]);
}
public static function workList($page, $limit,$keywords,$status,$classes_order_id=0,$user_id=0,$classes_lib_id = [],$classes_lib_ids = []){
$with_field = [
'user'=>['nickname','mobile','avatar','realname'],
'base'=>['*'],
'classesorder'=>['*'],
'detail'=>['*'],
];
$CANCEL = '-3';
$NOAUDIT = '-1';
$HAVE = '0';
$FINISH = '3';
$alisa = (new self)->getWithAlisaName();
$sort = "field({$alisa}.status,'{$NOAUDIT}','{$HAVE}','{$FINISH}','{$CANCEL}') asc,{$alisa}.id desc";
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,'classes_order_id'=>$classes_order_id,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids];
// if($type)$serch_where['type'] = $type;
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
}
/**订单数量统计
* @param int $user_id
* @return array
*/
public static function workCount($classes_lib_id = [],$classes_lib_ids = [],$classes_order_id=0){
return self::baseCount(['classes_lib_id'=>$classes_lib_id,'classes_order_id'=>$classes_order_id,"classes_lib_ids"=>$classes_lib_ids]);
}
/**
* 设置订单缓存
* @param $uid
* @param $data
* @return bool
*/
public static function setOrderCache($uid, $data)
{
//缓存名 = uid + order_no
$cacheNmae = 'classes_hourorder_cache' . $uid . $data['order_no'];
// 缓存在3600秒之后过期
return Cache::set($cacheNmae, $data, config("site.unpaid_order_expire_time"));
}
/**
* 得到订单缓存
* @param $uid
* @param $order_no
* @return mixed
*/
public static function getOrderCache($uid, $order_no)
{
//缓存名 = uid + order_no
$cacheNmae = 'classes_hourorder_cache' . $uid . $order_no;
// 缓存在3600秒之后过期
return Cache::get($cacheNmae);
}
/**
* 删除订单缓存
* @param $uid
* @param $order_no
* @return mixed
*/
public static function deleteOrderCache($uid, $order_no)
{
//缓存名 = uid + order_no
$cacheNmae = 'classes_hourorder_cache' . $uid . $order_no;
// 缓存在3600秒之后过期
return Cache::rm($cacheNmae);
}
/** 订单确认(订单计算)
* @param $user_id 下单用户
* @param $order_no 订单号(缓存标识)
* @param $classes_order_id 課程订单id
* @param $classes_lib_spec_id 課程课时规格id
* @param $param 額外参数(扩展用)
* @param bool $is_compute 是否重新计算订单
* @return array
*/
public function confirm($user_id, $classes_order_id,$order_no,$classes_lib_spec_id=0,$param=[], $is_compute = false)
{
if ($order_no && !$is_compute) {
//得到缓存
$data = self::getOrderCache($user_id, $order_no);
if (!$data) throw new \Exception('請您完善預約信息!');
$price_info = $data['price_info'];
} else {
//订单信息计算
// if(!$param) throw new \Exception('缺少必要信息');
$this->orderVaild($user_id,$classes_order_id,$order_no,$classes_lib_spec_id, $param);
//订单支付信息
$price_info = $this->getCost($user_id,$classes_order_id,$classes_lib_spec_id,$param);
//生成订单号
if (!$order_no) $order_no = get_order_sn();
//生成缓存
$data = compact('user_id', 'classes_order_id','param', 'order_no', 'price_info','classes_lib_spec_id');
self::setOrderCache($user_id, $data);
}
\think\Hook::listen('classeshour_order_create_before', $data);
//下单数据展示
return $this->showInfo($order_no, $price_info);
}
/**订单校验
* @param $user_id 用户id
* @param $classes_order_id 课程订单id
* @param $order_no 订单号
* @param $param 表单扩展参数
* @return bool
*/
public function orderVaild($user_id,$classes_order_id,$order_no,$classes_lib_spec_id, $param,$check=false){
if(!$user_id||!$classes_order_id)throw new \Exception("缺少必要参数");
//默认校验订单是否已创建
if($check){
//判断订单是否已创建
$order_info = self::where(['order_no'=>$order_no])->find();
if($order_info) throw new \Exception("订单已生成,如需重新下单请退出页面重新进入!");
if(!$classes_lib_spec_id)throw new \Exception("请选择您要预约的课时信息!");
}
//校验订单参数
//课程是否存在并上架
$classesOrder = \app\common\model\school\classes\order\Order::where("id",$classes_order_id)
->where("user_id",$user_id)
->find();
if(!$classesOrder){
throw new \Exception("课程不存在!");
}
$detail = $classesOrder->detail;
if(!$detail)throw new \Exception("课程不存在!");
//是否还有次数
if($detail['sub_num']<=0) throw new \Exception("该课程已无剩余课时!");
//不是可用状态
if($classesOrder['status']!="3") throw new \Exception("该课程单当前状态不可操作!");
//售后中
if($classesOrder['server_status']=="3") throw new \Exception("该课程单正在售后中,请勿操作!");
//判断课时信息
if($classes_lib_spec_id){
$classes_lib_spec_info = ClassesSpec::where('id',$classes_lib_spec_id)
->where('classes_lib_id',$detail["classes_lib_id"])
->find();
if(!$classes_lib_spec_info)throw new \Exception("课时信息不正确!");
//课时已下架
if($classes_lib_spec_info['status']!='1') throw new \Exception("该课时已下架,请选择其他课时!");
}
// $classes_lib_info = ClassesLib::where('id',$classesOrder["classes_lib_id"])->find();
// if(!$classes_lib_info || $classes_lib_info['status']!='1') throw new \Exception("该课程不存在或已下架!");
//用户存不存在
$user_info = User::where('id',$user_id)->find();
if(!$user_info) throw new \Exception("用户不存在!");
return true;
}
//计算订单所需返回数据接口
public static function getCost($user_id,$classes_order_id,$classes_lib_spec_id,$param=[],$other_params=[],$check = false){
//校验订单参数
//课程是否存在并上架
$classesOrder = \app\common\model\school\classes\order\Order::where("id",$classes_order_id)
->where("user_id",$user_id)
->find();
$detail = $classesOrder->detail;
$classes_lib_info = $detail;
$classes_lib_spec_info = null;
//判断课时信息
if($classes_lib_spec_id){
$classes_lib_spec_info = ClassesSpec::where('id',$classes_lib_spec_id)
->where('classes_lib_id',$detail["classes_lib_id"])
->find();
if($classes_lib_spec_info){
$classes_lib_spec_info = $classes_lib_spec_info->toArray();
}
}
//用户
$user_info = User::get($user_id);
$user_data = [
"nickname"=>$user_info["nickname"],
"realname"=>$user_info["realname"],
"avatar"=>$user_info["avatar"],
"mobile"=>$user_info["mobile"],
"money" =>$user_info["money"],
"score" =>$user_info["score"],
];
//组装订单下单数据
$order_data = [];
$order_data["user_id"] = $user_id;
$order_data["classes_order_id"] = $classes_order_id;
$order_data["classes_lib_spec_id"] = $classes_lib_spec_id;
$order_data["classes_order_detail_id"] = $detail["id"];
$order_data["classes_lib_id"] = $detail["classes_lib_id"];
$order_data["status"] = '-1';
$order_data["verification_user_id"] = 0;
$order_data["reservation_time"] = time();
$order_data["type"] = '1';
$order_data["reason"] = '';
$order_data["auth_status"] = '0';
return compact('order_data','classes_lib_info','user_data','classes_lib_spec_info');
}
/**
* 根据缓存创建订单
*/
public function cacheCreateOrder($order_no, $user_id,$remark="", $trans = false)
{
//得到缓存
$orderInfo = self::getOrderCache($user_id, $order_no); //得到下单信息
if (!$orderInfo) throw new \Exception('請您完善預約信息!');
if ($trans) {
self::beginTrans();
}
try {
//1订单执行创建
$this->createOrder($user_id,$orderInfo['classes_order_id'],$orderInfo['classes_lib_spec_id'],$order_no,$orderInfo['param'],$remark);
//5删除缓存
self::deleteOrderCache($user_id, $order_no);
if ($trans) {
self::commitTrans();
}
} catch (\Exception $e) {
if ($trans) {
self::rollbackTrans();
}
throw new \Exception($e->getMessage());
}
return self::showInfo($order_no);
}
/**得到可核销的订单
* @param $order_no
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getNoVerificationOrder($order_no){
$order = self::where('order_no|id',$order_no)->where("status","in",['0'])->find();
if(!$order)throw new \Exception("待核销订单不存在");
return $order;
}
/**得到可更新课时的订单
* @param $order_no
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getHaveUpdateOrder($order_no){
$order = self::where('order_no|id',$order_no)->where("status","in",['0','-1'])->find();
if(!$order)throw new \Exception("可更新课时订单不存在");
return $order;
}
//生成或更新课时
public static function buildLibSpec($order,$classes_lib_spec){
if(is_string($order)||is_numeric($order))$order = self::getHaveUpdateOrder($order);
if(is_string($classes_lib_spec)||is_numeric($classes_lib_spec))$classes_lib_spec = ClassesSpec::where('id',$classes_lib_spec)->where('classes_lib_id',$order["classes_lib_id"])->find();
if(!$classes_lib_spec)throw new \Exception("课时信息不正确!");
$classes_lib_spec_data = $classes_lib_spec->toArray();
$classes_lib_spec_data['classes_lib_spec_id'] = $classes_lib_spec_data['id'];
unset($classes_lib_spec_data['id']);
unset($classes_lib_spec_data['createtime']);
unset($classes_lib_spec_data['updatetime']);
unset($classes_lib_spec_data['deletetime']);
$order_detail_data = $order->toArray();
$order_detail_data = array_merge($order_detail_data,$classes_lib_spec_data);
$order->allowField(true)->save($order_detail_data);
return $order;
}
public function createOrder($user_id,$classes_order_id,$classes_lib_spec_id,$order_no,$param,$remark='',$other_params=[]){
$this->orderVaild($user_id,$classes_order_id, $order_no, $classes_lib_spec_id, $param,true);
//订单支付信息
$order_info = self::getCost($user_id,$classes_order_id,$classes_lib_spec_id,$param,$other_params,true);
//组装订单数据
$order_data = $order_info['order_data'];
$order_data["order_no"] = $order_no;
//课时数据
$classes_lib_spec_info = $order_info['classes_lib_spec_info'];
$res1 = self::create($order_data);
if (!$res1) throw new \Exception('创建订单失败');
//课时规格更新
$order = self::buildLibSpec($res1,$classes_lib_spec_id);
//扣减课程数
//记录订单日志
OrderLog::log($res1['id'],"课时预约下单成功,等待机构老师审核",'user',$user_id);
//7事件
$data = ['order' => $res1];
\think\Hook::listen('classeshour_order_create_after', $data);
return $res1;
}
}

View File

@ -3,9 +3,9 @@
namespace app\common\model\school\classes\hourorder;
use think\Model;
use app\common\model\BaseModel;
class OrderLog extends Model
class OrderLog extends BaseModel
{
@ -48,6 +48,48 @@ class OrderLog extends Model
public function order()
{
return $this->belongsTo('app\admin\model\school\classes\hour\Order', 'classes_hour_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo(Order::class, 'classes_hour_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
/**记录订单日志
* @param $params
* @param bool $trans
* @throws \Exception
*/
public static function log($order,$mark='更新订单状态',$oper_type='user',$oper_id = 0,$trans=false){
if(is_numeric($order))$order = Order::where('order_no|id',$order)->find();
if(!$order)throw new \Exception("找不到订单");
//操作人信息(可扩展)
$data = [
'oper_type'=>$oper_type ?: 'user',
'oper_id'=>$oper_id ?: $order['user_id'],
'remark'=>$mark,
];
//判断逻辑
if($trans){
self::beginTrans();
}
$res = true;
try{
//事务逻辑
$log_data = $order->toArray();
$log_data["classes_hour_order_id"] = $order['id'];
unset($log_data['id']);
unset($log_data['createtime']);
if($mark)$log_data['log_text'] = $mark;
$log = (new self);
$log->allowField(true)->save($log_data);
if($trans){
self::commitTrans();
}
}catch (\Exception $e){
if($trans){
self::rollbackTrans();
}
throw new \Exception($e->getMessage());
}
return $log;
}
}

View File

@ -269,13 +269,17 @@ class Order extends BaseModel
/**得到订单详情
* @param $order_no
*/
public static function getDetail($order_no){
$data = self::where('order_no|id|pay_no',$order_no)->find();
public static function getDetail($order_no,$classes_lib_id = []){
$model = self::where('order_no|id|pay_no|code',$order_no);
if($classes_lib_id)$model = $model->where("classes_lib_id","in",$classes_lib_id);
$data = $model->find();
if(!$data) return $data;
//加载订单详情
$data->detail->teacher;
//订单用户
$data->user;
// $data->user;
$data->user->visible(['id','nickname','mobile','avatar','realname']);
//订单机构
$data->shop;
// //得到二维码
@ -314,7 +318,7 @@ class Order extends BaseModel
$price_info = $data['price_info'];
} else {
//订单信息计算
if(!$param) throw new \Exception('缺少必要信息');
// if(!$param) throw new \Exception('缺少必要信息');
$this->orderVaild($user_id,$classes_lib_id,$order_no, $param);
//订单支付信息
$price_info = $this->getCost($user_id,$classes_lib_id,$param);
@ -417,21 +421,21 @@ class Order extends BaseModel
* @return bool
*/
public function orderVaild($user_id,$classes_lib_id, $order_no, $param,$check=false){
if(!$user_id ||!$param )throw new \Exception("缺少必要参数");
if(!$user_id||!$classes_lib_id )throw new \Exception("缺少必要参数");
//默认校验订单是否已创建
if($check){
//判断订单是否已创建
$order_info = self::where(['order_no'=>$order_no]);
$order_info = self::where(['order_no'=>$order_no])->find();
if($order_info) throw new \Exception("订单已生成,如需重新下单请退出页面重新进入!");
}
//校验订单参数
//课程是否存在并上架
$classes_lib_info = ClassesLib::where('classes_lib_id',$classes_lib_id);
$classes_lib_info = ClassesLib::where('id',$classes_lib_id)->find();
if(!$classes_lib_info || $classes_lib_info['status']!='1') throw new \Exception("该课程不存在或已下架!");
//用户存不存在
$user_info = User::where('user_id',$user_id)->find();
$user_info = User::where('id',$user_id)->find();
if(!$user_info) throw new \Exception("用户不存在!");
return true;
@ -486,7 +490,7 @@ class Order extends BaseModel
* @throws \think\exception\DbException
*/
public static function getNopayOrder($order_no){
$order = self::where('order_no|id|pay_no',$order_no)->where("status",'0')->find();
$order = self::where('order_no|id|pay_no|code',$order_no)->where("status",'0')->find();
if(!$order)throw new \Exception("待支付订单不存在");
return $order;
}
@ -660,7 +664,7 @@ class Order extends BaseModel
$order->pay_json = $notify['payment_json'] ?? '{}';
$order->pay_type = $notify['pay_type'] ?? 'yue';
//如果订单创建时间大于预约时间,则等于预约时间
if($order['createtime']>$order['starttime'])$order['createtime'] = $order['starttime'];
// if($order['createtime']>$order['starttime'])$order['createtime'] = $order['starttime'];
switch ($order->pay_type) {
case "offline": //线下付款,线上不需要支付
@ -691,15 +695,15 @@ class Order extends BaseModel
$params = http_build_query($params);
//生成二维码和一维码
//二维码
$order->codeimage = Common::getQrcode([
$order->codeimage = (Common::getQrcode([
'text' => $params,
'size' => 200,
]);
]))['url'];
//一维码
$order->codeoneimage = Common::getBarcode([
$order->codeoneimage = (Common::getBarcode([
'text' => $params,
'size' => 200,
]);
]))['url'];
$order->save();
return $order;
}
@ -707,6 +711,142 @@ class Order extends BaseModel
/**得到基础条件
* @param $status
* @param null $model
* @param string $alisa
*/
public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
{
if (!$model) {
$model = new static;
if ($alisa&&!$with) $model = $model->alias($alisa);
}
if ($alisa) $alisa = $alisa . '.';
$tableFields = (new static)->getTableFields();
foreach ($tableFields as $fields)
{
if(in_array($fields, ['status','classes_lib_id']))continue;
// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
if (isset($whereData[$fields]) && $whereData[$fields]){
if(is_array($whereData[$fields])){
$model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
}else{
$model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
}
}
}
if (isset($whereData['status'])) $model = $model->where("{$alisa}status", 'in', $whereData['status']);
if (isset($whereData['not_status'])) $model = $model->where("{$alisa}status", 'not in', $whereData['not_status']);
if (isset($whereData['keywords'])&&$whereData['keywords']) $model = $model->where("{$alisa}order_no|{$alisa}pay_no|{$alisa}code", '=', $whereData['keywords']);
if (isset($whereData['time'])&&$whereData['time']){
$model = $model->time($whereData['time']);
}
if (isset($whereData['user_id']) && $whereData['user_id']) $model = $model->where("{$alisa}user_id", '=', $whereData['user_id']);
if (isset($whereData['classes_lib_ids']) && $whereData['classes_lib_ids']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_ids']);
if (isset($whereData['classes_lib_id']) && $whereData['classes_lib_id']) $model = $model->where("{$alisa}classes_lib_id", 'in', $whereData['classes_lib_id']);
return $model;
}
public static function allList($user_id,$page, $limit,$keywords,$status,$classes_lib_id=[]){
$with_field = [
'user'=>['nickname','mobile','avatar','realname'],
'base'=>['*'],
'shop'=>['*'],
'detail'=>['*'],
];
$CANCEL = '-3';
$NOPAY = '0';
$PAYED = '3';
$REFUND = '6';
$FINISH = '9';
$alisa = (new self)->getWithAlisaName();
$sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$FINISH}','{$REFUND}','{$CANCEL}') asc,{$alisa}.id desc";
$serch_where = ['status'=>$status,'user_id'=>$user_id,'keywords'=>$keywords,"classes_lib_id"=>$classes_lib_id];
// if($type)$serch_where['type'] = $type;
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
}
public static function baseCount($where = []){
$CANCEL = '-3';
$NOPAY = '0';
$PAYED = '3';
$REFUND = '6';
$FINISH = '9';
$cancel_number = self::getBaseWhere(array_merge(['status'=>$CANCEL],$where))->count();
$nopay_number = self::getBaseWhere(array_merge(['status'=>$NOPAY],$where))->count();
$payed_number = self::getBaseWhere(array_merge(['status'=>$PAYED],$where))->count();
$retund_number = self::getBaseWhere(array_merge(['status'=>$REFUND],$where))->count();
$finish_number = self::getBaseWhere(array_merge(['status'=>$FINISH],$where))->count();
return compact('cancel_number','nopay_number','payed_number','retund_number','finish_number');
}
/**订单数量统计
* @param int $user_id
* @return array
*/
public static function orderCount($user_id = 0,$classes_lib_id=[]){
return self::baseCount(['user_id'=>$user_id,"classes_lib_id"=>$classes_lib_id]);
}
public static function workList($page, $limit,$keywords,$status,$classes_lib_id=[],$classes_lib_ids=[]){
$with_field = [
'user'=>['nickname','mobile','avatar','realname'],
'base'=>['*'],
'shop'=>['*'],
'detail'=>['*'],
];
$CANCEL = '-3';
$NOPAY = '0';
$PAYED = '3';
$REFUND = '6';
$FINISH = '9';
$alisa = (new self)->getWithAlisaName();
$sort = "field({$alisa}.status,'{$NOPAY}','{$PAYED}','{$FINISH}','{$REFUND}','{$CANCEL}') asc,{$alisa}.id desc";
$serch_where = ['status'=>$status,'keywords'=>$keywords,"classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids];
// if($type)$serch_where['type'] = $type;
return (new self)->getBaseList($serch_where, $page, $limit,$sort,$with_field);
}
/**订单数量统计
* @param int $user_id
* @return array
*/
public static function workCount($classes_lib_id=[],$classes_lib_ids=[]){
return self::baseCount(["classes_lib_id"=>$classes_lib_id,"classes_lib_ids"=>$classes_lib_ids]);
}
}

View File

@ -95,7 +95,7 @@ class OrderDetail extends Model
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function teacher()

View File

@ -2,10 +2,11 @@
namespace app\common\model\school\classes\order;
use app\common\model\BaseModel;
use think\Model;
class OrderLog extends Model
class OrderLog extends BaseModel
{
@ -90,7 +91,7 @@ class OrderLog extends Model
public function order()
{
return $this->belongsTo('app\admin\model\school\classes\Order', 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}