xiaoyong931011
2023-10-13 7ecd2c9bb7b1a77fd2d55a59b2ce85c9ddb26ee7
redbagprod
14 files modified
154 ■■■■■ changed files
src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/AdminChatController.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/entity/ChatGroup.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/mapper/ChatUserMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java 31 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/IAdminChatService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/vo/AdminChatUserVo.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/vo/AdminGroupVo.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java 1 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java 12 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/ChatUserMapper.xml 8 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/chat/groupList.html 27 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java
@@ -48,4 +48,21 @@
    }
    // === 添加机器人  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 ===
}
src/main/java/cc/mrbird/febs/mall/controller/AdminChatController.java
@@ -197,6 +197,29 @@
     * @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) {
src/main/java/cc/mrbird/febs/mall/entity/ChatGroup.java
@@ -65,5 +65,9 @@
     * 模式类型 1:简单模式-正常模式 2:困难模式
     */
    private Integer modelType;
    /**
     * 机器人是否自动发动红包 1:是 0:否
     */
    private Integer autoSend;
}
src/main/java/cc/mrbird/febs/mall/mapper/ChatUserMapper.java
@@ -46,4 +46,6 @@
    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);
}
src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
@@ -3,24 +3,30 @@
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;
@@ -34,14 +40,27 @@
@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());
            }
        }
    }
}
src/main/java/cc/mrbird/febs/mall/service/IAdminChatService.java
@@ -49,4 +49,8 @@
    FebsResponse closeModelType(String userId);
    FebsResponse updateRegisterMember(AdminRegisterMemberVo adminRegisterMemberVo);
    FebsResponse openSwitchAutoSend(String id);
    FebsResponse closeSwitchAutoSend(String id);
}
src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java
@@ -252,4 +252,16 @@
        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();
    }
}
src/main/java/cc/mrbird/febs/mall/vo/AdminChatUserVo.java
@@ -47,4 +47,8 @@
     * 是否是机器人 0:否 1:是
     */
    private Integer isRobot;
    /**
     * 模式类型 1:简单模式-正常模式 2:困难模式
     */
    private Integer modelType;
}
src/main/java/cc/mrbird/febs/mall/vo/AdminGroupVo.java
@@ -38,4 +38,8 @@
     * 模式类型 1:简单模式-正常模式 2:困难模式
     */
    private Integer modelType;
    /**
     * 机器人是否自动发动红包 1:是 0:否
     */
    private Integer autoSend;
}
src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java
@@ -7,6 +7,11 @@
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";
src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java
@@ -6,6 +6,7 @@
@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;
src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java
@@ -58,4 +58,16 @@
                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);
    }
}
src/main/resources/mapper/modules/ChatUserMapper.xml
@@ -186,6 +186,7 @@
        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
@@ -224,4 +225,11 @@
        where id = #{id}
    </select>
    <update id="updateAutoSendByGroupId">
        update chat_group
        set
            auto_send = #{autoSend}
        where id = #{id}
    </update>
</mapper>
src/main/resources/templates/febs/views/modules/chat/groupList.html
@@ -49,6 +49,13 @@
    <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>
@@ -131,6 +138,7 @@
                    {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: '操作',
@@ -140,6 +148,25 @@
                ]]
            });
        }
        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);