package com.ruoyi.app.user;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.app.mendian.PosStoreEnrichService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.PosStoreMapper;
import com.ruoyi.system.mapper.PosFoodMapper;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

import com.ruoyi.system.mapper.PosOrderMapper;
import com.ruoyi.app.user.dto.StoreOutput;

/**
 * 用户美食首页
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/user/index")
public class UserAppIndexController extends BaseController {

    @Autowired
    private IPosTypeService posTypeService;
    @Autowired
    private IPosFoodService posFoodService;
    @Autowired
    private IPosOrderService posOrderService;
    @Autowired
    private PosOrderMapper posOrderMapper;
    @Autowired
    private IFoodStatisticsService foodStatisticsService;

    @Autowired
    private PosStoreMapper posStoreMapper;
    @Autowired
    private PosFoodMapper posFoodMapper;
    @Autowired
    private IInfoUserService infoUserService;
    @Autowired
    private PosStoreEnrichService posStoreEnrichService;

    /**
     * 获取门店分页列表
     */
    @Anonymous
    @GetMapping("/getStoreList")
    public AjaxResult getFoodStoreList(@RequestParam String language,
                                       @RequestParam BigDecimal longitude,
                                        @RequestParam BigDecimal latitude,
                                        @RequestParam Integer page,
                                        @RequestParam(defaultValue = "0") Long flId) {
        List<PosStore> storeList = posStoreMapper.getjxStore(longitude,latitude,(page-1)*10,flId);
        posStoreEnrichService.enrichStoreList(storeList);
        int count = posStoreMapper.getjxStoreCount(longitude,latitude,flId);
        Page<StoreOutput> result = posStoreEnrichService.buildStoreOutputPage(storeList, language, page, count);
        return success(result);
    }




}
