ShopDay.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\api\controller\h5;
  3. use app\hander\HelpHander;
  4. use think\App;
  5. use think\Controller;
  6. use think\Db;
  7. class ShopDay extends Base
  8. {
  9. public function __construct(App $app = null) {
  10. parent::__construct($app);
  11. $this->model = new \app\common\model\ShopDay();
  12. }
  13. public function date(){
  14. $ret = $this->model->shopDate();
  15. HelpHander::success($ret);
  16. }
  17. public function cate(){
  18. $type = input('type/d',0);
  19. $ret = $this->model->cate_old($type,3);
  20. HelpHander::success($ret);
  21. }
  22. public function goods(){
  23. $type = input('type/d',0);
  24. $cate_id = input('cate_id/d',0);
  25. $ret = $this->model->goods_old($type,$cate_id,3);
  26. HelpHander::success($ret);
  27. }
  28. // 获取类型
  29. public function types(){
  30. $day = input('day/s','','trim');
  31. if(!$day){
  32. HelpHander::error('参数错误');
  33. }
  34. $lists = Db::name('shop_day')
  35. ->where('org_id',$this->orgId)
  36. ->where('day',$day)
  37. ->field('id,cate')
  38. ->order('cate asc')
  39. ->select();
  40. $lists = $lists?$lists:[];
  41. foreach ($lists as $k=>$v){
  42. if($v['cate'] == 1){
  43. $lists[$k]['name'] = "早餐";
  44. }else if($v['cate'] == 2){
  45. $lists[$k]['name'] = "午餐";
  46. }else if($v['cate'] == 3){
  47. $lists[$k]['name'] = "晚餐";
  48. }else if($v['cate'] == 4){
  49. $lists[$k]['name'] = "当日餐";
  50. }
  51. }
  52. HelpHander::success($lists);
  53. }
  54. }