|
@@ -19,6 +19,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|
|
use Intervention\Image\Facades\Image;
|
|
|
use Intervention\Image\Gd\Font;
|
|
|
+use App\Models\Custom\Shoptype;
|
|
|
|
|
|
/**
|
|
|
* 订单管理
|
|
@@ -38,7 +39,7 @@ class Orders extends Auth{
|
|
|
* 首页列表
|
|
|
*
|
|
|
* */
|
|
|
- public function index(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
|
|
|
+ public function index(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom,Shoptype $Shoptype){
|
|
|
// 接受参数
|
|
|
$code = request('order_code','');
|
|
|
$orders_other = request('orders_other',0);
|
|
@@ -86,7 +87,7 @@ class Orders extends Auth{
|
|
|
->orderByDesc('id')
|
|
|
->select([
|
|
|
'orders_product.*','custom.username as custom_name','orders.regiment_id as regiment_id',
|
|
|
- 'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
|
|
|
+ 'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.shop_type','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
|
|
|
])
|
|
|
->paginate(request('limit',config('page_num',10)))->appends(request()->all());
|
|
|
// 循环处理数据
|
|
@@ -95,6 +96,7 @@ class Orders extends Auth{
|
|
|
$value['order_code'] = $Model->idToCode($value['order_id']);
|
|
|
$value['custom_code'] = $Custom->idToCode($value['custom_uid']);
|
|
|
$value['state'] = $Model->getState($value['status'],'state');
|
|
|
+ $value['shop_type'] = $Shoptype->getOne($value['shop_type'],'name');
|
|
|
$value['product_code'] = $value['product_id'] ? $Product->idToCode($value['product_id']) : '— —';
|
|
|
// 重组
|
|
|
$list[$key] = $value;
|
|
@@ -362,7 +364,7 @@ class Orders extends Auth{
|
|
|
* 导出表格导入
|
|
|
*
|
|
|
* */
|
|
|
- public function down_excel(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
|
|
|
+ public function down_excel(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom,Shoptype $Shoptype){
|
|
|
// 接受参数
|
|
|
$code = request('order_code','');
|
|
|
$productCode = request('product_code','');
|
|
@@ -417,7 +419,7 @@ class Orders extends Auth{
|
|
|
'orders_product.status',
|
|
|
'orders_product.insert_time',
|
|
|
'custom.username as custom_name','custom.weiban_extid as weiban_extid',
|
|
|
- 'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
|
|
|
+ 'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.shop_type','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
|
|
|
])->get()->toArray();
|
|
|
// 返回结果
|
|
|
$data = [];
|
|
@@ -443,6 +445,7 @@ class Orders extends Auth{
|
|
|
$data[$value['order_id']]['contact_city'] = $value['contact_city'];
|
|
|
$data[$value['order_id']]['contact_area'] = $value['contact_area'];
|
|
|
$data[$value['order_id']]['contact_addr'] = $value['contact_addr'] .($value['contact_shop'] ? '【'.$value['contact_shop'].'】' : '');
|
|
|
+ $data[$value['order_id']]['shop_type'] = $value['shop_type'] ? $Shoptype->getOne($value['shop_type'],'name') : '';
|
|
|
// 子订单
|
|
|
$data[$value['order_id']]['product'][] = ['product_id'=>$value['product_id'] ? $Product->idToCode($value['product_id']) : '— —','product_name'=>$value['product_name'],'product_spec'=>$value['product_spec'],'product_thumb'=>$value['product_thumb'],'product_price'=>$value['product_price'],'pay_price'=>$value['pay_price'],'buy_num'=>$value['buy_num'],'pay_total'=>$value['pay_total'],'price_total'=>$value['price_total'],'coupon_total'=>$value['coupon_total']];
|
|
|
}
|
|
@@ -483,16 +486,17 @@ class Orders extends Auth{
|
|
|
$sheet->setCellValue('H'.$row, $value['contact_city']);
|
|
|
$sheet->setCellValue('I'.$row, $value['contact_area']);
|
|
|
$sheet->setCellValue('J'.$row, $value['contact_addr']);
|
|
|
- $sheet->setCellValue('K'.$row, $v['product_id']);
|
|
|
- $sheet->setCellValue('L'.$row, $v['product_name']);
|
|
|
- $sheet->setCellValue('M'.$row, $v['product_spec']);
|
|
|
- $sheet->setCellValue('N'.$row, $v['product_price']);
|
|
|
- $sheet->setCellValue('O'.$row, $v['pay_price']);
|
|
|
- $sheet->setCellValue('P'.$row, $v['buy_num']);
|
|
|
- $sheet->setCellValue('Q'.$row, $v['coupon_total']);
|
|
|
- $sheet->setCellValue('R'.$row, $v['pay_total']);
|
|
|
- $sheet->setCellValue('S'.$row, $value['weiban_extid']);
|
|
|
- $sheet->setCellValue('T'.$row, date('Y-m-d H:i:s',$value['insert_time']));
|
|
|
+ $sheet->setCellValue('K'.$row, $value['shop_type']);
|
|
|
+ $sheet->setCellValue('L'.$row, $v['product_id']);
|
|
|
+ $sheet->setCellValue('M'.$row, $v['product_name']);
|
|
|
+ $sheet->setCellValue('N'.$row, $v['product_spec']);
|
|
|
+ $sheet->setCellValue('O'.$row, $v['product_price']);
|
|
|
+ $sheet->setCellValue('P'.$row, $v['pay_price']);
|
|
|
+ $sheet->setCellValue('Q'.$row, $v['buy_num']);
|
|
|
+ $sheet->setCellValue('R'.$row, $v['coupon_total']);
|
|
|
+ $sheet->setCellValue('S'.$row, $v['pay_total']);
|
|
|
+ $sheet->setCellValue('T'.$row, $value['weiban_extid']);
|
|
|
+ $sheet->setCellValue('U'.$row, date('Y-m-d H:i:s',$value['insert_time']));
|
|
|
// 函数自增
|
|
|
$row++;
|
|
|
}
|
|
@@ -524,22 +528,23 @@ class Orders extends Auth{
|
|
|
$sheet->getColumnDimension('H')->setWidth(15);
|
|
|
$sheet->getColumnDimension('I')->setWidth(15);
|
|
|
$sheet->getColumnDimension('J')->setWidth(50);
|
|
|
- $sheet->getColumnDimension('K')->setWidth(20);
|
|
|
- $sheet->getColumnDimension('L')->setWidth(80);
|
|
|
+ $sheet->getColumnDimension('K')->setWidth(15);
|
|
|
+ $sheet->getColumnDimension('L')->setWidth(20);
|
|
|
$sheet->getColumnDimension('M')->setWidth(80);
|
|
|
- $sheet->getColumnDimension('N')->setWidth(10);
|
|
|
+ $sheet->getColumnDimension('N')->setWidth(80);
|
|
|
$sheet->getColumnDimension('O')->setWidth(10);
|
|
|
$sheet->getColumnDimension('P')->setWidth(10);
|
|
|
$sheet->getColumnDimension('Q')->setWidth(10);
|
|
|
$sheet->getColumnDimension('R')->setWidth(10);
|
|
|
- $sheet->getColumnDimension('S')->setWidth(50);
|
|
|
- $sheet->getColumnDimension('T')->setWidth(20);
|
|
|
+ $sheet->getColumnDimension('S')->setWidth(10);
|
|
|
+ $sheet->getColumnDimension('T')->setWidth(50);
|
|
|
+ $sheet->getColumnDimension('U')->setWidth(20);
|
|
|
// 默认高度
|
|
|
$sheet->getDefaultRowDimension()->setRowHeight(18);
|
|
|
// 加粗第一行
|
|
|
- $sheet->getStyle('A:T')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
- $sheet->getStyle('A1:T1')->getFont()->setBold(true);
|
|
|
- $sheet->getStyle('A1:T1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF00FF00'); // ARGB颜色代码,例如绿色
|
|
|
+ $sheet->getStyle('A:U')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
|
|
|
+ $sheet->getStyle('A1:U1')->getFont()->setBold(true);
|
|
|
+ $sheet->getStyle('A1:U1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF00FF00'); // ARGB颜色代码,例如绿色
|
|
|
// 设置表格标题
|
|
|
$sheet
|
|
|
->setCellValue('A1', '订单ID')
|
|
@@ -552,16 +557,17 @@ class Orders extends Auth{
|
|
|
->setCellValue('H1', '市')
|
|
|
->setCellValue('I1', '区县')
|
|
|
->setCellValue('J1', '收货地址')
|
|
|
- ->setCellValue('K1', '产品编码')
|
|
|
- ->setCellValue('L1', '产品名称')
|
|
|
- ->setCellValue('M1', '产品规格')
|
|
|
- ->setCellValue('N1', '产品单价')
|
|
|
- ->setCellValue('O1', '折后单价')
|
|
|
- ->setCellValue('P1', '产品数量')
|
|
|
- ->setCellValue('Q1', '优惠金额')
|
|
|
- ->setCellValue('R1', '产品金额')
|
|
|
- ->setCellValue('S1', '微伴ID')
|
|
|
- ->setCellValue('T1', '下单时间');
|
|
|
+ ->setCellValue('K1', '终端类型')
|
|
|
+ ->setCellValue('L1', '产品编码')
|
|
|
+ ->setCellValue('M1', '产品名称')
|
|
|
+ ->setCellValue('N1', '产品规格')
|
|
|
+ ->setCellValue('O1', '产品单价')
|
|
|
+ ->setCellValue('P1', '折后单价')
|
|
|
+ ->setCellValue('Q1', '产品数量')
|
|
|
+ ->setCellValue('R1', '优惠金额')
|
|
|
+ ->setCellValue('S1', '产品金额')
|
|
|
+ ->setCellValue('T1', '微伴ID')
|
|
|
+ ->setCellValue('U1', '下单时间');
|
|
|
// 返回结果
|
|
|
return $sheet;
|
|
|
}
|