andrew hace 4 años
padre
commit
f67c42621a

+ 6
- 0
src/main/java/com/huiju/estateagents/center/taUser/entity/TaUser.java Ver fichero

@@ -267,4 +267,10 @@ public class TaUser implements Serializable {
267 267
      */
268 268
     @TableField(exist = false)
269 269
     private String bossDisplay;
270
+
271
+    /**
272
+     * 拥有的房源id
273
+     */
274
+    @TableField(exist = false)
275
+    private Integer roomNoId;
270 276
 }

+ 55
- 3
src/main/java/com/huiju/estateagents/property/controller/BillController.java Ver fichero

@@ -24,6 +24,7 @@ import java.text.ParseException;
24 24
 import java.text.SimpleDateFormat;
25 25
 import java.util.Date;
26 26
 import java.util.List;
27
+import java.util.Map;
27 28
 
28 29
 /**
29 30
  * <p>
@@ -34,9 +35,8 @@ import java.util.List;
34 35
  * @since 2019-02-13
35 36
  */
36 37
 @RestController
37
-@RequestMapping("/")
38
-
39
-@Api(value = "缴费项 API", description = "缴费项 API")
38
+@RequestMapping("/api")
39
+@Api(value = "缴费项 API", tags = "缴费项 API")
40 40
 public class BillController extends BaseController {
41 41
 
42 42
     @Autowired
@@ -164,4 +164,56 @@ public class BillController extends BaseController {
164 164
         }
165 165
     }
166 166
 
167
+    @ApiOperation(value = "获取本人的收费账单信息(已缴费或未缴费)", notes = "获取本人的收费账单信息(已缴费或未缴费)")
168
+    @ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "payType", value = "0是未缴费1是已缴费"),
169
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
170
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度"),
171
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
172
+    })
173
+    @RequestMapping(value = "/wx/bills/current_user/{payType}",method = RequestMethod.GET)
174
+    public ResponseBean getBillInvoice(@PathVariable Integer payType,
175
+                                       @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
176
+                                       @RequestParam(value ="pageSize",defaultValue = "5") Integer pageSize, HttpServletRequest request){
177
+        TaUser userElement = getTaUser(request);
178
+        ResponseBean responseBean = new ResponseBean();
179
+
180
+        Map<String, Object> map = iBillService.getBillsList(userElement, payType, pageNum, pageSize);
181
+        responseBean.addSuccess(map);
182
+        return responseBean;
183
+    }
184
+
185
+    @ApiOperation(value = "获取账单的详细信息", notes = "获取账单的详细信息")
186
+    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
187
+            @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "billInvoiceId", value = "账单id")})
188
+    @RequestMapping(value = "/wx/bill/{orgId}/{billInvoiceId}",method = RequestMethod.GET)
189
+    public ResponseBean getBillInvoiceDetail(@PathVariable Integer orgId,@PathVariable Integer billInvoiceId){
190
+        ResponseBean responseBean = new ResponseBean();
191
+
192
+        Map<String,Object> billInvoiceMap = iBillService.getBillInvoiceDetail(orgId,billInvoiceId);
193
+        responseBean.addSuccess(billInvoiceMap);
194
+        return responseBean;
195
+    }
196
+
197
+    @ApiOperation(value = "获取历史缴费", notes = "获取历史缴费")
198
+    @ApiImplicitParams({
199
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
200
+    })
201
+    @RequestMapping(value = "/wx/bill/pay/history", method = RequestMethod.GET)
202
+    public ResponseBean payHistory(HttpServletRequest request) {
203
+        ResponseBean responseBean = new ResponseBean();
204
+        TaUser userElement = getTaUser(request);
205
+        responseBean = iBillService.payHistory(userElement);
206
+        return responseBean;
207
+    }
208
+
209
+    @ApiOperation(value = "获取订单详情", notes = "获取订单详情")
210
+    @ApiImplicitParams({
211
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "orderNumber", value = "订单号")
212
+    })
213
+    @RequestMapping(value = "/wx/bill/order/info/{orderNumber}", method = RequestMethod.GET)
214
+    public ResponseBean getOrderInfo(HttpSession session, @PathVariable("orderNumber") String orderNumber) {
215
+        ResponseBean responseBean = new ResponseBean();
216
+        responseBean = iBillService.getOrderInfo(orderNumber);
217
+        return responseBean;
218
+    }
167 219
 }

+ 50
- 2
src/main/java/com/huiju/estateagents/property/dao/BillInvoiceMapper.java Ver fichero

@@ -3,9 +3,10 @@ package com.huiju.estateagents.property.dao;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.huiju.estateagents.center.taUser.entity.TaUser;
6 7
 import com.huiju.estateagents.property.model.BillInvoice;
7
-import org.apache.ibatis.annotations.Mapper;
8
-import org.apache.ibatis.annotations.Param;
8
+import com.huiju.estateagents.property.model.TpBillOrder;
9
+import org.apache.ibatis.annotations.*;
9 10
 
10 11
 import java.util.List;
11 12
 import java.util.Map;
@@ -45,4 +46,51 @@ public interface BillInvoiceMapper extends BaseMapper<BillInvoice> {
45 46
     IPage<BillInvoice> selectBillInvoiceEffective(Page page, @Param("map") Map<String, Object> map);
46 47
 	
47 48
 	List<Map<String, Object>> getPriceCount();
49
+
50
+
51
+    /**
52
+     * 分页获取缴费和未缴费的数据
53
+     * @param orgId
54
+     * @param roomNoId 房间id
55
+     * @param payType
56
+     * @return
57
+     */
58
+    IPage<Map<String, Object>> getBillsList(IPage<Map<String, Object>> pg, @Param("orgId") Integer orgId, @Param("roomNoId") Integer roomNoId, @Param("payType") Integer payType);
59
+
60
+    /**
61
+     * 获取账单的详细信息
62
+     * @param billInvoiceId
63
+     * @return
64
+     */
65
+    Map<String, Object> getBillInvoiceDetail(@Param("orgId") Integer orgId,@Param("billInvoiceId") Integer billInvoiceId);
66
+
67
+    /**
68
+     * 获取需要支付的金额
69
+     * @param billInvoiceId
70
+     * @param buildingOwnerInfoId
71
+     * @param communityId
72
+     * @return
73
+     */
74
+    BillInvoice selectByIdAndroomNoId(@Param("id") Integer billInvoiceId,@Param("roomNoId") Integer buildingOwnerInfoId,@Param("communityId") Integer communityId);
75
+
76
+    BillInvoice selectByOutTradeNo(@Param("outTradeNo") String outTradeNo);
77
+
78
+    List<BillInvoice> selectByBuildingOwnerInfoId(@Param("buildingOwnerInfoId") Integer buildingOwnerInfoId);
79
+
80
+    int updateBeach(Map<String, Object> map);
81
+
82
+    /**
83
+     * 根据 id 查询缴费单
84
+     * @param billId
85
+     * @return
86
+     */
87
+    @ResultType(BillInvoice.class)
88
+    @Select("select " +
89
+            "t.* ," +
90
+            "b.bill_name as billName " +
91
+            "from " +
92
+            "tp_bill_invoice t " +
93
+            "LEFT JOIN tp_bill b ON t.bill_id = b.id " +
94
+            "where t.id = #{billId}")
95
+    BillInvoice selectByIdBillInvoiceInfo(Integer billId);
48 96
 }

+ 11
- 2
src/main/java/com/huiju/estateagents/property/dao/BillStatementMapper.java Ver fichero

@@ -4,8 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.property.model.BillStatement;
7
-import org.apache.ibatis.annotations.Mapper;
8
-import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.*;
9 8
 
10 9
 import java.util.Map;
11 10
 
