package com.winsun.mapper;

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

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.winsun.bean.Bill;
import com.winsun.bean.BonusApply;

/**
 * 
 * @author Warden
 *
 */
@Mapper
@Component
public interface BonusMapper extends BaseMapper<BonusApply>{
		
	@Insert(" insert into hhr_bonus_detail(bonus,apply_num,bonus_num,sales_id,order_phone) values(#{bonus},#{applyNum},#{bonusNum},#{salesId},#{orderPhone}) ")
	int addApplyDetail(@Param("bonus") double bonus,@Param("applyNum") String applyNum,@Param("bonusNum") String bonusNum,@Param("salesId") int salesId,
			@Param("orderPhone") String orderPhone);
	
	@Insert(" insert into hhr_bonus_log(order_num,request_desc,pay_type,create_id,create_date,state) values(#{orderNum},#{requestDesc},#{payType},#{createId},now(),#{state}) ")
	int addBonusLog(@Param("orderNum") String orderNum,@Param("requestDesc") String requestDesc,@Param("payType") String payType,@Param("createId") int createId,
			@Param("state") int state);
	
	@Update(" update hhr_bonus set state = #{state} where id = #{id} ")
	int updateBonus(@Param("state") int state, @Param("int") int id);
	
	@Update(" update hhr_bonus_log set response_desc = #{responseDesc},pay_order_num = #{payOrderNum},state = #{state} where order_num = #{orderNum} ")
	int updateBonusLog(@Param("responseDesc") String responseDesc, @Param("payOrderNum") String payOrderNum, @Param("state") int state,
			@Param("orderNum") String orderNum);
	
	@Select(" select * from hhr_bonus_detail where bonus_num = #{bonusNum} ")
	List<Map<String, Object>> getBonusDetail(@Param("bonusNum") String bonusNum);
}
