diff --git a/application/admin/controller/PaymentOrder.php b/application/admin/controller/PaymentOrder.php index 9deaad2..dba82d8 100755 --- a/application/admin/controller/PaymentOrder.php +++ b/application/admin/controller/PaymentOrder.php @@ -79,7 +79,7 @@ class PaymentOrder extends Backend public function addOrderMain(){ $params=$this->request->post(); $service = new PaymentOrderService(); - $result = $service->addOrderMain($params['id'],$params['order_id']); + $result = $service->addSubOrder($params); return json($result); } @@ -90,7 +90,7 @@ class PaymentOrder extends Backend public function removeOrderMain(){ $params=$this->request->post(); $service = new PaymentOrderService(); - $result = $service->removeOrderMain($params['order_id']); + $result = $service->removeSubOrder($params); return json($result); } @@ -99,10 +99,10 @@ class PaymentOrder extends Backend * 获取订单列表 * @return \think\response\Json */ - public function getOrderMainList(){ + public function getSubOrderList(){ $params=$this->request->post(); $service = new PaymentOrderService(); - $result = $service->getOrderMainList($params); + $result = $service->getSubOrderList($params); return json($result); } diff --git a/application/admin/service/OrderHotelDao.php b/application/admin/service/OrderHotelDao.php index 0221fd9..f4a47ef 100644 --- a/application/admin/service/OrderHotelDao.php +++ b/application/admin/service/OrderHotelDao.php @@ -243,7 +243,7 @@ class OrderHotelDao * @param $orderIds * @return array */ - public function addOrderMainInPayment($paymentOrder,$orderIds){ + public function addSubOrderInPayment($paymentOrder,$orderIds){ try{ $data = [ "payment_order_id"=>$paymentOrder['id'], @@ -263,7 +263,7 @@ class OrderHotelDao * @param $orderIds * @return array */ - public function removeOrderMainFormPayment($orderIds){ + public function removeSubOrderFormPayment($orderIds){ try{ $data = [ "payment_order_id"=>0, @@ -277,4 +277,24 @@ class OrderHotelDao 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()); + } + } } \ No newline at end of file diff --git a/application/admin/service/OrderItemDao.php b/application/admin/service/OrderItemDao.php index 3437384..3cf73d4 100644 --- a/application/admin/service/OrderItemDao.php +++ b/application/admin/service/OrderItemDao.php @@ -193,7 +193,7 @@ class OrderItemDao * @param $orderIds * @return array */ - public function addOrderMainInPayment($paymentOrder,$orderIds){ + public function addSubOrderInPayment($paymentOrder,$orderIds){ try{ $data = [ "payment_order_id"=>$paymentOrder['id'], @@ -213,7 +213,7 @@ class OrderItemDao * @param $orderIds * @return array */ - public function removeOrderMainFormPayment($orderIds){ + public function removeSubOrderFormPayment($orderIds){ try{ $data = [ "payment_order_id"=>0, @@ -227,4 +227,24 @@ class OrderItemDao 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()); + } + } } \ No newline at end of file diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php index 69fc8c3..bc5cedf 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -143,7 +143,7 @@ class OrderMainDao } /** - * 更新采购单下的订单信息 + * 更新收款单下的订单信息 * @param $receiptOrderId * @param $status * @return array @@ -159,7 +159,7 @@ class OrderMainDao } /** - * 添加主订单到采购单下 + * 添加主订单到收款单下 * @param $receiptOrder * @param $orderIds * @return array @@ -175,12 +175,12 @@ class OrderMainDao $model->save($data,["id"=>["in",$orderIds]]); return Util::returnArrSu(); }catch (Exception $e){ - return Util::returnArrEr("添加主订单到采购单下失败".$e->getMessage()); + return Util::returnArrEr("添加主订单到收款单下失败".$e->getMessage()); } } /** - * 将主订单从采购单下移除 + * 将主订单从收款单下移除 * @param $orderIds * @return array */ @@ -195,7 +195,7 @@ class OrderMainDao $model->save($data,["id"=>["in",$orderIds]]); return Util::returnArrSu(); }catch (Exception $e){ - return Util::returnArrEr("将主订单从采购单下移除失败".$e->getMessage()); + return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); } } @@ -218,7 +218,7 @@ class OrderMainDao } /** - * 删除采购单 + * 删除收款单 * @param $id * @return array */ @@ -233,7 +233,7 @@ class OrderMainDao $model->save($data,["receipt_order_id"=>$id]); return Util::returnArrSu(); }catch (Exception $e){ - return Util::returnArrEr("将主订单从采购单下移除失败".$e->getMessage()); + return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage()); } } } \ No newline at end of file diff --git a/application/admin/service/PaymentOrderDao.php b/application/admin/service/PaymentOrderDao.php index c7289e0..7064d2e 100644 --- a/application/admin/service/PaymentOrderDao.php +++ b/application/admin/service/PaymentOrderDao.php @@ -11,6 +11,7 @@ namespace app\admin\service; use app\admin\command\Util; use app\admin\model\PaymentOrder; +use think\Db; use think\Exception; class PaymentOrderDao @@ -131,16 +132,16 @@ class PaymentOrderDao ->alias("a") ->group("a.id") ->where($where)->count(); - $list = $receiptOrder ->alias("a") - ->join('hbp_order_hotel b', 'a.id = b.receipt_order_id', 'left') - ->join('hbp_order_item c', 'a.id = c.receipt_order_id', 'left') - ->field("a.*,GROUP_CONCAT(b.id ORDER BY b.id DESC) hotel_ids,sum(b.total_amount) hotel_amount,GROUP_CONCAT(c.id ORDER BY c.id DESC) hotel_ids,sum(c.total_amount) hotel_amount") + ->join('hbp_order_hotel b', 'a.id = b.payment_order_id', 'left') + ->join('hbp_order_item c', 'a.id = c.payment_order_id', 'left') + ->field("a.*,ifnull(GROUP_CONCAT(b.id ORDER BY b.id DESC),'-') hotel_ids,ifnull(sum(b.total_price),'-') hotel_amount, + ifnull(GROUP_CONCAT(c.id ORDER BY c.id DESC),'-') item_ids,ifnull(sum(c.total_price),'-') item_amount") ->group("a.id") ->where($where) ->limit($offset, $param['pageSize']) - ->order("id","DESC")->select(); + ->order("a.id","DESC")->select(); $data = ["total" => $total, "list" => $list->toArray()]; return Util::returnArrSu("", $data); } catch (Exception $e) { @@ -163,4 +164,75 @@ class PaymentOrderDao 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 b846036..fe2a87f 100644 --- a/application/admin/service/PaymentOrderService.php +++ b/application/admin/service/PaymentOrderService.php @@ -71,4 +71,164 @@ class PaymentOrderService Db::commit(); return Util::returnArrSu(); } + + + /** + * 添加子订单到付款单 + * @param $param + * @return array + */ + public function addSubOrder($param){ + $model = new PaymentOrderDao(); + $infoRe = $model->getInfoById($param['id']); + if (!$infoRe['flag']) { + return $infoRe; + } + if (isset($param['hotel_id']) && count($param['hotel_id'])>0) { + $orderMainDao = new OrderHotelDao(); + $addRe = $orderMainDao->addSubOrderInPayment($infoRe['data'],$param['hotel_id']); + if (!$addRe['flag']) { + return $addRe; + } + } + if (isset($param['item_id']) && count($param['item_id'])>0) { + $orderMainDao = new OrderItemDao(); + $addRe = $orderMainDao->addSubOrderInPayment($infoRe['data'],$param['item_id']); + if (!$addRe['flag']) { + return $addRe; + } + } + return Util::returnArrSu(); + } + + /** + * 移除子订单 + * @param $param + * @return array + */ + public function removeSubOrder($param){ + if (isset($param['hotel_id']) && count($param['hotel_id'])>0) { + $orderMainDao = new OrderHotelDao(); + $addRe = $orderMainDao->removeSubOrderFormPayment($param['hotel_id']); + if (!$addRe['flag']) { + return $addRe; + } + } + if (isset($param['item_id']) && count($param['item_id'])>0) { + $orderMainDao = new OrderItemDao(); + $addRe = $orderMainDao->removeSubOrderFormPayment($param['item_id']); + if (!$addRe['flag']) { + return $addRe; + } + } + return Util::returnArrSu(""); + } + + /** + * 获取子订单列表 + * @param $param + * @return array + */ + public function getSubOrderList($param){ + $dao = new PaymentOrderDao(); + $item_where_arr = ["d.del_flag=0","a.del_flag=0"]; + $hotel_where_arr = ["c.del_flag=0","b.del_flag=0"]; + $where_arr = []; + if ($param['prod_type']=='hotel'){ + $item_where_arr[] = " a.id = 0 "; + }else{ + $hotel_where_arr[]=" b.id = 0 "; + } + if (!empty($param['order_id'])) { + $item_where_arr[] = " a.id = {$param["order_id"]} "; + $hotel_where_arr[]=" b.id = {$param['order_id']} "; + } + if (!empty($param['supplier_id'])) { + $item_where_arr[] = " d.supplier_id = {$param["supplier_id"]} "; + $hotel_where_arr[]=" c.supplier_id = {$param['supplier_id']} "; + } + if (!empty($param['confirm_status'])) { + $item_where_arr[] = " a.confirm_status = {$param["confirm_status"]} "; + $hotel_where_arr[]=" b.confirm_status = {$param['confirm_status']} "; + } + if (!empty($param['customer_name'])) { + $item_where_arr[] = " a.customer_name like %{$param["customer_name"]}% "; + $hotel_where_arr[]=" b.customer_name like %{$param['customer_name']}% "; + } + if (!empty($param['item_id'])) { + $item_where_arr[] = " a.item_id = {$param["item_id"]} "; + } + if (!empty($param['hotel_id'])) { + $item_where_arr[] = " a.hotel_id = {$param["hotel_id"]} "; + } + + switch ($param['inPayment']) { + case 1: + $item_where_arr[] = " a.payment_order_id = {$param["payment_order_id"]} "; + $hotel_where_arr[]=" b.payment_order_id = {$param['payment_order_id']} "; + break; + case 2: + $item_where_arr[] = " a.payment_order_id != {$param["payment_order_id"]} "; + $hotel_where_arr[]=" b.payment_order_id != {$param['payment_order_id']} "; + break; + case 3: + $item_where_arr[] = " a.payment_order_id = '' "; + $hotel_where_arr[]=" b.payment_order_id = '' "; + } + + //金额区间查询 + if (!empty($param['startMoney'])) { + $item_where_arr[] = " a.total_cost >= {$param["startMoney"]} "; + $hotel_where_arr[]=" b.total_cost >= {$param['startMoney']} "; + } + if (!empty($param['endMoney'])) { + $item_where_arr[] = " a.total_cost <= {$param["endMoney"]} "; + $hotel_where_arr[]=" b.total_cost <= {$param['endMoney']} "; + } + + //时间区间查询 + if (!empty($param['startTime']) ) { + $item_where_arr[] = " a.create_time >= {$param["startTime"]} 00:00:00 "; + $hotel_where_arr[]=" b.create_time >= {$param['startTime']} 00:00:00 "; + } + if (!empty($param['endTime'])) { + $item_where_arr[] = " a.create_time <= {$param["endTime"]} 23:59:59 "; + $hotel_where_arr[]=" b.create_time <= {$param['endTime']} 23:59:59 "; + } + + return $dao->getSubOrderListByWhere(join(" and ",$hotel_where_arr),join(" and ",$item_where_arr),join(" and ",$where_arr),$param); + } + + /** + * 删除付款单 + * @param $id + * @return array + */ + public function delAll($id){ + Db::startTrans(); + //1.删除付款单下的附加项目订单 + $itemDao = new OrderItemDao(); + $itemRe = $itemDao->delPaymentOrder($id); + if (!$itemRe['flag']) { + Db::rollback(); + return $itemRe; + } + //1.删除付款单下的酒店订单 + $hotelDao = new OrderHotelDao(); + $hotelRe = $hotelDao->delPaymentOrder($id); + if (!$hotelRe['flag']) { + Db::rollback(); + return $hotelRe; + } + //2.删除付款单 + $model = new PaymentOrderDao(); + $delRe = $model->del($id); + if (!$delRe['flag']) { + Db::rollback(); + return $delRe; + } + Db::commit(); + return Util::returnArrSu(); + } + } \ No newline at end of file diff --git a/application/admin/service/PurchaseDao.php b/application/admin/service/PurchaseDao.php index b2ed1ab..f74202f 100644 --- a/application/admin/service/PurchaseDao.php +++ b/application/admin/service/PurchaseDao.php @@ -88,7 +88,7 @@ class PurchaseDao } $data = [ "order_id" => $itemOrder['order_id'], - "prod_type" => 'hotel', + "prod_type" => 'item', "order_detail_id" => $itemOrder['id'], "group_id" => $param['group_id'], "item_name" => $itemOrder['item_name'], diff --git a/application/admin/view/payment_order/index.html b/application/admin/view/payment_order/index.html index e8070bb..af64bee 100755 --- a/application/admin/view/payment_order/index.html +++ b/application/admin/view/payment_order/index.html @@ -1,4 +1,3 @@ - @@ -7,44 +6,681 @@ -
-
- 名称: - - 状态 - - - - - 搜索 +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+
+ + + +
+
+ + + 未付款 + 付款中 + 已付款 + + +
+
+ 保存 +
+
+
+
+ + + + + +
+ +
+
+ +
+
+ + + 未付款 + 付款中 + 已付款 + + +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 添加到采购单 +
+ +
+
+
+
+ + diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index 9286cf6..559abaa 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -129,7 +129,7 @@ :value="item.id"> - 收购单状态 + 收款单状态