|
|
@@ -9,6 +9,7 @@ namespace app\admin\model\system;
|
|
|
use crmeb\services\upload\Upload;
|
|
|
use crmeb\traits\ModelTrait;
|
|
|
use crmeb\basic\BaseModel;
|
|
|
+use app\models\store\StoreProduct as StoreProductModel;
|
|
|
|
|
|
/**
|
|
|
* 文件检验model
|
|
|
@@ -160,4 +161,31 @@ class SystemAttachment extends BaseModel
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ 根据 商品 ID 找到商品图片,再根据任意一张图片找到商品图片的分类ID和父ID
|
|
|
+ select esa.pid as id, esac.pid from eb_system_attachment esa
|
|
|
+left join eb_system_attachment_category esac
|
|
|
+on esa.pid = esac.id
|
|
|
+where esa.att_dir = 'http://twongpicd.shotshock.shop/606882670534/澳乐月亮围栏6+2_1.jpg'
|
|
|
+
|
|
|
+ @return: ['pid'=>int, 'ppid'=>int]
|
|
|
+ */
|
|
|
+ public static function getPidByProductId($productId)
|
|
|
+ {
|
|
|
+ $model = new self;
|
|
|
+ $res = StoreProductModel::where('id', $productId)->field('image,slider_image')->select()->toArray();
|
|
|
+ if ($res) {
|
|
|
+ $image=$res[0]['image'];
|
|
|
+ if(!$image){
|
|
|
+ $arr = $res[0]['slider_image'];
|
|
|
+ if($arr) {
|
|
|
+ $image = $arr[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $ids = $model::alias('a')->field('a.pid, c.pid as ppid')->join('SystemAttachmentCategory c', 'c.id=a.pid')
|
|
|
+ ->where('a.att_dir', $image)->find();
|
|
|
+ return $ids ? $ids->toArray() : ['pid'=>0, 'ppid'=>0];
|
|
|
+ }
|
|
|
}
|