Pārlūkot izejas kodu

账单管理,生成账单

lishiqiang 1 mēnesi atpakaļ
vecāks
revīzija
f600886881

+ 1 - 1
ship-module-ota/ship-module-ota-biz/src/main/java/com/yc/ship/module/ota/dal/mysql/distributor/DistributorMapper.java

@@ -44,7 +44,7 @@ public interface DistributorMapper extends BaseMapperX<DistributorDO> {
     }
 
     @TenantIgnore
-    List<StoreRespVO> selectDistributorStore(@Param("tenantId") Long tenantId);
+    List<StoreRespVO> selectDistributorStore(@Param("agencyId") Long agencyId);
     @TenantIgnore
     StoreRespVO selectStore(@Param("id") Long id);
     default List<DistributorDO> getSimpleList(DistributorListReqVO reqVO) {

+ 4 - 0
ship-module-ota/ship-module-ota-biz/src/main/resources/mapper/distributor/DistributorMapper.xml

@@ -26,6 +26,10 @@
           and type = #{type}
         </if>
     </select>
+    <select id="selectDistributorStore" resultType="com.yc.ship.module.trade.api.dto.StoreRespVO">
+        select * from otc_agency_store where is_use = 1 and deleted=0
+        and agency_id = #{agencyId}
+    </select>
     <select id="getOtcDistributorWithId" resultType="com.yc.ship.module.ota.controller.admin.distributor.vo.DistributorRespVO">
         select d.*, dp.id distributorProductId
         from ota_distributor d

+ 9 - 13
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/bill/BillServiceImpl.java

@@ -228,21 +228,15 @@ public class BillServiceImpl implements BillService {
                 //获取登录租户
                 Long tenantId = TenantContextHolder.getTenantId();
                 //查询是否门店登录
-                LoginUser loginUser = agencyAuthUtils.getLoginUser();
+                LoginUser loginUser = agencyAuthUtils.getAgencyLoginUser();
                 //是否旅行社登录
                 DistributorRespVO distributor = new DistributorRespVO();
-                if(loginUser != null){
-                    distributor = distributorMapper.getById(loginUser.getId());
+                if(loginUser.getDistributorId() != null){
+                    distributor = distributorMapper.getById(loginUser.getDistributorId());
                     billGenerator = 3;
                 }else{
-                    distributor = distributorMapper.getByTenantId(tenantId);
-                    if(distributor == null){
-                        //平台登录
-                        billGenerator = 1;
-                        distributor = distributorMapper.getById(createReqVO.getDistributorId());
-                    } else {
-                        billGenerator = 2;
-                    }
+                    distributor = distributorMapper.getById(createReqVO.getDistributorId());
+                    billGenerator = 1;
                 }
 
                 //判断是否部分生成账单
@@ -664,9 +658,9 @@ public class BillServiceImpl implements BillService {
         IPage<BillRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
         //获取登录租户
         Long tenantId = TenantContextHolder.getTenantId();
-        pageReqVO.setOtaTenantId(tenantId);
+//        pageReqVO.setOtaTenantId(tenantId);
         //查询当前旅行社门店
-        LoginUser loginUser = getLoginUser();
+        LoginUser loginUser = agencyAuthUtils.getAgencyLoginUser();
         Long storeId = loginUser.getStoreId();
         Long distributorId = loginUser.getDistributorId();
         if(storeId == null){
@@ -675,6 +669,7 @@ public class BillServiceImpl implements BillService {
                 DistributorRespVO distributor = distributorMapper.getDistributorById(distributorId);
                 //旅行社
                 if (distributor != null) {
+                    pageReqVO.setAgencyId(distributor.getId());
                     IPage<BillRespVO> iPage = billMapper.getBillPage(page, pageReqVO);
                     return new PageResult<>(iPage.getRecords(), iPage.getTotal());
                 }
@@ -686,6 +681,7 @@ public class BillServiceImpl implements BillService {
         }
         //门店
         else{
+            pageReqVO.setStoreId(storeId);
             IPage<BillRespVO> iPage = billMapper.getBillStorePage(page,pageReqVO);
             return new PageResult<>(iPage.getRecords(), iPage.getTotal());
         }

+ 10 - 6
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/billrule/BillRuleServiceImpl.java

@@ -188,19 +188,23 @@ public class BillRuleServiceImpl implements BillRuleService {
     public List<StoreRespVO> selectStoreList(Long distributorId) {
         List<StoreRespVO> storeList = new ArrayList<>();
         //查询当前旅行社门店
-        LoginUser loginUser = agencyAuthUtils.getLoginUser();
-        if(loginUser == null){
+        LoginUser loginUser = agencyAuthUtils.getAgencyLoginUser();
+        if(loginUser.getDistributorId()==null){
             //获取旅行社
             DistributorRespVO distributor = distributorMapper.getById(distributorId);
             if(distributor != null) {
                 //通过租户获取旅行社下面门店
-                storeList = distributorMapper.selectDistributorStore(distributor.getAccountTenantId());
+                storeList = distributorMapper.selectDistributorStore(distributor.getId());
             }
 
         }else{
-            //需要改
-            StoreRespVO store = distributorMapper.selectStore(agencyAuthUtils.getLoginStoreId());
-            storeList.add(store);
+            if(loginUser.getStoreId()!=null) {
+                //需要改
+                StoreRespVO store = distributorMapper.selectStore(loginUser.getStoreId());
+                storeList.add(store);
+            }else{
+                storeList = distributorMapper.selectDistributorStore(loginUser.getDistributorId());
+            }
         }
         return storeList;
     }

+ 1 - 4
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/bill/BillMapper.xml

@@ -44,10 +44,7 @@
         and td.order_status not in (-1,-2,0,1,6)
         and not exists(select 1 from trade_detail t where t.order_id = td.id and t.voucher_status not in (3,5,6,7,8,9))
         and top.pay_status =1
-        AND (top.payment_type = 6 and top.pay_amount>top.refund_amount
-        and exists(select 1 from trade_order_pay top
-        inner join trade_order_bind tob on tob.order_id  = top.order_id and tob.type =2
-        where tob.bind_id = td.id and top.payment_type = 6 and top.pay_amount>top.refund_amount and top.pay_status =1))
+        AND top.payment_type = 6 and top.pay_amount>top.refund_amount
         <if test="vo.type != null">
             AND td.is_bill =  #{vo.type}
         </if>