|
|
@@ -2,11 +2,15 @@
|
|
|
//退款退货
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
+use biz\shop\classes\ShopExtClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
+use bizHd\order\classes\OrderGoodsClass;
|
|
|
+use bizHd\order\classes\OrderItemClass;
|
|
|
use bizHd\refund\classes\HdRefundClass;
|
|
|
use bizHd\refund\classes\HdRefundGoodsClass;
|
|
|
use bizHd\refund\classes\HdRefundItemClass;
|
|
|
use bizHd\refund\services\HdRefundService;
|
|
|
+use common\components\noticeUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
|
|
|
@@ -109,6 +113,11 @@ class RefundController extends BaseController
|
|
|
HdRefundService::addRefund($post, $order);
|
|
|
$transaction->commit();
|
|
|
|
|
|
+ //制作单取消通知
|
|
|
+ $shopId = $this->shopId ?? 0;
|
|
|
+ $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
|
|
|
+ ShopExtClass::orderCancelRemind($shopExt, $order);
|
|
|
+
|
|
|
} catch (\Exception $exception) {
|
|
|
$transaction->rollBack();
|
|
|
Yii::info("出错了:" . $exception->getMessage());
|
|
|
@@ -117,4 +126,59 @@ class RefundController extends BaseController
|
|
|
util::complete();
|
|
|
}
|
|
|
|
|
|
+ public function actionAllRefund()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ OrderClass::valid($order, $this->mainId);
|
|
|
+
|
|
|
+ $shopId = $this->shopId ?? 0;
|
|
|
+ $sjId = $this->sjId ?? 0;
|
|
|
+ $mainId = $this->mainId ?? 0;
|
|
|
+ $post = [];
|
|
|
+ $post['price'] = $order->actPrice ?? 0;
|
|
|
+ $post['refundType'] = HdRefundClass::REFUND_TYPE_MONEY_GOOD;
|
|
|
+ $post['id'] = $order->id ?? 0;
|
|
|
+ $post['shopId'] = $shopId;
|
|
|
+ $post['sjId'] = $sjId;
|
|
|
+ $post['shopAdminId'] = 0;
|
|
|
+ $post['mainId'] = $mainId;
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $post['shopAdminName'] = $staff->name ?? '';
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
+ $orderGoods = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ $productData = [];
|
|
|
+ if (!empty($orderGoods)) {
|
|
|
+ foreach ($orderGoods as $goodsItem) {
|
|
|
+ $productData[] = ['productId' => $goodsItem->goodsId, 'num' => $goodsItem->num, 'unitPrice' => $goodsItem->unitPrice, 'property' => 0,];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $orderItem = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($orderItem)) {
|
|
|
+ foreach ($orderItem as $singe) {
|
|
|
+ $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1,];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post['product'] = $productData;
|
|
|
+ HdRefundService::addRefund($post, $order);
|
|
|
+
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ //制作单取消通知
|
|
|
+ $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
|
|
|
+ ShopExtClass::orderCancelRemind($shopExt, $order);
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ noticeUtil::push("取消报错了,错误信息:{$msg}", '15280215347');
|
|
|
+ util::fail('退款失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|