|
|
@@ -13,6 +13,32 @@ class KindClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\goods\models\Kind';
|
|
|
|
|
|
+ public static function addData($post)
|
|
|
+ {
|
|
|
+ $name = $post['name'] ?? '';
|
|
|
+ $name = trim($name);
|
|
|
+ $mainId = $post['mainId'] ?? 0;
|
|
|
+ $list = self::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
|
|
|
+ if (!empty($list)) {
|
|
|
+ $has = false;
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $hasName = $item->name ?? '';
|
|
|
+ if ($hasName == $name) {
|
|
|
+ $delStatus = $item->delStatus ?? 0;
|
|
|
+ if ($delStatus == 0) {
|
|
|
+ util::fail('名称已经存在');
|
|
|
+ }
|
|
|
+ $item->delStatus = 0;
|
|
|
+ $item->save();
|
|
|
+ $has = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($has == false) {
|
|
|
+ self::add($post, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function getKindList($mainId)
|
|
|
{
|
|
|
$where = ['mainId' => $mainId, 'delStatus' => 0];
|