@@ -21,4 +20,14 @@ import java.util.Map;
21 20
 public interface BillStatementMapper extends BaseMapper<BillStatement> {
22 21
 
23 22
     IPage<BillStatement> getBillStatementAll(Page page, @Param("map") Map<String, Object> map);
23
+
24
+    /**
25
+     * 根据小区id,缴费单id 查询
26
+     * @param orgId
27
+     * @param tpBillInvoiceId
28
+     * @return
29
+     */
30
+    @ResultType(BillStatement.class)
31
+    @Select("select *  from tp_bill_statement where community_id = #{orgId} and bill_invoice_id = #{tpBillInvoiceId}")
32
+    BillStatement selectByCommunityIdAndBillInvoiceId(Integer orgId, Integer tpBillInvoiceId);
24 33
 }

+ 32
- 4
src/main/java/com/huiju/estateagents/property/dao/TpBillOrderMapper.java Ver fichero

@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.property.model.TpBillOrder;
7
-import org.apache.ibatis.annotations.Mapper;
8
-import org.apache.ibatis.annotations.Param;
9
-import org.apache.ibatis.annotations.ResultType;
10
-import org.apache.ibatis.annotations.Select;
7
+import org.apache.ibatis.annotations.*;
11 8
 
12 9
 import java.util.List;
13 10
 import java.util.Map;
@@ -56,4 +53,35 @@ public interface TpBillOrderMapper extends BaseMapper<TpBillOrder> {
56 53
             "GROUP BY tbo.tp_bill_id")
57 54
     List<TpBillOrder> getByOrderNumberBillInvoice(@Param("orderNumber") String orderNumber);
58 55
 
56
+
57
+    /**
58
+     * 根据房间号查询订单
59
+     * @param roomNoId
60
+     * @return
61
+     */
62
+    @ResultType(TpBillOrder.class)
63
+    @Select("SELECT tbo.* FROM tp_bill_order tbo LEFT JOIN tp_bill_invoice tbi on tbo.tp_bill_invoice_id = tbi.id " +
64
+            "WHERE tbi.room_no_id = #{roomNoId} and tbo.order_status = 1 GROUP BY tbo.order_bumber ORDER BY tbo.create_date DESC")
65
+    List<TpBillOrder> selectByRoomNoId(@Param("roomNoId") Integer roomNoId);
66
+
67
+    /**
68
+     * 根据订单号 查询缴费组
69
+     * @param orderBumber
70
+     * @return
71
+     */
72
+    @ResultType(TpBillOrder.class)
73
+    @Select("SELECT * FROM tp_bill_order WHERE order_bumber = #{orderBumber} GROUP BY tp_bill_id")
74
+    List<TpBillOrder> selectByOrderNumberBill(@Param("orderBumber") String orderBumber);
75
+
76
+    /**
77
+     * 根据订单查询, 所有数据
78
+     * @param orderNumber
79
+     * @return
80
+     */
81
+    @ResultType(TpBillOrder.class)
82
+    @Select("select " +
83
+            "tbo.* from tp_bill_order tbo where tbo.order_bumber=#{orderNumber}")
84
+    List<TpBillOrder> selectByOrderBumber(@Param("orderNumber") String orderNumber);
85
+
86
+
59 87
 }

+ 6
- 0
src/main/java/com/huiju/estateagents/property/model/BillInvoice.java Ver fichero

@@ -177,4 +177,10 @@ public class BillInvoice implements Serializable {
177 177
     @TableField(exist = false)
178 178
     private String updateUserName;
179 179
 
180
+    /**
181
+     * 转换后金额,用于支付
182
+     */
183
+    @TableField(exist = false)
184
+    private Double sumPayPrice;
185
+
180 186
 }

+ 6
- 0
src/main/java/com/huiju/estateagents/property/model/TpBillOrder.java Ver fichero

@@ -118,4 +118,10 @@ public class TpBillOrder implements Serializable {
118 118
      */
119 119
     @TableField(exist = false)
120 120
     private String billName;
121
+
122
+    /**
123
+     * 缴费单集合
124
+     */
125
+    @TableField(exist = false)
126
+    private List<BillInvoice> billList;
121 127
 }

+ 33
- 0
src/main/java/com/huiju/estateagents/property/service/IBillService.java Ver fichero

@@ -9,6 +9,7 @@ import org.springframework.web.multipart.MultipartFile;
9 9
 
10 10
 import java.util.Date;
11 11
 import java.util.List;
12
+import java.util.Map;
12 13
 
13 14
 /**
14 15
  * <p>
@@ -86,4 +87,36 @@ public interface IBillService extends IService<Bill> {
86 87
 	 * @return
87 88
 	 */
88 89
 	ResponseBean downloadExcel(TaUser userElement);
90
+
91
+	/**
92
+	 * 根据payType分页获取缴费或未缴费的数据
93
+	 *
94
+	 * @param userElement
95
+	 * @param payType
96
+	 * @param pageNum
97
+	 * @param pageSize
98
+	 * @return
99
+	 */
100
+	Map<String, Object> getBillsList(TaUser userElement, Integer payType, Integer pageNum, Integer pageSize);
101
+
102
+	/**
103
+	 * 获取账单的详细信息
104
+	 * @param billInvoiceId
105
+	 * @return
106
+	 */
107
+	Map<String, Object> getBillInvoiceDetail(Integer orgId,Integer billInvoiceId);
108
+
109
+	/**
110
+	 * 获取缴费历史
111
+	 * @param userElement
112
+	 * @return
113
+	 */
114
+	ResponseBean payHistory(TaUser userElement);
115
+
116
+	/**
117
+	 * 订单详情
118
+	 * @param orderNumber
119
+	 * @return
120
+	 */
121
+	ResponseBean getOrderInfo(String orderNumber);
89 122
 }

+ 128
- 1
src/main/java/com/huiju/estateagents/property/service/impl/BillServiceImpl.java Ver fichero

@@ -2,13 +2,13 @@ package com.huiju.estateagents.property.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8
 import com.huiju.estateagents.base.ResponseBean;
8 9
 import com.huiju.estateagents.center.taUser.entity.TaUser;
9 10
 import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
10 11
 import com.huiju.estateagents.property.common.Constant;
11
-import com.huiju.estateagents.property.common.UserElement;
12 12
 import com.huiju.estateagents.property.dao.*;
13 13
 import com.huiju.estateagents.property.exception.WisdomException;
14 14
 import com.huiju.estateagents.property.model.*;
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
20 20
 import com.google.common.collect.Maps;
21 21
 import lombok.Data;
22 22
 import lombok.extern.slf4j.Slf4j;
23
+import org.apache.commons.collections.CollectionUtils;
23 24
 import org.apache.commons.lang3.StringUtils;
24 25
 import org.apache.poi.hssf.usermodel.HSSFCell;
25 26
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -97,6 +98,12 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
97 98
     @Autowired
98 99
     private TpRoomNoMapper tpRoomNoMapper;
99 100
 
101
+    @Autowired
102
+    private TpBillOrderMapper tpBillOrderMapper;
103
+
104
+    @Autowired
105
+    private BillStatementMapper tpBillStatementMapper;
106
+
100 107
     @Override
101 108
     @Transactional(rollbackFor = Exception.class)
102 109
     public ResponseBean updateBillNameAndBillExplainAndEndDate(TaUser userElement, String parameter) {
@@ -677,4 +684,124 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
677 684
         }
678 685
     }
679 686
 
687
+    /**
688
+     * 根据payType分页获取缴费或未缴费的数据
689
+     * @param userElement
690
+     * @param payType
691
+     * @param pageNum
692
+     * @param pageSize
693
+     * @return
694
+     */
695
+    @Override
696
+    public Map<String, Object> getBillsList(TaUser userElement, Integer payType, Integer pageNum, Integer pageSize) {
697
+
698
+
699
+        /**
700
+         * 账单 关联的是房产,
701
+         */
702
+
703
+        //使用分页插件
704
+        IPage<Map<String,Object>> page = new Page<>(pageNum, pageSize);
705
+        IPage<Map<String,Object>> billsPage = billInvoiceMapper.getBillsList(page,userElement.getOrgId(), userElement.getRoomNoId(), payType);
706
+        List<Map<String, Object>> billsList = billsPage.getRecords();
707
+        billsList.forEach(e-> {
708
+            String payPrice = String.valueOf(e.get("payPrice"));
709
+            Double payPriceDouble = Double.valueOf(payPrice) / 100;
710
+            e.put("payPrice", payPriceDouble);
711
+        });
712
+        Map<String,Object> result = Maps.newHashMap();
713
+        result.put("list",billsList);
714
+        result.put("total",page.getTotal());
715
+        return result;
716
+    }
717
+
718
+    /**
719
+     * 获取账单的详细信息
720
+     * @param billInvoiceId
721
+     * @return
722
+     */
723
+    @Override
724
+    public Map<String, Object> getBillInvoiceDetail(Integer orgId,Integer billInvoiceId) {
725
+        Map<String, Object> billInvoiceDetail = billInvoiceMapper.getBillInvoiceDetail(orgId, billInvoiceId);
726
+        String payPrice = String.valueOf(billInvoiceDetail.get("payPrice"));
727
+        Double payPriceDouble = Double.valueOf(payPrice) / 100;
728
+        billInvoiceDetail.put("payPrice", payPriceDouble);
729
+        return billInvoiceDetail;
730
+    }
731
+
732
+    @Override
733
+    public ResponseBean payHistory(TaUser userElement) {
734
+        ResponseBean responseBean = new ResponseBean();
735
+
736
+        //1. 查询所有订单
737
+        //2. 根据订单
738
+
739
+
740
+        // 所有订单
741
+        List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByRoomNoId(userElement.getRoomNoId());
742
+        billOrderList.forEach(e->{
743
+            // 这个订单的所有缴费信息
744
+            List<TpBillOrder> orderList = tpBillOrderMapper.selectByOrderBumber(e.getOrderBumber());
745
+
746
+            // 缴费组
747
+            List<BillInvoice> tpBillInvoices = orderList.stream().map(billOrder -> billInvoiceMapper.selectByIdBillInvoiceInfo(billOrder.getTpBillInvoiceId())).collect(Collectors.toList());
748
+            tpBillInvoices.forEach( billInvoice -> billInvoice.setSumPayPrice(Double.valueOf(billInvoice.getPayPrice() + "") / 100));
749
+
750
+            // 所有缴费组的总额
751
+            Long billCountPrice = Long.valueOf(tpBillInvoices.stream().map(billCount -> billCount.getPayPrice()).count() + "") / 100;
752
+
753
+
754
+            e.setBillList(tpBillInvoices);
755
+            e.setSumPrice(billCountPrice);
756
+        });
757
+
758
+        responseBean.addSuccess(billOrderList);
759
+        return responseBean;
760
+    }
761
+
762
+    @Override
763
+    public ResponseBean getOrderInfo(String orderNumber) {
764
+        ResponseBean responseBean = new ResponseBean();
765
+
766
+        /**
767
+         * 1.根据订单号获取所有缴费组
768
+         * 2.获取其中的一条缴费订单数据, 因为订单号再库里面是多条,取第一条就可以
769
+         * 3.计算出所有缴费组的总额
770
+         * 4.获取一个缴费的流水记录, 因为 订单号对应多个缴费单,每一个缴费单对应一个缴费流水, 然后通过缴费流水可以知道缴费人,缴费类型,缴费备注等等
771
+         */
772
+
773
+        // 这个订单所有的缴费组记录, 拿到每一个缴费组的id
774
+        List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderNumberBill(orderNumber);
775
+        if (CollectionUtils.isEmpty(billOrderList)) {
776
+            responseBean.addError("订单号不存在!");
777
+            return responseBean;
778
+        }
779
+        // 每个缴费单数据
780
+        List<BillInvoice> tpBillInvoices = billOrderList.stream().map(e -> billInvoiceMapper.selectByIdBillInvoiceInfo(e.getTpBillInvoiceId())).collect(Collectors.toList());
781
+        tpBillInvoices.forEach(e -> e.setSumPayPrice(Double.valueOf(e.getPayPrice() + "") / 100));
782
+
783
+        // 这个订单总额
784
+        Double billCountPrice = Double.valueOf(tpBillInvoices.stream().map(e -> e.getPayPrice()).count() + "") / 100;
785
+
786
+        // 因为订单号是多条,取第一条即可
787
+        TpBillOrder tpBillOrder = billOrderList.get(0);
788
+
789
+        // 获取一条流水
790
+        BillStatement tpBillStatement = tpBillStatementMapper.selectByCommunityIdAndBillInvoiceId(tpBillOrder.getOrgId(), tpBillOrder.getTpBillInvoiceId());
791
+
792
+
793
+        Map<String, Object> map = Maps.newHashMap();
794
+        map.put("orderNumber", orderNumber);
795
+        map.put("createDate", tpBillOrder.getCreateDate());
796
+        map.put("sumPrice", billCountPrice);
797
+        map.put("payName", tpBillStatement.getPayName());
798
+        map.put("updateDate", tpBillOrder.getUpdateDate());
799
+        map.put("payType", tpBillStatement.getPayType());
800
+        map.put("payRemark", tpBillStatement.getPayRemark());
801
+        map.put("list", tpBillInvoices);
802
+
803
+        responseBean.addSuccess(map);
804
+        return responseBean;
805
+    }
806
+
680 807
 }

