@ -11,6 +11,7 @@ class mCase extends mBase {
private $case_herb_tbl;
private $case_herb_tbl;
private $herb_tbl;
private $herb_tbl;
private $collect_log_tbl;
private $collect_log_tbl;
private $case_use_log_tbl;
public function __construct() {
public function __construct() {
$this->obj = new dCase();
$this->obj = new dCase();
@ -18,6 +19,7 @@ class mCase extends mBase {
$this->case_herb_tbl = 'tcm_case_herb';
$this->case_herb_tbl = 'tcm_case_herb';
$this->herb_tbl = 'tcm_herb';
$this->herb_tbl = 'tcm_herb';
$this->collect_log_tbl = 'tcm_collect_log';
$this->collect_log_tbl = 'tcm_collect_log';
$this->case_use_log_tbl = 'tcm_case_use_log';
}
}
public function createCase($name, $source, $original, $method, $herbs) {
public function createCase($name, $source, $original, $method, $herbs) {
@ -172,18 +174,10 @@ class mCase extends mBase {
return $this->obj->selectAll($this->case_herb_tbl, array('sql' => '`case_id`=?', 'vals' => array($case_id)), 'sort asc ');
return $this->obj->selectAll($this->case_herb_tbl, array('sql' => '`case_id`=?', 'vals' => array($case_id)), 'sort asc ');
}
}
public function getCaseByName($name, $page_num, $page_size) {
public function getCaseByName($uid, $name, $page_num, $page_size) {
$where = array();
if(!empty($name)) {
$sql = " `name` like '%{$name}%'";
$where = array('sql' => $sql, 'vals' => array());
}
$offset = ($page_num - 1) * $page_size;
$offset = ($page_num - 1) * $page_size;
$res = $this->obj->selectAll($this->tbl, $where, 'use_num desc,sort asc ', array($offset, $page_size));
$sql = "select c.id,c.name,c.source,c.original,c.method,u.use_num,c.sort from {$this->tbl} as c left join {$this->case_use_log_tbl} as u on c.id=u.case_id and u.uid={$uid} where c.`name` like '%{$name}%' order by u.use_num desc,c.sort desc limit {$offset},{$page_size}";
return $this->obj->execute($sql, true, true);
if (empty($res)) return array();
return $res;
}
}
public function getCaseByNameTotal($name) {
public function getCaseByNameTotal($name) {
@ -238,11 +232,11 @@ class mCase extends mBase {
return $this->obj->selectIn($this->tbl, array('id' => $ids));
return $this->obj->selectIn($this->tbl, array('id' => $ids));
}
}
public function updateCaseSearchNum($ id) {
public function updateCaseUseLog($uid, $case_ id) {
$res = $this->obj->increase($this->tbl, array('sql' => '`id`=?', 'vals' => array($id)), 'use_num');
$res = $this->obj->increase($this->case_use_log_ tbl, array('sql' => '`uid`=? and `case_ id`=?', 'vals' => array($uid, $case_ id)), 'use_num');
if (!$res) {
if (!$res) {
$tool_obj = new qTool();
$tool_obj = new qTool();
$tool_obj->trackLog('tcm', $id, sprintf(LOG_TRACK_SAVE_PATH, date('Y-m-d'), 'tcm_case_use_num'));
$tool_obj->trackLog('tcm', $uid . "|" . $case_ id, sprintf(LOG_TRACK_SAVE_PATH, date('Y-m-d'), 'tcm_case_use_num'));
$this->setError('药方使用次数更新失败');
$this->setError('药方使用次数更新失败');
return false;
return false;