dataLists(new OutboundOrderLists()); } /** * @notes 添加 * @author admin * @date 2025/03/10 11:08 */ public function add() { $params = (new OutboundOrderValidate())->post()->goCheck('add'); $params['admin_id'] = $this->adminId; $result = OutboundOrderLogic::add($params); if (true === $result) { return $this->success('出库成功', [], 1, 1); } return $this->fail(OutboundOrderLogic::getError()); } /** * @notes 编辑 * @author admin * @date 2025/03/10 11:08 */ public function edit() { $params = (new OutboundOrderValidate())->post()->goCheck('edit'); $result = OutboundOrderLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(OutboundOrderLogic::getError()); } /** * @notes 删除 * @author admin * @date 2025/03/10 11:08 */ public function delete() { $params = (new OutboundOrderValidate())->post()->goCheck('delete'); OutboundOrderLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取详情 * @author admin * @date 2025/03/10 11:08 */ public function detail() { $params = (new OutboundOrderValidate())->goCheck('detail'); $result = OutboundOrderLogic::detail($params); return $this->data($result); } /** * 出库表格 */ public function export() { $id = $this->request->post('id'); $type = $this->request->post('type'); if (in_array($type, [2, 3])) { return $this->fail('暂不支持此操作'); } $xlsx = new OrderDetail(); $order = OutboundOrder::where('id', $id)->findOrEmpty(); $system_store = SystemStore::where('id', $order['store_id'])->value('name'); $data = OutboundProduct::where('oid', $id)->select(); $order['total_num'] = 0; $total_price = 0; foreach ($data as $value) { if (in_array($order['store_id'], [17, 18])) { $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id', $order['store_id'])->withTrashed()->find(); } else { $find = StoreProduct::where('id', $value->product_id)->withTrashed()->find(); } $value->store_name = $find['store_name'] ?? ''; $value->store_info = $find['store_info'] ?? ''; if ($type == 1) { $value->price = $value['purchase']; $value->total_price = bcmul($value['purchase'], $value['nums'], 2); $total_price += $value->total_price; } $value->cart_num = $value['nums']; if (!empty($find['unit'])) { $value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name'); } else { $value->unit_name = ''; } $order['total_num'] += $value->nums; } if ($type == 2) { $order['total_price'] = $total_price; } $order['delivery_time'] = date('Y-m-d H:i:s', $order['delivery_time']); $order['pay_time'] = $order['create_time']; $order['order_id'] = $order['code']; if ($order['oid'] > 0) { $orders = StoreOrder::where('id', $order['oid'])->findOrEmpty(); $order['real_name'] = $orders['real_name']; $order['user_phone'] = $orders['user_phone']; $order['user_address'] = $orders['user_address']; } $file_path = $xlsx->export($data, $system_store, $order); return $this->success('导出成功', ['url' => $file_path]); } /** * 导出标签 */ public function export_tags() { $id = $this->request->post('id'); $warehouseOrder = OutboundOrder::where('id', $id)->field('oid,store_id')->find(); $system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('introduction'); $data = OutboundProduct::where('oid', $id)->field('oid,product_id,nums')->select() ->each(function ($item) use ($system_store, $warehouseOrder) { $find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->withTrashed()->find(); $unit_name = StoreProductUnit::where('id', $find['unit'])->value('name'); $item['system_store'] = $system_store; $item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['nums']) . '/' . $unit_name; $item['store_name'] = $find['store_name']; if ($warehouseOrder['oid']) { $find = StoreOrder::where('id', $warehouseOrder['oid'])->field('real_name,user_address')->find(); if ($find) { $item['address'] = $find['real_name'] . ' ' . $find['user_address']; } else { $item['address'] = '无地址'; } } else { $item['address'] = '无地址'; } }) ->toArray(); $file_path = (new Beforehand())->export($data, $system_store); return $this->success('导出成功', ['url' => $file_path]); } }