|
|
@@ -84,7 +84,6 @@ class ItemService extends BaseService
|
|
|
$data['hjAddPrice'] = $ptItem['hjAddPrice'] ?? 0;
|
|
|
$data['zsAddPrice'] = $ptItem['zsAddPrice'] ?? 0;
|
|
|
|
|
|
- ItemClass::add($data);
|
|
|
$shopIds = ShopService::getShopIds($sjId);
|
|
|
if (empty($shopIds)) {
|
|
|
util::fail("没有找到门店");
|
|
|
@@ -105,7 +104,6 @@ class ItemService extends BaseService
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- ItemClass::batchAdd($data);
|
|
|
ProductClass::batchAdd($data);
|
|
|
$transaction->commit();
|
|
|
} catch (\Exception $exception) {
|
|
|
@@ -114,71 +112,6 @@ class ItemService extends BaseService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //修改花材信息
|
|
|
- public static function updateGshItem($data)
|
|
|
- {
|
|
|
- $id = $data['id'] ?? 0;
|
|
|
- $stockWarning = $data['stockWarning'] ?? 0;
|
|
|
- $addPrice = $data['addPrice'] ?? 0;
|
|
|
- $weight = $data['weight'] ?? 0;
|
|
|
- $cost = $data['cost'] ?? 0; //成本价
|
|
|
- if ($stockWarning < 0) {
|
|
|
- util::fail("库存预警不能小于0");
|
|
|
- }
|
|
|
- if ($addPrice < 0) {
|
|
|
- util::fail("每扎加价不能小于0");
|
|
|
- }
|
|
|
- if ($weight < 0) {
|
|
|
- // util::fail("每扎重量不能小于0");
|
|
|
- }
|
|
|
- if ($cost < 0) {
|
|
|
- util::fail("成本价不能小于0");
|
|
|
- }
|
|
|
-
|
|
|
- $model = self::getById($id);
|
|
|
- if (!$model) {
|
|
|
- util::fail("该花材不存在");
|
|
|
- }
|
|
|
- if ($model['sjId'] !== $data['sjId']) {
|
|
|
- util::fail("参数错误");
|
|
|
- }
|
|
|
-
|
|
|
- ItemClass::updateGshItem($id, $stockWarning, $addPrice, $weight, $cost);
|
|
|
- }
|
|
|
-
|
|
|
- //删除花材,同时修改itemInfo 的状态值 delStatus = 1
|
|
|
- public static function deleteGhsItem($id, $shopId, $sjId, $adminId)
|
|
|
- {
|
|
|
- $model = ItemClass::getById($id);
|
|
|
- if (!$model) {
|
|
|
- util::fail("该花材不存在");
|
|
|
- }
|
|
|
- if ($model['sjId'] !== $sjId) {
|
|
|
- util::fail("参数错误");
|
|
|
- }
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- ItemClass::deleteGhsItem($id);
|
|
|
- $condition = [
|
|
|
- 'itemId' => $model['itemId'],
|
|
|
- 'shopId' => $shopId,
|
|
|
- ];
|
|
|
- ProductClass::updateByCondition($condition, ['delStatus' => 1, 'adminId' => $adminId]);
|
|
|
- $transaction->commit();
|
|
|
- } catch (\Exception $exception) {
|
|
|
- $transaction->rollBack();
|
|
|
- util::fail("操作失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //获取所有的花材ID
|
|
|
- public static function getGhsItemIds($sjId)
|
|
|
- {
|
|
|
- $data = ItemClass::getGhsItemAll($sjId, 'classId,itemId');
|
|
|
- return $data;
|
|
|
- }
|
|
|
-
|
|
|
//初始化 花材 ghsItemClass, ghsItem ghsProduct linqh 2021.4.12 modify shish 20210711
|
|
|
public static function initItem($sjId, $shopId)
|
|
|
{
|
|
|
@@ -262,7 +195,6 @@ class ItemService extends BaseService
|
|
|
if (empty($itemAddData)) {
|
|
|
continue;
|
|
|
}
|
|
|
- ItemClass::batchAdd($itemAddData);
|
|
|
ProductClass::batchAdd($productAddData);
|
|
|
|
|
|
}
|