Merge #111 into master from cc_20260417_bonus

fix:工资奖金

* cc_20260417_bonus: (28 commits squashed)

  - feat:工资奖金发放

  - fix:工资奖金发放

  - fix:工资奖金发放

  - fix:工资奖金发放

  - fix:工资奖金发放

  - fix:门店实收相关接口

  - fix:新品销售门店级接口

  - fix:新品销售菜品列表接口;规则新增返回id

  - fix:新品销售菜品详情接口

  - fix:新品销售菜品接口补充

  - fix:小程序接口补充

  - fix

  - fix:新增实收、新品销售测试接口

  - fix:新增实收、新品销售测试接口

  - fix

  - fix:新增门店菜品列表接口

  - fix:同规则下无法新增相同菜品规则;新增小程序门店列表接口

  - fix

  - fix:小程序用户获取来源修改

  - fix:实收规则新增上月日均实收字段

  - fix:规则限制

  - fix:小程序上月日均实收

  - fix:查询异常

  - fix:查询异常

  - fix:菜品员工明细字段赋值异常

  - fix:排序

  - fix:排序

  - fix:员工实收列表新增门店筛选条件

Signed-off-by: 王非凡 <accounts_67eba0c5fee9c49c80c8e2b4@mail.teambition.com>
Merged-by: 正新 <accounts_6964c7bcd2a2c377c5bbd01b@mail.teambition.com>

CR-link: https://codeup.aliyun.com/692ea314dec569489f6f167c/hangzhou/java/custom_zxjp/change/111
This commit is contained in:
王非凡
2026-04-27 10:41:08 +00:00
committed by 正新
parent 97f8a8669c
commit 22fcfc6a90
95 changed files with 5466 additions and 8 deletions

View File

@@ -0,0 +1,61 @@
package com.cool.store.dao.bonus;
import com.cool.store.entity.bonus.BonusDistributionRuleDO;
import com.cool.store.mapper.bonus.BonusDistributionRuleMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* <p>
* 奖金发放规则DAO
* </p>
*
* @author wangff
* @since 2026/4/20
*/
@Repository
@RequiredArgsConstructor
public class BonusDistributionRuleDAO {
private final BonusDistributionRuleMapper bonusDistributionRuleMapper;
public boolean addRule(BonusDistributionRuleDO ruleDO) {
return bonusDistributionRuleMapper.insertSelective(ruleDO) > 0;
}
/**
* 门店下相同规则类型的启用规则生效期间有无交集
* @param storeId 门店id
* @param type 规则类型
* @param startDate 开始有效日期
* @param endDate 结束有效日期
* @return 是否存在
*/
public boolean existOverlap(String storeId, Integer type, Date startDate, Date endDate) {
return bonusDistributionRuleMapper.existOverlap(storeId, type, startDate, endDate) > 0;
}
public BonusDistributionRuleDO getById(Long id) {
return bonusDistributionRuleMapper.selectByPrimaryKey(id);
}
public boolean updateByPrimaryKeySelective(BonusDistributionRuleDO ruleDO) {
return bonusDistributionRuleMapper.updateByPrimaryKeySelective(ruleDO) > 0;
}
public List<BonusDistributionRuleDO> getList(String storeNumOrName, Integer type, Integer enable, String storeId) {
return bonusDistributionRuleMapper.getList(storeNumOrName, type, enable, storeId);
}
/**
* 获取指定类型和生效月份的启用规则列表
* @param type 规则类型
* @param payMonth 发放月份 yyyy-MM
* @return 规则列表
*/
public List<BonusDistributionRuleDO> getEnabledRulesByTypeAndMonth(Integer type, String payMonth) {
return bonusDistributionRuleMapper.selectEnabledRulesByTypeAndMonth(type, payMonth);
}
}

View File

@@ -0,0 +1,37 @@
package com.cool.store.dao.bonus;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.bonus.BonusEmployeeRewardDetailDO;
import com.cool.store.mapper.bonus.BonusEmployeeRewardDetailMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* 员工奖励明细DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusEmployeeRewardDetailDAO {
private final BonusEmployeeRewardDetailMapper mapper;
public int insert(BonusEmployeeRewardDetailDO entity) {
return mapper.insertSelective(entity);
}
public int insertOrUpdateBatch(List<BonusEmployeeRewardDetailDO> list) {
if (CollectionUtils.isEmpty(list)) {
return 0;
}
return mapper.insertOrUpdateBatch(list);
}
public List<BonusEmployeeRewardDetailDO> selectListByCondition(String storeNumOrName, Date startDate, Date endDate, String rewardUserName, String storeId) {
return mapper.selectListByCondition(storeNumOrName, startDate, endDate, rewardUserName, storeId);
}
}

View File

