|
@@ -664,6 +664,82 @@ class OrderService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 订单提醒发货
|
|
|
|
|
+ * @param $userId
|
|
|
|
|
+ * @param $orderId
|
|
|
|
|
+ * @return array|false
|
|
|
|
|
+ */
|
|
|
|
|
+ public function tips($userId, $orderId)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($orderId <= 0) {
|
|
|
|
|
+ $this->error = '请选择订单';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 缓存锁
|
|
|
|
|
+ $cacheLockKey = "caches:orders:tips_lock:{$userId}_{$orderId}";
|
|
|
|
|
+ if (RedisService::get($cacheLockKey)) {
|
|
|
|
|
+ $this->error = '请不要频繁操作~';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RedisService::set($cacheLockKey, ['order_id' => $orderId, '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;
|
|
|
|
|
+ $nickname = isset($userInfo['nickname']) ? $userInfo['nickname'] : '';
|
|
|
|
|
+ if (empty($userInfo) || $status != 1) {
|
|
|
|
|
+ $this->error = 1045;
|
|
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 订单信息
|
|
|
|
|
+ $info = $this->model->where(['id' => $orderId, 'mark' => 1])
|
|
|
|
|
+ ->select(['id', 'order_no','store_id', 'pay_total','tips_status', 'status'])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ $orderNo = isset($info['order_no']) ? $info['order_no'] : '';
|
|
|
|
|
+ $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
|
|
+ $tipsStatus = isset($info['tips_status']) ? $info['tips_status'] : 0;
|
|
|
|
|
+ if (empty($info) || empty($orderNo)) {
|
|
|
|
|
+ $this->error = '订单信息不存在';
|
|
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($tipsStatus ==1){
|
|
|
|
|
+ $this->error = '已经提醒过';
|
|
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($status != 2) {
|
|
|
|
|
+ $this->error = '订单状态不可操作';
|
|
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->error = '订单提醒发货成功';
|
|
|
|
|
+ $this->model->where(['id' => $orderId])->update(['tips_status' => 1, 'update_time' => time()]);
|
|
|
|
|
+ $msgData = [
|
|
|
|
|
+ 'from_uid'=> $userId,
|
|
|
|
|
+ 'type'=> 4,
|
|
|
|
|
+ 'title'=>'互动消息',
|
|
|
|
|
+ 'description'=> "用户{$nickname}提醒了您,希望您尽快发货",
|
|
|
|
|
+ 'content'=> json_encode(['source_id'=>$orderId,'page'=>'/pagesSub/pages/order/detail?no='.$orderNo]),
|
|
|
|
|
+ 'msg_type'=>4,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ // 互动消息
|
|
|
|
|
+ MessageService::make()->pushMessage(1, $msgData);
|
|
|
|
|
+
|
|
|
|
|
+ return ['id' => $orderId];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 订单完成
|
|
* 订单完成
|
|
|
* @param $userId 订单用户ID
|
|
* @param $userId 订单用户ID
|
|
|
* @param $id 订单ID
|
|
* @param $id 订单ID
|
|
@@ -1071,8 +1147,4 @@ class OrderService extends BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getNewsOrder($limit = 30)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|