|
@@ -36,70 +36,16 @@ class AuctionProduct extends BaseModel
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
public static function list($data, $uid){
|
|
|
- $model = self::where('is_show', 1)->where('auction_id', $data['id'])->order('id DESC');
|
|
|
+ $model = self::where('auction_id', $data['id'])->order('succeed_time ASC,is_show DESC,id DESC');
|
|
|
+ $model = $model->page($data['page'], $data['limit']);
|
|
|
if ($data['name']) $model->where('name', 'like', '%'.$data['name'].'%');
|
|
|
$list = $model->select();
|
|
|
$list = empty($list)? [] : $list->toArray();
|
|
|
- $lists = [];
|
|
|
- $auction = Auction::where('id', $data['id'])->find();
|
|
|
- if ($list){
|
|
|
- foreach ($list as $k => $v) {
|
|
|
- $order = AuctionOrder::where('product_id', $v['id'])->where('status', '>', 0)->where('frequency', $auction['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', '=', $auction['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];
|
|
|
- }
|
|
|
- }
|
|
|
- $productId = AuctionProduct::where('auction_id', $data['id'])->column('id');
|
|
|
- $orderList = AuctionOrder::alias('a')
|
|
|
- ->field('p.*')
|
|
|
- ->leftJoin('auction_product p', 'a.product_id = p.id')
|
|
|
- ->where([['a.product_id', 'in', $productId], ['a.frequency', '=', $auction['frequency']], ['a.status', '=', 3]])
|
|
|
- ->select();
|
|
|
- }else{
|
|
|
- $productId = AuctionProduct::where('auction_id', $data['id'])->column('id');
|
|
|
- $orderList = AuctionOrder::alias('a')
|
|
|
- ->field('p.*')
|
|
|
- ->leftJoin('auction_product p', 'a.product_id = p.id')
|
|
|
- ->where([['a.product_id', 'in', $productId], ['a.frequency', '=', $auction['frequency']], ['a.status', '=', 3]])
|
|
|
- ->select();
|
|
|
+ foreach ($list as &$item){
|
|
|
+ $item['status'] = 1;
|
|
|
+ if ($item['succeed_time'] == strtotime('today') || $item['is_show'] == 0) $item['status'] = 2;
|
|
|
}
|
|
|
-
|
|
|
- $a = [];
|
|
|
- $b = [];
|
|
|
- foreach ($lists as $k => $v){
|
|
|
- if ($v['status'] == 1){
|
|
|
- $a[] = $v;
|
|
|
- }
|
|
|
- if ($v['status'] == 2) $b[] = $v;
|
|
|
- }
|
|
|
- foreach ($b as $k => $v){
|
|
|
- array_push($a, $v);
|
|
|
- }
|
|
|
- if (isset($orderList) and !empty($orderList)){
|
|
|
- $orderList = count($orderList) == 0? [] : $orderList->toArray();
|
|
|
- foreach ($orderList as $v){
|
|
|
- $v['status'] = 2;
|
|
|
- $v['str'] = '已卖完';
|
|
|
- array_push($a, $v);
|
|
|
- }
|
|
|
- }
|
|
|
- $data['page'] = ($data['page'] - 1)*$data['limit'];
|
|
|
- $List = array_slice($a, $data['page'], $data['limit']);
|
|
|
- return $List;
|
|
|
+ return $list;
|
|
|
}
|
|
|
|
|
|
|