shish 2 лет назад
Родитель
Сommit
c5189d8446

+ 11 - 4
app-ghs/controllers/RefundController.php

@@ -182,11 +182,18 @@ class RefundController extends BaseController
         $get = Yii::$app->request->get();
         $where = [];
         $where['mainId'] = $this->mainId;
-        $orderSn = $get['orderSn'] ?? '';
-        if (!empty($orderSn)) {
-            $where['relateOrderSn'] = $orderSn;
+        $status = $get['status'] ?? '';
+        if (is_numeric($status)) {
+            $where['status'] = $status;
         }
-        $list = RefundOrderClass::getOrderList($where);
+        $string = $get['ids'];
+        $ids = json_decode($string, true);
+        $itemList = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'classId' => ['in', $ids]], null, 'id', 'id');
+        if (!empty($itemList)) {
+            $productIds = array_keys($itemList);
+            $where['productId'] = ['in', $productIds];
+        }
+        $list = RefundOrderItemClass::getRefundItemList($where);
         util::success($list);
     }
 

+ 0 - 1
biz-ghs/order/classes/RefundOrderClass.php

@@ -346,7 +346,6 @@ class RefundOrderClass extends BaseClass
         return $data;
     }
 
-
     //2021.1.23 lqh 订单详情
     public static function getOrderDetail($orderSn, $shopId)
     {

+ 27 - 4
biz-ghs/order/classes/RefundOrderItemClass.php

@@ -2,10 +2,7 @@
 
 namespace bizGhs\order\classes;
 
-use biz\stat\classes\StatItemClass;
-use bizGhs\product\classes\ProductClass;
-use bizGhs\stock\classes\StockRecordClass;
-use common\components\dict;
+use bizGhs\order\models\RefundOrderItem;
 use Yii;
 use bizGhs\base\classes\BaseClass;
 
@@ -14,6 +11,32 @@ class RefundOrderItemClass extends BaseClass
 
     public static $baseFile = '\bizGhs\order\models\RefundOrderItem';
 
+    public static function getRefundItemList($where)
+    {
+        $data = self::getList('*', $where, 'id DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $orderSnList = array_column($list, 'orderSn');
+        $infoList = RefundOrderClass::getAllByCondition(['orderSn' => ['in', $orderSnList]], null, '*', 'orderSn');
+        foreach ($list as $key => $val) {
+            $orderSn = $val['orderSn'] ?? '';
+            $info = $infoList[$orderSn] ?? [];
+            $list[$key]['refundInfo'] = $info;
+        }
+        $data['list'] = $list;
+        $where2 = $where;
+        if (isset($where2['productId'])) {
+            $newIds = $where2['productId'][1];
+            unset($where2['productId']);
+            $where2['productId'] = $newIds;
+        }
+        $totalAmount = RefundOrderItem::find()->where($where2)->sum('xhPrice');
+        $data['totalAmount'] = $totalAmount;
+        return $data;
+    }
+
     public static function addData($data, $order)
     {
         self::add($data);