25 changed files with 894 additions and 300 deletions
@ -0,0 +1,120 @@ |
|||
<?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([]); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
<?php |
|||
|
|||
namespace app\job\custmer; |
|||
|
|||
use app\model\customer_resources\CustomerResources; |
|||
use app\model\resource_sharing\ResourceSharing; |
|||
use core\base\BaseJob; |
|||
|
|||
class ResourceAutoAllocation extends BaseJob |
|||
{ |
|||
public function doJob() |
|||
{ |
|||
//获取当天的资源列表模型CustomerResources |
|||
// CustomerResources::where('created_at') |
|||
//获取当天销售获取资源的数量ResourceSharing |
|||
// ResourceSharing::where('shared_at')-> |
|||
//遍历资源列表按照资源数量的最少的人员优先分配 |
|||
return true; |
|||
} |
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\service\api\apiService; |
|||
|
|||
use app\model\campus\Campus; |
|||
use app\model\campus_person_role\CampusPersonRole; |
|||
use app\model\chat_friends\ChatFriends; |
|||
use app\model\chat_messages\ChatMessages; |
|||
use app\model\dict\Dict; |
|||
use app\model\order_table\OrderTable; |
|||
use core\base\BaseApiService; |
|||
use think\facade\Db; |
|||
|
|||
/** |
|||
* 订单管理-控制器服务层 |
|||
* Class MemberService |
|||
* @package app\service\api\member |
|||
*/ |
|||
class OrderTableService extends BaseApiService |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
//查询列表 |
|||
public function getList(array $where) |
|||
{ |
|||
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数 |
|||
$page = $page_params['page']; |
|||
$limit = $page_params['limit']; |
|||
|
|||
$model = new OrderTable(); |
|||
//员工表id |
|||
if (!empty($where['staff_id'])) { |
|||
$model = $model->where('staff_id', $where['staff_id']); |
|||
} |
|||
|
|||
//客户资源表id |
|||
if (!empty($where['resource_id'])) { |
|||
$model = $model->where('resource_id', $where['resource_id']); |
|||
} |
|||
|
|||
$data = $model |
|||
->append([ |
|||
'customerResources', |
|||
'course', |
|||
'classGrade', |
|||
'personnel' |
|||
]) |
|||
->order('id','desc') |
|||
->paginate([ |
|||
'list_rows' => $limit, |
|||
'page' => $page, |
|||
])->toArray(); |
|||
|
|||
return $data; |
|||
} |
|||
|
|||
//查询详情 |
|||
public function getInfo(array $where) |
|||
{ |
|||
$model = new OrderTable(); |
|||
//判断用没有员工id |
|||
if (!empty($where['staff_id'])) { |
|||
$model = $model->where('staff_id', $where['staff_id']); |
|||
} |
|||
//判断用没有客户资源id |
|||
if (!empty($where['resource_id'])) { |
|||
$model = $model->where('resource_id', $where['resource_id']); |
|||
} |
|||
$data = $model |
|||
->append([ |
|||
'customerResources', |
|||
'course', |
|||
'classGrade', |
|||
'personnel' |
|||
]) |
|||
->find(); |
|||
|
|||
|
|||
if ($data) { |
|||
$data = $data->toArray(); |
|||
$res = [ |
|||
'code' => 1, |
|||
'msg' => '操作成功', |
|||
'data' => $data |
|||
]; |
|||
return $res; |
|||
} else { |
|||
$res = [ |
|||
'code' => 0, |
|||
'msg' => '暂无数据', |
|||
'data' => [] |
|||
]; |
|||
return $res; |
|||
} |
|||
} |
|||
|
|||
//创建订单 |
|||
public function addData(array $data) |
|||
{ |
|||
$success = OrderTable::create($data); |
|||
|
|||
$res = [ |
|||
'code' => 1, |
|||
'msg' => '操作成功', |
|||
'data' => [] |
|||
]; |
|||
if (!$success) { |
|||
$res = [ |
|||
'code' => 0, |
|||
'msg' => '操作失败', |
|||
'data' => [] |
|||
]; |
|||
} |
|||
return $res; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue