xiao547607 4 éve
szülő
commit
564479edba

+ 1 - 2
common/src/main/java/com/jpsoft/bus/modules/merchant/dao/CapitalInfoDAO.java

@@ -13,8 +13,7 @@ public interface CapitalInfoDAO {
 	int exist(String id);
 	CapitalInfo get(String id);
 	int delete(String id);
+	CapitalInfo findByMerchantId(String merchantId);
 	List<CapitalInfo> list();
 	List<CapitalInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
-
-    CapitalInfo findByMerchantId(String merchantId);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/dao/WithdrawalRecordDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.bus.modules.merchant.dao;
 
 import java.util.List;
+
+import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.bus.modules.merchant.entity.WithdrawalRecord;
 import java.util.Map;
@@ -13,6 +15,7 @@ public interface WithdrawalRecordDAO {
 	int exist(String id);
 	WithdrawalRecord get(String id);
 	int delete(String id);
+	WithdrawalRecord findByMerchantId(String merchantId);
 	List<WithdrawalRecord> list();
 	List<WithdrawalRecord> search(Map<String,Object> searchParams,List<Sort> sortList);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/entity/AccountInfo.java

@@ -50,4 +50,7 @@ public class AccountInfo {
     private Date updateTime;
         @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
+
+    @ApiModelProperty(value = "关联的公司车队")
+    private String companyName;
 }

+ 5 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/entity/WithdrawalRecord.java

@@ -52,4 +52,9 @@ public class WithdrawalRecord {
     private Date updateTime;
         @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
+
+    @ApiModelProperty(value = "商户相关信息")
+    private AccountInfo accountInfo;
+    @ApiModelProperty(value = "商户账户相关信息")
+    private CapitalInfo capitalInfo;
 }

+ 3 - 2
common/src/main/java/com/jpsoft/bus/modules/merchant/service/CapitalInfoService.java

@@ -2,6 +2,8 @@ package com.jpsoft.bus.modules.merchant.service;
 
 import java.util.List;
 import java.util.Map;
+
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
 import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.common.dto.Sort;
@@ -12,8 +14,7 @@ public interface CapitalInfoService {
 	int insert(CapitalInfo model);
 	int update(CapitalInfo model);
 	int delete(String id);
+	CapitalInfo findByMerchantId(String merchantId);
 	List<CapitalInfo> list();
 	Page<CapitalInfo> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
-
-    CapitalInfo findByMerchantId(String merchantId);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/service/WithdrawalRecordService.java

@@ -2,6 +2,7 @@ package com.jpsoft.bus.modules.merchant.service;
 
 import java.util.List;
 import java.util.Map;
+
 import com.jpsoft.bus.modules.merchant.entity.WithdrawalRecord;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.common.dto.Sort;
@@ -12,6 +13,7 @@ public interface WithdrawalRecordService {
 	int insert(WithdrawalRecord model);
 	int update(WithdrawalRecord model);
 	int delete(String id);
+	WithdrawalRecord findByMerchantId(String merchantId);
 	List<WithdrawalRecord> list();
 	Page<WithdrawalRecord> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
 }

+ 7 - 7
common/src/main/java/com/jpsoft/bus/modules/merchant/service/impl/CapitalInfoServiceImpl.java

@@ -29,14 +29,14 @@ public class CapitalInfoServiceImpl implements CapitalInfoService {
 	public int insert(CapitalInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-
+		
 		return capitalInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(CapitalInfo model) {
 		// TODO Auto-generated method stub
-		return capitalInfoDAO.update(model);
+		return capitalInfoDAO.update(model);		
 	}
 
 	@Override
@@ -49,27 +49,27 @@ public class CapitalInfoServiceImpl implements CapitalInfoService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = capitalInfoDAO.exist(id);
-
+		
 		return count > 0 ? true : false;
 	}
-
+	
 	@Override
 	public List<CapitalInfo> list() {
 		// TODO Auto-generated method stub
 		return capitalInfoDAO.list();
 	}
-
+		
 	@Override
 	public Page<CapitalInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<CapitalInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             capitalInfoDAO.search(searchParams,sortList);
         });
-
+        
         return page;
 	}
 
 	@Override
-	public CapitalInfo findByMerchantId(String merchantId) {
+	public CapitalInfo findByMerchantId(String merchantId){
 		return capitalInfoDAO.findByMerchantId(merchantId);
 	}
 }

+ 6 - 1
common/src/main/java/com/jpsoft/bus/modules/merchant/service/impl/WithdrawalRecordServiceImpl.java

@@ -2,8 +2,8 @@ package com.jpsoft.bus.modules.merchant.service.impl;
 
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import javax.annotation.Resource;
+
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.bus.modules.merchant.dao.WithdrawalRecordDAO;
@@ -67,4 +67,9 @@ public class WithdrawalRecordServiceImpl implements WithdrawalRecordService {
         
         return page;
 	}
+
+	@Override
+	public WithdrawalRecord findByMerchantId(String merchantId){
+		return withdrawalRecordDAO.findByMerchantId(merchantId);
+	}
 }

+ 29 - 5
common/src/main/resources/mapper/merchant/AccountInfo.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.bus.modules.merchant.dao.AccountInfoDAO">
@@ -19,6 +19,7 @@
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
 			<result property="delFlag" column="del_flag" />
+			<result property="companyName" column="company_name" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.bus.modules.merchant.entity.AccountInfo">
 	<!--
@@ -101,8 +102,13 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="AccountInfoMap">
-		select
-id_,name_,company_id,open_id,phone_,withdraw_allow,frozen_,image_url,bank_name,bank_number,create_by,create_time,update_by,update_time,del_flag		from merchant_account_info where id_=#{0}
+		SELECT
+		a.*,
+		b.name_ AS company_name
+		FROM
+		merchant_account_info a
+		LEFT JOIN bus_company_info b ON a.company_id = b.id_
+		where a.id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from merchant_account_info where id_=#{0}
@@ -112,11 +118,29 @@ id_,name_,company_id,open_id,phone_,withdraw_allow,frozen_,image_url,bank_name,b
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="AccountInfoMap">
 		<![CDATA[
-			select * from merchant_account_info
+			SELECT
+				a.*,
+				b.name_ AS company_name
+			FROM
+				merchant_account_info a
+				LEFT JOIN bus_company_info b ON b.id_ = a.company_id
 		]]>
 		<where>
+			a.del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and a.ID_ like #{searchParams.id}
+			</if>
+			<if test="searchParams.companyCode != null">
+				and b.code_ like #{searchParams.companyCode}
+			</if>
+			<if test="searchParams.name != null">
+				and a.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.phone != null">
+				and a.phone_ like #{searchParams.phone}
+			</if>
+			<if test="searchParams.frozen != null">
+				and a.frozen_ = #{searchParams.frozen}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 10 - 6
common/src/main/resources/mapper/merchant/CapitalInfo.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.bus.modules.merchant.dao.CapitalInfoDAO">
@@ -102,12 +102,16 @@
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
-
-	<select id="findByMerchantId" resultMap="CapitalInfoMap">
+	<select id="findByMerchantId" parameterType="string" resultMap="CapitalInfoMap">
 		<![CDATA[
-		select * from merchant_capital_info
-		where del_flag = 0
-		and merchant_id = #{merchantId}
+		SELECT
+			*
+			FROM
+			merchant_capital_info
+		WHERE
+			del_flag = 0
+			AND merchant_id = #{merchantId}
+		limit 1
 		]]>
 	</select>
 </mapper>

+ 35 - 3
common/src/main/resources/mapper/merchant/WithdrawalRecord.xml

@@ -96,8 +96,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="WithdrawalRecordMap">
-		select 
-id_,merchant_id,apply_withdrawal_amount,apply_time,status_,examine_time,examine_by,remark_,withdrawal_no,create_by,create_time,update_by,update_time,del_flag		from merchant_withdrawal_record where id_=#{0}
+		select * from merchant_withdrawal_record where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from merchant_withdrawal_record where id_=#{0}
@@ -107,15 +106,48 @@ id_,merchant_id,apply_withdrawal_amount,apply_time,status_,examine_time,examine_
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="WithdrawalRecordMap">
 		<![CDATA[
-			select * from merchant_withdrawal_record
+			SELECT
+				a.*
+			FROM
+				merchant_withdrawal_record a
+				LEFT JOIN merchant_account_info b ON a.merchant_id = b.id_
+				LEFT JOIN bus_company_info c ON b.company_id = c.id_
 		]]>
 		<where>
+			a.del_flag = 0
 			<if test="searchParams.id != null">
 				and ID_ like #{searchParams.id}
 			</if>
+			<if test="searchParams.companyCode != null">
+				and c.code_ like #{searchParams.companyCode}
+			</if>
+			<if test="searchParams.name != null">
+				and b.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.phone != null">
+				and b.phone_ like #{searchParams.phone}
+			</if>
+			<if test="searchParams.status != null">
+				and a.status_ = #{searchParams.status}
+			</if>
+			<if test="searchParams.withdrawalNo != null">
+				and a.withdrawal_no like #{searchParams.withdrawalNo}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="findByMerchantId" parameterType="string" resultMap="WithdrawalRecordMap">
+		<![CDATA[
+		SELECT
+			*
+			FROM
+			merchant_withdrawal_record
+		WHERE
+			del_flag = 0
+			AND merchant_id = #{merchantId}
+		limit 1
+		]]>
+	</select>
 </mapper>

+ 34 - 1
web/src/main/java/com/jpsoft/bus/modules/merchant/controller/AccountInfoController.java

@@ -1,11 +1,15 @@
 package com.jpsoft.bus.modules.merchant.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.bus.modules.bus.entity.CompanyInfo;
+import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
 import com.jpsoft.bus.modules.common.dto.MessageResult;
 import com.jpsoft.bus.modules.common.dto.Sort;
 import com.jpsoft.bus.modules.common.utils.PojoUtils;
 import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
 import com.jpsoft.bus.modules.merchant.service.AccountInfoService;
+import com.jpsoft.bus.modules.sys.entity.User;
+import com.jpsoft.bus.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -26,6 +30,10 @@ public class AccountInfoController {
 
     @Autowired
     private AccountInfoService accountInfoService;
+    @Autowired
+    private CompanyInfoService companyInfoService;
+    @Autowired
+    private UserService userService;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -197,6 +205,10 @@ public class AccountInfoController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestParam(value="phone",defaultValue="") String phone,
+            @RequestParam(value="frozen",defaultValue="") String frozen,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -209,12 +221,33 @@ public class AccountInfoController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
-        sortList.add(new Sort("id_","asc"));
+        sortList.add(new Sort("b.sort_no","asc"));
+        sortList.add(new Sort("a.create_time","asc"));
 
         if (StringUtils.isNotEmpty(id)) {
             searchParams.put("id","%" + id + "%");
         }
 
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(phone)) {
+            searchParams.put("phone","%" + phone + "%");
+        }
+        if (StringUtils.isNotEmpty(frozen)) {
+            searchParams.put("frozen",frozen);
+        }
+        if (StringUtils.isNotEmpty(companyId)) {
+            CompanyInfo companyInfo = companyInfoService.get(companyId);
+            searchParams.put("companyCode",companyInfo.getCode() + "%");
+        }else{
+            if (!userService.hasRole(subject, "SYSADMIN")) {
+                User user = userService.get(subject);
+                CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+                searchParams.put("companyCode", companyInfo.getCode() + "%");
+            }
+        }
+
         Page<AccountInfo> page = accountInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
 
         msgResult.setResult(true);

+ 51 - 0
web/src/main/java/com/jpsoft/bus/modules/merchant/controller/WithdrawalRecordController.java

@@ -1,11 +1,19 @@
 package com.jpsoft.bus.modules.merchant.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.bus.modules.bus.entity.CompanyInfo;
+import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
 import com.jpsoft.bus.modules.common.dto.MessageResult;
 import com.jpsoft.bus.modules.common.dto.Sort;
 import com.jpsoft.bus.modules.common.utils.PojoUtils;
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
+import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
 import com.jpsoft.bus.modules.merchant.entity.WithdrawalRecord;
+import com.jpsoft.bus.modules.merchant.service.AccountInfoService;
+import com.jpsoft.bus.modules.merchant.service.CapitalInfoService;
 import com.jpsoft.bus.modules.merchant.service.WithdrawalRecordService;
+import com.jpsoft.bus.modules.sys.entity.User;
+import com.jpsoft.bus.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
@@ -26,6 +34,14 @@ public class WithdrawalRecordController {
 
     @Autowired
     private WithdrawalRecordService withdrawalRecordService;
+    @Autowired
+    private AccountInfoService accountInfoService;
+    @Autowired
+    private CapitalInfoService capitalInfoService;
+    @Autowired
+    private CompanyInfoService companyInfoService;
+    @Autowired
+    private UserService userService;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -197,6 +213,11 @@ public class WithdrawalRecordController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestParam(value="phone",defaultValue="") String phone,
+            @RequestParam(value="status",defaultValue="") String status,
+            @RequestParam(value="withdrawalNo",defaultValue="") String withdrawalNo,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -215,7 +236,37 @@ public class WithdrawalRecordController {
             searchParams.put("id","%" + id + "%");
         }
 
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(phone)) {
+            searchParams.put("phone","%" + phone + "%");
+        }
+        if (StringUtils.isNotEmpty(status)) {
+            searchParams.put("status",status);
+        }
+        if (StringUtils.isNotEmpty(withdrawalNo)) {
+            searchParams.put("withdrawalNo","%" + withdrawalNo + "%");
+        }
+
+        if (StringUtils.isNotEmpty(companyId)) {
+            CompanyInfo companyInfo = companyInfoService.get(companyId);
+            searchParams.put("companyCode",companyInfo.getCode() + "%");
+        }else{
+            if (!userService.hasRole(subject, "SYSADMIN")) {
+                User user = userService.get(subject);
+                CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+                searchParams.put("companyCode", companyInfo.getCode() + "%");
+            }
+        }
+
         Page<WithdrawalRecord> page = withdrawalRecordService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+        for(WithdrawalRecord wr : page.getResult()){
+            AccountInfo ac = accountInfoService.get(wr.getMerchantId());
+            wr.setAccountInfo(ac);
+            CapitalInfo ci = capitalInfoService.findByMerchantId(wr.getMerchantId());
+            wr.setCapitalInfo(ci);
+        }
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));