|
|
|
@ -15,6 +15,10 @@ namespace app\controller\admin\v1\statistic; |
|
|
|
|
use app\controller\admin\AuthController; |
|
|
|
|
use app\services\product\category\StoreProductCategoryServices; |
|
|
|
|
use app\services\statistic\ProductStatisticServices; |
|
|
|
|
use app\services\order\StoreOrderServices; |
|
|
|
|
use app\services\store\SystemStoreServices; |
|
|
|
|
use app\services\product\product\StoreProductServices; |
|
|
|
|
use app\services\order\StoreOrderCartInfoServices; |
|
|
|
|
use think\facade\App; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -81,7 +85,56 @@ class ProductStatistic extends AuthController |
|
|
|
|
$where['time'] = $this->getDay($where['time']); |
|
|
|
|
return $this->success($this->services->getProductRanking($where)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getProductcount(StoreProductCategoryServices $storeProductCategoryServices) |
|
|
|
|
{ |
|
|
|
|
$where = $this->request->getMore([ |
|
|
|
|
['cate_id', ''], |
|
|
|
|
['data', '', '', 'time'], |
|
|
|
|
['sort', ''] |
|
|
|
|
]); |
|
|
|
|
//查询所有已支付的订单 |
|
|
|
|
/** @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(['paid'=>1]); |
|
|
|
|
$products = []; |
|
|
|
|
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'] = $v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['price']; |
|
|
|
|
$v['cart_info']['productInfo']['youhui'] = $v['cart_info']['productInfo']['sum_price']-$v['cart_info']['productInfo']['sum_true_price']; |
|
|
|
|
$v['cart_info']['productInfo']['cost'] = $v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['cost']; |
|
|
|
|
$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[] = $v['cart_info']['productInfo']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$cateId = $where['cate_id']; |
|
|
|
|
if ($cateId) { |
|
|
|
|
$cateId = is_string($cateId) ? [$cateId] : $cateId; |
|
|
|
|
$cateId = array_merge($cateId, $storeProductCategoryServices->getColumn(['pid' => $cateId], 'id')); |
|
|
|
|
$cateId = array_unique(array_diff($cateId, [0])); |
|
|
|
|
} |
|
|
|
|
$where['cate_id'] = $cateId; |
|
|
|
|
$where['time'] = $this->getDay($where['time']); |
|
|
|
|
return $this->success($products); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 导出 |
|
|
|
|
* @return mixed |
|
|
|
|