diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index ca59aa15d..4b5db2cb1 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -47,7 +47,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte public function lists(): array { return BeforehandOrder::where($this->searchWhere) - ->field(['id','order_id','store_id','order_type','total_num','total_price','outbound_id','admin_id','create_time', 'status', 'mark','warehousing_id']) + ->field(['id','order_id','store_id','order_type','total_num','total_price','outbound_id','admin_id','create_time', 'status', 'mark','warehousing_id','file']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item){ diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 0cc2cfe7b..df87e37d2 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -27,6 +27,7 @@ use app\common\service\xlsx\OrderAllocation; use app\common\service\xlsx\OrderInfo; use app\common\service\xlsx\OrderList; use app\common\service\xlsx\OrderOutbound; +use DateTime; use support\exception\BusinessException; use think\facade\Db; @@ -102,12 +103,11 @@ class BeforehandOrderLogic extends BaseLogic 'phone' => $params['phone'] ?? '', 'address' => $params['address'] ?? '', 'mark' => $params['mark'] ?? '', - 'arrival_time' => strtotime($params['arrival_time']), 'order_type' => $order_type, 'other_data' => json_encode($params['other_data'], true) ]); /** 添加审批记录 */ - BeforehandOrderRecord::create(['oid'=>$order['id'],'step_id'=>1]); + BeforehandOrderRecord::create(['oid' => $order['id'], 'step_id' => 1]); $product_arr = []; foreach ($datas as $k => $v) { $datas[$k]['bhoid'] = $order['id']; @@ -308,23 +308,14 @@ class BeforehandOrderLogic extends BaseLogic { Db::startTrans(); try { - BeforehandOrder::where('id', $params['id'])->update([ - 'store_id' => $params['store_id'], - 'order_id' => $params['order_id'], - 'uid' => $params['uid'], - 'cart_id' => $params['cart_id'], - 'total_num' => $params['total_num'], - 'total_price' => $params['total_price'], - 'pay_price' => $params['pay_price'], - 'deduction_price' => $params['deduction_price'], - 'paid' => $params['paid'], - 'pay_time' => $params['pay_time'], - 'pay_type' => $params['pay_type'], - 'source' => $params['source'], - 'status' => $params['status'], + $find=BeforehandOrder::where('id', $params['id'])->find(); + $other_data=$find['other_data']; + $other_data['arrival_time']=strtotime($params['arrival_time']); + $find->update([ + 'other_data'=>json_encode($other_data, true), + 'image' => $params['image'], 'mark' => $params['mark'] ]); - Db::commit(); return true; } catch (\Throwable $e) { @@ -508,8 +499,7 @@ class BeforehandOrderLogic extends BaseLogic */ public static function detail($params): array { - $res = BeforehandOrder::findOrEmpty($params['id'])->toArray(); - + $res = BeforehandOrder::where('id',$params['id'])->find()->toArray(); $ids = BeforehandOrderCartInfo::where('bhoid', $params['id'])->column('product_id'); $top_cate_ids = StoreProduct::where('id', 'in', $ids)->column('top_cate_id'); if ($top_cate_ids) { @@ -519,14 +509,13 @@ class BeforehandOrderLogic extends BaseLogic } $res['system_store'] = SystemStore::where('id', $res['store_id'])->value('name'); $res['admin_name'] = Admin::where('id', $res['admin_id'])->value('name'); - $record=BeforehandOrderRecord::where('oid',$params['id'])->order('id','desc')->find(); - $res['step_id']=1; - if($record){ - $res['step_id']=$record['step_id']; - if($record['check_user_id']>0){ - $res['examine_name']=Admin::where('id',$record['check_user_id'])->value('name'); + $record = BeforehandOrderRecord::where('oid', $params['id'])->order('id', 'desc')->find(); + $res['step_id'] = 1; + if ($record) { + $res['step_id'] = $record['step_id']; + if ($record['check_user_id'] > 0) { + $res['examine_name'] = Admin::where('id', $record['check_user_id'])->value('name'); } - } return $res; } @@ -568,6 +557,19 @@ class BeforehandOrderLogic extends BaseLogic }); $other_data = $order['other_data']; unset($order['other_data']); + $dateTime = new DateTime($order['create_time']); + $hour = (int) $dateTime->format('H'); + // 判断时间是否小于18点 + if ($hour < 18) { + // 时间小于18点的逻辑 + $data['storage_time'] = $dateTime->modify('+60 minutes')->format('Y-m-d H:i:s'); + $data['delivery_time'] = $dateTime->modify('+90 minutes')->format('Y-m-d H:i:s'); + } else { + // 时间大于或等于18点的逻辑 + $data['storage_time'] = $dateTime->modify('+150 minutes')->format('Y-m-d H:i:s'); + $data['delivery_time'] = $dateTime->modify('+205 minutes')->format('Y-m-d H:i:s'); + } + $data['split_time'] = $dateTime->modify('+10 minutes')->format('Y-m-d H:i:s'); $file_path = $order_allocation->export($data, $order, $other_data); return $file_path; } @@ -595,7 +597,7 @@ class BeforehandOrderLogic extends BaseLogic return $file_path; } - /** + /** * 导出出库 */ public static function OrderOutbound($params) @@ -609,7 +611,7 @@ class BeforehandOrderLogic extends BaseLogic $item['store_name'] = $find['store_name']; return $item; }); - $order['system_store_name']=SystemStore::where('id', $order['store_id'])->value('name'); + $order['system_store_name'] = SystemStore::where('id', $order['store_id'])->value('name'); $other_data = $order['other_data']; unset($order['other_data']); $file_path = $order_info->export($data, $order, $other_data); diff --git a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php index 086d239f5..e16e5e766 100644 --- a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php +++ b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\warehouse_product_return; use app\common\model\warehouse_product_return\WarehouseProductReturn; use app\common\logic\BaseLogic; +use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use support\exception\BusinessException; @@ -33,8 +34,10 @@ class WarehouseProductReturnLogic extends BaseLogic try { $find=WarehouseProduct::where('id',$params['id'])->find(); if($find){ + $id=BeforehandOrder::where('id',$find['oid'])->value('id'); WarehouseProductReturn::create([ 'source_id'=>$params['id'], + 'bhoid'=>$id??0, 'warehouse_id'=>$find['warehouse_id'], 'supplier_id'=>$find['supplier_id'], 'store_id'=>$find['store_id'], diff --git a/app/common/service/xlsx/OrderAllocation.php b/app/common/service/xlsx/OrderAllocation.php index f149d4262..b94eab94b 100644 --- a/app/common/service/xlsx/OrderAllocation.php +++ b/app/common/service/xlsx/OrderAllocation.php @@ -128,19 +128,17 @@ class OrderAllocation $sheet->setCellValue('N' . ($count + 8),$other_data->regional_manager??''); $sheet->setCellValue('A' . ($count + 9),'接单时间'); - $sheet->setCellValue('B' . ($count + 9),''); + $sheet->setCellValue('B' . ($count + 9),$order['create_time']??''); $sheet->setCellValue('C' . ($count + 9),'分单时间'); - $sheet->setCellValue('D' . ($count + 9),''); + $sheet->setCellValue('D' . ($count + 9),$order['split_time']??''); $sheet->setCellValue('E' . ($count + 9),'入库时间'); - $sheet->setCellValue('F' . ($count + 9),''); - $sheet->setCellValue('G' . ($count + 9),' 出库时间'); - $sheet->setCellValue('H' . ($count + 9),''); + $sheet->setCellValue('F' . ($count + 9),$order['storage_time']??''); + $sheet->setCellValue('G' . ($count + 9),' 分拣时间'); + $sheet->setCellValue('H' . ($count + 9),$order['delivery_time']??''); $sheet->setCellValue('I' . ($count + 9),' 到门店时间'); $sheet->setCellValue('J' . ($count + 9),''); $sheet->setCellValue('K' . ($count + 9),' 下单到货时间'); $sheet->setCellValue('L' . ($count + 9),''); - $sheet->setCellValue('M' . ($count + 9),' 实际到货时间'); - $sheet->setCellValue('N' . ($count + 9),''); // 设置单元格的样式 $styleArray = [ 'font' => [ diff --git a/app/functions.php b/app/functions.php index 2f3150285..2548a2290 100644 --- a/app/functions.php +++ b/app/functions.php @@ -546,3 +546,18 @@ function channelLog($data, $type, $title = '更新前') $log = Log::channel($type); $log->info($title, $data); } + +// if (!function_exists('getNewOrderSn')) { + +// /** +// * @notes 获取订单号 +// * @param $type +// * @return string +// */ +// function getNewOrderSn($type) +// { +// list($msec, $sec) = explode(' ', microtime()); +// $orderId = $type . date('YmdHis', time()); +// return $orderId; +// } +// } \ No newline at end of file