|
|
@@ -101,6 +101,7 @@ class WorkController extends BaseController
|
|
|
$post['sjId'] = $this->sjId ?? 0;
|
|
|
$post['shopId'] = $this->shopId ?? 0;
|
|
|
$orderSn = orderSn::getWorkSn();
|
|
|
+ $mainId = $this->mainId;
|
|
|
$post['workSn'] = $orderSn;
|
|
|
$post['staffId'] = $this->shopAdminId;
|
|
|
$post['staffName'] = $this->shopAdmin->name;
|
|
|
@@ -119,11 +120,25 @@ class WorkController extends BaseController
|
|
|
}
|
|
|
$post['num'] = isset($post['num']) && $post['num'] > 0 ? $post['num'] : 1;
|
|
|
|
|
|
- $catId = $post['catId'] ?? 0;
|
|
|
- $cat = CategoryClass::getById($catId, true);
|
|
|
- if ($cat->mainId != $this->mainId) {
|
|
|
- util::fail('请选择你自己的分类');
|
|
|
+ $default = CategoryClass::getByCondition(['mainId' => $mainId, 'flower' => 1, 'default' => 1], true);
|
|
|
+ if (empty($default)) {
|
|
|
+ $catData = [
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'sjId' => $this->sjId,
|
|
|
+ 'shopId' => $this->shopId,
|
|
|
+ 'default' => 1,
|
|
|
+ 'flower' => 1,
|
|
|
+ 'categoryName' => '未分类',
|
|
|
+ 'inTurn' => 0,
|
|
|
+ 'status' => 0,
|
|
|
+ ];
|
|
|
+ $default = CategoryClass::add($catData, true);
|
|
|
}
|
|
|
+ $catId = $default->id ?? 0;
|
|
|
+ if (empty($catId)) {
|
|
|
+ util::fail('没有找到分类');
|
|
|
+ }
|
|
|
+
|
|
|
$post['catName'] = $cat->categoryName ?? '';
|
|
|
$main = $this->main;
|
|
|
$work = WorkClass::createFinish($post, $main);
|