|
|
@ -13,6 +13,9 @@ declare (strict_types=1); |
|
|
|
namespace app\api\controller; |
|
|
|
namespace app\api\controller; |
|
|
|
|
|
|
|
|
|
|
|
use app\api\service\User as UserService; |
|
|
|
use app\api\service\User as UserService; |
|
|
|
|
|
|
|
use app\store\model\Express as ExpressModel; |
|
|
|
|
|
|
|
use app\store\model\store\shop\Clerk as ClerkModel; |
|
|
|
|
|
|
|
use app\store\service\order\Delivery as DeliveryService; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use cores\exception\BaseException; |
|
|
|
use think\App; |
|
|
|
use think\App; |
|
|
|
use think\response\Json; |
|
|
|
use think\response\Json; |
|
|
@ -21,6 +24,8 @@ 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 app\store\model\Goods as GoodsModel; |
|
|
|
use app\store\model\Goods as GoodsModel; |
|
|
|
|
|
|
|
use app\store\model\Order as OrderModel; |
|
|
|
|
|
|
|
use app\store\model\OrderRefund as OrderRefundModel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 店主管理 |
|
|
|
* 店主管理 |
|
|
@ -165,5 +170,173 @@ class StoreKeeper extends Controller |
|
|
|
return $this->renderSuccess('删除成功'); |
|
|
|
return $this->renderSuccess('删除成功'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//订单相关 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 订单列表 |
|
|
|
|
|
|
|
* @param string $dataType |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function orderList(string $dataType): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$params = $this->request->param(); |
|
|
|
|
|
|
|
$params['searchType'] = 'all'; |
|
|
|
|
|
|
|
// 订单列表 |
|
|
|
|
|
|
|
if (!empty($params['dataType']) && $params['dataType'] == 'refund') { |
|
|
|
|
|
|
|
$model = new OrderRefundModel; |
|
|
|
|
|
|
|
$list = $model->getList($params); |
|
|
|
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$model = new OrderModel; |
|
|
|
|
|
|
|
$list = $model->getList($params); |
|
|
|
|
|
|
|
return $this->renderSuccess(compact('dataType', 'list')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取全部记录 |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function expressAll(): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$model = new ExpressModel; |
|
|
|
|
|
|
|
$list = $model->getAll($this->request->param()); |
|
|
|
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 修改订单价格 |
|
|
|
|
|
|
|
* @param int $orderId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function updatePrice(int $orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 订单详情 |
|
|
|
|
|
|
|
$model = OrderModel::detail($orderId); |
|
|
|
|
|
|
|
if ($model->updatePrice($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 修改订单地址 |
|
|
|
|
|
|
|
* @param int $orderId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function updateAddress(int $orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 订单详情 |
|
|
|
|
|
|
|
$model = OrderModel::detail($orderId); |
|
|
|
|
|
|
|
if ($model->updateAddress($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 审核:用户取消订单 |
|
|
|
|
|
|
|
* @param $orderId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function confirmCancel($orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 订单详情 |
|
|
|
|
|
|
|
$model = OrderModel::detail($orderId); |
|
|
|
|
|
|
|
if ($model->confirmCancel($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 删除订单记录 |
|
|
|
|
|
|
|
* @param int $orderId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function oderDelete(int $orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 订单详情 |
|
|
|
|
|
|
|
$model = OrderModel::detail($orderId); |
|
|
|
|
|
|
|
// 确认核销 |
|
|
|
|
|
|
|
if ($model->setDelete()) { |
|
|
|
|
|
|
|
return $this->renderSuccess('删除成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 门店自提核销 |
|
|
|
|
|
|
|
* @param int $orderId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function extract(int $orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 订单详情 |
|
|
|
|
|
|
|
$model = OrderModel::detail($orderId); |
|
|
|
|
|
|
|
if ($model->extractEvent($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('核销成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '核销失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function clerkAll(): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 店员列表 |
|
|
|
|
|
|
|
$model = new ClerkModel; |
|
|
|
|
|
|
|
$list = $model->getAll($this->request->param()); |
|
|
|
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 确认发货 (手动录入) |
|
|
|
|
|
|
|
* @param int $orderId 订单ID |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function delivery(int $orderId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$service = new DeliveryService; |
|
|
|
|
|
|
|
if ($service->delivery($orderId, $this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('发货成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($service->getError() ?: '发货失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 商家审核 |
|
|
|
|
|
|
|
* @param int $orderRefundId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function audit(int $orderRefundId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 售后单详情 |
|
|
|
|
|
|
|
$model = OrderRefundModel::detail($orderRefundId); |
|
|
|
|
|
|
|
// 确认审核 |
|
|
|
|
|
|
|
if ($model->audit($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 确认收货并退款 |
|
|
|
|
|
|
|
* @param int $orderRefundId |
|
|
|
|
|
|
|
* @return Json |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function receipt(int $orderRefundId): Json |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 售后单详情 |
|
|
|
|
|
|
|
$model = OrderRefundModel::detail($orderRefundId); |
|
|
|
|
|
|
|
// 确认收货并退款 |
|
|
|
|
|
|
|
if ($model->receipt($this->postForm())) { |
|
|
|
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |