Procházet zdrojové kódy

添加钱包数据按时间筛选

hxl13994548489 před 2 roky
rodič
revize
8cebe8775d

+ 44 - 0
src/main/java/com/ydtech/modules/admin/controller/deptBalance/DeptBalanceController.java

@@ -8,11 +8,14 @@ import com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto;
 import com.ydtech.modules.admin.model.vo.DeptBalanceVo;
 import com.ydtech.modules.admin.model.vo.PartnerBalanceVo;
 import com.ydtech.modules.admin.service.DeptBalanceService;
+import com.ydtech.modules.admin.utils.SliceUpDateUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 @Api(tags = "机构管理费统计")
@@ -33,6 +36,9 @@ public class DeptBalanceController {
     @PostMapping("deptLeaderStatistics")
     @ApiOperation(value = "机构负责人统计")
     public HttpResult<IPage<DeptBalanceDto>> queryDeptLeaderStatistics(@RequestBody DeptBalanceVo deptBalanceVo) {
+        HashMap<String, String> map = getDateMapByType(deptBalanceVo.getDays(), deptBalanceVo.getBeginDate(), deptBalanceVo.getEndDate());
+        deptBalanceVo.setBeginDate(map.get("startDate"));
+        deptBalanceVo.setEndDate(map.get("endDate"));
         HttpResult<IPage<DeptBalanceDto>> result = deptBalanceService.queryDeptLeaderStatistics(deptBalanceVo);
         return result;
     }
@@ -46,6 +52,9 @@ public class DeptBalanceController {
     @PostMapping("queryPartnerStatistics")
     @ApiOperation(value = "合伙人统计")
     public HttpResult<IPage<SysPartnerConsoleDto>> queryPartnerStatistics(@RequestBody DeptBalanceVo deptBalanceVo) {
+        HashMap<String, String> map = getDateMapByType(deptBalanceVo.getDays(), deptBalanceVo.getBeginDate(), deptBalanceVo.getEndDate());
+        deptBalanceVo.setBeginDate(map.get("startDate"));
+        deptBalanceVo.setEndDate(map.get("endDate"));
         HttpResult<IPage<SysPartnerConsoleDto>> result = deptBalanceService.queryPartnerStatistics(deptBalanceVo);
         return result;
     }
@@ -75,10 +84,45 @@ public class DeptBalanceController {
     @PostMapping("walletAgent")
     @ApiOperation(value = "钱包代理人")
     public HttpResult<IPage<SysPartnerConsoleDto>> getWalletAgent(@RequestBody DeptBalanceVo deptBalanceVo) {
+        HashMap<String, String> map = getDateMapByType(deptBalanceVo.getDays(), deptBalanceVo.getBeginDate(), deptBalanceVo.getEndDate());
+        deptBalanceVo.setBeginDate(map.get("startDate"));
+        deptBalanceVo.setEndDate(map.get("endDate"));
         IPage<SysPartnerConsoleDto> result = deptBalanceService.getWalletAgent(deptBalanceVo);
         return HttpResult.ok(result);
     }
 
 
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/6/19 11:57
+     *  @Description:  通过时间类型判断
+     */
+    private static HashMap<String,String> getDateMapByType(String type, String startDate, String endDate) {
+        HashMap<String,String> map =new HashMap<>();
+        String  startDateStr="";
+        String  endDateStr="";
+        if(org.apache.commons.lang3.StringUtils.isNotBlank(startDate) && org.apache.commons.lang3.StringUtils.isNotBlank(endDate)){
+            startDateStr= org.apache.commons.lang3.StringUtils.isNotBlank(startDate)?startDate+" 00:00:00":null;
+            endDateStr= org.apache.commons.lang3.StringUtils.isNotBlank(endDate)?endDate+" 23:59:59":null;
+        }else{
+            if("1".equals(type)){
+                // 近1天
+                startDateStr= SliceUpDateUtil.getBeforeDay(new Date(),5)+" 00:00:00";
+                endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+            }else if("2".equals(type)){
+                // 近7天
+                startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),1)+" 00:00:00";
+                endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+            }else if("3".equals(type)){
+                // 近30天
+                startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),6)+" 00:00:00";
+                endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
+            }
+        }
+        map.put("startDate",startDateStr);
+        map.put("endDate",endDateStr);
+        return map;
+    }
 
 }