@@ -0,0 +1,82 @@
package com.cool.store.dao.bonus;
import cn.hutool.core.collection.CollStreamUtil;
import com.cool.store.entity.bonus.BonusNewProductEmployeeDO;
import com.cool.store.mapper.bonus.BonusNewProductEmployeeMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 新品销售奖金-员工DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusNewProductEmployeeDAO {
private final BonusNewProductEmployeeMapper mapper;
public int insert(BonusNewProductEmployeeDO entity) {
return mapper.insertSelective(entity);
}
public int insertBatch(List<BonusNewProductEmployeeDO> list) {
if (CollectionUtils.isEmpty(list)) {
return 0;
}
return mapper.insertBatch(list);
}
/**
* 月度奖金统计
* @param storeId 门店id
* @param payDate 发放年月
* @param userIds 用户id列表
* @return 实体列表
*/
public Map<String, BigDecimal> getMonthlyStatistics(String storeId, String payDate, List<String> userIds) {
List<Map<String, Objects>> list = mapper.getMonthlyStatistics(storeId, payDate, userIds);
return CollStreamUtil.toMap(list, v -> MapUtils.getString(v, "reward_user_id"), v -> new BigDecimal(MapUtils.getString(v, "total_amount")));
}
/**
* 月度统计
*/
public List<BonusNewProductEmployeeDO> monthlyStatistics(Long ruleId, String storeId, Date payDate, String userId) {
return mapper.monthlyStatistics(ruleId, storeId, payDate, userId);
}
/**
* 员工列表月度统计
*/
public List<BonusNewProductEmployeeDO> employeeMonthlyStatistics(Date startDate,
Date endDate,
String storeNumOrName,
String rewardUserName,
String storeId) {
return mapper.employeeMonthlyStatistics(startDate, endDate, storeNumOrName, rewardUserName, storeId);
}
public List<BonusNewProductEmployeeDO> getMonthlyStatisticsGroupByStore(String payMonth) {
return mapper.getMonthlyStatisticsGroupByStore(payMonth);
}
public void deleteDailyNewProduct(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusNewProductEmployeeDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -0,0 +1,64 @@
package com.cool.store.dao.bonus;
import cn.hutool.core.collection.CollStreamUtil;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.bonus.BonusNewProductRecipeDO;
import com.cool.store.mapper.bonus.BonusNewProductRecipeMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 新品销售奖金-菜品DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusNewProductRecipeDAO {
private final BonusNewProductRecipeMapper mapper;
public int insert(BonusNewProductRecipeDO entity) {
return mapper.insertSelective(entity);
}
public int insertBatch(List<BonusNewProductRecipeDO> list) {
if (CollectionUtils.isEmpty(list)) {
return 0;
}
return mapper.insertBatch(list);
}
public List<BonusNewProductRecipeDO> monthlyStatistics(String storeNumOrName, Date startDate, Date endDate, String recipeNoOrName) {
return mapper.monthlyStatistics(storeNumOrName, startDate, endDate, recipeNoOrName);
}
public List<BonusNewProductRecipeDO> selectListByCondition(String storeId, String recipeNo, Date startDate, Date endDate) {
return mapper.selectListByCondition(storeId, recipeNo, startDate, endDate);
}
public Map<Long, BonusNewProductRecipeDO> getMapByIds(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return Collections.emptyMap();
}
Example example = new Example(BonusNewProductRecipeDO.class);
example.createCriteria().andIn("id", ids);
List<BonusNewProductRecipeDO> list = mapper.selectByExample(example);
return CollStreamUtil.toMap(list, BonusNewProductRecipeDO::getId, v -> v);
}
public void deleteDailyNewProduct(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusNewProductRecipeDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -0,0 +1,74 @@
package com.cool.store.dao.bonus;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.bonus.BonusNewProductRecipeEmployeeDO;
import com.cool.store.mapper.bonus.BonusNewProductRecipeEmployeeMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 新品销售奖金-菜品-员工DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusNewProductRecipeEmployeeDAO {
private final BonusNewProductRecipeEmployeeMapper mapper;
public int insert(BonusNewProductRecipeEmployeeDO entity) {
return mapper.insertSelective(entity);
}
public int insertBatch(List<BonusNewProductRecipeEmployeeDO> list) {
if (CollectionUtils.isEmpty(list)) {
return 0;
}
return mapper.insertBatch(list);
}
/**
* 月度统计
*/
public List<BonusNewProductRecipeEmployeeDO> monthlyStatistics(String storeNumOrName, Date startDate, Date endDate, String rewardUserName, String recipeNoOrName) {
return mapper.monthlyStatistics(storeNumOrName, startDate, endDate, rewardUserName, recipeNoOrName);
}
public List<BonusNewProductRecipeEmployeeDO> selectListByCondition(String storeId, String recipeNo, String rewardUserId, Date startDate, Date endDate) {
Example example = new Example(BonusNewProductRecipeEmployeeDO.class);
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(storeId)) {
criteria.andEqualTo("storeId", storeId);
}
if (StringUtils.isNotBlank(recipeNo)) {
criteria.andEqualTo("recipeNo", recipeNo);
}
if (StringUtils.isNotBlank(rewardUserId)) {
criteria.andEqualTo("rewardUserId", rewardUserId);
}
if (Objects.nonNull(startDate)) {
criteria.andGreaterThanOrEqualTo("payDate", startDate);
}
if (Objects.nonNull(endDate)) {
criteria.andLessThanOrEqualTo("payDate", endDate);
}
example.setOrderByClause("create_time DESC");
return mapper.selectByExample(example);
}
public void deleteDailyNewProduct(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusNewProductRecipeEmployeeDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -0,0 +1,51 @@
package com.cool.store.dao.bonus;
import cn.hutool.core.collection.CollStreamUtil;
import com.cool.store.entity.bonus.BonusNewProductStoreDO;
import com.cool.store.mapper.bonus.BonusNewProductStoreMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 新品销售奖金-门店DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusNewProductStoreDAO {
private final BonusNewProductStoreMapper mapper;
public int insert(BonusNewProductStoreDO entity) {
return mapper.insertSelective(entity);
}
public boolean existsByRuleIdAndPayDate(Long ruleId, String payDate) {
return mapper.selectCountByRuleIdAndPayDate(ruleId, payDate) > 0;
}
public BonusNewProductStoreDO getById(Long id) {
return mapper.selectByPrimaryKey(id);
}
public List<BonusNewProductStoreDO> monthlyStatistics(String storeNumOrName, Date startDate, Date endDate, String storeId, Long ruleId) {
return mapper.monthlyStatistics(storeNumOrName, startDate, endDate, storeId, ruleId);
}
public void deleteDailyNewProduct(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusNewProductStoreDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -0,0 +1,62 @@
package com.cool.store.dao.bonus;
import com.cool.store.entity.bonus.BonusReceivedEmployeeDO;
import com.cool.store.mapper.bonus.BonusReceivedEmployeeMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
/**
* 实收奖金发放-员工DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusReceivedEmployeeDAO {
private final BonusReceivedEmployeeMapper mapper;
public int insert(BonusReceivedEmployeeDO entity) {
return mapper.insertSelective(entity);
}
public int insertBatch(List<BonusReceivedEmployeeDO> list) {
if (CollectionUtils.isEmpty(list)) {
return 0;
}
return mapper.insertBatch(list);
}
public List<BonusReceivedEmployeeDO> selectByReceivedStoreId(Long receivedStoreId) {
return mapper.selectByReceivedStoreId(receivedStoreId);
}
public BonusReceivedEmployeeDO getById(Long id) {
return mapper.selectByPrimaryKey(id);
}
public List<BonusReceivedEmployeeDO> selectEmployeeListByCondition(String storeNumOrName, Date startMonth, Date endMonth, String rewardUserName, String storeId) {
return mapper.selectEmployeeListByCondition(storeNumOrName, startMonth, endMonth, rewardUserName, storeId);
}
/**
* 按门店分组统计员工月度实收
*/
public List<BonusReceivedEmployeeDO> getMonthlyStatisticsGroupByStore(String payMonth) {
return mapper.getMonthlyStatisticsGroupByStore(payMonth);
}
public void deleteMonthlyReceived(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusReceivedEmployeeDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -0,0 +1,62 @@
package com.cool.store.dao.bonus;
import cn.hutool.core.collection.CollStreamUtil;
import com.cool.store.entity.bonus.BonusReceivedStoreDO;
import com.cool.store.mapper.bonus.BonusReceivedStoreMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 实收奖金发放-门店DAO
*
* @author wangff
* @since 2026/4/21
*/
@Repository
@RequiredArgsConstructor
public class BonusReceivedStoreDAO {
private final BonusReceivedStoreMapper mapper;
public int insert(BonusReceivedStoreDO entity) {
return mapper.insertSelective(entity);
}
public boolean existsByRuleIdAndPayDate(Long ruleId, String payDate) {
return mapper.selectCountByRuleIdAndPayDate(ruleId, payDate) > 0;
}
public BonusReceivedStoreDO getById(Long id) {
return mapper.selectByPrimaryKey(id);
}
public List<BonusReceivedStoreDO> selectListByCondition(String storeNumOrName, Date startMonth, Date endMonth, String storeId) {
return mapper.selectListByCondition(storeNumOrName, startMonth, endMonth, storeId);
}
public Map<Long, BonusReceivedStoreDO> getMapByIds(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return Collections.emptyMap();
}
Example example = new Example(BonusReceivedStoreDO.class);
example.createCriteria()
.andIn("id", ids);
List<BonusReceivedStoreDO> list = mapper.selectByExample(example);
return CollStreamUtil.toMap(list, BonusReceivedStoreDO::getId, v -> v);
}
public void deleteMonthlyReceived(Long ruleId, String storeId, Date payDate) {
Example example = new Example(BonusReceivedStoreDO.class);
example.createCriteria()
.andEqualTo("ruleId", ruleId)
.andEqualTo("storeId", storeId)
.andEqualTo("payDate", payDate);
mapper.deleteByExample(example);
}
}

View File

@@ -52,6 +52,14 @@ public interface UserAuthMappingMapper {
@Param("positionType")String positionType,
@Param("notRoleAuth")String notRoleAuth);
/**
* 与标品一致listUserAuthMappingByAuth方法会查询出运营顾问等角色
*/
List<UserAuthMappingDO> listUserAuthMappingByAuthV2(@Param("type") String type,
@Param("mappingIdList") List<String> mappingIdList,
@Param("positionType")String positionType,
@Param("notRoleAuth")String notRoleAuth);
List<UserAuthMappingDO> listUserAuthMappingByUserList(@Param("userIdList") List<String> userIdList);

View File

@@ -0,0 +1,34 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusDistributionRuleDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusDistributionRuleMapper extends Mapper<BonusDistributionRuleDO> {
/**
* 门店下相同规则类型的启用规则生效期间有无交集
* @param storeId 门店id
* @param type 规则类型
* @param startDate 开始有效日期
* @param endDate 结束有效日期
* @return 是否存在
*/
int existOverlap(@Param("storeId") String storeId, @Param("type") Integer type, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
/**
* 列表查询
*/
List<BonusDistributionRuleDO> getList(@Param("storeNumOrName") String storeNumOrName,
@Param("type") Integer type,
@Param("enable") Integer enable,
@Param("storeId") String storeId);
/**
* 获取指定类型和生效月份的启用规则列表
*/
List<BonusDistributionRuleDO> selectEnabledRulesByTypeAndMonth(@Param("type") Integer type, @Param("payMonth") String payMonth);
}

View File

@@ -0,0 +1,28 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusEmployeeRewardDetailDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public interface BonusEmployeeRewardDetailMapper extends Mapper<BonusEmployeeRewardDetailDO> {
List<BonusEmployeeRewardDetailDO> selectByStoreIdAndPayDate(@Param("storeId") String storeId,
@Param("payDate") String payDate,
@Param("userIds") List<String> userIds);
int updateReceivedAmountById(@Param("id") Long id, @Param("receivedAmount") BigDecimal receivedAmount);
int updateNewProjectAmountById(@Param("id") Long id, @Param("newProjectAmount") BigDecimal newProjectAmount);
int insertOrUpdateBatch(@Param("list") List<BonusEmployeeRewardDetailDO> list);
List<BonusEmployeeRewardDetailDO> selectListByCondition(@Param("storeNumOrName") String storeNumOrName,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("rewardUserName") String rewardUserName,
@Param("storeId") String storeId);
}

View File

@@ -0,0 +1,46 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusNewProductEmployeeDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public interface BonusNewProductEmployeeMapper extends Mapper<BonusNewProductEmployeeDO> {
/**
* 月度统计
*
* @param storeId 门店id
* @param payDate 发放年月
* @param userIds 用户id列表
* @return 实体列表
*/
List<Map<String, Objects>> getMonthlyStatistics(@Param("storeId") String storeId,
@Param("payDate") String payDate,
@Param("userIds") List<String> userIds);
int insertBatch(@Param("list") List<BonusNewProductEmployeeDO> list);
List<BonusNewProductEmployeeDO> monthlyStatistics(@Param("ruleId") Long ruleId,
@Param("storeId") String storeId,
@Param("payDate") Date payDate,
@Param("userId") String userId);
/**
* 员工列表月度统计
*/
List<BonusNewProductEmployeeDO> employeeMonthlyStatistics(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("storeNumOrName") String storeNumOrName,
@Param("rewardUserName") String rewardUserName,
@Param("storeId") String storeId);
/**
* 按门店分组统计员工月度新品销售
*/
List<BonusNewProductEmployeeDO> getMonthlyStatisticsGroupByStore(@Param("payMonth") String payMonth);
}

View File

@@ -0,0 +1,22 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusNewProductRecipeEmployeeDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusNewProductRecipeEmployeeMapper extends Mapper<BonusNewProductRecipeEmployeeDO> {
int insertBatch(@Param("list") List<BonusNewProductRecipeEmployeeDO> list);
/**
* 月度统计
*/
List<BonusNewProductRecipeEmployeeDO> monthlyStatistics(@Param("storeNumOrName") String storeNumOrName,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("rewardUserName") String rewardUserName,
@Param("recipeNoOrName") String recipeNoOrName);
}

View File

@@ -0,0 +1,23 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusNewProductRecipeDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusNewProductRecipeMapper extends Mapper<BonusNewProductRecipeDO> {
int insertBatch(@Param("list") List<BonusNewProductRecipeDO> list);
List<BonusNewProductRecipeDO> monthlyStatistics(@Param("storeNumOrName") String storeNumOrName,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("recipeNoOrName") String recipeNoOrName);
List<BonusNewProductRecipeDO> selectListByCondition(@Param("storeId") String storeId,
@Param("recipeNo") String recipeNo,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
}

View File

@@ -0,0 +1,20 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusNewProductStoreDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusNewProductStoreMapper extends Mapper<BonusNewProductStoreDO> {
int selectCountByRuleIdAndPayDate(@Param("ruleId") Long ruleId, @Param("payDate") String payDate);
List<BonusNewProductStoreDO> monthlyStatistics(@Param("storeNumOrName") String storeNumOrName,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("storeId") String storeId,
@Param("ruleId") Long ruleId);
}

View File

@@ -0,0 +1,25 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusReceivedEmployeeDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusReceivedEmployeeMapper extends Mapper<BonusReceivedEmployeeDO> {
int insertBatch(@Param("list") List<BonusReceivedEmployeeDO> list);
List<BonusReceivedEmployeeDO> selectByReceivedStoreId(@Param("receivedStoreId") Long receivedStoreId);
List<BonusReceivedEmployeeDO> selectEmployeeListByCondition(@Param("storeNumOrName") String storeNumOrName,
@Param("startMonth") Date startMonth,
@Param("endMonth") Date endMonth,
@Param("rewardUserName") String rewardUserName,
@Param("storeId") String storeId);
/**
* 按门店分组统计员工月度实收
*/
List<BonusReceivedEmployeeDO> getMonthlyStatisticsGroupByStore(@Param("payMonth") String payMonth);
}

View File

@@ -0,0 +1,18 @@
package com.cool.store.mapper.bonus;
import com.cool.store.entity.bonus.BonusReceivedStoreDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.Date;
import java.util.List;
public interface BonusReceivedStoreMapper extends Mapper<BonusReceivedStoreDO> {
int selectCountByRuleIdAndPayDate(@Param("ruleId") Long ruleId, @Param("payDate") String payDate);
List<BonusReceivedStoreDO> selectListByCondition(@Param("storeNumOrName") String storeNumOrName,
@Param("startMonth") Date startMonth,
@Param("endMonth") Date endMonth,
@Param("storeId") String storeId);
}

View File

@@ -67,6 +67,36 @@
</where>
</select>
<select id="listUserAuthMappingByAuthV2" resultMap="baseResult">
select a.id,a.user_id,mapping_id,a.type from user_auth_mapping_${enterpriseId} a
join enterprise_user_${enterpriseId} e on a.user_id= e.user_id
<where>
e.user_status= '1' and e.active= true
<if test="mappingIdList!=null and mappingIdList.size>0">
<foreach collection="mappingIdList" item="mappingId" open="and a.mapping_id in (" separator="," close=")">
#{mappingId}
</foreach>
</if>
<if test="type!=null and type!=''">
and a.type =#{type}
</if>
<if test="(positionType!=null and positionType!='') or (notRoleAuth!=null and notRoleAuth!='')">
and a.user_id in (
select
distinct(user_id)
from enterprise_user_role_${enterpriseId} ur JOIN sys_role_${enterpriseId} b on ur.role_id=b.id
<where>
<if test="positionType!=null and positionType!=''">
and b.position_type =#{positionType}
</if>
<if test="notRoleAuth!=null and notRoleAuth!=''">
and b.role_auth !=#{notRoleAuth}
</if>
</where>
)
</if>
</where>
</select>
<select id="listUserAuthMappingByUserList" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
<where>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusDistributionRuleMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusDistributionRuleDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="BIT" property="type" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="start_date" jdbcType="DATE" property="startDate" />
<result column="end_date" jdbcType="DATE" property="endDate" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
<result column="bonus_config" jdbcType="LONGVARCHAR" property="bonusConfig" />
<result column="distribute_config" jdbcType="LONGVARCHAR" property="distributeConfig" />
<result column="enable" jdbcType="BIT" property="enable" />
</resultMap>
<sql id="Base_Column_List">
id, type, store_id, start_date, end_date, create_time, create_user_id, update_time, update_user_id, bonus_config, distribute_config, enable
</sql>
<sql id="Base_Column_List_A">
a.id, a.type, a.store_id, a.start_date, a.end_date, a.create_time, a.create_user_id, a.update_time, a.update_user_id, a.bonus_config, a.distribute_config, a.enable
</sql>
<select id="existOverlap" resultType="int">
SELECT COUNT(1) FROM bonus_distribution_rule
WHERE store_id = #{storeId}
AND type = #{type}
AND enable = 1
AND start_date &lt;= #{endDate}
AND end_date >= #{startDate}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_A" />
FROM bonus_distribution_rule a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="type != null">
AND a.type = #{type}
</if>
<if test="enable != null">
AND a.enable = #{enable}
</if>
<if test="storeId != null and storeId != ''">
AND a.store_id = #{storeId}
</if>
</where>
ORDER BY a.create_time DESC
</select>
<select id="selectEnabledRulesByTypeAndMonth" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM bonus_distribution_rule
WHERE type = #{type} AND enable = 1
AND DATE_FORMAT(start_date, '%Y-%m') &lt;= #{payMonth} AND DATE_FORMAT(end_date, '%Y-%m') >= #{payMonth}
</select>
</mapper>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusEmployeeRewardDetailMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusEmployeeRewardDetailDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="reward_user_name" jdbcType="VARCHAR" property="rewardUserName" />
<result column="reward_user_id" jdbcType="VARCHAR" property="rewardUserId" />
<result column="received_amount" jdbcType="DECIMAL" property="receivedAmount" />
<result column="new_project_amount" jdbcType="DECIMAL" property="newProjectAmount" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, store_id, pay_date, reward_user_name, reward_user_id, received_amount, new_project_amount, create_time
</sql>
<sql id="Base_Column_List_A">
a.id, a.store_id, a.pay_date, a.reward_user_name, a.reward_user_id, a.received_amount, a.new_project_amount, a.create_time
</sql>
<select id="selectByStoreIdAndPayDate" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM bonus_employee_reward_detail
WHERE store_id = #{storeId}
AND DATE_FORMAT(pay_date, '%Y-%m') = #{payDate}
AND reward_user_id IN
<foreach item="item" index="index" collection="userIds" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="updateReceivedAmountById">
UPDATE bonus_employee_reward_detail SET received_amount = #{receivedAmount} WHERE id = #{id}
</update>
<update id="updateNewProjectAmountById">
UPDATE bonus_employee_reward_detail SET new_project_amount = #{newProjectAmount} WHERE id = #{id}
</update>
<insert id="insertOrUpdateBatch">
INSERT INTO bonus_employee_reward_detail (store_id, pay_date, reward_user_name, reward_user_id, received_amount, new_project_amount) VALUES
<foreach item="item" index="index" collection="list" separator=",">
(#{item.storeId}, #{item.payDate}, #{item.rewardUserName}, #{item.rewardUserId}, #{item.receivedAmount}, #{item.newProjectAmount})
</foreach>
ON DUPLICATE KEY UPDATE
received_amount = VALUES(received_amount),
new_project_amount = VALUES(new_project_amount)
</insert>
<select id="selectListByCondition" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List_A" />
FROM bonus_employee_reward_detail a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startDate != null">
AND a.pay_date >= #{startDate}
</if>
<if test="endDate != null">
AND a.pay_date &lt;= #{endDate}
</if>
<if test="rewardUserName != null and rewardUserName != ''">
AND a.reward_user_name LIKE CONCAT('%', #{rewardUserName}, '%')
</if>
<if test="storeId != null and storeId != ''">
AND a.store_id = #{storeId}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusNewProductEmployeeMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusNewProductEmployeeDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="product_store_id" jdbcType="BIGINT" property="productStoreId" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="reward_ratio" jdbcType="DECIMAL" property="rewardRatio" />
<result column="reward_amount" jdbcType="DECIMAL" property="rewardAmount" />
<result column="reward_user_name" jdbcType="VARCHAR" property="rewardUserName" />
<result column="reward_user_id" jdbcType="VARCHAR" property="rewardUserId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<select id="getMonthlyStatistics" resultType="java.util.Map">
SELECT reward_user_id, SUM(reward_amount) total_amount
FROM bonus_new_product_employee
WHERE store_id = #{storeId}
AND DATE_FORMAT(pay_date, '%Y-%m') = #{payDate}
AND reward_user_id IN
<foreach item="item" index="index" collection="userIds" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY reward_user_id
</select>
<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id">
INSERT INTO bonus_new_product_employee (product_store_id, rule_id, store_id, pay_date, reward_ratio, reward_amount, reward_user_name, reward_user_id) VALUES
<foreach item="item" index="index" collection="list" separator=",">
(#{item.productStoreId}, #{item.ruleId}, #{item.storeId}, #{item.payDate}, #{item.rewardRatio}, #{item.rewardAmount}, #{item.rewardUserName}, #{item.rewardUserId})
</foreach>
</insert>
<select id="monthlyStatistics" resultMap="BaseResultMap">
SELECT reward_user_id, reward_user_name, SUM(reward_amount) reward_amount, rule_id
FROM bonus_new_product_employee
<where>
<if test="storeId != null and storeId != ''">
AND store_id = #{storeId}
</if>
<if test="ruleId != null">
AND rule_id = #{ruleId}
</if>
<if test="payDate != null">
AND DATE_FORMAT(pay_date, '%Y-%m') = DATE_FORMAT(#{payDate}, '%Y-%m')
</if>
<if test="userId != null and userId != ''">
AND reward_user_id = #{userId}
</if>
</where>
GROUP BY reward_user_id
</select>
<select id="employeeMonthlyStatistics" resultMap="BaseResultMap">
SELECT a.store_id, a.rule_id, a.reward_user_id, a.reward_user_name, SUM(a.reward_amount) reward_amount, a.pay_date
FROM bonus_new_product_employee a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="startDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') >= DATE_FORMAT(#{startDate}, '%Y-%m')
</if>
<if test="endDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m')
</if>
<if test="rewardUserName != null and rewardUserName != ''">
AND a.reward_user_name LIKE CONCAT('%', #{rewardUserName}, '%')
</if>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="storeId != null and storeId != ''">
AND a.store_id = #{storeId}
</if>
</where>
GROUP BY a.store_id, a.reward_user_id, DATE_FORMAT(a.pay_date, '%Y-%m')
ORDER BY a.pay_date DESC, a.store_id ASC, a.reward_user_id ASC
</select>
<select id="getMonthlyStatisticsGroupByStore" resultMap="BaseResultMap">
SELECT store_id, reward_user_id, reward_user_name, SUM(reward_amount) AS reward_amount
FROM bonus_new_product_employee
<where>
<if test="payMonth != null and payMonth != ''">
AND DATE_FORMAT(pay_date, '%Y-%m') = #{payMonth}
</if>
</where>
GROUP BY store_id, reward_user_id
</select>
</mapper>

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusNewProductRecipeEmployeeMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusNewProductRecipeEmployeeDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="product_recipe_id" jdbcType="BIGINT" property="productRecipeId" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="recipe_no" jdbcType="VARCHAR" property="recipeNo" />
<result column="recipe_name" jdbcType="VARCHAR" property="recipeName" />
<result column="basic_reward_amount" jdbcType="DECIMAL" property="basicRewardAmount" />
<result column="sales_volume" jdbcType="INTEGER" property="salesVolume" />
<result column="excess_reward_amount" jdbcType="DECIMAL" property="excessRewardAmount" />
<result column="reward_ratio" jdbcType="DECIMAL" property="rewardRatio" />
<result column="reward_user_name" jdbcType="VARCHAR" property="rewardUserName" />
<result column="reward_user_id" jdbcType="VARCHAR" property="rewardUserId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>
<insert id="insertBatch">
insert into bonus_new_product_recipe_employee (id, product_recipe_id, rule_id, store_id, pay_date, recipe_no, recipe_name, basic_reward_amount, excess_reward_amount, reward_ratio, reward_user_name, reward_user_id, sales_volume)
values
<foreach collection="list" item="item" separator=",">
(#{item.id}, #{item.productRecipeId}, #{item.ruleId}, #{item.storeId}, #{item.payDate}, #{item.recipeNo}, #{item.recipeName}, #{item.basicRewardAmount}, #{item.excessRewardAmount}, #{item.rewardRatio}, #{item.rewardUserName}, #{item.rewardUserId}, #{item.salesVolume})
</foreach>
</insert>
<select id="monthlyStatistics" resultMap="BaseResultMap">
SELECT a.store_id, a.pay_date, a.recipe_no, a.recipe_name, SUM(a.sales_volume) sales_volume, SUM(a.basic_reward_amount) basic_reward_amount, SUM(a.excess_reward_amount) excess_reward_amount, a.reward_user_id, a.reward_user_name
FROM bonus_new_product_recipe_employee a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') >= DATE_FORMAT(#{startDate}, '%Y-%m')
</if>
<if test="endDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m')
</if>
<if test="rewardUserName != null and rewardUserName != ''">
AND a.reward_user_name LIKE CONCAT('%', #{rewardUserName}, '%')
</if>
<if test="recipeNoOrName != null and recipeNoOrName != ''">
AND (a.recipe_no LIKE CONCAT('%', #{recipeNoOrName}, '%') OR a.recipe_name LIKE CONCAT('%', #{recipeNoOrName}, '%'))
</if>
</where>
GROUP BY a.store_id, DATE_FORMAT(a.pay_date, '%Y-%m'), a.reward_user_id, a.recipe_no
ORDER BY a.pay_date DESC, a.store_id ASC, a.reward_user_id ASC, a.recipe_no ASC
</select>
</mapper>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusNewProductRecipeMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusNewProductRecipeDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="recipe_no" jdbcType="VARCHAR" property="recipeNo" />
<result column="recipe_name" jdbcType="VARCHAR" property="recipeName" />
<result column="min_standard_num" jdbcType="INTEGER" property="minStandardNum" />
<result column="reward_amount" jdbcType="DECIMAL" property="rewardAmount" />
<result column="excess_standard_num" jdbcType="INTEGER" property="excessStandardNum" />
<result column="excess_amount" jdbcType="DECIMAL" property="excessAmount" />
<result column="sales_volume" jdbcType="INTEGER" property="salesVolume" />
<result column="basic_reward_amount" jdbcType="DECIMAL" property="basicRewardAmount" />
<result column="excess_reward_amount" jdbcType="DECIMAL" property="excessRewardAmount" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, rule_id, store_id, pay_date, recipe_no, recipe_name, min_standard_num, reward_amount, excess_standard_num, excess_amount, sales_volume, basic_reward_amount, excess_reward_amount, create_time
</sql>
<insert id="insertBatch" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
INSERT INTO bonus_new_product_recipe (rule_id, store_id, pay_date, recipe_no, recipe_name, min_standard_num, reward_amount, excess_standard_num, excess_amount, sales_volume, basic_reward_amount, excess_reward_amount) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.ruleId}, #{item.storeId}, #{item.payDate}, #{item.recipeNo}, #{item.recipeName}, #{item.minStandardNum}, #{item.rewardAmount}, #{item.excessStandardNum}, #{item.excessAmount}, #{item.salesVolume}, #{item.basicRewardAmount}, #{item.excessRewardAmount})
</foreach>
</insert>
<select id="monthlyStatistics" resultMap="BaseResultMap">
SELECT a.store_id, a.recipe_no, a.recipe_name, a.pay_date, SUM(a.basic_reward_amount) basic_reward_amount, SUM(a.excess_reward_amount) excess_reward_amount
FROM bonus_new_product_recipe a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') >= DATE_FORMAT(#{startDate}, '%Y-%m')
</if>
<if test="endDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m')
</if>
<if test="recipeNoOrName != null and recipeNoOrName != ''">
AND (a.recipe_no LIKE CONCAT('%', #{recipeNoOrName}, '%') OR a.recipe_name LIKE CONCAT('%', #{recipeNoOrName}, '%'))
</if>
</where>
GROUP BY a.store_id, a.recipe_no, DATE_FORMAT(a.pay_date, '%Y-%m')
ORDER BY a.pay_date DESC, a.store_id ASC, a.recipe_no ASC
</select>
<select id="selectListByCondition" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM bonus_new_product_recipe
<where>
<if test="storeId != null and storeId != ''">
AND store_id = #{storeId}
</if>
<if test="recipeNo != null and recipeNo != ''">
AND recipe_no = #{recipeNo}
</if>
<if test="startDate != null">
AND DATE_FORMAT(pay_date, '%Y-%m-%d') >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
AND DATE_FORMAT(pay_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
</where>
ORDER BY create_time DESC, store_id ASC
</select>
</mapper>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusNewProductStoreMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusNewProductStoreDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="amount_total" jdbcType="DECIMAL" property="amountTotal" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<select id="selectCountByRuleIdAndPayDate" resultType="int">
SELECT COUNT(1) FROM bonus_new_product_store
WHERE rule_id = #{ruleId} AND DATE_FORMAT(pay_date, '%Y-%m-%d') = #{payDate}
</select>
<select id="monthlyStatistics" resultMap="BaseResultMap">
SELECT a.rule_id, a.store_id, a.pay_date, SUM(a.amount_total) amount_total
FROM bonus_new_product_store a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') >= DATE_FORMAT(#{startDate}, '%Y-%m')
</if>
<if test="endDate != null">
AND DATE_FORMAT(a.pay_date, '%Y-%m') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m')
</if>
<if test="storeId != null and storeId != ''">
AND a.store_id = #{storeId}
</if>
<if test="ruleId != null">
AND a.rule_id = #{ruleId}
</if>
</where>
GROUP BY a.store_id, a.rule_id, DATE_FORMAT(a.pay_date, '%Y-%m')
ORDER BY a.pay_date DESC, a.store_id ASC, a.rule_id ASC
</select>
</mapper>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusReceivedEmployeeMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusReceivedEmployeeDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="received_store_id" jdbcType="BIGINT" property="receivedStoreId" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="reward_ratio" jdbcType="DECIMAL" property="rewardRatio" />
<result column="received_amount" jdbcType="DECIMAL" property="receivedAmount" />
<result column="reward_user_name" jdbcType="VARCHAR" property="rewardUserName" />
<result column="reward_user_id" jdbcType="VARCHAR" property="rewardUserId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO bonus_received_employee(received_store_id, rule_id, store_id, pay_date, reward_ratio, received_amount, reward_user_name, reward_user_id)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.receivedStoreId}, #{item.ruleId}, #{item.storeId}, #{item.payDate}, #{item.rewardRatio}, #{item.receivedAmount}, #{item.rewardUserName}, #{item.rewardUserId})
</foreach>
</insert>
<select id="selectByReceivedStoreId" resultMap="BaseResultMap">
SELECT id, received_store_id, rule_id, store_id, pay_date, reward_ratio, received_amount, reward_user_name, reward_user_id, create_time
FROM bonus_received_employee
WHERE received_store_id = #{receivedStoreId}
ORDER BY id
</select>
<select id="selectEmployeeListByCondition" resultMap="BaseResultMap">
SELECT e.id, e.received_store_id, e.rule_id, e.store_id, e.pay_date, e.reward_ratio, e.received_amount, e.reward_user_name, e.reward_user_id, e.create_time
FROM bonus_received_employee e
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} st ON e.store_id = st.store_id AND st.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (st.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR st.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startMonth != null">
AND e.pay_date &gt;= #{startMonth}
</if>
<if test="endMonth != null">
AND e.pay_date &lt;= #{endMonth}
</if>
<if test="rewardUserName != null and rewardUserName != ''">
AND e.reward_user_name LIKE CONCAT('%', #{rewardUserName}, '%')
</if>
<if test="storeId != null and storeId != ''">
AND e.store_id = #{storeId}
</if>
</where>
ORDER BY e.create_time DESC, e.store_id ASC
</select>
<select id="getMonthlyStatisticsGroupByStore" resultMap="BaseResultMap">
SELECT store_id, reward_user_id, reward_user_name, SUM(received_amount) AS received_amount
FROM bonus_received_employee
WHERE DATE_FORMAT(pay_date, '%Y-%m') = #{payMonth}
GROUP BY store_id, reward_user_id
</select>
</mapper>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cool.store.mapper.bonus.BonusReceivedStoreMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.bonus.BonusReceivedStoreDO">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="rule_id" jdbcType="BIGINT" property="ruleId" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="pay_date" jdbcType="DATE" property="payDate" />
<result column="received_monthly" jdbcType="DECIMAL" property="receivedMonthly" />
<result column="business_days" jdbcType="INTEGER" property="businessDays" />
<result column="received_daily" jdbcType="DECIMAL" property="receivedDaily" />
<result column="received_daily_last" jdbcType="DECIMAL" property="receivedDailyLast" />
<result column="amount_total" jdbcType="DECIMAL" property="amountTotal" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<select id="selectCountByRuleIdAndPayDate" resultType="int">
SELECT COUNT(1) FROM bonus_received_store
WHERE rule_id = #{ruleId} AND DATE_FORMAT(pay_date, '%Y-%m') = #{payDate}
</select>
<select id="selectListByCondition" resultMap="BaseResultMap">
SELECT a.id, a.rule_id, a.store_id, a.pay_date, a.received_monthly, a.business_days, a.received_daily, a.received_daily_last, a.amount_total, a.create_time
FROM bonus_received_store a
<if test="storeNumOrName != null and storeNumOrName != ''">
INNER JOIN store_${enterpriseId} b ON a.store_id = b.store_id AND b.is_delete = 'effective'
</if>
<where>
<if test="storeNumOrName != null and storeNumOrName != ''">
AND (b.store_num LIKE CONCAT('%', #{storeNumOrName}, '%') OR b.store_name LIKE CONCAT('%', #{storeNumOrName}, '%'))
</if>
<if test="startMonth != null">
AND a.pay_date &gt;= #{startMonth}
</if>
<if test="endMonth != null">
AND a.pay_date &lt;= #{endMonth}
</if>
<if test="storeId != null and storeId != ''">
AND a.store_id = #{storeId}
</if>
</where>
ORDER BY a.create_time DESC
</select>
</mapper>