setAttrs($params); $model->store_id = request()->adminInfo['store_id']; $defaultAvatar = config('project.default_image.admin_avatar'); $model->avatar = !empty($model['avatar']) ? FileService::setFileUrl($model['avatar']) : $defaultAvatar; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function edit($id, $params) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->setAttrs($params); $defaultAvatar = config('project.default_image.admin_avatar'); $model->avatar = !empty($model['avatar']) ? FileService::setFileUrl($model['avatar']) : $defaultAvatar; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function delete($id) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->delete(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } public function detail($id) { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $data = $model->toArray(); $orderLogic = new StoreOrderLogic(); $data['wait'] = $orderLogic->storeOrderCountByWhere([ 'store_id' => $data['store_id'], 'delivery_id' => $data['phone'], 'status' => 0, 'paid' => 1, 'shipping_type' => 1, ]); $data['finish'] = $orderLogic->storeOrderCountByWhere([ 'store_id' => $data['store_id'], 'delivery_id' => $data['phone'], 'status' => [1, 2], 'paid' => 1, 'shipping_type' => 1, ]); $data['wait_amount'] = $orderLogic->storeOrderSumByWhere([ 'store_id' => $data['store_id'], 'delivery_id' => $data['phone'], 'status' => 0, 'paid' => 1, 'shipping_type' => 1, ]); $data['finish_amount'] = $orderLogic->storeOrderSumByWhere([ 'store_id' => $data['store_id'], 'delivery_id' => $data['phone'], 'status' => [1, 2], 'paid' => 1, 'shipping_type' => 1, ]); return $data; } public function status($id) { try { $model = DeliveryService::find($id); if (empty($model)) { throw new \Exception('数据不存在'); } $model->status = $model->status == 1 ? 0 : 1; $model->save(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } }