|
|
@@ -632,33 +632,33 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//获取当前门店下所有的product
|
|
|
- public static function getAllProduct($sjId,$shopId,$field="*")
|
|
|
+ public static function getAllProduct($sjId, $shopId, $field = "*")
|
|
|
{
|
|
|
$where = [
|
|
|
- 'merchantId'=>$sjId,
|
|
|
- 'shopId'=>$shopId,
|
|
|
+ 'merchantId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
];
|
|
|
- return self::getAllByCondition($where,null,$field);
|
|
|
+ return self::getAllByCondition($where, null, $field);
|
|
|
}
|
|
|
|
|
|
//获取当前门店下所有花材的库存数量,及成本价,库存预警的花材数量 linqh 2021-04-20
|
|
|
- public static function getProductStockByShopId($sjId,$shopId)
|
|
|
+ public static function getProductStockByShopId($sjId, $shopId)
|
|
|
{
|
|
|
- $productInfo = self::getAllProduct($sjId,$shopId,"*");
|
|
|
+ $productInfo = self::getAllProduct($sjId, $shopId, "*");
|
|
|
$data = [
|
|
|
- 'stockBigNum'=>0,
|
|
|
- 'stockSmallNum'=>0,
|
|
|
- 'stockCost'=>0,
|
|
|
- 'stockWarning'=>0,
|
|
|
+ 'stockBigNum' => 0,
|
|
|
+ 'stockSmallNum' => 0,
|
|
|
+ 'stockCost' => 0,
|
|
|
+ 'stockWarning' => 0,
|
|
|
];
|
|
|
- if($productInfo){
|
|
|
- foreach ($productInfo as $v){
|
|
|
- $stock = self::formatStock($v['stock'],$v['ratio']);
|
|
|
- $data['stockBigNum'] = bcadd($data['stockBigNum'],$stock['bigNum']);
|
|
|
- $data['stockSmallNum'] = bcadd($data['stockSmallNum'],$stock['smallNum']);
|
|
|
- $data['stockCost'] = bcadd($data['stockCost'],bcmul($v['stock'],$v['cost'],2),2);
|
|
|
- if($v['stock'] <= $v['stockWarning']) {
|
|
|
- $data['stockWarning'] ++;
|
|
|
+ if ($productInfo) {
|
|
|
+ foreach ($productInfo as $v) {
|
|
|
+ $stock = self::formatStock($v['stock'], $v['ratio']);
|
|
|
+ $data['stockBigNum'] = bcadd($data['stockBigNum'], $stock['bigNum']);
|
|
|
+ $data['stockSmallNum'] = bcadd($data['stockSmallNum'], $stock['smallNum']);
|
|
|
+ $data['stockCost'] = bcadd($data['stockCost'], bcmul($v['stock'], $v['cost'], 2), 2);
|
|
|
+ if ($v['stock'] <= $v['stockWarning']) {
|
|
|
+ $data['stockWarning']++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -666,28 +666,29 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//补className
|
|
|
- public static function groupClassName($sjId,$data)
|
|
|
+ public static function groupClassName($sjId, $data)
|
|
|
{
|
|
|
//补className
|
|
|
//获取当前商家下所有itemId=>classId
|
|
|
- $itemInfo = ItemClass::getGhsItemAll($sjId,"itemId,classId");
|
|
|
+ $itemInfo = ItemClass::getGhsItemAll($sjId, "itemId,classId");
|
|
|
$itemClassMap = [];
|
|
|
- foreach ($itemInfo as $v){
|
|
|
+ foreach ($itemInfo as $v) {
|
|
|
$itemClassMap[$v['itemId']] = $v['classId'];
|
|
|
}
|
|
|
//获取classId=>name
|
|
|
- $itemClassInfo = ItemClassClass::getAll($sjId,"id,name");
|
|
|
+ $itemClassInfo = ItemClassClass::getAll($sjId, "id,name");
|
|
|
$classNameMap = [];
|
|
|
- foreach ($itemClassInfo as $v){
|
|
|
+ foreach ($itemClassInfo as $v) {
|
|
|
$classNameMap[$v['id']] = $v['name'];
|
|
|
}
|
|
|
- foreach ($data as $k=>$v){
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
$itemId = $v['itemId'];
|
|
|
- $classId = $itemClassMap[$itemId]??0;
|
|
|
- $className = $classNameMap[$classId]??'';
|
|
|
+ $classId = $itemClassMap[$itemId] ?? 0;
|
|
|
+ $className = $classNameMap[$classId] ?? '';
|
|
|
$v['className'] = $className;
|
|
|
$data[$k] = $v;
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
}
|