| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- // +----------------------------------------------------------------------
- // | likeshop开源商城系统
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | gitee下载:https://gitee.com/likeshop_gitee
- // | github下载:https://github.com/likeshop-github
- // | 访问官网:https://www.likeshop.cn
- // | 访问社区:https://home.likeshop.cn
- // | 访问手册:http://doc.likeshop.cn
- // | 微信公众号:likeshop技术社区
- // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
- // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
- // | 禁止对系统程序代码以任何目的,任何形式的再发布
- // | likeshop团队版权所有并拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeshop.cn.team
- // +----------------------------------------------------------------------
- namespace app\shop\controller\order;
- use app\common\basics\ShopBase;
- use app\common\server\excel\Excel;
- use app\common\server\JsonServer;
- use app\shop\logic\order\DeliveryBatchLogic;
- use app\shop\validate\order\DeliveryBatchImportValidate;
- use PhpOffice\PhpSpreadsheet\Cell\DataType;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
- class DeliveryBatch extends ShopBase
- {
- /**
- * @notes 批量发货列表
- * @return \think\response\Json|\think\response\View
- * @author lbzy
- * @datetime 2025-03-06 18:10:51
- */
- function lists()
- {
- if ($this->request->isAjax()) {
- return JsonServer::success('', DeliveryBatchLogic::lists(input()));
- }
-
- return view();
- }
-
- /**
- * @notes 批量发货详情
- * @return \think\response\Json
- * @author lbzy
- * @datetime 2025-03-06 18:10:39
- */
- function detail()
- {
- return JsonServer::success('', [ 'detail' => DeliveryBatchLogic::detail(input('id/d')) ]);
- }
-
- /**
- * @notes 下载默认文件等
- * @return string|\think\response\File
- * @author lbzy
- * @datetime 2025-03-06 17:35:44
- */
- function down()
- {
- $filename = pathinfo(input('file/s'), PATHINFO_FILENAME);
- $path = app()->getRootPath() . 'public/static/excel/' . $filename . '.xls';
-
- if (! file_exists($path)) {
- return '文件不存在';
- }
-
- return download($path, $filename);
- }
-
- /**
- * @notes 下载导入失败的
- * @return void
- * @author lbzy
- * @datetime 2025-03-06 18:20:45
- */
- function down2()
- {
- $lists = DeliveryBatchLogic::getFailInfoLists(input('id/d'));
-
- Excel::out($lists, [
- [ 'field' => 'sn', 'title' => '订单编号', 'excel_data_type' => DataType::TYPE_STRING ],
- [ 'field' => 'express_name', 'title' => '快递公司名称' ],
- [ 'field' => 'express_no', 'title' => '快递单号' ],
- [ 'field' => 'fail_content', 'title' => '失败原因' ],
- ], '','', '导入失败订单');
- exit;
- }
-
- /**
- * @notes 立即导入
- * @return \think\response\Json
- * @author lbzy
- * @datetime 2025-03-06 17:56:34
- */
- function import()
- {
- $sheet = IOFactory::load($_FILES['file']['tmp_name'])->getActiveSheet();
- $sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
- $sheet->getStyle('B')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
- $sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
- $lists = $sheet->toArray(null, true, true, true);
-
- (new DeliveryBatchImportValidate())->goCheck('', [ 'lists' => $lists ]);
-
- $result = DeliveryBatchLogic::importLists($lists, $_FILES['file']['name']);
-
- return is_array($result) ? JsonServer::success('', $result) : JsonServer::error($result);
- }
-
- /**
- * @notes 执行导入页面
- * @return \think\response\Json|\think\response\View
- * @author lbzy
- * @datetime 2025-03-06 18:08:52
- */
- function delivery()
- {
- $detail = DeliveryBatchLogic::detail(input('id/d'));
-
- if ($this->request->isAjax()) {
- DeliveryBatchLogic::delivery($detail);
- return JsonServer::success('');
- }
-
- return view('', [
- 'detail' => $detail
- ]);
- }
- }
|