+ 2 - 2
src/main/java/com/ydtech/modules/admin/dao/DeptBalanceMapper.java

@@ -28,7 +28,7 @@ public interface DeptBalanceMapper {
      *  @Date: 2024/08/23 9:04
      *  @Description:  合伙人保费金额
      */
-    HashMap<String, BigDecimal> getByDeptId(@Param("deptId") String deptId, @Param("createTime")  String createTime);
+    HashMap<String, BigDecimal> getByDeptId(@Param("deptId") String deptId, @Param("createTime")  String createTime,@Param("beginDate") String beginDate,@Param("endDate") String endDate);
 
     /**
      * @version
@@ -43,5 +43,5 @@ public interface DeptBalanceMapper {
      * @param userId
      * @return  获取代理人 总收入
      */
-    HashMap<String, BigDecimal> getWalletAgentAmount(String userId);
+    HashMap<String, BigDecimal> getWalletAgentAmount(@Param("userId") String userId,@Param("beginDate") String beginDate,@Param("endDate") String endDate);
 }

+ 8 - 8
src/main/java/com/ydtech/modules/admin/service/impl/DeptBalanceServiceImpl.java

@@ -92,12 +92,12 @@ public class DeptBalanceServiceImpl implements DeptBalanceService {
                     } else {
                         dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
                     }
