Merge branch 'master_xieqiyu_78690'

This commit is contained in:
Yagami
2022-12-09 16:58:31 +08:00
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -1056,7 +1056,7 @@ class product extends control
$param = strtolower($param);
if(strpos($param, 'forstory') === false)
{
$plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, strpos($param, 'skipparent') !== false);
$plans = $this->loadModel('productplan')->getPairs($productID, empty($branch) ? 'all' : $branch, $expired, strpos($param, 'skipparent') !== false);
}
else
{
+15
View File
@@ -467,11 +467,25 @@ class productplanModel extends model
*/
public function getBranchPlanPairs($productID, $branches = '', $param = '', $skipParent = false)
{
$branchQuery = '';
if($branches !== '' and $branches !== 'all')
{
$branchQuery .= '(';
if(!is_array($branches)) $branches = explode(',', $branches);
foreach($branches as $branchID)
{
$branchQuery .= "CONCAT(',', branch, ',') LIKE '%,$branchID,%'";
if($branchID != end($branches)) $branchQuery .= ' OR ';
}
$branchQuery .= ')';
}
$date = date('Y-m-d');
$param = strtolower($param);
$plans = $this->dao->select('parent,branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN)
->where('product')->eq($productID)
->andWhere('deleted')->eq(0)
->beginIF(!empty($branchQuery))->andWhere($branchQuery)->fi()
->beginIF($branches != '')->andWhere('branch')->in($branches)->fi()
->beginIF(strpos($param, 'unexpired') !== false)->andWhere('end')->ge($date)->fi()
->orderBy('begin desc')
@@ -486,6 +500,7 @@ class productplanModel extends model
if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title;
$planPairs[$branch][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']';
if($branch !== BRANCH_MAIN) $planPairs[BRANCH_MAIN][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']';
}
}
return $planPairs;