Commit 06e13e25 authored by luhongguang's avatar luhongguang

update:检查商品名

parent 41919cd2
...@@ -5,17 +5,19 @@ namespace Validate; ...@@ -5,17 +5,19 @@ namespace Validate;
/** /**
* Class StoresListValidate * Class CheckGoodsNameValidate
* *
* @package Validate * @package Validate
*/ */
class StoresListValidate extends BaseValidate class CheckGoodsNameValidate extends BaseValidate
{ {
protected $rule = [ protected $rule = [
'name' => 'require',
'life_account_id' => 'require', 'life_account_id' => 'require',
]; ];
protected $message = [ protected $message = [
"name" => "商品名不能为空",
"life_account_id" => "生活号id不能为空", "life_account_id" => "生活号id不能为空",
]; ];
} }
\ No newline at end of file
<?php
namespace Validate;
/**
* Class EditSetmealValidate
*
* @package Validate
*/
class EditSetmealValidate extends BaseValidate
{
protected $rule = [
'life_account_id' => 'require',
'good_sku_id' => 'require',
'setmeal_data' => 'require',
];
protected $message = [
"life_account_id" => "生活号id不能为空",
"good_sku_id" => "商品id不能为空",
"setmeal_data" => "套餐数据不能为空",
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class EditStoresValidate
*
* @package Validate
*/
class EditStoresValidate extends BaseValidate
{
protected $rule = [
'life_account_id' => 'require',
'name' => 'require',
'address_lng' => 'require',
'address_lat' => 'require',
'address' => 'require',
'phone' => 'require',
];
protected $message = [
"life_account_id" => "生活号id不能为空",
"name" => "门店名称不能为空",
"address_lng" => "门店位置经度不能为空",
"address_lat" => "门店位置纬度不能为空",
"address" => "门店地址不能为空",
"phone" => "门店电话不能为空",
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class SetmealListValidate
*
* @package Validate
*/
class SetmealListValidate extends BaseValidate
{
protected $rule = [
'goods_sku_id' => 'require',
];
protected $message = [
"goods_sku_id" => "商品id不能为空",
];
}
\ No newline at end of file
...@@ -3,12 +3,7 @@ ...@@ -3,12 +3,7 @@
use App\Base\Base; use App\Base\Base;
use App\Services\goods\GoodsService; use App\Services\goods\GoodsService;
use App\Services\goods\CategoryService; use App\Services\goods\CategoryService;
use App\Services\goods\StoresService; use \Validate\CheckGoodsNameValidate;
use App\Services\goods\SetmealService;
use \Validate\EditStoresValidate;
use \Validate\StoresListValidate;
use \Validate\EditSetmealValidate;
use \Validate\SetmealListValidate;
use \Validate\GoodsAuditValidate; use \Validate\GoodsAuditValidate;
...@@ -96,7 +91,11 @@ class GoodsController extends Base ...@@ -96,7 +91,11 @@ class GoodsController extends Base
*/ */
public function check_goods_nameAction() public function check_goods_nameAction()
{ {
(new CheckGoodsNameValidate())->validate();
$params = $this->params;
$res = GoodsService::checkGoodsName($params["name"], $params["life_account_id"]);
$this->success(["data"=>$res]);
} }
/** /**
......
...@@ -157,7 +157,6 @@ class GoodsService ...@@ -157,7 +157,6 @@ class GoodsService
"shop_id" => $shopId, "shop_id" => $shopId,
"life_account_id" => $lifeAccountId, "life_account_id" => $lifeAccountId,
"merchant_id" => $lifeAccount["merchant_id"], "merchant_id" => $lifeAccount["merchant_id"],
"name" => $lifeAccount["life_account_name"],
"status" => Shop::STATUS_ONLINE, "status" => Shop::STATUS_ONLINE,
]); ]);
} else { } else {
...@@ -296,8 +295,19 @@ class GoodsService ...@@ -296,8 +295,19 @@ class GoodsService
return true; return true;
} }
public static function checkGoodsName($goodsName) /**
* 商品名是否可用
* @param $goodsName
* @param $lifeAccountId
* @return bool
*/
public static function checkGoodsName($goodsName, $lifeAccountId)
{ {
$sku = GoodsSpu::get("*", ["name" => $goodsName, "life_account_id" => $lifeAccountId]);
$nameCanUse = false;
if (empty($sku)) {
$nameCanUse = true;
}
return ["can_use" => $nameCanUse];
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment