diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 18db415..cb0cf37 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -47,13 +47,13 @@ class Test extends Command */ public function handle() { - $shop = Shop::query()->find(1); + $shop = Shop::query()->find(3); $business = BusinessFactory::init()->make($shop->plat_id); $business->setShop($shop); - $order = BusinessOrder::query()->where('shop_id', 1)->where('participate_no', 6436)->first(); +// $order = BusinessOrder::query()->where('shop_id', 1)->where('participate_no', 6436)->first(); // $res = $business->getOrderInfo($order->order_sn); - $endTime = DateTimeUtils::getMicroTime(); - $beginTime = $endTime - 3000; - $res = $business->getOrderInfo($beginTime, $endTime + 3000); + $endTime = DateTimeUtils::getMicroTime('2023-04-04 19:27:27'); +// $beginTime = $endTime - 3000; + $beginTime = DateTimeUtils::getMicroTime('2023-04-04 19:15:29'); } } diff --git a/app/Exports/OrderBlankExport.php b/app/Exports/OrderBlankExport.php index 7061059..c7c617a 100644 --- a/app/Exports/OrderBlankExport.php +++ b/app/Exports/OrderBlankExport.php @@ -38,27 +38,43 @@ class OrderBlankExport implements FromCollection, WithStyles $data = [ ['店铺名称', $this->shopName], ['跟团号', $noStr], - ['种类', '品牌', '商品规格', '商品名称', '数量', '所在货架编号', '配货'], + ['种类', '品牌', '商品名称', '数量', '货架', '配货'], ]; $goodsCodes = array_column($excelDate, 'goods_code'); $goods = Goods::query() ->with([ 'brand:id,name', 'type:id,name', + 'skus:id,goods_id,sku_code,title' ]) ->whereIn('goods_code', $goodsCodes) - ->get(['goods_code', 'type_id', 'brand_id']) + ->get(['id', 'title', 'goods_code', 'type_id', 'brand_id']) ->toArray(); $goods = ArrayUtils::index($goods, 'goods_code'); foreach ($excelDate as $key => $item) { + $str = ''; + $num = 0; + foreach ($item['p'] as $k => $v) { + $str .= $v . ';'; + $num++; + if (6 === $num) { + $str .= PHP_EOL; + $num = 0; + } + } $goodsInfo = $goods[$item['goods_code']]; + $name = ''; + foreach ($goodsInfo['skus'] as $sku) { + if ($sku['sku_code'] === $item['sku_code']) { + $name = $goodsInfo['title'] . $sku['title']; + } + } $arr[0] = $goodsInfo['type']['name']; $arr[1] = $goodsInfo['brand']['name']; - $arr[2] = $key; - $arr[3] = $item['goods_name']; - $arr[4] = $item['num']; - $arr[5] = $item['local']; - $arr[6] = implode(' ', $item['p']); + $arr[2] = $name; + $arr[3] = $item['num']; + $arr[4] = $item['local']; + $arr[5] = $str; $data[] = $arr; } @@ -67,20 +83,18 @@ class OrderBlankExport implements FromCollection, WithStyles public function styles(Worksheet $sheet) { - $count = $this->count + 2; - $sheet->mergeCells('B2:G2'); + $count = $this->count + 3; $sheet->getStyle('B2')->getAlignment() - ->setVertical('center') ->setWrapText(true); - $sheet->getStyle('G3:G' . $count)->getAlignment() - ->setVertical('center') + $sheet->mergeCells('B2:F2'); + $sheet->getStyle('F3:F' . $count)->getAlignment() ->setWrapText(true); - $sheet->getColumnDimension('A')->setWidth(10); + $sheet->getColumnDimension('A')->setWidth(8); $sheet->getColumnDimension('B')->setWidth(10); - $sheet->getColumnDimension('C')->setWidth(10); - $sheet->getColumnDimension('D')->setWidth(60); + $sheet->getColumnDimension('C')->setWidth(36); + $sheet->getColumnDimension('D')->setWidth(5); $sheet->getColumnDimension('E')->setWidth(5); - $sheet->getColumnDimension('F')->setWidth(11); - $sheet->getColumnDimension('G')->setWidth(14); + $sheet->getColumnDimension('F')->setWidth(36); + $sheet->getRowDimension(2)->setRowHeight(90); } } diff --git a/app/Http/Controllers/Business/BusinessOrderController.php b/app/Http/Controllers/Business/BusinessOrderController.php index 18089f4..b3944bf 100644 --- a/app/Http/Controllers/Business/BusinessOrderController.php +++ b/app/Http/Controllers/Business/BusinessOrderController.php @@ -52,15 +52,16 @@ class BusinessOrderController extends Controller $distribution = []; $no = []; foreach ($orders as $key => $order) { - $no[] = $order->participate_no; + $index = $key + 1; + $no[] = 'P' . $index . '(' . $order->participate_no . ')'; foreach ($order->items as $item) { $item = $item->toArray(); if (empty($item['external_sku_id'])) { continue; } - $local = $item['goods_sku_location'] ? $item['goods_sku_location']['location'] : '货架未找到'; + $local = $item['goods_sku_location'] ? $item['goods_sku_location']['location'] : '无'; $index = $key + 1; - $index = 'P' . $index . "({$order->participate_no}) * " . $item['goods_number']; + $index = "P{$index}*{$item['goods_number']}"; [$goodsCode, $skuCode] = explode('_', $item['external_sku_id']); if (isset($distribution[$item['external_sku_id']])) { $distribution[$item['external_sku_id']]['p'][] = $index; @@ -72,6 +73,7 @@ class BusinessOrderController extends Controller 'num' => $item['goods_number'], 'goods_name' => $item['goods_name'], 'goods_code' => $goodsCode, + 'sku_code' => $skuCode, ]; } }