Browse Source

Merge branch 'dev_v1.3.8_20221209'

# Conflicts:
#	cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheet.java
Eric 2 years ago
parent
commit
2d40d97c74

+ 6 - 1
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/AdminFeignService.java

@@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import java.math.BigDecimal;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Description
@@ -144,4 +143,10 @@ public interface AdminFeignService {
      */
     @GetMapping("/task/virtualNumber")
     HttpResponseResult<Boolean> virtualNumber();
+
+    /**
+     * 群发消息
+     */
+    @GetMapping("/task/batchSending")
+    HttpResponseResult<Boolean> batchSending();
 }

+ 22 - 0
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/BatchSendingTask.java

@@ -0,0 +1,22 @@
+package com.yonge.cooleshow.task.jobs;
+
+import com.yonge.cooleshow.api.feign.AdminFeignService;
+import com.yonge.cooleshow.task.core.BaseTask;
+import com.yonge.cooleshow.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 消息定时群发
+ */
+@Service
+public class BatchSendingTask extends BaseTask {
+
+    @Autowired
+    private AdminFeignService adminFeignService;
+
+    @Override
+    public void execute() throws TaskException {
+        Object o = adminFeignService.batchSending();
+    }
+}

+ 17 - 44
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/CustomerServiceReceiveController.java

@@ -7,6 +7,7 @@ import com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceReceiveService;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceReceiveWrapper;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
@@ -14,10 +15,9 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Objects;
 
 @Slf4j
 @Validated
@@ -36,22 +37,6 @@ public class CustomerServiceReceiveController {
     @Autowired
     private CustomerServiceReceiveService customerServiceReceiveService;
 
-	/**
-	 * 查询单条
-	 * @param id 详情ID
-	 * @return R<CustomerServiceReceiveVo.CustomerServiceReceive>
-	 */
-	@ApiOperation(value = "详情", notes = "客服群发接收-根据详情ID查询单条, 传入id")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
-    })
-    @GetMapping("/detail/{id}")
-    public HttpResponseResult<CustomerServiceReceiveVo.CustomerServiceReceive> detail(@PathVariable("id") Long id) {
-    
-    	CustomerServiceReceive wrapper = customerServiceReceiveService.detail(id);
-        
-        return HttpResponseResult.succeed(CustomerServiceReceiveVo.CustomerServiceReceive.from(JSON.toJSONString(wrapper)));
-	}
     
     /**
 	 * 查询分页
@@ -60,15 +45,12 @@ public class CustomerServiceReceiveController {
 	 */
     @ApiOperation(value = "查询分页", notes = "客服群发接收- 传入 CustomerServiceReceiveVo.CustomerServiceReceiveQuery") 
     @PostMapping("/page")
-    public HttpResponseResult<PageInfo<CustomerServiceReceiveVo.CustomerServiceReceive>> page(@RequestBody CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query) {
+    public HttpResponseResult<PageInfo<CustomerServiceReceiveWrapper.CustomerServiceReceive>> page(@RequestBody CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query) {
     
         // 查询数据
-        IPage<CustomerServiceReceive> pages = customerServiceReceiveService.selectPage(PageUtil.getPage(query), query);
-        // 数据类型转换
-        List<CustomerServiceReceiveVo.CustomerServiceReceive> records = JSON.parseArray(JSON.toJSONString(pages.getRecords()), 
-        	CustomerServiceReceiveVo.CustomerServiceReceive.class);
-        
-        return HttpResponseResult.succeed(PageUtil.getPageInfo(pages, records));
+        IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> pages = customerServiceReceiveService.selectPage(PageUtil.getPage(query), query);
+
+        return HttpResponseResult.succeed(PageUtil.pageInfo(pages));
 	}
     
     /**
@@ -78,29 +60,20 @@ public class CustomerServiceReceiveController {
 	 */
     @ApiOperation(value = "新增", notes = "客服群发接收- 传入 CustomerServiceReceiveVo.CustomerServiceReceive")
 	@PostMapping("/save")
-	public HttpResponseResult<Boolean> add(@Validated @RequestBody CustomerServiceReceiveVo.CustomerServiceReceive info) {
-    
-        // 新增数据
-        customerServiceReceiveService.save(JSON.parseObject(info.jsonString(), CustomerServiceReceive.class));
+	public HttpResponseResult<Boolean> add(@Validated @RequestBody List<CustomerServiceReceiveVo.CustomerServiceReceive> info) {
+
+		if (CollectionUtils.isEmpty(info)
+				|| info.stream().anyMatch(x -> Objects.isNull(x.getBatchSendingId()))) {
+			throw new BizException("无效的请求参数");
+		}
+
+		List<CustomerServiceReceive> receives = JSON.parseArray(JSON.toJSONString(info), CustomerServiceReceive.class);
+		// 新增数据
+        customerServiceReceiveService.saveBatch(receives);
         
         return HttpResponseResult.succeed();
 	}
     
-    /**
-	 * 修改
-	 * @param info CustomerServiceReceiveVo.CustomerServiceReceive
-	 * @return R<Boolean>
-	 */
-    @ApiOperation(value = "修改", notes = "客服群发接收- 传入 CustomerServiceReceiveVo.CustomerServiceReceive")
-	@PostMapping("/update")
-	public HttpResponseResult<Boolean> update(@Validated @RequestBody CustomerServiceReceiveVo.CustomerServiceReceive info) {
-                
-        // 更新数据
-        customerServiceReceiveService.updateById(JSON.parseObject(info.jsonString(), CustomerServiceReceive.class));
-        
-        return HttpResponseResult.succeed();
-	}
-
  	/**
 	 * 删除
 	 * @param id 详情ID

+ 26 - 1
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/task/TaskController.java

@@ -1,6 +1,17 @@
 package com.yonge.cooleshow.admin.task;
 
-import com.yonge.cooleshow.biz.dal.service.*;
+import com.yonge.cooleshow.biz.dal.service.ActivityPlanEvaluationService;
+import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
+import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
+import com.yonge.cooleshow.biz.dal.service.CustomerServiceBatchSendingService;
+import com.yonge.cooleshow.biz.dal.service.MusicAlbumService;
+import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.PlatformCashAccountRecordService;
+import com.yonge.cooleshow.biz.dal.service.TeacherStyleVideoService;
+import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;
+import com.yonge.cooleshow.biz.dal.service.UserBindingTeacherService;
+import com.yonge.cooleshow.biz.dal.service.UserOrderService;
+import com.yonge.cooleshow.biz.dal.service.VideoLessonGroupService;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -57,6 +68,8 @@ public class TaskController extends BaseController {
 
     @Autowired
     private VideoLessonGroupService videoLessonGroupService;
+    @Autowired
+    private CustomerServiceBatchSendingService customerServiceBatchSendingService;
 
     /***
      * 轮询用户订单
@@ -158,4 +171,16 @@ public class TaskController extends BaseController {
         return HttpResponseResult.succeed();
     }
 
+    /**
+     * 群发消息
+     */
+    @GetMapping("/batchSending")
+    public HttpResponseResult<Object> batchSending() {
+
+        // 群发消息定时
+        customerServiceBatchSendingService.scheduleSendMessage();
+
+        return HttpResponseResult.succeed();
+    }
+
 }

+ 22 - 36
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/MusicSheet.java

@@ -22,8 +22,18 @@ import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.ChargeTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.StringUtils;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Objects;
+
 /**
  * 曲谱表
  * @author yzp
@@ -224,19 +234,27 @@ public class MusicSheet implements Serializable {
 	@TableField("ext_config_json_")
 	@ApiModelProperty("曲目配置信息")
 	private String extConfigJson;
-	
+
 	@TableField("music_json_")
 	private String musicJSON;
-	
+
 	@TableField("music_svg_")
 	private String musicSvg;
-	
+
 	@TableField("music_jian_svg_")
 	private String musicJianSvg;
-	
+
 	@TableField("music_first_svg_")
 	private String musicFirstSvg;
 
+	@TableField("first_tone_")
+	@ApiModelProperty("首调")
+	private String firstTone;
+
+	@TableField("fixed_tone_")
+	@ApiModelProperty("固定调")
+	private String fixedTone;
+
 	@TableField("del_flag_")
 	@ApiModelProperty(value = "假删除标识 0:未删除 1:已删除")
 	private Boolean delFlag;
@@ -631,36 +649,4 @@ public class MusicSheet implements Serializable {
 		this.audioFileUrl = audioFileUrl;
 		return this;
 	}
-
-	public String getMusicJSON() {
-		return musicJSON;
-	}
-
-	public void setMusicJSON(String musicJSON) {
-		this.musicJSON = musicJSON;
-	}
-
-	public String getMusicSvg() {
-		return musicSvg;
-	}
-
-	public void setMusicSvg(String musicSvg) {
-		this.musicSvg = musicSvg;
-	}
-
-	public String getMusicJianSvg() {
-		return musicJianSvg;
-	}
-
-	public void setMusicJianSvg(String musicJianSvg) {
-		this.musicJianSvg = musicJianSvg;
-	}
-
-	public String getMusicFirstSvg() {
-		return musicFirstSvg;
-	}
-
-	public void setMusicFirstSvg(String musicFirstSvg) {
-		this.musicFirstSvg = musicFirstSvg;
-	}
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/CustomerServiceReceiveMapper.java

@@ -20,6 +20,6 @@ public interface CustomerServiceReceiveMapper extends BaseMapper<CustomerService
 	 * @param param CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery
 	 * @return List<CustomerServiceReceiveWrapper.CustomerServiceReceive>
 	 */
-	List<CustomerServiceReceive> selectPage(@Param("page") IPage<CustomerServiceReceive> page, @Param("param") CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery param);
+	List<CustomerServiceReceiveWrapper.CustomerServiceReceive> selectPage(@Param("page") IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> page, @Param("param") CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery param);
 	
 }

+ 5 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CustomerServiceBatchSendingService.java

@@ -53,4 +53,9 @@ public interface CustomerServiceBatchSendingService extends IService<CustomerSer
      * @param id 群发消息ID
      */
     void sendMessage(Long id);
+
+    /**
+     * 定时发送消息
+     */
+    void scheduleSendMessage();
 }

+ 3 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CustomerServiceReceiveService.java

@@ -20,11 +20,11 @@ public interface CustomerServiceReceiveService extends IService<CustomerServiceR
 
     /**
      * 分页查询
-     * @param page IPage<CustomerServiceReceive>
+     * @param page IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive>
      * @param query CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery
-     * @return IPage<CustomerServiceReceive>
+     * @return IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive>
      */
-    IPage<CustomerServiceReceive> selectPage(IPage<CustomerServiceReceive> page, CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query);
+    IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> selectPage(IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> page, CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query);
 	
     /**
      * 添加

+ 36 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceBatchSendingServiceImpl.java

@@ -13,6 +13,7 @@ import com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.MK;
 import com.yonge.cooleshow.biz.dal.enums.im.EImReceiveType;
 import com.yonge.cooleshow.biz.dal.enums.im.EImSendStatus;
 import com.yonge.cooleshow.biz.dal.enums.im.EImSendType;
@@ -38,6 +39,7 @@ import io.rong.models.response.ResponseResult;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -45,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.text.MessageFormat;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -417,7 +420,7 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
                         CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery receiveQuery = CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery
                                 .builder().build();
 
-                        Page<CustomerServiceReceive> page = PageUtil.getPage(1, 10);
+                        Page<CustomerServiceReceiveWrapper.CustomerServiceReceive> page = PageUtil.getPage(1, 10);
                         // 推送消息给指定用户
                         customerServiceReceiveService.selectPage(page, receiveQuery);
 
@@ -529,4 +532,36 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
         return messages;
     }
 
+
+    /**
+     * 定时发送消息
+     */
+    @Override
+    public void scheduleSendMessage() {
+
+        DistributedLock.of(redissonClient).runIfLockCanGet("scheduleSendMessage:LOCK", () -> {
+
+            // 定时发送时间
+            // 开始时间
+            Date startTime = DateTime.now().minusMinutes(1).toDate();
+            // 结束时间
+            Date endTime = DateTime.now().toDate();
+
+            List<CustomerServiceBatchSending> batchSendings = lambdaQuery()
+                    .between(CustomerServiceBatchSending::getSendTime, startTime, endTime)
+                    .eq(CustomerServiceBatchSending::getSendType, EImSendType.SCHEDULED)
+                    .eq(CustomerServiceBatchSending::getSendStatus, EImSendStatus.WAIT)
+                    .list();
+
+            if (CollectionUtils.isNotEmpty(batchSendings)) {
+                log.info("scheduleSendMessage time={}, size={}", DateTime.now().toString(MK.TIME_PATTERN), batchSendings.size());
+
+                for (List<CustomerServiceBatchSending> item : Lists.partition(batchSendings, 10)) {
+
+                    item.parallelStream().forEach(x -> sendMessage(x.getId()));
+                }
+
+            }
+        });
+    }
 }

+ 33 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceReceiveServiceImpl.java

@@ -4,12 +4,20 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive;
+import com.yonge.cooleshow.biz.dal.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.mapper.CustomerServiceReceiveMapper;
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceReceiveService;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceReceiveWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * 客服群发接收
  * 2022-12-09 10:49:10
@@ -18,6 +26,9 @@ import org.springframework.stereotype.Service;
 @Service
 public class CustomerServiceReceiveServiceImpl extends ServiceImpl<CustomerServiceReceiveMapper, CustomerServiceReceive> implements CustomerServiceReceiveService {
 
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
 	/**
      * 查询详情
      * @param id 详情ID
@@ -31,14 +42,31 @@ public class CustomerServiceReceiveServiceImpl extends ServiceImpl<CustomerServi
     
     /**
      * 分页查询
-     * @param page IPage<CustomerServiceReceive>
+     * @param page IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive>
      * @param query CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery
-     * @return IPage<CustomerServiceReceive>
+     * @return IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive>
      */
     @Override
-    public IPage<CustomerServiceReceive> selectPage(IPage<CustomerServiceReceive> page, CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query){
-        
-        return page.setRecords(baseMapper.selectPage(page, query));
+    public IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> selectPage(IPage<CustomerServiceReceiveWrapper.CustomerServiceReceive> page,
+                                                                                  CustomerServiceReceiveWrapper.CustomerServiceReceiveQuery query){
+
+        List<CustomerServiceReceiveWrapper.CustomerServiceReceive> receives = baseMapper.selectPage(page, query);
+
+        if (CollectionUtils.isNotEmpty(receives)) {
+
+            List<Long> userIds = receives.stream()
+                    .map(CustomerServiceReceiveWrapper.CustomerServiceReceive::getId).distinct().collect(Collectors.toList());
+
+            Map<Long, String> usernameMap = sysUserMapper.selectBatchIds(userIds).stream()
+                    .collect(Collectors.toMap(SysUser::getId, SysUser::getUsername, (o, n) -> n));
+
+            for (CustomerServiceReceiveWrapper.CustomerServiceReceive item : receives) {
+
+                item.setUserName(usernameMap.getOrDefault(item.getUserId(), ""));
+            }
+        }
+
+        return page.setRecords(receives);
     }
 	
     /**

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/im/CustomerServiceReceiveWrapper.java

@@ -29,6 +29,9 @@ public class CustomerServiceReceiveWrapper {
     
         @ApiModelProperty("关键字匹配")
 		private String keyword;
+
+        @ApiModelProperty("群发消息ID")
+        private Long batchSendingId;
         
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
@@ -64,6 +67,9 @@ public class CustomerServiceReceiveWrapper {
 
         @ApiModelProperty("创建时间")
         private Date createTime;
+
+        @ApiModelProperty("用户名称")
+        private String userName;
         
         public String jsonString() {
             return JSON.toJSONString(this);

+ 8 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CustomerServiceReceiveMapper.xml

@@ -7,15 +7,22 @@
     <!-- 表字段 -->
     <sql id="baseColumns">
          t.id_ AS id
+        , t.batch_sending_id_ AS batchSendingId
         , t.user_id_ AS userId
         , t.client_type_ AS clientType
         , t.create_time_ AS createTime
     </sql>
     
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive">
+    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceReceiveWrapper$CustomerServiceReceive">
 		SELECT         
         	<include refid="baseColumns" />
 		FROM customer_service_receive t
+		<where>
+            <if test="param.batchSendingId != null">
+                AND t.batch_sending_id_ = #{param.batchSendingId}
+            </if>
+        </where>
+        ORDER BY t.id_ DESC
 	</select>
     
 </mapper>

+ 2 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -75,6 +75,8 @@
         t.submit_audit_time_ as submitAuditTime,
         t.accompaniment_type_ as accompanimentType,
         t.remark_ as remark,
+        t.first_tone_ as firstTone,
+        t.fixed_tone_ as fixedTone,
         t.title_img_ as titleImg,
         t.reason_ as reason,
         t.music_img_ as musicImg,