pull/1/head
wanghousheng 12 months ago
parent b0f58984c3
commit 9fd37966b4
  1. 4
      app/api/controller/Recovery.php
  2. 16
      app/api/controller/Server.php
  3. 14
      app/common/service/server/Order.php

@ -47,6 +47,8 @@ class Recovery extends Controller
{
$recovery_name = $this->request->post('recovery_name');
$category_id = intval($this->request->post('category_id'));
$order_field = $this->request->post('order_field');
$order_sort = $this->request->post('order_sort', 'desc');
$where = [];
if ($recovery_name) {
$where[] = ['server_recovery.recovery_name', 'like', "%$recovery_name%"];
@ -56,7 +58,7 @@ class Recovery extends Controller
}
$where[] = ['server_recovery.status', '=', 1];
$model = new ServerRecovery();
$list = $model->getList($where);
$list = $model->getList($where, $order_field, $order_sort);
$data['list'] = $list->items();
$data['total'] = $list->total();
if (!$list->isEmpty()) {

@ -150,6 +150,14 @@ class Server extends Controller
$serverId = intval($this->request->post('server_id'));
$couponId = intval($this->request->post('coupon_id'));
$server_time = $this->request->post('server_time');
$username = $this->request->post('username');
if (!$username) {
return $this->renderError('联系人不能为空');
}
$mobile = $this->request->post('mobile');
if (!$mobile || !preg_match("/1[3457896]\d{9}$/", $mobile)) {
return $this->renderError('手机号不正确');
}
if (!$server_time) {
return $this->renderError('服务时间不能为空');
}
@ -162,7 +170,13 @@ class Server extends Controller
return $this->renderError('非法请求');
}
$orderService = new ServerServiceOrder();
$result = $orderService->createOrder($serverId, $couponId, $server_address, $server_time, $remake);
$data = [
'server_id' => $serverId,
'server_time' => $server_time,
'server_address' => $server_address,
'buyer_remark' => $remake,
];
$result = $orderService->createOrder($data, $couponId);
if ($result) {
return $this->renderSuccess($result);
}

@ -161,25 +161,21 @@ class Order extends BaseService
/**
* @notes:生成订单
* @param int $serverId
* @param array $params
* @param int $couponId
* @param string $server_address
* @param string $server_time
* @param string $buyer_remark
* @return array
* @throws BaseException
* @throws DbException
* @author: wanghousheng
*/
public function createOrder(int $serverId, int $couponId, string $server_address, string $server_time, string $buyer_remark = ''): array
public function createOrder(array $params, int $couponId): array
{
$userId = UserService::getCurrentLoginUserId();
$data = $this->onCheck($serverId, $couponId);
$data = $this->onCheck($params['server_id'], $couponId);
// 设置优惠券使用状态
$couponId > 0 && UserCoupon::setIsUse($couponId);
//封装数据
$order_data = [
'server_id' => $this->serverInfo['server_id'],
'order_no' => $this->orderNo(),
'server_name' => $this->serverInfo['server_name'],
'server_image_id' => $this->serverInfo['image_id'],
@ -189,12 +185,10 @@ class Order extends BaseService
'coupon_id' => $data['coupon_id'],
'coupon_money' => $data['coupon_money'],
'pay_price' => $data['pay_price'],
'buyer_remark' => $buyer_remark,
'create_time' => time(),
'update_time' => time(),
'server_time' => $server_time,
'server_address' => $server_address,
];
$order_data = array_merge($order_data, $params);
$model = new ServerOrder();
$order_id = $model->insertGetId($order_data);
if ($order_id) {

Loading…
Cancel
Save