|
|
@@ -13,9 +13,13 @@ 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;
|
|
|
|
|
|
@@ -65,30 +69,37 @@ class OrderService extends BaseService
|
|
|
$list = $model->where(function ($query) use ($params) {
|
|
|
$status = isset($params['status']) ? $params['status'] : 0;
|
|
|
// 进行中
|
|
|
- if ($status > 0 && is_array($status)) {
|
|
|
- $query->whereIn('a.status', $status);
|
|
|
- }else if($status>0){
|
|
|
- $query->where('a.status', $status);
|
|
|
+ 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', 'desc')
|
|
|
+ ->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 => '已完成'];
|
|
|
+ $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:s') : '';
|
|
|
+ $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'] = '接单中';
|
|
|
+ $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'] : [];
|
|
|
- $item['goods']['shipper_phone_text'] = $item['goods']['shipper_phone']?format_mobile($item['goods']['shipper_phone']) : '';
|
|
|
- $item['goods']['receiver_phone_text'] = $item['goods']['receiver_phone']?format_mobile($item['goods']['receiver_phone']) : '';
|
|
|
}
|
|
|
unset($item);
|
|
|
}
|
|
|
@@ -108,12 +119,12 @@ class OrderService extends BaseService
|
|
|
public function getQuery($params)
|
|
|
{
|
|
|
$where = ['a.mark' => 1];
|
|
|
- return $this->model->from('orders as a')->with(['goods'])
|
|
|
+ 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){
|
|
|
+ ->where(function ($query) use ($params) {
|
|
|
$userId = isset($params['user_id']) ? intval($params['user_id']) : 0;
|
|
|
- if($userId>0){
|
|
|
+ if ($userId > 0) {
|
|
|
$query->where('a.user_id', $userId);
|
|
|
}
|
|
|
})
|
|
|
@@ -121,7 +132,6 @@ class OrderService extends BaseService
|
|
|
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
|
|
|
if ($keyword) {
|
|
|
$query->where('a.order_no', 'like', "%{$keyword}%")
|
|
|
- ->orWhere('b.nickname', 'like', "%{$keyword}%")
|
|
|
->orWhere('b.mobile', 'like', "%{$keyword}%");
|
|
|
}
|
|
|
});
|
|
|
@@ -133,8 +143,8 @@ class OrderService extends BaseService
|
|
|
*/
|
|
|
public function getOrderInfo($id)
|
|
|
{
|
|
|
- $statusArr = [1 => '待审核', 2 => '进行中', 3 => '已完成'];
|
|
|
- $info = $this->model->from('orders as a')->with(['goods'])
|
|
|
+ $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.*'])
|
|
|
@@ -148,10 +158,6 @@ class OrderService extends BaseService
|
|
|
if ($status) {
|
|
|
$info['status_text'] = isset($statusArr[$status]) ? $statusArr[$status] : '';
|
|
|
}
|
|
|
-
|
|
|
- $info['goods'] = isset($info['goods']) && $info['goods'] ? $info['goods'] : [];
|
|
|
- $info['goods']['shipper_phone_text'] = $info['goods']['shipper_phone']?format_mobile($info['goods']['shipper_phone']) : '';
|
|
|
- $info['goods']['receiver_phone_text'] = $info['goods']['receiver_phone']?format_mobile($info['goods']['receiver_phone']) : '';
|
|
|
}
|
|
|
|
|
|
return $info;
|
|
|
@@ -165,105 +171,115 @@ class OrderService extends BaseService
|
|
|
*/
|
|
|
public function createOrder($userId, $params)
|
|
|
{
|
|
|
- $goodsId = isset($params['goods_id']) && $params['goods_id'] ? intval($params['goods_id']) : 0;
|
|
|
+ $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($goodsId)) {
|
|
|
- $this->error = 2103;
|
|
|
+ if (empty($goods) || empty($ids)) {
|
|
|
+ $this->error = '商品参数不为空';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($addressId <= 0) {
|
|
|
+ $this->error = '请选择收货地址';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 缓存锁
|
|
|
- $cacheLockKey = "caches:orders:submit_lock:{$userId}_{$goodsId}";
|
|
|
+ $cacheLockKey = "caches:orders:submit_lock:{$userId}";
|
|
|
if (RedisService::get($cacheLockKey)) {
|
|
|
- $this->error = 2107;
|
|
|
+ $this->error = '订单处理中~';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 货物信息
|
|
|
- RedisService::set($cacheLockKey, ['params' => $params, 'user_id' => $userId], rand(2, 3));
|
|
|
- $goodsInfo = GoodsModel::where(['id' => $goodsId,'status'=>1, 'mark' => 1])
|
|
|
- ->select(['id','num', 'price','picker_status', 'status'])
|
|
|
- ->first();
|
|
|
- $pickerStatus = isset($goodsInfo['picker_status']) ? $goodsInfo['picker_status'] : 0;
|
|
|
- $price = isset($goodsInfo['price']) ? floatval($goodsInfo['price']) : 0;
|
|
|
- $num = isset($goodsInfo['num']) ? intval($goodsInfo['num']) : 0;
|
|
|
- if(empty($goodsInfo)){
|
|
|
- $this->error = 2201;
|
|
|
+ // 商品数据
|
|
|
+ $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;
|
|
|
}
|
|
|
|
|
|
- if(in_array($pickerStatus,[2,3])){
|
|
|
- $this->error = "220{$pickerStatus}";
|
|
|
+ $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($price<=0){
|
|
|
- $this->error = 2204;
|
|
|
+ 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', 'mobile', 'nickname','realname','deposit','picker_status','confirm_status', 'status'])
|
|
|
+ ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status'])
|
|
|
->first();
|
|
|
$status = isset($userInfo['status']) ? $userInfo['status'] : 0;
|
|
|
- $nickname = isset($userInfo['nickname']) ? $userInfo['nickname'] : '';
|
|
|
- $realname = isset($userInfo['realname']) ? $userInfo['realname'] : '';
|
|
|
- $mobile = isset($userInfo['mobile']) ? $userInfo['mobile'] : '';
|
|
|
- $confirmStatus = isset($userInfo['confirm_status']) ? $userInfo['confirm_status'] : 0;
|
|
|
- $userPickerStatus = isset($userInfo['picker_status']) ? $userInfo['picker_status'] : 0;
|
|
|
- $userDeposit = isset($userInfo['deposit']) ? floatval($userInfo['deposit']) : 0;
|
|
|
- if(empty($userInfo) || $status != 1){
|
|
|
- $this->error = 2016;
|
|
|
+ $openid = isset($userInfo['openid']) ? $userInfo['openid'] : '';
|
|
|
+ if (empty($userInfo) || $status != 1) {
|
|
|
+ $this->error = 1045;
|
|
|
RedisService::clear($cacheLockKey);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 账号审核情况
|
|
|
- if($confirmStatus != 1){
|
|
|
- $this->error = 2042;
|
|
|
+ if (empty($openid)) {
|
|
|
+ $this->error = '用户微信未授权,请重新授权登录';
|
|
|
RedisService::clear($cacheLockKey);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if($userPickerStatus != 1){
|
|
|
- $this->error = 2205;
|
|
|
+ // 收货地址信息
|
|
|
+ $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;
|
|
|
}
|
|
|
|
|
|
- // 缴纳保证金验证
|
|
|
- $depositMoney = ConfigService::make()->getConfigByCode('deposit_money',0);
|
|
|
- if($depositMoney>0 && ($userDeposit < $depositMoney)){
|
|
|
- $this->error = 2206;
|
|
|
- RedisService::clear($cacheLockKey);
|
|
|
- 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;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 订单数据
|
|
|
- $pickerCount = $this->model->where(['goods_id'=> $goodsId,'mark'=>1])->whereIn('status',[1,2])->count('id');
|
|
|
- if($this->model->where(['user_id'=>$userId,'goods_id'=>$goodsId,'mark'=>1])->whereIn('status',[1,2,3])->value('id')){
|
|
|
- $this->error = 2209;
|
|
|
- RedisService::clear($cacheLockKey);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if($this->model->where(['user_id'=>$userId,'mark'=>1])->whereIn('status',[1,2])->value('id')){
|
|
|
- $this->error = 2209;
|
|
|
- RedisService::clear($cacheLockKey);
|
|
|
- return false;
|
|
|
- }
|
|
|
- $bonusRate = ConfigService::make()->getConfigByCode('picker_bonus_rate',100);
|
|
|
- $bonusRate = $bonusRate>0 && $bonusRate<=100? intval($bonusRate) : 100;
|
|
|
- $bonus = moneyFormat($price * $bonusRate/100,2);
|
|
|
- $orderNo = get_order_num('PD');
|
|
|
$order = [
|
|
|
'order_no' => $orderNo,
|
|
|
'user_id' => $userId,
|
|
|
- 'goods_id' => $goodsId,
|
|
|
- 'total' => $price,
|
|
|
+ '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(),
|
|
|
@@ -275,36 +291,409 @@ class OrderService extends BaseService
|
|
|
DB::beginTransaction();
|
|
|
if (!$orderId = $this->model->insertGetId($order)) {
|
|
|
DB::rollBack();
|
|
|
- $this->error = 2207;
|
|
|
+ $this->error = '创建订单失败';
|
|
|
RedisService::clear($cacheLockKey);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $title = "用户【{$realname}-{$mobile}】有新的抢单";
|
|
|
- $message = [
|
|
|
- 'from_uid'=> $userId,
|
|
|
- 'to_uid'=> 1,
|
|
|
- 'op'=> 'notice',
|
|
|
- 'scene'=> 'picker',
|
|
|
- 'message'=> '接单消息',
|
|
|
- 'type'=> 5,
|
|
|
- 'order'=>[
|
|
|
- 'title'=> $title.'<span class="ele-text-primary">查看订单</span>',
|
|
|
- 'order_no'=> $orderNo,
|
|
|
- 'money'=> $bonus,
|
|
|
- 'date'=> date('Y-m-d H:i:s'),
|
|
|
- 'user_id'=> $userId,
|
|
|
- 'type'=> 'deposit',
|
|
|
- 'remark'=> '接单消息',
|
|
|
- ]
|
|
|
+ // 订单商品
|
|
|
+ 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();
|
|
|
- $pickerCount = $pickerCount+1;
|
|
|
- $this->error = lang('2210');
|
|
|
+ $this->error = '订单创建成功,请前往支付~';
|
|
|
RedisService::clear($cacheLockKey);
|
|
|
- RedisService::keyDel("caches:goods:picker*");
|
|
|
- return ['order_id' => $orderId,'message'=>$message, 'total' => $price, 'num' => $pickerCount<=3?3:$pickerCount, 'goods' => $goodsId];
|
|
|
+ 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];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -313,19 +702,19 @@ class OrderService extends BaseService
|
|
|
* @param int $type
|
|
|
* @return array|mixed
|
|
|
*/
|
|
|
- public function getCountByDay($userId, $status=3)
|
|
|
+ public function getCountByDay($userId, $status = 3)
|
|
|
{
|
|
|
$cacheKey = "caches:orders:count_day_{$userId}_{$status}";
|
|
|
$data = RedisService::get($cacheKey);
|
|
|
- if($data){
|
|
|
+ if ($data) {
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- $data = $this->model->where(['user_id'=> $userId,'status'=>$status,'mark'=>1])
|
|
|
- ->where('create_time','>=', strtotime(date('Y-m-d')))
|
|
|
+ $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));
|
|
|
+ if ($data) {
|
|
|
+ RedisService::set($cacheKey, $data, rand(5, 10));
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
@@ -337,18 +726,18 @@ class OrderService extends BaseService
|
|
|
* @param int $status
|
|
|
* @return array|mixed
|
|
|
*/
|
|
|
- public function getCountByStatus($userId, $status=3)
|
|
|
+ public function getCountByStatus($userId, $status = 3)
|
|
|
{
|
|
|
$cacheKey = "caches:orders:count_status_{$userId}_{$status}";
|
|
|
$data = RedisService::get($cacheKey);
|
|
|
- if($data){
|
|
|
+ if ($data) {
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- $data = $this->model->where(['user_id'=> $userId,'status'=>$status,'mark'=>1])
|
|
|
+ $data = $this->model->where(['user_id' => $userId, 'status' => $status, 'mark' => 1])
|
|
|
->count('id');
|
|
|
- if($data){
|
|
|
- RedisService::set($cacheKey, $data, rand(5,10));
|
|
|
+ if ($data) {
|
|
|
+ RedisService::set($cacheKey, $data, rand(5, 10));
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
@@ -363,48 +752,134 @@ class OrderService extends BaseService
|
|
|
{
|
|
|
$cacheKey = "caches:orders:checkOrder:{$userId}";
|
|
|
$data = RedisService::get($cacheKey);
|
|
|
- if($data){
|
|
|
+ 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')
|
|
|
+ $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() : [];
|
|
|
+ $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){
|
|
|
+ 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){
|
|
|
+ } else if ($status == 2) {
|
|
|
$message = "恭喜您,抢单成功,请前往完成订单!";
|
|
|
- }else if($status == 3){
|
|
|
+ } 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;
|
|
|
+ } else {
|
|
|
+ $pickerCount = $this->model->where(['goods_id' => $goodsId, 'mark' => 1])->whereIn('status', [1, 2])->count('id');
|
|
|
+ $pickerCount = $pickerCount <= 3 ? 3 : $pickerCount;
|
|
|
$message = "<p style='padding: 5px 0;'>正在抢单</p><p>({$pickerCount}位师傅正在抢单中)</p>";
|
|
|
}
|
|
|
- $result = ['order_id'=>$orderId,'goods_id'=>$goodsId,'confirm_order_id'=>$confirmOrderId,'status'=>$status, 'message'=> $message];
|
|
|
+ $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;
|
|
|
+
|
|
|
+ }
|
|
|
}
|