| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /**
- *
- * @author: xaboy<365615158@qq.com>
- * @day: 2017/11/02
- */
- namespace app\models\auction;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * 竞拍上坪 Model
- * Class WechatNews
- * @package app\admin\model\wechat
- */
- class AuctionProduct extends BaseModel
- {
- use ModelTrait;
- protected $pk = 'id';
- protected $name = 'auction_product';
- protected $autoWriteTimestamp = true;
- /**
- * 竞拍商品列表
- * @param $data
- * @param $uid
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function list($data, $uid){
- $model = self::where('is_show', 1)->where('auction_id', $data['id'])->order('sort DESC,id DESC');
- $model->page($data['page'], $data['limit']);
- $list = $model->select()->toArray();
- if ($list){
- foreach ($list as $k => $v) {
- $order = AuctionOrder::where('product_id', $v['id'])->where('status', '>', 0)->whereBetweenTime('create_time', date('Y-m-d H:i:s', strtotime(date('Y-m-d'))), date('Y-m-d H:i:s', strtotime('+1 day')))->find();
- if ($order){
- $list[$k]['status'] = 2;// 已被购买
- $list[$k]['str'] = '已卖完';
- }else{
- $list[$k]['status'] = 1;// 能购买
- $list[$k]['str'] = '购买';
- }
- }
- }
- return $list;
- }
- /**
- * 用户商品
- * @param $data
- * @param $uid
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function user_product($data, $uid){
- $model = self::where('is_show', 1)->where('uid', $uid)->order('sort DESC,id DESC');
- $model->page($data['page'], $data['limit']);
- $list = $model->select()->toArray();
- return $list;
- }
- }
|