Files
huangjingfen/pro_v3.5.1/app/controller/api/store/StoreDelivery.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

132 lines
4.1 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\controller\api\store;
use app\Request;
use app\services\order\store\BranchOrderServices;
use app\services\store\DeliveryServiceServices;
use app\services\store\SystemStoreServices;
use app\services\store\SystemStoreStaffServices;
use app\services\user\UserServices;
use think\annotation\Inject;
/**
* 配送员
* Class StoreDelivery
* @package app\controller\store\staff
*/
class StoreDelivery
{
/**
* @var DeliveryServiceServices
*/
#[Inject]
protected DeliveryServiceServices $services;
/**
* 获取配送员信息
* @param Request $request
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function info(Request $request, SystemStoreServices $storeServices, UserServices $userServices)
{
$uid = (int)$request->uid();
$deliveryInfo = $this->services->getDeliveryInfoByUid($uid)->toArray();
$store_ids = $this->services->getDeliveryStoreIds($uid, 1, 'relation_id');
$store_info = [];
if ($store_ids) {
$store_info = $storeServices->getColumn([['id', 'in', $store_ids], ['is_show', '=', 1], ['is_del', '=', 0]], 'id,name');
}
$deliveryInfo['store_info'] = $store_info;
$deliveryInfo['user_nickname'] = $userServices->value(['uid' => $uid], 'nickname');
return app('json')->success($deliveryInfo);
}
/**
* 获取所有配送员列表
* @param DeliveryServiceServices $services
* @return mixed
*/
public function getDeliveryAll(Request $request, SystemStoreStaffServices $staffServices)
{
$uid = (int)$request->uid();
$staffInfo = $staffServices->getStaffInfoByUid($uid);
$list = $this->services->getDeliveryList(1, $staffInfo['store_id']);
return app('json')->success($list['list']);
}
/**
* 配送员数据统计
* @param Request $request
* @return mixed
*/
public function statistics(Request $request)
{
[$store_id, $time] = $request->getMore([
['store_id', 0],
['data', '', '', 'time'],
], true);
$uid = (int)$request->uid();
$data = $this->services->getStoreData($uid, $store_id, $time);
return app('json')->successful($data);
}
/**
* 配送统计列表数据
* @param Request $request
* @return mixed
*/
public function data(Request $request, BranchOrderServices $orderServices)
{
[$store_id, $time] = $request->getMore([
['store_id', 0],
['data', '', '', 'time'],
], true);
$uid = (int)$request->uid();
$this->services->getDeliveryInfoByUid($uid, $store_id);
$where = ['delivery_uid' => $uid, 'time' => $time];
if ($store_id) {
$where['store_id'] = $store_id;
}
$data = $orderServices->getOrderDataPriceCount($where);
return app('json')->successful($data);
}
/**
* 配送订单列表
* @param Request $request
* @return mixed
*/
public function orderList(Request $request, BranchOrderServices $orderServices)
{
[$type] = $request->getMore([
['type', 1]
], true);
$uid = (int)$request->uid();
$where = ['delivery_uid' => $uid, 'status' => 9, 'is_del' => 0, 'is_system_del' => 0, 'paid' => 1, 'refund_status' => [0, 3]];
if ($type == 1) {
$where['status'] = 2;
}
$list = $orderServices->getStoreOrderList($where, ['*'], ['pink', 'store' => function ($query) {
$query->field('id,name,address,detailed_address');
}]);
$data = [];
$where['status'] = 2;
$data['unsend'] = $orderServices->count($where);
$where['status'] = 9;
$data['send'] = $orderServices->count($where);
return app('json')->successful(compact('data', 'list'));
}
}