xiaoyong931011
2023-10-13 751120d03b7e47ef82fbc4ac28e0628b15c1cd1e
redbagprod
2 files added
7 files modified
313 ■■■■■ changed files
src/main/java/cc/mrbird/febs/mall/controller/AdminChatController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/ViewChatController.java 10 ●●●●● 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 22 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/IAdminChatService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/vo/AdminRedBagVo.java 53 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/ChatUserMapper.xml 19 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/chat/redBagList.html 190 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/AdminChatController.java
@@ -262,4 +262,13 @@
    public FebsResponse updateRegisterMember(@Valid AdminRegisterMemberVo adminRegisterMemberVo) {
        return iAdminChatService.updateRegisterMember(adminRegisterMemberVo);
    }
    /**
     * 红包列表
     */
    @GetMapping("redBagList")
    public FebsResponse redBagList(ChatUser chatUser, QueryRequest request) {
        Map<String, Object> data = getDataTable(iAdminChatService.getRedBagList(chatUser, request));
        return new FebsResponse().success().data(data);
    }
}
src/main/java/cc/mrbird/febs/mall/controller/ViewChatController.java
@@ -144,4 +144,14 @@
        model.addAttribute("groupInfo", data);
        return FebsUtil.view("modules/chat/groupEdit");
    }
    /**
     * 红包列表
     * @return
     */
    @GetMapping("redBagList")
    @RequiresPermissions("redBagList:view")
    public String redBagList() {
        return FebsUtil.view("modules/chat/redBagList");
    }
}
src/main/java/cc/mrbird/febs/mall/mapper/ChatUserMapper.java
@@ -48,4 +48,6 @@
    AdminGroupInfoVo getGroupInfoById(@Param("id")long id);
    void updateAutoSendByGroupId(@Param("id")String id, @Param("autoSend")int i);
    IPage<AdminRedBagVo> selectRedBagListInPage(Page<AdminRedBagVo> page, @Param("record")ChatUser chatUser);
}
src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
@@ -52,15 +52,15 @@
    /**
     * 代理分红
     */
    @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());
            }
        }
    }
//    @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
@@ -53,4 +53,6 @@
    FebsResponse openSwitchAutoSend(String id);
    FebsResponse closeSwitchAutoSend(String id);
    IPage<AdminRedBagVo> getRedBagList(ChatUser chatUser, QueryRequest request);
}
src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java
@@ -264,4 +264,10 @@
        this.baseMapper.updateAutoSendByGroupId(id,0);
        return new FebsResponse().success();
    }
    @Override
    public IPage<AdminRedBagVo> getRedBagList(ChatUser chatUser, QueryRequest request) {
        Page<AdminRedBagVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        return this.baseMapper.selectRedBagListInPage(page, chatUser);
    }
}
src/main/java/cc/mrbird/febs/mall/vo/AdminRedBagVo.java
New file
@@ -0,0 +1,53 @@
package cc.mrbird.febs.mall.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class AdminRedBagVo {
    private Long id;
    /**
     * 消息ID
     */
    private Long msgId;
    /**
     * 红包z总个数
     */
    private Integer totalCnt;
    /**
     * 剩余红包个数
     */
    private Integer avaCnt;
    /**
     * 金额
     */
    private BigDecimal amount;
    /**
     * 剩余金额
     */
    private BigDecimal amountAva;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 发送方
     */
    private Long fromUserId;
    private String nickName;
    /**
     * 接收方
     */
    private Long toUserId;
    /**
     * 雷
     */
    private Integer boomNum;
    private String msgType;
    private String groupName;
}
src/main/resources/mapper/modules/ChatUserMapper.xml
@@ -232,4 +232,23 @@
        where id = #{id}
    </update>
    <select id="selectRedBagListInPage" resultType="cc.mrbird.febs.mall.vo.AdminRedBagVo">
        select
        a.*,
        b.nick_name nickName,
        c.name groupName
        from chat_red_bag a
        left join chat_user b on b.user_id = a.from_user_id
        left join chat_group c on c.id = a.to_user_id
        <where>
            a.msg_type = 'GROUP'
            <if test="record != null">
                <if test="record.name != null and record.name != ''">
                    and c.name like CONCAT('%', CONCAT(#{record.name}, '%'))
                </if>
            </if>
        </where>
        order by a.create_time desc
    </select>
</mapper>
src/main/resources/templates/febs/views/modules/chat/redBagList.html
New file
@@ -0,0 +1,190 @@
<div class="layui-fluid layui-anim febs-anim" id="febs-red-bag-list" lay-title="红包列表">
    <div class="layui-row febs-container">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body febs-table-full">
                    <form class="layui-form layui-table-form" lay-filter="group-table-form">
                        <div class="layui-row">
                            <div class="layui-col-md10">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">群组名称:</label>
                                        <div class="layui-input-inline">
                                            <input type="text" placeholder="群组名称" name="name" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
                                    <i class="layui-icon">&#xe848;</i>
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
                                    <i class="layui-icon">&#xe79b;</i>
                                </div>
                            </div>
                        </div>
                    </form>
                    <table lay-filter="redBagTable" lay-data="{id: 'redBagTable'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<!--1:成功 2:失败 3:进行中-->
<script type="text/html" id="status-type">
    {{#
    var status = {
    1: {title: '-', color: ''},
    2: {title: '成功', color: 'green'},
    3: {title: '进行中', color: 'orange'},
    }[d.status];
    }}
    <span class="layui-badge febs-bg-{{status.color}}">{{ status.title }}</span>
</script>
<script type="text/html" id="switchUseRobot">
    {{# if(d.useRobot === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchUseRobot">
    {{# } else { }}
    <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="isMsgType">
    {{# if(d.msgType === 'SINGLE') { }}
    <span>个人</span>
    {{# } else { }}
    <span>群聊</span>
    {{# } }}
</script>
<style>
    .layui-form-onswitch {
        background-color: #5FB878 !important;
    }
</style>
<!-- 表格操作栏 end -->
<script data-th-inline="none" type="text/javascript">
    // 引入组件并初始化
    layui.use([ 'jquery', 'form', 'table', 'febs'], function () {
        var $ = layui.jquery,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            $view = $('#febs-red-bag-list'),
            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'phone', type: null},
            tableIns;
        form.render();
        // 表格初始化
        initTable();
        table.on('tool(redBagTable)', function (obj) {
            var data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'editGroup') {
                febs.modal.open('编辑', 'modules/chat/groupInfo/' + data.id, {
                    btn: ['提交', '取消'],
                    // area:['100%','100%'],
                    yes: function (index, layero) {
                        $('#febs-group-edit').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
        });
        // 查询按钮
        $query.on('click', function () {
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            tableIns.reload({where: params, page: {curr: 1}});
        });
        // 刷新按钮
        $reset.on('click', function () {
            $searchForm[0].reset();
            sortObject.type = 'null';
            tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
        });
        // 获取查询参数
        function getQueryParams() {
            return {
                name: $searchForm.find('input[name="name"]').val().trim(),
            };
        }
        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'redBagTable',
                url: ctx + 'admin/chat/redBagList',
                cols: [[
                    {field: 'id', title: '编号', minWidth: 100,align:'center'},
                    {field: 'nickName', title: '发送方', minWidth: 100,align:'center'},
                    {templet:"#isMsgType", title: '类型', minWidth: 100,align:'center'},
                    {field: 'groupName', title: '接收方', minWidth: 200,align:'center'},
                    {field: 'totalCnt', title: '红包总个数', minWidth: 100,align:'center'},
                    {field: 'avaCnt', title: '剩余个数', minWidth: 100,align:'center'},
                    {field: 'amount', title: '金额', minWidth: 100,align:'center'},
                    {field: 'amountAva', title: '剩余金额', minWidth: 100,align:'center'},
                    {field: 'boomNum', title: '雷', minWidth: 100,align:'center'},
                    {field: 'createTime', title: '创建时间', minWidth: 180,align:'center'},
                    // {title: '操作',
                    //     templet: function (d) {
                    //         return '<button class="layui-btn layui-btn-normal layui-btn-xs layui-btn-success" lay-event="editGroup" shiro:hasPermission="editGroup:info">编辑</button>'
                    //     },minWidth: 150,align:'center'}
                ]]
            });
        }
        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);
            } else {
                closeSwitchUseRobot(data.value);
            }
        })
        function openSwitchUseRobot(id) {
            febs.get(ctx + 'admin/chat/openSwitchUseRobot/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
        function closeSwitchUseRobot(id) {
            febs.get(ctx + 'admin/chat/closeSwitchUseRobot/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
    })
</script>