+ 120
- 1
src/main/resources/mapper/property/BillInvoiceMapper.xml Ver fichero

@@ -1,7 +1,11 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.property.dao.BillInvoiceMapper">
4
-
4
+    <sql id="Base_Column_List" >
5
+    id, community_id, bill_id, building_owner_info_id, ta_user_id, bill_invoice_explain,
6
+    pay_price, bill_statement_id, bill_status, pay_name, pay_date, create_user, create_date,
7
+    update_user, update_date, pay_type
8
+  </sql>
5 9
     <select id="selectBillInvoice" resultType="com.huiju.estateagents.property.model.BillInvoice">
6 10
 
7 11
         SELECT
@@ -125,4 +129,119 @@
125 129
         GROUP BY
126 130
             community_id
127 131
     </select>
132
+
133
+    <select id="getBillsList" resultType="map">
134
+        SELECT
135
+        i.id,
136
+        i.bill_invoice_explain as billInvoiceExplain,
137
+        i.pay_price AS payPrice,
138
+        i.ta_user_id AS taUserId,
139
+        i.bill_status AS billStatus,
140
+        b.bill_name AS billName,
141
+        b.bill_explain AS billExplain,
142
+        b.end_date AS endDate,
143
+        b.create_date AS createDate,
144
+        i.out_trade_no AS outTradeNo
145
+        FROM
146
+        tp_bill_invoice i
147
+        LEFT JOIN tp_bill b ON b.id = i.bill_id
148
+        AND b.community_id = #{communityId,jdbcType=INTEGER}
149
+        WHERE
150
+        i.orgId = #{orgId,jdbcType=INTEGER}
151
+        <if test="payType == 0">
152
+            AND i.bill_status = 0
153
+        </if>
154
+        <if test="payType == 1">
155
+            AND (i.bill_status = 1 or i.bill_status = 2)
156
+        </if>
157
+        and i.status=1
158
+        AND i.room_no_id = #{roomNoId,jdbcType=INTEGER}
159
+    </select>
160
+
161
+    <select id="getBillInvoiceDetail" resultType="map">
162
+    SELECT
163
+        i.id,
164
+        i.bill_invoice_explain AS billInvoiceExplain,
165
+        i.pay_price AS payPrice,
166
+        i.ta_user_id AS taUserId,
167
+        i.bill_status AS billStatus,
168
+        b.bill_name AS billName,
169
+        b.bill_explain AS billExplain,
170
+        b.end_date AS endDate,
171
+        s.id AS billStatementId,
172
+        s.pay_name AS payName,
173
+        s.pay_remark AS payRemark,
174
+        s.pay_type AS payType,
175
+        s.create_time AS createTime,
176
+        i.out_trade_no AS outTradeNo
177
+    FROM
178
+        tp_bill_invoice i
179
+        LEFT JOIN tp_bill b ON b.id = i.bill_id
180
+        AND b.org_id = #{orgId,jdbcType=INTEGER}
181
+        LEFT JOIN tp_bill_statement s ON i.bill_statement_id = s.id
182
+        AND s.org_id = #{orgId,jdbcType=INTEGER}
183
+    WHERE
184
+        i.id = #{billInvoiceId,jdbcType=INTEGER}
185
+    AND i.org_id = #{orgId,jdbcType=INTEGER}
186
+  </select>
187
+
188
+    <select id="selectByIdAndroomNoId" resultType="com.huiju.estateagents.property.model.BillInvoice" >
189
+    SELECT
190
+        t.id,
191
+        t.community_id AS communityId,
192
+        t.bill_id AS billId,
193
+        t.building_owner_info_id AS buildingOwnerInfoId,
194
+        t.ta_user_id AS taUserId,
195
+        t.bill_invoice_explain AS billInvoiceExplain,
196
+        t.pay_price AS payPrice,
197
+        t.bill_statement_id AS billStatementId,
198
+        t.bill_status AS billStatus,
199
+        t.pay_name AS payName,
200
+        t.out_trade_no AS outTradeNo,
201
+        b.bill_name as billName
202
+    FROM
203
+	    tp_bill_invoice t
204
+	LEFT JOIN tp_bill b ON t.bill_id = b.id and b.community_id = #{communityId,jdbcType=INTEGER}
205
+    where t.id = #{id,jdbcType=INTEGER}
206
+    and t.community_id = #{communityId,jdbcType=INTEGER}
207
+    and t.status = 1
208
+    and t.room_no_id = #{roomNoId,jdbcType=INTEGER}
209
+  </select>
210
+
211
+    <select id="selectByOutTradeNo" resultType="com.huiju.estateagents.property.model.BillInvoice" >
212
+  SELECT
213
+        t.id,
214
+        t.community_id AS communityId,
215
+        t.bill_id AS billId,
216
+        t.building_owner_info_id AS buildingOwnerInfoId,
217
+        t.ta_user_id AS taUserId,
218
+        t.bill_invoice_explain AS billInvoiceExplain,
219
+        t.pay_price AS payPrice,
220
+        t.bill_statement_id AS billStatementId,
221
+        t.bill_status AS billStatus,
222
+        t.pay_name AS payName,
223
+        t.out_trade_no AS outTradeNo,
224
+        b.bill_name as billName
225
+    FROM
226
+	    tp_bill_invoice t
227
+	LEFT JOIN tp_bill b ON t.bill_id = b.id
228
+	where t.out_trade_no = #{outTradeNo,jdbcType=VARCHAR}
229
+	and t.status = 1
230
+  </select>
231
+
232
+    <select id="selectByBuildingOwnerInfoId" parameterType="integer" resultType="com.huiju.estateagents.property.model.BillInvoice" >
233
+        select
234
+        <include refid="Base_Column_List"/>
235
+        from tp_bill_invoice
236
+        where bill_statement_id = #{buildingOwnerInfoId,jdbcType=INTEGER}
237
+    </select>
238
+
239
+    <update id="updateBeach" parameterType="map" >
240
+        update tp_bill_invoice
241
+        set ta_user_id = #{map.taUserId}
242
+        where id in
243
+        <foreach collection="map.list" item="item" index="index" separator="," open="(" close=")">
244
+            #{item.id}
245
+        </foreach>
246
+    </update>
128 247
 </mapper>