package com.qs.mp.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qs.mp.admin.domain.vo.ShippingTemplateCalculateVO;
import com.qs.mp.common.domain.Area;
import com.qs.mp.common.domain.ShippingTemplateRule;
import com.qs.mp.common.mapper.ShippingTemplateRuleMapper;
import com.qs.mp.common.service.IShippingTemplateRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 运费规则表 服务实现类
 * </p>
 *
 * @author quanshu
 * @since 2022-04-29
 */
@Service
public class ShippingTemplateRuleServiceImpl extends ServiceImpl<ShippingTemplateRuleMapper, ShippingTemplateRule> implements IShippingTemplateRuleService {

    @Override
    public ShippingTemplateCalculateVO getShippingTemplateRuleByTemplateIdAndAreaInfo(Long shippingTemplateId, Long provinceId, Long cityId) {
        QueryWrapper<ShippingTemplateRule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("t1.id", shippingTemplateId);
        queryWrapper.eq("t3.province_id", provinceId);
        queryWrapper.eq("t3.city_id", cityId);
        return this.getBaseMapper().selectShippingTemplateRuleByTemplateIdAndAreaInfo(queryWrapper);
    }
}
