0
0

ShopDay.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  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($this->orgId);
  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($cate_id,$this->orgId);
  26. HelpHander::success($ret);
  27. }
  28. // 获取类型
  29. public function types(){
  30. $day = input('day','','trim');
  31. if(!$day){
  32. $this->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. }