fllmoyu 4 سال پیش
والد
کامیت
4b5afa5622
21فایلهای تغییر یافته به همراه668 افزوده شده و 38 حذف شده
  1. 8 0
      common/src/main/java/com/jpsoft/bus/modules/base/dao/OrderInfoDAO.java
  2. 3 0
      common/src/main/java/com/jpsoft/bus/modules/base/entity/OrderInfo.java
  3. 8 0
      common/src/main/java/com/jpsoft/bus/modules/base/service/OrderInfoService.java
  4. 13 0
      common/src/main/java/com/jpsoft/bus/modules/base/service/impl/OrderInfoServiceImpl.java
  5. 2 0
      common/src/main/java/com/jpsoft/bus/modules/bus/dao/VehicleInfoDAO.java
  6. 15 0
      common/src/main/java/com/jpsoft/bus/modules/bus/dto/VehicleDTO.java
  7. 2 0
      common/src/main/java/com/jpsoft/bus/modules/bus/service/VehicleInfoService.java
  8. 5 0
      common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/VehicleInfoServiceImpl.java
  9. 4 0
      common/src/main/java/com/jpsoft/bus/modules/merchant/dao/AccountInfoDAO.java
  10. 2 0
      common/src/main/java/com/jpsoft/bus/modules/merchant/dao/CapitalInfoDAO.java
  11. 22 19
      common/src/main/java/com/jpsoft/bus/modules/merchant/entity/CapitalInfo.java
  12. 4 0
      common/src/main/java/com/jpsoft/bus/modules/merchant/service/AccountInfoService.java
  13. 2 0
      common/src/main/java/com/jpsoft/bus/modules/merchant/service/CapitalInfoService.java
  14. 16 6
      common/src/main/java/com/jpsoft/bus/modules/merchant/service/impl/AccountInfoServiceImpl.java
  15. 11 6
      common/src/main/java/com/jpsoft/bus/modules/merchant/service/impl/CapitalInfoServiceImpl.java
  16. 72 1
      common/src/main/resources/mapper/base/OrderInfo.xml
  17. 8 0
      common/src/main/resources/mapper/bus/VehicleInfo.xml
  18. 19 2
      common/src/main/resources/mapper/merchant/AccountInfo.xml
  19. 16 4
      common/src/main/resources/mapper/merchant/CapitalInfo.xml
  20. 3 0
      web/src/main/java/com/jpsoft/bus/config/WebMvcConfig.java
  21. 433 0
      web/src/main/java/com/jpsoft/bus/modules/mobile/controller/MerchantApiController.java

+ 8 - 0
common/src/main/java/com/jpsoft/bus/modules/base/dao/OrderInfoDAO.java

@@ -1,6 +1,10 @@
 package com.jpsoft.bus.modules.base.dao;
 
+import java.math.BigDecimal;
 import java.util.List;
+
+import cn.hutool.core.date.DateTime;
+import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import java.util.Map;
@@ -23,4 +27,8 @@ public interface OrderInfoDAO {
 	List<OrderInfo> findByMergeOrderId(String mergeOrderId);
 
     OrderInfo findByPassengerIdMergeOrderId(String passengerId, String mergeOrderId);
+
+    BigDecimal paySum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay,Boolean settlementFlag);
+
+    Integer payNum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay, Boolean settlementFlag);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/base/entity/OrderInfo.java

@@ -73,6 +73,9 @@ public class OrderInfo {
     @ApiModelProperty(value = "购票的下车站点")
     private String ticketDownStationId;
 
+    @ApiModelProperty(value = "结算状态")
+    private Boolean settlementFlag = false;
+
 
     public String getPayNameStr(String payName){
         String payNameStr = "";

+ 8 - 0
common/src/main/java/com/jpsoft/bus/modules/base/service/OrderInfoService.java

@@ -1,9 +1,13 @@
 package com.jpsoft.bus.modules.base.service;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
+
+import cn.hutool.core.date.DateTime;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.github.pagehelper.Page;
+import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import com.jpsoft.bus.modules.common.dto.Sort;
 
 public interface OrderInfoService {
@@ -31,4 +35,8 @@ public interface OrderInfoService {
 	 * @throws Exception
 	 */
 	Boolean refund(String orderId,String userId) throws Exception;
+
+    BigDecimal paySum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay,Boolean settlementFlag);
+
+	Integer payNum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay,Boolean settlementFlag);
 }

+ 13 - 0
common/src/main/java/com/jpsoft/bus/modules/base/service/impl/OrderInfoServiceImpl.java

@@ -1,15 +1,18 @@
 package com.jpsoft.bus.modules.base.service.impl;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
 
+import cn.hutool.core.date.DateTime;
 import com.jpsoft.bus.modules.base.dao.OrderLogDAO;
 import com.jpsoft.bus.modules.base.entity.OrderLog;
 import com.jpsoft.bus.modules.base.service.OrderLogService;
 import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
+import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import com.jpsoft.bus.modules.bus.service.PassengerInfoService;
 import com.jpsoft.bus.modules.pay.service.AlipayService;
 import com.jpsoft.bus.modules.pay.service.WechatService;
@@ -148,4 +151,14 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 
 		return true;
 	}
+
+	@Override
+	public BigDecimal paySum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay,Boolean settlementFlag) {
+		return orderInfoDAO.paySum(vehicleInfoList,payName,beginOfDay,endOfDay,settlementFlag);
+	}
+
+	@Override
+	public Integer payNum(List<VehicleInfo> vehicleInfoList, String payName, DateTime beginOfDay, DateTime endOfDay, Boolean settlementFlag) {
+		return orderInfoDAO.payNum(vehicleInfoList,payName,beginOfDay,endOfDay,settlementFlag);
+	}
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/VehicleInfoDAO.java

@@ -21,4 +21,6 @@ public interface VehicleInfoDAO {
 	int updateGps(VehicleInfo entity);
 
 	VehicleInfo findByCarNum(String carNum);
+
+    List<VehicleInfo> findByCompanyId(String companyId);
 }

+ 15 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dto/VehicleDTO.java

@@ -0,0 +1,15 @@
+package com.jpsoft.bus.modules.bus.dto;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-5-7 16:08
+ */
+@Data
+public class VehicleDTO {
+
+    private String id;
+
+    private String licensePlateNumber;
+}

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

