package com.chaozhanggui.admin.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chaozhanggui.admin.system.service.MerchantInfoService;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.entity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lyf
 */
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/merchantInfo")
@Slf4j
public class MerchantInfoController {

    @Resource
    private MerchantInfoService merchantInfoService;


    /**
     * 实名认证信息
     * @return
     */
    @GetMapping("/detail/audit/{userId}")
    public RespBody auditInfo(@PathVariable("userId") Integer userId) {
       return merchantInfoService.merchantReal(userId);
    }

    /**
     * 更改实名认证信息
     * @param userApp
     * @return
     */
    @PostMapping("/updatePromoterInformation")
    public RespBody updatePromoterInformation(@RequestBody TbPlussUserApp userApp){
        if (userApp == null){
            log.error("参数错误");
            return new RespBody("000019");
        }
        return merchantInfoService.updatePromoterInformation(userApp);
    }
//    @PostMapping("/updateMerchantInformation")
//    @ResponseBody
//    public RespBody updateMerchantInformation(TbPlussUserApp userApp, TbPlussMerchantImage merchantImage){
//        if (userApp == null || merchantImage == null){
//            log.error("参数错误");
//            return new RespBody("000019");
//        }
//        return merchantInfoService.updateMerchantInformation(userApp,merchantImage);
//    }
    @PostMapping("/updateIdCard")
    public RespBody updateIdCard(@RequestBody TbPlussIdCard idCard){
        if (idCard == null){
            log.error("参数错误");
            return new RespBody("000019");
        }
        return merchantInfoService.updateIdCard(idCard);
    }

    @PostMapping("/updateBankCard")
    public RespBody updateBankCard(@RequestBody TbPlussBankCard bankCard){
        if (bankCard == null){
            log.error("参数错误");
            return new RespBody("000019");
        }
        return merchantInfoService.updateBankCard(bankCard);
    }
    /**
     * 商户基本信息
     * @param userId
     * @return
     */
    @GetMapping("/detail/merchBaseInfo/{userId}")
    public RespBody merchBaseInfo(@PathVariable("userId") Integer userId){
        return merchantInfoService.merchantBaseInfo(userId);
    }
    /**
     * 结算信息
     * @param userId
     * @return
     */
    @GetMapping("/detail/merchBaseAccount/{userId}")
    public RespBody merchBaseAccount(@PathVariable("userId") Integer userId){
        return merchantInfoService.merchantAccount(userId);
    }

//    /**
//     * 进件相关信息
//     * @param userId
//     * @return
//     */
//    @GetMapping("/detail/channelAuditInfo/{userId}")
//    public RespBody channelAuditInfo(@PathVariable("userId") Long userId) {
//
//    }

    /**
     * 获取所有省
     */
//    private void getProvince() {
//        QueryWrapper<TbPlussAreaCity> queryWrapper = new QueryWrapper<TbPlussAreaCity>().eq("type", "1");
//        List<TbPlussAreaCity> areaCitiesList = TbPlussAreaCityMapper.selectList(queryWrapper);
//        for (AreaCity areaCity : areaCitiesList) {
//            switch (areaCity.getAreaName()) {
//                case "北京":
//                    areaCity.setAreaName("北京市");
//                    break;
//                case "天津":
//                    areaCity.setAreaName("天津市");
//                    break;
//                case "重庆":
//                    areaCity.setAreaName("重庆市");
//                    break;
//                case "上海":
//                    areaCity.setAreaName("上海市");
//                    break;
//                default:
//                    break;
//            }
//        }
//
//        request.setAttribute("areaCitiesList", areaCitiesList);
//    }
}
