shish 3 rokov pred
rodič
commit
98d936af5e

+ 36 - 0
app-ghs/controllers/CgRefundController.php

@@ -4,14 +4,48 @@ namespace ghs\controllers;
 
 
 use bizGhs\cg\classes\CgRefundClass;
+use bizGhs\cg\classes\CgRefundItemClass;
 use bizGhs\cg\services\CgRefundService;
 use bizGhs\order\classes\PurchaseOrderClass;
+use common\components\imgUtil;
 use common\components\util;
 use Yii;
 
 class CgRefundController extends BaseController
 {
 
+    //详情 ssh 20220910
+    public function actionGetRefundFullInfo()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $refund = CgRefundClass::getById($id, true);
+        CgRefundClass::valid($refund, $this->mainId);
+        $refundSn = $refund->refundSn ?? '';
+        $itemList = CgRefundItemClass::getAllByCondition(['refundSn' => $refundSn], null, '*');
+        if (!empty($itemList)) {
+            foreach ($itemList as $key => $item) {
+                $shortCover = $item['cover'] ?? '';
+                $itemList[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+            }
+        }
+        util::success(['info' => $refund, 'itemList' => $itemList]);
+    }
+
+    //记录 ssh 20220910
+    public function actionGetRefundList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $refundSn = $get['refundSn'] ?? '';
+        if (!empty($orderSn)) {
+            $where['refundSn'] = $refundSn;
+        }
+        $list = CgRefundClass::getRefundList($where);
+        util::success($list);
+    }
+
     //退款 ssh 20220909
     public function actionCreateOrder()
     {
@@ -84,4 +118,6 @@ class CgRefundController extends BaseController
         }
         util::complete();
     }
+
+
 }

+ 18 - 0
biz-ghs/cg/classes/CgRefundClass.php

@@ -14,4 +14,22 @@ class CgRefundClass extends BaseClass
     const REFUND_TYPE_MONEY_GOOD = 1; //退款退货
     const REFUND_TYPE_MONEY = 2; // 仅退款
 
+    public static function getRefundList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $data['list'] = $list;
+        return $data;
+    }
+
+    public static function valid($refund, $mainId)
+    {
+        if (isset($refund->mainId) == false || $refund->mainId != $mainId) {
+            util::fail('没有权限');
+        }
+    }
+
 }

+ 7 - 0
biz-ghs/cg/services/CgRefundService.php

@@ -68,6 +68,9 @@ class CgRefundService extends BaseService
                 $currentCgItem = $cgItemList[$productId] ?? null;
                 $hasRefundNum = $currentCgItem->refundNum ?? 0;
                 $totalNum = $currentCgItem->itemNum ?? 0;
+                $unitPrice = $currentCgItem->bigPrice ?? 0;
+                $unitName = $currentCgItem->bigUnit ?? '';
+                $totalPrice = bcmul($unitPrice, $num, 2);
                 $couldRefundNum = bcsub($totalNum, $hasRefundNum);
                 if ($couldRefundNum < $num) {
                     util::fail('超过可退数量');
@@ -82,6 +85,10 @@ class CgRefundService extends BaseService
                     'itemId' => $productId,
                     'ptItemId' => $ptItemId,
                     'num' => $num,
+                    'unitName' => $unitName,
+                    'unitType' => 0,
+                    'unitPrice' => $unitPrice,
+                    'price' => $totalPrice,
                 ];
                 CgRefundItemClass::addData($refundItemData, $order);
             }

+ 0 - 1
biz-hd/cg/classes/CgRefundSnClass.php

@@ -9,5 +9,4 @@ class CgRefundSnClass extends BaseClass
 
     public static $baseFile = '\bizHd\cg\models\CgRefundSn';
 
-
 }

+ 1 - 2
common/components/orderSn.php

@@ -4,7 +4,6 @@ namespace common\components;
 
 use biz\sj\classes\CashSnClass;
 use bizGhs\order\classes\OrderClass;
-use bizHd\cg\classes\CgRefundClass;
 use bizHd\cg\classes\CgRefundSnClass;
 use bizHd\goods\classes\GoodsCgSnClass;
 use bizHd\goods\classes\GoodsSnClass;
@@ -331,7 +330,7 @@ class orderSn
         if (getenv('YII_ENV', 'local') == 'production') {
             $prefix = 'GCRD';
         }
-        $respond = \bizGhs\cg\classes\CgRefundClass::add(['id' => null]);
+        $respond = \bizGhs\cg\classes\CgRefundSnClass::add(['id' => null]);
         $id = $respond['id'] ?? 0;
         if (empty($id)) {
             util::fail('单号没有生成');