@@ -22,4 +22,6 @@ public interface VehicleInfoService {
 	VehicleInfo findByCarNum(String carNum);
 
 	void updateGps(VehicleInfo v);
+
+    List<VehicleInfo> findByCompanyId(String companyId);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/VehicleInfoServiceImpl.java

@@ -82,6 +82,11 @@ public class VehicleInfoServiceImpl implements VehicleInfoService {
 		vehicleInfoDAO.updateGps(v);
 	}
 
+	@Override
+	public List<VehicleInfo> findByCompanyId(String companyId) {
+		return vehicleInfoDAO.findByCompanyId(companyId);
+	}
+
 	@Override
 	public VehicleInfo findByCarNum(String carNum){
 		return vehicleInfoDAO.findByCarNum(carNum);

+ 4 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/dao/AccountInfoDAO.java

@@ -15,4 +15,8 @@ public interface AccountInfoDAO {
 	int delete(String id);
 	List<AccountInfo> list();
 	List<AccountInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
+
+    AccountInfo findByPhone(String phone);
+
+    AccountInfo findByOpenId(String openId);
 }

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

@@ -15,4 +15,6 @@ public interface CapitalInfoDAO {
 	int delete(String id);
 	List<CapitalInfo> list();
 	List<CapitalInfo> search(Map<String,Object> searchParams,List<Sort> sortList);
+
+    CapitalInfo findByMerchantId(String merchantId);
 }

+ 22 - 19
common/src/main/java/com/jpsoft/bus/modules/merchant/entity/CapitalInfo.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
+
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -11,33 +12,35 @@ import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
 /**
-  描述:merchant_capital_info的实体类
+ * 描述:merchant_capital_info的实体类
  */
 @Data
 @ApiModel(value = "merchant_capital_info的实体类")
 public class CapitalInfo {
-        @ApiModelProperty(value = "")
+    @ApiModelProperty(value = "")
     private String id;
-        @ApiModelProperty(value = "商户id")
+    @ApiModelProperty(value = "商户id")
     private String merchantId;
-        @ApiModelProperty(value = "可提现金额(线上)")
-    private BigDecimal withdrawalAmount;
-        @ApiModelProperty(value = "已提现金额(线上)")
-    private BigDecimal alreadyWithdrawalAmount;
-        @ApiModelProperty(value = "总收益(线上,不包含当天)")
-    private BigDecimal totalRevenue;
-        @ApiModelProperty(value = "创建人")
+    @ApiModelProperty(value = "可提现金额(线上)")
+    private BigDecimal withdrawalAmount = BigDecimal.ZERO;
+    @ApiModelProperty(value = "已提现金额(线上)")
+    private BigDecimal alreadyWithdrawalAmount= BigDecimal.ZERO;
+    @ApiModelProperty(value = "总收益(不包含当天)")
+    private BigDecimal totalRevenue= BigDecimal.ZERO;
+    @ApiModelProperty(value = "线上总收益(不包含当天)")
+    private BigDecimal onlineTotalRevenue= BigDecimal.ZERO;
+    @ApiModelProperty(value = "创建人")
     private String createBy;
-        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
     private Date createTime;
-        @ApiModelProperty(value = "更新人")
+    @ApiModelProperty(value = "更新人")
     private String updateBy;
-        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-	    @ApiModelProperty(value = "更新时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
-        @ApiModelProperty(value = "是否删除")
-    private Boolean delFlag;
+    @ApiModelProperty(value = "是否删除")
+    private Boolean delFlag = false;
 }

+ 4 - 0
common/src/main/java/com/jpsoft/bus/modules/merchant/service/AccountInfoService.java

@@ -14,4 +14,8 @@ public interface AccountInfoService {
 	int delete(String id);
 	List<AccountInfo> list();
 	Page<AccountInfo> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+
+    AccountInfo findByPhone(String phone);
+
+    AccountInfo findByOpenId(String openId);
 }

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

@@ -14,4 +14,6 @@ public interface CapitalInfoService {
 	int delete(String id);
 	List<CapitalInfo> list();
 	Page<CapitalInfo> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+
+    CapitalInfo findByMerchantId(String merchantId);
 }

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

@@ -29,14 +29,14 @@ public class AccountInfoServiceImpl implements AccountInfoService {
 	public int insert(AccountInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return accountInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(AccountInfo model) {
 		// TODO Auto-generated method stub
-		return accountInfoDAO.update(model);		
+		return accountInfoDAO.update(model);
 	}
 
 	@Override
@@ -49,22 +49,32 @@ public class AccountInfoServiceImpl implements AccountInfoService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = accountInfoDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<AccountInfo> list() {
 		// TODO Auto-generated method stub
 		return accountInfoDAO.list();
 	}
-		
+
 	@Override
 	public Page<AccountInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<AccountInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             accountInfoDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public AccountInfo findByPhone(String phone) {
+		return accountInfoDAO.findByPhone(phone);
+	}
+
+	@Override
+	public AccountInfo findByOpenId(String openId) {
+		return accountInfoDAO.findByOpenId(openId);
+	}
 }

+ 11 - 6
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,22 +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) {
+		return capitalInfoDAO.findByMerchantId(merchantId);
+	}
 }

+ 72 - 1
common/src/main/resources/mapper/base/OrderInfo.xml

@@ -27,6 +27,7 @@
 			<result property="mergeOrderId" column="merge_order_id"/>
 			<result property="ticketUpStationId" column="ticket_up_station_id"/>
 			<result property="ticketDownStationId" column="ticket_down_station_id"/>
+			<result property="settlementFlag" column="settlement_flag"/>
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.bus.modules.base.entity.OrderInfo">
 	<!--
@@ -36,7 +37,7 @@
 	-->
 	<![CDATA[
 		insert into base_order_info
-	    (id_,total_fee,body_,pay_status,pay_name,pay_fee,refund_fee,pay_time,out_order_no,transaction_id,open_id,payment_id,create_by,create_time,update_by,update_time,del_flag,passenger_id,ticket_type,goods_ticket,merge_order_id,ticket_up_station_id,ticket_down_station_id)
+	    (id_,total_fee,body_,pay_status,pay_name,pay_fee,refund_fee,pay_time,out_order_no,transaction_id,open_id,payment_id,create_by,create_time,update_by,update_time,del_flag,passenger_id,ticket_type,goods_ticket,merge_order_id,ticket_up_station_id,ticket_down_station_id,settlement_flag)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -62,6 +63,7 @@
 ,#{mergeOrderId,jdbcType=VARCHAR}
 ,#{ticketUpStationId,jdbcType=VARCHAR}
 ,#{ticketDownStationId,jdbcType=VARCHAR}
+,#{settlementFlag,jdbcType=NUMERIC}
 		)
 	]]>
 	</insert>
@@ -137,6 +139,9 @@
 			<if test="ticketDownStationId != null">
 				ticket_down_station_id = #{ticketDownStationId,jdbcType=VARCHAR},
 			</if>
+			<if test="settlementFlag != null">
+				settlement_flag = #{settlementFlag,jdbcType=NUMERIC}}
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
@@ -246,4 +251,70 @@
 		and merge_order_id = #{mergeOrderId}
 		]]>
 	</select>
+
+	<select id="paySum" resultType="java.math.BigDecimal">
+		<![CDATA[
+		select SUM(a.pay_fee) from base_order_info a
+		left join base_merge_order_info b on a.merge_order_id = b.id_
+		left join bus_shift_info c on b.vehicle_shift_id = c.id_
+		]]>
+		<where>
+			a.del_flag = 0
+			and a.pay_status = 20
+			<if test="payName != null">
+				and a.pay_name = #{payName}
+			</if>
+			<if test="vehicleInfoList!= null">
+				<foreach item="item" collection="vehicleInfoList" open="and c.vehicle_id in (" separator="," close=")">
+					#{item.id}
+				</foreach>
+			</if>
+			<if test="beginOfDay != null">
+				<![CDATA[
+			and	a.pay_time >= #{beginOfDay}
+				]]>
+			</if>
+			<if test="endOfDay != null">
+				<![CDATA[
+			and	a.pay_time < #{endOfDay}
+				]]>
+			</if>
+			<if test="settlementFlag != null">
+			and	a.settlement_flag = #{settlementFlag}
+			</if>
+		</where>
+	</select>
+
+	<select id="payNum" resultType="Integer">
+		<![CDATA[
+		select count(a.id_) from base_order_info a
+		left join base_merge_order_info b on a.merge_order_id = b.id_
+		left join bus_shift_info c on b.vehicle_shift_id = c.id_
+		]]>
+		<where>
+			a.del_flag = 0
+			and a.pay_status = 20
+			<if test="payName != null">
+				and a.pay_name = #{payName}
+			</if>
+			<if test="vehicleInfoList!= null">
+				<foreach item="item" collection="vehicleInfoList" open="and c.vehicle_id in (" separator="," close=")">
+					#{item.id}
+				</foreach>
+			</if>
+			<if test="beginOfDay != null">
+				<![CDATA[
+			and	a.pay_time >= #{beginOfDay}
+				]]>
+			</if>
+			<if test="endOfDay != null">
+				<![CDATA[
+			and	a.pay_time < #{endOfDay}
+				]]>
+			</if>
+			<if test="settlementFlag != null">
+				and	a.settlement_flag = #{settlementFlag}
+			</if>
+		</where>
+	</select>
 </mapper>

