| xqd
@@ -152,6 +152,20 @@ class ProductController extends Controller
|
|
|
if(!$res){
|
|
|
return $this->error("上传失败!");
|
|
|
}
|
|
|
+ $follow = UserFollow::query()->where('to_user_id',$this->userId)->pluck('user_id')->toArray();
|
|
|
+ if(!empty($follow)){
|
|
|
+ $user = User::query()->where('id',$this->userId)->first();
|
|
|
+ foreach ($follow as $v){
|
|
|
+ $msg = [
|
|
|
+ 'type' => 5,//关注的人发了新作品
|
|
|
+ 'title' => "关注的人发了新作品",
|
|
|
+ 'content' => " 您关注的".$user->name."上传了1张图片",
|
|
|
+ 'user_id' => $this->userId,
|
|
|
+ 'to_user_id' => $v,
|
|
|
+ ];
|
|
|
+ Msg::query()->create($msg); // 添加通知消息
|
|
|
+ }
|
|
|
+ }
|
|
|
return $this->success($res);
|
|
|
|
|
|
}
|
| xqd
@@ -174,7 +188,7 @@ class ProductController extends Controller
|
|
|
/**
|
|
|
* @param Request $request
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
- * 产品列
|
|
|
+ * 产品列表
|
|
|
*/
|
|
|
public function productList(Request $request){
|
|
|
$limit = $request->get('limit',10);
|
| xqd
@@ -263,6 +277,30 @@ class ProductController extends Controller
|
|
|
if(!$res){
|
|
|
return $this->error("收藏失败!");
|
|
|
}
|
|
|
+ $user = User::query()->where('id',$this->userId)->first();
|
|
|
+ $product_type = ProductType::query()->whereIn('id',$product['type'])->select('id','zh_name','ko_name')->first();
|
|
|
+ $type_name = '';
|
|
|
+ if(!empty($product_type)){
|
|
|
+ $type_name = $product_type['zh_name'];
|
|
|
+ }
|
|
|
+ $msg = [
|
|
|
+ 'type' => 2,//喜欢通知
|
|
|
+ 'title' => "下载通知",
|
|
|
+ 'content' => "您收藏了".$type_name."中的1张图片",
|
|
|
+ 'user_id' => $this->userId,
|
|
|
+ 'to_user_id' => $this->userId,
|
|
|
+ ];
|
|
|
+ Msg::query()->create($msg); // 添加通知消息
|
|
|
+
|
|
|
+ $msg1 = [
|
|
|
+ 'type' => 3,//喜欢通知
|
|
|
+ 'title' => "保存通知",
|
|
|
+ 'content' => $user->name."收藏了您".$type_name."中的1张图片",
|
|
|
+ 'user_id' => $this->userId,
|
|
|
+ 'to_user_id' => $product['user_id'],
|
|
|
+ ];
|
|
|
+ Msg::query()->create($msg1); // 添加通知消息
|
|
|
+
|
|
|
return $this->success();
|
|
|
}
|
|
|
|
| xqd
@@ -289,7 +327,7 @@ class ProductController extends Controller
|
|
|
public function addLike(Request $request){
|
|
|
$product = Product::query()->where('id',$request->get('product_id'))->first();
|
|
|
if(!$product){
|
|
|
- return $this->error("商品不存在!");
|
|
|
+ return $this->error("数据不存在!");
|
|
|
}
|
|
|
$collect = UserLike::query()->where('product_id',$product->id)->where('user_id',$this->userId)->first();
|
|
|
if($collect){
|
| xqd
@@ -303,20 +341,20 @@ class ProductController extends Controller
|
|
|
if(!$res){
|
|
|
return $this->error("操作失败!");
|
|
|
}
|
|
|
-// dd($product['type']);
|
|
|
-// $user = User::query()->where('id',$this->userId)->first();
|
|
|
-// $product_type = ProductType::query()->whereIn('id',$product['type'])->value('name');
|
|
|
-// dd($product_type);
|
|
|
-// $msg = [
|
|
|
-// 'type' => 1,//喜欢通知
|
|
|
-// 'title' => "喜欢通知",
|
|
|
-//// 'content' => $user->name."点赞了您".12."中的xxx(数量)张图片",
|
|
|
-// 'user_id' => $this->userId,
|
|
|
-// 'to_user_id' => $product['user_id']
|
|
|
-// ];
|
|
|
-//
|
|
|
-// dd($product);
|
|
|
-// $msg = Msg::query()->create();
|
|
|
+ $user = User::query()->where('id',$this->userId)->first();
|
|
|
+ $product_type = ProductType::query()->whereIn('id',$product['type'])->select('id','zh_name','ko_name')->first();
|
|
|
+ $type_name = '';
|
|
|
+ if(!empty($product_type)){
|
|
|
+ $type_name = $product_type['zh_name'];
|
|
|
+ }
|
|
|
+ $msg = [
|
|
|
+ 'type' => 1,//喜欢通知
|
|
|
+ 'title' => "喜欢通知",
|
|
|
+ 'content' => $user->name."点赞了您".$type_name."中的1张图片",
|
|
|
+ 'user_id' => $this->userId,
|
|
|
+ 'to_user_id' => $product['user_id']
|
|
|
+ ];
|
|
|
+ Msg::query()->create($msg); // 添加通知消息
|
|
|
|
|
|
return $this->success();
|
|
|
}
|