|
@@ -8,6 +8,35 @@
|
|
|
|
|
|
namespace activity;
|
|
namespace activity;
|
|
|
|
|
|
|
|
+class full_item
|
|
|
|
+{
|
|
|
|
+ private $mStart;
|
|
|
|
+ private $mEnd;
|
|
|
|
+ private $mName;
|
|
|
|
+ private $mRules;
|
|
|
|
+
|
|
|
|
+ public function __construct($start,$end,$name)
|
|
|
|
+ {
|
|
|
|
+ $this->mStart = $start;
|
|
|
|
+ $this->mEnd = $end;
|
|
|
|
+ $this->mName = $name;
|
|
|
|
+
|
|
|
|
+ $this->mRules = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function add_rule($title)
|
|
|
|
+ {
|
|
|
|
+ $this->mRules[] = $title;
|
|
|
|
+ }
|
|
|
|
+ public function is_runing()
|
|
|
|
+ {
|
|
|
|
+ $cur = time();
|
|
|
|
+ return ($cur >= $this->mStart && $cur < $this->mEnd);
|
|
|
|
+ }
|
|
|
|
+ public function rules() {
|
|
|
|
+ return $this->mRules;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
class full_sent
|
|
class full_sent
|
|
{
|
|
{
|
|
@@ -18,7 +47,8 @@ class full_sent
|
|
|
|
|
|
static private $stInstance = null;
|
|
static private $stInstance = null;
|
|
private $verchecker;
|
|
private $verchecker;
|
|
- private $contents;
|
|
|
|
|
|
+ private $mItem;
|
|
|
|
+ private $mFreePrice;
|
|
|
|
|
|
private function __construct()
|
|
private function __construct()
|
|
{
|
|
{
|
|
@@ -37,45 +67,94 @@ class full_sent
|
|
return self::$stInstance;
|
|
return self::$stInstance;
|
|
}
|
|
}
|
|
|
|
|
|
- public function contents()
|
|
|
|
|
|
+ public function rules()
|
|
{
|
|
{
|
|
- $contents = array();
|
|
|
|
- $cur = time();
|
|
|
|
- foreach ($this->contents as $item) {
|
|
|
|
- $start = intval($item['start_time']);
|
|
|
|
- $end = intval($item['end_time']);
|
|
|
|
- if($cur >= $start && $cur < $end) {
|
|
|
|
- array_push($contents,$item);
|
|
|
|
- }
|
|
|
|
|
|
+ if($this->mItem->is_runing()) {
|
|
|
|
+ return $this->mItem->rules();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return array();
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- return $contents;
|
|
|
|
|
|
+ public function free_price()
|
|
|
|
+ {
|
|
|
|
+ if($this->mFreePrice > 0) {
|
|
|
|
+ $val = $this->mFreePrice / 100;
|
|
|
|
+ return "满{$val}包邮";
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private function init()
|
|
private function init()
|
|
{
|
|
{
|
|
|
|
+ $store_list = Model('store')->getStoreOnlineList(array('store_id' => 6),null,'','store_free_price');
|
|
|
|
+ if(empty($store_list)) {
|
|
|
|
+ $this->mFreePrice = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $this->mFreePrice = intval($store_list[0]['store_free_price'] * 100 + 0.5);
|
|
|
|
+ }
|
|
|
|
+
|
|
$mod = Model('p_mansong');
|
|
$mod = Model('p_mansong');
|
|
- $condition = array();
|
|
|
|
- $condition['store_id'] = self::STORE_ID;
|
|
|
|
- $condition['state'] = array('in', array(self::MANSONG_STATE_NORMAL));
|
|
|
|
-
|
|
|
|
- $list = $mod->getMansongList($condition);
|
|
|
|
- $this->contents = array();
|
|
|
|
- foreach ($list as $val) {
|
|
|
|
- array_push($this->contents,$this->filter($val));
|
|
|
|
|
|
+ $value = $mod->getMansongInfoByStoreID(self::STORE_ID);
|
|
|
|
+ if(empty($value)) {
|
|
|
|
+ $this->mItem = null;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ $start = intval($value['start_time']);
|
|
|
|
+ $end = intval($value['end_time']);
|
|
|
|
+ $name = $value['mansong_name'];
|
|
|
|
+
|
|
|
|
+ $this->mItem = new full_item($start,$end,$name);
|
|
|
|
+
|
|
|
|
+ $rules = $value['rules'];
|
|
|
|
+ foreach ($rules as $rule)
|
|
|
|
+ {
|
|
|
|
+ $val = $this->filter($rule);
|
|
|
|
+ if($val != false) {
|
|
|
|
+ $this->mItem->add_rule($val);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function filter($info)
|
|
|
|
|
|
+ private function filter($rule)
|
|
{
|
|
{
|
|
- if(!empty($info)) {
|
|
|
|
- unset($$info['quota_id']);
|
|
|
|
- unset($$info['member_id']);
|
|
|
|
- unset($$info['store_id']);
|
|
|
|
- unset($$info['member_name']);
|
|
|
|
- unset($$info['store_name']);
|
|
|
|
- unset($$info['state']);
|
|
|
|
|
|
+ $discount = floatval($rule['discount']) * 100 + 0.5;
|
|
|
|
+ $discount = intval($discount);
|
|
|
|
+
|
|
|
|
+ if($discount > 0) {
|
|
|
|
+ $discount = $discount / 100;
|
|
|
|
+ $desc = "减 {$discount}";
|
|
|
|
+ } else {
|
|
|
|
+ $desc = "";
|
|
}
|
|
}
|
|
- return $info;
|
|
|
|
|
|
+
|
|
|
|
+ $goods_id = intval($rule['goods_id']);
|
|
|
|
+ if($goods_id > 0) {
|
|
|
|
+ $goods_name = $rule['mansong_goods_name'];
|
|
|
|
+ $name = "赠 {$goods_name}";
|
|
|
|
+ } else {
|
|
|
|
+ $name = '';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($desc) && empty($name)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $price = $rule['price'];
|
|
|
|
+ if(empty($desc)) {
|
|
|
|
+ $title = "满 {$price} {$name}";
|
|
|
|
+ }
|
|
|
|
+ elseif(empty($name)) {
|
|
|
|
+ $title = "满 {$price} {$desc}";
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $title = "满 {$price} {$desc}#{$name}";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $title;
|
|
}
|
|
}
|
|
}
|
|
}
|