Beispiel #1
0
 function _get_data()
 {
     $cache_server =& cache_server();
     $key = $this->_get_cache_id();
     $data = $cache_server->get($key);
     if ($data === false) {
         $model_groupbuy =& m('groupbuy');
         $data = $model_groupbuy->find(array('join' => 'belong_goods', 'conditions' => $model_groupbuy->getRealFields('this.recommended=1 AND this.state=' . GROUP_ON . ' AND this.end_time>' . gmtime()), 'fields' => 'group_id, goods.default_image, group_name, end_time, spec_price', 'order' => 'group_id DESC', 'limit' => $_num));
         if ($data) {
             foreach ($data as $gb_id => $gb_info) {
                 $price = current(unserialize($gb_info['spec_price']));
                 empty($gb_info['default_image']) && ($data[$gb_id]['default_image'] = Conf::get('default_goods_image'));
                 $data[$gb_id]['lefttime'] = lefttime($gb_info['end_time']);
                 $data[$gb_id]['price'] = $price['price'];
             }
         }
         $cache_server->set($key, $data, $this->_ttl);
     }
     return $data;
 }
 public function api_collect($date, $p)
 {
     $this->_mod->where(array('id' => $date['id']))->save(array('last_page' => $p, 'last_time' => time()));
     if (false === ($totalcoll = F('totalcoll'))) {
         $totalcoll = 0;
     }
     if (false === ($robots_time = F('robots_time'))) {
         $robots_time = time();
         F('robots_time', time());
     }
     $map['keyword'] = $date['keyword'];
     //关键词
     $map['cid'] = $date['cid'];
     //api分类ID
     $map['cate_id'] = $date['cate_id'];
     //入库分类ID
     if ($date['start_commissionRate'] < 100) {
         $map['start_commissionRate'] = $date['start_commissionRate'] * 100;
         //佣金比率下限
     } else {
         $map['start_commissionRate'] = $date['start_commissionRate'];
         //佣金比率下限
     }
     if ($date['end_commissionRate'] < 100) {
         $map['end_commissionRate'] = $date['end_commissionRate'] * 100;
         //佣金比率上限
     } else {
         $map['end_commissionRate'] = $date['end_commissionRate'];
         //佣金比率上限
     }
     $map['start_price'] = $date['start_price'];
     //价格下限
     $map['end_price'] = $date['end_price'];
     //价格上限
     $map['shop_type'] = $date['shop_type'];
     //是否天猫商品
     $map['recid'] = $date['recid'];
     //是否更新分类
     $map['sort'] = $date['sort'];
     //排序方法
     $result = $this->_get_list($map, $p);
     $taobaoke_item_list = $result['item_list'];
     $totalnum = $result['count'];
     $coll = 0;
     $thiscount = 0;
     if (is_array($taobaoke_item_list)) {
         $msg = '成功!';
     } else {
         $msg = '失败!';
     }
     foreach ($taobaoke_item_list as $key => $val) {
         /*入库操作START*/
         $coupon_add_time = C('ftx_coupon_add_time');
         if ($coupon_add_time) {
             $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + $coupon_add_time * 3600);
         } else {
             $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + 72 * 86400);
         }
         $val['coupon_start_time'] = strtotime(date("Y-m-d H:00:00", time()));
         $val['coupon_end_time'] = $times;
         $val['astime'] = date("Ymd");
         $val['recid'] = $map['recid'];
         $res = $this->_ajax_ftx_publish_insert($val);
         if ($res > 0) {
             $coll++;
             $totalcoll++;
         }
         /*入库操作END*/
         $thiscount++;
     }
     F('totalcoll', $totalcoll);
     $result_data['p'] = $p;
     $result_data['msg'] = $msg;
     $result_data['coll'] = $coll;
     $result_data['totalcoll'] = $totalcoll;
     $result_data['totalnum'] = $totalnum;
     $result_data['thiscount'] = $thiscount;
     $result_data['times'] = lefttime(time() - $robots_time);
     return $result_data;
 }
Beispiel #3
0
 function _get_new_groupbuy($id, $num = 12)
 {
     $model_groupbuy =& m('groupbuy');
     $groupbuy_list = $model_groupbuy->find(array('fields' => 'goods.default_image, this.group_name, this.group_id, this.spec_price, this.end_time', 'join' => 'belong_goods', 'conditions' => $model_groupbuy->getRealFields('this.state=' . GROUP_ON . ' AND this.store_id=' . $id . ' AND end_time>' . gmtime()), 'order' => 'group_id DESC', 'limit' => $num));
     if (empty($groupbuy_list)) {
         $groupbuy_list = array();
     }
     foreach ($groupbuy_list as $key => $_g) {
         empty($groupbuy_list[$key]['default_image']) && ($groupbuy_list[$key]['default_image'] = Conf::get('default_goods_image'));
         $tmp = current(unserialize($_g['spec_price']));
         $groupbuy_list[$key]['price'] = $tmp['price'];
         $groupbuy_list[$key]['lefttime'] = lefttime($_g['end_time']);
     }
     return $groupbuy_list;
 }
