Box.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\admin\controller\box;
  3. use app\admin\model\SystemAdmin;
  4. use app\common\model\BoxModel;
  5. use app\common\model\BoxRecordModel;
  6. use app\common\model\CouponAreaModel;
  7. use app\common\model\CouponPlanModel;
  8. use app\common\model\ShopCategory;
  9. use app\admin\traits\Curd;
  10. use app\common\controller\AdminController;
  11. use app\common\model\ThirddataLogModel;
  12. use app\common\model\ThirddataModel;
  13. use EasyAdmin\annotation\ControllerAnnotation;
  14. use EasyAdmin\annotation\NodeAnotation;
  15. use think\App;
  16. use think\facade\Db;
  17. use think\Model;
  18. /**
  19. * Class Admin
  20. * @package app\admin\controller\system
  21. * @ControllerAnnotation(title="魔盒")
  22. */
  23. class Box extends AdminController
  24. {
  25. public function __construct(App $app)
  26. {
  27. parent::__construct($app);
  28. $this->model = new BoxModel();
  29. }
  30. use Curd;
  31. // protected $allowModifyFields = [
  32. // 'can_buy',
  33. // 'status'
  34. // ];
  35. /**
  36. * @NodeAnotation(title="福袋列表")
  37. */
  38. public function index ()
  39. {
  40. if ($this->request->isAjax()) {
  41. if (input('selectFields')) {
  42. return $this->selectList();
  43. }
  44. list($page, $limit, $where) = $this->buildTableParames();
  45. $count = $this->model
  46. ->where($where)
  47. ->count();
  48. // return 11;
  49. // return json_decode('[{"price":10, "fee":1},{"price":50, "fee":0.5},{"price":100, "fee":0}]');
  50. $list = $this->model
  51. ->withoutField('password')
  52. // ->withAttr('buy_time', function ($val, $data){
  53. // if (!$val){return '还未配置时间';}
  54. // $curdata = json_decode($val);
  55. // $cu_data['day'] = sr_getcurtime($curdata->day, 'Y-m-d');
  56. //
  57. // $arr_time = $curdata->time;
  58. // for ($i = 0; $i < count($arr_time); $i++){
  59. // $val1 = $curdata->time[$i];
  60. // $key = 'time'.($i+1);
  61. // $cu_data[$key] = (sr_getcurtime($val1->start_time, 'H:i:s') . ' - ' . sr_getcurtime($val1->end_time, 'H:i:s'));
  62. // }
  63. //
  64. // return ($cu_data['day']. '日'. ($cu_data['time1']?('【'.$cu_data['time1'].'】'):'' ). '|'. (isset($cu_data['time2'])?('【'.$cu_data['time2'].'】'):''). '|' .(isset($cu_data['time3'])?('【'.$cu_data['time3'].'】'):''));
  65. // })
  66. ->withAttr('box_img', function($val, $data){
  67. return getWebUrl().'/'.$val;
  68. })
  69. ->where($where)
  70. ->page($page, $limit)
  71. ->order($this->sort)
  72. ->select();
  73. $data = [
  74. 'code' => 0,
  75. 'msg' => '',
  76. 'count' => $count,
  77. 'data' => $list,
  78. ];
  79. return json($data);
  80. }
  81. return $this->fetch();
  82. }
  83. }