101captain
2022-02-22 d4ae014840dd3267c6cf7f7fc9942163ccc794b1
Merge branch 'hemenkou_dev' into dev

# Conflicts:
# springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
# springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/RabbitmqConfig.java
# springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java
# springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
16个文件已修改
3个文件已添加
666 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComActRaffleRecordApi.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/StreetApi.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/raffle/ComActRaffleRecordExcelVO.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/raffle/ComActRaffleRecordVO.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActRaffleRecordApi.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActRaffleRecordApi.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/RabbitmqConfig.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActRafflePrizeDao.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActRaffleRecordDao.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/message/RaffleMessage.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActRaffleRecordService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleRecordServiceImpl.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActRaffleRecordMapper.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/ComActRaffleRecordApi.java
New file
@@ -0,0 +1,105 @@
package com.panzhihua.applets.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO;
import com.panzhihua.common.service.community.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
/**
 * 抽奖活动中奖记录表(ComActRaffleRecord)表控制层
 * projectName 成都呐喊信息技术有限公司-智慧社区项目
 * description: 抽奖活动中奖记录表相关功能
 *
 * @author zzj
 * @since 2022-02-18 14:32:02
 */
@Slf4j
@Api(tags = {"获奖记录"})
@RestController
@RequestMapping("comActRaffleRecord")
public class ComActRaffleRecordApi extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private CommunityService communityService;
    /**
     * 分页查询所有数据
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询",response = ComActRaffleRecordVO.class)
    @PostMapping("queryAll")
    public R selectAll(@RequestBody CommonPage commonPage) {
        return this.communityService.selectAllComActRaffleRecord(commonPage);
    }
    @ApiOperation(value = "根据抽奖活动id获取奖品统计")
    @GetMapping("/queryPrize")
    public R queryPrize(@RequestParam("id")Long id){
        return this.communityService.queryPrize(id);
    }
    /**
     * 生成二维码
     * @param qrCodeVO
     * @return
     */
    @ApiOperation("生成二维码")
    @PostMapping("/getQRCode")
    public R getQRCode(@RequestBody QRCodeVO qrCodeVO){
        return this.communityService.getRaffleQRCode(qrCodeVO);
    }
    /**
     * 修改数据
     *
     * @param comActRaffleRecordVO 实体对象
     * @return 修改结果
     */
    @ApiOperation("核销接口")
    @PostMapping("/update")
    public R update(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO) {
        comActRaffleRecordVO.setStaffId(this.getUserId());
        comActRaffleRecordVO.setStaffTime(new Date());
        comActRaffleRecordVO.setStatus(2);
        return this.communityService.updateRaffleRecord(comActRaffleRecordVO);
    }
    /**
     * 新增数据
     *
     * @param comActRaffleRecordVO 实体对象
     * @return 新增结果
     */
    @ApiOperation("参加活动")
    @PostMapping
    public R insert(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO) {
        comActRaffleRecordVO.setCreateTime(new Date());
        comActRaffleRecordVO.setUserId(this.getUserId());
        comActRaffleRecordVO.setStatus(0);
        return communityService.insertRaffleRecord(comActRaffleRecordVO);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("详情")
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Long id) {
        return this.communityService.selectOneRaffleRecord(id);
    }
}
springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/StreetApi.java
@@ -52,19 +52,6 @@
    @PostMapping("addstreet")
    public R pageStreet(@RequestBody ComStreetVO comStreetVO) {
        R<ComStreetVO> r = communityService.addStreet(comStreetVO);
        if (R.isOk(r)) {
            AdministratorsUserVO administratorsUserVO = new AdministratorsUserVO();
            administratorsUserVO.setAccount(comStreetVO.getAccount());
            administratorsUserVO.setPassword(comStreetVO.getPassword());
            administratorsUserVO.setType(3);
            administratorsUserVO.setAreaId(null);
            administratorsUserVO.setStatus(1);
            administratorsUserVO.setSocialType(1);
            administratorsUserVO.setRoleId(777777777L);
            administratorsUserVO.setUserId(this.getUserId());
            administratorsUserVO.setStreetId(r.getData().getStreetId());
            userService.addUserBackstageProperty(administratorsUserVO);
        }
        return r;
    }
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/raffle/ComActRaffleRecordExcelVO.java
New file
@@ -0,0 +1,51 @@
package com.panzhihua.common.model.vos.community.raffle;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.net.URL;
import java.util.Date;
/**
 * @author zzj
 */
@Data
public class ComActRaffleRecordExcelVO {
    @ApiModelProperty(value = "昵称")
    @ExcelProperty(value = "昵称",index = 0)
    private String nickName;
    @ApiModelProperty(value = "姓名")
    @ExcelProperty(value = "姓名",index = 1)
    private String username;
    @ApiModelProperty(value = "联系电话")
    @ExcelProperty(value = "联系电话",index = 2)
    private String phone;
    /**
     * 创建时间
     */
    @ExcelProperty(value = "中奖时间",index = 3)
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @ApiModelProperty(value = "奖品名称")
    @ExcelProperty(value = "奖品名称",index = 4)
    private String prizeName;
    @ApiModelProperty(value = "奖品图片")
    @ExcelProperty(value = "奖品图片",index = 5)
    private URL imageUrl;
    @ApiModelProperty(value = "核销人名称")
    @ExcelProperty(value = "核销人",index = 6)
    private String staffName;
    @ApiModelProperty(value = "核销时间")
    @ExcelProperty(value = "核销时间",index = 7)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date staffTime;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/raffle/ComActRaffleRecordVO.java
@@ -1,5 +1,6 @@
package com.panzhihua.common.model.vos.community.raffle;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
@@ -57,7 +58,7 @@
    @ApiModelProperty(value = "核销时间")
    private Date staffTime;
    @ApiModelProperty(value = "0 已参加 1待兑奖 2已兑奖 3已失效")
    @ApiModelProperty(value = "0 已参加 1待兑奖 2已兑奖 3已失效 4未中奖")
    private Integer status;
    @ApiModelProperty(value = "抽奖id")
@@ -81,4 +82,18 @@
    @ApiModelProperty(value = "联系电话")
    private String phone;
    /**
     * 兑奖开始时间
     */
    @ApiModelProperty(value = "兑奖开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date raffleStartTime;
    /**
     * 兑奖结束时间
     */
    @ApiModelProperty(value = "兑奖结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date raffleStopTime;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -27,6 +27,7 @@
import com.panzhihua.common.model.vos.civil.ComActSocialWorkerDetailsVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.community.cluster.admin.ComClusterMemberExcelVO;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleVO;
import com.panzhihua.common.model.vos.community.social.*;
import io.swagger.annotations.ApiOperation;
@@ -8679,6 +8680,55 @@
    R deleteComActRaffle(@RequestParam("id") Long id);
    /**
     * 分页查询所有数据
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @PostMapping("/comActRaffleRecord/queryAll")
    R selectAllComActRaffleRecord(@RequestBody CommonPage commonPage);
    @GetMapping("/comActRaffleRecord/queryPrize")
    R queryPrize(@RequestParam("id")Long id);
    /**
     * 生成二维码
     * @param qrCodeVO
     * @return
     */
    @PostMapping("/comActRaffleRecord/getQRCode")
    R getRaffleQRCode(@RequestBody QRCodeVO qrCodeVO);
    /**
     * 修改数据
     *
     * @param comActRaffleRecordVO 实体对象
     * @return 修改结果
     */
    @PostMapping("/comActRaffleRecord/update")
    R updateRaffleRecord(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO);
    @PostMapping("/comActRaffleRecord")
    R insertRaffleRecord(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO);
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/comActRaffleRecord/{id}")
    R selectOneRaffleRecord(@PathVariable("id") Long id);
    /**
     * 导出
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @PostMapping("/comActRaffleRecord/export")
    R exportComActRaffleRecord(@RequestBody CommonPage commonPage);
    /**
     * [方法描述] 根据社区ID查询所属城市所在区区域代码,
     *
     * @param communityId
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java
@@ -349,6 +349,17 @@
    @PostMapping("adduserbackstageproperty")
    R addUserBackstageProperty(@RequestBody AdministratorsUserVO administratorsUserVO);
    /**
     * 更新
     *
     * @param administratorsUserVO
     *            编辑账户内容
     * @return 编辑结果
     */
    @PostMapping("updateStreet")
    R updateStreet(@RequestBody AdministratorsUserVO administratorsUserVO);
    /**
     * 编辑运营、社区后台账户
     * 
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActRaffleRecordApi.java
@@ -1,14 +1,29 @@
package com.panzhihua.community_backstage.api;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordExcelVO;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyExcelVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.SFTPUtil;
import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;
/**
@@ -30,4 +45,89 @@
    @Resource
    private CommunityService communityService;
    @Value("${excel.userurl}")
    private String excelUrl;
    // FTP 登录用户名
    @Value("${ftp.username}")
    private String userName;
    // FTP 登录密码
    @Value("${ftp.password}")
    private String password;
    // FTP 服务器地址IP地址
    @Value("${ftp.host}")
    private String host;
    // FTP 端口
    @Value("${ftp.port}")
    private int port;
    /**
     * 分页查询所有数据
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询",response = ComActRaffleRecordVO.class)
    @PostMapping("queryAll")
    public R selectAll(@RequestBody CommonPage commonPage) {
        return this.communityService.selectAllComActRaffleRecord(commonPage);
    }
    @ApiOperation(value = "根据抽奖活动id获取奖品统计")
    @GetMapping("/queryPrize")
    public R queryPrize(@RequestParam("id")Long id){
        return this.communityService.queryPrize(id);
    }
    @ApiOperation(value = "导出")
    @PostMapping("/export")
    public R export(@RequestBody CommonPage commonPage) {
        String name = "获奖名单.xlsx";
        String ftpUrl = "/mnt/data/web/excel/";
        // 用户搜索了就下载搜索的用户否则下载所有用户
        R r = communityService.exportComActRaffleRecord(commonPage);
        if (R.isOk(r)) {
            try {
                SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
                sftp.login();
                boolean existDir = sftp.isExistDir(ftpUrl + name);
                if (!existDir) {
                    String property = System.getProperty("user.dir");
                    String fileName = property + File.separator + name;
                    // 这里 需要指定写用哪个class去写
                    ExcelWriter excelWriter = null;
                    InputStream inputStream = null;
                    try {
                        excelWriter = EasyExcel.write(fileName, ComActRaffleRecordExcelVO.class)
                                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                                .registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet( "导出").build();
                        excelWriter.write(JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComActRaffleRecordExcelVO.class), writeSheet);
                        excelWriter.finish();
                        File file = new File(fileName);
                        inputStream = new FileInputStream(file);
                        sftp.uploadMore(ftpUrl, name, inputStream);
                        sftp.logout();
                        inputStream.close();
                        String absolutePath = file.getAbsolutePath();
                        boolean delete = file.delete();
                        log.info("删除excel【{}】结果【{}】", absolutePath, delete);
                    } finally {
                        // 千万别忘记finish 会帮忙关闭流
                        if (inputStream != null) {
                            inputStream.close();
                        }
                        if (excelWriter != null) {
                            excelWriter.finish();
                        }
                    }
                }
                return R.ok(excelUrl + name);
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }
        return r;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActRaffleRecordApi.java
@@ -6,8 +6,12 @@
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO;
import com.panzhihua.service_community.entity.ComActRaffleRecord;
import com.panzhihua.service_community.service.ComActRaffleRecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -47,35 +51,50 @@
    }
    /**
     * 生成二维码
     * @param qrCodeVO
     * @return
     */
    @ApiOperation("生成二维码")
    @PostMapping("/getQRCode")
    public R getQRCode(@RequestBody QRCodeVO qrCodeVO){
        return this.comActRaffleRecordService.queryQrCode(qrCodeVO);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Serializable id) {
        return R.ok(this.comActRaffleRecordService.getById(id));
    public R selectOne(@PathVariable("id") Long id) {
        return R.ok(this.comActRaffleRecordService.selectById(id));
    }
    /**
     * 新增数据
     *
     * @param comActRaffleRecord 实体对象
     * @param comActRaffleRecordVO 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody ComActRaffleRecord comActRaffleRecord) {
    public R insert(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO) {
        ComActRaffleRecord comActRaffleRecord=new ComActRaffleRecord();
        BeanUtils.copyProperties(comActRaffleRecordVO,comActRaffleRecord);
        return R.ok(this.comActRaffleRecordService.save(comActRaffleRecord));
    }
    /**
     * 修改数据
     *
     * @param comActRaffleRecord 实体对象
     * @param comActRaffleRecordVO 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    public R update(@RequestBody ComActRaffleRecord comActRaffleRecord) {
    public R update(@RequestBody ComActRaffleRecordVO comActRaffleRecordVO) {
        ComActRaffleRecord comActRaffleRecord=new ComActRaffleRecord();
        BeanUtils.copyProperties(comActRaffleRecordVO,comActRaffleRecord);
        return R.ok(this.comActRaffleRecordService.updateById(comActRaffleRecord));
    }
@@ -89,4 +108,15 @@
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comActRaffleRecordService.removeById(id));
    }
    /**
     * 分页查询所有数据
     *
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @PostMapping("export")
    public R export(@RequestBody CommonPage commonPage) {
        return this.comActRaffleRecordService.export(commonPage);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/config/RabbitmqConfig.java
@@ -21,6 +21,10 @@
    public static final String Order_ROUTING_KEY="order.key";
    public static final String Order_EXCHANGE="order.exchange";
    public static final String RAFFLE_QUEUE="raffle.queue";
    public static final String RAFFLE_ROUTING_KEY="raffle.key";
    public static final String RAFFLE_EXCHANGE="raffle.exchange";
    public static final String McsOrder_QUEUE="mcsOrder.queue";
    public static final String McsOrder_ROUTING_KEY="mcsOrder.key";
    public static final String McsOrder_EXCHANGE="mcsOrder.exchange";
@@ -44,6 +48,23 @@
    }
    @Bean
    public Queue raffleQueue(){
        return new Queue(RAFFLE_QUEUE,true,false,false,null);
    }
    @Bean
    public Exchange raffleExchange(){
        Map<String, Object> arguments = new HashMap<>();
        arguments.put("x-delayed-type", ExchangeTypes.DIRECT);
        return new CustomExchange(RAFFLE_EXCHANGE,"x-delayed-message",true,false,arguments);
    }
    @Bean
    public Binding raffleBinding(){
        return BindingBuilder.bind(raffleQueue()).to(raffleExchange()).with(RAFFLE_ROUTING_KEY).noargs();
    }
    @Bean
    public Queue mcsOrderQueue(){
        return new Queue(McsOrder_QUEUE,true,false,false,null);
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActRafflePrizeDao.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.common.model.vos.community.raffle.ComActRafflePrizeCount;
import com.panzhihua.common.model.vos.community.raffle.ComActRafflePrizeVO;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import org.apache.ibatis.annotations.Mapper;
import com.panzhihua.service_community.entity.ComActRafflePrize;
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActRaffleRecordDao.java
@@ -4,11 +4,14 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordExcelVO;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO;
import org.apache.ibatis.annotations.Mapper;
import com.panzhihua.service_community.entity.ComActRaffleRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
 * 抽奖活动中奖记录表(ComActRaffleRecord)表数据库访问层
@@ -35,4 +38,19 @@
     * @return
     */
    IPage<ComActRaffleRecordVO> pageList(Page page, @Param("commonPage")CommonPage commonPage);
    /**
     * 导出
     * @param commonPage
     * @return
     */
    List<ComActRaffleRecordExcelVO> export(@Param("commonPage")CommonPage commonPage);
    /**
     * 根据id查询
     * @param id
     * @return
     */
    ComActRaffleRecordVO selectById(Long id);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/message/RaffleMessage.java
New file
@@ -0,0 +1,90 @@
package com.panzhihua.service_community.message;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panzhihua.common.model.vos.community.raffle.ComActRaffleVO;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.ComActRaffleDao;
import com.panzhihua.service_community.dao.ComActRafflePrizeDao;
import com.panzhihua.service_community.dao.ComActRaffleRecordDao;
import com.panzhihua.service_community.entity.ComActRaffle;
import com.panzhihua.service_community.entity.ComActRafflePrize;
import com.panzhihua.service_community.entity.ComActRaffleRecord;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
 * @author zzj
 */
@Component
public class RaffleMessage {
    public static final String DELAYED_QUEUE="raffle.queue";
    @Resource
    private ComActRaffleDao comActRaffleDao;
    @Resource
    private ComActRaffleRecordDao comActRaffleRecordDao;
    @Resource
    private ComActRafflePrizeDao comActRafflePrizeDao;
    @Resource
    private RabbitTemplate rabbitTemplate;
    @RabbitListener(queues=DELAYED_QUEUE)
    public void doRaffle(ComActRaffleVO comActRaffleVO){
        ComActRaffle comActRaffle=comActRaffleDao.selectOne(new QueryWrapper<ComActRaffle>().lambda().eq(ComActRaffle::getId,comActRaffleVO.getId()));
        if(comActRaffle!=null&&comActRaffle.getStatus()==2&&comActRaffle.getLotteryTime().before(new Date())){
            List<ComActRafflePrize> comActRafflePrizeList=comActRafflePrizeDao.selectList(new QueryWrapper<ComActRafflePrize>().lambda().eq(ComActRafflePrize::getRaffleId,comActRaffleVO.getId()));
            if(StringUtils.isNotEmpty(comActRafflePrizeList)){
                List<ComActRaffleRecord> comActRaffleRecords=comActRaffleRecordDao.selectList(new QueryWrapper<ComActRaffleRecord>().lambda().eq(ComActRaffleRecord::getRaffleId,comActRaffleVO.getId()));
                if(StringUtils.isNotEmpty(comActRaffleRecords)){
                    Random random=new Random();
                    comActRafflePrizeList.forEach(comActRafflePrize -> {
                        int a=0;
                        for(int i=1;i<=comActRafflePrize.getSurplus();i++){
                            if(comActRaffleRecords.size()>0){
                                ComActRaffleRecord comActRaffleRecord=comActRaffleRecords.get(random.nextInt(comActRaffleRecords.size()));
                                comActRaffleRecord.setPrizeId(comActRafflePrize.getId());
                                comActRaffleRecord.setStatus(1);
                                comActRaffleRecordDao.updateById(comActRaffleRecord);
                                comActRaffleRecords.remove(comActRaffleRecord);
                                a++;
                            }
                        }
                        comActRafflePrize.setSurplus(comActRafflePrize.getSurplus()-a);
                        comActRafflePrizeDao.updateById(comActRafflePrize);
                    });
                }
            }
            comActRaffle.setStatus(3);
            comActRaffleDao.updateById(comActRaffle);
        }
        if(comActRaffle!=null&&comActRaffle.getStatus()==0&&comActRaffle.getStartTime().before(new Date())){
            comActRaffle.setStatus(1);
            comActRaffleDao.updateById(comActRaffle);
            rabbitTemplate.convertAndSend("raffle.exchange", "raffle.key", comActRaffleVO, message -> {
                message.getMessageProperties().setHeader("x-delay", dateToSecond(comActRaffle.getStopTime()));
                return message;
            });
        }
        if(comActRaffle!=null&&comActRaffle.getStatus()==1&&comActRaffle.getStopTime().before(new Date())){
            comActRaffle.setStatus(2);
            comActRaffleDao.updateById(comActRaffle);
            rabbitTemplate.convertAndSend("raffle.exchange", "raffle.key", comActRaffleVO, message -> {
                message.getMessageProperties().setHeader("x-delay", dateToSecond(comActRaffle.getLotteryTime()));
                return message;
            });
        }
    }
    private Long dateToSecond(Date expireTime){
        return DateUtil.between(new Date(),expireTime, DateUnit.MS);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActRaffleRecordService.java
@@ -3,6 +3,7 @@
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO;
import com.panzhihua.service_community.entity.ComActRaffleRecord;
/**
@@ -28,4 +29,26 @@
     * @return
     */
    R queryPrize(Long id);
    /**
     * 生成二维码
     * @param qrCodeVO
     * @return
     */
    R queryQrCode(QRCodeVO qrCodeVO);
    /**
     * 导出
     *
     * @param commonPage
     * @return
     */
    R export(CommonPage commonPage);
    /**
     * 根据Id查询
     * @param id
     * @return
     */
    R selectById(Long id);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleRecordServiceImpl.java
@@ -1,14 +1,17 @@
package com.panzhihua.service_community.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.raffle.ComActRafflePrizeCount;
import com.panzhihua.common.model.vos.community.warehouse.QRCodeVO;
import com.panzhihua.service_community.dao.ComActRafflePrizeDao;
import com.panzhihua.service_community.entity.ComActRaffleRecord;
import com.panzhihua.service_community.dao.ComActRaffleRecordDao;
import com.panzhihua.service_community.service.ComActRaffleRecordService;
import com.panzhihua.service_community.util.QRCodeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -39,4 +42,23 @@
        comActRafflePrizeCount.setComActRafflePrizeVOList(comActRafflePrizeDao.selectByRaffleId(id));
        return R.ok(comActRafflePrizeCount);
    }
    @Override
    public R queryQrCode(QRCodeVO qrCodeVO) {
        ComActRaffleRecord comActRaffleRecord=this.baseMapper.selectById(qrCodeVO.getId());
        if(comActRaffleRecord!=null){
            return R.ok(QRCodeUtil.getBase64QRCode(JSON.toJSONString(qrCodeVO)));
        }
        return R.fail("抽奖记录不存在");
    }
    @Override
    public R export(CommonPage commonPage) {
        return R.ok(this.baseMapper.export(commonPage));
    }
    @Override
    public R selectById(Long id) {
        return R.ok(this.baseMapper.selectById(id));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
@@ -53,9 +53,6 @@
    @Override
    @Transactional
    public R<ComStreetVO> addStreet(ComStreetVO comStreetVO) {
        String password = comStreetVO.getPassword();
        String encode = new BCryptPasswordEncoder().encode(password);
        comStreetVO.setPassword(encode);
        ComStreetDO comStreetDO = new ComStreetDO();
        LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda();
        param.eq(ComStreetDO::getName, comStreetVO.getName());
@@ -79,6 +76,10 @@
            BeanUtils.copyProperties(comStreetVO, comStreetDO);
            int insert = comStreetDAO.insert(comStreetDO);
            if (insert > 0) {
                AdministratorsUserVO administratorsUserVO1=new AdministratorsUserVO();
                administratorsUserVO1.setUserId(Long.parseLong(r.getData().toString()));
                administratorsUserVO1.setStreetId(comStreetDO.getStreetId());
                userService.updateStreet(administratorsUserVO1);
                ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
                BeanUtils.copyProperties(comStreetDO1, comStreetVO);
                return R.ok(comStreetVO);
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActRaffleRecordMapper.xml
@@ -21,9 +21,37 @@
    </select>
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO">
        select t.*, t1.image, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName
        select t.*, t1.image, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName,t4.raffle_start_time as raffleStartTime,t4.raffle_stop_time as raffleStopTime
        from com_act_raffle_record t
        left join com_act_raffle_prize t1 on t.staff_id = t1.id
        left join com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        left join com_act_raffle t4 on t.raffle_id = t4.id
        <where>
            <if test="commonPage.status!=null">
                and t.status = #{commonPage.status}
            </if>
            <if test="commonPage.keyword!=null and commonPage.keyword!=''">
                and (t2.name like concat('%',#{commonPage.keyword},'%') or t2.phone like
                concat('%',#{commonPage.keyword},'%') or t1.name like concat('%',#{commonPage.keyword},'%') )
            </if>
            <if test="commonPage.paramId !=null">
                and t.raffle_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.userId !=null">
                and t.user_id = #{commonPage.userId}
            </if>
            <if test="commonPage.paramId2 !=null">
                and t.staff_id = #{commonPage.paramId2}
            </if>
        </where>
        order by t.create_time desc
    </select>
    <select id="export" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordExcelVO">
        select t.*, t1.image as imageUrl, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName
        from com_act_raffle_record t
        left join com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        <where>
@@ -37,7 +65,17 @@
            <if test="commonPage.paramId !=null">
                and t.raffle_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.userId !=null">
                and t.user_id = #{commonPage.userId}
            </if>
        </where>
        order by t.create_time desc
    </select>
    <select id="selectById" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO">
        select t.*, t1.`name`, t1.image
        from com_act_raffle_record t
        LEFT JOIN com_act_raffle_prize t1 on t.prize_id = t1.id
        where t.id=#{id}
    </select>
</mapper>
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java
@@ -399,6 +399,18 @@
    }
    /**
     * 更新
     *
     * @param administratorsUserVO
     *            编辑账户内容
     * @return 编辑结果
     */
    @PostMapping("updateStreet")
    R updateStreet(@RequestBody AdministratorsUserVO administratorsUserVO) {
        return userService.updateStreetId(administratorsUserVO);
    }
    /**
     * 新增社区后台物业,社会组织,业主委员会账户
     *
     * @param administratorsUserVO
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java
@@ -813,4 +813,11 @@
     * @return
     */
    R bindOrAddMcsUser(BindUserPhoneDTO bindUserPhoneDTO);
    /**
     * 更新街道id
     * @param administratorsUserVO
     * @return
     */
    R updateStreetId(AdministratorsUserVO administratorsUserVO);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java
@@ -1237,25 +1237,23 @@
            List<Long> menu=new ArrayList<>();
            if(administratorsUserVO.getSocialType()==1){
                sysRoleDO.setRoleKey(Constants.STREET_ROLE_KEY + administratorsUserVO.getStreetId());
                menu.add(233L);
                menu.add(234L);
                menu.add(235L);
                menu.add(236L);
                menu.add(237L);
                menu.add(300L);
                menu.add(301L);
                menu.add(302L);
                menu.add(303L);
                menu.add(304L);
            }
            else if(administratorsUserVO.getSocialType()==2){
                sysRoleDO.setRoleKey("social_org" + administratorsUserVO.getStreetId());
                menu.add(233L);
                menu.add(76L);
                menu.add(234L);
                menu.add(236L);
                menu.add(237L);
                menu.add(238L);
                menu.add(300L);
                menu.add(301L);
                menu.add(302L);
                menu.add(303L);
            }
            else if(administratorsUserVO.getSocialType()==3){
                sysRoleDO.setRoleKey("social_org_member" + administratorsUserVO.getStreetId());
                menu.add(233L);
                menu.add(237L);
                menu.add(300L);
                menu.add(303L);
            }
            sysRoleDO.setRoleSort(0);
@@ -1270,7 +1268,7 @@
                // 新街道管理员角色设置固定三社权限
                MenuRoleVO menuRoleVO = new MenuRoleVO();
                menuRoleVO.setMenuIds(menu);
                menuRoleVO.setRoleId(roleId);
                menuRoleVO.setRoleId(sysRoleDO.getRoleId());
                this.putMenuRole(menuRoleVO);
            }
        }
@@ -2935,6 +2933,14 @@
        return R.ok(loginUserInfoVO);
    }
    @Override
    public R updateStreetId(AdministratorsUserVO administratorsUserVO) {
        SysUserDO sysUserDO=new SysUserDO();
        BeanUtils.copyProperties(administratorsUserVO,sysUserDO);
        userDao.updateById(sysUserDO);
        return R.ok();
    }
    /**
     * 微商业街新增商家账号
     * @param mcsMerchantDTO