|
|
@@ -18,7 +18,7 @@ class ProductService extends BaseService
|
|
|
const OFTEN_CLASS_ID = '-2';
|
|
|
|
|
|
//组装分类花材数据
|
|
|
- public static function assembleData($classIds, $itemInfoData, $showSale = false)
|
|
|
+ public static function assembleData($classIds, $itemInfoData, $showTodayDiscount = false)
|
|
|
{
|
|
|
$saleItem = []; //今日特价
|
|
|
|
|
|
@@ -47,18 +47,19 @@ class ProductService extends BaseService
|
|
|
];
|
|
|
$classData = [];
|
|
|
|
|
|
- foreach ($classIds as $v) {
|
|
|
- $classId = $v['id'];
|
|
|
+ foreach ($classIds as $classVal) {
|
|
|
+ $classId = $classVal['id'];
|
|
|
if ($classId > 0) {
|
|
|
$tmp = [];
|
|
|
$tmp['classId'] = $classId;
|
|
|
- $tmp['className'] = $v['name'];
|
|
|
+ $tmp['className'] = $classVal['name'] ?? '';
|
|
|
$items = $classMapItem[$classId] ?? [];
|
|
|
if ($items) {
|
|
|
if ($itemInfoData) {
|
|
|
foreach ($itemInfoData as $v) {
|
|
|
if (in_array($v['itemId'], $items)) {
|
|
|
- $v['classId'] = $classId; //前端要求增加classId 2021.1.31 linqh
|
|
|
+ //前端要求增加classId 2021.1.31 linqh
|
|
|
+ $v['classId'] = $classId;
|
|
|
$tmp['child'][] = $v;
|
|
|
}
|
|
|
}
|
|
|
@@ -68,17 +69,11 @@ class ProductService extends BaseService
|
|
|
} else {
|
|
|
$tmp['child'] = [];
|
|
|
}
|
|
|
- //去除空分类
|
|
|
- if (empty($tmp['child'])) {
|
|
|
- //暂时列出所有的分类 shish 2021.5.2
|
|
|
- //continue;
|
|
|
- }
|
|
|
$classData[] = $tmp;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- if ($showSale && !empty($saleItem)) {
|
|
|
+ if ($showTodayDiscount && !empty($saleItem)) {
|
|
|
$classData = array_merge($saleData, $classData);
|
|
|
}
|
|
|
return $classData;
|
|
|
@@ -116,38 +111,21 @@ class ProductService extends BaseService
|
|
|
//生成价格表 shish 20210922
|
|
|
public static function generatePriceTable($sjId, $shopId)
|
|
|
{
|
|
|
-
|
|
|
- $py = '';
|
|
|
- $type = '';
|
|
|
- //默认只显示上架的商品
|
|
|
$status = 1;
|
|
|
|
|
|
- //获取所有当前供应商的分类 (全部、常用)
|
|
|
+ //获取所有当前供应商的分类
|
|
|
//根据分类组装分类下的花材信息
|
|
|
$classIds = ItemClassClass::getGhsItemClassAll($sjId);
|
|
|
|
|
|
$where['sjId'] = $sjId;
|
|
|
- if ($py) {
|
|
|
- $pyName = strtolower($py);
|
|
|
- $where['py'] = $pyName;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
$where['shopId'] = $shopId;
|
|
|
- if (!empty($status)) {
|
|
|
- $where['status'] = $status;
|
|
|
- }
|
|
|
+ $where['status'] = $status;
|
|
|
$where['delStatus'] = 0;
|
|
|
|
|
|
$itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
|
|
|
$itemInfoData = ProductClass::groupProductInfo($itemInfoData);
|
|
|
- //常用的itemIds
|
|
|
- $oftenItemIds = [];
|
|
|
- //$oftenItemIds = ProductClass::getOftenItemIds($shopId);
|
|
|
- //获取供应商下所有花材ID (itemIds)
|
|
|
- $itemIdsInfo = ProductClass::getGhsItemIds($sjId);
|
|
|
|
|
|
- $data = self::assembleData($classIds, $itemIdsInfo, $itemInfoData, $oftenItemIds, $type);
|
|
|
+ $data = self::assembleData($classIds, $itemInfoData, true);
|
|
|
|
|
|
$formatData = [];
|
|
|
|
|
|
@@ -235,10 +213,6 @@ class ProductService extends BaseService
|
|
|
|
|
|
$file = $date . '.xls';
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
- //$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
|
|
-
|
|
|
- //$file = $date . '.pdf';
|
|
|
- //$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
|
|
|
|
|
|
if (file_exists($dir . '/' . $file)) {
|
|
|
unlink($dir . '/' . $file);
|