package cn.superdesk.uniorder.service.order.base;

import cn.superdesk.uniorder.common.enums.common.CommonAccountingStateEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.base.UnifiedOrderGoods;
import cn.superdesk.uniorder.dao.entity.invoice.customer.InvoiceApplyXGoods;
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.dto.vo.unified.UnifiedOrderJoinGoodsDetailVo;
import cn.superdesk.uniorder.service.base.BaseService;
import com.github.pagehelper.PageInfo;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: linjinyu
 * @CreateDate: 2022/3/22 2:18 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/3/22 2:18 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public interface UnifiedOrderGoodsService extends BaseService<UnifiedOrderGoods> {


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

    int insertSelective(UnifiedOrderGoods entity);

    int updateByPrimaryKeySelective(UnifiedOrderGoods entity);

    @Deprecated
    void deleteObj(Long id);

    UnifiedOrderGoods findById(Long id);

    @Deprecated
    PageInfo<UnifiedOrderGoods> findByPaging(Map<String, Object> conditions, Integer pageNun, Integer pageSize);

    @Deprecated
    List<UnifiedOrderGoods> findAll(Map<String, Object> queryMap);

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


    int addUnifiedOrderGoods(UnifiedOrderGoods entity);

    int updateUnifiedOrderGoods(UnifiedOrderGoods entity);

    int deleteUnifiedOrderGoods(Long id);

    UnifiedOrderGoods findUnifiedOrderGoodsById(Long id);

    UnifiedOrderGoodsListItemVo findListItemVoById(Long id, LoginSysUser loginSysUser);

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

    R<List<UnifiedOrderGoodsListItemVo>> pageQueryGenericParam(
            UnifiedOrderGoodsQueryCriteria criteria,
            LoginSysUser loginSysUser);

    UnifiedOrderGoodsHeadVo queryHeadGenericParam(
            UnifiedOrderGoodsQueryCriteria queryCriteria,
            LoginSysUser loginSysUser);

    List<UnifiedOrderGoodsListItemVo> queryGenericParam(
            UnifiedOrderGoodsQueryCriteria criteria,
            LoginSysUser loginSysUser);

    /****************************************** Biz 部分   end ******************************************/


    List<UnifiedOrderJoinGoodsDetailVo> getUnifiedOrderJoinGoodsDetailVoList(Map<String, Object> params);


    /****************************************** 关于 供应商结算 对账单 设置 对账状态 或 恢复 对账状态 start ******************************************/
    /**
     * 订单维度
     *  @param processOrderSn
     * @param state
     * @return
     */
    int updateAccountingStateSupplierByOrderSn(List<String> processOrderSn, CommonAccountingStateEnum state);

    /**
     * 商品维度
     *  @param processOrderSn
     * @param processSysUnifiedOrderGoodsIds
     * @param state
     * @return
     */
    int updateAccountingStateSupplierByOrderSnAndSysUnifiedOrderGoodsIds(
            List<String> processOrderSn,
            List<Long> processSysUnifiedOrderGoodsIds,
            CommonAccountingStateEnum state);

    /****************************************** 关于 供应商结算 对账单 设置 对账状态 或 恢复 对账状态   end ******************************************/


    /****************************************** 关于 客户结算 对账单 设置 对账状态 或 恢复 对账状态 start ******************************************/
    /**
     * 订单维度
     *  @param processOrderSn
     * @param state
     * @return
     */
    int updateAccountingStateCustomerByOrderSn(List<String> processOrderSn, CommonAccountingStateEnum state);

    /**
     * 商品维度
     *  @param processOrderSn
     * @param sysUnifiedOrderGoodsIds
     * @param state
     * @return
     */
    int updateAccountingStateCustomerByOrderSnAndSysUnifiedOrderGoodsIds(List<String> processOrderSn, List<Long> sysUnifiedOrderGoodsIds, CommonAccountingStateEnum state);

    /****************************************** 关于 客户结算 对账单 设置 对账状态 或 恢复 对账状态   end ******************************************/

    /****************************************** 商品 状态 回款状态 start ******************************************/

    void updateFieldBackAccountStatusByInvoiceX(List<InvoiceApplyXGoods> invoiceX);

    /****************************************** 商品 状态 回款状态   end ******************************************/

    List<UnifiedOrderGoods> findByOrderSn(String orderSn);

    List<UnifiedOrderGoods> findByOrderSns(List<String> processOrderSn);

    List<UnifiedOrderGoods> findBySysUnifiedOrderGoodsIds(List<Long> sysUnifiedOrderGoodsIds);

    /****************************************** 工具方法 start ******************************************/

    Map<Long, UnifiedOrderGoods> convertSysUnifiedOrderGoodsIds2MapSysUnifiedOrderGoodsId2Entity(List<Long> sysUnifiedOrderGoodsIds);

    /****************************************** 工具方法   end ******************************************/


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

    String checkAndFixFixTaxRateTaxCodeFiscalCode();

    int deleteUnifiedOrderGoodsBatch(List<Long> processSysUnifiedOrderGoodsIds);
}
