Explorar el Código

Merge branch 'dev_share_20221202'

liujunchi hace 2 años
padre
commit
3def9f3275

+ 5 - 0
cooleshow-common/pom.xml

@@ -49,6 +49,11 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-oauth2</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>org.springframework.security.oauth</groupId>
+			<artifactId>spring-security-oauth2</artifactId>
+			<version>2.3.3.RELEASE</version>
+		</dependency>
 
 		<dependency>
 			<groupId>com.baomidou</groupId>

+ 7 - 2
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/io/request/im/IMNotifyMessageVO.java

@@ -1,16 +1,15 @@
 package com.yonge.cooleshow.admin.io.request.im;
 
 import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.Serializable;
 import java.util.List;
-import java.util.Optional;
 
 /**
  * 系统IM通知信息
@@ -39,6 +38,12 @@ public class IMNotifyMessageVO implements Serializable {
     @ApiModelProperty(value = "图片文件地址")
     private String imgUrl;
 
+    @ApiModelProperty("用户身份")
+    private ClientEnum clientType;
+
+    @ApiModelProperty("声部ID")
+    private String subjectId;
+
     public String jsonString() {
 
         return JSON.toJSONString(this);

+ 11 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/SysUserMapper.java

@@ -1,11 +1,12 @@
 package com.yonge.cooleshow.biz.dal.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.vo.CouponIssueUserVo;
+import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerService;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -30,8 +31,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      * @param keyword 查询条件
      * @return
      */
-    List<CouponIssueUserVo> queryCouponIssueUser(@Param("iPage") IPage<CouponIssueUserVo> iPage, @Param(
-            "client") ClientEnum client, @Param("keyword") String keyword);
+    List<CouponIssueUserVo> queryCouponIssueUser(@Param("iPage") IPage<CouponIssueUserVo> iPage,
+                                                 @Param("client") ClientEnum client, @Param("keyword") String keyword);
 
 
     /***
@@ -42,4 +43,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      * @return: java.lang.Integer
      */
     Integer updateUserCard(@Param("param") RealnameAuthReq param);
+
+    /**
+     * 客服消息接收者
+     * @param message 客服消息
+     * @return List<CustomerService.MessageReceives>
+     */
+    List<CustomerService.MessageReceives> selectMessageReceives(@Param("param") CustomerService.NotifyMessage message);
 }

+ 13 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/PlatformCashAccountRecordService.java

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.PlatformCashAccountRecordDao;
 import com.yonge.cooleshow.biz.dal.dto.search.PlatformCashAccountRecordSearch;
 import com.yonge.cooleshow.biz.dal.entity.PlatformCashAccountRecord;
+import com.yonge.cooleshow.biz.dal.enums.AccountBizTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.InOrOutEnum;
 import com.yonge.cooleshow.biz.dal.vo.PlatformCashAccountRecordSummaryVo;
 
 import java.util.List;
@@ -49,5 +51,16 @@ public interface PlatformCashAccountRecordService extends IService<PlatformCashA
      * @param goodType
      */
     void mallRecordedRecord(Long productSkuId, String orderSn, String goodType);
+
+
+    /**
+     * 更新入账状态成功
+     *
+     * @param orderNo 订单号
+     * @param bizType 订单类型
+     * @param bizId 业务id
+     * @param type 收入 / 支出
+     */
+    void recordedRecord(String orderNo, AccountBizTypeEnum bizType, Long bizId, InOrOutEnum type);
 }
 

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -123,6 +123,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     private UserAccountRecordService userAccountRecordService;
     @Autowired
     private UserOrderService userOrderService;
+
+    @Autowired
+    private PlatformCashAccountRecordService platformCashAccountRecordService;
     
     @Autowired
     private StudentService studentService;
@@ -1880,6 +1883,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 UserAccountRecordVo record = userAccountRecordService.detail(dto.getOrderNo(), dto.getBizType(), dto.getBizId());
                 if (null != record) {
                     userAccountService.accountChange(record, PostStatusEnum.RECORDED);
+                    platformCashAccountRecordService.recordedRecord(dto.getOrderNo(), dto.getBizType(), dto.getBizId(),InOrOutEnum.OUT);
                 }
             }
             Set<Long> bizIds = list.stream().map(UserAccountRecordDto::getBizId).collect(Collectors.toSet());

+ 28 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImUserFriendServiceImpl.java

@@ -269,14 +269,34 @@ public class ImUserFriendServiceImpl extends ServiceImpl<ImUserFriendDao, ImUser
             throw new BizException("无效的客服联系方式");
         }
 
-        LambdaQueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> wrapper = Wrappers.<com.yonge.cooleshow.biz.dal.entity.SysUser>lambdaQuery()
-                .select(com.yonge.cooleshow.biz.dal.entity.SysUser::getId,
-                        com.yonge.cooleshow.biz.dal.entity.SysUser::getUsername)
-                .in(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, info.getReceives());
-
-        wrapper.last("LIMIT 1000");
-        // 接收者信息
-        List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(wrapper);
+        List<String> receiveUserIds;
+        if (Objects.nonNull(info.getClientType())) {
+
+            receiveUserIds = sysUserMapper.selectMessageReceives(info).stream()
+                    .map(x -> String.valueOf(x.getUserId()))
+                    .collect(Collectors.toList());
+            if (ClientEnum.STUDENT == info.getClientType()) {
+                receiveUserIds = receiveUserIds.stream()
+                        .map(x -> MessageFormat.format("{0}:STUDENT", x))
+                        .collect(Collectors.toList());
+            }
+        } else {
+
+            LambdaQueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> wrapper = Wrappers.<com.yonge.cooleshow.biz.dal.entity.SysUser>lambdaQuery()
+                    .select(com.yonge.cooleshow.biz.dal.entity.SysUser::getId,
+                            com.yonge.cooleshow.biz.dal.entity.SysUser::getUsername)
+                    .in(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, info.getReceives());
+
+            wrapper.last("LIMIT 1500");
+            // 接收者信息
+            List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(wrapper);
+
+            // 分批次发送用户消息
+            receiveUserIds = sysUsers.stream()
+                    .map(com.yonge.cooleshow.biz.dal.entity.SysUser::getId)
+                    .map(String::valueOf)
+                    .collect(Collectors.toList());
+        }
 
         // 发送图片消息
         ImgMessage imgMessage = new ImgMessage(imageToBase64(info.getImgMessage(), "png"), "", info.getImgUrl());
@@ -292,12 +312,6 @@ public class ImUserFriendServiceImpl extends ServiceImpl<ImUserFriendDao, ImUser
                 new PushExt.APNs("", ""),
                 new PushExt.OPPO(""));
 
-        // 分批次发送用户消息
-        List<String> receiveUserIds = sysUsers.stream()
-                .map(com.yonge.cooleshow.biz.dal.entity.SysUser::getId)
-                .map(String::valueOf)
-                .collect(Collectors.toList());
-
         String senderId = String.valueOf(senderUser.getId());
         PrivateMessage privateMessage;
         ResponseResult privateResult;

+ 15 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PlatformCashAccountRecordServiceImpl.java

@@ -1,10 +1,13 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import com.yonge.cooleshow.biz.dal.enums.InOrOutEnum;
 import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;
+import com.yonge.cooleshow.common.enums.PostStatusEnum;
 import com.yonge.toolset.base.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,8 +67,6 @@ public class PlatformCashAccountRecordServiceImpl extends ServiceImpl<PlatformCa
     public boolean updateWaitRecord() {
         //平台账户修改
         List<String> paramNames = new ArrayList<>();
-        paramNames.add(AccountBizTypeEnum.PRACTICE.getCode());
-        paramNames.add(AccountBizTypeEnum.LIVE.getCode());
         paramNames.add(AccountBizTypeEnum.LIVE_SHARE.getCode());
         paramNames.add(AccountBizTypeEnum.VIDEO.getCode());
         paramNames.add(AccountBizTypeEnum.VIDEO_SHARE.getCode());
@@ -102,5 +103,17 @@ public class PlatformCashAccountRecordServiceImpl extends ServiceImpl<PlatformCa
 
         baseMapper.mallRecordedRecord(orderSn, goodType, productSkuId);
     }
+
+    @Override
+    public void recordedRecord(String orderNo, AccountBizTypeEnum bizType, Long bizId, InOrOutEnum type) {
+        this.lambdaUpdate()
+                .eq(PlatformCashAccountRecord::getOrderNo,orderNo)
+                .eq(PlatformCashAccountRecord::getBizType,bizId)
+                .eq(PlatformCashAccountRecord::getBizId,bizId)
+                .eq(PlatformCashAccountRecord::getInOrOut,type)
+                .set(PlatformCashAccountRecord::getPostStatus, PostStatusEnum.RECORDED)
+                .set(PlatformCashAccountRecord::getUpdateTime,new Date())
+                .update();
+    }
 }
 

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

@@ -91,7 +91,7 @@ public class UserAccountRecordServiceImpl extends ServiceImpl<UserAccountRecordD
 
     @Override
     public void updateWaitRecord() {
-        //平台账户修改
+        //老师账户修改
         List<String> paramNames = new ArrayList<>();
         paramNames.add(AccountBizTypeEnum.ACTI_REGIST_SHARE.getCode());
         paramNames.add(AccountBizTypeEnum.LIVE_SHARE.getCode());

+ 13 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -959,21 +959,24 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
             platformFeeRate = BigDecimal.ONE;
         }
         BigDecimal platformFee = expectPrice.multiply(platformFeeRate).setScale(2, RoundingMode.HALF_UP);
+        BigDecimal teacherFee = expectPrice.subtract(platformFee);
         platformFee = platformFee.subtract(orderDetailVo.getCouponAmount());
 
         if (platformFee.compareTo(BigDecimal.ZERO) > 0) {
-            PlatformCashAccountRecord platformCashAccountRecord;
-            if (GoodTypeEnum.PINAO_ROOM.equals(orderDetailVo.getGoodType())) {
-                platformCashAccountRecord = new PlatformCashAccountRecord(orderDetailVo.getUserId(), platformFee,
-                        InOrOutEnum.IN, PostStatusEnum.RECORDED, AccountBizTypeEnum.PIAON_ROOM, orderDetailVo.getBizId(),
-                        orderDetailVo.getOrderNo(), new Date());
-            } else {
-                AccountBizTypeEnum bizTypeEnum = AccountBizTypeEnum.valueOf(orderDetailVo.getGoodType().getCode());
-                platformCashAccountRecord = new PlatformCashAccountRecord(orderDetailVo.getUserId(), platformFee,
+            // 订单实收
+            AccountBizTypeEnum bizTypeEnum = AccountBizTypeEnum.valueOf(orderDetailVo.getGoodType().getCode());
+            PlatformCashAccountRecord platformCashAccountRecord = new PlatformCashAccountRecord(orderDetailVo.getUserId(), orderDetailVo.getActualPrice(),
                         InOrOutEnum.IN, PostStatusEnum.RECORDED, bizTypeEnum, orderDetailVo.getBizId(),
                         orderDetailVo.getOrderNo(), new Date());
-            }
             platformCashAccountRecordService.save(platformCashAccountRecord);
+            // 支出给老师金额
+            if (teacherFee.compareTo(BigDecimal.ZERO) >0) {
+                platformCashAccountRecord = new PlatformCashAccountRecord(orderDetailVo.getUserId(), teacherFee,
+                                              InOrOutEnum.OUT, PostStatusEnum.WAIT, bizTypeEnum, orderDetailVo.getBizId(),
+                                              orderDetailVo.getOrderNo(), accountPeriodTime);
+                platformCashAccountRecordService.save(platformCashAccountRecord);
+            }
+
 
             //卖家不能分润自己 买家和分润人相同,不分润
             if (null != orderDetailVo.getRecomUserId() && orderDetailVo.getRecomUserId() != 0
@@ -985,7 +988,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 //入老师账户
                 BigDecimal shareFee = platformFee.multiply(shareFeeRate).setScale(2, RoundingMode.HALF_UP);
                 if (shareFee.compareTo(BigDecimal.ZERO) > 0) {
-                    AccountBizTypeEnum bizTypeEnum = AccountBizTypeEnum.valueOf(orderDetailVo.getGoodType().getCode() + "_SHARE");
+                    bizTypeEnum = AccountBizTypeEnum.valueOf(orderDetailVo.getGoodType().getCode() + "_SHARE");
                     if (null != bizTypeEnum) {
                         //插入分润老师账户变更记录-分润老师预收
                         HttpResponseResult<UserAccountRecord> recomRecordRes = userAccountService.accountRecord(

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

@@ -1,10 +1,12 @@
 package com.yonge.cooleshow.biz.dal.wrapper.im;
 
 import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
 
 import java.io.Serializable;
 import java.util.List;
@@ -25,6 +27,8 @@ public class CustomerService {
     public static class NotifyMessage implements Serializable {
 
         private List<String> receives;
+        private ClientEnum clientType;
+        private String subjectId;
 
         private String title;
         private String txtMessage;
@@ -35,5 +39,22 @@ public class CustomerService {
 
             return JSON.parseObject(recv, NotifyMessage.class);
         }
+
+        public List<String> getReceives() {
+            if (CollectionUtils.isEmpty(receives)) {
+                return null;
+            }
+            return receives;
+        }
+    }
+
+    /**
+     * 消息接收者
+     */
+    @Data
+    public static class MessageReceives implements Serializable {
+
+        private Long userId;
+        private String nickname;
     }
 }

+ 20 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/SysUserMapper.xml

@@ -85,4 +85,24 @@
         update_time_ = now()
         WHERE del_flag_ = 0 and id_ = #{param.userId}
     </update>
+
+    <!--客服消息接收者-->
+    <select id="selectMessageReceives"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.im.CustomerService$MessageReceives">
+        SELECT t1.id_ AS userId, t1.username_ FROM sys_user t1
+        <if test="param.clientType != null">
+            <if test="param.clientType.code == 'TEACHER'"> LEFT JOIN teacher t2 ON (t1.id_ = t2.user_id_)</if>
+            <if test="param.clientType.code == 'STUDENT'"> LEFT JOIN student t2 ON (t1.id_ = t2.user_id_)</if>
+        </if>
+        <where>
+            <if test="param.receives != null">
+                AND t1.phone_ IN (<foreach collection="param.receives" separator="," item="item">#{item}</foreach>)
+            </if>
+            <if test="param.subjectId != null">
+                AND FIND_IN_SET(#{param.subjectId}, t2.subject_id_)
+            </if>
+        </where>
+        LIMIT 1500
+    </select>
+    <!--客服消息接收者-->
 </mapper>