LotteryModel.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. use Think\Model;
  16. class LotteryModel extends Model{
  17. protected $tableName ='spike_goods';
  18. public function show_lottery_page($where=' and sg.state=0' ){
  19. $sql='SELECT sg.*,g.name,g.image,pg.pin_price as pinprice,g.danprice,g.store_id,g.quantity,pg.pin_count,g.seller_count FROM
  20. '.C('DB_PREFIX').'lottery_goods as sg left join '.C('DB_PREFIX').'goods as g on sg.goods_id=g.goods_id
  21. left join '.C('DB_PREFIX').'pin_goods as pg on pg.goods_id = g.goods_id
  22. where 1=1 '.$where;
  23. $count=count(M()->query($sql));
  24. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  25. $show = $Page->show();// 分页显示输出
  26. $sql.=' order by sg.addtime desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  27. $list=M()->query($sql);
  28. foreach ($list as $key => $value) {
  29. $list[$key]['image']=resize($value['image'], 100, 100);
  30. if( !empty($value['voucher_id']) )
  31. {
  32. $voucher_info = M('voucher')->where( array('id' => $value['voucher_id']) )->find();
  33. $list[$key]['voucher_title'] = '<span class="blue">'.$voucher_info['voucher_title'].'<br/> 剩余数量: '.( $voucher_info['total_count'] - $voucher_info['send_count'] )."</span>";
  34. } else {
  35. $list[$key]['voucher_title'] = '<span class="red">未指定券</span>';
  36. }
  37. //index.html voucher_title
  38. }
  39. return array(
  40. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  41. 'list'=>$list,
  42. 'page'=>$show
  43. );
  44. }
  45. }
  46. ?>