Jelajahi Sumber

Merge branch 'develop' into test-user

* develop:
  更新运营中心账户变动记录到新表,更新v2的表字段
  预借款还款扣除日志修改所属表
  修复同步用户注销后重新恢复导致的数据错误
  后台菜单列表增加权限集合
mac 2 tahun lalu
induk
melakukan
bac8643f94

+ 49 - 2
kxs-common/kxs-common-core/src/main/resources/logback-spring.xml

@@ -63,14 +63,60 @@
 		</filter>
 	</appender>
 
+	<!--为了防止进程退出时,内存中的数据丢失,请加上此选项-->
+	<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook"/>
+	<!-- 可用来获取StatusManager中的状态 -->
+	<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>
+
+	<!-- 解决debug模式下循环发送的问题 -->
+	<logger name="org.apache.http.impl.conn.Wire" level="WARN" />
+
+	<!-- 引入sls日志 -->
+	<appender name="aliyun" class="com.aliyun.openservices.log.logback.LoghubAppender">
+		<!-- Configure account and network  -->
+		<endpoint>cn-shenzhen.log.aliyuncs.com</endpoint>
+		<!-- 填写sls key密钥 -->
+		<accessKeyId>**********</accessKeyId>
+		<accessKeySecret>*****************</accessKeySecret>
+
+		<project>tajia-log</project>
+		<!--logStore名称 -->
+		<logStore>tajia-api</logStore>
+
+		<!-- Optional parameters -->
+<!--		#单个 producer 实例能缓存的日志大小上限,默认为 100MB。-->
+		<totalSizeInBytes>104857600</totalSizeInBytes>
+		<maxBlockMs>0</maxBlockMs>
+<!--		执行日志发送任务的线程池大小,默认为可用处理器个数。-->
+		<ioThreadCount>8</ioThreadCount>
+		<batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
+		<batchCountThreshold>4096</batchCountThreshold>
+		<lingerMs>2000</lingerMs>
+		<retries>10</retries>
+		<baseRetryBackoffMs>100</baseRetryBackoffMs>
+		<maxRetryBackoffMs>50000</maxRetryBackoffMs>
+
+		<!-- 可选项 通过配置 encoder 的 pattern 自定义 log 的格式 -->
+		<encoder>
+			<pattern>%d %-5level [%thread] %X{traceId} %logger{0}: %msg</pattern>-->
+			<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %highlight([%-5level] [%thread] %logger{50} - %msg%n)</pattern>
+			<charset>UTF-8</charset>
+		</encoder>
+
+		<!--  Optional parameters -->
+		<timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
+		<!--  Optional parameters -->
+		<timeZone>UTC</timeZone>
+		<mdcFields>
+			TraceId,#####
+		</mdcFields>
+	</appender>
 
 	<!-- Level: FATAL 0  ERROR 3  WARN 4  INFO 6  DEBUG 7 -->
 
 	<springProfile name="dev">
 		<root level="INFO">
 			<appender-ref ref="console"/>
-			<appender-ref ref="debug"/>
-			<appender-ref ref="error"/>
 		</root>
 	</springProfile>
 	<springProfile name="test">
@@ -85,6 +131,7 @@
 			<appender-ref ref="console"/>
 			<appender-ref ref="debug"/>
 			<appender-ref ref="error"/>
+			<appender-ref ref="aliyun" />
 		</root>
 	</springProfile>
 </configuration>

+ 6 - 0
kxs-common/kxs-common-log/pom.xml

@@ -48,6 +48,12 @@
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-oauth2-core</artifactId>
         </dependency>
+        <!--阿里云SLS日志包-->
+        <dependency>
+            <groupId>com.aliyun.openservices</groupId>
+            <artifactId>aliyun-log-logback-appender</artifactId>
+            <version>0.1.18</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 13 - 4
kxs-system/kxs-system-biz/src/main/java/com/kxs/system/biz/service/impl/SysMenuServiceImpl.java

@@ -92,7 +92,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
 				.eq(StrUtil.isNotBlank(type), SysMenu::getMenuType, type)
 				.orderByAsc(SysMenu::getSortOrder))
 			.stream()
