package cn.superdesk.uniorder.dubbo.consumer.order.base;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.base.UnifiedOrderGoods;

import cn.superdesk.uniorder.dto.param.order.base.UnifiedOrderGoodsParam;
import cn.superdesk.uniorder.dto.param.order.base.UnifiedOrderGoodsQueryCriteria;
import cn.superdesk.uniorder.dto.vo.order.base.UnifiedOrderGoodsHeadVo;
import cn.superdesk.uniorder.dto.vo.order.base.UnifiedOrderGoodsListItemVo;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.order.base.DubboUnifiedOrderGoodsService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

/**
 * @Description:
 * @Author: linjinyu
 * @Email linjinyu@avic-s.com
 * @CreateDate: 2021-01-06 20:55:13
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021-01-06 20:55:13
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class UnifiedOrderGoodsDubboConsumerService {

    @Reference(version = "1.0.0", timeout = 60000, retries = -1)
    private DubboUnifiedOrderGoodsService dubboUnifiedOrderGoodsService;

    @Resource
    private PermissionDubboCustomerService permissionDubboCustomerService;

    /****************************************** extends BaseService 部分 start ******************************************/

    public int insertSelective(UnifiedOrderGoods entity) {

        return dubboUnifiedOrderGoodsService.insertSelective(entity);

    }

    public int updateByPrimaryKeySelective(UnifiedOrderGoods entity) {

        return dubboUnifiedOrderGoodsService.updateByPrimaryKeySelective(entity);
    }

    public void deleteObj(Long id) {

        dubboUnifiedOrderGoodsService.deleteObj(id);
    }

    public UnifiedOrderGoods findById(Long id) {

        return dubboUnifiedOrderGoodsService.findById(id);
    }

    public PageInfo<UnifiedOrderGoods> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize) {

        return dubboUnifiedOrderGoodsService.findByPaging(conditions, pageNun, pageSize);
    }

    public List<UnifiedOrderGoods> findAll(Map<String, Object> queryMap) {

        return dubboUnifiedOrderGoodsService.findAll(queryMap);
    }

    /****************************************** extends BaseService 部分   end ******************************************/


    public int addUnifiedOrderGoods(UnifiedOrderGoodsParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.addUnifiedOrderGoods(param, loginSysUser);
    }


    public int updateUnifiedOrderGoods(UnifiedOrderGoodsParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.updateUnifiedOrderGoods(param, loginSysUser);
    }


    public int deleteUnifiedOrderGoods(Long id, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.deleteUnifiedOrderGoods(id, loginSysUser);
    }


    public UnifiedOrderGoods findUnifiedOrderGoodsById(Long id) {

        return dubboUnifiedOrderGoodsService.findUnifiedOrderGoodsById(id);
    }


    public R<List<UnifiedOrderGoods>> pageQuery(Map<String, Object> conditions, int pageNun, int pageSize) {

        return dubboUnifiedOrderGoodsService.pageQuery(conditions, pageNun, pageSize);
    }

    public UnifiedOrderGoodsListItemVo findListItemVoById(Long id, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.findListItemVoById(id, loginSysUser);
    }

    public R<List<UnifiedOrderGoodsListItemVo>> pageQueryGenericParam(UnifiedOrderGoodsQueryCriteria queryCriteria, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.pageQueryGenericParam(queryCriteria, loginSysUser);
    }

    public List<UnifiedOrderGoodsListItemVo> queryGenericParam(UnifiedOrderGoodsQueryCriteria queryCriteria, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.queryGenericParam(queryCriteria, loginSysUser);
    }

    public UnifiedOrderGoodsHeadVo queryHeadGenericParam(UnifiedOrderGoodsQueryCriteria queryCriteria, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboUnifiedOrderGoodsService.queryHeadGenericParam(queryCriteria, loginSysUser);
    }

    /****************************************** 补丁部分 mark by linjinyu at 20210323 start ******************************************/

    public String checkAndFixFixTaxRateTaxCodeFiscalCode() {
        return dubboUnifiedOrderGoodsService.checkAndFixFixTaxRateTaxCodeFiscalCode();
    }
}