-                    HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getByDeptId(deptId, dateStr);
+                    HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getByDeptId(deptId, dateStr,deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
                     if (orderAmount != null && !orderAmount.isEmpty()) {
                         BigDecimal totalIncome = orderAmount.get("totalIncome")==null ? BigDecimal.ZERO : orderAmount.get("totalIncome");
                         allTotalIncome = totalIncome.multiply(new BigDecimal(proportional))
                                 .divide(new BigDecimal("100")).setScale(2, RoundingMode.DOWN);
-                        allDeptManagementFee = this.calculateTotal(orderAmount.get("deptManagementFee"), allDeptManagementFee, null);//机构管理费
+                        allDeptManagementFee = this.calculateTotal(orderAmount.get("deptManagementFee"), allDeptManagementFee, null);
                     }
                     // 填充 已提现抽成费用和可提现抽成费用
                     List<SysAgencyFeeApproval> sysAgencyFeeApprovals = sysAgencyFeeApprovalMapper.selectList(new LambdaQueryWrapper<SysAgencyFeeApproval>()
@@ -162,19 +162,19 @@ public class DeptBalanceServiceImpl implements DeptBalanceService {
                         }else{
                             dateStr=  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
                         }
-                        HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getByDeptId(deptId,dateStr);
+                        HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getByDeptId(deptId,dateStr,deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
 
                         if (orderAmount != null && !orderAmount.isEmpty()) {
                             BigDecimal totalIncome = orderAmount.get("totalIncome")==null ? BigDecimal.ZERO : orderAmount.get("totalIncome");
                             allTotalIncome = totalIncome.multiply(new BigDecimal(proportional))
                                     .divide(new BigDecimal("100")).setScale(2, RoundingMode.DOWN);
-                            allDeptManagementFee = this.calculateTotal(orderAmount.get("deptManagementFee"), allDeptManagementFee, null);//机构管理费
+                            allDeptManagementFee = this.calculateTotal(orderAmount.get("deptManagementFee"), allDeptManagementFee, null);
                         }
                         // 填充 已提现抽成费用和可提现抽成费用
                         List<SysAgencyFeeApproval> sysAgencyFeeApprovals = sysAgencyFeeApprovalMapper.selectList(new LambdaQueryWrapper<SysAgencyFeeApproval>()
                                 .eq(SysAgencyFeeApproval::getUserId, item.getUserId())
                                 .eq(SysAgencyFeeApproval::getStatus, 1));
-                        if (sysAgencyFeeApprovals.size() > 0) {
+                        if (!sysAgencyFeeApprovals.isEmpty()) {
                             for (SysAgencyFeeApproval sysAgencyFeeApproval : sysAgencyFeeApprovals) {
                                 allWithdrawn = allWithdrawn.add(sysAgencyFeeApproval.getHistoryFee());
                             }
@@ -282,19 +282,19 @@ public class DeptBalanceServiceImpl implements DeptBalanceService {
         if (!records.isEmpty()) {
             for (SysPartnerConsoleDto record : records) {
                 String userId = record.getUserId();
-                HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getWalletAgentAmount(userId);
+                HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getWalletAgentAmount(userId,deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
 //              总金额
                 if (orderAmount != null && !orderAmount.isEmpty()) {
                     record.setTotalIncome(orderAmount.get("totalIncome"));
                 }
 //                          已提现
-                BigDecimal ysTXAmount= insFeeOrderNewService.findMyAmountYTXmount(record.getUserId(),"3");
+                BigDecimal ysTXAmount= insFeeOrderNewService.findMyAmountYTXmountByDate(record.getUserId(),"3",deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
 //                          未提现
                 MySumAmountQueryDto mySumAmountQueryDto = new MySumAmountQueryDto();
                 mySumAmountQueryDto.setAuditstatus("1");
                 SysUserAccount sysUserAccountEntity = sysUserAccountService.getById(record.getUserId());
                 BigDecimal ssKTAmount =BigDecimal.ZERO;
-                BigDecimal txzTXAmount= insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(),"2");
+                BigDecimal txzTXAmount= insFeeOrderNewService.findMyAmountYTXmountByDate(mySumAmountQueryDto.getUserId(),"2",deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
 
                 if(sysUserAccountEntity!=null){
                     ssKTAmount = sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO: sysUserAccountEntity.getSumAmount();

+ 7 - 0
src/main/java/com/ydtech/modules/protocols/dao/InsFeeOrderNewMapper.java

@@ -170,6 +170,13 @@ public interface InsFeeOrderNewMapper extends BaseMapper<InsFeeOrderNew> {
     List<CostSettlementExcelVo> getCostSettlementExcel(@Param("param") CostSettlementQueryVo costSettlementQueryVo);
 
     List<FeeReceivableVo> getFeeReceivable(@Param("param") CostSettlementQueryVo costSettlementQueryVo);
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/9/2 11:17
+     *  @Description:  按时间统计数据
+     */
+    BigDecimal findMyAmountYTXmountByDate(@Param("userId") String userId, @Param("status") String status, @Param("beginDate") String beginDate, @Param("endDate") String endDate);
 }
 
 

+ 7 - 1
src/main/java/com/ydtech/modules/protocols/service/InsFeeOrderNewService.java

@@ -204,5 +204,11 @@ public interface InsFeeOrderNewService extends IService<InsFeeOrderNew> {
                 .eq(InsFeeOrderNew::getInsOrderNo, insOrderNo)
                 .one();
     }
-
+    /**
+     *  @version
+     *  @author: hxl
+     *  @Date: 2024/9/2 11:15
+     *  @Description:  按时间检索
+     */
+    BigDecimal findMyAmountYTXmountByDate(String userId, String number, String beginDate, String endDate);
 }

+ 5 - 0
src/main/java/com/ydtech/modules/protocols/service/impl/InsFeeOrderNewServiceImpl.java

@@ -206,4 +206,9 @@ public class InsFeeOrderNewServiceImpl extends ServiceImpl<InsFeeOrderNewMapper,
     public List<FeeReceivableVo> getFeeReceivable(CostSettlementQueryVo costSettlementQueryVo) {
         return baseMapper.getFeeReceivable(costSettlementQueryVo);
     }
+
+    @Override
+    public BigDecimal findMyAmountYTXmountByDate(String userId, String type, String beginDate, String endDate) {
+        return baseMapper.findMyAmountYTXmountByDate(userId,type,beginDate,endDate);
+    }
 }

+ 6 - 8
src/main/resources/mapper/modules/admin/DeptBalanceMapper.xml

@@ -106,6 +106,9 @@
             <if test="createTime  != null  and  createTime !=''">
                 and io.createtime >= #{createTime}
             </if>
+            <if test="beginDate !=null and beginDate != '' and endDate !=null and endDate != ''">
+                AND  io.createtime  BETWEEN  #{beginDate}  AND  #{endDate}
+            </if>
         </where>
     </select>
 
@@ -139,14 +142,6 @@
             <if test="vo.userCode !=null  and  vo.userCode !=''">
                 and su.id= #{vo.userCode}
             </if>
-            <if test="vo.days !=null  and vo.days !='' ">
-                and su.create_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
-            </if>
-
-            <if test="vo.beginDate !=null and vo.beginDate != '' and vo.endDate !=null and vo.endDate != ''">
-                AND   DATE_FORMAT( su.create_time, '%Y-%m-%d')   BETWEEN #{vo.beginDate} AND #{vo.endDate}
-            </if>
-
         </where>
     </select>
 
@@ -162,6 +157,9 @@
             <if test="userId  != null  and  userId !=''">
              and   io.userid =#{userId}
             </if>
+            <if test="beginDate !=null and beginDate != '' and endDate !=null and endDate != ''">
+                AND  io.createtime  BETWEEN  #{beginDate}  AND  #{endDate}
+            </if>
         </where>
     </select>
 </mapper>

+ 0 - 6
src/main/resources/mapper/modules/admin/SysAgencyLeaderMapper.xml

@@ -65,12 +65,6 @@
             <if test="vo.userCode !=null  and  vo.userCode !=''">
                 and su.id= #{vo.userCode}
             </if>
-            <if test="vo.days !=null  and vo.days !='' ">
-                and su.create_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
-            </if>
-            <if test="vo.beginDate !=null and vo.beginDate != '' and vo.endDate !=null and vo.endDate != ''">
-                AND   DATE_FORMAT( su.create_time, '%Y-%m-%d')   BETWEEN #{vo.beginDate} AND #{vo.endDate}
-            </if>
         </where>
     </select>
 

+ 0 - 6
src/main/resources/mapper/modules/admin/SysPartnerMapper.xml

@@ -45,12 +45,6 @@
             <if test="vo.userCode !=null  and  vo.userCode !=''">
                 and su.id= #{vo.userCode}
             </if>
-            <if test="vo.days !=null  and vo.days !='' ">
-                and su.create_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
-            </if>
-            <if test="vo.beginDate !=null and vo.beginDate != '' and vo.endDate !=null and vo.endDate != ''">
-                AND DATE_FORMAT( su.create_time, '%Y-%m-%d')   BETWEEN #{vo.beginDate} AND #{vo.endDate}
-            </if>
         </where>
     </select>
 

+ 13 - 0
src/main/resources/mapper/modules/ins/InsFeeOrderNewMapper.xml

@@ -1414,4 +1414,17 @@
             ins_company
 
     </select>
+    <select id="findMyAmountYTXmountByDate" resultType="java.math.BigDecimal">
+        SELECT
+            ifnull( sum( au.amount ), 0 )
+        FROM
+            sys_amount_auditing au
+        <where>
+            au.user_id = #{userId}
+            AND au.auditing_status = #{status}
+            <if test="beginDate !=null and  beginDate != '' and endDate !=null and  endDate != ''">
+                AND au.create_time  BETWEEN #{beginDate}  AND #{endDate}
+            </if>
+        </where>
+    </select>
 </mapper>