// +---------------------------------------------------------------------- namespace App\Services\Api; use App\Models\GoodsModel; use App\Models\MemberModel; use App\Models\OrderGoodsModel; use App\Models\OrderModel; use App\Models\StoreModel; use App\Services\BaseService; use App\Services\ConfigService; use App\Services\Kd100Service; use App\Services\PaymentService; use App\Services\RedisService; use Illuminate\Support\Facades\DB; /** * 订单-服务类 * @author laravel开发员 * @since 2020/11/11 * @package App\Services\Api */ class OrderService extends BaseService { // 静态对象 protected static $instance = null; /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 */ public function __construct() { $this->model = new OrderModel(); } /** * 静态入口 */ public static function make() { if (!self::$instance) { self::$instance = new static(); } return self::$instance; } /** * 订单列表 * @param $params * @param int $pageSize * @return array */ public function getDataList($params, $pageSize = 15) { $model = $this->getQuery($params); // 数据 $list = $model->where(function ($query) use ($params) { $status = isset($params['status']) ? $params['status'] : 0; // 进行中 if ($status == 9) { $query->where('a.refund_status', '>', 0); } elseif ($status > 0 && is_array($status)) { $query->whereIn('a.status', $status)->where('a.refund_status', 0); } else if ($status == 4) { $query->where('a.status', $status)->where('a.refund_status', 0); } else if ($status > 0) { $query->where('a.status', $status)->where('a.refund_status', 0); } })->select(['a.*']) ->orderBy('a.status', 'asc') ->orderBy('a.create_time', 'desc') ->orderBy('a.id', 'desc') ->paginate($pageSize > 0 ? $pageSize : 9999999); $list = $list ? $list->toArray() : []; if ($list) { $statusArr = [1 => '待支付', 2 => '待发货', 3 => '待收货', 4 => '确认收货']; $refundStatusArr = [1 => '已退款', 2 => '退款中', 3 => '退款审核', 4 => '退款驳回']; foreach ($list['data'] as &$item) { $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y/m/d H:i') : ''; $status = isset($item['status']) ? $item['status'] : 0; $item['status_text'] = '待支付'; if ($status) { $item['status_text'] = isset($statusArr[$status]) ? $statusArr[$status] : ''; } if ($item['refund_status'] > 0) { $item['status_text'] = '退款/售后'; } $item['goods'] = isset($item['goods']) && $item['goods'] ? $item['goods'] : []; } unset($item); } return [ 'pageSize' => $pageSize, 'total' => isset($list['total']) ? $list['total'] : 0, 'list' => isset($list['data']) ? $list['data'] : [] ]; } /** * 查询条件 * @param $params * @return mixed */ public function getQuery($params) { $where = ['a.mark' => 1]; return $this->model->from('orders as a')->with(['orderGoods', 'store']) ->leftJoin('member as b', 'b.id', '=', 'a.user_id') ->where($where) ->where(function ($query) use ($params) { $userId = isset($params['user_id']) ? intval($params['user_id']) : 0; if ($userId > 0) { $query->where('a.user_id', $userId); } }) ->where(function ($query) use ($params) { $keyword = isset($params['keyword']) ? $params['keyword'] : ''; if ($keyword) { $query->where('a.order_no', 'like', "%{$keyword}%") ->orWhere('b.mobile', 'like', "%{$keyword}%"); } }); } /** * 订单详情 * @param $id */ public function getOrderInfo($id) { $statusArr = [1 => '待支付', 2 => '待发货', 3 => '待收货', 4 => '已完成']; $info = $this->model->from('orders as a')->with(['orderGoods','store']) ->leftJoin('member as b', 'b.id', '=', 'a.user_id') ->where(['a.id' => $id, 'a.mark' => 1]) ->select(['a.*']) ->first(); if ($info) { $info = $info->toArray(); $info['create_time'] = $info['create_time'] ? datetime($info['create_time'], 'Y-m-d H:i:s') : ''; $status = isset($info['status']) ? $info['status'] : 0; $info['status_text'] = '待付款'; if ($status) { $info['status_text'] = isset($statusArr[$status]) ? $statusArr[$status] : ''; } } return $info; } /** * 创建订单 * @param $userId 用户 * @param $params 参数 * @return array|false */ public function createOrder($userId, $params) { $addressId = isset($params['address_id']) && $params['address_id'] ? $params['address_id'] : 0; $goods = isset($params['goods']) && $params['goods'] ? $params['goods'] : []; $ids = $goods ? array_column($goods, 'id') : []; // 参数验证 if (empty($goods) || empty($ids)) { $this->error = '商品参数不为空'; return false; } if ($addressId <= 0) { $this->error = '请选择收货地址'; return false; } // 缓存锁 $cacheLockKey = "caches:orders:submit_lock:{$userId}"; if (RedisService::get($cacheLockKey)) { $this->error = '订单处理中~'; return false; } // 商品数据 $orderNo = get_order_num('GX'); RedisService::set($cacheLockKey, ['params' => $params, 'user_id' => $userId], rand(3, 5)); $result = GoodsService::make()->getOrderGoods($ids, $goods, $orderNo, $userId); if (empty($result)) { RedisService::clear($cacheLockKey); $this->error = GoodsService::make()->getError(); return false; } $orderGoods = isset($result['goods']) ? $result['goods'] : []; $orderTotal = isset($result['total']) ? $result['total'] : 0; $orderCount = isset($result['count']) ? $result['count'] : 0; $storeId = isset($result['store_id']) ? $result['store_id'] : 0; if (empty($orderGoods)) { RedisService::clear($cacheLockKey); $this->error = '获取订单商品错误~'; return false; } if ($orderTotal <= 0) { RedisService::clear($cacheLockKey); $this->error = '订单金额错误~'; return false; } if ($orderCount <= 0) { RedisService::clear($cacheLockKey); $this->error = '订单商品数量错误~'; return false; } // 用户信息 $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1]) ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status']) ->first(); $status = isset($userInfo['status']) ? $userInfo['status'] : 0; $openid = isset($userInfo['openid']) ? $userInfo['openid'] : ''; if (empty($userInfo) || $status != 1) { $this->error = 1045; RedisService::clear($cacheLockKey); return false; } if (empty($openid)) { $this->error = '用户微信未授权,请重新授权登录'; RedisService::clear($cacheLockKey); return false; } // 收货地址信息 $addressInfo = MemberAddressService::make()->getBindInfo($userId, $addressId); $realname = isset($addressInfo['realname']) ? $addressInfo['realname'] : ''; $mobile = isset($addressInfo['mobile']) ? $addressInfo['mobile'] : ''; $area = isset($addressInfo['area']) ? $addressInfo['area'] : ''; $address = isset($addressInfo['address']) ? $addressInfo['address'] : ''; if (empty($addressInfo) || empty($realname) || empty($mobile) || empty($area) || empty($address)) { RedisService::clear($cacheLockKey); $this->error = '收货地址信息错误,请核对后重试~'; return false; } // 商家佣金 $storeInfo = StoreModel::where(['id' => $storeId])->first(); $bonusRate = isset($storeInfo['bonus_rate']) ? floatval($storeInfo['bonus_rate']) : 0; $storeBonusRate = ConfigService::make()->getConfigByCode('store_bonus_rate', 0); $storeBonusRate = $storeBonusRate > 0 && $storeBonusRate <= 100 ? $storeBonusRate : 0; $bonusRate = $bonusRate > 0 && $bonusRate <= 100 ? $bonusRate : $storeBonusRate; $bonus = moneyFormat($orderTotal * $bonusRate / 100, 2); $total = $orderTotal; if (env('PAY_DEBUG')) { $orderTotal = 0.1; } // 订单数据 $order = [ 'order_no' => $orderNo, 'user_id' => $userId, 'store_id' => $storeId, 'total' => $total, 'num' => $orderCount, 'pay_total' => $orderTotal, 'receiver_name' => $realname, 'receiver_mobile' => $mobile, 'receiver_area' => $area, 'receiver_address' => $address, 'bonus' => $bonus, 'create_time' => time(), 'update_time' => time(), 'status' => 1, 'mark' => 1, ]; // 订单处理 DB::beginTransaction(); if (!$orderId = $this->model->insertGetId($order)) { DB::rollBack(); $this->error = '创建订单失败'; RedisService::clear($cacheLockKey); return false; } // 订单商品 if ($orderGoods && !OrderGoodsModel::insert($orderGoods)) { DB::rollBack(); $this->error = '处理订单商品错误'; RedisService::clear($cacheLockKey); return false; } // 获取支付参数 /* TODO 支付处理 */ $payOrder = [ 'type' => 1, 'order_no' => $orderNo, 'pay_money' => $orderTotal, 'body' => '购物消费', 'openid' => $openid ]; // 调起支付 $payment = PaymentService::make()->minPay($userInfo, $payOrder, 'store'); if (empty($payment)) { DB::rollBack(); RedisService::clear($cacheLockKey); $this->error = PaymentService::make()->getError(); return false; } // 用户操作记录 DB::commit(); $this->error = '订单创建成功,请前往支付~'; RedisService::clear($cacheLockKey); return [ 'order_id' => $orderId, 'payment' => $payment, 'total' => $payOrder['pay_money'], 'pay_type' => 10, ]; } /** * 订单支付 * @param $userId * @param $id * @return array|false */ public function pay($userId, $id) { if ($id <= 0) { $this->error = '请选择支付订单'; return false; } // 缓存锁 $cacheLockKey = "caches:orders:pay_lock:{$userId}_{$id}"; if (RedisService::get($cacheLockKey)) { $this->error = '订单处理中~'; return false; } // 商品数据 RedisService::set($cacheLockKey, ['order_id' => $id, 'user_id' => $userId], rand(3, 5)); // 用户信息 $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1]) ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status']) ->first(); $status = isset($userInfo['status']) ? $userInfo['status'] : 0; $openid = isset($userInfo['openid']) ? $userInfo['openid'] : ''; if (empty($userInfo) || $status != 1) { $this->error = 1045; RedisService::clear($cacheLockKey); return false; } if (empty($openid)) { $this->error = '用户微信未授权,请重新授权登录'; RedisService::clear($cacheLockKey); return false; } // 订单信息 $info = $this->model->where(['id' => $id, 'mark' => 1]) ->select(['id', 'order_no', 'pay_total', 'status']) ->first(); $orderTotal = isset($info['pay_total']) ? $info['pay_total'] : 0; $orderNo = isset($info['order_no']) ? $info['order_no'] : ''; $status = isset($info['status']) ? $info['status'] : 0; if (empty($info) || empty($orderNo)) { $this->error = '订单信息不存在'; RedisService::clear($cacheLockKey); return false; } if ($status != 1) { $this->error = '订单已支付'; RedisService::clear($cacheLockKey); return false; } // 获取支付参数 /* TODO 支付处理 */ $payOrder = [ 'type' => 1, 'order_no' => $orderNo, 'pay_money' => $orderTotal, 'body' => '购物消费', 'openid' => $openid ]; // 调起支付 $payment = PaymentService::make()->minPay($userInfo, $payOrder, 'store'); if (empty($payment)) { DB::rollBack(); RedisService::clear($cacheLockKey); $this->error = PaymentService::make()->getError(); return false; } // 用户操作记录 DB::commit(); $this->error = '支付请求成功,请前往支付~'; RedisService::clear($cacheLockKey); return [ 'order_id' => $id, 'payment' => $payment, 'total' => $payOrder['pay_money'], 'pay_type' => 10, ]; } /** * 订单取消 * @param $userId * @param $id * @return array|false */ public function cancel($userId, $id) { if ($id <= 0) { $this->error = '请选择订单'; return false; } // 缓存锁 $cacheLockKey = "caches:orders:cancel_lock:{$userId}_{$id}"; if (RedisService::get($cacheLockKey)) { $this->error = '订单处理中~'; return false; } // 商品数据 RedisService::set($cacheLockKey, ['order_id' => $id, 'user_id' => $userId], rand(3, 5)); // 用户信息 $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1]) ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status']) ->first(); $status = isset($userInfo['status']) ? $userInfo['status'] : 0; if (empty($userInfo) || $status != 1) { $this->error = 1045; RedisService::clear($cacheLockKey); return false; } // 订单信息 $info = $this->model->where(['id' => $id, 'mark' => 1]) ->select(['id', 'order_no', 'pay_total', 'status']) ->first(); $orderNo = isset($info['order_no']) ? $info['order_no'] : ''; $status = isset($info['status']) ? $info['status'] : 0; if (empty($info) || empty($orderNo)) { $this->error = '订单信息不存在'; RedisService::clear($cacheLockKey); return false; } if ($status != 1) { $this->error = '订单已支付'; RedisService::clear($cacheLockKey); return false; } $this->error = '取消订单成功'; $this->model->where(['user_id' => $userId, 'mark' => 0])->where('update_time', '<=', time() - 300)->delete(); $this->model->where(['id' => $id])->update(['mark' => 0, 'update_time' => time()]); return ['id' => $id]; } /** * 订单完成 * @param $userId 订单用户ID * @param $id 订单ID * @return array|false */ public function complete($userId, $id) { if ($id <= 0) { $this->error = '请选择订单'; return false; } // 缓存锁 $cacheLockKey = "caches:orders:complete_lock:{$userId}_{$id}"; if (RedisService::get($cacheLockKey)) { $this->error = '订单处理中~'; return false; } // 商品数据 RedisService::set($cacheLockKey, ['order_id' => $id, 'user_id' => $userId], rand(3, 5)); // 用户信息 $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1]) ->select(['id', 'openid', 'mobile', 'parent_id', 'nickname', 'realname', 'balance', 'status']) ->first(); $status = isset($userInfo['status']) ? $userInfo['status'] : 0; $parentId = isset($userInfo['parent_id']) ? $userInfo['parent_id'] : 0; if (empty($userInfo) || $status != 1) { $this->error = 1045; RedisService::clear($cacheLockKey); return false; } // 订单信息 $info = $this->model->with(['orderGoods'])->where(['id' => $id, 'mark' => 1]) ->select(['id', 'order_no', 'store_id', 'pay_total', 'bonus', 'delivery_no', 'delivery_company', 'delivery_code', 'status']) ->first(); $orderNo = isset($info['order_no']) ? $info['order_no'] : ''; $deliveryNo = isset($info['delivery_no']) ? $info['delivery_no'] : ''; $deliverCompany = isset($info['delivery_company']) ? $info['delivery_company'] : ''; $deliverCode = isset($info['delivery_code']) ? $info['delivery_code'] : ''; $storeId = isset($info['store_id']) ? $info['store_id'] : 0; $orderTotal = isset($info['pay_total']) ? $info['pay_total'] : 0; $bonus = isset($info['bonus']) ? $info['bonus'] : 0; $status = isset($info['status']) ? $info['status'] : 0; $orderGoods = isset($info['order_goods']) ? $info['order_goods'] : []; if (empty($info) || empty($orderNo)) { $this->error = '订单信息不存在'; RedisService::clear($cacheLockKey); return false; } if ($status != 3) { $this->error = '订单未发货'; RedisService::clear($cacheLockKey); return false; } if ((empty($deliveryNo) || empty($deliverCompany) || empty($deliverCode))) { $this->error = '订单发货信息错误'; RedisService::clear($cacheLockKey); return false; } if (empty($deliveryNo) || empty($deliverCompany) || empty($deliverCode)) { $this->error = '订单发货信息错误,请联系客服'; RedisService::clear($cacheLockKey); return false; } DB::beginTransaction(); $this->model->where(['id' => $id])->update(['status' => '4', 'update_time' => time()]); // 商家订单数据统计 $updateData = ['order_count' => DB::raw('order_count+1'), 'order_total' => DB::raw("order_total + {$orderTotal}")]; StoreModel::where(['id' => $storeId])->update($updateData); // 商品销量数据 if ($orderGoods) { $counts = []; foreach ($orderGoods as $item) { $counts[$item['goods_id']] = isset($counts[$item['goods_id']]) ? $counts[$item['goods_id']] : 0; $counts[$item['goods_id']] += $item['num']; } if ($counts) { foreach ($counts as $id => $v) { GoodsModel::where(['id' => $id])->update(['sales' => DB::raw("sales + {$v}"), 'update_time' => time()]); } } } // 结算商家收益 if (SettleService::make()->storeBonus($storeId, $bonus, $info) < 0) { DB::rollBack(); $this->error = SettleService::make()->getError(); RedisService::clear($cacheLockKey); return false; } // 代理佣金结算 if (SettleService::make()->agentBonus($userId, $orderTotal, $info, $parentId) < 0) { DB::rollBack(); $this->error = SettleService::make()->getError(); RedisService::clear($cacheLockKey); return false; } DB::commit(); $this->error = '确认收货成功'; return ['id' => $id]; } /** * 售后或退款 * @param $userId * @param $params * @return array|false */ public function after($userId, $params) { $id = isset($params['id']) ? $params['id'] : 0; $afterType = isset($params['after_type']) ? $params['after_type'] : 1; if ($id <= 0) { $this->error = '请选择订单'; return false; } // 缓存锁 $cacheLockKey = "caches:orders:after_lock:{$userId}_{$id}"; if (RedisService::get($cacheLockKey)) { $this->error = '订单处理中~'; return false; } // 商品数据 RedisService::set($cacheLockKey, ['params' => $params, 'user_id' => $userId], rand(3, 5)); // 用户信息 $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1]) ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status']) ->first(); $status = isset($userInfo['status']) ? $userInfo['status'] : 0; if (empty($userInfo) || $status != 1) { $this->error = 1045; RedisService::clear($cacheLockKey); return false; } // 订单信息 $info = $this->model->where(['id' => $id, 'mark' => 1]) ->select(['id', 'order_no', 'after_type', 'refund_status', 'pay_total', 'status']) ->first(); $orderNo = isset($info['order_no']) ? $info['order_no'] : ''; $status = isset($info['status']) ? $info['status'] : 0; $refundStatus = isset($info['refund_status']) ? $info['refund_status'] : 0; if (empty($info) || empty($orderNo)) { $this->error = '订单信息不存在'; RedisService::clear($cacheLockKey); return false; } if ($status == 1) { $this->error = '订单未支付'; RedisService::clear($cacheLockKey); return false; } if ($status == 4 && $afterType==2) { $this->error = '订单已完成'; RedisService::clear($cacheLockKey); return false; } if ($refundStatus > 0 && $refundStatus != 4) { $this->error = '订单售后处理中'; RedisService::clear($cacheLockKey); return false; } $afterRealname = isset($params['after_realname']) ? $params['after_realname'] : ''; $afterPhone = isset($params['after_phone']) ? $params['after_phone'] : ''; $afterRemark = isset($params['after_remark']) ? $params['after_remark'] : ''; if ($afterType == 1) { if (empty($afterRealname) || empty($afterPhone) || empty($afterRemark)) { $this->error = '请填写售后信息'; RedisService::clear($cacheLockKey); return false; } } $data = [ 'after_type' => $afterType, 'after_realname' => $afterRealname, 'after_phone' => $afterPhone, 'after_remark' => $afterRemark, 'refund_remark' => isset($params['refund_remark']) ? $params['refund_remark'] : '', 'refund_status' => 3, 'update_time' => time() ]; $this->model->where(['id' => $id])->update($data); $this->error = '订单申请售后成功'; return ['id' => $id]; } /** * 今日数量统计数据 * @param $userId * @param int $type * @return array|mixed */ public function getCountByDay($userId, $status = 3) { $cacheKey = "caches:orders:count_day_{$userId}_{$status}"; $data = RedisService::get($cacheKey); if ($data) { return $data; } $data = $this->model->where(['user_id' => $userId, 'status' => $status, 'mark' => 1]) ->where('create_time', '>=', strtotime(date('Y-m-d'))) ->count('id'); if ($data) { RedisService::set($cacheKey, $data, rand(5, 10)); } return $data; } /** * 订单数 * @param $userId * @param int $status * @return array|mixed */ public function getCountByStatus($userId, $status = 3) { $cacheKey = "caches:orders:count_status_{$userId}_{$status}"; $data = RedisService::get($cacheKey); if ($data) { return $data; } $data = $this->model->where(['user_id' => $userId, 'status' => $status, 'mark' => 1]) ->count('id'); if ($data) { RedisService::set($cacheKey, $data, rand(5, 10)); } return $data; } /** * 获取订单审核状态 * @param $userId * @return array|mixed */ public function checkOrderStatus($userId) { $cacheKey = "caches:orders:checkOrder:{$userId}"; $data = RedisService::get($cacheKey); if ($data) { return $data; } $data = $this->model->with(['confirm'])->where(function ($query) { $query->where(function ($query) { $query->where('status', 2)->where('confirm_at', '>=', date('Y-m-d H:i:s', time() - 3600)); })->orWhere(function ($query) { $query->where('status', 9)->where('confirm_at', '>=', date('Y-m-d H:i:s', time() - 600)); })->orWhere(function ($query) { $query->where('status', 3)->where('confirm_at', '>=', date('Y-m-d H:i:s', time() - 600)); })->orWhere('status', 1); }) ->where(['user_id' => $userId, 'mark' => 1]) ->select(['id', 'order_no', 'user_id', 'goods_id', 'status']) ->orderBy('id', 'desc') ->first(); $data = $data ? $data->toArray() : []; $result = []; if ($data) { $orderId = isset($data['id']) ? $data['id'] : 0; $status = isset($data['status']) ? $data['status'] : 0; $goodsId = isset($data['goods_id']) ? $data['goods_id'] : 0; $confirmOrder = isset($data['confirm']) ? $data['confirm'] : []; $confirmOrderId = isset($confirmOrder['id']) ? $confirmOrder['id'] : 0; $confirmOrderUser = isset($confirmOrder['user']) ? $confirmOrder['user'] : []; $realname = isset($confirmOrderUser['realname']) ? $confirmOrderUser['realname'] : ''; if ($status == 9) { $message = "抱歉,订单已被其他师傅接走"; } else if ($status == 2) { $message = "恭喜您,抢单成功,请前往完成订单!"; } else if ($status == 3) { $message = "恭喜您,订单已经完成!"; } else { $pickerCount = $this->model->where(['goods_id' => $goodsId, 'mark' => 1])->whereIn('status', [1, 2])->count('id'); $pickerCount = $pickerCount <= 3 ? 3 : $pickerCount; $message = "
正在抢单
({$pickerCount}位师傅正在抢单中)
"; } $result = ['order_id' => $orderId, 'goods_id' => $goodsId, 'confirm_order_id' => $confirmOrderId, 'status' => $status, 'message' => $message]; RedisService::set($cacheKey, $result, rand(10, 20)); } return $result; } /** * 物流查询 * @param $id * @return array|false|mixed */ public function getDelivery($id) { $info = $this->model->where(['id' => $id, 'mark' => 1])->first(); $deliveryNo = isset($info['delivery_no']) ? $info['delivery_no'] : ''; $deliveryCode = isset($info['delivery_code']) ? $info['delivery_code'] : ''; $mobile = isset($info['receiver_mobile']) ? $info['receiver_mobile'] : ''; if (empty($info)) { $this->error = '请选择订单'; return false; } $cacheKey = "caches:kd100_{$id}"; $data = RedisService::get($cacheKey); $data = [ [ "time" => "2025-12-24 11:29:23", "context" => "您的快件已投递,收件人在[沙岗镇绕城路天猫1号店妈妈驿站]取件(凭取件码签收),如有疑问请联系站点:13086796129,快递员电话:13086796129,投诉电话:15278929512。感谢使用圆通速递,期待再次为您服务!", "ftime" => "2025-12-24 11:29:23", "areaCode" => "CN450521000000", "areaName" => "广西,北海市,合浦县", "status" => "签收", ], [ "time" => "2025-12-22 17:29:40", "context" => "您的快件已到达[妈妈驿站]沙岗镇绕城路1号天猫店,请您及时取件,如有取件码问题或找不到包裹等问题,请联系站点:13086796129,快递员电话:13086796129,投诉电话:15278929512。感谢使用圆通速递,期待再次为您服务!", "ftime" => "2025-12-22 17:29:40", "areaCode" => "CN450521000000", "areaName" => "广西,北海市,合浦县", "status" => "派件", ],[ "time" => "2025-12-22 17:28:40", "context" => "【广西北海市合浦县沙岗镇】的莫业琨(13086796129)正在派件,(有事先呼我,勿找平台,少一次投诉,多一份感恩)!如有疑问请联系网点:15278929512,投诉电话:15278929512。[95161和18521号段的上海号码为圆通快递员专属号码,请放心接听]", "ftime" => "2025-12-22 17:28:40", "areaCode" => "CN450521100000", "areaName" => "广西,北海市,合浦县,廉州镇", "status" => "派件", ],[ "time" => "2025-12-22 02:44:12", "context" => "您的快件离开【南宁转运中心】,已发往【广西北海市合浦】", "ftime" => "2025-12-22 02:44:12", "areaCode" => "CN450108000000", "areaName" => "广西,南宁市,良庆区", "status" => "在途", ],[ "time" => "2025-12-22 02:21:21", "context" => "您的快件已经到达【南宁转运中心】【物流问题无需找商家或平台,请致电(专属热线:95554)更快解决】", "ftime" => "2025-12-22 02:21:21", "areaCode" => "CN450108000000", "areaName" => "广西,南宁市,良庆区", "status" => "在途", ],[ "time" => "2025-12-20 23:47:58", "context" => "您的快件离开【临海转运中心】,已发往【南宁转运中心】。预计【12月22日】到达【南宁市】,因运输距离较远,预计将在【22日晚上】为您更新快件状态,请您放心!", "ftime" => "2025-12-20 23:47:58", "areaCode" => "CN331082000000", "areaName" => "浙江,台州市,临海市", "status" => "在途", ],[ "time" => "2025-12-20 23:45:58", "context" => "您的快件已经到达【临海转运中心】【物流问题无需找商家或平台,请致电(专属热线:95554)更快解决】", "ftime" => "2025-12-20 23:45:58", "areaCode" => "CN331082000000", "areaName" => "浙江,台州市,临海市", "status" => "在途", ] ]; if ($data) { return $data; } $result = Kd100Service::make()->query($deliveryNo, $mobile, $deliveryCode); $status = isset($result['status'])?$result['status']:0; $data = isset($result['data'])?$result['data']:[]; if ($data && $status==200) { RedisService::set($cacheKey, $data, 300); } return $data; } }