Bläddra i källkod

sp_admin 加入类型(00=运营管理者,01=合作社),运营者统计全部,合作社只统计对应的互市区ID

李书文 1 år sedan
förälder
incheckning
cd14e64b3a

+ 2 - 0
sp-core/sp-base/src/main/java/com/pj/current/dto/PCLoginUserInfo.java

@@ -9,4 +9,6 @@ import java.io.Serializable;
 public class PCLoginUserInfo implements Serializable {
     private String loginId;
     private String loginName;
+    private String type;
+    private Long tradeAreaId;
 }

+ 20 - 3
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersController.java

@@ -1,6 +1,8 @@
 package com.pj.tb_orders;
 
 import java.util.List;
+
+import com.pj.current.satoken.StpUserUtil;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -89,7 +91,14 @@ public class TbOrdersController {
 	public AjaxJson selectYear() {
 		SoMap so=new SoMap();
 		so.put("year",tbOrdersService.selectYear());
-		so.put("count",tbOrdersService.totalMoney());
+		//运营管理者统计全部
+		if(StpUserUtil.getPCLoginInfo().getType()==null||StpUserUtil.getPCLoginInfo().getType().equals("00")){
+			so.put("count",tbOrdersService.totalMoney(null));
+		}
+		//合作社只统计对应的互市id
+		if(StpUserUtil.getPCLoginInfo().getType()!=null&&StpUserUtil.getPCLoginInfo().getType().equals("01")){
+			so.put("count",tbOrdersService.totalMoney(StpUserUtil.getPCLoginInfo().getTradeAreaId()));
+		}
 		return AjaxJson.getSuccessData(so);
 	}
 
@@ -97,8 +106,16 @@ public class TbOrdersController {
 	@RequestMapping("orderStatistics")
 	public AjaxJson orderStatistics(String year) {
 		SoMap so=new SoMap();
-		so.put("money",tbOrdersService.orderStatistics("交易额",year));
-		so.put("count",tbOrdersService.orderStatistics("交易量",year));
+		//运营管理者统计全部
+		if(StpUserUtil.getPCLoginInfo().getType()==null||StpUserUtil.getPCLoginInfo().getType().equals("00")){
+			so.put("money",tbOrdersService.orderStatistics("交易额",year,  null));
+			so.put("count",tbOrdersService.orderStatistics("交易量",year,null));
+		}
+		//合作社只统计对应的互市id
+		if(StpUserUtil.getPCLoginInfo().getType()!=null&&StpUserUtil.getPCLoginInfo().getType().equals("01")){
+			so.put("money",tbOrdersService.orderStatistics("交易额",year,  StpUserUtil.getPCLoginInfo().getTradeAreaId()));
+			so.put("count",tbOrdersService.orderStatistics("交易量",year,StpUserUtil.getPCLoginInfo().getTradeAreaId()));
+		}
 		return AjaxJson.getSuccessData(so);
 	}
 

+ 2 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersMapper.java

@@ -34,9 +34,9 @@ public interface TbOrdersMapper extends BaseMapper <TbOrders> {
 
 	List<TbOrders> getLevelTwoList(SoMap so);
 
-	List<Map<String, Object>> orderStatistics(@Param("type") String type,@Param("year") String year);
+	List<Map<String, Object>> orderStatistics(@Param("type") String type,@Param("year") String year,@Param("tradeAreaId") Long tradeAreaId);
 
 	List<Map<String, Object>> selectYear();
 
-	Map<String, Object> totalMoney();
+	Map<String, Object> totalMoney(@Param("tradeAreaId") Long tradeAreaId);
 }

+ 4 - 3
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersMapper.xml

@@ -99,9 +99,9 @@
 	<!--已完成和累计交易额 -->
 	<select id="totalMoney" resultType="java.util.Map">
 		SELECT
-				( SELECT SUM( resale_price ) FROM tb_orders ) AS totalMoney,
-				( SELECT SUM( resale_price )  FROM tb_orders WHERE order_finish=1) AS finishMoney,
-				( SELECT COUNT(id)  FROM tb_orders) AS orders
+				( SELECT SUM( resale_price ) FROM tb_orders  <if test='tradeAreaId != null '> WHERE trade_area_id = #{tradeAreaId} </if> ) AS totalMoney,
+				( SELECT SUM( resale_price )  FROM tb_orders WHERE order_finish=1 <if test='tradeAreaId != null '> AND trade_area_id = #{tradeAreaId} </if>) AS finishMoney,
+				( SELECT COUNT(id)  FROM tb_orders <if test='tradeAreaId != null '> WHERE trade_area_id = #{tradeAreaId} </if>) AS orders
 	</select>
 	<!--查询所有统计年份 -->
 	<select id="selectYear" resultType="java.util.Map">
@@ -135,6 +135,7 @@
 			LEFT JOIN
 			tb_orders ON
 			MONTH(tb_orders.create_time) = months.month AND YEAR(tb_orders.create_time) =#{year}
+		    <if test='tradeAreaId != null '> and tb_orders.trade_area_id = #{tradeAreaId} </if>
 		GROUP BY
 			months.month
 		ORDER BY

+ 4 - 4
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -423,8 +423,8 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
      * @param year
      * @return
      */
-    public List<Map<String, Object>> orderStatistics(String type,String year){
-        return tbOrdersMapper.orderStatistics(type,year);
+    public List<Map<String, Object>> orderStatistics(String type,String year,Long tradeAreaId){
+        return tbOrdersMapper.orderStatistics(type,year,tradeAreaId);
     }
 
     /**
@@ -439,7 +439,7 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
      * 累计交易额
      * @return
      */
-    public Map<String, Object> totalMoney(){
-        return tbOrdersMapper.totalMoney();
+    public Map<String, Object> totalMoney(Long tradeAreaId){
+        return tbOrdersMapper.totalMoney(tradeAreaId);
     }
 }

+ 12 - 2
sp-service/sp-admin/src/main/java/com/pj/project4sp/admin/SpAdmin.java

@@ -19,8 +19,18 @@ public class SpAdmin implements Serializable  {
 
 
 	/** id,--主键、自增 */
-	public Long id;	
-	
+	public Long id;
+
+	/**
+	 * 类型(00=运营管理者,01=合作社)
+	 */
+	private String type;
+
+	/**
+	 * 所属互市(type=00时,值=-1;其他则为对应互市ID)
+	 */
+	private Long tradeAreaId;
+
 	/** admin名称 */
 	public String name;	
 	

+ 2 - 0
sp-service/sp-admin/src/main/java/com/pj/project4sp/admin4login/SpAccAdminService.java

@@ -104,6 +104,8 @@ public class SpAccAdminService {
         // 记录登录信息至redis
         PCLoginUserInfo info = new PCLoginUserInfo();
         info.setLoginId(String.valueOf(admin.getId())).setLoginName(admin.getName());
+        info.setType(admin.getType());
+        info.setTradeAreaId(admin.getTradeAreaId());
         StpUserUtil.cachePcLoginInfo(info);
         return AjaxJson.getSuccessData(map);
     }