|
|
@@ -0,0 +1,51 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace bizHd\order\classes;
|
|
|
+
|
|
|
+use common\components\util;
|
|
|
+use Yii;
|
|
|
+use bizHd\base\classes\BaseClass;
|
|
|
+
|
|
|
+class SettleClass extends BaseClass
|
|
|
+{
|
|
|
+
|
|
|
+ public static $baseFile = '\bizHd\order\models\Settle';
|
|
|
+
|
|
|
+ //结清尾款 ssh 20220708
|
|
|
+ public static function confirmSettle($order, $payWay)
|
|
|
+ {
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
+ $settleId = $order->settleId ?? 0;
|
|
|
+ if (!empty($settleId)) {
|
|
|
+ util::fail('已经结清过了');
|
|
|
+ }
|
|
|
+ $remainDebtPrice = $order->remainDebtPrice ?? 0;
|
|
|
+ if ($remainDebtPrice <= 0) {
|
|
|
+ util::fail('尾款已经结清过了');
|
|
|
+ }
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $settleData = [
|
|
|
+ 'prePrice' => $remainDebtPrice,
|
|
|
+ 'actPrice' => $remainDebtPrice,
|
|
|
+ 'realPrice' => $remainDebtPrice,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'hdShopId' => $shopId,
|
|
|
+ 'purchaseIds' => $orderId,
|
|
|
+ 'saleIds' => $orderId,
|
|
|
+ 'num' => 1,
|
|
|
+ 'status' => 2,
|
|
|
+ ];
|
|
|
+ $return = self::addData($settleData);
|
|
|
+ $settleId = $return->id ?? 0;
|
|
|
+ $order->settleId = $settleId;
|
|
|
+ $order->debt = 0;
|
|
|
+ $order->remainDebtPrice = 0;
|
|
|
+ $order->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function addData($data)
|
|
|
+ {
|
|
|
+ return self::add($data, true);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|