+ 8 - 0
common/src/main/resources/mapper/bus/VehicleInfo.xml

@@ -205,4 +205,12 @@
 		order by create_time desc limit 1
 	</select>
 
+	<select id="findByCompanyId" resultMap="VehicleInfoMap">
+		<![CDATA[
+		select * from bus_vehicle_info
+		where del_flag = 0
+		and company_id = #{companyId}
+		]]>
+	</select>
+
 </mapper>

+ 19 - 2
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">
@@ -101,7 +101,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="AccountInfoMap">
-		select 
+		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>
 	<select id="exist" parameterType="string" resultType="int">
@@ -123,4 +123,21 @@ id_,name_,company_id,open_id,phone_,withdraw_allow,frozen_,image_url,bank_name,b
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+	<select id="findByPhone" resultMap="AccountInfoMap">
+		<![CDATA[
+		select  * from merchant_account_info
+		where del_flag = 0
+		and phone_ = #{phone}
+		]]>
+	</select>
+
+	<select id="findByOpenId" resultMap="AccountInfoMap">
+		<![CDATA[
+		select * from merchant_account_info
+		where del_flag = 0
+		and open_id = #{openId}
+		limit 1
+		]]>
+	</select>
 </mapper>

+ 16 - 4
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">
@@ -9,6 +9,7 @@
 			<result property="withdrawalAmount" column="withdrawal_amount" />
 			<result property="alreadyWithdrawalAmount" column="already_withdrawal_amount" />
 			<result property="totalRevenue" column="total_revenue" />
+			<result property="onlineTotalRevenue" column="online_total_revenue"/>
 			<result property="createBy" column="create_by" />
 			<result property="createTime" column="create_time" />
 			<result property="updateBy" column="update_by" />
