|
@@ -262,6 +262,7 @@ class ChatController extends BaseController
|
|
$refer_id = $request->input('refer_id', 0);
|
|
$refer_id = $request->input('refer_id', 0);
|
|
$shop_good_id = $request->input('shop_good_id', 0);
|
|
$shop_good_id = $request->input('shop_good_id', 0);
|
|
$voter_id = _abs(_empty_default_($request->voter_id, 0));
|
|
$voter_id = _abs(_empty_default_($request->voter_id, 0));
|
|
|
|
+ $ask_order_id = _abs(_empty_default_($request->ask_order_id, 0));
|
|
|
|
|
|
if(_empty_($uid) || _empty_($oid)){
|
|
if(_empty_($uid) || _empty_($oid)){
|
|
return $this->fail(200001);
|
|
return $this->fail(200001);
|
|
@@ -299,7 +300,7 @@ class ChatController extends BaseController
|
|
return $this->fail(200000, [], '抱歉,您没有聊天权限');
|
|
return $this->fail(200000, [], '抱歉,您没有聊天权限');
|
|
}
|
|
}
|
|
|
|
|
|
- $model = WxContRepositories::add($uid, $oid, $chat_content, $chat_image, $chat_audio_url, $chat_audio_length, $refer_id, 0, 0, $shop_good_id, null, 0, $voter_id);
|
|
|
|
|
|
+ $model = WxContRepositories::add($uid, $oid, $chat_content, $chat_image, $chat_audio_url, $chat_audio_length, $refer_id, 0, 0, $shop_good_id, null, 0, $voter_id,$ask_order_id); //通用聊天
|
|
|
|
|
|
if($model){
|
|
if($model){
|
|
$websocket_id = GatewayUtils::uid2client_id($oid);
|
|
$websocket_id = GatewayUtils::uid2client_id($oid);
|
|
@@ -370,6 +371,7 @@ class ChatController extends BaseController
|
|
$query->where('user_id', $oid)
|
|
$query->where('user_id', $oid)
|
|
->where('object_id', $uid);
|
|
->where('object_id', $uid);
|
|
})
|
|
})
|
|
|
|
+ ->where('expand_type','!=',9) //排除问答聊天,因为要独立
|
|
->orderByRaw('id DESC')
|
|
->orderByRaw('id DESC')
|
|
->simplePaginate($limit);
|
|
->simplePaginate($limit);
|
|
|
|
|
|
@@ -420,6 +422,10 @@ class ChatController extends BaseController
|
|
}else if($v->expand_type == 8){
|
|
}else if($v->expand_type == 8){
|
|
$v->mode = 'voter';
|
|
$v->mode = 'voter';
|
|
$v->voter_id = $v->expand_id;
|
|
$v->voter_id = $v->expand_id;
|
|
|
|
+ }else if($v->expand_type == 9){
|
|
|
|
+ //仅占用
|
|
|
|
+ $v->mode = 'ask_order';
|
|
|
|
+ $v->ask_order_id = $v->expand_id;
|
|
}else if(in_array($v->expand_type, [101, 102, 103, 104, 105, 106, 107, 108, 109, 110])){
|
|
}else if(in_array($v->expand_type, [101, 102, 103, 104, 105, 106, 107, 108, 109, 110])){
|
|
$v->mode = 'review';
|
|
$v->mode = 'review';
|
|
}else{
|
|
}else{
|
|
@@ -692,6 +698,10 @@ class ChatController extends BaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(!_empty_($v->ask_order_id)){
|
|
|
|
+ //仅占用
|
|
|
|
+ }
|
|
|
|
+
|
|
if(!_empty_($v->shop_good_id)){
|
|
if(!_empty_($v->shop_good_id)){
|
|
$data = WxShopGoods::where('id', $v->shop_good_id)->first()->toArray();
|
|
$data = WxShopGoods::where('id', $v->shop_good_id)->first()->toArray();
|
|
if($data) {
|
|
if($data) {
|
|
@@ -788,6 +798,78 @@ class ChatController extends BaseController
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 查询用户问答订单聊天记录
|
|
|
|
+ * @param Request $request
|
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
|
+ */
|
|
|
|
+ public function getUserAskOrderChat(Request $request, $limit = 6)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $uid = $request->uid;
|
|
|
|
+ $oid = $request->oid;
|
|
|
|
+ $ask_order_id = $request->ask_order_id;
|
|
|
|
+
|
|
|
|
+ if(_empty_($uid) || _empty_($oid)){
|
|
|
|
+ return $this->fail(200001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $data = WxChat::where(function ($query) use ($uid, $oid) {
|
|
|
|
+ $query->where('user_id', $uid)
|
|
|
|
+ ->where('object_id', $oid);
|
|
|
|
+ })
|
|
|
|
+ ->orWhere(function ($query) use ($uid, $oid) {
|
|
|
|
+ $query->where('user_id', $oid)
|
|
|
|
+ ->where('object_id', $uid);
|
|
|
|
+ })
|
|
|
|
+ ->where('expand_type',9) //只要问答订单的
|
|
|
|
+ ->where('expand_id',$ask_order_id) //只要问答订单的
|
|
|
|
+ ->orderByRaw('id DESC')
|
|
|
|
+ ->simplePaginate($limit);
|
|
|
|
+
|
|
|
|
+ $data->map(function ($v) use ($uid){
|
|
|
|
+ $v->type = 'user';
|
|
|
|
+ $imgList = array();
|
|
|
|
+ array_push($imgList, ['img_url' => $v->chat_image]);
|
|
|
|
+ $v->imgList = $imgList;
|
|
|
|
+ $v->user = WxUser::where('id', $v->user_id)->first(FieldUtils::userInfoColums());
|
|
|
|
+ $v->datetime = format_datetime($v->created_at);
|
|
|
|
+
|
|
|
|
+ if($v->chat_audio_url && $v->chat_audio_length){
|
|
|
|
+ $v->mode = 'audio';
|
|
|
|
+ }else if($v->chat_image){
|
|
|
|
+ $v->mode = 'img';
|
|
|
|
+ }else{
|
|
|
|
+ $v->mode = 'text';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!_empty_($v->chat_audio_length)){
|
|
|
|
+ $min = (int)($v->chat_audio_length / 60);
|
|
|
|
+ if($min < 10){
|
|
|
|
+ $min = '0'.$min;
|
|
|
|
+ }
|
|
|
|
+ $sec = $v->chat_audio_length % 60;
|
|
|
|
+ if($sec < 10){
|
|
|
|
+ $sec = '0'.$sec;
|
|
|
|
+ }
|
|
|
|
+ $v->chat_audio_length = $min.':'.$sec;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $allowable[] = [
|
|
|
|
+ 'text' => '复制',
|
|
|
|
+ 'type' => 'copy',
|
|
|
|
+ 'id' => $v->id,
|
|
|
|
+ 'raw' => strip_tags($v->chat_content),
|
|
|
|
+ 'icon' => 'mini-icon mini-fuzhi'
|
|
|
|
+ ];
|
|
|
|
+ $v->allowable = $allowable;
|
|
|
|
+
|
|
|
|
+ return $v;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return $this->success($data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 已读对应用户信息
|
|
* 已读对应用户信息
|
|
* @param Request $request
|
|
* @param Request $request
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @return \Illuminate\Http\JsonResponse
|