|
|
@@ -4,6 +4,9 @@ namespace ghs\controllers;
|
|
|
|
|
|
use bizGhs\order\classes\RefundOrderItemClass;
|
|
|
use bizGhs\order\services\RefundOrderService;
|
|
|
+use bizGhs\shop\classes\ShopClass;
|
|
|
+use bizHd\cg\classes\CgRefundClass;
|
|
|
+use bizHd\notice\classes\NoticeClass;
|
|
|
use bizHd\purchase\classes\PurchaseClearClass;
|
|
|
use common\components\imgUtil;
|
|
|
use Yii;
|
|
|
@@ -35,6 +38,15 @@ class RefundController extends BaseController
|
|
|
try {
|
|
|
RefundOrderService::passRefund($refund);
|
|
|
$transaction->commit();
|
|
|
+
|
|
|
+ $cgRefundId = $refund->cgRefundId ?? 0;
|
|
|
+ $cgRefund = CgRefundClass::getById($cgRefundId, true);
|
|
|
+ $cgShopId = $cgRefund->shopId ?? 0;
|
|
|
+ $cgShop = ShopClass::getById($cgShopId, true);
|
|
|
+ if (!empty($cgRefund) && !empty($cgShop)) {
|
|
|
+ NoticeClass::afterSaleNotice($cgShop, $cgRefund);
|
|
|
+ }
|
|
|
+
|
|
|
util::complete('操作成功');
|
|
|
} catch (\Exception $e) {
|
|
|
$transaction->rollBack();
|
|
|
@@ -56,8 +68,28 @@ class RefundController extends BaseController
|
|
|
$rejectReason = $post['rejectReason'] ?? '';
|
|
|
$refund = RefundOrderClass::getById($id, true);
|
|
|
RefundOrderClass::valid($refund, $this->mainId);
|
|
|
- RefundOrderClass::rejectRefund($refund, $rejectReason);
|
|
|
- util::complete('操作成功');
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ RefundOrderClass::rejectRefund($refund, $rejectReason);
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ $cgRefundId = $refund->cgRefundId ?? 0;
|
|
|
+ $cgRefund = CgRefundClass::getById($cgRefundId, true);
|
|
|
+ $cgShopId = $cgRefund->shopId ?? 0;
|
|
|
+ $cgShop = ShopClass::getById($cgShopId, true);
|
|
|
+ if (!empty($cgRefund) && !empty($cgShop)) {
|
|
|
+ NoticeClass::afterSaleNotice($cgShop, $cgRefund);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::complete('操作成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("操作失败原因:" . $e->getMessage());
|
|
|
+ util::fail('操作失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//退款之后报损 ssh 20230409
|