发现冲突

main
yangsai 4 months ago
parent 5b8db94272
commit e559fb8ce4
  1. 114
      app/controller/admin/v1/statistic/ProductStatistic.php
  2. 2
      crmeb/services/printer/storage/YiLianYun.php
  3. 6
      route/admin.php

@ -138,15 +138,18 @@ class ProductStatistic extends AuthController
$v['cart_info']['productInfo']['code'] = $v['cart_info']['productInfo']['attrInfo']['code'];
$v['cart_info']['productInfo']['cate_name'] = $storeProductCategoryServices->getColumn(['id' => $v['cart_info']['productInfo']['cate_id']], 'cate_name')[0];
$v['cart_info']['productInfo']['storename'] = $val['storename'];
// print_r($v['cart_info']['sum_true_price']);die;
//获取商品单位
if(empty($v['cart_info']['productInfo']['unit_name'])) $v['cart_info']['productInfo']['unit_name'] = $StoreProductServices->getColumn(['id'=>$v['cart_info']['productInfo']['product_id']], 'unit_name')[0];
$products['data'][] = $v['cart_info']['productInfo'];
if($cateId && in_array($v['cart_info']['productInfo']['cate_id'], $cateId)){
$products['data'][] = $v['cart_info']['productInfo'];
}else if(!$cateId){
$products['data'][] = $v['cart_info']['productInfo'];
}
}
}
return $this->success($products);
}
//商品分类统计
public function getProductcatecount(StoreProductCategoryServices $storeProductCategoryServices)
{
$where = $this->request->getMore([
@ -167,12 +170,7 @@ class ProductStatistic extends AuthController
$SystemStoreServices = app()->make(SystemStoreServices::class);
$payOrder = $StoreOrderServices->getOrderList($where);
$products = [];
$cateinfo = [];
$products['data'] = [];
$products['allpay'] = 0;
$products['allsum'] = 0;
$products['allyouhui'] = 0;
$products['allshiji'] = 0;
$cateId = $where['cate_id'];
if ($cateId) {
$cateId = is_string($cateId) ? [$cateId] : $cateId;
@ -184,35 +182,107 @@ class ProductStatistic extends AuthController
//获取门店名称
$val['storename'] = empty($val['store_id'])?'平台':$SystemStoreServices->getFieldValue($val['store_id'],'id', 'name');
foreach($val['_info'] as $k => $v){
if(in_array($v['cart_info']['productInfo']['cate_id'],$cateId)){
$cateinfo[$v['cart_info']['productInfo']['cate_id']] = $cateinfo[$v['cart_info']['productInfo']['cate_id']][];
$cateinfo[$v['cart_info']['productInfo']['cate_id']] = $cateinfo[$v['cart_info']['productInfo']['cate_id']][];
}
$v['cart_info']['productInfo']['pnum'] = empty($v['cart_info']['productInfo']['pnum'])?$v['cart_info']['cart_num']:$v['cart_info']['productInfo']['pnum'];
$products['allsum'] = $products['allsum']+$v['cart_info']['productInfo']['pnum'];
$v['cart_info']['productInfo']['pink_name'] = $val['pink_name'];
$v['cart_info']['productInfo']['order_no'] = $val['order_id'];
$v['cart_info']['productInfo']['sum_true_price'] = empty($v['cart_info']['sum_true_price'])?'0.00':$v['cart_info']['sum_true_price'];
$products['allshiji'] = round($products['allshiji']+$v['cart_info']['productInfo']['sum_true_price'],2);
$v['cart_info']['productInfo']['sum_price'] = round($v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['price'],2);
$products['allpay'] = round($products['allpay']+$v['cart_info']['productInfo']['sum_price'],2);
$v['cart_info']['productInfo']['youhui'] = round($v['cart_info']['productInfo']['sum_price']-$v['cart_info']['productInfo']['sum_true_price'],2);
$products['allyouhui'] = round($products['allyouhui']+$v['cart_info']['productInfo']['youhui'],2);
$v['cart_info']['productInfo']['cost'] = round($v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['cost'],2);
$v['cart_info']['productInfo']['code'] = $v['cart_info']['productInfo']['attrInfo']['code'];
$v['cart_info']['productInfo']['cate_name'] = $storeProductCategoryServices->getColumn(['id' => $v['cart_info']['productInfo']['cate_id']], 'cate_name')[0];
$v['cart_info']['productInfo']['storename'] = $val['storename'];
// print_r($v['cart_info']['sum_true_price']);die;
//获取商品单位
if(empty($v['cart_info']['productInfo']['unit_name'])) $v['cart_info']['productInfo']['unit_name'] = $StoreProductServices->getColumn(['id'=>$v['cart_info']['productInfo']['product_id']], 'unit_name')[0];
$products['data'][] = $v['cart_info']['productInfo'];
$cate[$v['cart_info']['productInfo']['cate_id']]['cate_name'] = $v['cart_info']['productInfo']['cate_name'];
$cate[$v['cart_info']['productInfo']['cate_id']]['pay_num'] = round((!isset($cate[$v['cart_info']['productInfo']['cate_id']]['pay_num'])?0:$cate[$v['cart_info']['productInfo']['cate_id']]['pay_num'])+$v['cart_info']['productInfo']['pnum'],2);
$cate[$v['cart_info']['productInfo']['cate_id']]['sum_price'] = round((!isset($cate[$v['cart_info']['productInfo']['cate_id']]['sum_price'])?0:$cate[$v['cart_info']['productInfo']['cate_id']]['sum_price'])+$v['cart_info']['productInfo']['sum_price'],2);
$cate[$v['cart_info']['productInfo']['cate_id']]['cost'] = round((!isset($cate[$v['cart_info']['productInfo']['cate_id']]['cost'])?0:$cate[$v['cart_info']['productInfo']['cate_id']]['cost'])+$v['cart_info']['productInfo']['cost'],2);
$cate[$v['cart_info']['productInfo']['cate_id']]['data'][] = $v['cart_info']['productInfo'];
}
}
return $this->success($products);
$sumcount['cate_name'] = "总计";
$sumcount['pay_num'] = 0;
$sumcount['sum_price'] = 0;
$sumcount['cost'] = 0;
foreach($cate as $k => $v){
if($cateId && in_array($k, $cateId)){
$sumcount['pay_num'] = $sumcount['pay_num']+$v['pay_num'];
$sumcount['sum_price'] = round($sumcount['sum_price']+$v['sum_price'],2);
$sumcount['cost'] = round($sumcount['cost']+$v['cost'],2);
$returncate[] = $v;
}else if(!$cateId){
$sumcount['pay_num'] = $sumcount['pay_num']+$v['pay_num'];
$sumcount['sum_price'] = round($sumcount['sum_price']+$v['sum_price'],2);
$sumcount['cost'] = round($sumcount['cost']+$v['cost'],2);
$returncate[] = $v;
}
}
$returncate[] = $sumcount;
return $this->success($returncate);
}
//查询套餐销售报表
public function getProductchupincount(StoreProductCategoryServices $storeProductCategoryServices)
{
$where = $this->request->getMore([
['cate_id', ''],
['data', '', '', 'time'],
['sort', ''],
['type', ''],
['paid',1],
]);
//查询所有已支付的订单
/** @var StoreOrderServices $StoreOrderServices */
$StoreOrderServices = app()->make(StoreOrderServices::class);
//商品服务层
/** @var StoreProductServices $StoreProductServices */
$StoreProductServices = app()->make(StoreProductServices::class);
//门店服务层
/** @var SystemStoreServices $SystemStoreServices */
$SystemStoreServices = app()->make(SystemStoreServices::class);
$payOrder = $StoreOrderServices->getOrderList($where);
$products = [];
$products['data'] = [];
foreach($payOrder['data'] as $key => $val){
$val['pink_name'] = !empty($val['other_order'])?'[会员礼包]':$val['pink_name'];
//获取门店名称
$val['storename'] = empty($val['store_id'])?'平台':$SystemStoreServices->getFieldValue($val['store_id'],'id', 'name');
foreach($val['_info'] as $k => $v){
$v['cart_info']['productInfo']['pnum'] = empty($v['cart_info']['productInfo']['pnum'])?$v['cart_info']['cart_num']:$v['cart_info']['productInfo']['pnum'];
$v['cart_info']['productInfo']['pink_name'] = $val['pink_name'];
$v['cart_info']['productInfo']['order_no'] = $val['order_id'];
$v['cart_info']['productInfo']['sum_true_price'] = empty($v['cart_info']['sum_true_price'])?'0.00':$v['cart_info']['sum_true_price'];
$v['cart_info']['productInfo']['sum_price'] = round($v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['price'],2);
$v['cart_info']['productInfo']['youhui'] = round($v['cart_info']['productInfo']['sum_price']-$v['cart_info']['productInfo']['sum_true_price'],2);
$v['cart_info']['productInfo']['cost'] = round($v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['cost'],2);
$v['cart_info']['productInfo']['code'] = $v['cart_info']['productInfo']['attrInfo']['code'];
$v['cart_info']['productInfo']['cate_name'] = $storeProductCategoryServices->getColumn(['id' => $v['cart_info']['productInfo']['cate_id']], 'cate_name')[0];
$v['cart_info']['productInfo']['storename'] = $val['storename'];
//获取商品单位
if(empty($v['cart_info']['productInfo']['unit_name'])) $v['cart_info']['productInfo']['unit_name'] = $StoreProductServices->getColumn(['id'=>$v['cart_info']['productInfo']['product_id']], 'unit_name')[0];
$products['data'][] = $v['cart_info']['productInfo'];
$cate[$v['cart_info']['productInfo']['pink_name']]['cate_name'] = $v['cart_info']['productInfo']['pink_name'];
$cate[$v['cart_info']['productInfo']['pink_name']]['pay_num'] = (!isset($cate[$v['cart_info']['productInfo']['pink_name']]['pay_num'])?0:$cate[$v['cart_info']['productInfo']['pink_name']]['pay_num'])+$v['cart_info']['productInfo']['pnum'];
$cate[$v['cart_info']['productInfo']['pink_name']]['sum_price'] = round((!isset($cate[$v['cart_info']['productInfo']['pink_name']]['sum_price'])?0:$cate[$v['cart_info']['productInfo']['pink_name']]['sum_price'])+$v['cart_info']['productInfo']['sum_price'],2);
$cate[$v['cart_info']['productInfo']['pink_name']]['cost'] = round((!isset($cate[$v['cart_info']['productInfo']['pink_name']]['cost'])?0:$cate[$v['cart_info']['productInfo']['pink_name']]['cost'])+$v['cart_info']['productInfo']['cost'],2);
$cate[$v['cart_info']['productInfo']['pink_name']]['data'][] = $v['cart_info']['productInfo'];
}
}
$sumcount['cate_name'] = "总计";
$sumcount['pay_num'] = 0;
$sumcount['sum_price'] = 0;
$sumcount['cost'] = 0;
if(!empty($cate)){
foreach($cate as $k => $v){
$sumcount['pay_num'] = $sumcount['pay_num']+$v['pay_num'];
$sumcount['sum_price'] = round($sumcount['sum_price']+$v['sum_price'],2);
$sumcount['cost'] = round($sumcount['cost']+$v['cost'],2);
$returncate[] = $v;
}
}
$returncate[] = $sumcount;
return $this->success($returncate);
}
/**
* 导出

@ -99,7 +99,7 @@ class YiLianYun extends BasePrinter
}
$goodsStr .= '</table>';
$orderInfo = $config['orderInfo'];
$tableInfo = $config['tableInfo'];
$tableInfo = isset($config['tableInfo'])&&!empty($config['tableInfo'])?$config['tableInfo']:[];
$name = $config['name'];
/** @var TableQrcodeServices $qrcodeService */
$qrcodeService = app()->make(TableQrcodeServices::class);

@ -2028,8 +2028,12 @@ Route::group('adminapi', function () {
Route::get('product/get_trend', 'v1.statistic.ProductStatistic/getTrend')->option(['real_name' => '商品趋势']);
//商品排行
Route::get('product/get_product_ranking', 'v1.statistic.ProductStatistic/getProductRanking')->option(['real_name' => '商品排行']);
//商品排行
//商品统计报表
Route::get('product/get_product_count', 'v1.statistic.ProductStatistic/getProductcount')->option(['real_name' => '商品统计报表']);
//商品分类统计
Route::get('product/get_product_cate_count', 'v1.statistic.ProductStatistic/getProductcatecount')->option(['real_name' => '商品分类统计报表']);
Route::get('product/get_product_chupin_count', 'v1.statistic.ProductStatistic/getProductchupincount')->option(['real_name' => '商品分类统计报表']);
//商品数据导出
Route::get('product/get_excel', 'v1.statistic.ProductStatistic/getExcel')->option(['real_name' => '商品数据导出']);
/** 交易统计 */

Loading…
Cancel
Save