From 68f5db41fb1f57b4bd93665cd5f2eb16f003d6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E6=A2=A6=E5=AE=81?= Date: Sun, 7 Nov 2021 17:06:24 +0800 Subject: [PATCH 01/35] init --- application/admin/controller/OrderMain.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index 411005c..6bf5fd7 100755 --- a/application/admin/controller/OrderMain.php +++ b/application/admin/controller/OrderMain.php @@ -272,10 +272,9 @@ class OrderMain extends Backend * 获取订单详情 * @return \think\response\Json */ - public function getShowInfo(){ - $params=$this->request->post(); + public function getShowInfo($id){ $orderMainService = new OrderMainService(); - $result = $orderMainService->getOrderInfo($params['id']); + $result = $orderMainService->getOrderInfo($id); return json($result); } From eb1c080c5eb4f8a51bc9af888050431a102d0696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E6=A2=A6=E5=AE=81?= Date: Sun, 7 Nov 2021 17:14:38 +0800 Subject: [PATCH 02/35] init --- application/admin/controller/OrderMain.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index 6bf5fd7..411005c 100755 --- a/application/admin/controller/OrderMain.php +++ b/application/admin/controller/OrderMain.php @@ -272,9 +272,10 @@ class OrderMain extends Backend * 获取订单详情 * @return \think\response\Json */ - public function getShowInfo($id){ + public function getShowInfo(){ + $params=$this->request->post(); $orderMainService = new OrderMainService(); - $result = $orderMainService->getOrderInfo($id); + $result = $orderMainService->getOrderInfo($params['id']); return json($result); } From 3c74feffa8736ccf4f013b0ed512eebeda9ed355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E6=A2=A6=E5=AE=81?= Date: Sun, 14 Nov 2021 20:00:55 +0800 Subject: [PATCH 03/35] init --- application/admin/controller/OrderMain.php | 192 ++++++++++++++++++++++++++++- public/assets/js/backend/order_main.js | 12 +- 2 files changed, 197 insertions(+), 7 deletions(-) diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index 411005c..e9cc901 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 c','order_main.create_id = c.id','left') + ->field("order_main.*,b.channel_name,c.nickname") ->where($where); if ($group_id){ $list = $list @@ -100,6 +101,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() diff --git a/public/assets/js/backend/order_main.js b/public/assets/js/backend/order_main.js index e834f3e..dd3f87d 100755 --- a/public/assets/js/backend/order_main.js +++ b/public/assets/js/backend/order_main.js @@ -21,6 +21,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin table.on('post-body.bs.table',function(){ $(".btn-editone").data("area",["100%","100%"]); }); + table.on('post-common-search.bs.table', function (event, table) { + var form = $("form", table.$commonsearch); + $("input[name='channel_name']", form).addClass("selectpage").data("source", "cf_channel_info/index").data("primaryKey", "channel_name").data("field", "channel_name").data("orderBy", "id desc"); + $("input[name='commissioner']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + $("input[name='nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + Form.events.cxselect(form); + Form.events.selectpage(form); + }); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, @@ -28,8 +36,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin sortName: 'id', columns: [ [ - {field: 'id', title: __('Id')}, - {field: 'commissioner', title: __('Commissioner'), operate: 'LIKE'}, + {field: 'id', title: __('Id'),operate:"false"}, + {field: 'commissioner', title: __('Commissioner'),formatter: Table.api.formatter.search}, {field: 'channel_name', title: __('下单渠道'), operate: 'LIKE'}, {field: 'channel_order_no', title: __('Channel_order_no'), operate: 'LIKE'}, {field: 'nickname', title: __('下单用户'), operate: 'LIKE'}, From 7b4142a6106940de29b58272ada53876b0ae4018 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Mon, 15 Nov 2021 19:33:22 +0800 Subject: [PATCH 04/35] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/AdminDao.php | 2 +- application/admin/service/ReceiptOrderService.php | 8 +- application/admin/view/payment_order/index.html | 79 +- application/admin/view/receipt_order/index.html | 274 +- public/assets/js/vue/index.js | 1 + public/assets/js/vue/vue.js | 12014 ++++++++++++++++++++ 6 files changed, 12312 insertions(+), 66 deletions(-) create mode 100644 public/assets/js/vue/index.js create mode 100644 public/assets/js/vue/vue.js diff --git a/application/admin/service/AdminDao.php b/application/admin/service/AdminDao.php index f241709..1d36372 100644 --- a/application/admin/service/AdminDao.php +++ b/application/admin/service/AdminDao.php @@ -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/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index b5edf02..cd45da8 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -22,8 +22,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(); + } /** diff --git a/application/admin/view/payment_order/index.html b/application/admin/view/payment_order/index.html index 650f395..e8070bb 100755 --- a/application/admin/view/payment_order/index.html +++ b/application/admin/view/payment_order/index.html @@ -1,35 +1,50 @@ -
- {:build_heading()} -
- + + + + + + + + +
+
+ 名称: + + 状态 + + + + + 搜索
+ + + + + + + diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index c15741d..7722efc 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -1,35 +1,245 @@ -
- {:build_heading()} - -
-
- - + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+
+ + + +
+
+ + + 未收款 + 收款中 + 已收款 + + +
+
+ 保存 +
+
+
+
+
+ + + + + + + + + diff --git a/public/assets/js/vue/index.js b/public/assets/js/vue/index.js new file mode 100644 index 0000000..a9647a4 --- /dev/null +++ b/public/assets/js/vue/index.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define("ELEMENT",["vue"],t):"object"==typeof exports?exports.ELEMENT=t(require("vue")):e.ELEMENT=t(e.Vue)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/dist/",i(i.s=49)}([function(t,i){t.exports=e},function(e,t,i){var n=i(4);e.exports=function(e,t,i){return void 0===i?n(e,t,!1):n(e,i,!1!==t)}},function(e,t,i){var n;!function(r){"use strict";var s={},a=/d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,o="[^\\s]+",l=/\[([^]*?)\]/gm,u=function(){};function c(e,t){for(var i=[],n=0,r=e.length;n3?0:(e-e%10!=10)*e%10]}};var g={D:function(e){return e.getDay()},DD:function(e){return d(e.getDay())},Do:function(e,t){return t.DoFn(e.getDate())},d:function(e){return e.getDate()},dd:function(e){return d(e.getDate())},ddd:function(e,t){return t.dayNamesShort[e.getDay()]},dddd:function(e,t){return t.dayNames[e.getDay()]},M:function(e){return e.getMonth()+1},MM:function(e){return d(e.getMonth()+1)},MMM:function(e,t){return t.monthNamesShort[e.getMonth()]},MMMM:function(e,t){return t.monthNames[e.getMonth()]},yy:function(e){return d(String(e.getFullYear()),4).substr(2)},yyyy:function(e){return d(e.getFullYear(),4)},h:function(e){return e.getHours()%12||12},hh:function(e){return d(e.getHours()%12||12)},H:function(e){return e.getHours()},HH:function(e){return d(e.getHours())},m:function(e){return e.getMinutes()},mm:function(e){return d(e.getMinutes())},s:function(e){return e.getSeconds()},ss:function(e){return d(e.getSeconds())},S:function(e){return Math.round(e.getMilliseconds()/100)},SS:function(e){return d(Math.round(e.getMilliseconds()/10),2)},SSS:function(e){return d(e.getMilliseconds(),3)},a:function(e,t){return e.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(e,t){return e.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+d(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)}},y={d:["\\d\\d?",function(e,t){e.day=t}],Do:["\\d\\d?"+o,function(e,t){e.day=parseInt(t,10)}],M:["\\d\\d?",function(e,t){e.month=t-1}],yy:["\\d\\d?",function(e,t){var i=+(""+(new Date).getFullYear()).substr(0,2);e.year=""+(t>68?i-1:i)+t}],h:["\\d\\d?",function(e,t){e.hour=t}],m:["\\d\\d?",function(e,t){e.minute=t}],s:["\\d\\d?",function(e,t){e.second=t}],yyyy:["\\d{4}",function(e,t){e.year=t}],S:["\\d",function(e,t){e.millisecond=100*t}],SS:["\\d{2}",function(e,t){e.millisecond=10*t}],SSS:["\\d{3}",function(e,t){e.millisecond=t}],D:["\\d\\d?",u],ddd:[o,u],MMM:[o,h("monthNamesShort")],MMMM:[o,h("monthNames")],a:[o,function(e,t,i){var n=t.toLowerCase();n===i.amPm[0]?e.isPm=!1:n===i.amPm[1]&&(e.isPm=!0)}],ZZ:["[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z",function(e,t){var i,n=(t+"").match(/([+-]|\d\d)/gi);n&&(i=60*n[1]+parseInt(n[2],10),e.timezoneOffset="+"===n[0]?i:-i)}]};y.dd=y.d,y.dddd=y.ddd,y.DD=y.D,y.mm=y.m,y.hh=y.H=y.HH=y.h,y.MM=y.M,y.ss=y.s,y.A=y.a,s.masks={default:"ddd MMM dd yyyy HH:mm:ss",shortDate:"M/D/yy",mediumDate:"MMM d, yyyy",longDate:"MMMM d, yyyy",fullDate:"dddd, MMMM d, yyyy",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},s.format=function(e,t,i){var n=i||s.i18n;if("number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date in fecha.format");t=s.masks[t]||t||s.masks.default;var r=[];return(t=(t=t.replace(l,function(e,t){return r.push(t),"@@@"})).replace(a,function(t){return t in g?g[t](e,n):t.slice(1,t.length-1)})).replace(/@@@/g,function(){return r.shift()})},s.parse=function(e,t,i){var n=i||s.i18n;if("string"!=typeof t)throw new Error("Invalid format in fecha.parse");if(t=s.masks[t]||t,e.length>1e3)return null;var r={},o=[],u=[];t=t.replace(l,function(e,t){return u.push(t),"@@@"});var c,h=(c=t,c.replace(/[|\\{()[^$+*?.-]/g,"\\$&")).replace(a,function(e){if(y[e]){var t=y[e];return o.push(t[1]),"("+t[0]+")"}return e});h=h.replace(/@@@/g,function(){return u.shift()});var d=e.match(new RegExp(h,"i"));if(!d)return null;for(var p=1;pe?u():!0!==t&&(r=setTimeout(n?function(){r=void 0}:u,void 0===n?e-o:e))}}},function(e,t){var i=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(e,t){var i=/^(attrs|props|on|nativeOn|class|style|hook)$/;function n(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}}e.exports=function(e){return e.reduce(function(e,t){var r,s,a,o,l;for(a in t)if(r=e[a],s=t[a],r&&i.test(a))if("class"===a&&("string"==typeof r&&(l=r,e[a]=r={},r[l]=!0),"string"==typeof s&&(l=s,t[a]=s={},s[l]=!0)),"on"===a||"nativeOn"===a||"hook"===a)for(o in s)r[o]=n(r[o],s[o]);else if(Array.isArray(r))e[a]=r.concat(s);else if(Array.isArray(s))e[a]=[r].concat(s);else for(o in s)r[o]=s[o];else e[a]=t[a];return e},{})}},function(e,t){var i={}.hasOwnProperty;e.exports=function(e,t){return i.call(e,t)}},function(e,t,i){"use strict";t.__esModule=!0;var n,r=i(56),s=(n=r)&&n.__esModule?n:{default:n};t.default=s.default||function(e){for(var t=1;t0?n:i)(e)}},function(e,t,i){var n=i(28)("keys"),r=i(21);e.exports=function(e){return n[e]||(n[e]=r(e))}},function(e,t,i){var n=i(14),r=i(5),s=r["__core-js_shared__"]||(r["__core-js_shared__"]={});(e.exports=function(e,t){return s[e]||(s[e]=void 0!==t?t:{})})("versions",[]).push({version:n.version,mode:i(20)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){e.exports={}},function(e,t,i){var n=i(10).f,r=i(7),s=i(13)("toStringTag");e.exports=function(e,t,i){e&&!r(e=i?e:e.prototype,s)&&n(e,s,{configurable:!0,value:t})}},function(e,t,i){t.f=i(13)},function(e,t,i){var n=i(5),r=i(14),s=i(20),a=i(33),o=i(10).f;e.exports=function(e){var t=r.Symbol||(r.Symbol=s?{}:n.Symbol||{});"_"==e.charAt(0)||e in t||o(t,e,{value:a.f(e)})}},function(e,t,i){var n=i(4),r=i(1);e.exports={throttle:n,debounce:r}},function(e,t,i){e.exports=!i(11)&&!i(16)(function(){return 7!=Object.defineProperty(i(37)("div"),"a",{get:function(){return 7}}).a})},function(e,t,i){var n=i(15),r=i(5).document,s=n(r)&&n(r.createElement);e.exports=function(e){return s?r.createElement(e):{}}},function(e,t,i){var n=i(7),r=i(12),s=i(62)(!1),a=i(27)("IE_PROTO");e.exports=function(e,t){var i,o=r(e),l=0,u=[];for(i in o)i!=a&&n(o,i)&&u.push(i);for(;t.length>l;)n(o,i=t[l++])&&(~s(u,i)||u.push(i));return u}},function(e,t,i){var n=i(40);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==n(e)?e.split(""):Object(e)}},function(e,t){var i={}.toString;e.exports=function(e){return i.call(e).slice(8,-1)}},function(e,t,i){var n=i(25);e.exports=function(e){return Object(n(e))}},function(e,t,i){"use strict";var n=i(20),r=i(23),s=i(43),a=i(9),o=i(31),l=i(69),u=i(32),c=i(72),h=i(13)("iterator"),d=!([].keys&&"next"in[].keys()),p=function(){return this};e.exports=function(e,t,i,f,m,v,g){l(i,t,f);var y,b,w,_=function(e){if(!d&&e in S)return S[e];switch(e){case"keys":case"values":return function(){return new i(this,e)}}return function(){return new i(this,e)}},x=t+" Iterator",C="values"==m,k=!1,S=e.prototype,D=S[h]||S["@@iterator"]||m&&S[m],$=D||_(m),E=m?C?_("entries"):$:void 0,T="Array"==t&&S.entries||D;if(T&&(w=c(T.call(new e)))!==Object.prototype&&w.next&&(u(w,x,!0),n||"function"==typeof w[h]||a(w,h,p)),C&&D&&"values"!==D.name&&(k=!0,$=function(){return D.call(this)}),n&&!g||!d&&!k&&S[h]||a(S,h,$),o[t]=$,o[x]=p,m)if(y={values:C?$:_("values"),keys:v?$:_("keys"),entries:E},g)for(b in y)b in S||s(S,b,y[b]);else r(r.P+r.F*(d||k),t,y);return y}},function(e,t,i){e.exports=i(9)},function(e,t,i){var n=i(17),r=i(70),s=i(29),a=i(27)("IE_PROTO"),o=function(){},l=function(){var e,t=i(37)("iframe"),n=s.length;for(t.style.display="none",i(71).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write(" From 56c24a3cd11452ef2890c804a238292d495d2132 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 15:46:21 +0800 Subject: [PATCH 06/35] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=8D=95=20=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/ReceiptOrder.php | 10 ++ application/admin/service/OrderMainDao.php | 18 ++++ application/admin/service/ReceiptOrderDao.php | 18 +++- application/admin/service/ReceiptOrderService.php | 53 ++++++++++- application/admin/view/receipt_order/index.html | 111 +++++++++++++++++++--- 5 files changed, 196 insertions(+), 14 deletions(-) diff --git a/application/admin/controller/ReceiptOrder.php b/application/admin/controller/ReceiptOrder.php index 9539a19..c4376ed 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/OrderMainDao.php b/application/admin/service/OrderMainDao.php index 9c7949a..d973184 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -216,4 +216,22 @@ class OrderMainDao return Util::returnArrSu("", ["total" => 0, "list" => []]); } } + + /** + * 删除采购单 + * @param $id + * @return array + */ + public function delReceiptOrder($id){ + try{ + $data = [ + "del_flag"=>1 + ]; + $model = new OrderMain(); + $model->save($data,["receipt_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/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php index 7fcef8c..cc61898 100644 --- a/application/admin/service/ReceiptOrderDao.php +++ b/application/admin/service/ReceiptOrderDao.php @@ -88,7 +88,7 @@ class ReceiptOrderDao public function getList($param) { try { - $where = []; + $where = ["a.del_flag"=>0]; if (!empty($param['name'])) { $where['a.name'] = ["like","%".$param['name']."%"]; } @@ -118,4 +118,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/service/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index a442839..6e0528d 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -121,12 +121,36 @@ class ReceiptOrderService 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; @@ -138,4 +162,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/receipt_order/index.html b/application/admin/view/receipt_order/index.html index bfccf9e..bade57c 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -47,7 +47,7 @@ 编辑 订单 - 删除 + 删除 @@ -99,7 +99,7 @@ - +
@@ -121,7 +121,7 @@ 订单ID: 订单状态: - + -
- +
- + + + + @@ -192,6 +218,9 @@ +
+ 添加到采购单 +
{ console.log(response) @@ -457,6 +501,18 @@ console.log(error); }); }, + addOrderAll(){ + let orderId = ""; + let length = this.multipleSelection.length; + for (var k = 0; k < length; k++) { + if (orderId == "") { + orderId = this.multipleSelection[k].id; + continue; + } + orderId =orderId+","+this.multipleSelection[k].id; + } + this.addOrderMain(orderId); + }, removeOrderMain(order_id){ let param = { order_id:order_id, @@ -476,6 +532,36 @@ }).catch(function (error) { console.log(error); }); + }, + delAll(id){ + let param = { + id:id + } + this.$confirm('确定删除采购单?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + axios.post("/hotel.php/receipt_order/delAll", param).then((response) => { + let data = response.data; + if (data.flag) { + this.$message({ + message: '移除成功!', + type: 'success' + }); + this.getData(this.search.pageNum) + } else { + this.$message.error(response.msg); + } + }).catch(function (error) { + console.log(error); + }); + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消' + }); + }); } } @@ -501,5 +587,8 @@ margin-top: 12px; background-color: white; } + .el-form-item{ + margin-bottom: 5px !important; + } From 53cd15226295187322812b697b65d0e829523cdc Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 15:50:33 +0800 Subject: [PATCH 07/35] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/receipt_order/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index bade57c..2a1f28a 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -219,7 +219,7 @@
- 添加到采购单 + 添加到采购单
Date: Tue, 16 Nov 2021 15:56:29 +0800 Subject: [PATCH 08/35] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AD=90=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/OrderMain.php | 2 ++ application/admin/service/OrderMainService.php | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index e9cc901..de36dcc 100755 --- a/application/admin/controller/OrderMain.php +++ b/application/admin/controller/OrderMain.php @@ -428,6 +428,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/service/OrderMainService.php b/application/admin/service/OrderMainService.php index bd05cd7..0d5bafa 100644 --- a/application/admin/service/OrderMainService.php +++ b/application/admin/service/OrderMainService.php @@ -135,20 +135,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 +184,7 @@ class OrderMainService if (!$setOrderMainRe['flag']) { return $setOrderMainRe; } - return Util::returnArrSu("",$subOrderId); + return Util::returnArrSu("保存成功",$subOrderId); } /** From b9a94ba99cf13d8ffa7dddbf42520f0efd2f1774 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 16:00:13 +0800 Subject: [PATCH 09/35] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/receipt_order/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index 2a1f28a..17dbc4d 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -445,6 +445,7 @@ } else { this.$message.error(response.msg); } + this.getData(this.search.pageNum) }).catch(function (error) { this.$message.error("保存失败"); console.log(error); From 802e3f7b9473de35dca4a2731d71a7369b098e96 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 16:03:47 +0800 Subject: [PATCH 10/35] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/OrderMainDao.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php index d973184..69fc8c3 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -225,7 +225,9 @@ class OrderMainDao public function delReceiptOrder($id){ try{ $data = [ - "del_flag"=>1 + "receipt_order_id"=>0, + "receipt_order_status"=>0, + "receipt_order_name"=>"" ]; $model = new OrderMain(); $model->save($data,["receipt_order_id"=>$id]); From 4bb1a5effe3a5810b7cbd20aa0d39ec86378e7f7 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 16:05:25 +0800 Subject: [PATCH 11/35] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/receipt_order/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index 17dbc4d..f794113 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -495,6 +495,7 @@ type: 'success' }); this.getOrderMainData(this.orderMainListSearch.pageNum) + this.getData(this.search.pageNum) } else { this.$message.error(response.msg); } @@ -527,6 +528,7 @@ type: 'success' }); this.getOrderMainData(this.orderMainListSearch.pageNum) + this.getData(this.search.pageNum) } else { this.$message.error(response.msg); } From c7689373e6fc302e42ad3d958e38e633e9df70ff Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 16 Nov 2021 16:07:53 +0800 Subject: [PATCH 12/35] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/receipt_order/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index f794113..b81649c 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -445,17 +445,19 @@ } else { this.$message.error(response.msg); } - this.getData(this.search.pageNum) }).catch(function (error) { this.$message.error("保存失败"); console.log(error); }); }).catch(() => { + this.$message({ type: 'info', message: '已取消' }); - }); + }).finally(()=>{ + this.getData(this.search.pageNum) + }) }, editOrderDivShow(info){ From 6058149328243fb6e2a23f48e309e9bdad05fa34 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Wed, 17 Nov 2021 10:42:25 +0800 Subject: [PATCH 13/35] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/ReceiptOrderDao.php | 32 +++++++++++++++++++++++++ application/admin/view/receipt_order/index.html | 22 +++++++++-------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php index cc61898..ed1721e 100644 --- a/application/admin/service/ReceiptOrderDao.php +++ b/application/admin/service/ReceiptOrderDao.php @@ -42,12 +42,18 @@ class ReceiptOrderDao */ 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'] ]; + if (isset($param['status'])) { + $data['status'] = $param['status']; + } $receiptOrder = new ReceiptOrder(); if (empty($param['id'])) { $id = $receiptOrder->insertGetId($data); @@ -62,6 +68,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 diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index b81649c..9286cf6 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -197,7 +197,7 @@ - + @@ -211,8 +211,8 @@ @@ -274,7 +274,6 @@ editType: false, editData: {}, editOrderShow:false, - editOrderOld:{}, editOrder:{}, orderMainListSearch:{ "receipt_order_id":"", @@ -321,6 +320,9 @@ }, methods: { checkSelect(row,index){ + if (this.editOrder.status != 0) { + return false; + } if (row.receipt_order_id ==0) { return true; } @@ -422,7 +424,7 @@ this.editShow = false; this.getData(1); } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { this.$message.error("保存失败"); @@ -443,7 +445,7 @@ type: 'success' }); } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { this.$message.error("保存失败"); @@ -478,7 +480,7 @@ this.orderMainTotal = data.data.total; console.log(this.orderMainList); } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { console.log(error); @@ -499,7 +501,7 @@ this.getOrderMainData(this.orderMainListSearch.pageNum) this.getData(this.search.pageNum) } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { console.log(error); @@ -532,7 +534,7 @@ this.getOrderMainData(this.orderMainListSearch.pageNum) this.getData(this.search.pageNum) } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { console.log(error); @@ -556,7 +558,7 @@ }); this.getData(this.search.pageNum) } else { - this.$message.error(response.msg); + this.$message.error(data.msg); } }).catch(function (error) { console.log(error); From 6025788eb3277c151a3358d654a849be50c63129 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Wed, 17 Nov 2021 17:20:52 +0800 Subject: [PATCH 14/35] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/OrderMainService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/admin/service/OrderMainService.php b/application/admin/service/OrderMainService.php index 0d5bafa..f4d03c0 100644 --- a/application/admin/service/OrderMainService.php +++ b/application/admin/service/OrderMainService.php @@ -35,6 +35,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 +112,7 @@ class OrderMainService if (!$setOrderMainRe['flag']) { return $setOrderMainRe; } - return Util::returnArrSu("",$orderId); + return Util::returnArrSu("成功",$orderId); } /** @@ -213,7 +216,7 @@ class OrderMainService //重新计算订单总金额 $orderMainDao = new OrderMainDao(); $orderMainDao->setOrderAmount($subOrderRe['data']['order_id']); - return Util::returnArrSu(); + return Util::returnArrSu("成功"); }catch (Exception $e){ return Util::returnArrEr("删除子订单失败:".$e->getMessage()); } @@ -265,6 +268,6 @@ class OrderMainService return $subOrderList; } $orderMain["subOrderList"]=$subOrderList['data']; - return Util::returnArrSu("",$orderMain); + return Util::returnArrSu("成功",$orderMain); } } \ No newline at end of file From 521c503605614665dff21f238f3247bb01b8d973 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Wed, 17 Nov 2021 17:52:40 +0800 Subject: [PATCH 15/35] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/PaymentOrder.php | 81 ++++++++++- application/admin/controller/ReceiptOrder.php | 2 +- application/admin/service/OrderHotelDao.php | 59 ++++++++ application/admin/service/OrderItemDao.php | 58 ++++++++ application/admin/service/PaymentOrderDao.php | 166 ++++++++++++++++++++++ application/admin/service/PaymentOrderService.php | 74 ++++++++++ application/admin/service/ReceiptOrderDao.php | 2 +- 7 files changed, 439 insertions(+), 3 deletions(-) create mode 100644 application/admin/service/PaymentOrderDao.php create mode 100644 application/admin/service/PaymentOrderService.php diff --git a/application/admin/controller/PaymentOrder.php b/application/admin/controller/PaymentOrder.php index c27b4b7..9deaad2 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->addOrderMain($params['id'],$params['order_id']); + return json($result); + } + + /** + * 移除收购单 + * @return \think\response\Json + */ + public function removeOrderMain(){ + $params=$this->request->post(); + $service = new PaymentOrderService(); + $result = $service->removeOrderMain($params['order_id']); + return json($result); + } + + + /** + * 获取订单列表 + * @return \think\response\Json + */ + public function getOrderMainList(){ + $params=$this->request->post(); + $service = new PaymentOrderService(); + $result = $service->getOrderMainList($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 c4376ed..9a15af4 100755 --- a/application/admin/controller/ReceiptOrder.php +++ b/application/admin/controller/ReceiptOrder.php @@ -257,7 +257,7 @@ class ReceiptOrder extends Backend } /** - * 删除采购单 + * 删除收款单 */ public function delAll(){ $params=$this->request->post(); diff --git a/application/admin/service/OrderHotelDao.php b/application/admin/service/OrderHotelDao.php index 5c156ec..0221fd9 100644 --- a/application/admin/service/OrderHotelDao.php +++ b/application/admin/service/OrderHotelDao.php @@ -218,4 +218,63 @@ 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 addOrderMainInPayment($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 removeOrderMainFormPayment($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()); + } + } } \ No newline at end of file diff --git a/application/admin/service/OrderItemDao.php b/application/admin/service/OrderItemDao.php index 7f65182..3437384 100644 --- a/application/admin/service/OrderItemDao.php +++ b/application/admin/service/OrderItemDao.php @@ -169,4 +169,62 @@ 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 addOrderMainInPayment($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 removeOrderMainFormPayment($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()); + } + } } \ No newline at end of file diff --git a/application/admin/service/PaymentOrderDao.php b/application/admin/service/PaymentOrderDao.php new file mode 100644 index 0000000..c7289e0 --- /dev/null +++ b/application/admin/service/PaymentOrderDao.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'] + ]; + if (isset($param['status'])) { + $data['status'] = $param['status']; + } + $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") + ->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") + ->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 PaymentOrder(); + $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/PaymentOrderService.php b/application/admin/service/PaymentOrderService.php new file mode 100644 index 0000000..b846036 --- /dev/null +++ b/application/admin/service/PaymentOrderService.php @@ -0,0 +1,74 @@ +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; + } + Db::commit(); + return Util::returnArrSu(); + } +} \ No newline at end of file diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php index ed1721e..c37c8ac 100644 --- a/application/admin/service/ReceiptOrderDao.php +++ b/application/admin/service/ReceiptOrderDao.php @@ -139,7 +139,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']) From 9612d21e2e35666f9fe2e3ed5a6fdb53e6f42777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E6=A2=A6=E5=AE=81?= Date: Wed, 17 Nov 2021 22:51:29 +0800 Subject: [PATCH 16/35] init --- .idea/workspace.xml | 269 ++++++++++++++-------------- application/admin/controller/CfItem.php | 4 +- application/admin/controller/CfRoomInfo.php | 2 +- application/admin/controller/CfRoomPlan.php | 8 +- application/admin/lang/zh-cn/cf_item.php | 2 +- application/admin/lang/zh-cn/order_item.php | 2 +- application/admin/view/cf_item/edit.html | 2 +- public/assets/js/backend/cf_hotel_info.js | 2 +- public/assets/js/backend/cf_item.js | 17 +- public/assets/js/backend/cf_room_info.js | 5 +- public/assets/js/backend/cf_room_plan.js | 14 +- 11 files changed, 169 insertions(+), 158 deletions(-) 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 @@ - + - - - - - - - + + + + + + + + + + - + + + + @@ -83,21 +89,30 @@ + - - - - - - - + + + +
diff --git a/public/assets/js/backend/cf_hotel_info.js b/public/assets/js/backend/cf_hotel_info.js index ca9e0d3..cd87e93 100755 --- a/public/assets/js/backend/cf_hotel_info.js +++ b/public/assets/js/backend/cf_hotel_info.js @@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin sortName: 'id', columns: [ [ - {checkbox: true}, + {field: 'id', title: __('Id')}, {field: 'hotel_name', title: __('Hotel_name'), operate: 'LIKE'}, {field: 'hotel_phone', title: __('Hotel_phone'), operate: 'LIKE'}, {field: 'nickname', title: __('创建人')}, diff --git a/public/assets/js/backend/cf_item.js b/public/assets/js/backend/cf_item.js index a13db1f..7f552dd 100755 --- a/public/assets/js/backend/cf_item.js +++ b/public/assets/js/backend/cf_item.js @@ -16,7 +16,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }); var table = $("#table"); - + table.on('post-common-search.bs.table', function (event, table) { + var form = $("form", table.$commonsearch); + $("input[name='nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + Form.events.cxselect(form); + Form.events.selectpage(form); + }); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, @@ -25,15 +30,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {field: 'id', title: __('Id')}, - {field: 'item_type_name', title: __('Item_type')}, + {field: 'item_type', title: __('Item_type'), + searchList: {"1":"一日游","2":"交通接驳","3":"租车","4":"门票"}}, {field: 'item_name', title: __('Item_name'), operate: 'LIKE'}, - {field: 'item_unit', title: __('计价单位'), operate: 'LIKE'}, - {field: 'item_memo', title: __('Item_memo'), operate: 'LIKE'}, + {field: 'item_unit', title: __('计价单位'), + searchList: {"1":"件","2":"份","3":"匝","4":"张"}}, + {field: 'item_memo', title: __('Item_memo'), operate: 'LIKE',visible: false}, {field: 'province_name', title: __('Province_name'), operate: 'LIKE'}, {field: 'city_name', title: __('City_name'), operate: 'LIKE'}, {field: 'area_name', title: __('地区名'), operate: 'LIKE'}, {field: 'detail_address', title: __('Detail_address'), operate: 'LIKE'}, - {field: 'purchase_user_name', title: __('采购负责人'), operate: 'LIKE'}, + {field: 'nickname', title: __('采购负责人')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} diff --git a/public/assets/js/backend/cf_room_info.js b/public/assets/js/backend/cf_room_info.js index a27e989..b6e84e9 100755 --- a/public/assets/js/backend/cf_room_info.js +++ b/public/assets/js/backend/cf_room_info.js @@ -24,9 +24,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin sortName: 'id', columns: [ [ - {checkbox: true}, - {field: 'hotel_name', title: __('酒店名称')}, + {field: 'hotel_id', title: __('酒店ID')}, + {field: 'hotel_name', title: __('酒店名称'),operate: 'LIKE'}, {field: 'nickname', title: __('创建人')}, + {field: 'id', title: __('房型ID')}, {field: 'room_name', title: __('Room_name'), operate: 'LIKE'}, {field: 'room_memo', title: __('Room_memo'), operate: 'LIKE'}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, diff --git a/public/assets/js/backend/cf_room_plan.js b/public/assets/js/backend/cf_room_plan.js index 3bb8d1c..a9dc7de 100755 --- a/public/assets/js/backend/cf_room_plan.js +++ b/public/assets/js/backend/cf_room_plan.js @@ -16,7 +16,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }); var table = $("#table"); - + table.on('post-common-search.bs.table', function (event, table) { + var form = $("form", table.$commonsearch); + $("input[name='d.nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + Form.events.cxselect(form); + Form.events.selectpage(form); + }); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, @@ -25,15 +30,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {field: 'id', title: __('Id')}, + {field: 'hotel_id', title: __('酒店ID')}, {field: 'hotel_name', title: __('酒店')}, + {field: 'room_id', title: __('房型ID')}, {field: 'room_name', title: __('房型')}, {field: 'plan_name', title: __('Plan_name'), operate: 'LIKE'}, {field: 'breakfast_num', title: __('Breakfast_num')}, {field: 'book_end_day', title: __('Book_end_day')}, {field: 'book_end_hour', title: __('Book_end_hour')}, - {field: 'continuity_type', title: __('Continuity_type')}, + {field: 'continuity_type', title: __('Continuity_type'), + searchList: {"0": __('无限制'), "1": __('连住几晚'),"2": __('连住几晚及以上'),"3": __('连住几晚及其倍数')}}, {field: 'coutinuity_day', title: __('Coutinuity_day')}, - {field: 'purchase_user_name', title: __('Charge_person'), operate: 'LIKE'}, + {field: 'd.nickname', title: __('采购负责人')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} From 23623cf79a28c19fabc5d45a7ac550ec6c594b13 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Thu, 18 Nov 2021 17:17:00 +0800 Subject: [PATCH 17/35] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/PaymentOrder.php | 8 +- application/admin/service/OrderHotelDao.php | 24 +- application/admin/service/OrderItemDao.php | 24 +- application/admin/service/OrderMainDao.php | 14 +- application/admin/service/PaymentOrderDao.php | 82 ++- application/admin/service/PaymentOrderService.php | 160 +++++ application/admin/service/PurchaseDao.php | 2 +- application/admin/view/payment_order/index.html | 684 +++++++++++++++++++++- application/admin/view/receipt_order/index.html | 2 +- 9 files changed, 954 insertions(+), 46 deletions(-) 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"> - 收购单状态 + 收款单状态 Date: Thu, 18 Nov 2021 17:23:18 +0800 Subject: [PATCH 18/35] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/payment_order/index.html | 3 ++- application/admin/view/receipt_order/index.html | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/application/admin/view/payment_order/index.html b/application/admin/view/payment_order/index.html index af64bee..1f3b791 100755 --- a/application/admin/view/payment_order/index.html +++ b/application/admin/view/payment_order/index.html @@ -512,10 +512,12 @@ }); } else { this.$message.error(data.msg); + this.getData(this.search.pageNum) } }).catch(function (error) { this.$message.error("保存失败"); console.log(error); + this.getData(this.search.pageNum) }); }).catch(() => { @@ -523,7 +525,6 @@ type: 'info', message: '已取消' }); - }).finally(()=>{ this.getData(this.search.pageNum) }) diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index 559abaa..6534f8d 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -446,10 +446,13 @@ }); } else { this.$message.error(data.msg); + this.getData(this.search.pageNum) } + }).catch(function (error) { this.$message.error("保存失败"); console.log(error); + this.getData(this.search.pageNum) }); }).catch(() => { @@ -457,7 +460,6 @@ type: 'info', message: '已取消' }); - }).finally(()=>{ this.getData(this.search.pageNum) }) From f7cd5d023414d56032ad4d07ba880c96574f34a4 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Thu, 18 Nov 2021 17:40:25 +0800 Subject: [PATCH 19/35] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/payment_order/index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/admin/view/payment_order/index.html b/application/admin/view/payment_order/index.html index 1f3b791..89df186 100755 --- a/application/admin/view/payment_order/index.html +++ b/application/admin/view/payment_order/index.html @@ -129,7 +129,7 @@
- + 未付款 付款中 已付款 diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html index 43f0e5f..4f39d02 100755 --- a/application/admin/view/receipt_order/index.html +++ b/application/admin/view/receipt_order/index.html @@ -82,7 +82,7 @@
- + 未收款 收款中 已收款 From d7b94f90b6037b718b98c28dca8c436ceb691337 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Fri, 19 Nov 2021 17:02:24 +0800 Subject: [PATCH 25/35] =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/service/OrderMainDao.php | 31 ++++++++++++++++++++--- application/admin/service/PaymentOrderService.php | 6 ++++- application/admin/service/ReceiptOrderService.php | 11 +++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php index e3d8dc4..f572934 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -101,8 +101,11 @@ class OrderMainDao $statusList['isPayment']++; } } - $orderInfo = $this->getInfoById($orderId); - $orderStatus = $this->getStatus($cnt,$statusList,$orderInfo); + $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]); @@ -122,7 +125,6 @@ class OrderMainDao 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; @@ -293,4 +295,27 @@ class OrderMainDao 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/PaymentOrderService.php b/application/admin/service/PaymentOrderService.php index d03e226..dc68b4d 100644 --- a/application/admin/service/PaymentOrderService.php +++ b/application/admin/service/PaymentOrderService.php @@ -74,7 +74,11 @@ class PaymentOrderService $orderMainIds = array_unique(array_merge($hotelIds,$itemIds)); $orderMainDao = new OrderMainDao(); foreach ($orderMainIds as $orderId) { - $orderMainDao->setOrderAmount($orderId); + $setRe = $orderMainDao->setOrderAmount($orderId); + if (!$setRe['flag']) { + Db::rollback(); + return $setRe; + } } Db::commit(); return Util::returnArrSu(); diff --git a/application/admin/service/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index 5bbe79c..9a84cf7 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -64,10 +64,15 @@ class ReceiptOrderService Db::rollback(); return $orderRe; } + //3.设置订单状态 - $setRe = $orderDao->setOrderAmount($id); - if (!$setRe['flag']) { - return $setRe; + $orderIds = $orderDao->getOrderMainIdsByReceipt($id); + foreach ($orderIds as $orderId) { + $setRe = $orderDao->setOrderAmount($orderId); + if (!$setRe['flag']) { + Db::rollback(); + return $setRe; + } } Db::commit(); return Util::returnArrSu(); From cd80bb24a6a9de417569565a11abfc09f0778833 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Fri, 19 Nov 2021 17:26:18 +0800 Subject: [PATCH 26/35] 1 --- application/admin/service/PaymentOrderDao.php | 2 +- application/admin/service/ReceiptOrderDao.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/admin/service/PaymentOrderDao.php b/application/admin/service/PaymentOrderDao.php index bcf51aa..8666f68 100644 --- a/application/admin/service/PaymentOrderDao.php +++ b/application/admin/service/PaymentOrderDao.php @@ -120,7 +120,7 @@ class PaymentOrderDao 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']; diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php index 1417a3d..ccb1884 100644 --- a/application/admin/service/ReceiptOrderDao.php +++ b/application/admin/service/ReceiptOrderDao.php @@ -121,7 +121,7 @@ class ReceiptOrderDao 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']; From 62577c3554c2c89077d61c5b55eeadd20db63687 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Mon, 22 Nov 2021 17:32:27 +0800 Subject: [PATCH 27/35] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BD=8D=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 { From a1c34419562b9db36c0b390fcb96a10488152a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=84=E6=A2=A6=E5=AE=81?= Date: Mon, 22 Nov 2021 22:52:58 +0800 Subject: [PATCH 28/35] init --- application/admin/controller/CfRoomPlan.php | 8 ++++---- application/admin/controller/OrderMain.php | 5 +++-- public/assets/js/backend/cf_room_plan.js | 4 ++-- public/assets/js/backend/order_main.js | 5 +++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/application/admin/controller/CfRoomPlan.php b/application/admin/controller/CfRoomPlan.php index e83011a..ff9800e 100755 --- a/application/admin/controller/CfRoomPlan.php +++ b/application/admin/controller/CfRoomPlan.php @@ -84,11 +84,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,e.room_name,f.hotel_name") + ->field("a.*,hbp_admin.nickname,e.room_name,f.hotel_name") ->where($where); if ($group_id){ $list = $list @@ -103,7 +102,8 @@ class CfRoomPlan extends Backend $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); } diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index de36dcc..3a83436 100755 --- a/application/admin/controller/OrderMain.php +++ b/application/admin/controller/OrderMain.php @@ -59,8 +59,8 @@ class OrderMain extends Backend $list = $this->model ->alias("order_main") ->join('hbp_cf_channel_info b','order_main.channel_id = b.id','left') - ->join('hbp_admin c','order_main.create_id = c.id','left') - ->field("order_main.*,b.channel_name,c.nickname") + ->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 @@ -91,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); diff --git a/public/assets/js/backend/cf_room_plan.js b/public/assets/js/backend/cf_room_plan.js index a9dc7de..f6999e2 100755 --- a/public/assets/js/backend/cf_room_plan.js +++ b/public/assets/js/backend/cf_room_plan.js @@ -18,7 +18,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin var table = $("#table"); table.on('post-common-search.bs.table', function (event, table) { var form = $("form", table.$commonsearch); - $("input[name='d.nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + $("input[name='hbp_admin.nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); Form.events.cxselect(form); Form.events.selectpage(form); }); @@ -41,7 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'continuity_type', title: __('Continuity_type'), searchList: {"0": __('无限制'), "1": __('连住几晚'),"2": __('连住几晚及以上'),"3": __('连住几晚及其倍数')}}, {field: 'coutinuity_day', title: __('Coutinuity_day')}, - {field: 'd.nickname', title: __('采购负责人')}, + {field: 'hbp_admin.nickname', title: __('采购负责人')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} diff --git a/public/assets/js/backend/order_main.js b/public/assets/js/backend/order_main.js index dd3f87d..cbd5aac 100755 --- a/public/assets/js/backend/order_main.js +++ b/public/assets/js/backend/order_main.js @@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin var form = $("form", table.$commonsearch); $("input[name='channel_name']", form).addClass("selectpage").data("source", "cf_channel_info/index").data("primaryKey", "channel_name").data("field", "channel_name").data("orderBy", "id desc"); $("input[name='commissioner']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); - $("input[name='nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); + $("input[name='hbp_admin.nickname']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "nickname").data("field", "nickname").data("orderBy", "id desc"); Form.events.cxselect(form); Form.events.selectpage(form); }); @@ -40,7 +40,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'commissioner', title: __('Commissioner'),formatter: Table.api.formatter.search}, {field: 'channel_name', title: __('下单渠道'), operate: 'LIKE'}, {field: 'channel_order_no', title: __('Channel_order_no'), operate: 'LIKE'}, - {field: 'nickname', title: __('下单用户'), operate: 'LIKE'}, + {field: 'hbp_admin.nickname', title: __('订单提交人'), operate: 'LIKE'}, + {field: 'user_name', title: __('订单联系人'), operate: 'LIKE'}, {field: 'user_phone', title: __('User_phone'), operate: 'LIKE'}, {field: 'total_amount', title: __('Total_amount'), operate:'BETWEEN'}, {field: 'cost_amount', title: __('Cost_amount'), operate:'BETWEEN'}, From 17887c6a345ed04bd3dcc9b6103bcc7a08ed28d5 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 23 Nov 2021 15:52:26 +0800 Subject: [PATCH 29/35] =?UTF-8?q?=E9=85=92=E5=BA=97=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 21 + application/admin/controller/CfHotelInfo.php | 187 ++------- application/admin/dao/CfHotelInfoDao.php | 103 +++++ application/admin/service/CfHotelInfoService.php | 45 +++ application/admin/view/cf_hotel_info/index.html | 467 +++++++++++++++++++++-- 5 files changed, 632 insertions(+), 191 deletions(-) create mode 100644 application/admin/dao/CfHotelInfoDao.php create mode 100644 application/admin/service/CfHotelInfoService.php 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..0e145fc 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,17 +16,17 @@ use think\exception\ValidateException; */ class CfHotelInfo extends Backend { - + /** - * CfHotelInfo模型对象 - * @var \app\admin\model\CfHotelInfo + * PaymentOrder模型对象 + * @var \app\admin\model\PaymentOrder */ protected $model = null; public function _initialize() { parent::_initialize(); - $this->model = new \app\admin\model\CfHotelInfo; + $this->model = new \app\admin\model\PaymentOrder; } @@ -40,170 +41,38 @@ 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'); - $result= $this->model->getList($name,$keyValue); - if($keyValue){ - return json(['list' => $result]); - } - return json(['list' => $result]); + /****=========================================**/ + /** + * 获取列表 + * @return \think\response\Json + */ + public function getList(){ + $params=$this->request->post(); + $service = new CfHotelInfoService(); + return json($service->getList($params)); } /** - * 添加 + * 保存记录 + * @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 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/dao/CfHotelInfoDao.php b/application/admin/dao/CfHotelInfoDao.php new file mode 100644 index 0000000..bf8bf0c --- /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'] + ]; + $receiptOrder = new CfHotelInfo(); + if (empty($param['id'])) { + $data['create_id'] = $param['create_id']; + $data['group_id'] = $param['group_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 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 { + //设置收购单状态 + $receiptOrder = new CfHotelInfo(); + $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/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/view/cf_hotel_info/index.html b/application/admin/view/cf_hotel_info/index.html index 8794410..ba07060 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()} - -
-
- - + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+
+ + + +
+
+ + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + +
+
+ 保存 +
+
+
+
+ + + + + + + + + From 6f7807a8cf7796826cdd5854ec4ea761905d66fa Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 23 Nov 2021 15:53:36 +0800 Subject: [PATCH 30/35] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/cf_hotel_info/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/view/cf_hotel_info/index.html b/application/admin/view/cf_hotel_info/index.html index ba07060..558477b 100755 --- a/application/admin/view/cf_hotel_info/index.html +++ b/application/admin/view/cf_hotel_info/index.html @@ -11,7 +11,7 @@