瀏覽代碼

活动包修改

cqp 1 月之前
父節點
當前提交
a4036e7128
共有 3 個文件被更改,包括 44 次插入18 次删除
  1. 34 16
      app/Service/SportsBagService.php
  2. 5 1
      config/header/30.php
  3. 5 1
      config/header/57.php

+ 34 - 16
app/Service/SportsBagService.php

@@ -284,22 +284,7 @@ class SportsBagService extends Service
         $emp_map = Employee::whereIn('id',$emp_id)
                     ->pluck('emp_name','id')
                     ->toArray();
-        $product = [];
-        if(! empty($ergs['product'])){
-            $sales_p_info = SportsBagProductInfo::where('del_time',0)
-                ->whereIn('sports_bag_id',array_column($data['data'],'id'))
-                ->get()->toArray();
-            $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
-            foreach ($sales_p_info as $value){
-                $tmp = $map[$value['product_id']] ?? [];
-                $value['title'] = $tmp['title'] ?? "";
-                $value['code'] = $tmp['code'] ?? "";
-                $value['size'] = $tmp['size'] ?? "";
-                $value['unit'] = $tmp['unit'] ?? "";
-                $value['bar_code'] = $tmp['bar_code'] ?? "";
-                $product[$value['sports_bag_id']][] = $value;
-            }
-        }
+        list($product_price, $product) = $this->getProductMessage(array_column($data['data'],'id'), $ergs);
 
         //订单状态数据组织
         $state_array = $this->getStateMake($data['data']);
@@ -312,12 +297,45 @@ class SportsBagService extends Service
             $data['data'][$key]['crt_name'] = $emp_map[$value['crt_id']] ?? '';
             $data['data'][$key]['state_title'] = $this->makeState($data['data'][$key], $state_array);
             $data['data'][$key]['product'] = $product[$value['id']] ?? [];
+            $data['data'][$key]['ori_total_amount'] = $product_price[$value['id']] ?? 0;
             $data['data'][$key]['is_attribute_title'] = SportsBag::$attribute_name[$value['is_attribute']] ?? "";
         }
 
         return $data;
     }
 
+    public function getProductMessage($sports_bag_id = [], $data){
+        $product_price = $product_message = [];
+        if(empty($sports_bag_id)) return [$product_price, $product_message];
+        $sales_p_info = SportsBagProductInfo::where('del_time',0)
+            ->whereIn('sports_bag_id', $sports_bag_id)
+            ->get()->toArray();
+
+        //产品信息
+        $map = [];
+        if(! empty($data['product'])) $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
+
+        foreach ($sales_p_info as $value){
+            if(! empty($data['product'])){
+                $tmp = $map[$value['product_id']] ?? [];
+                $value['title'] = $tmp['title'] ?? "";
+                $value['code'] = $tmp['code'] ?? "";
+                $value['size'] = $tmp['size'] ?? "";
+                $value['unit'] = $tmp['unit'] ?? "";
+                $value['bar_code'] = $tmp['bar_code'] ?? "";
+                $product_message[$value['sports_bag_id']][] = $value;
+            }
+
+            $tmp = bcmul($value['retail_price'], $value['number'], 2);
+            if(isset($product_price[$value['sports_bag_id']])){
+                $product_price[$value['sports_bag_id']] = bcadd($tmp, $product_price[$value['sports_bag_id']],2);
+            }else{
+                $product_price[$value['sports_bag_id']] = $tmp;
+            }
+        }
+        return [$product_price, $product_message];
+    }
+
     public function makeState($value, $state_array){
         $nowStamp = time();
         if(! empty($state_array[$value['order_number']])){

+ 5 - 1
config/header/30.php

@@ -15,8 +15,12 @@ return [
         'value' => '活动包时间范围',
     ],
     [
+        'key' => 'ori_total_amount',
+        'value' => '销售原价',
+    ],
+    [
         'key' => 'total_amount',
-        'value' => '活动包金额',
+        'value' => '销售活动价',
     ],
     [
         'key' => 'mark',

+ 5 - 1
config/header/57.php

@@ -15,8 +15,12 @@ return [
         'value' => '活动包时间范围',
     ],
     [
+        'key' => 'ori_total_amount',
+        'value' => '采购原价',
+    ],
+    [
         'key' => 'total_amount',
-        'value' => '活动包金额',
+        'value' => '采购活动价',
     ],
     [
         'key' => 'mark',