Merge pull request !149 from 赵世界/develop
This commit is contained in:
赵世界 2023-04-04 13:16:46 +00:00 committed by Gitee
commit 5bd346d76d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 41 additions and 25 deletions

View File

@ -47,13 +47,13 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
$shop = Shop::query()->find(1); $shop = Shop::query()->find(3);
$business = BusinessFactory::init()->make($shop->plat_id); $business = BusinessFactory::init()->make($shop->plat_id);
$business->setShop($shop); $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); // $res = $business->getOrderInfo($order->order_sn);
$endTime = DateTimeUtils::getMicroTime(); $endTime = DateTimeUtils::getMicroTime('2023-04-04 19:27:27');
$beginTime = $endTime - 3000; // $beginTime = $endTime - 3000;
$res = $business->getOrderInfo($beginTime, $endTime + 3000); $beginTime = DateTimeUtils::getMicroTime('2023-04-04 19:15:29');
} }
} }

View File

@ -38,27 +38,43 @@ class OrderBlankExport implements FromCollection, WithStyles
$data = [ $data = [
['店铺名称', $this->shopName], ['店铺名称', $this->shopName],
['跟团号', $noStr], ['跟团号', $noStr],
['种类', '品牌', '商品规格', '商品名称', '数量', '所在货架编号', '配货'], ['种类', '品牌', '商品名称', '数量', '货架', '配货'],
]; ];
$goodsCodes = array_column($excelDate, 'goods_code'); $goodsCodes = array_column($excelDate, 'goods_code');
$goods = Goods::query() $goods = Goods::query()
->with([ ->with([
'brand:id,name', 'brand:id,name',
'type:id,name', 'type:id,name',
'skus:id,goods_id,sku_code,title'
]) ])
->whereIn('goods_code', $goodsCodes) ->whereIn('goods_code', $goodsCodes)
->get(['goods_code', 'type_id', 'brand_id']) ->get(['id', 'title', 'goods_code', 'type_id', 'brand_id'])
->toArray(); ->toArray();
$goods = ArrayUtils::index($goods, 'goods_code'); $goods = ArrayUtils::index($goods, 'goods_code');
foreach ($excelDate as $key => $item) { 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']]; $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[0] = $goodsInfo['type']['name'];
$arr[1] = $goodsInfo['brand']['name']; $arr[1] = $goodsInfo['brand']['name'];
$arr[2] = $key; $arr[2] = $name;
$arr[3] = $item['goods_name']; $arr[3] = $item['num'];
$arr[4] = $item['num']; $arr[4] = $item['local'];
$arr[5] = $item['local']; $arr[5] = $str;
$arr[6] = implode(' ', $item['p']);
$data[] = $arr; $data[] = $arr;
} }
@ -67,20 +83,18 @@ class OrderBlankExport implements FromCollection, WithStyles
public function styles(Worksheet $sheet) public function styles(Worksheet $sheet)
{ {
$count = $this->count + 2; $count = $this->count + 3;
$sheet->mergeCells('B2:G2');
$sheet->getStyle('B2')->getAlignment() $sheet->getStyle('B2')->getAlignment()
->setVertical('center')
->setWrapText(true); ->setWrapText(true);
$sheet->getStyle('G3:G' . $count)->getAlignment() $sheet->mergeCells('B2:F2');
->setVertical('center') $sheet->getStyle('F3:F' . $count)->getAlignment()
->setWrapText(true); ->setWrapText(true);
$sheet->getColumnDimension('A')->setWidth(10); $sheet->getColumnDimension('A')->setWidth(8);
$sheet->getColumnDimension('B')->setWidth(10); $sheet->getColumnDimension('B')->setWidth(10);
$sheet->getColumnDimension('C')->setWidth(10); $sheet->getColumnDimension('C')->setWidth(36);
$sheet->getColumnDimension('D')->setWidth(60); $sheet->getColumnDimension('D')->setWidth(5);
$sheet->getColumnDimension('E')->setWidth(5); $sheet->getColumnDimension('E')->setWidth(5);
$sheet->getColumnDimension('F')->setWidth(11); $sheet->getColumnDimension('F')->setWidth(36);
$sheet->getColumnDimension('G')->setWidth(14); $sheet->getRowDimension(2)->setRowHeight(90);
} }
} }

View File

@ -52,15 +52,16 @@ class BusinessOrderController extends Controller
$distribution = []; $distribution = [];
$no = []; $no = [];
foreach ($orders as $key => $order) { foreach ($orders as $key => $order) {
$no[] = $order->participate_no; $index = $key + 1;
$no[] = 'P' . $index . '(' . $order->participate_no . ')';
foreach ($order->items as $item) { foreach ($order->items as $item) {
$item = $item->toArray(); $item = $item->toArray();
if (empty($item['external_sku_id'])) { if (empty($item['external_sku_id'])) {
continue; 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 = $key + 1;
$index = 'P' . $index . "({$order->participate_no}) * " . $item['goods_number']; $index = "P{$index}*{$item['goods_number']}";
[$goodsCode, $skuCode] = explode('_', $item['external_sku_id']); [$goodsCode, $skuCode] = explode('_', $item['external_sku_id']);
if (isset($distribution[$item['external_sku_id']])) { if (isset($distribution[$item['external_sku_id']])) {
$distribution[$item['external_sku_id']]['p'][] = $index; $distribution[$item['external_sku_id']]['p'][] = $index;
@ -72,6 +73,7 @@ class BusinessOrderController extends Controller
'num' => $item['goods_number'], 'num' => $item['goods_number'],
'goods_name' => $item['goods_name'], 'goods_name' => $item['goods_name'],
'goods_code' => $goodsCode, 'goods_code' => $goodsCode,
'sku_code' => $skuCode,
]; ];
} }
} }