|
|
@@ -3,6 +3,7 @@
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
use biz\item\classes\PtItemClass;
|
|
|
+use biz\item\classes\UnitClass;
|
|
|
use biz\shop\classes\ShopExtClass;
|
|
|
use bizGhs\book\classes\BookItemClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
@@ -21,6 +22,168 @@ use Yii;
|
|
|
class ItemController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ public function actionModifyWeight()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? '';
|
|
|
+ $weight = $get['weight'] ?? 1;
|
|
|
+ if ($weight <= 0) {
|
|
|
+ util::fail('重量不能小于0');
|
|
|
+ }
|
|
|
+ $item = ItemClass::getById($id, true);
|
|
|
+ if (empty($item)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($item->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的花材');
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ $ptItemId = $item->itemId ?? 0;
|
|
|
+ $hasRightChange = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
|
|
|
+ if ($hasRightChange == 0) {
|
|
|
+ util::fail('不能修改');
|
|
|
+ }
|
|
|
+ $ptItem = PtItemClass::getById($ptItemId, true);
|
|
|
+ if (empty($ptItem)) {
|
|
|
+ util::fail('花材信息缺失');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $ptItem->weight = $weight;
|
|
|
+ $ptItem->save();
|
|
|
+ ItemClass::updateByCondition(['itemId' => $ptItemId], ['weight' => $weight]);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("修改失败原因:" . $e->getMessage());
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionModifyRatio()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? '';
|
|
|
+ $ratio = $get['ratio'] ?? 20;
|
|
|
+ if ($ratio < 1) {
|
|
|
+ util::fail('单位比不能小于1');
|
|
|
+ }
|
|
|
+ $item = ItemClass::getById($id, true);
|
|
|
+ if (empty($item)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($item->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的花材');
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ $ptItemId = $item->itemId ?? 0;
|
|
|
+ $hasRightChange = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
|
|
|
+ if ($hasRightChange == 0) {
|
|
|
+ util::fail('不能修改');
|
|
|
+ }
|
|
|
+ $ptItem = PtItemClass::getById($ptItemId, true);
|
|
|
+ if (empty($ptItem)) {
|
|
|
+ util::fail('花材信息缺失');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $ptItem->ratio = $ratio;
|
|
|
+ $ptItem->save();
|
|
|
+ ItemClass::updateByCondition(['itemId' => $ptItemId], ['ratio' => $ratio]);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("修改失败原因:" . $e->getMessage());
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionModifyBigUnit()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? '';
|
|
|
+ $unitId = $get['unitId'] ?? 1;
|
|
|
+ $unit = UnitClass::getById($unitId, true);
|
|
|
+ if (empty($unit)) {
|
|
|
+ util::fail('没有找到单位');
|
|
|
+ }
|
|
|
+ $unitName = $unit->name;
|
|
|
+ $item = ItemClass::getById($id, true);
|
|
|
+ if (empty($item)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($item->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的花材');
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ $ptItemId = $item->itemId ?? 0;
|
|
|
+ $hasRightChange = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
|
|
|
+ if ($hasRightChange == 0) {
|
|
|
+ util::fail('不能修改');
|
|
|
+ }
|
|
|
+ $ptItem = PtItemClass::getById($ptItemId, true);
|
|
|
+ if (empty($ptItem)) {
|
|
|
+ util::fail('花材信息缺失');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $ptItem->bigUnit = $unitName;
|
|
|
+ $ptItem->bigUnitId = $unitId;
|
|
|
+ $ptItem->save();
|
|
|
+ ItemClass::updateByCondition(['itemId' => $ptItemId], ['bigUnit' => $unitName, 'bigUnitId' => $unitId]);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("修改失败原因:" . $e->getMessage());
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionModifySmallUnit()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? '';
|
|
|
+ $unitId = $get['unitId'] ?? 1;
|
|
|
+ $unit = UnitClass::getById($unitId, true);
|
|
|
+ if (empty($unit)) {
|
|
|
+ util::fail('没有找到单位');
|
|
|
+ }
|
|
|
+ $unitName = $unit->name;
|
|
|
+ $item = ItemClass::getById($id, true);
|
|
|
+ if (empty($item)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($item->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的花材');
|
|
|
+ }
|
|
|
+ $adminId = $this->adminId;
|
|
|
+ $ptItemId = $item->itemId ?? 0;
|
|
|
+ $hasRightChange = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
|
|
|
+ if ($hasRightChange == 0) {
|
|
|
+ util::fail('不能修改');
|
|
|
+ }
|
|
|
+ $ptItem = PtItemClass::getById($ptItemId, true);
|
|
|
+ if (empty($ptItem)) {
|
|
|
+ util::fail('花材信息缺失');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $ptItem->smallUnit = $unitName;
|
|
|
+ $ptItem->smallUnitId = $unitId;
|
|
|
+ $ptItem->save();
|
|
|
+ ItemClass::updateByCondition(['itemId' => $ptItemId], ['smallUnit' => $unitName, 'smallUnitId' => $smallUnitId]);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("修改失败原因:" . $e->getMessage());
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//挪到处理区 ssh 20250418
|
|
|
public function actionMoveToLosing()
|
|
|
{
|