
package com.tmerclub.cloud.multishop.controller.admin;

import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.StrUtil;
import com.tmerclub.cloud.common.constant.Constant;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.multishop.service.CompanyAuditingService;
import com.tmerclub.cloud.multishop.vo.ShopCompanyAuditingVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author chiley
 * @date 2022/9/13 14:06
 */
@RestController("adminCompanyAuditingController")
@RequestMapping("/mp/shopCompanyAuditing")
@Tag(name = "admin-工商信息审核情况")
public class CompanyAuditingController {

    @Autowired
    private CompanyAuditingService companyAuditingService;


    @GetMapping("/auditInfo")
    @Operation(summary = "查看申请审核情况", description = "查看申请审核情况")
    public ServerResponseEntity<ShopCompanyAuditingVO> auditInfo(@RequestParam(value = "shopId", required = false) Long shopId) {
        Long tenantId = AuthUserContext.get().getTenantId();
        if (!Objects.equals(tenantId, Constant.PLATFORM_SHOP_ID)) {
            shopId = tenantId;
        }
        ShopCompanyAuditingVO auditInfo = companyAuditingService.getAuditInfo(shopId);
        if (Objects.nonNull(auditInfo) && Objects.nonNull(auditInfo.getShopCompanyVO()) && StrUtil.isNotBlank(auditInfo.getShopCompanyVO().getLegalPhone())) {
            auditInfo.getShopCompanyVO().setLegalPhone(PhoneUtil.hideBetween(auditInfo.getShopCompanyVO().getLegalPhone()).toString());
        }
        return ServerResponseEntity.success(auditInfo);
    }
}