Beispiel #4
0
 public function api_collect($date, $p)
 {
     if (false === ($uz_totalcoll = F('uz_totalcoll'))) {
         $uz_totalcoll = 0;
     }
     if (false === ($uz_collect_time = F('uz_collect_time'))) {
         $uz_collect_time = time();
         F('uz_collect_time', time());
     }
     $map['uid'] = $date['uzhan_id'];
     //关键词
     $map['uzhanCate'] = $date['uzhanCate'];
     //api分类ID
     $map['cate_id'] = $date['cate_id'];
     //入库分类ID
     $map['shop_type'] = $date['shop_type'];
     $result = $this->_get_list($map, $p);
     $taobaoke_item_list = $result['item_list'];
     $totalnum = $result['count'];
     $taobaoke_item_list && F('taobaoke_item_list', $taobaoke_item_list);
     $coll = 0;
     $thiscount = 4;
     if (is_array($taobaoke_item_list)) {
         $msg = '成功!';
     } else {
         $msg = '失败!';
     }
     foreach ($taobaoke_item_list as $key => $val) {
         if ($map['shop_type'] == 'B') {
             if ($map['shop_type'] == $val['shop_type']) {
                 /*入库操作START*/
                 $coupon_add_time = C('ftx_coupon_add_time');
                 if ($coupon_add_time) {
                     $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + $coupon_add_time * 3600);
                 } else {
                     $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + 168 * 86400);
                 }
                 if (!$val['coupon_end_time']) {
                     $val['coupon_end_time'] = $times;
                 }
                 $val['recid'] = 0;
                 $res = $this->_ajax_ftx_publish_insert($val);
                 if ($res > 0) {
                     $coll++;
                     $uz_totalcoll++;
                 }
                 /*入库操作END*/
             }
         } else {
             /*入库操作START*/
             $coupon_add_time = C('ftx_coupon_add_time');
             if ($coupon_add_time) {
                 $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + $coupon_add_time * 3600);
             } else {
                 $times = (int) (strtotime(date("Y-m-d H:00:00", time())) + 168 * 86400);
             }
             if (!$val['coupon_end_time']) {
                 $val['coupon_end_time'] = $times;
             }
             $val['recid'] = 0;
             $res = $this->_ajax_ftx_publish_insert($val);
             if ($res > 0) {
                 $coll++;
                 $uz_totalcoll++;
             }
             /*入库操作END*/
         }
         $thiscount++;
     }
     F('uz_totalcoll', $uz_totalcoll);
     $result_data['p'] = $p;
     $result_data['msg'] = $msg;
     $result_data['coll'] = $coll;
     $result_data['totalcoll'] = $uz_totalcoll;
     $result_data['totalnum'] = $totalnum;
     $result_data['thiscount'] = $thiscount;
     $result_data['times'] = lefttime(time() - $uz_collect_time);
     return $result_data;
 }
 public function api_collect($date, $p)
 {
     M('robots')->where(array('id' => $date['id']))->save(array('last_page' => $p, 'last_time' => time()));
     if (false === ($totalcoll = F('totalcoll'))) {
         $totalcoll = 0;
     }
     if (false === ($robots_time = F('robots_time'))) {
         $robots_time = time();
         F('robots_time', time());
     }
     $map['keyword'] = $date['keyword'];
     //关键词
     $map['cid'] = $date['cid'];
     //api分类ID
     $map['cate_id'] = $date['cate_id'];
     //入库分类ID
     if ($date['start_commissionRate'] < 100) {
         $map['start_commissionRate'] = $date['start_commissionRate'] * 100;
         //佣金比率下限
     } else {
         $map['start_commissionRate'] = $date['start_commissionRate'];
         //佣金比率下限
     }
     if ($date['end_commissionRate'] < 100) {
         $map['end_commissionRate'] = $date['end_commissionRate'] * 100;
         //佣金比率上限
     } else {
         $map['end_commissionRate'] = $date['end_commissionRate'];
         //佣金比率上限
     }
     if ($date['start_coupon_rate'] < 100) {
         $map['start_coupon_rate'] = $date['start_coupon_rate'] * 100;
         //折扣最低比率
     } else {
         $map['start_coupon_rate'] = $date['start_coupon_rate'];
         //折扣最低比率
     }
     if ($date['end_coupon_rate'] < 100) {
         $map['end_coupon_rate'] = $date['end_coupon_rate'] * 100;
         //折扣最高比率
     } else {
         $map['end_coupon_rate'] = $date['end_coupon_rate'];
         //折扣最高比率
     }
     $map['start_volume'] = $date['start_volume'];
     //销量下限
     $map['end_volume'] = $date['end_volume'];
     //销量上限
     $map['start_price'] = $date['start_price'];
     //价格下限
     $map['end_price'] = $date['end_price'];
     //价格上限
     $map['start_credit'] = $date['start_credit'];
     //卖家信用下限
     $map['end_credit'] = $date['end_credit'];
     //卖家信用上限
     $map['shop_type'] = $date['shop_type'];
     //是否天猫商品
     $map['recid'] = $date['recid'];
     //是否更新分类
     if ($date['sort']) {
         $sorts = explode("|", $date['sort']);
         $map['sort'] = $sorts[0] . '_' . $sorts[1];
         //排序方法
     }
     $result = $this->_get_list($map, $p);
     $taobaoke_item_list = $result['item_list'];
     $totalnum = $result['count'];
     $taobaoke_item_list && F('taobaoke_item_list', $taobaoke_item_list);
     $coll = 0;
     $thiscount = 4;
     if (is_array($taobaoke_item_list)) {
         $msg = '成功!';
     } else {
         $msg = '失败!';
     }
     foreach ($taobaoke_item_list as $key => $val) {
         if ($map['start_volume'] <= $val['volume'] && $val['volume'] <= $map['end_volume'] && $map['start_price'] <= $val['coupon_price'] && $val['coupon_price'] <= $map['end_price'] && $map['start_coupon_rate'] <= $val['coupon_rate'] && $val['coupon_rate'] <= $map['end_coupon_rate']) {
             if ($map['shop_type'] == 'B') {
                 if ($map['shop_type'] == $val['shop_type']) {
                     /*入库操作START*/
                     $coupon_add_time = C('ftx_coupon_add_time');
                     if ($coupon_add_time) {
                         $times = (int) (time() + $coupon_add_time * 3600);
                     } else {
                         $times = (int) (time() + 72 * 86400);
                     }
                     $val['coupon_start_time'] = time();
                     $val['coupon_end_time'] = $times;
                     $val['recid'] = $map['recid'];
                     $res = $this->_ajax_ftx_publish_insert($val);
                     if ($res > 0) {
                         $coll++;
                         $totalcoll++;
                     }
                     /*入库操作END*/
                 }
             } else {
                 /*入库操作START*/
                 $coupon_add_time = C('ftx_coupon_add_time');
                 if ($coupon_add_time) {
                     $times = (int) (time() + $coupon_add_time * 3600);
                 } else {
                     $times = (int) (time() + 72 * 86400);
                 }
                 $val['coupon_start_time'] = time();
                 $val['coupon_end_time'] = $times;
                 $val['recid'] = $map['recid'];
                 $res = $this->_ajax_ftx_publish_insert($val);
                 if ($res > 0) {
                     $coll++;
                     $totalcoll++;
                 }
                 /*入库操作END*/
             }
         }
         $thiscount++;
     }
     F('totalcoll', $totalcoll);
     $result_data['p'] = $p;
     $result_data['msg'] = $msg;
     $result_data['coll'] = $coll;
     $result_data['totalcoll'] = $totalcoll;
     $result_data['totalnum'] = $totalnum;
     $result_data['thiscount'] = $thiscount;
     $result_data['times'] = lefttime(time() - $robots_time);
     return $result_data;
 }
Beispiel #6
0
 function _recommended_groupbuy($_num)
 {
     $model_groupbuy =& m('groupbuy');
     $data = $model_groupbuy->find(array('join' => 'belong_goods', 'conditions' => 'gb.recommended=1 AND gb.state=' . GROUP_ON . ' AND gb.end_time>' . gmtime(), 'fields' => 'group_id, goods.default_image, group_name, end_time, spec_price', 'order' => 'group_id DESC', 'limit' => $_num));
     foreach ($data as $gb_id => $gb_info) {
         $price = current(unserialize($gb_info['spec_price']));
         empty($gb_info['default_image']) && ($data[$gb_id]['default_image'] = Conf::get('default_goods_image'));
         $data[$gb_id]['lefttime'] = lefttime($gb_info['end_time']);
         $data[$gb_id]['price'] = $price['price'];
     }
     return $data;
 }
 function _get_state_desc($state, $end_time)
 {
     $lefttime = lefttime($end_time);
     $desc = array(GROUP_ON => Lang::get('desc_on') . ' ' . $lefttime, GROUP_END => Lang::get('desc_end'), GROUP_FINISHED => Lang::get('desc_finished'), GROUP_CANCELED => Lang::get('desc_cancel'));
     return $desc[$state];
 }