|
@@ -414,5 +414,54 @@ class AuctionOrder extends BaseModel
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static function auction_time()
|
|
|
+ {
|
|
|
+ $auction = Auction::where('status', 1)->select();
|
|
|
+ if ($auction){
|
|
|
+ foreach ($auction as $item){
|
|
|
+ $addtime = strtotime($item['radd_time']);
|
|
|
+ $rendtime = strtotime($item['rend_time']);
|
|
|
+ if (($addtime-360) < time() and $addtime > time()){
|
|
|
+ $model = AuctionProduct::where('is_show', 1)->where('auction_id', $item['id'])->order('id DESC');
|
|
|
+ $list = $model->select();
|
|
|
+ $list = empty($list)? [] : $list->toArray();
|
|
|
+ $lists = [];
|
|
|
+ if ($list){
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $order = AuctionOrder::where('product_id', $v['id'])->where('status', '>', 0)->where('frequency', $item['frequency'])->find();
|
|
|
+ if ($order){
|
|
|
+ $list[$k]['status'] = 2;
|
|
|
+ $list[$k]['str'] = '已卖完';
|
|
|
+ }else{
|
|
|
+ $list[$k]['status'] = 1;
|
|
|
+ $list[$k]['str'] = '购买';
|
|
|
+ }
|
|
|
+ if ($v['is_admin'] == 2){
|
|
|
+ $time = AuctionTime::where([['auction_id', '=', $item['id']], ['product_id', '=', $v['id']], ['add_time', '=', strtotime(date('Y-m-d', time()))]])->find();
|
|
|
+ if (!$time){
|
|
|
+ unset($list[$k]);
|
|
|
+ } else{
|
|
|
+ $lists[] = $list[$k];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $lists[] = $list[$k];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $redis = new \Redis();
|
|
|
+ $redis->connect('127.0.0.1','6379', 3600);
|
|
|
+ foreach ($lists as $k => $v) {
|
|
|
+ if ($v['status'] == 1) {
|
|
|
+ if (!$redis->llen($v['id']) > 0) {
|
|
|
+ $redis->lPush($v['id'], json_encode($v));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|