diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e52083d..03d3779 100755
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,15 +1,18 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -24,7 +27,10 @@
-
+
+
+
+
@@ -83,21 +89,30 @@
+
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -112,7 +127,11 @@
-
+
+
+
+
+
1633847937612
@@ -184,11 +203,102 @@
1635067483089
-
+
+ 1635067920033
+
+
+
+ 1635067920033
+
+
+ 1635083574492
+
+
+
+ 1635083574492
+
+
+ 1635088810703
+
+
+
+ 1635088810703
+
+
+ 1635655791788
+
+
+
+ 1635655791788
+
+
+ 1635775792351
+
+
+
+ 1635775792351
+
+
+ 1635780400746
+
+
+
+ 1635780400746
+
+
+ 1635865804532
+
+
+
+ 1635865804532
+
+
+ 1636265845920
+
+
+
+ 1636265845920
+
+
+ 1636268317457
+
+
+
+ 1636268317457
+
+
+ 1636268567040
+
+
+
+ 1636268567040
+
+
+ 1636276001595
+
+
+
+ 1636276001595
+
+
+ 1636276496007
+
+
+
+ 1636276496007
+
+
+ 1636891272640
+
+
+
+ 1636891272640
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- file://$PROJECT_DIR$/public/index.php
- 13
-
-
-
- file://$PROJECT_DIR$/public/hotel.php
- 15
-
-
-
-
-
\ No newline at end of file
diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php
index bd0b5d0..abdd780 100755
--- a/application/admin/controller/Ajax.php
+++ b/application/admin/controller/Ajax.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\admin\command\Util;
use app\common\controller\Backend;
use app\common\exception\UploadException;
use app\common\library\Upload;
@@ -289,6 +290,26 @@ class Ajax extends Backend
$provincelist = Db::name('area')->where($where)->field('id as value,name')->select();
$this->success('', '', $provincelist);
}
+ /**
+ * 读取省市区数据,联动列表
+ */
+ public function areaList()
+ {
+ $province = $this->request->post('province', '');
+ $city = $this->request->post('city', '');
+ $where = ['pid' => 0, 'level' => 1];
+ $provincelist = null;
+ if ($province !== '') {
+ $where['pid'] = $province;
+ $where['level'] = 2;
+ if ($city !== '') {
+ $where['pid'] = $city;
+ $where['level'] = 3;
+ }
+ }
+ $provincelist = Db::name('area')->where($where)->field('id as value,name')->select();
+ return json(Util::returnArrSu("",$provincelist->toArray()));
+ }
/**
* 生成后缀图标
diff --git a/application/admin/controller/CfHotelInfo.php b/application/admin/controller/CfHotelInfo.php
index 2a882d0..db78784 100755
--- a/application/admin/controller/CfHotelInfo.php
+++ b/application/admin/controller/CfHotelInfo.php
@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\admin\model\Area;
+use app\admin\service\CfHotelInfoService;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
@@ -15,7 +16,7 @@ use think\exception\ValidateException;
*/
class CfHotelInfo extends Backend
{
-
+
/**
* CfHotelInfo模型对象
* @var \app\admin\model\CfHotelInfo
@@ -40,42 +41,6 @@ class CfHotelInfo extends Backend
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $group_id=$this->auth->getGroupId();
- $list = $this->model
- ->alias("a")
- ->join('hbp_admin c','a.create_id = c.id','left')
- ->field("a.*,c.nickname")
- ->where($where);
- if ($group_id){
- $list = $list
- ->where("group_id","=",$group_id)
- ->order($sort, $order)
- ->paginate($limit);
- }else{
- $list = $list
- ->order($sort, $order)
- ->paginate($limit);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
-
-
public function getHotelList(){
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
@@ -86,124 +51,36 @@ class CfHotelInfo extends Backend
return json(['list' => $result]);
}
+ /****=========================================**/
/**
- * 添加
+ * 获取列表
+ * @return \think\response\Json
*/
- public function add()
- {
- if ($this->request->isPost()) {
-
- $params = $this->request->post("row/a");
- if ($params) {
- $params = $this->preExcludeFields($params);
-
- if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
- $params[$this->dataLimitField] = $this->auth->id;
- }
- $result = false;
- Db::startTrans();
- try {
- //是否采用模型验证
- if ($this->modelValidate) {
- $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
- $this->model->validateFailException(true)->validate($validate);
- }
- $area=new Area();
- if ($params["area"]){
- $params["area_name"]=$area->where("id","=",$params["area"])->value("name");
- }
- if ($params["province"]){
- $params["province_name"]=$area->where("id","=",$params["province"])->value("name");
- }
- if ($params["city"]){
- $params["city_name"]=$area->where("id","=",$params["city"])->value("name");
- }
- $params['create_id']=$this->auth->id;
- $params['group_id']=$this->auth->getGroupId();
- $result = $this->model->allowField(true)->save($params);
- Db::commit();
- } catch (ValidateException $e) {
- Db::rollback();
- $this->error($e->getMessage());
- } catch (PDOException $e) {
- Db::rollback();
- $this->error($e->getMessage());
- } catch (Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- if ($result !== false) {
- $this->success();
- } else {
- $this->error(__('No rows were inserted'));
- }
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- return $this->view->fetch();
+ public function getList(){
+ $params=$this->request->post();
+ $service = new CfHotelInfoService();
+ return json($service->getList($params));
}
+ /**
+ * 保存记录
+ * @return \think\response\Json
+ */
+ public function save(){
+ $params=$this->request->post();
+ $params['create_id']=$this->auth->id;
+ $params['group_id']=$this->auth->getGroupId();
+ $service = new CfHotelInfoService();
+ return json($service->save($params));
+ }
/**
- * 编辑
+ * 删除
+ * @return \think\response\Json
*/
- public function edit($ids = null)
- {
- $row = $this->model->get($ids);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $adminIds = $this->getDataLimitAdminIds();
- if (is_array($adminIds)) {
- if (!in_array($row[$this->dataLimitField], $adminIds)) {
- $this->error(__('You have no permission'));
- }
- }
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- if ($params) {
- $params = $this->preExcludeFields($params);
- $result = false;
- Db::startTrans();
- try {
- //是否采用模型验证
- if ($this->modelValidate) {
- $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
- $row->validateFailException(true)->validate($validate);
- }
- $area=new Area();
- if ($params["area"]){
- $params["area_name"]=$area->where("id","=",$params["area"])->value("name");
- }
- if ($params["province"]){
- $params["province_name"]=$area->where("id","=",$params["province"])->value("name");
- }
- if ($params["city"]){
- $params["city_name"]=$area->where("id","=",$params["city"])->value("name");
- }
- $result = $row->allowField(true)->save($params);
- Db::commit();
- } catch (ValidateException $e) {
- Db::rollback();
- $this->error($e->getMessage());
- } catch (PDOException $e) {
- Db::rollback();
- $this->error($e->getMessage());
- } catch (Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- if ($result !== false) {
- $this->success();
- } else {
- $this->error(__('No rows were updated'));
- }
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- $this->view->assign("row", $row);
- return $this->view->fetch();
+ public function delAll(){
+ $params=$this->request->post();
+ $service = new CfHotelInfoService();
+ return json($service->del($params));
}
}
diff --git a/application/admin/controller/CfItem.php b/application/admin/controller/CfItem.php
index 378b33a..c668c07 100755
--- a/application/admin/controller/CfItem.php
+++ b/application/admin/controller/CfItem.php
@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\admin\model\Area;
+use app\admin\service\CfItemService;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
@@ -57,7 +58,7 @@ class CfItem extends Backend
->alias("a")
->join('hbp_admin c','a.create_id = c.id','left')
->join('hbp_admin d','a.purchase_user_id = d.id','left')
- ->field("a.*,c.nickname,d.nickname as purchase_user_name")
+ ->field("a.*,d.nickname")
->where($where);
if ($group_id){
$list = $list
@@ -76,7 +77,7 @@ class CfItem extends Backend
$config1 = json_decode($config1,true);
$res = $list->items();
foreach ($res as $key=>$val){
- $res[$key]["item_type_name"]=$config[$val["item_type"]];
+ $res[$key]["item_type"]=$config[$val["item_type"]];
$res[$key]["item_unit"]=$config1[$val["item_unit"]];
}
$result = array("total" => $list->total(), "rows" => $list->items());
@@ -213,12 +214,13 @@ class CfItem extends Backend
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,item_name as name,item_unit,item_type,item_memo');
+ $where = ["del_flag"=>0];
if($keyValue){
- $this->model->where(['id'=>$keyValue]);
+ $where = ['id'=>$keyValue,"del_flag"=>0];
}elseif($name){
- $this->model->where(['item_name'=>['like','%'.$name.'%']]);
+ $where = ['item_name'=>['like','%'.$name.'%'],"del_flag"=>0];
}
- $result= $this->model->select()->toArray();
+ $result= $this->model->where($where)->select()->toArray();
$config = \think\Config::get("site.item_category");
$config = json_decode($config,true);
@@ -236,4 +238,36 @@ class CfItem extends Backend
return json(['list' => $result]);
}
+ /**=================================================**/
+ /**
+ * 获取列表
+ * @return \think\response\Json
+ */
+ public function list(){
+ $params=$this->request->post();
+ $service = new CfItemService();
+ return json($service->getList($params));
+ }
+
+ /**
+ * 保存记录
+ * @return \think\response\Json
+ */
+ public function save(){
+ $params=$this->request->post();
+ $params['create_id']=$this->auth->id;
+ $params['group_id']=$this->auth->getGroupId();
+ $service = new CfItemService();
+ return json($service->save($params));
+ }
+
+ /**
+ * 删除
+ * @return \think\response\Json
+ */
+ public function delAll(){
+ $params=$this->request->post();
+ $service = new CfItemService();
+ return json($service->del($params));
+ }
}
diff --git a/application/admin/controller/CfRoomInfo.php b/application/admin/controller/CfRoomInfo.php
index 81180c4..64340a3 100755
--- a/application/admin/controller/CfRoomInfo.php
+++ b/application/admin/controller/CfRoomInfo.php
@@ -57,7 +57,7 @@ class CfRoomInfo extends Backend
->alias('a')
->join('hbp_cf_hotel_info b','a.hotel_id = b.id','left')
->join('hbp_admin c','a.create_id = c.id','left')
- ->field("a.id,a.room_name,a.room_memo,b.hotel_name,a.create_time,a.update_time,c.nickname")
+ ->field("a.id,a.hotel_id,a.room_name,a.room_memo,b.hotel_name,a.create_time,a.update_time,c.nickname")
->where($where);
if ($group_id){
$list = $list
@@ -181,7 +181,7 @@ class CfRoomInfo extends Backend
$hotelId=$this->request->get('hotelId');
$result= $this->model
->field("id,room_name as name,room_memo")
- ->where("hotel_id","=",$hotelId)->select();
+ ->where(["hotel_id"=>$hotelId,"del_flag"=>0])->select();
return json(['list' => $result]);
}
diff --git a/application/admin/controller/CfRoomPlan.php b/application/admin/controller/CfRoomPlan.php
index 4f76eed..0b38a57 100755
--- a/application/admin/controller/CfRoomPlan.php
+++ b/application/admin/controller/CfRoomPlan.php
@@ -52,16 +52,17 @@ class CfRoomPlan extends Backend
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,plan_name as name,purchase_user_id,plan_memo');
+ $where = ["del_flag"=>0];
if($keyValue){
- $this->model->where(['id'=>$keyValue]);
+ $where = ['id'=>$keyValue,"del_flag"=>0];
}elseif($name){
- $this->model->where(['plan_name'=>['like','%'.$name.'%']]);
+ $where = ['plan_name'=>['like','%'.$name.'%'],"del_flag"=>0];
}
$roomId =$this->request->get('room_id');
if ($roomId){
- $this->model->where("room_id","=",$roomId);
+ $where["room_id"] = $roomId;
}
- $result= $this->model->select();
+ $result= $this->model->where($where)->select();
if($keyValue){
return json(['list' => $result]);
}
@@ -84,11 +85,10 @@ class CfRoomPlan extends Backend
$group_id=$this->auth->getGroupId();
$list = $this->model
->alias("a")
- ->join('hbp_admin c','a.create_id = c.id','left')
- ->join('hbp_admin d','a.purchase_user_id = d.id','left')
+ ->join('hbp_admin','a.purchase_user_id = hbp_admin.id','left')
->join('hbp_cf_room_info e','a.room_id = e.id','left')
->join('hbp_cf_hotel_info f','a.hotel_id = f.id','left')
- ->field("a.*,c.nickname,d.nickname as purchase_user_name,e.room_name,f.hotel_name")
+ ->field("a.*,hbp_admin.nickname,e.room_name,f.hotel_name")
->where($where);
if ($group_id){
$list = $list
@@ -100,7 +100,12 @@ class CfRoomPlan extends Backend
->order($sort, $order)
->paginate($limit);
}
- $result = array("total" => $list->total(), "rows" => $list->items());
+ $result = $list->items();
+ foreach ($result as $k=>$item){
+ $result[$k]["continuity_type"]=$this->continuity_type[$item["continuity_type"]];
+ $result[$k]["hbp_admin.nickname"] = $item["nickname"];
+ }
+ $result = array("total" => $list->total(), "rows" => $result);
return json($result);
}
return $this->view->fetch();
diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php
index 411005c..3a83436 100755
--- a/application/admin/controller/OrderMain.php
+++ b/application/admin/controller/OrderMain.php
@@ -8,6 +8,7 @@ use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
+use think\Loader;
/**
* 订单主管理
@@ -26,7 +27,7 @@ class OrderMain extends Backend
{
parent::_initialize();
$this->model = new \app\admin\model\OrderMain;
-
+ $this->relationSearch = true;
}
public function import()
@@ -56,10 +57,10 @@ class OrderMain extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$group_id=$this->auth->getGroupId();
$list = $this->model
- ->alias("a")
- ->join('hbp_cf_channel_info b','a.channel_id = b.id','left')
- ->join('hbp_admin c','a.create_id = c.id','left')
- ->field("a.*,b.channel_name,c.nickname")
+ ->alias("order_main")
+ ->join('hbp_cf_channel_info b','order_main.channel_id = b.id','left')
+ ->join('hbp_admin','order_main.create_id = hbp_admin.id','left')
+ ->field("order_main.*,b.channel_name,hbp_admin.nickname")
->where($where);
if ($group_id){
$list = $list
@@ -90,6 +91,7 @@ class OrderMain extends Backend
$result[$k]["order_status"]="已取消";
break;
}
+ $result[$k]["hbp_admin.nickname"] = $item["nickname"];
}
$result = array("total" => $list->total(), "rows" =>$result);
@@ -100,6 +102,187 @@ class OrderMain extends Backend
/**
+ * 生成查询所需要的条件,排序方式
+ * @param mixed $searchfields 快速查询的字段
+ * @param boolean $relationSearch 是否关联查询
+ * @return array
+ */
+ protected function buildparams($searchfields = null, $relationSearch = null)
+ {
+ $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
+ $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
+ $search = $this->request->get("search", '');
+ $filter = $this->request->get("filter", '');
+ $op = $this->request->get("op", '', 'trim');
+ $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
+ $order = $this->request->get("order", "DESC");
+ $offset = $this->request->get("offset/d", 0);
+ $limit = $this->request->get("limit/d", 999999);
+ //新增自动计算页码
+ $page = $limit ? intval($offset / $limit) + 1 : 1;
+ if ($this->request->has("page")) {
+ $page = $this->request->get("page/d", 1);
+ }
+ $this->request->get([config('paginate.var_page') => $page]);
+ $filter = (array)json_decode($filter, true);
+ $op = (array)json_decode($op, true);
+ $filter = $filter ? $filter : [];
+ $where = [];
+ $alias = [];
+ $bind = [];
+ $name = '';
+ $aliasName = '';
+ if (!empty($this->model) && $this->relationSearch) {
+ $name = $this->model->getTable();
+ $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
+ $aliasName = $alias[$name] . '.';
+ }
+ $sortArr = explode(',', $sort);
+ foreach ($sortArr as $index => & $item) {
+ $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
+ }
+ unset($item);
+ $sort = implode(',', $sortArr);
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds)) {
+ $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
+ }
+ if ($search) {
+ $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
+ foreach ($searcharr as $k => &$v) {
+ $v = stripos($v, ".") === false ? $aliasName . $v : $v;
+ }
+ unset($v);
+ $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
+ }
+ $index = 0;
+ foreach ($filter as $k => $v) {
+ if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
+ continue;
+ }
+ $sym = isset($op[$k]) ? $op[$k] : '=';
+ if (stripos($k, ".") === false) {
+ $k = $aliasName . $k;
+ }
+ $v = !is_array($v) ? trim($v) : $v;
+ $sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
+ //null和空字符串特殊处理
+ if (!is_array($v)) {
+ if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
+ $sym = strtoupper($v);
+ }
+ if (in_array($v, ['""', "''"])) {
+ $v = '';
+ $sym = '=';
+ }
+ }
+
+ switch ($sym) {
+ case '=':
+ case '<>':
+ $where[] = [$k, $sym, (string)$v];
+ break;
+ case 'LIKE':
+ case 'NOT LIKE':
+ case 'LIKE %...%':
+ case 'NOT LIKE %...%':
+ $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
+ break;
+ case '>':
+ case '>=':
+ case '<':
+ case '<=':
+ $where[] = [$k, $sym, intval($v)];
+ break;
+ case 'FINDIN':
+ case 'FINDINSET':
+ case 'FIND_IN_SET':
+ $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
+ $findArr = array_values($v);
+ foreach ($findArr as $idx => $item) {
+ $bindName = "item_" . $index . "_" . $idx;
+ $bind[$bindName] = $item;
+ $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
+ }
+ break;
+ case 'IN':
+ case 'IN(...)':
+ case 'NOT IN':
+ case 'NOT IN(...)':
+ $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
+ break;
+ case 'BETWEEN':
+ case 'NOT BETWEEN':
+ $arr = array_slice(explode(',', $v), 0, 2);
+ if (stripos($v, ',') === false || !array_filter($arr)) {
+ continue 2;
+ }
+ //当出现一边为空时改变操作符
+ if ($arr[0] === '') {
+ $sym = $sym == 'BETWEEN' ? '<=' : '>';
+ $arr = $arr[1];
+ } elseif ($arr[1] === '') {
+ $sym = $sym == 'BETWEEN' ? '>=' : '<';
+ $arr = $arr[0];
+ }
+ $where[] = [$k, $sym, $arr];
+ break;
+ case 'RANGE':
+ case 'NOT RANGE':
+ $v = str_replace(' - ', ',', $v);
+ $arr = array_slice(explode(',', $v), 0, 2);
+ if (stripos($v, ',') === false || !array_filter($arr)) {
+ continue 2;
+ }
+ //当出现一边为空时改变操作符
+ if ($arr[0] === '') {
+ $sym = $sym == 'RANGE' ? '<=' : '>';
+ $arr = $arr[1];
+ } elseif ($arr[1] === '') {
+ $sym = $sym == 'RANGE' ? '>=' : '<';
+ $arr = $arr[0];
+ }
+ $tableArr = explode('.', $k);
+ if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
+ //修复关联模型下时间无法搜索的BUG
+ $relation = Loader::parseName($tableArr[0], 1, false);
+ $alias[$this->model->$relation()->getTable()] = $tableArr[0];
+ }
+ $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
+ break;
+ case 'NULL':
+ case 'IS NULL':
+ case 'NOT NULL':
+ case 'IS NOT NULL':
+ $where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
+ break;
+ default:
+ break;
+ }
+ $index++;
+ }
+ if (!empty($this->model)) {
+ $this->model->alias($alias);
+ }
+ $model = $this->model;
+ $where = function ($query) use ($where, $alias, $bind, &$model) {
+ if (!empty($model)) {
+ $model->alias($alias);
+ $model->bind($bind);
+ }
+ foreach ($where as $k => $v) {
+ if (is_array($v)) {
+ call_user_func_array([$query, 'where'], $v);
+ } else {
+ $query->where($v);
+ }
+ }
+ };
+ return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
+ }
+
+
+ /**
* 添加
*/
public function add()
@@ -246,6 +429,8 @@ class OrderMain extends Backend
*/
public function subOrderSave(){
$params=$this->request->post();
+ $params['create_id']=$this->auth->id;
+ $params['group_id']=$this->auth->getGroupId();
$orderMainService = new OrderMainService();
Db::startTrans();
$result = $orderMainService->subOrderSave($params);
diff --git a/application/admin/controller/PaymentOrder.php b/application/admin/controller/PaymentOrder.php
index c27b4b7..dba82d8 100755
--- a/application/admin/controller/PaymentOrder.php
+++ b/application/admin/controller/PaymentOrder.php
@@ -2,6 +2,7 @@
namespace app\admin\controller;
+use app\admin\service\PaymentOrderService;
use app\common\controller\Backend;
/**
@@ -35,6 +36,84 @@ class PaymentOrder extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
-
+
+ /**
+ * 保存记录
+ * @return \think\response\Json
+ */
+ public function save(){
+ $params=$this->request->post();
+ $params['create_id']=$this->auth->id;
+ $params['group_id']=$this->auth->getGroupId();
+ $service = new PaymentOrderService();
+ $result = $service->save($params);
+ return json($result);
+ }
+
+ /**
+ * 获取列表
+ * @return \think\response\Json
+ */
+ public function getList(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->getList($params);
+ return json($result);
+ }
+
+ /**
+ * 状态设置
+ * @return \think\response\Json
+ */
+ public function setStatus(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->setStatus($params['id'],$params['status']);
+ return json($result);
+ }
+
+ /**
+ * 添加到收款单
+ * @return \think\response\Json
+ */
+ public function addOrderMain(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->addSubOrder($params);
+ return json($result);
+ }
+
+ /**
+ * 移除收购单
+ * @return \think\response\Json
+ */
+ public function removeOrderMain(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->removeSubOrder($params);
+ return json($result);
+ }
+
+
+ /**
+ * 获取订单列表
+ * @return \think\response\Json
+ */
+ public function getSubOrderList(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->getSubOrderList($params);
+ return json($result);
+ }
+
+ /**
+ * 删除收款单
+ */
+ public function delAll(){
+ $params=$this->request->post();
+ $service = new PaymentOrderService();
+ $result = $service->delAll($params['id']);
+ return json($result);
+ }
}
diff --git a/application/admin/controller/ReceiptOrder.php b/application/admin/controller/ReceiptOrder.php
index 9539a19..9a15af4 100755
--- a/application/admin/controller/ReceiptOrder.php
+++ b/application/admin/controller/ReceiptOrder.php
@@ -256,4 +256,14 @@ class ReceiptOrder extends Backend
return json($result);
}
+ /**
+ * 删除收款单
+ */
+ public function delAll(){
+ $params=$this->request->post();
+ $service = new ReceiptOrderService();
+ $result = $service->delAll($params['id']);
+ return json($result);
+ }
+
}
diff --git a/application/admin/service/AdminDao.php b/application/admin/dao/AdminDao.php
similarity index 90%
rename from application/admin/service/AdminDao.php
rename to application/admin/dao/AdminDao.php
index f241709..c6f12c2 100644
--- a/application/admin/service/AdminDao.php
+++ b/application/admin/dao/AdminDao.php
@@ -6,7 +6,7 @@
* Time: 15:49
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -20,7 +20,7 @@ class AdminDao
* @param int $id
* @return array
*/
- public function getInfoById(int $id) {
+ public function getInfoById($id) {
try{
$model = new Admin();
$info = $model->where(["id"=>$id])->find();
diff --git a/application/admin/service/CfChannelInfoDao.php b/application/admin/dao/CfChannelInfoDao.php
similarity index 96%
rename from application/admin/service/CfChannelInfoDao.php
rename to application/admin/dao/CfChannelInfoDao.php
index 1bda8f4..b5c5fb1 100644
--- a/application/admin/service/CfChannelInfoDao.php
+++ b/application/admin/dao/CfChannelInfoDao.php
@@ -6,7 +6,7 @@
* Time: 15:20
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
diff --git a/application/admin/dao/CfHotelInfoDao.php b/application/admin/dao/CfHotelInfoDao.php
new file mode 100644
index 0000000..93bfa90
--- /dev/null
+++ b/application/admin/dao/CfHotelInfoDao.php
@@ -0,0 +1,103 @@
+ $param['hotel_name'],
+ 'hotel_phone' => $param['hotel_phone'],
+ 'area' => $param['area'],
+ 'area_name' => $param['area_name'],
+ 'province' => $param['province'],
+ 'province_name' => $param['province_name'],
+ 'city' => $param['city'],
+ 'city_name' => $param['city_name'],
+ 'detail_address' => $param['detail_address']
+ ];
+ $model = new CfHotelInfo();
+ if (empty($param['id'])) {
+ $data['create_id'] = $param['create_id'];
+ $data['group_id'] = $param['group_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 $param
+ * @return array
+ */
+ public function getList($param)
+ {
+ try {
+ $where = ["del_flag"=>0];
+ if (!empty($param['hotel_name'])) {
+ $where['hotel_name'] = ["like","%".$param['hotel_name']."%"];
+ }
+ if (!empty($param['hotel_phone'])) {
+ $where["hotel_phone"] = $param['hotel_phone'];
+ }
+ if (!empty($param['area'])) {
+ $where["area"] = $param['area'];
+ }
+ if (!empty($param['province'])) {
+ $where["province"] = $param['province'];
+ }
+ if (!empty($param['city'])) {
+ $where["city"] = $param['city'];
+ }
+ $offset = ($param['pageNum'] - 1) * $param['pageSize'];
+ $model = new CfHotelInfo();
+ $total = $model->where($where)->count();
+ $list = $model->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 {
+ //设置收购单状态
+ $model = new CfHotelInfo();
+ $model->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/dao/CfItemDao.php b/application/admin/dao/CfItemDao.php
new file mode 100644
index 0000000..0ee7d9f
--- /dev/null
+++ b/application/admin/dao/CfItemDao.php
@@ -0,0 +1,106 @@
+ $param['item_type'],
+ 'item_name' => $param['item_name'],
+ 'item_unit' => $param['item_unit'],
+ 'item_memo' => $param['item_memo'],
+ 'area' => $param['area'],
+ 'area_name' => $param['area_name'],
+ 'province' => $param['province'],
+ 'province_name' => $param['province_name'],
+ 'city' => $param['city'],
+ 'city_name' => $param['city_name'],
+ 'detail_address' => $param['detail_address'],
+ 'purchase_user_id'=>$param['purchase_user_id']
+ ];
+ $model = new CfItem();
+ if (empty($param['id'])) {
+ $data['create_id'] = $param['create_id'];
+ $data['group_id'] = $param['group_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 $param
+ * @return array
+ */
+ public function getList($param)
+ {
+ try {
+ $where = ["del_flag"=>0];
+ if (!empty($param['item_name'])) {
+ $where['item_name'] = ["like","%".$param['item_name']."%"];
+ }
+ if (!empty($param['item_type'])) {
+ $where["item_type"] = $param['item_type'];
+ }
+ if (!empty($param['area'])) {
+ $where["area"] = $param['area'];
+ }
+ if (!empty($param['province'])) {
+ $where["province"] = $param['province'];
+ }
+ if (!empty($param['city'])) {
+ $where["city"] = $param['city'];
+ }
+ $offset = ($param['pageNum'] - 1) * $param['pageSize'];
+ $model = new CfItem();
+ $total = $model->where($where)->count();
+ $list = $model->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 {
+ //设置收购单状态
+ $model = new CfItem();
+ $model->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/CfSuplierInfoDao.php b/application/admin/dao/CfSuplierInfoDao.php
similarity index 96%
rename from application/admin/service/CfSuplierInfoDao.php
rename to application/admin/dao/CfSuplierInfoDao.php
index 521cc60..e8cfb7e 100644
--- a/application/admin/service/CfSuplierInfoDao.php
+++ b/application/admin/dao/CfSuplierInfoDao.php
@@ -6,7 +6,7 @@
* Time: 16:03
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
diff --git a/application/admin/service/OrderHotelDao.php b/application/admin/dao/OrderHotelDao.php
similarity index 68%
rename from application/admin/service/OrderHotelDao.php
rename to application/admin/dao/OrderHotelDao.php
index 5c156ec..197a8a8 100644
--- a/application/admin/service/OrderHotelDao.php
+++ b/application/admin/dao/OrderHotelDao.php
@@ -6,7 +6,7 @@
* Time: 13:36
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -218,4 +218,105 @@ class OrderHotelDao
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/dao/OrderItemDao.php
similarity index 62%
rename from application/admin/service/OrderItemDao.php
rename to application/admin/dao/OrderItemDao.php
index 7f65182..1faed68 100644
--- a/application/admin/service/OrderItemDao.php
+++ b/application/admin/dao/OrderItemDao.php
@@ -6,7 +6,7 @@
* Time: 13:36
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -169,4 +169,104 @@ class OrderItemDao
}
+ /**=====================================**/
+
+ /**
+ * 更新付款单下的状态
+ * @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/dao/OrderMainDao.php
similarity index 62%
rename from application/admin/service/OrderMainDao.php
rename to application/admin/dao/OrderMainDao.php
index 62f7a4f..350c3c2 100644
--- a/application/admin/service/OrderMainDao.php
+++ b/application/admin/dao/OrderMainDao.php
@@ -6,7 +6,7 @@
* Time: 11:26
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -72,21 +72,43 @@ class OrderMainDao
try {
$itemModel = new OrderItem();
$hotelModel = new OrderHotel();
- $itemList = $itemModel->where(["order_id" => $orderId])->select()->toArray();
- $hotelList = $hotelModel->where(["order_id" => $orderId])->select()->toArray();
+ $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],["id" => $orderId]);
+ $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());
@@ -94,6 +116,43 @@ class OrderMainDao
}
/**
+ * 获取订单状态
+ * @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
@@ -143,7 +202,7 @@ class OrderMainDao
}
/**
- * 更新采购单下的订单信息
+ * 更新收款单下的订单信息
* @param $receiptOrderId
* @param $status
* @return array
@@ -159,7 +218,7 @@ class OrderMainDao
}
/**
- * 添加主订单到采购单下
+ * 添加主订单到收款单下
* @param $receiptOrder
* @param $orderIds
* @return array
@@ -172,15 +231,15 @@ class OrderMainDao
"receipt_order_name"=>$receiptOrder['name']
];
$model = new OrderMain();
- $model->save($data,["id"=>$orderIds]);
+ $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
*/
@@ -192,10 +251,10 @@ class OrderMainDao
"receipt_order_name"=>""
];
$model = new OrderMain();
- $model->save($data,["id"=>$orderIds]);
+ $model->save($data,["id"=>["in",$orderIds]]);
return Util::returnArrSu();
}catch (Exception $e){
- return Util::returnArrEr("将主订单从采购单下移除失败".$e->getMessage());
+ return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage());
}
}
@@ -216,4 +275,47 @@ class OrderMainDao
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/service/PurchaseDao.php b/application/admin/dao/PurchaseDao.php
similarity index 99%
rename from application/admin/service/PurchaseDao.php
rename to application/admin/dao/PurchaseDao.php
index b2ed1ab..53002ad 100644
--- a/application/admin/service/PurchaseDao.php
+++ b/application/admin/dao/PurchaseDao.php
@@ -6,7 +6,7 @@
* Time: 16:38
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -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/service/PurchasePriceDao.php b/application/admin/dao/PurchasePriceDao.php
similarity index 98%
rename from application/admin/service/PurchasePriceDao.php
rename to application/admin/dao/PurchasePriceDao.php
index 1a180a1..a0da498 100644
--- a/application/admin/service/PurchasePriceDao.php
+++ b/application/admin/dao/PurchasePriceDao.php
@@ -6,7 +6,7 @@
* Time: 19:19
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/dao/ReceiptOrderDao.php
similarity index 66%
rename from application/admin/service/ReceiptOrderDao.php
rename to application/admin/dao/ReceiptOrderDao.php
index 127d6ed..377258a 100644
--- a/application/admin/service/ReceiptOrderDao.php
+++ b/application/admin/dao/ReceiptOrderDao.php
@@ -6,7 +6,7 @@
* Time: 10:20
*/
-namespace app\admin\service;
+namespace app\admin\dao;
use app\admin\command\Util;
@@ -24,14 +24,14 @@ class ReceiptOrderDao
*/
public function getInfoById($id){
try{
- $model = new OrderMain();
+ $model = new ReceiptOrder();
$info = $model->where(["id"=>$id])->find();
if ($info == null) {
- return Util::returnArrEr("获取管理员信息失败:".$id);
+ return Util::returnArrEr("获取收款单信息失败:".$id);
}
return Util::returnArrSu("",$info->toArray());
}catch (Exception $e){
- return Util::returnArrEr("获取管理员信息失败:".$e->getMessage());
+ return Util::returnArrEr("获取收款单信息失败:".$e->getMessage());
}
}
@@ -42,6 +42,9 @@ class ReceiptOrderDao
*/
public function save($param)
{
+ if ($this->checkName($param)) {
+ return Util::returnArrEr("名称已经存在");
+ }
try {
$data = [
'name' => $param['name'],
@@ -62,6 +65,32 @@ class ReceiptOrderDao
}
/**
+ * 校验名称
+ * @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
@@ -88,11 +117,11 @@ class ReceiptOrderDao
public function getList($param)
{
try {
- $where = [];
+ $where = ["a.del_flag"=>0];
if (!empty($param['name'])) {
$where['a.name'] = ["like","%".$param['name']."%"];
}
- if ($param['status'] != 'all') {
+ if ($param['status']."" != 'all') {
$where["a.status"] = $param['status'];
}
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
@@ -107,7 +136,7 @@ class ReceiptOrderDao
$list = $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")
+ ->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'])
@@ -118,4 +147,20 @@ class ReceiptOrderDao
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/lang/zh-cn/cf_item.php b/application/admin/lang/zh-cn/cf_item.php
index c366e08..9514e82 100755
--- a/application/admin/lang/zh-cn/cf_item.php
+++ b/application/admin/lang/zh-cn/cf_item.php
@@ -4,7 +4,7 @@ return [
'Id' => '附加项目ID',
'Item_type' => '附件项目类型',
'Item_name' => '附件项目名称',
- 'Item_unit' => '计价单位 件、份、匝、张等',
+ 'Item_unit' => '计价单位',
'Item_memo' => '附件项目说明',
'Item_log' => '日志',
'Country_id' => '国家ID',
diff --git a/application/admin/lang/zh-cn/order_item.php b/application/admin/lang/zh-cn/order_item.php
index 75cf4ab..b0b7113 100755
--- a/application/admin/lang/zh-cn/order_item.php
+++ b/application/admin/lang/zh-cn/order_item.php
@@ -7,7 +7,7 @@ return [
'Item_type' => '附加项目类型',
'Item_name' => '附加项目名称',
'Item_memo' => '附加项目说明',
- 'Item_unit' => '计价单位 件、份、匝、张等',
+ 'Item_unit' => '计价单位',
'Use_date' => '使用日期',
'Prod_num' => '产品数量',
'Total_price' => '总金额',
diff --git a/application/admin/model/CfHotelInfo.php b/application/admin/model/CfHotelInfo.php
index 8b2e501..60154d2 100755
--- a/application/admin/model/CfHotelInfo.php
+++ b/application/admin/model/CfHotelInfo.php
@@ -31,12 +31,13 @@ class CfHotelInfo extends Model
public function getList($name='',$keyValue=''){
$this->field('id,hotel_name as name');
+ $where = ["del_flag"=>0];
if($keyValue){
- $this->where(['id'=>$keyValue]);
+ $where = ['id'=>$keyValue,"del_flag"=>0];
}elseif($name){
- $this->where(['hotel_name'=>['like','%'.$name.'%']]);
+ $where = ['hotel_name'=>['like','%'.$name.'%'],"del_flag"=>0];
}
- return $this->select()->toArray();
+ return $this->where($where)->select()->toArray();
}
diff --git a/application/admin/service/CfHotelInfoService.php b/application/admin/service/CfHotelInfoService.php
new file mode 100644
index 0000000..89919f9
--- /dev/null
+++ b/application/admin/service/CfHotelInfoService.php
@@ -0,0 +1,45 @@
+getList($param);
+ }
+
+ /**
+ * 保存记录
+ * @param $param
+ * @return array
+ */
+ public function save($param){
+ $dao = new CfHotelInfoDao();
+ return $dao->save($param);
+ }
+
+ /**
+ * 删除记录
+ * @param $param
+ * @return array
+ */
+ public function del($param){
+ $dao = new CfHotelInfoDao();
+ return $dao->del($param['id']);
+ }
+}
\ No newline at end of file
diff --git a/application/admin/service/CfItemService.php b/application/admin/service/CfItemService.php
new file mode 100644
index 0000000..97045a8
--- /dev/null
+++ b/application/admin/service/CfItemService.php
@@ -0,0 +1,45 @@
+getList($param);
+ }
+
+ /**
+ * 保存记录
+ * @param $param
+ * @return array
+ */
+ public function save($param){
+ $dao = new CfItemDao();
+ return $dao->save($param);
+ }
+
+ /**
+ * 删除记录
+ * @param $param
+ * @return array
+ */
+ public function del($param){
+ $dao = new CfItemDao();
+ return $dao->del($param['id']);
+ }
+}
\ No newline at end of file
diff --git a/application/admin/service/OrderMainService.php b/application/admin/service/OrderMainService.php
index bd05cd7..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.
@@ -35,6 +33,9 @@ class OrderMainService
if (!$addOrderMain["flag"]) {
return $addOrderMain;
}
+ if (!isset($param['subOrderList']) || count($param['subOrderList'])==0) {
+ return Util::returnArrSu("成功",$addOrderMain['data']);
+ }
$orderId = $addOrderMain['data'];
//所有子订单设置为删除
$orderHotelDao = new OrderHotelDao();
@@ -109,7 +110,7 @@ class OrderMainService
if (!$setOrderMainRe['flag']) {
return $setOrderMainRe;
}
- return Util::returnArrSu("",$orderId);
+ return Util::returnArrSu("成功",$orderId);
}
/**
@@ -135,20 +136,22 @@ class OrderMainService
}
$subOrderId = $addSubOrder['data'];
$subOrderInfo = $subOrderDao->getInfoById($subOrderId);
-
+ if (!$subOrderInfo['flag']) {
+ return $subOrderInfo;
+ }
/**
* 2.1添加子订单下的采购单
*/
$purchaseDao = new PurchaseDao();
if ($subOrderParam['prod_type'] == 'hotel') {
- $addPurchase = $purchaseDao->saveHotelPurchase($subOrderParam, $subOrderInfo);
+ $addPurchase = $purchaseDao->saveHotelPurchase($subOrderParam, $subOrderInfo['data']);
} else {
- $addPurchase = $purchaseDao->saveItemPurchase($subOrderParam, $subOrderInfo);
+ $addPurchase = $purchaseDao->saveItemPurchase($subOrderParam, $subOrderInfo['data']);
}
if (!$addPurchase['flag']) {
return $addPurchase;
}
- $purchaseId = $addPurchase['id'];
+ $purchaseId = $addPurchase['data'];
/**
* 2.1.1添加采购单的每日价格
@@ -182,7 +185,7 @@ class OrderMainService
if (!$setOrderMainRe['flag']) {
return $setOrderMainRe;
}
- return Util::returnArrSu("",$subOrderId);
+ return Util::returnArrSu("保存成功",$subOrderId);
}
/**
@@ -211,8 +214,8 @@ class OrderMainService
//重新计算订单总金额
$orderMainDao = new OrderMainDao();
$orderMainDao->setOrderAmount($subOrderRe['data']['order_id']);
- return Util::returnArrSu();
- }catch (Exception $e){
+ return Util::returnArrSu("成功");
+ }catch (\Exception $e){
return Util::returnArrEr("删除子订单失败:".$e->getMessage());
}
}
@@ -263,6 +266,6 @@ class OrderMainService
return $subOrderList;
}
$orderMain["subOrderList"]=$subOrderList['data'];
- return Util::returnArrSu("",$orderMain);
+ return Util::returnArrSu("成功",$orderMain);
}
}
\ No newline at end of file
diff --git a/application/admin/service/PaymentOrderService.php b/application/admin/service/PaymentOrderService.php
new file mode 100644
index 0000000..d51d713
--- /dev/null
+++ b/application/admin/service/PaymentOrderService.php
@@ -0,0 +1,250 @@
+save($param);
+ if (!$addRe['flag']) {
+ return $addRe;
+ }
+ return Util::returnArrSu();
+
+ }
+
+ /**
+ * 获取列表
+ * @param $param
+ * @return array
+ */
+ public function getList($param){
+ $dao = new PaymentOrderDao();
+ return $dao->getList($param);
+ }
+
+ /**
+ * 设置状态
+ * @param $id
+ * @param $status
+ * @return array
+ */
+ public function setStatus($id,$status) {
+ Db::startTrans();
+ //1.设置收购单状态
+ $dao = new PaymentOrderDao();
+ $statusRe = $dao->setStatus($id,$status);
+ if (!$statusRe['flag']) {
+ Db::rollback();
+ return$statusRe;
+ }
+ //2.设置所有订单表的状态
+ $hotelDao = new OrderHotelDao();
+ $hotelRe = $hotelDao->setPaymentOrderStatus($id,$status);
+ if (!$hotelRe['flag']) {
+ Db::rollback();
+ return $hotelRe;
+ }
+ $itemDao = new OrderItemDao();
+ $itemRe = $itemDao->setPaymentOrderStatus($id,$status);
+ if (!$itemRe['flag']) {
+ Db::rollback();
+ return $itemRe;
+ }
+ //3.获取所有子订单对应的主订单ID
+ $hotelIds = $hotelDao->getOrderMainIdByPayment($id);
+ $itemIds = $itemDao->getOrderMainIdByPayment($id);
+ $orderMainIds = array_unique(array_merge($hotelIds,$itemIds));
+ $orderMainDao = new OrderMainDao();
+ foreach ($orderMainIds as $orderId) {
+ $setRe = $orderMainDao->setOrderAmount($orderId);
+ if (!$setRe['flag']) {
+ Db::rollback();
+ return $setRe;
+ }
+ }
+ 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/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php
index b5edf02..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
{
@@ -22,8 +23,14 @@ class ReceiptOrderService
* @return array
*/
public function save($param){
+ //保存
$dao = new ReceiptOrderDao();
- return $dao->save($param);
+ $addRe = $dao->save($param);
+ if (!$addRe['flag']) {
+ return $addRe;
+ }
+ return Util::returnArrSu();
+
}
/**
@@ -58,6 +65,16 @@ class ReceiptOrderService
Db::rollback();
return $orderRe;
}
+
+ //3.设置订单状态
+ $orderIds = $orderDao->getOrderMainIdsByReceipt($id);
+ foreach ($orderIds as $orderId) {
+ $setRe = $orderDao->setOrderAmount($orderId);
+ if (!$setRe['flag']) {
+ Db::rollback();
+ return $setRe;
+ }
+ }
Db::commit();
return Util::returnArrSu();
@@ -106,9 +123,45 @@ class ReceiptOrderService
if (!empty($param['order_id'])) {
$where["order"]=$param['order_id'];
}
+ if (!empty($param['channel_id'])) {
+ $where['channel_id'] = $param['channel_id'];
+ }
+ if ($param['order_status'] != '') {
+ $where['order_status'] = $param['order_status'];
+ }
+ if (!empty($param['commissioner_id'])) {
+ $where['commissioner_id'] = $param['commissioner_id'];
+ }
+ if (!empty($param['user_name'])) {
+ $where['user_name'] = ["like","%".$param['user_name']."%"];
+ }
+ if (!empty($param['user_phone'])) {
+ $where['user_phone'] = $param['user_phone'];
+ }
+ if (!empty($param['create_id'])) {
+ $where['create_id'] = $param['create_id'];
+ }
+ //金额区间查询
+ if (!empty($param['startMoney'])&& empty($param['endMoney'])) {
+ $where['total_amount'] = [">=",$param['startMoney']];
+ }
+ if (!empty($param['endMoney']) && empty($param['startMoney'])) {
+ $where['total_amount'] = ["<=",$param['endMoney']];
+ }
+ if (!empty($param['endMoney']) && !empty($param['startMoney'])) {
+ $where['total_amount'] = ["between",[$param['startMoney'],$param['endMoney']]];
+ }
+ //时间区间查询
+ if (!empty($param['startTime']) && empty($param['endTime'])) {
+ $where['create_time'] = [">=",$param['startTime']." 00:00:00"];
+ }
+ if (!empty($param['endTime'])&& empty($param['startTime'])) {
+ $where['create_time'] = ["<=",$param['endTime']." 23:59:59"];
+ }
+ if(!empty($param['endTime'])&& !empty($param['startTime'])){
+ $where['create_time'] = ["between",[$param['startTime']." 00:00:00",$param['endTime']." 23:59:59"]];
+ }
switch ($param['inReceipt']) {
- case 0:
- break;
case 1:
$where["receipt_order_id"] = $param['receipt_order_id'];
break;
@@ -120,4 +173,29 @@ class ReceiptOrderService
}
return $orderMainDao->getOrderListByWhere($where,$param);
}
+
+ /**
+ * 删除采购单
+ * @param $id
+ * @return array
+ */
+ public function delAll($id){
+ Db::startTrans();
+ //1.删除采购单下的主订单
+ $orderMainDao = new OrderMainDao();
+ $delReceipt = $orderMainDao->delReceiptOrder($id);
+ if (!$delReceipt['flag']) {
+ Db::rollback();
+ return $delReceipt;
+ }
+ //2.删除采购单
+ $model = new ReceiptOrderDao();
+ $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/view/cf_hotel_info/index.html b/application/admin/view/cf_hotel_info/index.html
index 8794410..36a9851 100755
--- a/application/admin/view/cf_hotel_info/index.html
+++ b/application/admin/view/cf_hotel_info/index.html
@@ -1,35 +1,438 @@
-
- {:build_heading()}
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/admin/view/cf_item/edit.html b/application/admin/view/cf_item/edit.html
index b3131dc..8ce882b 100755
--- a/application/admin/view/cf_item/edit.html
+++ b/application/admin/view/cf_item/edit.html
@@ -16,7 +16,7 @@