| | |
| | | } |
| | | // === 添加机器人 end === |
| | | |
| | | // === 自动发送 start === |
| | | @Bean |
| | | public DirectExchange imAutoSendExchange() { |
| | | return new DirectExchange(RabbitQueueEnum.IM_REDBAG_AUTO_SEND.getExchange()); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue imAutoSendQueue() { |
| | | return new Queue(RabbitQueueEnum.IM_REDBAG_AUTO_SEND.getQueue()); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding imAutoSendBind() { |
| | | return BindingBuilder.bind(imAutoSendQueue()).to(imAutoSendExchange()).with(RabbitQueueEnum.IM_REDBAG_AUTO_SEND.getRoute()); |
| | | } |
| | | // === 自动发送 end === |
| | | |
| | | } |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("openSwitchAutoSend/{id}") |
| | | @ControllerEndpoint(operation = "会员列表---开启", exceptionMessage = "操作失败") |
| | | public FebsResponse openSwitchAutoSend(@NotNull(message = "{required}") @PathVariable String id) { |
| | | return iAdminChatService.openSwitchAutoSend(id); |
| | | } |
| | | /** |
| | | * 使用机器人---关闭 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("closeSwitchAutoSend/{id}") |
| | | @ControllerEndpoint(operation = "会员列表---关闭", exceptionMessage = "操作失败") |
| | | public FebsResponse closeSwitchAutoSend(@NotNull(message = "{required}") @PathVariable String id) { |
| | | return iAdminChatService.closeSwitchAutoSend(id); |
| | | } |
| | | |
| | | /** |
| | | * 使用机器人---开启 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("openSwitchUseRobot/{id}") |
| | | @ControllerEndpoint(operation = "会员列表---开启", exceptionMessage = "操作失败") |
| | | public FebsResponse openSwitchUseRobot(@NotNull(message = "{required}") @PathVariable String id) { |
| | |
| | | * 模式类型 1:简单模式-正常模式 2:困难模式 |
| | | */ |
| | | private Integer modelType; |
| | | /** |
| | | * 机器人是否自动发动红包 1:是 0:否 |
| | | */ |
| | | private Integer autoSend; |
| | | |
| | | } |
| | |
| | | void updateIsRobotByGroupId(@Param("id")String id, @Param("useRobot")int i); |
| | | |
| | | AdminGroupInfoVo getGroupInfoById(@Param("id")long id); |
| | | |
| | | void updateAutoSendByGroupId(@Param("id")String id, @Param("autoSend")int i); |
| | | } |
| | |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.mall.entity.ChatGroup; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMoneyFlow; |
| | | import cc.mrbird.febs.mall.mapper.ChatGroupMapper; |
| | | import cc.mrbird.febs.mall.mapper.ChatUserMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMoneyFlowMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMemberProfitService; |
| | | import cc.mrbird.febs.mall.service.impl.CommonService; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | |
| | | @Component |
| | | public class ProfitJob { |
| | | |
| | | // @Autowired |
| | | // private IMemberProfitService memberProfitService; |
| | | @Resource |
| | | private ChatUserMapper chatUserMapper; |
| | | |
| | | @Resource |
| | | private ChatGroupMapper chatGroupMapper; |
| | | |
| | | @Resource |
| | | private AgentProducer agentProducer; |
| | | |
| | | /** |
| | | * 代理分红 |
| | | */ |
| | | // @Scheduled(cron = "0 30 0 * * ?") |
| | | // public void profitJob() { |
| | | // memberProfitService.agentProfit(null); |
| | | // } |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void profitJob() { |
| | | QueryWrapper<ChatGroup> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("auto_send", 1); |
| | | List<ChatGroup> chatGroups = chatGroupMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(chatGroups)){ |
| | | for(ChatGroup chatGroup : chatGroups){ |
| | | agentProducer.sendAutoSendMsg(chatGroup.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | FebsResponse closeModelType(String userId); |
| | | |
| | | FebsResponse updateRegisterMember(AdminRegisterMemberVo adminRegisterMemberVo); |
| | | |
| | | FebsResponse openSwitchAutoSend(String id); |
| | | |
| | | FebsResponse closeSwitchAutoSend(String id); |
| | | } |
| | |
| | | agentProducer.sendAddRobotMsg(adminRegisterMemberVo.getInviteId()); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse openSwitchAutoSend(String id) { |
| | | this.baseMapper.updateAutoSendByGroupId(id,1); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse closeSwitchAutoSend(String id) { |
| | | this.baseMapper.updateAutoSendByGroupId(id,0); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |
| | |
| | | * 是否是机器人 0:否 1:是 |
| | | */ |
| | | private Integer isRobot; |
| | | /** |
| | | * 模式类型 1:简单模式-正常模式 2:困难模式 |
| | | */ |
| | | private Integer modelType; |
| | | } |
| | |
| | | * 模式类型 1:简单模式-正常模式 2:困难模式 |
| | | */ |
| | | private Integer modelType; |
| | | /** |
| | | * 机器人是否自动发动红包 1:是 0:否 |
| | | */ |
| | | private Integer autoSend; |
| | | } |
| | |
| | | public class QueueConstants { |
| | | |
| | | /** |
| | | * 自动发送 |
| | | */ |
| | | public static final String QUEUE_IM_REDBAG_AUTO_SEND = "queue_im_redbag_auto_send"; |
| | | |
| | | /** |
| | | * 添加机器人 |
| | | */ |
| | | public static final String QUEUE_IM_REDBAG_ADD_ROBOT = "queue_im_redbag_add_robot"; |
| | |
| | | @Getter |
| | | public enum RabbitQueueEnum { |
| | | |
| | | IM_REDBAG_AUTO_SEND("exchange_im_redbag_auto_send", "route_key_im_redbag_auto_send", QueueConstants.QUEUE_IM_REDBAG_AUTO_SEND), |
| | | IM_REDBAG_GET_ADD_ROBOT("exchange_im_redbag_add_robot", "route_key_im_redbag_add_robot", QueueConstants.QUEUE_IM_REDBAG_ADD_ROBOT); |
| | | |
| | | private String exchange; |
| | |
| | | correlationData); |
| | | } |
| | | |
| | | /** |
| | | * 自动发送 |
| | | */ |
| | | public void sendAutoSendMsg(Long groupId) { |
| | | log.info("自动发送:{}", groupId); |
| | | CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); |
| | | rabbitTemplate.convertAndSend(RabbitQueueEnum.IM_REDBAG_AUTO_SEND.getExchange(), |
| | | RabbitQueueEnum.IM_REDBAG_AUTO_SEND.getRoute(), |
| | | groupId, |
| | | correlationData); |
| | | } |
| | | |
| | | } |
| | |
| | | a.amount_min amountMin, |
| | | a.amount_max amountMax, |
| | | a.red_bag_cnt redBagCnt, |
| | | a.auto_send autoSend, |
| | | b.phone phone, |
| | | b.nick_name nickName, |
| | | a.create_time createTime |
| | |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <update id="updateAutoSendByGroupId"> |
| | | update chat_group |
| | | set |
| | | auto_send = #{autoSend} |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchUseRobot"> |
| | | {{# } }} |
| | | </script> |
| | | <script type="text/html" id="switchAutoSend"> |
| | | {{# if(d.autoSend === 1) { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchAutoSend"> |
| | | {{# } else { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchAutoSend"> |
| | | {{# } }} |
| | | </script> |
| | | <script type="text/html" id="isModelType"> |
| | | {{# if(d.modelType === 1) { }} |
| | | <span>简单模式</span> |
| | |
| | | {field: 'amountMax', title: '下限', minWidth: 100,align:'center'}, |
| | | {field: 'redBagCnt', title: '红包个数', minWidth: 100,align:'center'}, |
| | | {field: 'useRobot', title: '使用机器人', templet: '#switchUseRobot', minWidth: 80,align:'center'}, |
| | | {field: 'autoSend', title: '自动发红包', templet: '#switchAutoSend', minWidth: 180,align:'center'}, |
| | | {templet:"#isModelType", title: '模式', minWidth: 150,align:'center'}, |
| | | {field: 'createTime', title: '创建时间', minWidth: 180,align:'center'}, |
| | | {title: '操作', |
| | |
| | | ]] |
| | | }); |
| | | } |
| | | form.on('switch(switchAutoSend)', function (data) { |
| | | if (data.elem.checked) { |
| | | openSwitchAutoSend(data.value); |
| | | } else { |
| | | closeSwitchAutoSend(data.value); |
| | | } |
| | | }) |
| | | function openSwitchAutoSend(id) { |
| | | febs.get(ctx + 'admin/chat/openSwitchAutoSend/' + id, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | function closeSwitchAutoSend(id) { |
| | | febs.get(ctx + 'admin/chat/closeSwitchAutoSend/' + id, null, function () { |
| | | febs.alert.success('操作成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | form.on('switch(switchUseRobot)', function (data) { |
| | | if (data.elem.checked) { |
| | | openSwitchUseRobot(data.value); |