|
|
@@ -7,6 +7,7 @@ use biz\item\classes\PtItemClass;
|
|
|
|
|
|
use bizGhs\item\classes\ItemClass;
|
|
|
use bizGhs\item\services\ItemService;
|
|
|
+use bizHd\product\classes\ProductClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -14,6 +15,54 @@ use Yii;
|
|
|
class ItemController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //增加和减少半扎 ssh 20250417
|
|
|
+ public function actionChangeHalf()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $productId = $post['productId'] ?? '';
|
|
|
+ $add = $post['add'] ?? 0;
|
|
|
+ $remark = $post['remark'] ?? '';
|
|
|
+ $product = ProductClass::getLockById($productId);
|
|
|
+ if (empty($product)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($product->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的花材');
|
|
|
+ }
|
|
|
+ if ($product->ratioType == 1) {
|
|
|
+ util::fail('若干扎的花材不能减半份');
|
|
|
+ }
|
|
|
+
|
|
|
+ //避免重复提交
|
|
|
+ util::checkRepeatCommit($this->adminId, 5);
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $shop = $this->shop;
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $staffId = $staff->id;
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ $params = [
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'adminId' => $adminId,
|
|
|
+ 'remark' => $remark,
|
|
|
+ ];
|
|
|
+ ItemClass::modifyHalf($shop, $product, $params, $add);
|
|
|
+ $product = ProductClass::getLockById($productId);
|
|
|
+ $stock = $product->stock;
|
|
|
+ $stock = floatval($stock);
|
|
|
+ $transaction->commit();
|
|
|
+ util::success(['stock' => $stock]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("加减半份失败原因:" . $e->getMessage());
|
|
|
+ util::fail('加减半份失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//检测是否要刷新
|
|
|
public function actionCheckRefresh()
|
|
|
{
|