|
|
@@ -3,6 +3,7 @@
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
use bizGhs\merchant\classes\ShopClass;
|
|
|
+use bizGhs\order\classes\StockInOrderClass;
|
|
|
use bizGhs\order\classes\StockOutOrderClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use common\components\util;
|
|
|
@@ -12,6 +13,42 @@ use Yii;
|
|
|
class StockOutController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //结清账单 ssh 20221113
|
|
|
+ public function actionClear()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $orderSn = $get['orderSn'] ?? '';
|
|
|
+ $out = StockOutOrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($out)) {
|
|
|
+ util::fail('没有找到出库单');
|
|
|
+ }
|
|
|
+ if ($out->outMainId != $this->mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ if ($out->status != 2) {
|
|
|
+ util::fail('已出库才能结账单');
|
|
|
+ }
|
|
|
+ if ($out->debt == 0) {
|
|
|
+ util::fail('已经结过了');
|
|
|
+ }
|
|
|
+ $inOrderSn = $out->inOrderSn ?? '';
|
|
|
+ $in = StockInOrderClass::getByCondition(['orderSn' => $inOrderSn], true);
|
|
|
+ if (empty($in)) {
|
|
|
+ util::fail('没有找到入库单');
|
|
|
+ }
|
|
|
+ if ($in->status != 2) {
|
|
|
+ util::fail('已入库才能结账单');
|
|
|
+ }
|
|
|
+ if ($in->debt == 0) {
|
|
|
+ util::fail('已经结过了');
|
|
|
+ }
|
|
|
+ $out->debt = 0;
|
|
|
+ $out->save();
|
|
|
+ $in->debt = 0;
|
|
|
+ $in->save();
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
//全部出库 ssh 20220906
|
|
|
public function actionAllOut()
|
|
|
{
|