From 62577c3554c2c89077d61c5b55eeadd20db63687 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Mon, 22 Nov 2021 17:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/dao/AdminDao.php | 35 +++ application/admin/dao/CfChannelInfoDao.php | 35 +++ application/admin/dao/CfSuplierInfoDao.php | 35 +++ application/admin/dao/OrderHotelDao.php | 322 ++++++++++++++++++++++ application/admin/dao/OrderItemDao.php | 272 ++++++++++++++++++ application/admin/dao/OrderMainDao.php | 321 +++++++++++++++++++++ application/admin/dao/PaymentOrderDao.php | 236 ++++++++++++++++ application/admin/dao/PurchaseDao.php | 211 ++++++++++++++ application/admin/dao/PurchasePriceDao.php | 95 +++++++ application/admin/dao/ReceiptOrderDao.php | 166 +++++++++++ application/admin/service/AdminDao.php | 35 --- application/admin/service/CfChannelInfoDao.php | 35 --- application/admin/service/CfSuplierInfoDao.php | 35 --- application/admin/service/OrderHotelDao.php | 322 ---------------------- application/admin/service/OrderItemDao.php | 272 ------------------ application/admin/service/OrderMainDao.php | 321 --------------------- application/admin/service/OrderMainService.php | 14 +- application/admin/service/PaymentOrderDao.php | 236 ---------------- application/admin/service/PaymentOrderService.php | 4 + application/admin/service/PurchaseDao.php | 211 -------------- application/admin/service/PurchasePriceDao.php | 95 ------- application/admin/service/ReceiptOrderDao.php | 166 ----------- application/admin/service/ReceiptOrderService.php | 3 +- 23 files changed, 1740 insertions(+), 1737 deletions(-) create mode 100644 application/admin/dao/AdminDao.php create mode 100644 application/admin/dao/CfChannelInfoDao.php create mode 100644 application/admin/dao/CfSuplierInfoDao.php create mode 100644 application/admin/dao/OrderHotelDao.php create mode 100644 application/admin/dao/OrderItemDao.php create mode 100644 application/admin/dao/OrderMainDao.php create mode 100644 application/admin/dao/PaymentOrderDao.php create mode 100644 application/admin/dao/PurchaseDao.php create mode 100644 application/admin/dao/PurchasePriceDao.php create mode 100644 application/admin/dao/ReceiptOrderDao.php delete mode 100644 application/admin/service/AdminDao.php delete mode 100644 application/admin/service/CfChannelInfoDao.php delete mode 100644 application/admin/service/CfSuplierInfoDao.php delete mode 100644 application/admin/service/OrderHotelDao.php delete mode 100644 application/admin/service/OrderItemDao.php delete mode 100644 application/admin/service/OrderMainDao.php delete mode 100644 application/admin/service/PaymentOrderDao.php delete mode 100644 application/admin/service/PurchaseDao.php delete mode 100644 application/admin/service/PurchasePriceDao.php delete mode 100644 application/admin/service/ReceiptOrderDao.php diff --git a/application/admin/dao/AdminDao.php b/application/admin/dao/AdminDao.php new file mode 100644 index 0000000..c6f12c2 --- /dev/null +++ b/application/admin/dao/AdminDao.php @@ -0,0 +1,35 @@ +where(["id"=>$id])->find(); + if ($info == null) { + return Util::returnArrEr("获取管理员信息失败:".$id); + } + return Util::returnArrSu("",$info->toArray()); + }catch (Exception $e){ + return Util::returnArrEr("获取管理员信息失败:".$e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/dao/CfChannelInfoDao.php b/application/admin/dao/CfChannelInfoDao.php new file mode 100644 index 0000000..b5c5fb1 --- /dev/null +++ b/application/admin/dao/CfChannelInfoDao.php @@ -0,0 +1,35 @@ +where(["id"=>$id])->find(); + if ($info == null) { + return Util::returnArrEr("获取渠道信息失败:".$id); + } + return Util::returnArrSu("",$info->toArray()); + }catch (Exception $e){ + return Util::returnArrEr("获取渠道信息失败:".$e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/dao/CfSuplierInfoDao.php b/application/admin/dao/CfSuplierInfoDao.php new file mode 100644 index 0000000..e8cfb7e --- /dev/null +++ b/application/admin/dao/CfSuplierInfoDao.php @@ -0,0 +1,35 @@ +where(["id"=>$id])->find(); + if ($info == null) { + return Util::returnArrEr("获取供应商信息失败:".$id); + } + return Util::returnArrSu("",$info->toArray()); + }catch (Exception $e){ + return Util::returnArrEr("获取供应商信息失败:".$e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/dao/OrderHotelDao.php b/application/admin/dao/OrderHotelDao.php new file mode 100644 index 0000000..197a8a8 --- /dev/null +++ b/application/admin/dao/OrderHotelDao.php @@ -0,0 +1,322 @@ +getHotelInfo($param['hotel_id']); + if (!$hotelInfo['flag']){ + return $hotelInfo; + } + $roomInfo = $this->getRoomInfo($param['room_id']); + if (!$roomInfo['flag']){ + return $roomInfo; + } + $roomPlan = $this->getRoomPlan($param['plan_id']); + if (!$roomPlan['flag']) { + return $roomPlan; + } + try { + //设置入参 + $data = [ + "order_id" => $orderId, + "hotel_id" => $param['hotel_id'], + "hotel_name" => $hotelInfo['data']['hotel_name'], + "hotel_phone" => $hotelInfo['data']['hotel_phone'], + "province_name" => $hotelInfo['data']['province_name'], + "city_name" => $hotelInfo['data']['city_name'], + "area_name" => $hotelInfo['data']['area_name'], + "detail_address" => $hotelInfo['data']['detail_address'], + //房型 + "room_id" => $param['room_id'], + "room_name" => $roomInfo['data']['room_name'], + "room_memo" => $roomInfo['data']['room_memo'], + //价格方案 + "plan_id" => $param['plan_id'], + "plan_name" => $roomPlan['data']['plan_name'], + "plan_memo" => $roomPlan['data']['plan_memo'], + //其他 + "check_in_date" => $param['check_in_date'], + "check_out_date" => $param['check_out_date'], + "confirm_status" => $param['confirm_status'], + "confirm_no" => $param['confirm_no'], + "customer_name" => $param['customer_name'], + "customer_comments" => empty($param['customer_comments'])?"":$param['customer_comments'], + "trade_order_number" => $param['trade_order_number'], + "del_flag"=>0 + ]; + $orderHotelModel = new OrderHotel(); + if (empty($param['id'])) { + + $id = $orderHotelModel->insertGetId($data); + return Util::returnArrSu("", $id); + }else { + $orderHotelModel->save($data, ["id" => $param['id']]); + return Util::returnArrSu("", $param['id']); + } + }catch (Exception $e){ + return Util::returnArrEr("更新酒店子订单失败:".$e->getMessage()); + } + } + + /** + * 获取酒店信息 + * @param $id + * @return array + */ + public function getHotelInfo($id) + { + try { + $model = new CfHotelInfo(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取酒店信息失败:" . $id); + } + return Util::returnArrSu("",$result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取酒店信息失败:" . $id); + } + } + + /** + * 获取房型详情 + * @param $id + * @return array + */ + public function getRoomInfo($id) + { + try { + $model = new CfRoomInfo(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取房型信息失败:" . $id); + } + return Util::returnArrSu("", $result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取房型信息失败:" . $id); + } + } + + /** + * 获取房型价格方案 + * @param $id + * @return array + */ + public function getRoomPlan($id) + { + try { + $model = new CfRoomPlan(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取价格方案信息失败:" . $id); + } + return Util::returnArrSu("",$result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取价格方案信息失败:" . $id); + } + } + + /** + * 设置子订单金额 + * @param int $subOrderId + * @return array + */ + public function setSubOrderAmount( int $subOrderId) { + try{ + $purchaseModel = new Purchase(); + $purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); + $cost = 0; + $amount = 0; + $count = 0; + foreach ($purchaseList as $purchase) { + $cost += $purchase['total_cost']; + $amount += $purchase['total_price']; + $count += $purchase['count']; + } + $orderHotel = new OrderHotel(); + $orderHotel->save(["total_price"=>$amount,"total_cost"=>$cost,"prod_num"=>$count, "profit"=>$amount-$cost],["id"=>$subOrderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新酒店订单子表金额失败:".$subOrderId); + } + + } + + /** + * 获取详情 + * @param $id + * @return array + */ + public function getInfoById($id) { + try { + $model = new OrderHotel(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取子订单信息失败:" . $id); + } + return Util::returnArrSu("",$result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取子订单信息失败:" . $id); + } + } + + /** + * 删除记录 + * @param $order_id + */ + public function delete($order_id){ + $model = new OrderHotel(); + $model->save(["del_flag"=>1],["order_id"=>$order_id]); + } + + /** + * 删除记录 + * @param $id + */ + public function delById($id) { + $model = new OrderHotel(); + $model->save(["del_flag"=>1],["id"=>$id]); + } + + /** + * 获取酒店子订单列表 + * @param $orderId + * @return array + */ + public function getListByOrderId($orderId){ + $subOrderModel = new OrderHotel(); + try { + $subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return Util::returnArrSu("",[]); + } + return Util::returnArrSu("", $subOrderList); + }catch (Exception $e) { + return Util::returnArrEr("获取酒店订单列表异常:".$e->getMessage()); + } + } + + /**=====================================**/ + + /** + * 更新付款单下的状态 + * @param $paymentOrderId + * @param $status + * @return array + */ + public function setPaymentOrderStatus($paymentOrderId, $status){ + try{ + $model = new OrderHotel(); + $model->save(['payment_order_status'=>$status],['payment_order_id'=>$paymentOrderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新收款单下的酒店订单状态失败".$e->getMessage()); + } + } + + /** + * 添加酒店订单到付款单下 + * @param $paymentOrder + * @param $orderIds + * @return array + */ + public function addSubOrderInPayment($paymentOrder,$orderIds){ + try{ + $data = [ + "payment_order_id"=>$paymentOrder['id'], + "payment_order_status"=>$paymentOrder['status'], + "payment_order_name"=>$paymentOrder['name'] + ]; + $model = new OrderHotel(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("添加酒店订单到付款单下失败".$e->getMessage()); + } + } + + /** + * 将酒店订单从付款单下移除 + * @param $orderIds + * @return array + */ + public function removeSubOrderFormPayment($orderIds){ + try{ + $data = [ + "payment_order_id"=>0, + "payment_order_status"=>0, + "payment_order_name"=>"" + ]; + $model = new OrderHotel(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将酒店订单从付款单下移除失败".$e->getMessage()); + } + } + + /** + * 删除采购单 + * @param $id + * @return array + */ + public function delPaymentOrder($id){ + try{ + $data = [ + "payment_order_id"=>0, + "payment_order_status"=>0, + "payment_order_name"=>"" + ]; + $model = new OrderHotel(); + $model->save($data,["payment_order_id"=>$id]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将酒店订单从付款单下移除失败".$e->getMessage()); + } + } + + /** + * 获取主订单ID + * @param $payment_order_id + * @return array + */ + public function getOrderMainIdByPayment($payment_order_id){ + $subOrderModel = new OrderHotel(); + try { + $subOrderList = $subOrderModel->where(["payment_order_id" => $payment_order_id, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return []; + } + $id = []; + foreach ($subOrderList as $val){ + $id[] = $val['order_id']; + } + return array_unique($id); + }catch (Exception $e) { + return []; + } + } +} \ No newline at end of file diff --git a/application/admin/dao/OrderItemDao.php b/application/admin/dao/OrderItemDao.php new file mode 100644 index 0000000..1faed68 --- /dev/null +++ b/application/admin/dao/OrderItemDao.php @@ -0,0 +1,272 @@ +getItemInfo($param['item_id']); + if (!$itemInfo['flag']){ + return $itemInfo; + } + try{ + //设置入参 + $data = [ + "order_id" => $orderId, + //附加项目 + "item_id"=>$itemInfo['data']['id'], + "item_type"=>$itemInfo['data']['item_type'], + "item_name"=>$itemInfo['data']['item_name'], + "item_memo"=>$itemInfo['data']['item_memo'], + "item_unit"=>$itemInfo['data']['item_unit'], + "area_name" => $itemInfo['data']['area_name'], + "province_name" => $itemInfo['data']['province_name'], + "city_name" => $itemInfo['data']['city_name'], + "detail_address" => $itemInfo['data']['detail_address'], + //其他 + "check_in_date" => $param['check_in_date'], + "confirm_status" => $param['confirm_status'], + "confirm_no" => $param['confirm_no'], + "customer_name" => $param['customer_name'], + "customer_comments" => empty($param['customer_comments'])?"":$param['customer_comments'], + "trade_order_number" => $param['trade_order_number'], + "del_flag"=>0 + ]; + $model = new OrderItem(); + if (empty($param['id'])) { + $id = $model->insertGetId($data); + return Util::returnArrSu("",$id); + }else { + $model->save($data,["id"=>$param['id']]); + return Util::returnArrSu("",$param['id']); + } + }catch (Exception $e){ + return Util::returnArrEr("更新附加项目子订单失败:".$e->getMessage()); + } + + } + + /** + * 获取附加项目信息 + * @param $id + * @return array + */ + public function getItemInfo($id) + { + try { + $model = new CfItem(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取附加项目信息失败:" . $id); + } + return Util::returnArrSu("",$result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取附加项目信息失败:" . $id); + } + } + + /** + * 设置子订单金额 + * @param int $subOrderId + * @return array + */ + public function setSubOrderAmount( int $subOrderId) { + try{ + $purchaseModel = new Purchase(); + $purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); + $cost = 0; + $amount = 0; + $count = 0; + foreach ($purchaseList as $purchase) { + $cost += $purchase['total_cost']; + $amount += $purchase['total_price']; + $count += $purchase['count']; + } + //更新数据 + $oderItem = new OrderItem(); + $oderItem->save(["total_price"=>$amount,"total_cost"=>$cost,"prod_num"=>$count,"profit"=>$amount-$cost],["id"=>$subOrderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新附加项目订单子表金额失败:".$subOrderId); + } + + } + + /** + * 获取详情 + * @param $id + * @return array + */ + public function getInfoById($id) { + try { + $model = new OrderItem(); + $result = $model->where(["id" => $id])->find(); + if ($result == null) { + return Util::returnArrEr("获取子订单信息失败:" . $id); + } + return Util::returnArrSu("", $result->toArray()); + } catch (Exception $e) { + return Util::returnArrEr("获取子订单信息失败:" . $id); + } + } + + /** + * 删除记录 + * @param $order_id + */ + public function delete($order_id){ + $model = new OrderItem(); + $model->save(["del_flag"=>1],["order_id"=>$order_id]); + } + + /** + * 删除记录 + * @param $id + */ + public function delById($id) { + $model = new OrderItem(); + $model->save(["del_flag"=>1],["id"=>$id]); + } + + /** + * 获取附加项目子订单列表 + * @param $orderId + * @return array + */ + public function getListByOrderId($orderId){ + $subOrderModel = new OrderItem(); + try { + $subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return Util::returnArrSu("",[]); + } + return Util::returnArrSu("", $subOrderList); + }catch (Exception $e) { + return Util::returnArrEr("获取附加项目订单列表异常".$e->getMessage()); + } + } + + + /**=====================================**/ + + /** + * 更新付款单下的状态 + * @param $paymentOrderId + * @param $status + * @return array + */ + public function setPaymentOrderStatus($paymentOrderId, $status){ + try{ + $model = new OrderItem(); + $model->save(['payment_order_status'=>$status],['payment_order_id'=>$paymentOrderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新收款单下的附加项目订单状态失败".$e->getMessage()); + } + } + + /** + * 添加附加项目订单到付款单下 + * @param $paymentOrder + * @param $orderIds + * @return array + */ + public function addSubOrderInPayment($paymentOrder,$orderIds){ + try{ + $data = [ + "payment_order_id"=>$paymentOrder['id'], + "payment_order_status"=>$paymentOrder['status'], + "payment_order_name"=>$paymentOrder['name'] + ]; + $model = new OrderItem(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("添加附加项目订单到付款单下失败".$e->getMessage()); + } + } + + /** + * 将附加项目订单从付款单下移除 + * @param $orderIds + * @return array + */ + public function removeSubOrderFormPayment($orderIds){ + try{ + $data = [ + "payment_order_id"=>0, + "payment_order_status"=>0, + "payment_order_name"=>"" + ]; + $model = new OrderItem(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将附加项目订单从付款单下移除失败".$e->getMessage()); + } + } + + /** + * 删除采购单 + * @param $id + * @return array + */ + public function delPaymentOrder($id){ + try{ + $data = [ + "payment_order_id"=>0, + "payment_order_status"=>0, + "payment_order_name"=>"" + ]; + $model = new OrderItem(); + $model->save($data,["payment_order_id"=>$id]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将附加项目订单从付款单下移除失败".$e->getMessage()); + } + } + + /** + * 获取主订单ID + * @param $payment_order_id + * @return array + */ + public function getOrderMainIdByPayment($payment_order_id){ + $subOrderModel = new OrderItem(); + try { + $subOrderList = $subOrderModel->where(["payment_order_id" => $payment_order_id, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return []; + } + $id = []; + foreach ($subOrderList as $val){ + $id[] = $val['order_id']; + } + return array_unique($id); + }catch (Exception $e) { + return []; + } + } +} \ No newline at end of file diff --git a/application/admin/dao/OrderMainDao.php b/application/admin/dao/OrderMainDao.php new file mode 100644 index 0000000..350c3c2 --- /dev/null +++ b/application/admin/dao/OrderMainDao.php @@ -0,0 +1,321 @@ +getInfoById($param['channel_id']); + if (!$channelRe['flag']) { + return $channelRe; + } + //2.获取专员 + $adminDao = new AdminDao(); + $adminRe = $adminDao->getInfoById($param['commissioner_id']); + if (!$adminRe['flag']) { + return $adminRe; + } + $data = [ + "commissioner_id"=>$param['commissioner_id'], + "commissioner"=>$adminRe["data"]['nickname'], + "channel_id"=>$param["channel_id"], + "channel_name"=>$channelRe['data']['channel_name'], + "channel_order_no"=>$param["channel_order_no"], + "user_name"=>$param["user_name"], + "user_phone"=>$param["user_phone"], + "order_memo"=>$param["order_memo"], + "create_id"=>empty($param['create_id'])?0:$param['create_id'], + "group_id"=>empty($param['group_id'])?0:$param['group_id'] + ]; + $orderMain = new OrderMain(); + if (empty($param['id'])) { + $id = $orderMain->insertGetId($data); + return Util::returnArrSu("", $id); + } else { + $orderMain->save($data,['id'=>$param['id']]); + return Util::returnArrSu("", $param['id']); + } + }catch (Exception $e){ + return Util::returnArrEr("更新主订单失败:".$e->getMessage()); + } + + } + + /** + * 设置主订单金额 + * @param int $orderId + * @return array + */ + public function setOrderAmount(int $orderId){ + try { + $itemModel = new OrderItem(); + $hotelModel = new OrderHotel(); + $itemList = $itemModel->where(["order_id" => $orderId,"del_flag"=>0])->select()->toArray(); + $hotelList = $hotelModel->where(["order_id" => $orderId,"del_flag"=>0])->select()->toArray(); + $amount = 0; + $cost = 0; + //状态数量统计 用于统计当前订单的状态 + $statusList = [ + 1=>0, + 2=>0, + 3=>0, + 4=>0, + "isPayment"=>0 + ]; + $cnt = count($itemList)+count($hotelList); + foreach ($itemList as $item) { + $amount += $item['total_price']; + $cost += $item['total_cost']; + $statusList[$item['confirm_status']]++; + if ($item['payment_order_status'] ==2) { + $statusList['isPayment']++; + } + } + foreach ($hotelList as $hotel) { + $amount += $hotel['total_price']; + $cost += $hotel["total_cost"]; + $statusList[$hotel['confirm_status']]++; + if ($hotel['payment_order_status'] ==2) { + $statusList['isPayment']++; + } + } + $orderInfoRe = $this->getInfoById($orderId); + if (!$orderInfoRe['flag']) { + return $orderInfoRe; + } + $orderStatus = $this->getStatus($cnt,$statusList,$orderInfoRe['data']); + //更新金额 + $orderMain = new OrderMain(); + $orderMain->save(["total_amount" => $amount, "cost_amount" => $cost,"profit_amount"=>$amount-$cost,"order_status"=>$orderStatus],["id" => $orderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新主表订单金额失败:".$e->getMessage()); + } + } + + /** + * 获取订单状态 + * @param $cnt + * @param $statusList + * @param $orderInfo + * @return int + */ + public function getStatus($cnt,$statusList,$orderInfo){ + //资源单状态 1、未发单/ 2已发单、3已确认、4已取消 + //订单状态0待处理 1已确认 2部分取消 3处理中 10已完成 11已取消 + //已完成:订单已完成付款、已完成收款(无视子订单状态) + if ($orderInfo['receipt_order_status'] ==2 && $statusList['isPayment'] == $cnt) { + return 10; + } + //全部未发单 待处理:子订单全部未发单 + if ($statusList[1] == $cnt) { + return 0; + } + //全部已确认 已确认:子订单全部已确认 + if ($statusList[3] == $cnt) { + return 1; + } + //全部已取消 已取消:订单中所有子订单已取消 + if ($statusList[4] == $cnt) { + return 11; + } + //部分取消:订单中有子订单取消,其他子订单已确认 + if (($statusList[3]+$statusList[4]) == $cnt ) { + return 2; + } + //处理中:非以上状态,即部分子订单确认、或者部分子订单在已发单,或部分子订单在未发单。 + return 3; + + } + + + + /** + * 根据ID获取详情 + * @param $id + * @return array + */ + public function getInfoById($id) { + try { + $orderMainModel = new OrderMain(); + $orderMain = $orderMainModel->where(["id" => $id])->find(); + if (null == $orderMain) { + return Util::returnArrEr("订单查询失败:".$id); + } + return Util::returnArrSu("",$orderMain->toArray()); + }catch (Exception $e) { + return Util::returnArrEr("订单查询失败:".$e->getMessage()); + } + } + + /** + * 子订单展示 + * @param $purchaseShow + * @param $orderHotel + * @param $orderItem + * @return array + */ + public function setSubOrderShow($purchaseShow,$orderHotel,$orderItem){ + $result = []; + + foreach ($orderItem as $item) { + $item['prod_type'] = 'item'; + foreach ($purchaseShow as $key=> $purchase) { + if ($item['id'] == $key) { + $item = array_merge($item,$purchase); + } + } + $result[] = $item; + } + foreach ($orderHotel as $hotel) { + $hotel['prod_type'] = 'hotel'; + foreach ($purchaseShow as $key=> $purchase) { + if ($hotel['id'] == $key) { + $hotel = array_merge($hotel,$purchase); + } + } + $result[] = $hotel; + } + return Util::returnArrSu("",$result); + } + + /** + * 更新收款单下的订单信息 + * @param $receiptOrderId + * @param $status + * @return array + */ + public function setReceiptOrderStatus($receiptOrderId, $status){ + try{ + $model = new OrderMain(); + $model->save(['receipt_order_status'=>$status],['receipt_order_id'=>$receiptOrderId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新收款单子啊的主订单状态失败".$e->getMessage()); + } + } + + /** + * 添加主订单到收款单下 + * @param $receiptOrder + * @param $orderIds + * @return array + */ + public function addOrderMainInReceipt($receiptOrder,$orderIds){ + try{ + $data = [ + "receipt_order_id"=>$receiptOrder['id'], + "receipt_order_status"=>$receiptOrder['status'], + "receipt_order_name"=>$receiptOrder['name'] + ]; + $model = new OrderMain(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("添加主订单到收款单下失败".$e->getMessage()); + } + } + + /** + * 将主订单从收款单下移除 + * @param $orderIds + * @return array + */ + public function removeOrderMainFormReceipt($orderIds){ + try{ + $data = [ + "receipt_order_id"=>0, + "receipt_order_status"=>0, + "receipt_order_name"=>"" + ]; + $model = new OrderMain(); + $model->save($data,["id"=>["in",$orderIds]]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); + } + } + + /** + * 获取订单列表 + * @param $where + * @param $param + * @return array + */ + public function getOrderListByWhere($where,$param){ + try { + $offset = ($param['pageNum'] - 1) * $param['pageSize']; + $model = new OrderMain(); + $count = $model->where($where)->count(); + $list = $model->where($where)->limit($offset,$param['pageSize'])->order("id","DESC")->select(); + return Util::returnArrSu("", ["total" => $count, "list" => $list->toArray()]); + }catch (Exception $e){ + return Util::returnArrSu("", ["total" => 0, "list" => []]); + } + } + + /** + * 删除收款单 + * @param $id + * @return array + */ + public function delReceiptOrder($id){ + try{ + $data = [ + "receipt_order_id"=>0, + "receipt_order_status"=>0, + "receipt_order_name"=>"" + ]; + $model = new OrderMain(); + $model->save($data,["receipt_order_id"=>$id]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); + } + } + + /** + * 获取收款单下所有主订单的订单ID + * @param $receipt_order_id + * @return array + */ + public function getOrderMainIdsByReceipt($receipt_order_id){ + $orderModel = new OrderMain(); + try { + $subOrderList = $orderModel->where(["receipt_order_id" => $receipt_order_id, "del_flag" => 0])->select()->toArray(); + if (null == $subOrderList) { + return []; + } + + $id = []; + foreach ($subOrderList as $val){ + $id[] = $val['id']; + } + return array_unique($id); + }catch (Exception $e) { + return []; + } + } +} \ No newline at end of file diff --git a/application/admin/dao/PaymentOrderDao.php b/application/admin/dao/PaymentOrderDao.php new file mode 100644 index 0000000..f7a3773 --- /dev/null +++ b/application/admin/dao/PaymentOrderDao.php @@ -0,0 +1,236 @@ +where(["id"=>$id])->find(); + if ($info == null) { + return Util::returnArrEr("获取付款单信息失败:".$id); + } + return Util::returnArrSu("",$info->toArray()); + }catch (Exception $e){ + return Util::returnArrEr("获取付款单信息失败:".$e->getMessage()); + } + } + + /** + * 添加记录 + * @param $param + * @return array + */ + public function save($param) + { + if ($this->checkName($param)) { + return Util::returnArrEr("名称已经存在"); + } + try { + $data = [ + 'name' => $param['name'], + "create_id"=>$param['create_id'], + "group_id"=>$param['group_id'] + ]; + $receiptOrder = new PaymentOrder(); + if (empty($param['id'])) { + $id = $receiptOrder->insertGetId($data); + return Util::returnArrSu("", $id); + } else { + $receiptOrder->save($data, ['id' => $param['id']]); + return Util::returnArrSu("", $param['id']); + } + } catch (Exception $e) { + return Util::returnArrEr("更新主订单失败:" . $e->getMessage()); + } + } + + /** + * 校验名称 + * @param $param + * @return bool + */ + public function checkName($param):bool { + try { + $model = new PaymentOrder(); + $infoRe = $model->where(["name" => $param['name']])->find(); + if ($infoRe == null) { + return false; + } + $info = $infoRe->toArray(); + if (isset($param['id'])) { + if ($param['id'] != $info['id']) { + return true; + } + }else{ + return true; + } + return false; + } catch (Exception $e) { + return false; + } + } + + /** + * 修改状态 + * @param $id + * @param $status + * @return array + */ + public function setStatus($id, $status) + { + try { + //设置收购单状态 + $receiptOrder = new PaymentOrder(); + $receiptOrder->save(['status' => $status], ['id' => $id]); + return Util::returnArrSu(); + } catch (Exception $e) { + return Util::returnArrEr("修改状态失败" . $e->getMessage()); + } + } + + + /** + * 获取列表 + * @param $param + * @return array + */ + public function getList($param) + { + try { + $where = ["a.del_flag"=>0]; + if (!empty($param['name'])) { + $where['a.name'] = ["like","%".$param['name']."%"]; + } + if ($param['status']."" != 'all') { + $where["a.status"] = $param['status']; + } + $offset = ($param['pageNum'] - 1) * $param['pageSize']; + $receiptOrder = new PaymentOrder(); + $total = $receiptOrder + ->alias("a") + ->group("a.id") + ->where($where)->count(); + $list = $receiptOrder + ->alias("a") + ->field("a.*, + (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '
金额:',ifnull( sum( total_price ), '-' )) from hbp_order_item where payment_order_id = a.id) 'item', + (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '
金额:',ifnull( sum( total_price ), '-' )) from hbp_order_hotel where payment_order_id = a.id) 'hotel' + ") + ->group("a.id") + ->where($where) + ->limit($offset, $param['pageSize']) + ->order("a.id","DESC")->select(); + + $data = ["total" => $total, "list" => $list->toArray()]; + return Util::returnArrSu("", $data); + } catch (Exception $e) { + return Util::returnArrSu("", ["total" => 0, "list" => []]); + } + } + + /** + * 删除 + * @param $id + * @return array + */ + public function del($id){ + try { + //设置收购单状态 + $receiptOrder = new PaymentOrder(); + $receiptOrder->save(['del_flag' => 1], ['id' => $id]); + return Util::returnArrSu(); + } catch (Exception $e) { + return Util::returnArrEr("修改状态失败" . $e->getMessage()); + } + } + + /** + * 获取子订单列表 + * @param $hotel_where + * @param $item_where + * @param $where + * @param $param + * @return array + */ + public function getSubOrderListByWhere($hotel_where,$item_where,$where,$param):array { + $limit = $param['pageSize']; + $offset = ($param['pageNum']-1)*$param['pageSize']; + $sqlCnt = "SELECT count(1) cnt + from ( + ( + SELECT a.order_id,a.id,d.supplier_name,a.trade_order_number,a.item_type 'hotel_name',a.item_name 'room_name', + a.item_unit 'plan_name', + a.check_in_date,a.check_in_date 'check_out_date',d.count,a.create_time,'item' as 'prod_type' + ,a.payment_order_name,a.payment_order_status,a.payment_order_id,a.customer_name,a.total_cost,a.total_price,a.confirm_status + from hbp_order_item a + INNER JOIN hbp_purchase d on a.id = d.order_detail_id and d.prod_type='item' + where + $item_where + order by a.create_time desc + ) + UNION + ( + SELECT b.order_id,b.id,c.supplier_name,b.trade_order_number,b.hotel_name ,b.room_name ,b.plan_name, + b.check_in_date,b.check_out_date,c.count,b.create_time,'hotel' as 'prod_type' + ,b.payment_order_name,b.payment_order_status,b.payment_order_id,b.customer_name,b.total_cost,b.total_price,b.confirm_status + from hbp_order_hotel b + INNER JOIN hbp_purchase c on b.id=c.order_detail_id and c.prod_type='hotel' + where + $hotel_where + order by b.create_time desc + ) + ) x + $where + ORDER BY x.create_time desc"; + $totalRe = Db::query($sqlCnt); + $sql = "SELECT x.* + from ( + ( + SELECT a.order_id,a.id,d.supplier_name,a.trade_order_number,a.item_type 'hotel_name',a.item_name 'room_name', + a.item_unit 'plan_name', + a.check_in_date,a.check_in_date 'check_out_date',d.count,a.create_time,'item' as 'prod_type' + ,a.payment_order_name,a.payment_order_status,a.payment_order_id,a.customer_name,a.total_cost,a.total_price,a.confirm_status + from hbp_order_item a + INNER JOIN hbp_purchase d on a.id = d.order_detail_id and d.prod_type='item' + where + $item_where + order by a.create_time desc + ) + UNION + ( + SELECT b.order_id,b.id,c.supplier_name,b.trade_order_number,b.hotel_name ,b.room_name ,b.plan_name, + b.check_in_date,b.check_out_date,c.count,b.create_time,'hotel' as 'prod_type' + ,b.payment_order_name,b.payment_order_status,b.payment_order_id,b.customer_name,b.total_cost,b.total_price,b.confirm_status + from hbp_order_hotel b + INNER JOIN hbp_purchase c on b.id=c.order_detail_id and c.prod_type='hotel' + where + $hotel_where + order by b.create_time desc + ) + ) x + ORDER BY x.create_time desc + limit $limit offset $offset"; + $list = Db::query($sql); + $result = ["list"=>$list,"total"=>$totalRe[0]['cnt']]; + return Util::returnArrSu("",$result); + } +} \ No newline at end of file diff --git a/application/admin/dao/PurchaseDao.php b/application/admin/dao/PurchaseDao.php new file mode 100644 index 0000000..53002ad --- /dev/null +++ b/application/admin/dao/PurchaseDao.php @@ -0,0 +1,211 @@ +getInfoById($param['supplier_id']); + if (!$suplierRe['flag']) { + return $suplierRe; + } + //2.获取负责人昵称 + $adminDao = new AdminDao(); + $adminRe = $adminDao->getInfoById($param['purchase_user_id']); + if (!$adminRe['flag']) { + return $adminRe; + } + $data = [ + "order_id" => $hotelOrder['order_id'], + "prod_type" => 'hotel', + "order_detail_id" => $hotelOrder['id'], + "group_id" => $param['group_id'], + "pro_name" => $hotelOrder['hotel_name'], + "item_name" => $hotelOrder['room_name'], + "item_unit" => $hotelOrder['plan_name'], + "check_in_date" => $param['check_in_date'], + "check_out_date" => $param['check_out_date'], + "supplier_id" => $param['supplier_id'], + "supplier_name" => $suplierRe['data']['supplier_name'], + "purchase_user_id" => $param['purchase_user_id'], + "purchase_user" => $adminRe['data']['nickname'], + "del_flag"=>0 + ]; + + $model = new Purchase(); + if (empty($param['purchase_id'])) { + $id = $model->insertGetId($data); + return Util::returnArrSu("", $id); + }else { + $model->save($data,["id"=>$param['purchase_id']]); + return Util::returnArrSu("", $param['purchase_id']); + } + }catch (Exception $e){ + return Util::returnArrEr("新增采购单失败:".$e->getMessage()); + } + } + + /** + * 添加附加项目采购单 + * @param $param + * @param $itemOrder + * @return array + */ + public function saveItemPurchase($param, $itemOrder):array { + try { + //1.获取供应商名称 + $suplierDao = new CfSuplierInfoDao(); + $suplierRe = $suplierDao->getInfoById($param['supplier_id']); + if (!$suplierRe['flag']) { + return $suplierRe; + } + //2.获取负责人昵称 + $adminDao = new AdminDao(); + $adminRe = $adminDao->getInfoById($param['purchase_user_id']); + if (!$adminRe['flag']) { + return $adminRe; + } + $data = [ + "order_id" => $itemOrder['order_id'], + "prod_type" => 'item', + "order_detail_id" => $itemOrder['id'], + "group_id" => $param['group_id'], + "item_name" => $itemOrder['item_name'], + "item_unit" => $itemOrder['item_unit'], + "check_in_date" => $param['check_in_date'], + "supplier_id" => $param['supplier_id'], + "supplier_name" => $suplierRe['data']['supplier_name'], + "purchase_user_id" => $param['purchase_user_id'], + "purchase_user" => $adminRe['data']['nickname'], + "del_flag"=>0 + ]; + $model = new Purchase(); + if (empty($param['purchase_id'])) { + $id = $model->insertGetId($data); + return Util::returnArrSu("", $id); + }else { + $model->save($data,["id"=>$param['purchase_id']]); + return Util::returnArrSu("", $param['purchase_id']); + } + }catch (Exception $e){ + return Util::returnArrEr("新增采购单失败:".$e->getMessage()); + } + } + + /** + * 设置采购单 金额 + * @param $purchaseId + * @return array + */ + public function setPurchaseAmount(int $purchaseId){ + try{ + $purchasePrice = new PurchasePrice(); + $purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchaseId,"del_flag"=>0])->select()->toArray(); + $cost = 0; + $amount = 0; + $cnt = 0; + foreach ($purchasePriceList as $price) { + $cost += $price['cost'] * $price["count"]; + $amount += $price['price'] * $price["count"]; + $cnt += $price['count']; + } + $purchase = new Purchase(); + $purchase->save(["total_price"=>$amount,"total_cost"=>$cost,"count"=>$cnt,"profit"=>$amount-$cost],["id"=>$purchaseId]); + return Util::returnArrSu(); + }catch (Exception $e){ + return Util::returnArrEr("更新采购单金额失败:".$e->getMessage()); + } + + } + + /** + * 删除记录 + * @param $order_id + */ + public function delete($order_id){ + $model = new Purchase(); + $model->save(["del_flag"=>1],["order_id"=>$order_id]); + } + + /** + * 删除子订单 + * @param $subOrderId + */ + public function deleteBySubOrderId($subOrderId) { + $model = new Purchase(); + $model->save(["del_flag"=>1],["order_detail_id"=>$subOrderId]); + } + + /** + * 获取采购单列表 + * @param $orderId + * @return array + */ + public function getListByOrderId($orderId) { + $model = new Purchase(); + try { + $list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); + if (null == $list) { + return Util::returnArrSu("",[]); + } + return Util::returnArrSu("",$list); + }catch (Exception $e) { + return Util::returnArrEr("获取订单的采购单列表失败:".$e->getMessage()); + } + } + + /** + * 设置 + * @param $purchaseList + * @param $purchasePriceList + * @return array + */ + public function setPurchaseShow($purchaseList,$purchasePriceList){ + $result = []; + foreach ($purchaseList as $purchase) { + $purchaseShow=[ + "purchase_id"=>$purchase['id'], + "purchase_user_id"=>$purchase['purchase_user_id'], + "purchase_user"=>$purchase['purchase_user'], + "supplier_id"=>$purchase['supplier_id'], + "supplier_name" =>$purchase['supplier_name'], + "purchasePriceList"=>[] + ]; + foreach ($purchasePriceList as $price) { + if ($price['purchase_id'] == $purchase['id']) { + $priceShow = [ + "id"=>$price['id'], + "run_date"=>$price['run_date'], + "count"=>$price['count'], + "price"=>$price['price'], + "cost"=>$price['cost'] + ]; + $purchaseShow["purchasePriceList"][]=$priceShow; + } + } + $result[$purchase['order_detail_id']]= $purchaseShow; + } + return Util::returnArrSu("", $result); + } +} \ No newline at end of file diff --git a/application/admin/dao/PurchasePriceDao.php b/application/admin/dao/PurchasePriceDao.php new file mode 100644 index 0000000..a0da498 --- /dev/null +++ b/application/admin/dao/PurchasePriceDao.php @@ -0,0 +1,95 @@ +delete($order_detail_id); + //循环添加 + foreach ($param as $value) { + $data = [ + "order_id" => $order_id, + "prod_type" => $prod_type, + "order_detail_id" => $order_detail_id, + "purchase_id" => $purchase_id, + "run_date" => $value['run_date'], + "count" => $value['count'], + "price" => $value['price'], + "cost" => $value['cost'], + "del_flag" => 0 + ]; + $model = new PurchasePrice(); + if (empty($value['id'])) { + $model->insertGetId($data); + } else { + $model->save($data, ["id" => $value['id']]); + } + } + return Util::returnArrSu(); + } catch (Exception $e) { + return Util::returnArrEr("添加/更新采购单每日价格失败:" . $e->getMessage()); + } + } + + /** + * 删除数据 + * @param $purchase_id + */ + public function delete($purchase_id) + { + $model = new PurchasePrice(); + $model->save(["del_flag" => 1], ["purchase_id" => $purchase_id]); + } + + /** + * 删除子订单对于的每日价格 + * @param $subOrderId + */ + public function deleteBySubOrderId($subOrderId) { + $model = new PurchasePrice(); + $model->save(["del_flag" => 1], ["order_detail_id" => $subOrderId]); + } + + /** + * 获取采购单金额 + * @param $orderId + * @return array + */ + public function getPurchasePriceListByOrderId($orderId) { + $model = new PurchasePrice(); + try { + $list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); + if (null == $list) { + return Util::returnArrSu("", []); + } + return Util::returnArrSu("", $list); + }catch (Exception $e) { + return Util::returnArrEr("获取采购单金额异常".$e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/dao/ReceiptOrderDao.php b/application/admin/dao/ReceiptOrderDao.php new file mode 100644 index 0000000..377258a --- /dev/null +++ b/application/admin/dao/ReceiptOrderDao.php @@ -0,0 +1,166 @@ +where(["id"=>$id])->find(); + if ($info == null) { + return Util::returnArrEr("获取收款单信息失败:".$id); + } + return Util::returnArrSu("",$info->toArray()); + }catch (Exception $e){ + return Util::returnArrEr("获取收款单信息失败:".$e->getMessage()); + } + } + + /** + * 添加记录 + * @param $param + * @return array + */ + public function save($param) + { + if ($this->checkName($param)) { + return Util::returnArrEr("名称已经存在"); + } + try { + $data = [ + 'name' => $param['name'], + "create_id"=>$param['create_id'], + "group_id"=>$param['group_id'] + ]; + $receiptOrder = new ReceiptOrder(); + if (empty($param['id'])) { + $id = $receiptOrder->insertGetId($data); + return Util::returnArrSu("", $id); + } else { + $receiptOrder->save($data, ['id' => $param['id']]); + return Util::returnArrSu("", $param['id']); + } + } catch (Exception $e) { + return Util::returnArrEr("更新主订单失败:" . $e->getMessage()); + } + } + + /** + * 校验名称 + * @param $param + * @return bool + */ + public function checkName($param):bool { + try { + $model = new ReceiptOrder(); + $infoRe = $model->where(["name" => $param['name']])->find(); + if ($infoRe == null) { + return false; + } + $info = $infoRe->toArray(); + if (isset($param['id'])) { + if ($param['id'] != $info['id']) { + return true; + } + }else{ + return true; + } + return false; + } catch (Exception $e) { + return false; + } + } + + /** + * 修改状态 + * @param $id + * @param $status + * @return array + */ + public function setStatus($id, $status) + { + try { + //设置收购单状态 + $receiptOrder = new ReceiptOrder(); + $receiptOrder->save(['status' => $status], ['id' => $id]); + return Util::returnArrSu(); + } catch (Exception $e) { + return Util::returnArrEr("修改状态失败" . $e->getMessage()); + } + } + + + /** + * 获取列表 + * @param $param + * @return array + */ + public function getList($param) + { + try { + $where = ["a.del_flag"=>0]; + if (!empty($param['name'])) { + $where['a.name'] = ["like","%".$param['name']."%"]; + } + if ($param['status']."" != 'all') { + $where["a.status"] = $param['status']; + } + $offset = ($param['pageNum'] - 1) * $param['pageSize']; + $receiptOrder = new ReceiptOrder(); + $total = $receiptOrder + ->alias("a") + ->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') + ->field("a.*,GROUP_CONCAT(b.id) order_ids,sum(b.total_amount) total_amount") + ->group("a.id") + ->where($where)->count(); + + $list = $receiptOrder + ->alias("a") + ->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') + ->field("a.*,GROUP_CONCAT(b.id ORDER BY b.id DESC) order_ids,sum(b.total_amount) total_amount") + ->group("a.id") + ->where($where) + ->limit($offset, $param['pageSize']) + ->order("id","DESC")->select(); + $data = ["total" => $total, "list" => $list->toArray()]; + return Util::returnArrSu("", $data); + } catch (Exception $e) { + return Util::returnArrSu("", ["total" => 0, "list" => []]); + } + } + + /** + * 删除 + * @param $id + * @return array + */ + public function del($id){ + try { + //设置收购单状态 + $receiptOrder = new ReceiptOrder(); + $receiptOrder->save(['del_flag' => 1], ['id' => $id]); + return Util::returnArrSu(); + } catch (Exception $e) { + return Util::returnArrEr("修改状态失败" . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/service/AdminDao.php b/application/admin/service/AdminDao.php deleted file mode 100644 index 1d36372..0000000 --- a/application/admin/service/AdminDao.php +++ /dev/null @@ -1,35 +0,0 @@ -where(["id"=>$id])->find(); - if ($info == null) { - return Util::returnArrEr("获取管理员信息失败:".$id); - } - return Util::returnArrSu("",$info->toArray()); - }catch (Exception $e){ - return Util::returnArrEr("获取管理员信息失败:".$e->getMessage()); - } - } -} \ No newline at end of file diff --git a/application/admin/service/CfChannelInfoDao.php b/application/admin/service/CfChannelInfoDao.php deleted file mode 100644 index 1bda8f4..0000000 --- a/application/admin/service/CfChannelInfoDao.php +++ /dev/null @@ -1,35 +0,0 @@ -where(["id"=>$id])->find(); - if ($info == null) { - return Util::returnArrEr("获取渠道信息失败:".$id); - } - return Util::returnArrSu("",$info->toArray()); - }catch (Exception $e){ - return Util::returnArrEr("获取渠道信息失败:".$e->getMessage()); - } - } -} \ No newline at end of file diff --git a/application/admin/service/CfSuplierInfoDao.php b/application/admin/service/CfSuplierInfoDao.php deleted file mode 100644 index 521cc60..0000000 --- a/application/admin/service/CfSuplierInfoDao.php +++ /dev/null @@ -1,35 +0,0 @@ -where(["id"=>$id])->find(); - if ($info == null) { - return Util::returnArrEr("获取供应商信息失败:".$id); - } - return Util::returnArrSu("",$info->toArray()); - }catch (Exception $e){ - return Util::returnArrEr("获取供应商信息失败:".$e->getMessage()); - } - } -} \ No newline at end of file diff --git a/application/admin/service/OrderHotelDao.php b/application/admin/service/OrderHotelDao.php deleted file mode 100644 index 1c40d85..0000000 --- a/application/admin/service/OrderHotelDao.php +++ /dev/null @@ -1,322 +0,0 @@ -getHotelInfo($param['hotel_id']); - if (!$hotelInfo['flag']){ - return $hotelInfo; - } - $roomInfo = $this->getRoomInfo($param['room_id']); - if (!$roomInfo['flag']){ - return $roomInfo; - } - $roomPlan = $this->getRoomPlan($param['plan_id']); - if (!$roomPlan['flag']) { - return $roomPlan; - } - try { - //设置入参 - $data = [ - "order_id" => $orderId, - "hotel_id" => $param['hotel_id'], - "hotel_name" => $hotelInfo['data']['hotel_name'], - "hotel_phone" => $hotelInfo['data']['hotel_phone'], - "province_name" => $hotelInfo['data']['province_name'], - "city_name" => $hotelInfo['data']['city_name'], - "area_name" => $hotelInfo['data']['area_name'], - "detail_address" => $hotelInfo['data']['detail_address'], - //房型 - "room_id" => $param['room_id'], - "room_name" => $roomInfo['data']['room_name'], - "room_memo" => $roomInfo['data']['room_memo'], - //价格方案 - "plan_id" => $param['plan_id'], - "plan_name" => $roomPlan['data']['plan_name'], - "plan_memo" => $roomPlan['data']['plan_memo'], - //其他 - "check_in_date" => $param['check_in_date'], - "check_out_date" => $param['check_out_date'], - "confirm_status" => $param['confirm_status'], - "confirm_no" => $param['confirm_no'], - "customer_name" => $param['customer_name'], - "customer_comments" => empty($param['customer_comments'])?"":$param['customer_comments'], - "trade_order_number" => $param['trade_order_number'], - "del_flag"=>0 - ]; - $orderHotelModel = new OrderHotel(); - if (empty($param['id'])) { - - $id = $orderHotelModel->insertGetId($data); - return Util::returnArrSu("", $id); - }else { - $orderHotelModel->save($data, ["id" => $param['id']]); - return Util::returnArrSu("", $param['id']); - } - }catch (Exception $e){ - return Util::returnArrEr("更新酒店子订单失败:".$e->getMessage()); - } - } - - /** - * 获取酒店信息 - * @param $id - * @return array - */ - public function getHotelInfo($id) - { - try { - $model = new CfHotelInfo(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取酒店信息失败:" . $id); - } - return Util::returnArrSu("",$result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取酒店信息失败:" . $id); - } - } - - /** - * 获取房型详情 - * @param $id - * @return array - */ - public function getRoomInfo($id) - { - try { - $model = new CfRoomInfo(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取房型信息失败:" . $id); - } - return Util::returnArrSu("", $result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取房型信息失败:" . $id); - } - } - - /** - * 获取房型价格方案 - * @param $id - * @return array - */ - public function getRoomPlan($id) - { - try { - $model = new CfRoomPlan(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取价格方案信息失败:" . $id); - } - return Util::returnArrSu("",$result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取价格方案信息失败:" . $id); - } - } - - /** - * 设置子订单金额 - * @param int $subOrderId - * @return array - */ - public function setSubOrderAmount( int $subOrderId) { - try{ - $purchaseModel = new Purchase(); - $purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); - $cost = 0; - $amount = 0; - $count = 0; - foreach ($purchaseList as $purchase) { - $cost += $purchase['total_cost']; - $amount += $purchase['total_price']; - $count += $purchase['count']; - } - $orderHotel = new OrderHotel(); - $orderHotel->save(["total_price"=>$amount,"total_cost"=>$cost,"prod_num"=>$count, "profit"=>$amount-$cost],["id"=>$subOrderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新酒店订单子表金额失败:".$subOrderId); - } - - } - - /** - * 获取详情 - * @param $id - * @return array - */ - public function getInfoById($id) { - try { - $model = new OrderHotel(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取子订单信息失败:" . $id); - } - return Util::returnArrSu("",$result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取子订单信息失败:" . $id); - } - } - - /** - * 删除记录 - * @param $order_id - */ - public function delete($order_id){ - $model = new OrderHotel(); - $model->save(["del_flag"=>1],["order_id"=>$order_id]); - } - - /** - * 删除记录 - * @param $id - */ - public function delById($id) { - $model = new OrderHotel(); - $model->save(["del_flag"=>1],["id"=>$id]); - } - - /** - * 获取酒店子订单列表 - * @param $orderId - * @return array - */ - public function getListByOrderId($orderId){ - $subOrderModel = new OrderHotel(); - try { - $subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); - if (null == $subOrderList) { - return Util::returnArrSu("",[]); - } - return Util::returnArrSu("", $subOrderList); - }catch (Exception $e) { - return Util::returnArrEr("获取酒店订单列表异常:".$e->getMessage()); - } - } - - /**=====================================**/ - - /** - * 更新付款单下的状态 - * @param $paymentOrderId - * @param $status - * @return array - */ - public function setPaymentOrderStatus($paymentOrderId, $status){ - try{ - $model = new OrderHotel(); - $model->save(['payment_order_status'=>$status],['payment_order_id'=>$paymentOrderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新收款单下的酒店订单状态失败".$e->getMessage()); - } - } - - /** - * 添加酒店订单到付款单下 - * @param $paymentOrder - * @param $orderIds - * @return array - */ - public function addSubOrderInPayment($paymentOrder,$orderIds){ - try{ - $data = [ - "payment_order_id"=>$paymentOrder['id'], - "payment_order_status"=>$paymentOrder['status'], - "payment_order_name"=>$paymentOrder['name'] - ]; - $model = new OrderHotel(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("添加酒店订单到付款单下失败".$e->getMessage()); - } - } - - /** - * 将酒店订单从付款单下移除 - * @param $orderIds - * @return array - */ - public function removeSubOrderFormPayment($orderIds){ - try{ - $data = [ - "payment_order_id"=>0, - "payment_order_status"=>0, - "payment_order_name"=>"" - ]; - $model = new OrderHotel(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将酒店订单从付款单下移除失败".$e->getMessage()); - } - } - - /** - * 删除采购单 - * @param $id - * @return array - */ - public function delPaymentOrder($id){ - try{ - $data = [ - "payment_order_id"=>0, - "payment_order_status"=>0, - "payment_order_name"=>"" - ]; - $model = new OrderHotel(); - $model->save($data,["payment_order_id"=>$id]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将酒店订单从付款单下移除失败".$e->getMessage()); - } - } - - /** - * 获取主订单ID - * @param $payment_order_id - * @return array - */ - public function getOrderMainIdByPayment($payment_order_id){ - $subOrderModel = new OrderHotel(); - try { - $subOrderList = $subOrderModel->where(["payment_order_id" => $payment_order_id, "del_flag" => 0])->select()->toArray(); - if (null == $subOrderList) { - return []; - } - $id = []; - foreach ($subOrderList as $val){ - $id[] = $val['order_id']; - } - return array_unique($id); - }catch (Exception $e) { - return []; - } - } -} \ No newline at end of file diff --git a/application/admin/service/OrderItemDao.php b/application/admin/service/OrderItemDao.php deleted file mode 100644 index 5017255..0000000 --- a/application/admin/service/OrderItemDao.php +++ /dev/null @@ -1,272 +0,0 @@ -getItemInfo($param['item_id']); - if (!$itemInfo['flag']){ - return $itemInfo; - } - try{ - //设置入参 - $data = [ - "order_id" => $orderId, - //附加项目 - "item_id"=>$itemInfo['data']['id'], - "item_type"=>$itemInfo['data']['item_type'], - "item_name"=>$itemInfo['data']['item_name'], - "item_memo"=>$itemInfo['data']['item_memo'], - "item_unit"=>$itemInfo['data']['item_unit'], - "area_name" => $itemInfo['data']['area_name'], - "province_name" => $itemInfo['data']['province_name'], - "city_name" => $itemInfo['data']['city_name'], - "detail_address" => $itemInfo['data']['detail_address'], - //其他 - "check_in_date" => $param['check_in_date'], - "confirm_status" => $param['confirm_status'], - "confirm_no" => $param['confirm_no'], - "customer_name" => $param['customer_name'], - "customer_comments" => empty($param['customer_comments'])?"":$param['customer_comments'], - "trade_order_number" => $param['trade_order_number'], - "del_flag"=>0 - ]; - $model = new OrderItem(); - if (empty($param['id'])) { - $id = $model->insertGetId($data); - return Util::returnArrSu("",$id); - }else { - $model->save($data,["id"=>$param['id']]); - return Util::returnArrSu("",$param['id']); - } - }catch (Exception $e){ - return Util::returnArrEr("更新附加项目子订单失败:".$e->getMessage()); - } - - } - - /** - * 获取附加项目信息 - * @param $id - * @return array - */ - public function getItemInfo($id) - { - try { - $model = new CfItem(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取附加项目信息失败:" . $id); - } - return Util::returnArrSu("",$result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取附加项目信息失败:" . $id); - } - } - - /** - * 设置子订单金额 - * @param int $subOrderId - * @return array - */ - public function setSubOrderAmount( int $subOrderId) { - try{ - $purchaseModel = new Purchase(); - $purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); - $cost = 0; - $amount = 0; - $count = 0; - foreach ($purchaseList as $purchase) { - $cost += $purchase['total_cost']; - $amount += $purchase['total_price']; - $count += $purchase['count']; - } - //更新数据 - $oderItem = new OrderItem(); - $oderItem->save(["total_price"=>$amount,"total_cost"=>$cost,"prod_num"=>$count,"profit"=>$amount-$cost],["id"=>$subOrderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新附加项目订单子表金额失败:".$subOrderId); - } - - } - - /** - * 获取详情 - * @param $id - * @return array - */ - public function getInfoById($id) { - try { - $model = new OrderItem(); - $result = $model->where(["id" => $id])->find(); - if ($result == null) { - return Util::returnArrEr("获取子订单信息失败:" . $id); - } - return Util::returnArrSu("", $result->toArray()); - } catch (Exception $e) { - return Util::returnArrEr("获取子订单信息失败:" . $id); - } - } - - /** - * 删除记录 - * @param $order_id - */ - public function delete($order_id){ - $model = new OrderItem(); - $model->save(["del_flag"=>1],["order_id"=>$order_id]); - } - - /** - * 删除记录 - * @param $id - */ - public function delById($id) { - $model = new OrderItem(); - $model->save(["del_flag"=>1],["id"=>$id]); - } - - /** - * 获取附加项目子订单列表 - * @param $orderId - * @return array - */ - public function getListByOrderId($orderId){ - $subOrderModel = new OrderItem(); - try { - $subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); - if (null == $subOrderList) { - return Util::returnArrSu("",[]); - } - return Util::returnArrSu("", $subOrderList); - }catch (Exception $e) { - return Util::returnArrEr("获取附加项目订单列表异常".$e->getMessage()); - } - } - - - /**=====================================**/ - - /** - * 更新付款单下的状态 - * @param $paymentOrderId - * @param $status - * @return array - */ - public function setPaymentOrderStatus($paymentOrderId, $status){ - try{ - $model = new OrderItem(); - $model->save(['payment_order_status'=>$status],['payment_order_id'=>$paymentOrderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新收款单下的附加项目订单状态失败".$e->getMessage()); - } - } - - /** - * 添加附加项目订单到付款单下 - * @param $paymentOrder - * @param $orderIds - * @return array - */ - public function addSubOrderInPayment($paymentOrder,$orderIds){ - try{ - $data = [ - "payment_order_id"=>$paymentOrder['id'], - "payment_order_status"=>$paymentOrder['status'], - "payment_order_name"=>$paymentOrder['name'] - ]; - $model = new OrderItem(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("添加附加项目订单到付款单下失败".$e->getMessage()); - } - } - - /** - * 将附加项目订单从付款单下移除 - * @param $orderIds - * @return array - */ - public function removeSubOrderFormPayment($orderIds){ - try{ - $data = [ - "payment_order_id"=>0, - "payment_order_status"=>0, - "payment_order_name"=>"" - ]; - $model = new OrderItem(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将附加项目订单从付款单下移除失败".$e->getMessage()); - } - } - - /** - * 删除采购单 - * @param $id - * @return array - */ - public function delPaymentOrder($id){ - try{ - $data = [ - "payment_order_id"=>0, - "payment_order_status"=>0, - "payment_order_name"=>"" - ]; - $model = new OrderItem(); - $model->save($data,["payment_order_id"=>$id]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将附加项目订单从付款单下移除失败".$e->getMessage()); - } - } - - /** - * 获取主订单ID - * @param $payment_order_id - * @return array - */ - public function getOrderMainIdByPayment($payment_order_id){ - $subOrderModel = new OrderItem(); - try { - $subOrderList = $subOrderModel->where(["payment_order_id" => $payment_order_id, "del_flag" => 0])->select()->toArray(); - if (null == $subOrderList) { - return []; - } - $id = []; - foreach ($subOrderList as $val){ - $id[] = $val['order_id']; - } - return array_unique($id); - }catch (Exception $e) { - return []; - } - } -} \ No newline at end of file diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php deleted file mode 100644 index f572934..0000000 --- a/application/admin/service/OrderMainDao.php +++ /dev/null @@ -1,321 +0,0 @@ -getInfoById($param['channel_id']); - if (!$channelRe['flag']) { - return $channelRe; - } - //2.获取专员 - $adminDao = new AdminDao(); - $adminRe = $adminDao->getInfoById($param['commissioner_id']); - if (!$adminRe['flag']) { - return $adminRe; - } - $data = [ - "commissioner_id"=>$param['commissioner_id'], - "commissioner"=>$adminRe["data"]['nickname'], - "channel_id"=>$param["channel_id"], - "channel_name"=>$channelRe['data']['channel_name'], - "channel_order_no"=>$param["channel_order_no"], - "user_name"=>$param["user_name"], - "user_phone"=>$param["user_phone"], - "order_memo"=>$param["order_memo"], - "create_id"=>empty($param['create_id'])?0:$param['create_id'], - "group_id"=>empty($param['group_id'])?0:$param['group_id'] - ]; - $orderMain = new OrderMain(); - if (empty($param['id'])) { - $id = $orderMain->insertGetId($data); - return Util::returnArrSu("", $id); - } else { - $orderMain->save($data,['id'=>$param['id']]); - return Util::returnArrSu("", $param['id']); - } - }catch (Exception $e){ - return Util::returnArrEr("更新主订单失败:".$e->getMessage()); - } - - } - - /** - * 设置主订单金额 - * @param int $orderId - * @return array - */ - public function setOrderAmount(int $orderId){ - try { - $itemModel = new OrderItem(); - $hotelModel = new OrderHotel(); - $itemList = $itemModel->where(["order_id" => $orderId,"del_flag"=>0])->select()->toArray(); - $hotelList = $hotelModel->where(["order_id" => $orderId,"del_flag"=>0])->select()->toArray(); - $amount = 0; - $cost = 0; - //状态数量统计 用于统计当前订单的状态 - $statusList = [ - 1=>0, - 2=>0, - 3=>0, - 4=>0, - "isPayment"=>0 - ]; - $cnt = count($itemList)+count($hotelList); - foreach ($itemList as $item) { - $amount += $item['total_price']; - $cost += $item['total_cost']; - $statusList[$item['confirm_status']]++; - if ($item['payment_order_status'] ==2) { - $statusList['isPayment']++; - } - } - foreach ($hotelList as $hotel) { - $amount += $hotel['total_price']; - $cost += $hotel["total_cost"]; - $statusList[$hotel['confirm_status']]++; - if ($hotel['payment_order_status'] ==2) { - $statusList['isPayment']++; - } - } - $orderInfoRe = $this->getInfoById($orderId); - if (!$orderInfoRe['flag']) { - return $orderInfoRe; - } - $orderStatus = $this->getStatus($cnt,$statusList,$orderInfoRe['data']); - //更新金额 - $orderMain = new OrderMain(); - $orderMain->save(["total_amount" => $amount, "cost_amount" => $cost,"profit_amount"=>$amount-$cost,"order_status"=>$orderStatus],["id" => $orderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新主表订单金额失败:".$e->getMessage()); - } - } - - /** - * 获取订单状态 - * @param $cnt - * @param $statusList - * @param $orderInfo - * @return int - */ - public function getStatus($cnt,$statusList,$orderInfo){ - //资源单状态 1、未发单/ 2已发单、3已确认、4已取消 - //订单状态0待处理 1已确认 2部分取消 3处理中 10已完成 11已取消 - //已完成:订单已完成付款、已完成收款(无视子订单状态) - if ($orderInfo['receipt_order_status'] ==2 && $statusList['isPayment'] == $cnt) { - return 10; - } - //全部未发单 待处理:子订单全部未发单 - if ($statusList[1] == $cnt) { - return 0; - } - //全部已确认 已确认:子订单全部已确认 - if ($statusList[3] == $cnt) { - return 1; - } - //全部已取消 已取消:订单中所有子订单已取消 - if ($statusList[4] == $cnt) { - return 11; - } - //部分取消:订单中有子订单取消,其他子订单已确认 - if (($statusList[3]+$statusList[4]) == $cnt ) { - return 2; - } - //处理中:非以上状态,即部分子订单确认、或者部分子订单在已发单,或部分子订单在未发单。 - return 3; - - } - - - - /** - * 根据ID获取详情 - * @param $id - * @return array - */ - public function getInfoById($id) { - try { - $orderMainModel = new OrderMain(); - $orderMain = $orderMainModel->where(["id" => $id])->find(); - if (null == $orderMain) { - return Util::returnArrEr("订单查询失败:".$id); - } - return Util::returnArrSu("",$orderMain->toArray()); - }catch (Exception $e) { - return Util::returnArrEr("订单查询失败:".$e->getMessage()); - } - } - - /** - * 子订单展示 - * @param $purchaseShow - * @param $orderHotel - * @param $orderItem - * @return array - */ - public function setSubOrderShow($purchaseShow,$orderHotel,$orderItem){ - $result = []; - - foreach ($orderItem as $item) { - $item['prod_type'] = 'item'; - foreach ($purchaseShow as $key=> $purchase) { - if ($item['id'] == $key) { - $item = array_merge($item,$purchase); - } - } - $result[] = $item; - } - foreach ($orderHotel as $hotel) { - $hotel['prod_type'] = 'hotel'; - foreach ($purchaseShow as $key=> $purchase) { - if ($hotel['id'] == $key) { - $hotel = array_merge($hotel,$purchase); - } - } - $result[] = $hotel; - } - return Util::returnArrSu("",$result); - } - - /** - * 更新收款单下的订单信息 - * @param $receiptOrderId - * @param $status - * @return array - */ - public function setReceiptOrderStatus($receiptOrderId, $status){ - try{ - $model = new OrderMain(); - $model->save(['receipt_order_status'=>$status],['receipt_order_id'=>$receiptOrderId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新收款单子啊的主订单状态失败".$e->getMessage()); - } - } - - /** - * 添加主订单到收款单下 - * @param $receiptOrder - * @param $orderIds - * @return array - */ - public function addOrderMainInReceipt($receiptOrder,$orderIds){ - try{ - $data = [ - "receipt_order_id"=>$receiptOrder['id'], - "receipt_order_status"=>$receiptOrder['status'], - "receipt_order_name"=>$receiptOrder['name'] - ]; - $model = new OrderMain(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("添加主订单到收款单下失败".$e->getMessage()); - } - } - - /** - * 将主订单从收款单下移除 - * @param $orderIds - * @return array - */ - public function removeOrderMainFormReceipt($orderIds){ - try{ - $data = [ - "receipt_order_id"=>0, - "receipt_order_status"=>0, - "receipt_order_name"=>"" - ]; - $model = new OrderMain(); - $model->save($data,["id"=>["in",$orderIds]]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); - } - } - - /** - * 获取订单列表 - * @param $where - * @param $param - * @return array - */ - public function getOrderListByWhere($where,$param){ - try { - $offset = ($param['pageNum'] - 1) * $param['pageSize']; - $model = new OrderMain(); - $count = $model->where($where)->count(); - $list = $model->where($where)->limit($offset,$param['pageSize'])->order("id","DESC")->select(); - return Util::returnArrSu("", ["total" => $count, "list" => $list->toArray()]); - }catch (Exception $e){ - return Util::returnArrSu("", ["total" => 0, "list" => []]); - } - } - - /** - * 删除收款单 - * @param $id - * @return array - */ - public function delReceiptOrder($id){ - try{ - $data = [ - "receipt_order_id"=>0, - "receipt_order_status"=>0, - "receipt_order_name"=>"" - ]; - $model = new OrderMain(); - $model->save($data,["receipt_order_id"=>$id]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); - } - } - - /** - * 获取收款单下所有主订单的订单ID - * @param $receipt_order_id - * @return array - */ - public function getOrderMainIdsByReceipt($receipt_order_id){ - $orderModel = new OrderMain(); - try { - $subOrderList = $orderModel->where(["receipt_order_id" => $receipt_order_id, "del_flag" => 0])->select()->toArray(); - if (null == $subOrderList) { - return []; - } - - $id = []; - foreach ($subOrderList as $val){ - $id[] = $val['id']; - } - return array_unique($id); - }catch (Exception $e) { - return []; - } - } -} \ No newline at end of file diff --git a/application/admin/service/OrderMainService.php b/application/admin/service/OrderMainService.php index f4d03c0..ca70037 100644 --- a/application/admin/service/OrderMainService.php +++ b/application/admin/service/OrderMainService.php @@ -3,13 +3,11 @@ namespace app\admin\service; use app\admin\command\Util; -use app\admin\model\OrderHotel; -use app\admin\model\OrderItem; -use app\admin\model\OrderMain; -use app\admin\model\Purchase; -use app\admin\model\PurchasePrice; -use think\Exception; -use think\Url; +use app\admin\dao\OrderHotelDao; +use app\admin\dao\OrderItemDao; +use app\admin\dao\OrderMainDao; +use app\admin\dao\PurchaseDao; +use app\admin\dao\PurchasePriceDao; /** * Created by PhpStorm. @@ -217,7 +215,7 @@ class OrderMainService $orderMainDao = new OrderMainDao(); $orderMainDao->setOrderAmount($subOrderRe['data']['order_id']); return Util::returnArrSu("成功"); - }catch (Exception $e){ + }catch (\Exception $e){ return Util::returnArrEr("删除子订单失败:".$e->getMessage()); } } diff --git a/application/admin/service/PaymentOrderDao.php b/application/admin/service/PaymentOrderDao.php deleted file mode 100644 index 8666f68..0000000 --- a/application/admin/service/PaymentOrderDao.php +++ /dev/null @@ -1,236 +0,0 @@ -where(["id"=>$id])->find(); - if ($info == null) { - return Util::returnArrEr("获取付款单信息失败:".$id); - } - return Util::returnArrSu("",$info->toArray()); - }catch (Exception $e){ - return Util::returnArrEr("获取付款单信息失败:".$e->getMessage()); - } - } - - /** - * 添加记录 - * @param $param - * @return array - */ - public function save($param) - { - if ($this->checkName($param)) { - return Util::returnArrEr("名称已经存在"); - } - try { - $data = [ - 'name' => $param['name'], - "create_id"=>$param['create_id'], - "group_id"=>$param['group_id'] - ]; - $receiptOrder = new PaymentOrder(); - if (empty($param['id'])) { - $id = $receiptOrder->insertGetId($data); - return Util::returnArrSu("", $id); - } else { - $receiptOrder->save($data, ['id' => $param['id']]); - return Util::returnArrSu("", $param['id']); - } - } catch (Exception $e) { - return Util::returnArrEr("更新主订单失败:" . $e->getMessage()); - } - } - - /** - * 校验名称 - * @param $param - * @return bool - */ - public function checkName($param):bool { - try { - $model = new PaymentOrder(); - $infoRe = $model->where(["name" => $param['name']])->find(); - if ($infoRe == null) { - return false; - } - $info = $infoRe->toArray(); - if (isset($param['id'])) { - if ($param['id'] != $info['id']) { - return true; - } - }else{ - return true; - } - return false; - } catch (Exception $e) { - return false; - } - } - - /** - * 修改状态 - * @param $id - * @param $status - * @return array - */ - public function setStatus($id, $status) - { - try { - //设置收购单状态 - $receiptOrder = new PaymentOrder(); - $receiptOrder->save(['status' => $status], ['id' => $id]); - return Util::returnArrSu(); - } catch (Exception $e) { - return Util::returnArrEr("修改状态失败" . $e->getMessage()); - } - } - - - /** - * 获取列表 - * @param $param - * @return array - */ - public function getList($param) - { - try { - $where = ["a.del_flag"=>0]; - if (!empty($param['name'])) { - $where['a.name'] = ["like","%".$param['name']."%"]; - } - if ($param['status']."" != 'all') { - $where["a.status"] = $param['status']; - } - $offset = ($param['pageNum'] - 1) * $param['pageSize']; - $receiptOrder = new PaymentOrder(); - $total = $receiptOrder - ->alias("a") - ->group("a.id") - ->where($where)->count(); - $list = $receiptOrder - ->alias("a") - ->field("a.*, - (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '
金额:',ifnull( sum( total_price ), '-' )) from hbp_order_item where payment_order_id = a.id) 'item', - (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '
金额:',ifnull( sum( total_price ), '-' )) from hbp_order_hotel where payment_order_id = a.id) 'hotel' - ") - ->group("a.id") - ->where($where) - ->limit($offset, $param['pageSize']) - ->order("a.id","DESC")->select(); - - $data = ["total" => $total, "list" => $list->toArray()]; - return Util::returnArrSu("", $data); - } catch (Exception $e) { - return Util::returnArrSu("", ["total" => 0, "list" => []]); - } - } - - /** - * 删除 - * @param $id - * @return array - */ - public function del($id){ - try { - //设置收购单状态 - $receiptOrder = new PaymentOrder(); - $receiptOrder->save(['del_flag' => 1], ['id' => $id]); - return Util::returnArrSu(); - } catch (Exception $e) { - return Util::returnArrEr("修改状态失败" . $e->getMessage()); - } - } - - /** - * 获取子订单列表 - * @param $hotel_where - * @param $item_where - * @param $where - * @param $param - * @return array - */ - public function getSubOrderListByWhere($hotel_where,$item_where,$where,$param):array { - $limit = $param['pageSize']; - $offset = ($param['pageNum']-1)*$param['pageSize']; - $sqlCnt = "SELECT count(1) cnt - from ( - ( - SELECT a.order_id,a.id,d.supplier_name,a.trade_order_number,a.item_type 'hotel_name',a.item_name 'room_name', - a.item_unit 'plan_name', - a.check_in_date,a.check_in_date 'check_out_date',d.count,a.create_time,'item' as 'prod_type' - ,a.payment_order_name,a.payment_order_status,a.payment_order_id,a.customer_name,a.total_cost,a.total_price,a.confirm_status - from hbp_order_item a - INNER JOIN hbp_purchase d on a.id = d.order_detail_id and d.prod_type='item' - where - $item_where - order by a.create_time desc - ) - UNION - ( - SELECT b.order_id,b.id,c.supplier_name,b.trade_order_number,b.hotel_name ,b.room_name ,b.plan_name, - b.check_in_date,b.check_out_date,c.count,b.create_time,'hotel' as 'prod_type' - ,b.payment_order_name,b.payment_order_status,b.payment_order_id,b.customer_name,b.total_cost,b.total_price,b.confirm_status - from hbp_order_hotel b - INNER JOIN hbp_purchase c on b.id=c.order_detail_id and c.prod_type='hotel' - where - $hotel_where - order by b.create_time desc - ) - ) x - $where - ORDER BY x.create_time desc"; - $totalRe = Db::query($sqlCnt); - $sql = "SELECT x.* - from ( - ( - SELECT a.order_id,a.id,d.supplier_name,a.trade_order_number,a.item_type 'hotel_name',a.item_name 'room_name', - a.item_unit 'plan_name', - a.check_in_date,a.check_in_date 'check_out_date',d.count,a.create_time,'item' as 'prod_type' - ,a.payment_order_name,a.payment_order_status,a.payment_order_id,a.customer_name,a.total_cost,a.total_price,a.confirm_status - from hbp_order_item a - INNER JOIN hbp_purchase d on a.id = d.order_detail_id and d.prod_type='item' - where - $item_where - order by a.create_time desc - ) - UNION - ( - SELECT b.order_id,b.id,c.supplier_name,b.trade_order_number,b.hotel_name ,b.room_name ,b.plan_name, - b.check_in_date,b.check_out_date,c.count,b.create_time,'hotel' as 'prod_type' - ,b.payment_order_name,b.payment_order_status,b.payment_order_id,b.customer_name,b.total_cost,b.total_price,b.confirm_status - from hbp_order_hotel b - INNER JOIN hbp_purchase c on b.id=c.order_detail_id and c.prod_type='hotel' - where - $hotel_where - order by b.create_time desc - ) - ) x - ORDER BY x.create_time desc - limit $limit offset $offset"; - $list = Db::query($sql); - $result = ["list"=>$list,"total"=>$totalRe[0]['cnt']]; - return Util::returnArrSu("",$result); - } -} \ No newline at end of file diff --git a/application/admin/service/PaymentOrderService.php b/application/admin/service/PaymentOrderService.php index dc68b4d..d51d713 100644 --- a/application/admin/service/PaymentOrderService.php +++ b/application/admin/service/PaymentOrderService.php @@ -10,6 +10,10 @@ namespace app\admin\service; use app\admin\command\Util; +use app\admin\dao\OrderHotelDao; +use app\admin\dao\OrderItemDao; +use app\admin\dao\OrderMainDao; +use app\admin\dao\PaymentOrderDao; use think\Db; class PaymentOrderService diff --git a/application/admin/service/PurchaseDao.php b/application/admin/service/PurchaseDao.php deleted file mode 100644 index f74202f..0000000 --- a/application/admin/service/PurchaseDao.php +++ /dev/null @@ -1,211 +0,0 @@ -getInfoById($param['supplier_id']); - if (!$suplierRe['flag']) { - return $suplierRe; - } - //2.获取负责人昵称 - $adminDao = new AdminDao(); - $adminRe = $adminDao->getInfoById($param['purchase_user_id']); - if (!$adminRe['flag']) { - return $adminRe; - } - $data = [ - "order_id" => $hotelOrder['order_id'], - "prod_type" => 'hotel', - "order_detail_id" => $hotelOrder['id'], - "group_id" => $param['group_id'], - "pro_name" => $hotelOrder['hotel_name'], - "item_name" => $hotelOrder['room_name'], - "item_unit" => $hotelOrder['plan_name'], - "check_in_date" => $param['check_in_date'], - "check_out_date" => $param['check_out_date'], - "supplier_id" => $param['supplier_id'], - "supplier_name" => $suplierRe['data']['supplier_name'], - "purchase_user_id" => $param['purchase_user_id'], - "purchase_user" => $adminRe['data']['nickname'], - "del_flag"=>0 - ]; - - $model = new Purchase(); - if (empty($param['purchase_id'])) { - $id = $model->insertGetId($data); - return Util::returnArrSu("", $id); - }else { - $model->save($data,["id"=>$param['purchase_id']]); - return Util::returnArrSu("", $param['purchase_id']); - } - }catch (Exception $e){ - return Util::returnArrEr("新增采购单失败:".$e->getMessage()); - } - } - - /** - * 添加附加项目采购单 - * @param $param - * @param $itemOrder - * @return array - */ - public function saveItemPurchase($param, $itemOrder):array { - try { - //1.获取供应商名称 - $suplierDao = new CfSuplierInfoDao(); - $suplierRe = $suplierDao->getInfoById($param['supplier_id']); - if (!$suplierRe['flag']) { - return $suplierRe; - } - //2.获取负责人昵称 - $adminDao = new AdminDao(); - $adminRe = $adminDao->getInfoById($param['purchase_user_id']); - if (!$adminRe['flag']) { - return $adminRe; - } - $data = [ - "order_id" => $itemOrder['order_id'], - "prod_type" => 'item', - "order_detail_id" => $itemOrder['id'], - "group_id" => $param['group_id'], - "item_name" => $itemOrder['item_name'], - "item_unit" => $itemOrder['item_unit'], - "check_in_date" => $param['check_in_date'], - "supplier_id" => $param['supplier_id'], - "supplier_name" => $suplierRe['data']['supplier_name'], - "purchase_user_id" => $param['purchase_user_id'], - "purchase_user" => $adminRe['data']['nickname'], - "del_flag"=>0 - ]; - $model = new Purchase(); - if (empty($param['purchase_id'])) { - $id = $model->insertGetId($data); - return Util::returnArrSu("", $id); - }else { - $model->save($data,["id"=>$param['purchase_id']]); - return Util::returnArrSu("", $param['purchase_id']); - } - }catch (Exception $e){ - return Util::returnArrEr("新增采购单失败:".$e->getMessage()); - } - } - - /** - * 设置采购单 金额 - * @param $purchaseId - * @return array - */ - public function setPurchaseAmount(int $purchaseId){ - try{ - $purchasePrice = new PurchasePrice(); - $purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchaseId,"del_flag"=>0])->select()->toArray(); - $cost = 0; - $amount = 0; - $cnt = 0; - foreach ($purchasePriceList as $price) { - $cost += $price['cost'] * $price["count"]; - $amount += $price['price'] * $price["count"]; - $cnt += $price['count']; - } - $purchase = new Purchase(); - $purchase->save(["total_price"=>$amount,"total_cost"=>$cost,"count"=>$cnt,"profit"=>$amount-$cost],["id"=>$purchaseId]); - return Util::returnArrSu(); - }catch (Exception $e){ - return Util::returnArrEr("更新采购单金额失败:".$e->getMessage()); - } - - } - - /** - * 删除记录 - * @param $order_id - */ - public function delete($order_id){ - $model = new Purchase(); - $model->save(["del_flag"=>1],["order_id"=>$order_id]); - } - - /** - * 删除子订单 - * @param $subOrderId - */ - public function deleteBySubOrderId($subOrderId) { - $model = new Purchase(); - $model->save(["del_flag"=>1],["order_detail_id"=>$subOrderId]); - } - - /** - * 获取采购单列表 - * @param $orderId - * @return array - */ - public function getListByOrderId($orderId) { - $model = new Purchase(); - try { - $list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); - if (null == $list) { - return Util::returnArrSu("",[]); - } - return Util::returnArrSu("",$list); - }catch (Exception $e) { - return Util::returnArrEr("获取订单的采购单列表失败:".$e->getMessage()); - } - } - - /** - * 设置 - * @param $purchaseList - * @param $purchasePriceList - * @return array - */ - public function setPurchaseShow($purchaseList,$purchasePriceList){ - $result = []; - foreach ($purchaseList as $purchase) { - $purchaseShow=[ - "purchase_id"=>$purchase['id'], - "purchase_user_id"=>$purchase['purchase_user_id'], - "purchase_user"=>$purchase['purchase_user'], - "supplier_id"=>$purchase['supplier_id'], - "supplier_name" =>$purchase['supplier_name'], - "purchasePriceList"=>[] - ]; - foreach ($purchasePriceList as $price) { - if ($price['purchase_id'] == $purchase['id']) { - $priceShow = [ - "id"=>$price['id'], - "run_date"=>$price['run_date'], - "count"=>$price['count'], - "price"=>$price['price'], - "cost"=>$price['cost'] - ]; - $purchaseShow["purchasePriceList"][]=$priceShow; - } - } - $result[$purchase['order_detail_id']]= $purchaseShow; - } - return Util::returnArrSu("", $result); - } -} \ No newline at end of file diff --git a/application/admin/service/PurchasePriceDao.php b/application/admin/service/PurchasePriceDao.php deleted file mode 100644 index 1a180a1..0000000 --- a/application/admin/service/PurchasePriceDao.php +++ /dev/null @@ -1,95 +0,0 @@ -delete($order_detail_id); - //循环添加 - foreach ($param as $value) { - $data = [ - "order_id" => $order_id, - "prod_type" => $prod_type, - "order_detail_id" => $order_detail_id, - "purchase_id" => $purchase_id, - "run_date" => $value['run_date'], - "count" => $value['count'], - "price" => $value['price'], - "cost" => $value['cost'], - "del_flag" => 0 - ]; - $model = new PurchasePrice(); - if (empty($value['id'])) { - $model->insertGetId($data); - } else { - $model->save($data, ["id" => $value['id']]); - } - } - return Util::returnArrSu(); - } catch (Exception $e) { - return Util::returnArrEr("添加/更新采购单每日价格失败:" . $e->getMessage()); - } - } - - /** - * 删除数据 - * @param $purchase_id - */ - public function delete($purchase_id) - { - $model = new PurchasePrice(); - $model->save(["del_flag" => 1], ["purchase_id" => $purchase_id]); - } - - /** - * 删除子订单对于的每日价格 - * @param $subOrderId - */ - public function deleteBySubOrderId($subOrderId) { - $model = new PurchasePrice(); - $model->save(["del_flag" => 1], ["order_detail_id" => $subOrderId]); - } - - /** - * 获取采购单金额 - * @param $orderId - * @return array - */ - public function getPurchasePriceListByOrderId($orderId) { - $model = new PurchasePrice(); - try { - $list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select()->toArray(); - if (null == $list) { - return Util::returnArrSu("", []); - } - return Util::returnArrSu("", $list); - }catch (Exception $e) { - return Util::returnArrEr("获取采购单金额异常".$e->getMessage()); - } - } -} \ No newline at end of file diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php deleted file mode 100644 index ccb1884..0000000 --- a/application/admin/service/ReceiptOrderDao.php +++ /dev/null @@ -1,166 +0,0 @@ -where(["id"=>$id])->find(); - if ($info == null) { - return Util::returnArrEr("获取收款单信息失败:".$id); - } - return Util::returnArrSu("",$info->toArray()); - }catch (Exception $e){ - return Util::returnArrEr("获取收款单信息失败:".$e->getMessage()); - } - } - - /** - * 添加记录 - * @param $param - * @return array - */ - public function save($param) - { - if ($this->checkName($param)) { - return Util::returnArrEr("名称已经存在"); - } - try { - $data = [ - 'name' => $param['name'], - "create_id"=>$param['create_id'], - "group_id"=>$param['group_id'] - ]; - $receiptOrder = new ReceiptOrder(); - if (empty($param['id'])) { - $id = $receiptOrder->insertGetId($data); - return Util::returnArrSu("", $id); - } else { - $receiptOrder->save($data, ['id' => $param['id']]); - return Util::returnArrSu("", $param['id']); - } - } catch (Exception $e) { - return Util::returnArrEr("更新主订单失败:" . $e->getMessage()); - } - } - - /** - * 校验名称 - * @param $param - * @return bool - */ - public function checkName($param):bool { - try { - $model = new ReceiptOrder(); - $infoRe = $model->where(["name" => $param['name']])->find(); - if ($infoRe == null) { - return false; - } - $info = $infoRe->toArray(); - if (isset($param['id'])) { - if ($param['id'] != $info['id']) { - return true; - } - }else{ - return true; - } - return false; - } catch (Exception $e) { - return false; - } - } - - /** - * 修改状态 - * @param $id - * @param $status - * @return array - */ - public function setStatus($id, $status) - { - try { - //设置收购单状态 - $receiptOrder = new ReceiptOrder(); - $receiptOrder->save(['status' => $status], ['id' => $id]); - return Util::returnArrSu(); - } catch (Exception $e) { - return Util::returnArrEr("修改状态失败" . $e->getMessage()); - } - } - - - /** - * 获取列表 - * @param $param - * @return array - */ - public function getList($param) - { - try { - $where = ["a.del_flag"=>0]; - if (!empty($param['name'])) { - $where['a.name'] = ["like","%".$param['name']."%"]; - } - if ($param['status']."" != 'all') { - $where["a.status"] = $param['status']; - } - $offset = ($param['pageNum'] - 1) * $param['pageSize']; - $receiptOrder = new ReceiptOrder(); - $total = $receiptOrder - ->alias("a") - ->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') - ->field("a.*,GROUP_CONCAT(b.id) order_ids,sum(b.total_amount) total_amount") - ->group("a.id") - ->where($where)->count(); - - $list = $receiptOrder - ->alias("a") - ->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') - ->field("a.*,GROUP_CONCAT(b.id ORDER BY b.id DESC) order_ids,sum(b.total_amount) total_amount") - ->group("a.id") - ->where($where) - ->limit($offset, $param['pageSize']) - ->order("id","DESC")->select(); - $data = ["total" => $total, "list" => $list->toArray()]; - return Util::returnArrSu("", $data); - } catch (Exception $e) { - return Util::returnArrSu("", ["total" => 0, "list" => []]); - } - } - - /** - * 删除 - * @param $id - * @return array - */ - public function del($id){ - try { - //设置收购单状态 - $receiptOrder = new ReceiptOrder(); - $receiptOrder->save(['del_flag' => 1], ['id' => $id]); - return Util::returnArrSu(); - } catch (Exception $e) { - return Util::returnArrEr("修改状态失败" . $e->getMessage()); - } - } -} \ No newline at end of file diff --git a/application/admin/service/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index 9a84cf7..7412607 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -10,8 +10,9 @@ namespace app\admin\service; use app\admin\command\Util; +use app\admin\dao\OrderMainDao; +use app\admin\dao\ReceiptOrderDao; use think\Db; -use think\Exception; class ReceiptOrderService {