|
|
@@ -4,6 +4,7 @@ namespace hd\controllers;
|
|
|
|
|
|
use bizGhs\order\classes\StockWastageOrderClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
+use bizHd\wastage\classes\WastageClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -13,6 +14,43 @@ class WastageController extends BaseController
|
|
|
|
|
|
public $guestAccess = [];
|
|
|
|
|
|
+ //成品报损 ssh 20220424
|
|
|
+ public function actionGoodsWastage()
|
|
|
+ {
|
|
|
+ $shopAdmin = $this->shopAdmin;
|
|
|
+ if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
|
|
|
+ util::fail('超管才能报损');
|
|
|
+ }
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $post['sjId'] = $this->sjId;
|
|
|
+ $post['mainId'] = $this->mainId;
|
|
|
+ $post['shopAdminId'] = $this->shopAdminId;
|
|
|
+ $shopAdmin = $this->shopAdmin;
|
|
|
+ $adminName = $shopAdmin['name'] ?? '';
|
|
|
+ $post['shopAdminName'] = $adminName;
|
|
|
+ $goodsJson = $post['goodsList'] ?? '';
|
|
|
+ if (empty($goodsJson)) {
|
|
|
+ util::fail('请选择成品');
|
|
|
+ }
|
|
|
+ $goodsList = json_decode($goodsJson, true);
|
|
|
+ if (empty($goodsList)) {
|
|
|
+ util::fail('请选择成品');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $post['goodsList'] = $goodsList;
|
|
|
+ $return = WastageClass::goodsWastage($post);
|
|
|
+ $transaction->commit();
|
|
|
+ util::success($return);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("失败原因:" . $e->getMessage());
|
|
|
+ util::fail('报损失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//新增损耗
|
|
|
public function actionCreateOrder()
|
|
|
{
|
|
|
@@ -62,7 +100,10 @@ class WastageController extends BaseController
|
|
|
$bigNum = $v['bigNum'] ?? 0;
|
|
|
$smallNum = $v['smallNum'] ?? 0;
|
|
|
if ($bigNum <= 0 && $smallNum <= 0) {
|
|
|
- util::fail('花材数量不能为0');
|
|
|
+ util::fail('数量不能为0');
|
|
|
+ }
|
|
|
+ if (isset($v['property']) && $v['property'] == 0) {
|
|
|
+ util::fail('花材和成品请分开报损');
|
|
|
}
|
|
|
}
|
|
|
$connection = Yii::$app->db;
|