Browse Source

采购人

shish 2 years ago
parent
commit
c765a5155d

+ 6 - 0
app-ghs/controllers/ProductController.php

@@ -321,6 +321,12 @@ class ProductController extends BaseController
             $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
+        } elseif ($requestType == 'cgStaffList') {
+            unset($where['status']);
+            $where['delStatus'] = 0;
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount,cgStaffId,cgStaffName';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::cgStaffListGroup($itemInfoData, $level);
         } elseif ($requestType == 'outList') {
             //下架花材列表
             $where['status'] = 2;

+ 46 - 0
biz-ghs/product/classes/ProductClass.php

@@ -396,6 +396,52 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    public static function cgStaffListGroup($list, $level = 0)
+    {
+        //各个等级对应的price addPrice字段
+        $priceMap = CustomClass::$levelPriceKeyMap;
+        $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+
+        foreach ($list as $k => $v) {
+            $shortCover = $v['cover'] ?? '';
+            $cover = imgUtil::getPrefix() . 'hhb_small.png';
+            if (!empty($shortCover)) {
+                $parse = parse_url(self::groupImg($shortCover));
+                if (empty($parse['query'])) {
+                    $cover = self::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
+                } else {
+                    $cover = self::groupImg($shortCover);
+                }
+            }
+            $list[$k]['cover'] = $cover;
+            //今日特价、会员价
+            $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            if ($level == 0) {
+                //零售做特价时显示的原价,不能删除
+                if (isset($v['skPrice'])) {
+                    $list[$k]['prePrice'] = $v['skPrice'];
+                }
+            }
+            if (isset($v['discountPrice']) && $v['discountPrice'] > 0) {
+                //做特价花材时,花材列表和改价列表显示的会员价和零售价,不能删除
+                $list[$k]['hjPrice'] = floatval($v['hjDiscountPrice']);
+                $list[$k]['skPrice'] = floatval($v['skDiscountPrice']);
+            }
+            $list[$k]['price'] = $price;
+            $cost = $v['cost'] ?? 0;
+            if ($price > 0) {
+                $profit = bcsub($price, $cost, 2);
+                $mll = bcdiv($profit, $price, 3);
+                $mll = bcmul($mll, 100);
+                $mll = round($mll, 1);
+            } else {
+                $mll = 0;
+            }
+            $list[$k]['mll'] = $mll;
+        }
+        return $list;
+    }
+
     //通用花材列表数组组合
     public static function changeStockGroup($list, $level = 0)
     {