package com.bohuikeji.delivery.backstage.controller.api.rental;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bohuikeji.delivery.backstage.entity.TConfig;
import com.bohuikeji.delivery.backstage.entity.TCustomer;
import com.bohuikeji.delivery.backstage.entity.rental.TRentalCarOrder;
import com.bohuikeji.delivery.backstage.entity.rental.TRentalConfig;
import com.bohuikeji.delivery.backstage.service.ITCustomerService;
import com.bohuikeji.delivery.backstage.service.ITRentalCarOrderService;
import com.bohuikeji.delivery.backstage.service.ITRentalConfigService;
import com.bohuikeji.delivery.backstage.service.ITRentalPayService;
import com.bohuikeji.frame.module.admin.base.ApiController;
import com.bohuikeji.frame.module.admin.component.RedisUtil;
import com.bohuikeji.frame.module.admin.entity.TFranchiseeInformation;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.bohuikeji.frame.module.admin.entity.sys.SysConfig;
import com.bohuikeji.frame.module.admin.service.ITFranchiseeInformationService;
import com.bohuikeji.frame.module.admin.utils.MapUtils;
import com.bohuikeji.frame.module.admin.utils.NumberUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Api(tags = {"租车服务相关接口"})
@RestController
@Slf4j
@RequestMapping("/api/rental/config")
@RequiredArgsConstructor
public class RentalConfigApi extends ApiController {

    final ITRentalCarOrderService rentalCarOrderService;
    final ITCustomerService customerService;
    final ITRentalPayService rentalPayService;
    final ITRentalConfigService rentalConfigService;
    final ITFranchiseeInformationService franService;
    final RedisUtil redisUtil;

    @ApiOperation("租车服务计费选择")
    @GetMapping("/lease/car")
    //配置忽略参数
    @ApiOperationSupport(ignoreParameters = {"records","total","searchCount"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="groupKey",value="carry_type",dataType="String", paramType = "query"),})
    public APIEntity<List<SysConfig>> getLeaseGoods(String groupKey){
        log.info("@@@@@@@@@@@@@@@@@@@:配置组：{}",groupKey);
        //TFranchiseeInformation fran=franService.checkPio(MapUtils.getAddressReGeo(location));
        List<TRentalConfig> rentalConfigs=rentalConfigService.list(new QueryWrapper<TRentalConfig>().eq("config_group",groupKey).eq("fran_id",1).eq("show_type",1).orderByDesc("config_sort"));
        List<SysConfig> sysConfigKey=new ArrayList<>(rentalConfigs.size());
        rentalConfigs.forEach(rentalConfig->{
            sysConfigKey.add(rentalConfig.toOldConfig());
        });
        return APIEntity.success(sysConfigKey);
    }

}