-			.map(getNodeFunction())
+			.map(getNodeFunction(null))
 			.collect(Collectors.toList());
 
 		// 模糊查询 不组装树结构 直接返回 表格方便编辑
@@ -117,9 +117,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
 	 */
 	@Override
 	public List<Tree<Long>> filterMenu(Set<SysMenu> all, String type, Long parentId) {
+		//拿出每个菜单的权限转为集合
+		Map<Long, List<String>> permissions = all.stream()
+				.filter(item -> item.getMenuType().equals(MenuTypeEnum.BUTTON.getType()))
+				.collect(Collectors.groupingBy(SysMenu::getParentId, Collectors.mapping(SysMenu::getPermission, Collectors.toList())));
+
 		List<TreeNode<Long>> collect = all.stream()
 			.filter(menuTypePredicate(type))
-			.map(getNodeFunction())
+			.map(getNodeFunction(permissions))
 			.collect(Collectors.toList());
 
 		Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
@@ -127,7 +132,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
 	}
 
 	@NotNull
-	private Function<SysMenu, TreeNode<Long>> getNodeFunction() {
+	private Function<SysMenu, TreeNode<Long>> getNodeFunction(Map<Long, List<String>> permissions) {
 		return menu -> {
 			TreeNode<Long> node = new TreeNode<>();
 			node.setId(menu.getMenuId());
@@ -138,7 +143,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
 			Map<String, Object> extra = new HashMap<>();
 			extra.put("path", menu.getPath());
 			extra.put("menuType", menu.getMenuType());
-			extra.put("permission", menu.getPermission());
+			if(permissions != null){
+				extra.put("permission", permissions.get(menu.getMenuId()));
+			}else{
+				extra.put("permission", menu.getPermission());
+			}
 			extra.put("sortOrder", menu.getSortOrder());
 
 			// 适配 vue3

+ 3 - 1
kxs-transfer/src/main/java/com/kxs/transfer/api/service/user/impl/KxsUserServiceImpl.java

@@ -163,7 +163,9 @@ public class KxsUserServiceImpl extends ServiceImpl<KxsUserMapper, KxsUser> impl
                     user.setToMerchantMakerTime(LocalDateTimeUtil.parse(fieldDataMap.get(field).toString(), DatePattern.NORM_DATETIME_PATTERN));
                     break;
                 case "LogOutDate":
-                    user.setUpdateTime(LocalDateTimeUtil.parse(fieldDataMap.get(field).toString(), DatePattern.NORM_DATETIME_PATTERN));
+                    if(fieldDataMap.get(field) != null){
+                        user.setUpdateTime(LocalDateTimeUtil.parse(fieldDataMap.get(field).toString(), DatePattern.NORM_DATETIME_PATTERN));
+                    }
                     break;
                 case "CreateDate":
                     user.setCreateTime(LocalDateTimeUtil.parse(fieldDataMap.get(field).toString(), DatePattern.NORM_DATETIME_PATTERN));

+ 35 - 30
kxs-user/kxs-user-api/src/main/java/com/kxs/user/api/model/KxsLeaderAmountLog.java

@@ -15,31 +15,11 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 /**
- * 盟主储备金变动记录(KxsLeaderAmountLog)表实体类
- *
- * Sort //老库类型
- * //11:盟主储蓄金增减单(兑换机具券 机具券兑换 系统增加(盟主储蓄金) 系统扣减(盟主储蓄金) 储备金购买)
- * // 示例:+/-金额
- * //  盟主储蓄金:剩余盟主储蓄金
- * // 12:可提现余额增减单(系统增加(可提现余额) 系统扣减(可提现余额))
- * // 示例:+/-金额
- * //  可提现余额:剩余可提现余额
- * // 13:盟主储蓄金减少可提现余额增加(推荐大/小盟主 商城购机 购机奖励)
- * // 示例:-金额
- * //  盟主储蓄金:剩余盟主储蓄金
- * //  可提现余额:+金额
- *
- * ChangeType //操作类型(1 增加 2 减少)
- * ChangeAmt //变动金额
- * AfterAmt //变动后余额
- * Remark //标题
- * SeoDescription //描述
+ * 盟主金额变动记录(KxsLeaderAmountLog)表实体类
  *
  * @author 系统
- * @since 2024-02-22 15:39:26
+ * @since 2024-03-28 13:57:27
  */
-
-
 @EqualsAndHashCode(callSuper = true)
 @Data
 public class KxsLeaderAmountLog extends Model<KxsLeaderAmountLog> implements Serializable {
@@ -110,9 +90,6 @@ public class KxsLeaderAmountLog extends Model<KxsLeaderAmountLog> implements Ser
 
     /**
      * 操作金额
-     * 盟主储蓄金增减单=11
-     * 可提现余额增减单=12
-     * 盟主储蓄金减少可提现余额增加=13
      */
     @Schema(description = "操作金额")
     private BigDecimal amount;
@@ -120,9 +97,6 @@ public class KxsLeaderAmountLog extends Model<KxsLeaderAmountLog> implements Ser
 
     /**
      * 金额类型
-     * 盟主储蓄金增减单=11
-     * 可提现余额增减单=12
-     * 盟主储蓄金减少可提现余额增加=13
      */
     @Schema(description = "金额类型")
     private Integer variationType;
@@ -155,12 +129,43 @@ public class KxsLeaderAmountLog extends Model<KxsLeaderAmountLog> implements Ser
     @Schema(description = "大盟主的用户ID 标记")
     private Integer sourceUserId;
 
+
     /**
-     * 商城订单ID
+     * 订单ID
      */
-    @Schema(description = "商城订单ID")
+    @Schema(description = "订单ID")
     private Integer orderId;
 
 
+    /**
+     * 收支类型 对应change_type表
+     */
+    @Schema(description = "收支类型 对应change_type表")
+    private Integer changeType;
+
+
+    /**
+     * 变动可提现额度
+     */
+    @Schema(description = "变动可提现额度")
+    private BigDecimal useWithdrawalMount;
+
+
+    /**
+     * 变动后可提现额度
+     */
+    @Schema(description = "变动后可提现额度")
+    private BigDecimal afterWithdrawalMount;
+
+
+    /**
+     * 变动前可提现额度
+     */
+    @Schema(description = "变动前可提现额度")
+    private BigDecimal beforeWithdrawalAmount;
+
+
+
+
 }
 

+ 45 - 6
kxs-user/kxs-user-api/src/main/java/com/kxs/user/api/model/KxsPartnerAmountLog.java

@@ -18,7 +18,7 @@ import lombok.EqualsAndHashCode;
  * 合伙人金额变动记录(KxsPartnerAmountLog)表实体类
  *
  * @author 系统
- * @since 2024-02-22 15:39:26
+ * @since 2024-03-28 13:41:58
  */
 @EqualsAndHashCode(callSuper = true)
 @Data
@@ -82,9 +82,9 @@ public class KxsPartnerAmountLog extends Model<KxsPartnerAmountLog> implements S
 
 
     /**
-     * 变动后金额
+     * 变动后未使用金额
      */
-    @Schema(description = "变动后金额")
+    @Schema(description = "变动后未使用金额")
     private BigDecimal afterAmount;
 
 
@@ -97,9 +97,6 @@ public class KxsPartnerAmountLog extends Model<KxsPartnerAmountLog> implements S
 
     /**
      * 金额类型
-     * 可提现余额增减=0
-     * 可使用余额增减=1
-     * 关键分仓额度增减=2
      */
     @Schema(description = "金额类型")
     private Integer variationType;
@@ -126,6 +123,48 @@ public class KxsPartnerAmountLog extends Model<KxsPartnerAmountLog> implements S
     private String remark;
 
 
+    /**
+     * 使用关联分仓额度
+     */
+    @Schema(description = "使用关联分仓额度")
+    private BigDecimal useStoreAmount;
+
+
+    /**
+     * 使用未使用额度
+     */
+    @Schema(description = "使用未使用额度")
+    private BigDecimal useTotalAmt;
+
+
+    /**
+     * 使用可提现额度
+     */
+    @Schema(description = "使用可提现额度")
+    private BigDecimal useWithdrawalMount;
+
+
+    /**
+     * 使用后关联分仓额度
+     */
+    @Schema(description = "使用后关联分仓额度")
+    private BigDecimal afterStoreAmount;
+
+
+    /**
+     * 使用后可提现额度
+     */
+    @Schema(description = "使用后可提现额度")
+    private BigDecimal afterWithdrawalMount;
+
+
+    /**
+     * 收支类别
+     */
+    @Schema(description = "收支类别")
+    private Integer changeType;
+
+
 
 
 }

+ 17 - 3
kxs-user/kxs-user-biz/src/main/java/com/kxs/user/biz/service/impl/KxsTotalDebtServiceImpl.java

@@ -18,6 +18,7 @@ import com.kxs.user.biz.constant.enums.UserVariationTypeEnum;
 import com.kxs.user.biz.mapper.*;
 import com.kxs.user.biz.mapper.old.KxsMainServerMapper;
 import com.kxs.user.biz.mapper.old.KxsOpServerMapper;
+import com.kxs.user.biz.service.KxsPartnerAmountLogService;
 import com.kxs.user.biz.service.KxsTotalDebtService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -52,6 +53,10 @@ public class KxsTotalDebtServiceImpl extends ServiceImpl<KxsTotalDebtMapper, Kxs
 
     private final KxsOpServerMapper kxsOpServerMapper;
 
+    private final KxsPartnerAmountLogMapper kxsPartnerAmountLogMapper;
+
+    private final KxsLeaderAmountLogMapper kxsLeaderAmountLogMapper;
+
 
     @Override
     public IPage<TotalDebtListVO> getByPage(Page<KxsTotalDebt> page, String keyword) {
@@ -114,12 +119,16 @@ public class KxsTotalDebtServiceImpl extends ServiceImpl<KxsTotalDebtMapper, Kxs
             KxsPartnerAmountLog kxsPartnerAmountLog = new KxsPartnerAmountLog();
             kxsPartnerAmountLog.setUserId(kxsTotalDebt.getUserId());
             kxsPartnerAmountLog.setBeforeAmount(NumberUtil.add(kxsPartner.getWithdrawalAmount(),partnerDeductAmount));
-            kxsPartnerAmountLog.setAfterAmount(kxsPartner.getWithdrawalAmount());
             kxsPartnerAmountLog.setAmount(partnerDeductAmount);
+            kxsPartnerAmountLog.setAfterWithdrawalMount(kxsPartner.getWithdrawalAmount());
             kxsPartnerAmountLog.setKind(KindTypeEnum.SUB.getType());
             kxsPartnerAmountLog.setRemark("预借款项还款");
             kxsPartnerAmountLog.setVariationType(UserVariationTypeEnum.PARTNER_WITHDRAW_BALANCE.getType());
+            kxsPartnerAmountLog.setChangeType(21);
+            //添加到老库
             kxsOpServerMapper.addAmountLog(kxsPartner, kxsPartnerAmountLog);
+            //添加到新库
+//            kxsPartnerAmountLogMapper.insert(kxsPartnerAmountLog);
             //扣除成功 增加欠款日志
             BigDecimal afterAmount = NumberUtil.sub(kxsTotalDebt.getTotalDebt(),partnerDeductAmount);
             //添加日志
@@ -169,12 +178,17 @@ public class KxsTotalDebtServiceImpl extends ServiceImpl<KxsTotalDebtMapper, Kxs
             KxsLeaderAmountLog kxsLeaderAmountLog = new KxsLeaderAmountLog();
             kxsLeaderAmountLog.setUserId(kxsTotalDebt.getUserId());
             kxsLeaderAmountLog.setRemark("预借款项还款");
-            kxsLeaderAmountLog.setBeforeAmount(NumberUtil.add(userAmount.getLeaderBalanceAmount(), leaderDeductAmount));
-            kxsLeaderAmountLog.setAfterAmount(userAmount.getLeaderBalanceAmount());
+            kxsLeaderAmountLog.setBeforeWithdrawalAmount(NumberUtil.add(userAmount.getLeaderBalanceAmount(), leaderDeductAmount));
+            kxsLeaderAmountLog.setAfterWithdrawalMount(userAmount.getLeaderBalanceAmount());
             kxsLeaderAmountLog.setAmount(leaderDeductAmount);
+            kxsLeaderAmountLog.setUseWithdrawalMount(leaderDeductAmount);
             kxsLeaderAmountLog.setKind(KindTypeEnum.SUB.getType());
             kxsLeaderAmountLog.setVariationType(UserVariationTypeEnum.LEADER_WITHDRAW_BALANCE.getType());
+            kxsLeaderAmountLog.setChangeType(342);
+            //添加到老库
             kxsMainServerMapper.addAmountLog(kxsLeaderAmountLog);
+            //添加到新库
+//            kxsLeaderAmountLogMapper.insert(kxsLeaderAmountLog);
 
             //扣除盟主余额成功
             BigDecimal afterAmount = kxsTotalDebt.getTotalDebt().subtract(leaderDeductAmount);

+ 5 - 0
kxs-user/kxs-user-biz/src/main/resources/mapper/KxsLeaderAmountLogMapper.xml

@@ -18,6 +18,11 @@
         <result column="remark" property="remark" />
         <result column="source_user_id" property="sourceUserId" />
         <result column="order_id" property="orderId" />
+        <result column="change_type" property="changeType" />
+        <result column="use_withdrawal_mount" property="useWithdrawalMount" />
+        <result column="after_withdrawal_mount" property="afterWithdrawalMount" />
+        <result column="before_withdrawal_amount" property="beforeWithdrawalAmount" />
+
     </resultMap>
 
 </mapper>

+ 2 - 2
kxs-user/kxs-user-biz/src/main/resources/mapper/KxsMainMapper.xml

@@ -3,8 +3,8 @@
 <mapper namespace="com.kxs.user.biz.mapper.old.KxsMainServerMapper">
 
     <insert id="addAmountLog">
-        insert into LeaderReserveRecord (UserId, ChangeType, Remark, AfterAmt, BeforeAmt, ChangeAmt, sort, TradeDate, TradeMonth, CreateDate)
-        values (#{userId}, 1, #{remark}, #{afterAmount},#{beforeAmount},#{amount}, #{variationType}, DATE_FORMAT(NOW(), '%Y%m%d'), DATE_FORMAT(NOW(), '%Y%m'), NOW())
+        insert into LeaderAccountRecord (UserId, ChangeType, SeoDescription, AfterBalanceAmount, BeforeBalanceAmount, ChangeAmount, CreateDate)
+        values (#{userId}, #{changeType}, #{remark}, #{afterAmount},#{beforeAmount},#{amount}, NOW())
     </insert>
 
     <update id="deductMakerUseAmount">

+ 2 - 2
kxs-user/kxs-user-biz/src/main/resources/mapper/KxsOpMapper.xml

@@ -4,8 +4,8 @@
 
 
     <insert id="addAmountLog">
-        insert into AmountRecord (UserId, SeoDescription, UseAmount, AfterValidForGetAmount, AfterTotalAmt, AfterValidAmount, CreateDate)
-        values (#{amountLog.userId}, #{amountLog.remark}, #{amountLog.amount},#{param.withdrawalAmount},#{param.amount}, #{param.storeAmount}, NOW())
+        insert into AmountRecordNew (UserId, ChangeTypeId, ShowType, Remark, UseAmount, AfterValidForGetAmount, UseValidForGetAmount, OperateType, CreateDate)
+        values (#{amountLog.userId},  #{amountLog.changeType}, 11, #{amountLog.remark}, #{amountLog.amount},#{param.withdrawalAmount},#{amountLog.amount}, 2, NOW())
     </insert>
 
 

+ 6 - 1
kxs-user/kxs-user-biz/src/main/resources/mapper/KxsPartnerAmountLogMapper.xml

@@ -16,7 +16,12 @@
         <result column="variation_cause" property="variationCause" />
         <result column="kind" property="kind" />
         <result column="remark" property="remark" />
-
+        <result column="use_store_amount" property="useStoreAmount" />
+        <result column="use_total_amt" property="useTotalAmt" />
+        <result column="use_withdrawal_mount" property="useWithdrawalMount" />
+        <result column="after_store_amount" property="afterStoreAmount" />
+        <result column="after_withdrawal_mount" property="afterWithdrawalMount" />
+        <result column="change_type" property="changeType" />
 
     </resultMap>