Compare commits
2 Commits
602a9a7fb6
...
3b178ca160
| Author | SHA1 | Date |
|---|---|---|
|
|
3b178ca160 | |
|
|
e2e36b8389 |
|
|
@ -1,7 +1,10 @@
|
|||
package com.hzs.activity.base.controller.api;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.hzs.activity.base.param.ActivityParam;
|
||||
import com.hzs.activity.base.service.IAcBaseAuthorityService;
|
||||
import com.hzs.activity.base.service.IAcBaseConfigService;
|
||||
import com.hzs.common.core.enums.EActType;
|
||||
import com.hzs.common.core.web.controller.BaseController;
|
||||
import com.hzs.common.core.web.page.TableDataInfo;
|
||||
import com.hzs.common.domain.activity.base.AcBaseConfig;
|
||||
|
|
@ -14,44 +17,51 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 查询活动列表
|
||||
* @author: sui q
|
||||
* @time: 2023/4/27 09:15
|
||||
* @classname: ApiActivityController
|
||||
* @package_name: com.hzs.activity.base.controller.api
|
||||
* version 1.0.0
|
||||
* 查询活动列表
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/base")
|
||||
public class ApiActivityController extends BaseController {
|
||||
|
||||
private IAcBaseConfigService baseConfigService;
|
||||
|
||||
@Autowired
|
||||
public void setBaseConfigService(IAcBaseConfigService baseConfigService) {
|
||||
this.baseConfigService = baseConfigService;
|
||||
}
|
||||
private IAcBaseConfigService iAcBaseConfigService;
|
||||
@Autowired
|
||||
private IAcBaseAuthorityService iAcBaseAuthorityService;
|
||||
|
||||
/*
|
||||
* @description: 查询活动列表
|
||||
* @author: sui q
|
||||
* @date: 2023/4/21 17:33
|
||||
* @param: null null
|
||||
* 查询活动列表
|
||||
**/
|
||||
@GetMapping("/activity-list")
|
||||
public TableDataInfo activityList() {
|
||||
return getDataTable(baseConfigService.queryBaseConfigList(SecurityUtils.getPkCountry(), SecurityUtils.getUserId()));
|
||||
Long pkMember = SecurityUtils.getUserId();
|
||||
String memberCode = SecurityUtils.getMemberCode();
|
||||
|
||||
List<AcBaseConfigExt> resultList = new ArrayList<>();
|
||||
|
||||
List<AcBaseConfigExt> list = iAcBaseConfigService.queryBaseConfigList(SecurityUtils.getPkCountry(), SecurityUtils.getUserId());
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (AcBaseConfigExt acBaseConfigExt : list) {
|
||||
if (EActType.DECLARATION_GIFT.getValue() == acBaseConfigExt.getActType()) {
|
||||
// 报单赠送,需要处理权限
|
||||
if (!iAcBaseAuthorityService.checkAuthority(pkMember, memberCode, acBaseConfigExt.getPkId())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
resultList.add(acBaseConfigExt);
|
||||
}
|
||||
}
|
||||
|
||||
TableDataInfo tableDataInfo = getDataTable(list);
|
||||
tableDataInfo.setRows(resultList);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
/*
|
||||
* @description: 查询活动列表
|
||||
* @author: sui q
|
||||
* @date: 2023/4/21 17:33
|
||||
* @param: null null
|
||||
* 查询活动列表
|
||||
**/
|
||||
@PostMapping("/activity-detail")
|
||||
public TableDataInfo activityDetail(@RequestBody ActivityParam activityParam) {
|
||||
AcBaseConfigExt acBaseConfig = baseConfigService.queryBaseConfigDetail(activityParam.getPkId(), SecurityUtils.getPkCountry());
|
||||
AcBaseConfigExt acBaseConfig = iAcBaseConfigService.queryBaseConfigDetail(activityParam.getPkId(), SecurityUtils.getPkCountry());
|
||||
List<AcBaseConfig> acBaseConfigList = new ArrayList<>();
|
||||
acBaseConfigList.add(acBaseConfig);
|
||||
return getDataTable(acBaseConfigList);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import com.hzs.common.domain.activity.base.AcBaseAuthority;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 活动基础权限表 Mapper 接口
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface AcBaseAuthorityMapper extends BaseMapper<AcBaseAuthority> {
|
||||
|
||||
|
|
@ -40,4 +38,14 @@ public interface AcBaseAuthorityMapper extends BaseMapper<AcBaseAuthority> {
|
|||
*/
|
||||
List<AcBaseAuthority> listAuthority(@Param("pkBaseId") Long pkBaseId);
|
||||
|
||||
/**
|
||||
* 批量查询会员是否在血缘伞下
|
||||
*/
|
||||
Set<Long> queryBlood(@Param("paramList") Set<String> paramList, @Param("pkMember") Long pkMember);
|
||||
|
||||
/**
|
||||
* 批量查询会员是否在安置伞下
|
||||
*/
|
||||
Set<Long> queryPlace(@Param("paramList") Set<String> paramList, @Param("pkMember") Long pkMember);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 活动基础权限表 服务类
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface IAcBaseAuthorityService extends IService<AcBaseAuthority> {
|
||||
|
||||
|
|
@ -39,4 +36,9 @@ public interface IAcBaseAuthorityService extends IService<AcBaseAuthority> {
|
|||
*/
|
||||
List<AcBaseAuthority> listAuthority(Long pkBaseId);
|
||||
|
||||
/**
|
||||
* 校验权限
|
||||
*/
|
||||
boolean checkAuthority(Long pkMember, String memberCode, Long pkBaseId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package com.hzs.activity.base.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.hzs.activity.base.mapper.AcBaseAuthorityMapper;
|
||||
import com.hzs.activity.base.service.IAcBaseAuthorityService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.hzs.common.core.enums.EWaresPermissionType;
|
||||
import com.hzs.common.domain.activity.base.AcBaseAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 活动基础权限表 服务实现类
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class AcBaseAuthorityServiceImpl extends ServiceImpl<AcBaseAuthorityMapper, AcBaseAuthority> implements IAcBaseAuthorityService {
|
||||
|
|
@ -32,4 +33,59 @@ public class AcBaseAuthorityServiceImpl extends ServiceImpl<AcBaseAuthorityMappe
|
|||
return baseMapper.listAuthority(pkBaseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAuthority(Long pkMember, String memberCode, Long pkBaseId) {
|
||||
List<AcBaseAuthority> authorityList = baseMapper.listAuthority(pkBaseId);
|
||||
if (CollectionUtil.isNotEmpty(authorityList)) {
|
||||
// 血缘查询
|
||||
Set<String> authorityParentSet = new HashSet<>();
|
||||
// 安置查询
|
||||
Set<String> authorityPlaceSet = new HashSet<>();
|
||||
|
||||
for (AcBaseAuthority acBaseAuthority : authorityList) {
|
||||
if (EWaresPermissionType.MEMBER.getValue() == acBaseAuthority.getAuthorityType()) {
|
||||
// 指定会员
|
||||
if (acBaseAuthority.getMemberCode().equals(memberCode)) {
|
||||
return true;
|
||||
}
|
||||
} else if (EWaresPermissionType.BLOOD_ALLOW.getValue() == acBaseAuthority.getAuthorityType()
|
||||
|| EWaresPermissionType.BLOOD_STOP.getValue() == acBaseAuthority.getAuthorityType()) {
|
||||
// 血缘关系
|
||||
authorityParentSet.add(acBaseAuthority.getMemberCode());
|
||||
} else if (EWaresPermissionType.PLACE_ALLWO.getValue() == acBaseAuthority.getAuthorityType()
|
||||
|| EWaresPermissionType.PLACE_STOP.getValue() == acBaseAuthority.getAuthorityType()) {
|
||||
// 安置关系
|
||||
authorityPlaceSet.add(acBaseAuthority.getMemberCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 查询血缘
|
||||
Set<Long> authParentList = new HashSet<>();
|
||||
if (authorityParentSet.size() > 0) {
|
||||
authParentList = baseMapper.queryBlood(authorityParentSet, pkMember);
|
||||
}
|
||||
// 查询安置
|
||||
Set<Long> authPlaceList = new HashSet<>();
|
||||
if (authorityPlaceSet.size() > 0) {
|
||||
authPlaceList = baseMapper.queryPlace(authorityPlaceSet, pkMember);
|
||||
}
|
||||
|
||||
for (AcBaseAuthority acBaseAuthority : authorityList) {
|
||||
if (acBaseAuthority.getAuthorityType() == EWaresPermissionType.BLOOD_STOP.getValue()) {
|
||||
// 血缘禁止
|
||||
if (authParentList.contains(pkMember)) {
|
||||
return false;
|
||||
}
|
||||
} else if (acBaseAuthority.getAuthorityType() == EWaresPermissionType.PLACE_STOP.getValue()) {
|
||||
// 安置禁止
|
||||
if (authPlaceList.contains(pkMember)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.hzs.activity.base.service.IAcBaseConfigService;
|
||||
import com.hzs.activity.declaration.service.IAcDeclarationGiftConfigService;
|
||||
import com.hzs.activity.declaration.service.IAcDeclarationGiftRecordService;
|
||||
import com.hzs.common.core.enums.*;
|
||||
import com.hzs.common.domain.activity.declaration.AcDeclarationGiftConfig;
|
||||
import com.hzs.common.domain.activity.declaration.AcDeclarationGiftRecord;
|
||||
import com.hzs.activity.tourism.IAcTourismServiceApi;
|
||||
import com.hzs.activity.tourism.service.IAcTourismDataService;
|
||||
import com.hzs.common.core.constant.CountryConstants;
|
||||
import com.hzs.common.core.domain.R;
|
||||
import com.hzs.common.core.enums.EOrderType;
|
||||
import com.hzs.common.domain.activity.base.AcBaseConfig;
|
||||
import com.hzs.common.domain.member.base.CuMember;
|
||||
import com.hzs.common.domain.sale.order.SaOrder;
|
||||
|
|
@ -110,33 +110,38 @@ public class AcTourismServiceProvider implements IAcTourismServiceApi {
|
|||
Date targetDate = java.sql.Date.valueOf(LocalDate.now().minusDays(7));
|
||||
log.info("处理日期: {}", targetDate);
|
||||
|
||||
// 获取所有7天前有效的报单赠送活动
|
||||
List<AcBaseConfig> acBaseConfigList = iAcBaseConfigService.list(new LambdaQueryWrapper<AcBaseConfig>()
|
||||
.le(AcBaseConfig::getActStartDate, targetDate)
|
||||
.ge(AcBaseConfig::getActEndDate, targetDate)
|
||||
.eq(AcBaseConfig::getActType, EActType.DECLARATION_GIFT.getValue())
|
||||
.eq(AcBaseConfig::getDelFlag, EDelFlag.UN_DELETE.getValue()));
|
||||
if (acBaseConfigList.isEmpty()) {
|
||||
log.info("{}天前无有效报单赠送活动,处理结束", daysAgo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
// 查询订单
|
||||
List<SaOrder> orderList = iSaOrderService.list(new LambdaQueryWrapper<SaOrder>()
|
||||
.nested(w -> w.in(SaOrder::getOrderType, EOrderType.REGISTER_ORDER.getValue(), EOrderType.UPGRADE_ORDER.getValue())
|
||||
.or()
|
||||
.nested(x -> x.eq(SaOrder::getOrderType, EOrderType.REPURCHASE_ORDER.getValue())
|
||||
.eq(SaOrder::getOrderTypeExtend, 1)))
|
||||
.eq(SaOrder::getOrderTypeExtend, EOrderTypeExtend.REG_REP.getValue())))
|
||||
.apply("TRUNC(PAY_TIME) BETWEEN TRUNC(SYSDATE - {0}) AND TRUNC(SYSDATE - 7)", daysAgo)
|
||||
.eq(SaOrder::getOrderStatus, 1)
|
||||
.eq(SaOrder::getDelFlag, 0)
|
||||
.eq(SaOrder::getOrderStatus, EOrderStatus.PAY.getValue())
|
||||
.eq(SaOrder::getDelFlag, EDelFlag.UN_DELETE.getValue())
|
||||
);
|
||||
log.info("{}天无有效订单,处理结束", daysAgo);
|
||||
// 获取所有7天前有效的报单赠送活动
|
||||
List<AcBaseConfig> acBaseConfigList = iAcBaseConfigService.list(new LambdaQueryWrapper<AcBaseConfig>()
|
||||
.le(AcBaseConfig::getActStartDate, targetDate)
|
||||
.ge(AcBaseConfig::getActEndDate, targetDate)
|
||||
.eq(AcBaseConfig::getActType, 32)
|
||||
.eq(AcBaseConfig::getDelFlag, 0));
|
||||
if (acBaseConfigList.isEmpty()) {
|
||||
log.info("{}天前无有效报单赠送活动,处理结束", daysAgo);
|
||||
if (orderList.isEmpty()) {
|
||||
log.info("{}天无有效订单,处理结束", daysAgo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
// 报单赠送活动主键集合
|
||||
List<Long> declarationBaseIds = acBaseConfigList.stream().map(AcBaseConfig::getPkId).collect(Collectors.toList());
|
||||
// 查询所有报单赠送活动数据
|
||||
List<AcDeclarationGiftConfig> declarationGiftConfigs = iAcDeclarationGiftConfigService.list(new LambdaQueryWrapper<AcDeclarationGiftConfig>()
|
||||
.in(AcDeclarationGiftConfig::getPkBaseId, declarationBaseIds)
|
||||
.eq(AcDeclarationGiftConfig::getDelFlag, 0));
|
||||
.eq(AcDeclarationGiftConfig::getDelFlag, EDelFlag.UN_DELETE.getValue()));
|
||||
Map<String, AcDeclarationGiftConfig> configMap = declarationGiftConfigs.stream()
|
||||
.collect(Collectors.toMap(
|
||||
cfg -> cfg.getRegisterAuthority() + "_" + cfg.getSpecifyLevel(),
|
||||
|
|
@ -145,14 +150,16 @@ public class AcTourismServiceProvider implements IAcTourismServiceApi {
|
|||
));
|
||||
|
||||
orderList.forEach(order -> {
|
||||
// TODO 一天可能会有几百单,最好改成批量查询
|
||||
// 查看是否有重复订单
|
||||
int count = iAcDeclarationGiftRecordService.count(new LambdaQueryWrapper<AcDeclarationGiftRecord>()
|
||||
.eq(AcDeclarationGiftRecord::getOrderCode, order.getOrderCode())
|
||||
.eq(AcDeclarationGiftRecord::getDelFlag, 0));
|
||||
.eq(AcDeclarationGiftRecord::getDelFlag, EDelFlag.UN_DELETE.getValue()));
|
||||
if (count > 0) {
|
||||
log.warn("当前订单已同步至报单明细{}", order.getOrderCode());
|
||||
return;
|
||||
}
|
||||
// TODO 下面两个查询会员,报单会员可能都是同一个人,最好提前查询或者做个map存下来,防止多次查询数据库
|
||||
// 查询新会员信息
|
||||
R<CuMember> newMemberResult = iMemberServiceApi.getMember(order.getPkMember());
|
||||
CuMember newMember = newMemberResult.getData();
|
||||
|
|
@ -174,6 +181,7 @@ public class AcTourismServiceProvider implements IAcTourismServiceApi {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO 入库改成批量
|
||||
AcDeclarationGiftRecord record = AcDeclarationGiftRecord.builder()
|
||||
.pkRuleId(matchedConfig.getPkId())
|
||||
.pkBaseId(matchedConfig.getPkBaseId())
|
||||
|
|
@ -181,7 +189,7 @@ public class AcTourismServiceProvider implements IAcTourismServiceApi {
|
|||
.syncStatus(0)
|
||||
.build();
|
||||
record.setCreationTime(new Date());
|
||||
record.setDelFlag(0);
|
||||
record.setDelFlag(EDelFlag.UN_DELETE.getValue());
|
||||
record.setPkCreator(oldMember.getPkId());
|
||||
record.setPkCountry(pkCountry);
|
||||
// 插入数据库
|
||||
|
|
|
|||
|
|
@ -36,4 +36,26 @@
|
|||
and aba.pk_base_id = #{pkBaseId}
|
||||
</select>
|
||||
|
||||
<select id="queryBlood" resultType="long">
|
||||
<foreach collection="paramList" item="item" separator=" union ">
|
||||
select ${pkMember}
|
||||
from cu_member cm
|
||||
where cm.del_flag = 0
|
||||
and cm.member_code = #{item}
|
||||
start with cm.pk_id = #{pkMember}
|
||||
connect by cm.pk_id = prior cm.pk_parent
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="queryPlace" resultType="long">
|
||||
<foreach collection="paramList" item="item" separator=" union ">
|
||||
select ${pkMember}
|
||||
from cu_member cm
|
||||
where cm.del_flag = 0
|
||||
and cm.member_code = #{item}
|
||||
start with cm.pk_id = #{pkMember}
|
||||
connect by cm.pk_id = prior cm.pk_place_parent
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -56,25 +56,14 @@
|
|||
when act_end_date < sysdate then 2
|
||||
else 1 end) ACT_STATUS,
|
||||
ac.act_explain,
|
||||
nvl(draw.exist_draw_num, 1) exist_draw_num,
|
||||
pk_new_people,
|
||||
nvl(people.exist_new_people_gift, 1) exist_new_people_gift
|
||||
nvl(draw.exist_draw_num, 1) exist_draw_num
|
||||
from ac_base_config ac
|
||||
left join (
|
||||
select pk_base_id, 0 exist_draw_num
|
||||
from ac_draw_reward_num
|
||||
where del_flag = 0
|
||||
and pk_member = #{pkMember}
|
||||
and (total_surplus_num + available_surplus_num) > 0) draw
|
||||
on ac.pk_id = draw.pk_base_id
|
||||
left join (
|
||||
select distinct pk_base_id, pk_new_people, 0 exist_new_people_gift
|
||||
from ac_people_service
|
||||
where del_flag = 0
|
||||
and pk_member = #{pkMember}
|
||||
and plan_state = 0
|
||||
) people
|
||||
on ac.pk_id = people.pk_base_id
|
||||
and (total_surplus_num + available_surplus_num) > 0) draw on ac.pk_id = draw.pk_base_id
|
||||
where ac.del_flag = 0
|
||||
and ac.pk_country = #{pkCountry}
|
||||
and ac.dis_start_date <= sysdate
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* 活动基础权限表
|
||||
*
|
||||
* @author hzs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue