pull/1/head
wanghousheng 10 months ago
parent 6c21348af5
commit 89f6717abd
  1. 47
      app/api/controller/Server.php
  2. 67
      app/api/model/Server/ServerOrder.php
  3. 4
      app/common/service/server/Order.php

@ -112,7 +112,7 @@ class Server extends Controller
$end_time = strtotime($end_time) + 86400; $end_time = strtotime($end_time) + 86400;
$where[] = ['create_time', '<', $end_time]; $where[] = ['create_time', '<', $end_time];
} }
$model = new ServerOrder($where); $model = new ServerOrder();
$list = $model->orderList($where); $list = $model->orderList($where);
$data['list'] = $list->items(); $data['list'] = $list->items();
$data['total'] = $list->total(); $data['total'] = $list->total();
@ -134,6 +134,51 @@ class Server extends Controller
return $this->renderSuccess($data); return $this->renderSuccess($data);
} }
/**
* @notes:订单详情
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function orderDetails(): Json
{
$orderId = intval($this->request->post('order_id'));
if (!$orderId) {
return $this->renderError('非法请求');
}
$model = new ServerOrder();
$info = $model->info(['order_id' => $orderId]);
if (!empty($info)) {
$info['is_cancel'] = ServerServiceOrder::checkCancel($info);
$info['is_dispatch'] = ServerServiceOrder::checkDispatch($info);
$info['is_pay'] = ServerServiceOrder::checkPay($info);
$info['is_success'] = ServerServiceOrder::checkSuccess($info);
}
return $this->renderSuccess(['info' => $info]);
}
/**
* @notes:确认完成
* @return Json
* @throws BaseException
* @author: wanghousheng
*/
public function confirmSuccess(): Json
{
$orderId = intval($this->request->post('order_id'));
if (!$orderId) {
return $this->renderError('非法请求');
}
$model = new ServerOrder();
if ($model->confirmSuccess(['order_id' => $orderId])) {
return $this->renderSuccess('操作成功');
}
return $this->renderError('操作失败');
}
/** /**
* @notes:确认订单 * @notes:确认订单
* @return Json * @return Json

@ -11,6 +11,7 @@ use cores\exception\BaseException;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\Model;
use think\Paginator; use think\Paginator;
class ServerOrder extends Order class ServerOrder extends Order
@ -68,6 +69,72 @@ class ServerOrder extends Order
} }
/**
* @notes:
* @param $where
* @return bool
* @throws BaseException
* @author: wanghousheng
*/
public function confirmSuccess($where): bool
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
if (!UserService::isDealerEngineer() || !UserService::isStore()) {
return false;
}
if (UserService::isDealerEngineer()) {
$where = array_merge($where, ['dealer_id' => $userId]);
}
//分销商工程师
$order_id = $this->where($where)
->where(['order_status' => ServerEnum::APPLYSERVER])
->where('is_delete', '=', 0)
->value('order_id');
if (!empty($order_id)) {
$this->where(['id' => $order_id])->save(['order_status' => ServerEnum::COMPLETED]);
return true;
}
return false;
}
/**
* @notes:订单详情
* @param $where
* @return ServerOrder|array|mixed|Model|null
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function info($where)
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
//判断当前用户身份
if (UserService::isDealerEngineer()) {
//分销商工程师
return $this->with(['image', 'user'])
->where($where)
->where('dealer_id', '=', $userId)
->where('is_delete', '=', 0)
->find();
} elseif (UserService::isStore()) {
// 店主
return $this->with(['image', 'user', 'dealer'])
->where($where)
->where('is_delete', '=', 0)
->find();
} else {
return $this->with(['image', 'dealer'])
->where($where)
->where('user_id', '=', $userId)
->where('is_delete', '=', 0)
->find();
}
}
/** /**
* 获取用户订单详情(仅订单记录) * 获取用户订单详情(仅订单记录)
* @param int $orderId * @param int $orderId

@ -120,10 +120,14 @@ class Order extends BaseService
* @notes:是否可以完成 * @notes:是否可以完成
* @param $order * @param $order
* @return bool * @return bool
* @throws BaseException
* @author: wanghousheng * @author: wanghousheng
*/ */
public static function checkSuccess($order): bool public static function checkSuccess($order): bool
{ {
if (!UserService::isDealerEngineer() || !UserService::isStore()) {
return false;
}
if (!empty($order) && $order['order_status'] == ServerEnum::APPLYSERVER) { if (!empty($order) && $order['order_status'] == ServerEnum::APPLYSERVER) {
return true; return true;
} }

Loading…
Cancel
Save