package com.gree.mall.manager.logic.activity;

import org.apache.commons.lang3.StringUtils;
import com.gree.mall.manager.plus.entity.PromotionGroupSpecUser;
import com.gree.mall.manager.plus.service.PromotionGroupService;
import com.gree.mall.manager.plus.service.PromotionGroupSpecUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class PromotionGroupUserLogic {

    @Autowired
    PromotionGroupSpecUserService promotionGroupSpecUserService;

    /**
     * 列表
     */
    public List<PromotionGroupSpecUser> list(String promotionGroupSpecId, String name, String phone, BigDecimal groupPrice,BigDecimal shareAmount){
        return promotionGroupSpecUserService.lambdaQuery()
                .eq(PromotionGroupSpecUser::getPromotionGroupSpecId,promotionGroupSpecId)
                .like(StringUtils.isNotBlank(name),PromotionGroupSpecUser::getUserName,name)
                .like(StringUtils.isNotBlank(phone),PromotionGroupSpecUser::getUserPhone,phone)
                .eq(groupPrice != null ,PromotionGroupSpecUser::getGroupPrice,groupPrice)
                .eq(shareAmount != null,PromotionGroupSpecUser::getShareAmount,shareAmount)
                .list();
    }

    /**
     * 团长价格分佣设置
     */
    public void update(List<PromotionGroupSpecUser> promotionGroupSpecUsers){
        promotionGroupSpecUserService.updateBatchById(promotionGroupSpecUsers);
    }





}
