Forráskód Böngészése

交易记录添加权限

hym 3 éve
szülő
commit
24f7dabb07

+ 2 - 0
zoniot-pay/zoniot-pay-core/src/main/java/com/zcxk/rmcp/pay/dto/pay/PayTransactiondetailsDto.java

@@ -1,5 +1,6 @@
 package com.zcxk.rmcp.pay.dto.pay;
 
+import com.bz.zoneiot.core.common.pojo.UserCondition;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -92,5 +93,6 @@ public class PayTransactiondetailsDto{
     @ApiModelProperty(value = "账期月",  hidden = true)
     private Integer month;
     private String tenantId;
+    private UserCondition userCondition;
 
 }

+ 34 - 5
zoniot-pay/zoniot-pay-core/src/main/resources/mapper/pay/PayTransactiondetailsMapper.xml

@@ -362,7 +362,7 @@
             ,max(cancelperson) cancelperson
             ,max(invoice_id) as "invoiceId"
             ,0 as "isprint"
-            from pay_pay_transactiondetails
+            from pay_pay_transactiondetails pba
             where canceledrecord_id is null and payway !=5 and transtype!=2
                 and tenant_id=#{tenantId}
                 <if test="beginTime != null">
@@ -383,7 +383,7 @@
                 <if test="accountId != null and accountId !=''">
                     and account_id = #{accountId}
                 </if>
-
+                <include refid="permissionCondition"></include>
             group by accountnumber,accountname,payseriesno
             union all
             select accountnumber,accountname,payseriesno
@@ -395,7 +395,7 @@
             ,max(cancelperson) cancelperson
             ,max(invoice_id) as "invoiceId"
             ,max(isprint) as "isprint"
-            from pay_pay_received
+            from pay_pay_received pba
             where canceledrecord_id is null and payway !=5
                 and tenant_id=#{tenantId}
                 <if test="beginTime != null">
@@ -416,7 +416,7 @@
                 <if test="accountId != null and accountId !=''">
                     and account_id = #{accountId}
                 </if>
-
+             <include refid="permissionCondition"></include>
             group by accountnumber,accountname,payseriesno
             ) a
             group by accountnumber,accountname,payseriesno
@@ -441,7 +441,36 @@
         </where>
         order by t.transtime desc
     </select>
-
+    <sql id="permissionCondition">
+        <if test="userCondition.tenantId != null">and pba.tenant_id = #{userCondition.tenantId}</if>
+        <if test="userCondition.userType!=null and userCondition.userType!=-999 and userCondition.userType!=-9999 and  userCondition.programItems != null and userCondition.programItems.size() > 0">
+            <if test="userCondition.permissionType == 5 or userCondition.permissionType == 2">
+                and ( pba.dept_org_id in
+                <foreach collection="userCondition.programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                or
+                pba.company_org_id in
+                <foreach collection="userCondition.programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                )
+            </if>
+            <if test="userCondition.permissionType == 4 or userCondition.permissionType == 3">
+                and pba.dept_org_id in
+                <foreach collection="userCondition.programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+            </if>
+            <if test="userCondition.permissionType == 1">
+                and pba.company_org_id in
+                <foreach collection="userCondition.programItems" item="item" open="(" close=")" separator=",">
+                    #{item.orgId}
+                </foreach>
+                and (pba.dept_org_id is null or pba.dept_org_id =0)
+            </if>
+        </if>
+    </sql>
     <select id="selectTransactionListForAgenttrans" resultType="com.zcxk.rmcp.pay.dto.pay.PayTransactiondetailsDto">
         select
         CONCAT(

+ 17 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/impl/MeasurementSettlementServiceImpl.java

@@ -808,6 +808,23 @@ public class MeasurementSettlementServiceImpl implements MeasurementSettlementSe
         return baseClosingAccountInfo;
     }
 
+    @Override
+    public List<MeasurementInstance> findBillingPeriod(Integer companyId, Integer departmentId) {
+        List<MeasurementInstance> history = measurementInstanceMapper.findHistory(null, companyId, departmentId);
+
+        if(CollectionUtils.isEmpty(history)){
+            MeasurementInstance a = new MeasurementInstance();
+            for(int i=0; i<=1; i++){
+
+                a.setBillingPeriod(new Date());
+
+                a.setClearingStartDate(new Date());
+                history.add(a);
+            }
+        }
+        return history;
+    }
+
     private void insetAmountInfo(Integer year, Integer month, MeasurementSettlementDto measurementSettlementDto) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String start = year+"-"+(String.format("%02d",month))+"-01";

+ 5 - 12
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/impl/pay/PayChargeSurveyServiceImpl.java

@@ -8,9 +8,11 @@ import com.zcxk.rmcp.pay.dao.pay.PayChargeSurveyMapper;
 import com.zcxk.rmcp.pay.dto.LoginUser;
 import com.zcxk.rmcp.pay.dto.pay.*;
 import com.zcxk.rmcp.pay.entity.pay.*;
+import com.zcxk.rmcp.pay.service.pay.MeasurementSettlementService;
 import com.zcxk.rmcp.pay.service.pay.PayChargeSurveyService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -37,6 +39,8 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
     private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
     @Resource
     private MeasurementInstanceMapper measurementInstanceMapper;
+    @Autowired
+    private MeasurementSettlementService measurementSettlementService;
 
     @Override
     public Integer getAccountCount(BigInteger siteId,BigInteger customerId){
@@ -228,19 +232,8 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         return payChargeSurveyDto;
     }
     List<MeasurementInstance> findBillingPeriod(Integer companyId,Integer departmentId){
-        List<MeasurementInstance> history = measurementInstanceMapper.findHistory(null, companyId, departmentId);
 
-        if(CollectionUtils.isEmpty(history)){
-            MeasurementInstance a = new MeasurementInstance();
-            for(int i=0; i<=1; i++){
-
-                a.setBillingPeriod(new Date());
-
-                a.setClearingStartDate(new Date());
-                history.add(a);
-            }
-        }
-        return history;
+        return measurementSettlementService.findBillingPeriod(companyId,departmentId);
     }
 
     /**

+ 2 - 2
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/impl/pay/PayControlRuleServiceImpl.java

@@ -66,10 +66,10 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
     }
 
     @Override
-    public List<PayControlRule>findList(String name){
+    public List<PayControlRule>findList(String name, Integer companyId){
         LoginUser loginUser = UserUtil.getCurrentUser();
 
-        return payControlRuleMapper.findList(null,name,loginUser.getTenantId(), loginUser.getUserCondition(), null);
+        return payControlRuleMapper.findList(null,name,loginUser.getTenantId(), loginUser.getUserCondition(), companyId);
     }
 
     @Override

+ 17 - 15
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/impl/pay/PayTransactiondetailsServiceImp.java

@@ -1,5 +1,6 @@
 package com.zcxk.rmcp.pay.service.impl.pay;
 
+import com.bz.zoneiot.core.utils.DateUtil;
 import com.zcxk.rmcp.pay.commom.exception.ServiceException;
 import com.zcxk.rmcp.pay.commom.model.AjaxMessage;
 import com.zcxk.rmcp.pay.commom.model.Pagination;
@@ -12,6 +13,8 @@ import com.zcxk.rmcp.pay.dto.pay.BaseClosingAccountInfoDto;
 import com.zcxk.rmcp.pay.dto.pay.PayRechargeaccountDto;
 import com.zcxk.rmcp.pay.dto.pay.PayTransactiondetails;
 import com.zcxk.rmcp.pay.dto.pay.PayTransactiondetailsDto;
+import com.zcxk.rmcp.pay.entity.pay.MeasurementInstance;
+import com.zcxk.rmcp.pay.service.pay.MeasurementSettlementService;
 import com.zcxk.rmcp.pay.service.pay.PayPayReceivedService;
 import com.zcxk.rmcp.pay.service.pay.PayTransactiondetailsService;
 import com.github.pagehelper.Page;
@@ -20,12 +23,14 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -49,6 +54,8 @@ public class PayTransactiondetailsServiceImp implements PayTransactiondetailsSer
     PayPayReceivedService payPayReceivedService;
     @Resource
     BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+    @Resource
+    MeasurementSettlementService measurementSettlementService;
 
 
     public void insert(PayTransactiondetails payTransactiondetails) {
@@ -183,27 +190,22 @@ public class PayTransactiondetailsServiceImp implements PayTransactiondetailsSer
     public Pagination<PayTransactiondetailsDto> selectTransactionPageList(PayTransactiondetailsDto payTransactiondetailsDto, int pageNum, int pageSize){
         LoginUser loginUser = UserUtil.getCurrentUser();
 
-        //站点为空则加入用户站点查询
-        if( loginUser !=null){
-            //站点权限
-            payTransactiondetailsDto.setSiteId(loginUser.getSiteId());
-            //客户权限
-            payTransactiondetailsDto.setCustomerId(loginUser.getCustomerId());
-            payTransactiondetailsDto.setTenantId(loginUser.getTenantId());
-            //数据权限
-            //payTransactiondetailsDto.setProgramItems(loginUser.getDataPermissionMap().get(loginUser.getSiteId()));
-        }
+
         //有机构
         if(payTransactiondetailsDto.getAgentbranchId() != null){
-            BaseClosingAccountInfoDto baseClosingAccountInfoDto =  baseClosingAccountInfoMapper.getLastClosingAccount(loginUser.getSiteId(),loginUser.getCustomerId());
-            if(baseClosingAccountInfoDto == null){
-                return new Pagination<>(new Page<>());
+
+            List<MeasurementInstance> billingPeriod = measurementSettlementService.findBillingPeriod(loginUser.getCompanyId(), loginUser.getDepartmentId());
+            if(!CollectionUtils.isEmpty(billingPeriod)){
+                MeasurementInstance measurementInstance = billingPeriod.get(0);
+                payTransactiondetailsDto.setYear(DateUtil.getYear(measurementInstance.getBillingPeriod()));
+                payTransactiondetailsDto.setMonth(DateUtil.getMonth(measurementInstance.getBillingPeriod()));
             }
-            payTransactiondetailsDto.setYear(baseClosingAccountInfoDto.getYear());
-            payTransactiondetailsDto.setMonth(baseClosingAccountInfoDto.getMonth());
+
         }
         //分页
         PageHelper.startPage(pageNum,pageSize);
+        payTransactiondetailsDto.setTenantId(loginUser.getTenantId());
+        payTransactiondetailsDto.setUserCondition(loginUser.getUserCondition());
         return new Pagination<>(payTransactiondetailsMapper.selectTransactionList(payTransactiondetailsDto));
     }
     public Pagination<PayTransactiondetailsDto> getTransactionListForAgenttrans(PayTransactiondetailsDto payTransactiondetailsDto, int pageNum, int pageSize){

+ 2 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/pay/MeasurementSettlementService.java

@@ -3,6 +3,7 @@ package com.zcxk.rmcp.pay.service.pay;
 import com.bz.zoneiot.core.mysql.pageing.Pagination;
 import com.zcxk.rmcp.pay.dto.measurementsettlement.*;
 import com.zcxk.rmcp.pay.entity.pay.BaseClosingAccountInfo;
+import com.zcxk.rmcp.pay.entity.pay.MeasurementInstance;
 
 import java.util.List;
 
@@ -114,4 +115,5 @@ public interface MeasurementSettlementService {
 
     void billPlease(MeasurementSettlementDto measurementSettlementDto);
     BaseClosingAccountInfo findHistory();
+    List<MeasurementInstance> findBillingPeriod(Integer companyId, Integer departmentId);
 }

+ 1 - 1
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/pay/PayControlRuleService.java

@@ -18,7 +18,7 @@ public interface PayControlRuleService {
     Integer adds(List<PayControlRule> payControlRuleList);
 
     //查询规则
-    List<PayControlRule> findList(String name);
+    List<PayControlRule> findList(String name, Integer companyId);
 
     Pagination<PayControlRule> findPage(String name, int pageNum, int pageSize, Integer companyId);