feat: 增加订单购物详情列表导出功能
This commit is contained in:
parent
8ea1011492
commit
919b4ba034
@ -9,13 +9,17 @@ use app\common\lists\ListsSearchInterface;
|
|||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\lists\ListsExcelInterface;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\store_order\StoreOrder;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单购物详情列表
|
* 订单购物详情列表
|
||||||
* Class StoreOrderCartInfoLists
|
* Class StoreOrderCartInfoLists
|
||||||
* @package app\admin\store_order_cart_info
|
* @package app\admin\store_order_cart_info
|
||||||
*/
|
*/
|
||||||
class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -45,15 +49,19 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return StoreOrderCartInfo::where($this->searchWhere)
|
return StoreOrderCartInfo::where($this->searchWhere)
|
||||||
->field('cart_info,product_id,store_id')->limit($this->limitOffset, $this->limitLength)
|
->field('cart_info,product_id,store_id,cart_num,price,total_price')->limit($this->limitOffset, $this->limitLength)
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,store_name,store_info')->find();
|
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find();
|
||||||
if($find){
|
if($find){
|
||||||
$item['image']=$find['image'];//商品图片
|
$item['image']=$find['image'];//商品图片
|
||||||
$item['store_name']=$find['store_name'];//商品名称
|
$item['store_name']=$find['store_name'];//商品名称
|
||||||
$item['store_info']=$find['store_info'];//商品规格
|
$item['store_info']=$find['store_info'];//商品规格
|
||||||
|
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??"";
|
||||||
|
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name')??"";
|
||||||
}else{
|
}else{
|
||||||
$item['image']='';//商品图片
|
$item['image']='';//商品图片
|
||||||
|
$item['unit_name']='';//商品图片
|
||||||
|
$item['cate_name']='';//商品图片
|
||||||
$item['store_name']='';//商品名称
|
$item['store_name']='';//商品名称
|
||||||
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
||||||
}
|
}
|
||||||
@ -72,5 +80,41 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return StoreOrderCartInfo::where($this->searchWhere)->count();
|
return StoreOrderCartInfo::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出文件名
|
||||||
|
* @return string
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setFileName(): string
|
||||||
|
{
|
||||||
|
if($this->request->get('oid')){
|
||||||
|
$order_id=StoreOrder::where('id',$this->request->get('oid'))->value('order_id');
|
||||||
|
return '订单'.$order_id.'商品详情';
|
||||||
|
}
|
||||||
|
return '订单商品详情';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出字段
|
||||||
|
* @return string[]
|
||||||
|
* @author 乔峰
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setExcelFields(): array
|
||||||
|
{
|
||||||
|
$data=[
|
||||||
|
'store_name' => '商品名称',
|
||||||
|
'store_info' => '规格',
|
||||||
|
'unit_name' => '单位',
|
||||||
|
'cate_name' => '分类',
|
||||||
|
'cart_num' => '数量',
|
||||||
|
'price' => '单价',
|
||||||
|
'total_price' => '总价',
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user