| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?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']);
- if ($data['name']) $model->where('name', 'like', '%'.$data['name'].'%');
- $list = $model->select();
- $list = empty($list)? [] : $list->toArray();
- if ($list){
- foreach ($list as $k => $v) {
- $auction = Auction::where('id', $v['auction_id'])->find();
- $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'] = '购买';
- }
- }
- }
- 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();
- $list = empty($list)? [] : $list->toArray();
- foreach ($list as $k => $v)
- {
- $auction = Auction::where('id', $v['auction_id'])->find();
- if (strtotime(date('Y-m-d',strtotime($v['update_time']))) < strtotime(date('Y-m-d'))){
- $list[$k]['g_time'] = date('Y-m-d H:i:s', strtotime($auction['radd_time']));
- }else{
- $list[$k]['g_time'] = date('Y-m-d', strtotime('+1 day')).' '.$auction['radd_time'];
- }
- }
- return $list;
- }
- }
|