You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB
PHP

<?php
namespace Base\Service;
use Base\Facade\Request;
class PaymentRuleService {
public function getRulesByIds(array $ids = null, $fields = '*')
{
$map = [];
if (is_null($ids)) {
$map['_string'] = '1=1';
} elseif (count($ids) == 0) {
return [];
} else {
$map['id'] = ['in', $ids];
}
$rules = M('payment_rule', 'tab_')->field($fields)->where($map)->select();
return index_by_column('id', $rules);
}
public function getEffectiveTimeDisplay($rule)
{
$startTime = $rule['start_time'] == 0 ? null : date('Y-m-d', $rule['start_time']);
$endTime = $rule['end_time'] == 0 ? null : date('Y-m-d', $rule['end_time']);
if ($startTime == null && $endTime == null) {
return '永久';
}
if ($startTime != null && $endTime != null) {
return $startTime . ' 至 ' . $endTime;
}
if ($startTime == null && $endTime != null) {
return '从前 至 ' . $endTime;
}
if ($startTime != null && $endTime == null) {
return $startTime . ' 至 永久';
}
}
}