diff --git a/config/define.php b/config/define.php index a76fbe5..0075789 100644 --- a/config/define.php +++ b/config/define.php @@ -14,8 +14,8 @@ define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/tcm/'); define('LOG_TRACK_SAVE_PATH', LOG_PATH_BASE.'track/%s/%s.log'); // 监控日志的路径,如2014-02-14/1(检测类型).log - define('TCM_DOMAIN', 'http://tcm.pengda.checkcopy.com'); - define('CSS_URL', '//tcm.pengda.checkcopy.com'); + define('TCM_DOMAIN', 'https://yian.kuailebangshou.cn'); + define('CSS_URL', '//yian.kuailebangshou.cn'); // 小程序获取openid define('MP_APPID',"wx7b28b3159197282d"); // 公众号APPID diff --git a/control/index.php b/control/index.php index c529cc9..feeea9a 100644 --- a/control/index.php +++ b/control/index.php @@ -50,6 +50,7 @@ class index extends publicBase { $this->view['uid'] = $_COOKIE['uid']; $this->view['token'] = $_COOKIE['token']; + $status = $this->get('status') + 0; $is_all = $this->get('is_all') + 0; $name = trim($this->get('name')); @@ -63,6 +64,14 @@ class index extends publicBase { $condition['uid'] = 0; } + if ($status == 0) { + $condition['is_delete'] = array(0, 2); + } elseif ($status == 1) { + $condition['is_delete'] = 2; + } elseif ($status == 2) { + $condition['is_delete'] = 0; + } + $mformula = new mFormula(); $total = $mformula->getFormulaTotal($condition); @@ -126,9 +135,10 @@ class index extends publicBase { $uinfo = $this->_check_login(); $id = $this->post('id') + 0; + $is_delete = $this->post('is_delete') + 0; $mformula = new mFormula(); - $id = $mformula->deleteFormula($uinfo['uid'], $id); + $id = $mformula->deleteFormula($uinfo['uid'], $id, $is_delete); if (!$id) $this->ajax_json(false, $mformula->getError()); $this->ajax_json(true, '请求成功'); @@ -145,6 +155,7 @@ class index extends publicBase { $condition = array(); $condition['uid'] = $uinfo['uid']; + $condition['is_delete'] = 0; if ($content) $condition['name'] = $content; $mformula = new mFormula(); @@ -186,6 +197,7 @@ class index extends publicBase { $condition = array(); $condition['uid'] = array(0, $uinfo['uid']); + $condition['is_delete'] = 0; if ($content) $condition['name'] = $content; $mformula = new mFormula(); diff --git a/model/mFormula.php b/model/mFormula.php index ca1d8ad..0fba1ba 100644 --- a/model/mFormula.php +++ b/model/mFormula.php @@ -25,7 +25,7 @@ class mFormula extends mBase { public function getFormulaByCondition($condition, $page_num, $page_size) { $offset = ($page_num - 1) * $page_size; - $where = "is_delete=0"; + $where = "1=1"; $use_limit = ""; if (!empty($condition)) { foreach ($condition as $key => $val) { @@ -33,11 +33,13 @@ class mFormula extends mBase { $where .= " and s.{$key} like '%{$val}%'"; } elseif ($key == 'uid' && is_array($val)) { $val = implode(',', $val); - $where .= " and s.{$key} in ({$val})"; //兼容查药方只计算当前用户对药方的使用次数 $use_limit .= " and u.uid in ({$val})"; + } elseif ($key == 'is_delete' && is_array($val)) { + $val = implode(',', $val); + $where .= " and {$key} in ({$val})"; } else { $where .= " and s.{$key}={$val}"; } @@ -76,14 +78,16 @@ class mFormula extends mBase { } public function getFormulaTotal($condition) { - $where = "is_delete=0"; + $where = "1=1"; if (!empty($condition)) { foreach ($condition as $key => $val) { if ($key == 'name') { $where .= " and {$key} like '%{$val}%'"; } elseif ($key == 'uid' && is_array($val)) { $val = implode(',', $val); - + $where .= " and {$key} in ({$val})"; + } elseif ($key == 'is_delete' && is_array($val)) { + $val = implode(',', $val); $where .= " and {$key} in ({$val})"; } else { $where .= " and {$key}={$val}"; @@ -407,6 +411,7 @@ class mFormula extends mBase { //更新原方和用法 $data['original'] = json_encode($org_herb, JSON_UNESCAPED_UNICODE); $data['method'] = $method; + $data['is_delete'] = 2; } //格式化药方对应的药材数据 @@ -455,7 +460,7 @@ class mFormula extends mBase { return $id; } - public function deleteFormula($uid, $id) { + public function deleteFormula($uid, $id, $is_delete) { $formula = $this->getFormulaById($id); if (empty($formula)) { $this->setError('抱歉,未找到匹配的药方'); @@ -466,7 +471,7 @@ class mFormula extends mBase { return false; } - $res = $this->updateFormula($id, array('is_delete' => 1)); + $res = $this->updateFormula($id, array('is_delete' => $is_delete)); if (!$res) { $this->setError('删除药方失败'); return false; diff --git a/view/templates/index/formula_add.html b/view/templates/index/formula_add.html index 0e65183..24be6ec 100644 --- a/view/templates/index/formula_add.html +++ b/view/templates/index/formula_add.html @@ -46,7 +46,7 @@