package shop.alien.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.store.LifeUserOrder;
import shop.alien.entity.store.vo.StoreSalesDetailsVo;

/**
 * 售卖明细 Mapper 接口
 * @author ssk
 * @since 2024-12-31
 */
@Mapper
public interface StoreSalesDetailsMapper extends BaseMapper<LifeUserOrder> {

    @Select("select coupon.name couponName, luser.user_phone userPhone, lorder.order_no orderNo, lorder.pay_time payTime, lorder.price, " +
            "lorder.final_price finalPrice, (lorder.final_price*0.97)  expecteDrevenue, lorder.status " +
            "from life_user_order lorder " +
            "join life_coupon coupon on coupon.id = lorder.quan_id " +
            "join life_user luser on luser.id = lorder.user_id ${ew.customSqlSegment}")
    IPage<StoreSalesDetailsVo> getSalesDetails(IPage<StoreSalesDetailsVo> iPage, @Param(Constants.WRAPPER) QueryWrapper<StoreSalesDetailsVo> wrapper);

    @Select("select coupon_code couponCode, name couponName, image_path imagePath from life_coupon ${ew.customSqlSegment}")
    IPage<StoreSalesDetailsVo> getCouponDetails(IPage<StoreSalesDetailsVo> iPage, @Param(Constants.WRAPPER) QueryWrapper<StoreSalesDetailsVo> wrapper);
}
