|
|
@ -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; |
|
|
|