feat: 添加了根据订单ID获取订单详细信息的功能

This commit is contained in:
mkm 2024-09-25 17:40:46 +08:00
parent 1d8e9a9a36
commit 64396fe1b5
10 changed files with 403 additions and 17 deletions

View File

@ -10,6 +10,7 @@ use app\admin\logic\warehouse_order\WarehouseOrderLogic;
use app\admin\logic\warehouse_product\WarehouseProductLogic;
use app\admin\validate\warehouse_order\WarehouseOrderValidate;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
@ -263,6 +264,13 @@ class WarehouseOrderController extends BaseAdminController
$order['delivery_time']=date('Y-m-d H:i:s',$order['delivery_time']);
$order['pay_time']=$order['create_time'];
$order['order_id']=$order['code'];
if($order['oid']>0){
$orders=StoreOrder::where('id',$order['oid'])->findOrEmpty();
$order['real_name']=$orders['real_name'];
$order['user_phone']=$orders['user_phone'];
$order['user_address']=$orders['user_address'];
}
$file_path = $xlsx->export($data, $system_store, $order);
return $this->success('导出成功', ['url' => $file_path]);

View File

@ -4,8 +4,8 @@ namespace app\api\controller\store_order_cart_info;
use app\api\controller\BaseApiController;
use app\api\lists\store_order_cart_info\CateLists;
use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists;
use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists;
/**
* 商品销量控制器
@ -22,8 +22,13 @@ class StoreOrderCartInfoController extends BaseApiController
*/
public function lists()
{
return $this->dataLists(new CateLists());
$this->request->__set('store_id',5);
return $this->dataLists(new StoreOrderCartInfoLists());
}
public function group_lists()
{
$this->request->__set('store_id',5);
return $this->dataLists(new StoreOrderCartInfoGroupLists());
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace app\api\controller\system_store_storage;
use app\api\controller\BaseApiController;
use app\api\lists\system_store_storage\SystemStoreStorageLists;
use app\api\lists\system_store_storage\SystemStoreStorageGroupLists;
/**
* 门店入库控制器
* Class SystemStoreStorageController
* @package app\admin\controller\goods
*/
class SystemStoreStorageController extends BaseApiController
{
/**
* @notes 获取商品分类列表
* @return
* @author likeadmin
* @date 2024/04/23 10:27
*/
public function lists()
{
return $this->dataLists(new SystemStoreStorageLists());
}
/**
* @notes 获取商品分类列表
* @return
* @author likeadmin
* @date 2024/04/23 10:27
*/
public function group_lists()
{
return $this->dataLists(new SystemStoreStorageGroupLists());
}
}

View File

@ -46,7 +46,6 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
$userId = $this->request->userId;
if (!$userId) return [];
$data = StoreOrder::with(['store'])->where($this->searchWhere)->where(['uid'=>$userId])
->whereIn('shipping_type',[1,2])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()

View File

@ -0,0 +1,96 @@
<?php
namespace app\api\lists\store_order_cart_info;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_category\StoreCategory;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_unit\StoreProductUnit;
/**
* 订单购物详情列表
* Class StoreOrderCartInfoGroupLists
* @package app\api\operation
*/
class StoreOrderCartInfoGroupLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
*/
public function setSearch(): array
{
return [
'between_time' => 'create_time'
];
}
/**
* @notes 获取地址列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @date 2024/04/27 11:26
*/
public function lists(): array
{
$store_id = $this->request->__get('store_id');
if (!$store_id) return [];
if ($this->request->get('store_name')) {
$store_name = $this->request->get('store_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
} else {
return [];
}
}
$this->searchWhere[] = ['is_pay', '=', 1];
$this->searchWhere[] = ['status', '>=', 0];
$this->searchWhere[] = ['store_id', '=', $store_id];
$query = StoreOrderCartInfo::where($this->searchWhere);
$query->field('store_id,product_id,price,sum(total_price) as total_price,sum(cart_num) as cart_num');
return $query->limit($this->limitOffset, $this->limitLength)
->group('product_id')
->select()->each(function ($item) {
$find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find();
if ($find) {
$item['image'] = $find['image']; //商品图片
$item['store_name'] = $find['store_name']; //商品名称
$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 {
$item['image'] = ''; //商品图片
$item['store_name'] = ''; //商品名称
$item['store_info'] = ''; //商品规格-(数据库叫商品简介)
$item['unit_name'] = ''; //
$item['cate_name'] = ''; //
$item['system_store'] = ''; //
}
return $item; //返回处理后的数据。
})
->toArray();
}
/**
* @notes 获取地址数量
* @return int
* @date 2024/04/27 11:26
*/
public function count(): int
{
return StoreOrderCartInfo::where($this->searchWhere)->count();
}
}

View File

@ -44,19 +44,20 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
{
$store_id=$this->request->__get('store_id');
if(!$store_id) return [];
// if ($this->request->get('start_time') == '') {
// $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
// }
$is_group=$this->request->get('is_group');
if ($this->request->get('store_name')) {
$store_name = $this->request->get('store_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
} else {
return [];
}
}
$this->searchWhere[] = ['is_pay', '=', 1];
$this->searchWhere[] = ['status', '>=', 0];
$this->searchWhere[] = ['store_id', '=', 1];
$this->searchWhere[] = ['store_id', '=', $store_id];
$query = StoreOrderCartInfo::where($this->searchWhere);
if ($is_group == 1) {
$query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']);
} else {
$query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid');
}
$query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid');
return $query->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item){
$find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find();

View File

@ -0,0 +1,115 @@
<?php
namespace app\api\lists\system_store_storage;
use app\api\lists\BaseApiDataLists;
use app\common\model\store_product\StoreProduct;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\system_store_storage\SystemStoreStorage;
/**
* 门店入库列表
* Class goods
* @package app\api\goods
*/
class SystemStoreStorageGroupLists extends BaseApiDataLists implements ListsSearchInterface,ListsSortInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function setSearch(): array
{
return [
'between_time' => 'create_time',
];
}
/**
* @notes 设置支持排序字段
* @return string[]
* @date 2021/12/29 10:07
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
*/
public function setSortFields(): array
{
return [];
}
/**
* @notes 设置默认排序
* @return string[]
* @date 2021/12/29 10:06
*/
public function setDefaultOrder(): array
{
return ['id' => 'desc'];
}
/**
* @notes 获取商品列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function lists(): array
{
$fields = 'store_id,product_id,sum(nums) as nums,mark';
if ($this->request->get('store_name')) {
$store_name = $this->request->get('store_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
} else {
return [];
}
}
$this->searchWhere[] = ['type', '=', 1];
$this->searchWhere[] = ['status', '=', 1];
return SystemStoreStorage::where($this->searchWhere)
->field($fields)
->group('product_id')
->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder)
->select()->each(function ($item) {
$find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName'])
->field('id,store_name,image,unit,cate_id,store_info')->find();
if($find){
$item['store_name'] = $find['store_name'];
$item['image'] = $find['image'];
$item['unit_name'] = $find['unit_name'];
$item['class_name'] = $find['class_name'];
$item['store_info'] = $find['store_info'];
}else{
$item['product_name'] = '';
$item['product_image'] = '';
$item['product_unit'] = '';
$item['product_cate'] = '';
$item['store_info'] = '';
}
return $item;
})
->toArray();
}
/**
* @notes 获取商品列表数量
* @return int
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function count(): int
{
return SystemStoreStorage::where($this->searchWhere)
->count();
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace app\api\lists\system_store_storage;
use app\api\lists\BaseApiDataLists;
use app\common\model\store_product\StoreProduct;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\system_store_storage\SystemStoreStorage;
/**
* 门店入库列表
* Class goods
* @package app\api\goods
*/
class SystemStoreStorageLists extends BaseApiDataLists implements ListsSearchInterface,ListsSortInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function setSearch(): array
{
return [
'between_time' => 'create_time',
];
}
/**
* @notes 设置支持排序字段
* @return string[]
* @date 2021/12/29 10:07
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
*/
public function setSortFields(): array
{
return [];
}
/**
* @notes 设置默认排序
* @return string[]
* @date 2021/12/29 10:06
*/
public function setDefaultOrder(): array
{
return ['id' => 'desc'];
}
/**
* @notes 获取商品列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function lists(): array
{
$fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status';
if ($this->request->get('store_name')) {
$store_name = $this->request->get('store_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
} else {
return [];
}
}
$this->searchWhere[] = ['type', '=', 1];
return SystemStoreStorage::where($this->searchWhere)
->field($fields)
->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder)
->select()->each(function ($item) {
if($item['staff_id']>0){
$item['staff_name']=SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
}
$find=StoreProduct::where('id', $item['product_id'])->with(['className', 'unitName'])
->field('id,store_name,image,unit,cate_id,store_info')->find();
if($find){
$item['store_name'] = $find['store_name'];
$item['image'] = $find['image'];
$item['unit_name'] = $find['unit_name'];
$item['class_name'] = $find['class_name'];
$item['store_info'] = $find['store_info'];
}else{
$item['product_name'] = '';
$item['product_image'] = '';
$item['product_unit'] = '';
$item['product_cate'] = '';
$item['store_info'] = '';
}
return $item;
})
->toArray();
}
/**
* @notes 获取商品列表数量
* @return int
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function count(): int
{
return SystemStoreStorage::where($this->searchWhere)
->count();
}
}

View File

@ -217,7 +217,6 @@ class OrderLogic extends BaseLogic
// }
//成本价 收益
$order = [
'create_time' => time(),
'order_id' => $params['order_id'] ?? getNewOrderId('PF'),
'total_price' => self::$total_price, //总价
'cost' => self::$cost, //成本价1-

View File

@ -109,8 +109,16 @@ class OrderDetail
$sheet->setCellValue('A' . $count + 12, '下单人',);
$sheet->mergeCells('B' . ($count + 12) . ':C' . $count + 12);
$sheet->setCellValue('B' . ($count + 12), $order['real_name']??'');
$sheet->setCellValue('D' . $count + 12, '电话');
$sheet->mergeCells('E' . ($count + 12) . ':F' . $count + 12);
$sheet->setCellValue('E' . ($count + 12), $order['user_phone']??'');
$sheet->setCellValue('G' . $count + 12, '地址');
$sheet->mergeCells('H' . ($count + 12) . ':J' . $count + 12);
$sheet->setCellValue('H' . ($count + 12), $order['user_address']??'');
$sheet->setCellValue('A' . $count + 13, '仓库',);
$sheet->mergeCells('B' . ($count + 13) . ':C' . $count + 13);
$sheet->setCellValue('D' . $count + 13, '送货');