|
|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
namespace bizGhs\item\services;
|
|
|
|
|
|
+use biz\item\classes\PtItemClass;
|
|
|
use bizGhs\base\services\BaseService;
|
|
|
use bizGhs\item\classes\ItemClass;
|
|
|
use bizGhs\item\classes\ItemClassClass;
|
|
|
@@ -26,6 +27,8 @@ class ItemService extends BaseService
|
|
|
$merchantId = $data['merchantId']??0;
|
|
|
$classId = $data['classId']??0;
|
|
|
$itemId = $data['itemId']??0;
|
|
|
+ $cost = $data['cost']??false;
|
|
|
+ $addPrice = $data['addPrice']??false;
|
|
|
//$shopId = $data['shopId']??0;
|
|
|
if(!$merchantId ){
|
|
|
util::fail("请选择供应商");
|
|
|
@@ -36,8 +39,18 @@ class ItemService extends BaseService
|
|
|
if(!$itemId){
|
|
|
util::fail("请选择花材");
|
|
|
}
|
|
|
+ if($cost===false){
|
|
|
+ util::fail("请输入花材的成本价");
|
|
|
+ }
|
|
|
+ if($addPrice===false){
|
|
|
+ util::fail("请输入花材的加价");
|
|
|
+ }
|
|
|
+
|
|
|
//判断花材是否存在 调用平台花材的方法
|
|
|
- //todo
|
|
|
+ $checkItem = PtItemClass::getById($itemId);
|
|
|
+ if(!$checkItem){
|
|
|
+ util::fail("花材不存在");
|
|
|
+ }
|
|
|
|
|
|
$existItemClass = ItemClassClass::exists(['id'=>$classId,'merchantId'=>$merchantId]);
|
|
|
if(!$existItemClass){
|
|
|
@@ -60,6 +73,11 @@ class ItemService extends BaseService
|
|
|
}
|
|
|
foreach ($shopIds as $shopId){
|
|
|
$data['shopId'] = $shopId;
|
|
|
+ //判断product 是否存在,若存在,则不再处理
|
|
|
+ $existItem = ProductClass::exists(['itemId'=>$itemId,'merchantId'=>$merchantId,'shopId'=>$shopId]);
|
|
|
+ if($existItem){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
ProductClass::add($data);
|
|
|
}
|
|
|
$transaction->commit();
|