@@ -23,7 +24,7 @@
 	-->
 	<![CDATA[
 		insert into merchant_capital_info
-	    (id_,merchant_id,withdrawal_amount,already_withdrawal_amount,total_revenue,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,merchant_id,withdrawal_amount,already_withdrawal_amount,total_revenue,online_total_revenue,create_by,create_time,update_by,update_time,del_flag)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -31,6 +32,7 @@
 ,#{withdrawalAmount,jdbcType= NUMERIC }
 ,#{alreadyWithdrawalAmount,jdbcType= NUMERIC }
 ,#{totalRevenue,jdbcType= NUMERIC }
+,#{onlineTotalRevenue,jdbcType=NUMERIC}
 ,#{createBy,jdbcType=VARCHAR}
 ,#{createTime,jdbcType= TIMESTAMP }
 ,#{updateBy,jdbcType=VARCHAR}
@@ -57,6 +59,9 @@
 				<if test="totalRevenue!=null">
 		total_revenue=#{totalRevenue,jdbcType= NUMERIC },
 		</if>
+			<if test="onlineTotalRevenue!=null">
+				online_total_revenue=#{onlineTotalRevenue,jdbcType= NUMERIC },
+			</if>
 				<if test="createBy!=null">
 		create_by=#{createBy,jdbcType=VARCHAR},
 		</if>
@@ -76,8 +81,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="CapitalInfoMap">
-		select 
-id_,merchant_id,withdrawal_amount,already_withdrawal_amount,total_revenue,create_by,create_time,update_by,update_time,del_flag		from merchant_capital_info where id_=#{0}
+		select *	from merchant_capital_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from merchant_capital_info where id_=#{0}
@@ -98,4 +102,12 @@ id_,merchant_id,withdrawal_amount,already_withdrawal_amount,total_revenue,create
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+	<select id="findByMerchantId" resultMap="CapitalInfoMap">
+		<![CDATA[
+		select * from merchant_capital_info
+		where del_flag = 0
+		and merchant_id = #{merchantId}
+		]]>
+	</select>
 </mapper>

+ 3 - 0
web/src/main/java/com/jpsoft/bus/config/WebMvcConfig.java

@@ -90,6 +90,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/passengerApi/passengerShiftRemindList")
 				.excludePathPatterns("/mobile/passengerApi/helpCenterList")
 				.excludePathPatterns("/mobile/passengerApi/vehicleStationDis")
+				.excludePathPatterns("/mobile/merchantApi/getVerifyCode")
+				.excludePathPatterns("/mobile/merchantApi/validateCode")
+				.excludePathPatterns("/mobile/merchantApi/findByOpenId")
 
 
 		;

+ 433 - 0
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/MerchantApiController.java

@@ -0,0 +1,433 @@
+package com.jpsoft.bus.modules.mobile.controller;
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.jpsoft.bus.modules.base.entity.ProblemFeedback;
+import com.jpsoft.bus.modules.base.service.OrderInfoService;
+import com.jpsoft.bus.modules.bus.dto.VehicleDTO;
+import com.jpsoft.bus.modules.bus.entity.CompanyInfo;
+import com.jpsoft.bus.modules.bus.entity.UserInfo;
+import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
+import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
+import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
+import com.jpsoft.bus.modules.common.dto.MessageResult;
+import com.jpsoft.bus.modules.common.utils.DES3;
+import com.jpsoft.bus.modules.common.utils.JwtUtil;
+import com.jpsoft.bus.modules.common.utils.SMSUtil;
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
+import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
+import com.jpsoft.bus.modules.merchant.service.AccountInfoService;
+import com.jpsoft.bus.modules.merchant.service.CapitalInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-5-7 11:05
+ */
+@RestController
+@RequestMapping("/mobile/merchantApi")
+@Api(value = "merchantApi")
+@Slf4j
+public class MerchantApiController {
+
+    @Value("${jwt.secret}")
+    private String jwtSecret;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @Autowired
+    private CapitalInfoService capitalInfoService;
+
+    @Autowired
+    private OrderInfoService orderInfoService;
+
+    @Autowired
+    private VehicleInfoService vehicleInfoService;
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    @Autowired
+    private AccountInfoService accountInfoService;
+
+
+    @PostMapping("getVerifyCode")
+    @ApiOperation(value = "商户获取短信验证码(公开接口)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "phone", value = "电话", required = true, paramType = "form")
+    })
+    public MessageResult<String> getVerifyCode(String phone) {
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+
+            AccountInfo accountInfo = accountInfoService.findByPhone(phone);
+            if (accountInfo == null) {
+                throw new Exception("该号码还未注册营收管理员帐号");
+            }
+
+
+            String key = "SMS_" + phone;
+
+            String verifyCode = (String) redisTemplate.opsForValue().get(key);
+
+            if (StringUtils.isEmpty(verifyCode)) {
+                verifyCode = SMSUtil.generateNumberString(6);
+                JSONObject verifyCodeJSON = new JSONObject();
+                verifyCodeJSON.put("code", verifyCode);
+
+                messageResult = SMSUtil.send(phone, "车信达", "SMS_49390047", verifyCodeJSON.toString());
+
+                //设置当前用户的验证码,5分钟内有效
+                redisTemplate.opsForValue().set(key, verifyCode, 5, TimeUnit.MINUTES);
+            }
+
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setResult(false);
+            messageResult.setCode(400);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("validateCode")
+    @ApiOperation(value = "验证短信验证码(公开接口)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "verifyCode", value = "验证码", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "openId", value = "微信openId", paramType = "form")
+    })
+    public MessageResult<Map> validateCode(String phone, String verifyCode, String openId) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+
+            AccountInfo accountInfo = accountInfoService.findByPhone(phone);
+            if (accountInfo == null) {
+                throw new Exception("该号码还未注册营收管理员帐号");
+            }
+            String smsKey = "SMS_" + phone;
+
+            String beforeVerifyCode = (String) redisTemplate.opsForValue().get(smsKey);
+
+            if (StringUtils.isBlank(openId)) {
+                throw new Exception("用户标识为空");
+            }
+
+            if (StringUtils.isEmpty(beforeVerifyCode)) {
+                throw new Exception("验证码已过期!");
+            }
+
+            if (!beforeVerifyCode.equals(verifyCode)) {
+                throw new Exception("验证码错误!");
+            }
+
+            accountInfo.setOpenId(openId);
+            accountInfoService.update(accountInfo);
+
+
+            String token = JwtUtil.createToken(jwtSecret, String.valueOf(accountInfo.getId()), DateTime.now().plusDays(30).toDate());
+
+            Map<String, Object> map = new HashMap<>();
+            map.put("token", token);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("findByOpenId")
+    @ApiOperation(value = "通过openId查询人员(公开接口)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "openId", value = "微信openId", required = true, paramType = "form")
+    })
+    public MessageResult<Map> findByOpenId(String openId) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            if (StringUtils.isBlank(openId)) {
+                throw new Exception("获取微信信息有误");
+            }
+            AccountInfo accountInfo = accountInfoService.findByOpenId(openId);
+
+            String token = JwtUtil.createToken(jwtSecret, String.valueOf(accountInfo.getId()), DateTime.now().plusDays(30).toDate());
+
+            Map<String, Object> map = new HashMap<>();
+            map.put("token", token);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+
+    @PostMapping("revenueStatisticsUp")
+    @ApiOperation(value = "营收统计(上)")
+    public MessageResult<Map> revenueStatisticsUp(String token, @RequestAttribute String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            AccountInfo accountInfo = accountInfoService.get(subject);
+            if (accountInfo == null){
+                throw new Exception("请重新登录");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            //今日收益
+            BigDecimal todayRevenue = BigDecimal.ZERO;
+            //昨日收益
+            BigDecimal yesterdayRevenue = BigDecimal.ZERO;
+            //累计收益
+            BigDecimal totalRevenue = BigDecimal.ZERO;
+
+            CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
+            if (capitalInfo != null){
+                totalRevenue = capitalInfo.getTotalRevenue();
+            }
+
+            if (vehicleInfoList.size()>0){
+                //今日收益
+                BigDecimal todaySum = orderInfoService.paySum(vehicleInfoList,null, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (todaySum != null){
+                    todayRevenue = todaySum;
+                }
+                //昨日收益
+                BigDecimal yesterdaySum = orderInfoService.paySum(vehicleInfoList,null,DateUtil.beginOfDay(DateUtil.offsetDay(new Date(),-1)),DateUtil.endOfDay(DateUtil.offsetDay(new Date(),-1)),null);
+                if (yesterdaySum != null){
+                    yesterdayRevenue = yesterdaySum;
+                }
+
+                //总收益
+                BigDecimal totalSum = orderInfoService.paySum(vehicleInfoList,null,null,new cn.hutool.core.date.DateTime(),null);
+
+                if (totalSum != null){
+                    totalRevenue = totalSum;
+                }
+
+
+            }
+
+            Map<String,Object> map = new HashMap<>();
+            map.put("todayRevenue",todayRevenue);
+            map.put("yesterdayRevenue",yesterdayRevenue);
+            map.put("totalRevenue",totalRevenue);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("revenueStatisticsDown")
+    @ApiOperation(value = "营收统计(下)")
+    public MessageResult<Map> revenueStatisticsDown(String token, @RequestAttribute String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            AccountInfo accountInfo = accountInfoService.get(subject);
+            if (accountInfo == null){
+                throw new Exception("请重新登录");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            //线上购票款
+            BigDecimal onlineRevenue = BigDecimal.ZERO;
+            //微信收款
+            BigDecimal wechatRevenue = BigDecimal.ZERO;
+            //支付宝收款
+            BigDecimal alipayRevenue = BigDecimal.ZERO;
+            //现金收款
+            BigDecimal cashRevenue = BigDecimal.ZERO;
+            //车票收款
+            BigDecimal ticketRevenue = BigDecimal.ZERO;
+            //售票数
+            Integer num = 0;
+
+
+
+            if (vehicleInfoList.size()>0){
+                //微信
+                BigDecimal wechatSum = orderInfoService.paySum(vehicleInfoList,"wechat", DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (wechatSum != null){
+                    wechatRevenue = wechatSum;
+                }
+                //支付宝
+                BigDecimal alipaySum = orderInfoService.paySum(vehicleInfoList,"alipay",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (alipaySum != null){
+                    alipayRevenue = alipaySum;
+                }
+
+                //现金
+                BigDecimal cashSum = orderInfoService.paySum(vehicleInfoList,"cash",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (cashSum != null){
+                    cashRevenue = cashSum;
+                }
+
+                //车票
+                BigDecimal ticketSum = orderInfoService.paySum(vehicleInfoList,"ticket",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (ticketSum != null){
+                    ticketRevenue = ticketSum;
+                }
+
+                Integer ticketNum = orderInfoService.payNum(vehicleInfoList,null,DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
+                if (ticketNum != null){
+                    num = ticketNum;
+                }
+
+
+            }
+
+            Map<String,Object> map = new HashMap<>();
+            map.put("onlineRevenue",wechatRevenue.add(alipayRevenue));
+            map.put("wechatRevenue",wechatRevenue);
+            map.put("alipayRevenue",alipayRevenue);
+            map.put("cashRevenue",cashRevenue);
+            map.put("ticketRevenue",ticketRevenue);
+            map.put("num",num);
+
+            messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+    @PostMapping("merchantVehicleList")
+    @ApiOperation(value = "商户的车辆列表")
+    public MessageResult<List<VehicleDTO>> merchantVehicleList(String token, @RequestAttribute String subject) {
+        MessageResult<List<VehicleDTO>> messageResult = new MessageResult<>();
+
+        try {
+
+            AccountInfo accountInfo = accountInfoService.get(subject);
+            if (accountInfo == null){
+                throw new Exception("请重新登录");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            List<VehicleDTO> list = new ArrayList<>();
+            if (vehicleInfoList.size()>0){
+                for (VehicleInfo vehicleInfo : vehicleInfoList){
+                    VehicleDTO vehicleDTO = new VehicleDTO();
+                    BeanUtils.copyProperties(vehicleInfo,vehicleDTO);
+                    list.add(vehicleDTO);
+                }
+            }
+
+            messageResult.setData(list);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+    @PostMapping("profitList")
+    @ApiOperation(value = "收益明细")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "vehicleId", value = "车辆id", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
+            @ApiImplicitParam(name = "date", value = "时间(格式:yyyy-MM)", required = false, paramType = "form")
+    })
+    public MessageResult<Map> profitList(String vehicleId,String payName,String date,String token, @RequestAttribute String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            AccountInfo accountInfo = accountInfoService.get(subject);
+            if (accountInfo == null){
+                throw new Exception("请重新登录");
+            }
+            CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
+            List<VehicleInfo> vehicleInfoList = new ArrayList<>();
+            if (StringUtils.isNotBlank(vehicleId)){
+                VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
+                if (vehicleInfo != null){
+                    vehicleInfoList.add(vehicleInfo);
+                }
+            }else {
+                vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            }
+
+
+
+
+
+
+           // map.put("token", token);
+
+         //   messageResult.setData(map);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+}