wuwen 4 years ago
parent
commit
a8f7524301

+ 8 - 8
src/main/java/com/ssj/dao/sys/fx/dao/impl/FinanceQueryDaoImpl.java

@@ -592,16 +592,16 @@ public class FinanceQueryDaoImpl implements FinanceQueryDao {
          selSql.append("  	SELECT IFNULL( SUM( c.lib_service ), 0 ) FROM fx_merchant_sign c WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )< TO_DAYS( ? )  ");
          selSql.append("  ) AS init_4,");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL  AND TO_DAYS( c.sign_time )< TO_DAYS( ? ) ");
+         selSql.append("  	SELECT IFNULL( SUM( o.price ), 0 ) FROM fx_merchant_meal_order o  WHERE o.merchant_id = t.id AND TO_DAYS( o.create_time )< TO_DAYS( ? ) ");
          selSql.append("  ) AS ir_1, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL	 AND TO_DAYS( c.end_sign_time )< TO_DAYS( ?)  ");
+         selSql.append("  	SELECT IFNULL(o.price/(o.buy_month+o.give_month)*count(1), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL	 AND TO_DAYS( c.end_sign_time )< TO_DAYS( ?)  ");
          selSql.append("  ) AS ir_2, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id  AND TO_DAYS( c.sign_time )< TO_DAYS( ? ) ");
+         selSql.append("  	SELECT IFNULL( SUM( o.price ), 0 ) FROM fx_merchant_sign_order o  WHERE o.merchant_id = t.id  AND TO_DAYS( o.create_time )< TO_DAYS( ? ) ");
          selSql.append("  ) AS ir_3, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )< TO_DAYS( ? )  ");
+         selSql.append("  	SELECT IFNULL(o.price/o.num*count(1), 0 )  FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )< TO_DAYS( ? )  ");
          selSql.append("  ) AS ir_4, ");
          selSql.append("  ( ");
          selSql.append("  	SELECT IFNULL(SUM( c.price ), 0 ) FROM fx_merchant_plat_order c WHERE c.merchant_id = t.id AND TO_DAYS( c.create_time )< TO_DAYS( ? )  ");
@@ -623,16 +623,16 @@ public class FinanceQueryDaoImpl implements FinanceQueryDao {
          selSql.append("  	SELECT IFNULL( SUM( c.lib_service ), 0 ) FROM fx_merchant_sign c WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )>= TO_DAYS( ? ) AND TO_DAYS( c.end_sign_time )<= TO_DAYS(? ) ");
          selSql.append("  ) AS count_4,");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL AND TO_DAYS( c.sign_time )>= TO_DAYS( ? ) AND TO_DAYS( c.sign_time )<= TO_DAYS(? ) ");
+         selSql.append("  	SELECT IFNULL( SUM( o.price ), 0 ) FROM fx_merchant_meal_order o  WHERE o.merchant_id = t.id AND TO_DAYS( o.create_time )>= TO_DAYS( ? ) AND TO_DAYS( o.create_time )<= TO_DAYS(? ) ");
          selSql.append("  ) AS pr_1, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL AND TO_DAYS( c.end_sign_time )>= TO_DAYS( ?) AND TO_DAYS( c.end_sign_time )<= TO_DAYS(?) ");
+         selSql.append("  	SELECT IFNULL(o.price/(o.buy_month+o.give_month)*count(1), 0 ) FROM fx_merchant_meal c LEFT JOIN fx_merchant_meal_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND c.type>1 AND c.remarks is NULL AND TO_DAYS( c.end_sign_time )>= TO_DAYS( ?) AND TO_DAYS( c.end_sign_time )<= TO_DAYS(?) ");
          selSql.append("  ) AS pr_2, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id  AND TO_DAYS( c.sign_time )>= TO_DAYS( ? ) AND TO_DAYS( c.sign_time )<= TO_DAYS(? ) ");
+         selSql.append("  	SELECT IFNULL( SUM( o.price ), 0 ) FROM fx_merchant_sign_order o WHERE o.merchant_id = t.id  AND TO_DAYS( o.create_time )>= TO_DAYS( ? ) AND TO_DAYS( o.create_time )<= TO_DAYS(? ) ");
          selSql.append("  ) AS pr_3, ");
          selSql.append("  ( ");
-         selSql.append("  	SELECT IFNULL( SUM( o.unit_price ), 0 ) FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )>= TO_DAYS( ? ) AND TO_DAYS( c.end_sign_time )<= TO_DAYS(? ) ");
+         selSql.append("  	SELECT IFNULL(o.price/o.num*count(1), 0 ) FROM fx_merchant_sign c LEFT JOIN fx_merchant_sign_order o ON c.order_id=o.id WHERE c.merchant_id = t.id AND TO_DAYS( c.end_sign_time )>= TO_DAYS( ? ) AND TO_DAYS( c.end_sign_time )<= TO_DAYS(? ) ");
          selSql.append("  ) AS pr_4, ");
          selSql.append("  ( ");
          selSql.append("  	SELECT IFNULL(SUM( c.price ), 0 ) FROM fx_merchant_plat_order c WHERE c.merchant_id = t.id AND TO_DAYS( c.create_time )>= TO_DAYS( ? ) AND TO_DAYS( c.create_time )<= TO_DAYS(? ) ");

+ 1 - 1
src/main/java/com/ssj/dao/sys/fx/dao/impl/FxQueryDaoImpl.java

@@ -905,7 +905,7 @@ public class FxQueryDaoImpl implements FxQueryDao {
         selSql.append(" 	SELECT m.id,m.type as merchant_type,m.pos_code,m.unit_name,t.unit_price,t.price,t.buy_month,t.give_month,t.sign_type,t.type,t.lib_service,t.create_time as time,1 as cap_type from fx_merchant_meal_order t    ");
         selSql.append("  	LEFT JOIN fx_merchant m ON t.merchant_id=m.id ");
         selSql.append("  UNION ALL");
-        selSql.append("  	SELECT m.id,m.type as merchant_type,m.pos_code,m.unit_name,IF(t.remarks='开始收费期',0,o.unit_price),IF(t.remarks='开始收费期',0,o.price),o.buy_month,o.give_month,o.sign_type,o.type,t.lib_service,t.sign_time as time,2 as cap_type from fx_merchant_meal t  ");
+        selSql.append("  	SELECT m.id,m.type as merchant_type,m.pos_code,m.unit_name,IF(t.remarks is NOT NULL,0,o.unit_price),IF(t.remarks is NOT NULL,0,o.price),o.buy_month,o.give_month,o.sign_type,o.type,t.lib_service,t.sign_time as time,2 as cap_type from fx_merchant_meal t  ");
         selSql.append("  	LEFT JOIN fx_merchant m ON t.merchant_id=m.id ");
         selSql.append(" 	LEFT JOIN fx_merchant_meal_order o ON t.order_id=o.id where t.status=1 and t.type>1 ");//激活期的流水,不统计到资金流水表
         selSql.append("  UNION ALL");

+ 8 - 12
src/main/java/com/ssj/sys/controller/FinanceReportController.java

@@ -534,8 +534,7 @@ public class FinanceReportController extends BaseController {
         		if(Integer.parseInt(map.get("count_2").toString())>0) {
         			map.put("count_2_m", map.get("balance_month") );
         			map.put("sum_price_2", map.get("price_1")!=null && StringUtils.isNotEmpty(map.get("price_1").toString()) ? 
-        					new BigDecimal(map.get("price_1").toString()).doubleValue()*
-        					new BigDecimal(map.get("count_2").toString()).intValue()
+        					new BigDecimal(map.get("price_1").toString()).doubleValue()
         					*0.4 
         					: 0);
         		}else {
@@ -543,7 +542,7 @@ public class FinanceReportController extends BaseController {
         		}
         	}
         	
-        	map.put("sum_price_3", new BigDecimal(map.get("sum_price_1").toString()).doubleValue()+new BigDecimal(map.get("sum_price_2").toString()).doubleValue());
+        	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
 
 		}
         
@@ -566,7 +565,7 @@ public class FinanceReportController extends BaseController {
     public void export5( HttpServletRequest request, HttpServletResponse response) {
         ServletOutputStream os = null;
         try {
-            String libName="小塾币使用情况-结算(旧模式)";
+            String libName="塾币模式结算表";
             os = response.getOutputStream(); //获得输出流
             response.reset();   //清空输出流
             String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
@@ -640,7 +639,7 @@ public class FinanceReportController extends BaseController {
     public void export6( HttpServletRequest request, HttpServletResponse response) {
         ServletOutputStream os = null;
         try {
-            String libName="小塾币使用情况-结算(新模式)";
+            String libName="端口模式结算表";
             os = response.getOutputStream(); //获得输出流
             response.reset();   //清空输出流
             String fileName = new String(libName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
@@ -733,7 +732,7 @@ public class FinanceReportController extends BaseController {
             			map.put("price_1", "0");
             		}
             	}
-            	map.put("sum_price_3", new BigDecimal(map.get("sum_price_1").toString()).doubleValue()+new BigDecimal(map.get("sum_price_2").toString()).doubleValue());
+            	map.put("sum_price_3", new BigDecimal(map.get("price").toString()).doubleValue()+new BigDecimal(map.get("price_1").toString()).doubleValue());
     		}
             
             List<ExcelColumn> myColumns3 = new ArrayList<ExcelColumn>();
@@ -745,17 +744,14 @@ public class FinanceReportController extends BaseController {
             myColumns3.add(new ExcelColumn("套餐名称", "meal_type", 20));
             myColumns3.add(new ExcelColumn("服务包名称", "sign_type", 20));
             
-            myColumns3.add(new ExcelColumn("服务包/月金额", "price", 20));
             myColumns3.add(new ExcelColumn("服务包/结算月份", "count_1_m", 20));
+            myColumns3.add(new ExcelColumn("服务包结算金额", "price", 20));
             
-            myColumns3.add(new ExcelColumn("服务包应结算金额", "sum_price_1", 20));
-            
-            myColumns3.add(new ExcelColumn("加油包/月金额", "price_1", 20));
             myColumns3.add(new ExcelColumn("加油包/结算月份", "count_2_m", 20));
             myColumns3.add(new ExcelColumn("加油包/结算数量", "count_2", 20));
+            myColumns3.add(new ExcelColumn("加油包结算金额", "price_1", 20));
             
-            myColumns3.add(new ExcelColumn("加油包应结算金额", "sum_price_2", 20));
-            myColumns3.add(new ExcelColumn("总应结算金额", "sum_price_3", 20));
+            myColumns3.add(new ExcelColumn("总结算金额", "sum_price_3", 20));
             
             CustomizeToExcel.downFile(myColumns3, list, os);
         }catch (IOException e) {

+ 12 - 10
src/main/java/com/ssj/sys/controller/FxController.java

@@ -4030,8 +4030,8 @@ public class FxController  extends BaseController {
 	    		map.put("pr_1",new BigDecimal(new BigDecimal(map.get("price").toString()).doubleValue()*(Integer.parseInt(map.get("count_1").toString()))).setScale(2, RoundingMode.UP).doubleValue());
 	    		map.put("pr_2",new BigDecimal(new BigDecimal(map.get("price").toString()).doubleValue()*(Integer.parseInt(map.get("count_2").toString()))).setScale(2, RoundingMode.UP).doubleValue());
 	    		
-	    		map.put("count_3",new BigDecimal(map.get("count_1").toString()).intValue()-new BigDecimal(map.get("count_2").toString()).intValue());
-	    		map.put("pr_3",new BigDecimal(map.get("pr_1").toString()).doubleValue()-new BigDecimal(map.get("pr_2").toString()).doubleValue());
+	    		map.put("count_3",new BigDecimal(map.get("init_3").toString()).doubleValue()+new BigDecimal(map.get("count_1").toString()).doubleValue()-new BigDecimal(map.get("count_2").toString()).doubleValue());
+	    		map.put("pr_3",new BigDecimal(map.get("ir_1").toString()).doubleValue()+new BigDecimal(map.get("pr_1").toString()).doubleValue()-new BigDecimal(map.get("pr_2").toString()).doubleValue());
 		   
 	        	switch (map.get("type").toString()) {
 					case "1":
@@ -4127,12 +4127,12 @@ public class FxController  extends BaseController {
 	    		//本期减少
 	    		map.put("count_6",(Integer.parseInt(map.get("count_2").toString())+Integer.parseInt(map.get("count_4").toString())));
 	    		map.put("pr_8",new BigDecimal(
-	    					(new BigDecimal(map.get("pr_1").toString()).doubleValue()+new BigDecimal(map.get("pr_4").toString()).doubleValue()+new BigDecimal(map.get("pr_6").toString()).doubleValue())
+	    					(new BigDecimal(map.get("pr_2").toString()).doubleValue()+new BigDecimal(map.get("pr_4").toString()).doubleValue()+new BigDecimal(map.get("pr_6").toString()).doubleValue())
 	    				).setScale(2, RoundingMode.UP).doubleValue());
 	    		
 	    		//本期结存
-	    		map.put("count_7",new BigDecimal(map.get("count_5").toString()).intValue()-new BigDecimal(map.get("count_6").toString()).intValue());
-	    		map.put("pr_9",new BigDecimal(map.get("pr_7").toString()).doubleValue()-new BigDecimal(map.get("pr_8").toString()).doubleValue());
+	    		map.put("count_7",new BigDecimal(map.get("init_5").toString()).intValue()+new BigDecimal(map.get("count_5").toString()).intValue()-new BigDecimal(map.get("count_6").toString()).intValue());
+	    		map.put("pr_9",new BigDecimal(map.get("ir_7").toString()).intValue()+new BigDecimal(map.get("pr_7").toString()).doubleValue()-new BigDecimal(map.get("pr_8").toString()).doubleValue());
   
 	        	switch (map.get("type").toString()) {
 					case "1":
@@ -4960,8 +4960,9 @@ public class FxController  extends BaseController {
     		
     		map.put("pr_1",new BigDecimal(new BigDecimal(map.get("price").toString()).doubleValue()*(Integer.parseInt(map.get("count_1").toString()))).setScale(2, RoundingMode.UP).doubleValue());
     		map.put("pr_2",new BigDecimal(new BigDecimal(map.get("price").toString()).doubleValue()*(Integer.parseInt(map.get("count_2").toString()))).setScale(2, RoundingMode.UP).doubleValue());
-    		map.put("count_3",new BigDecimal(map.get("count_1").toString()).doubleValue()-new BigDecimal(map.get("count_2").toString()).doubleValue());
-    		map.put("pr_3",new BigDecimal(map.get("pr_1").toString()).doubleValue()-new BigDecimal(map.get("pr_2").toString()).doubleValue());
+    		
+    		map.put("count_3",new BigDecimal(map.get("init_3").toString()).doubleValue()+new BigDecimal(map.get("count_1").toString()).doubleValue()-new BigDecimal(map.get("count_2").toString()).doubleValue());
+    		map.put("pr_3",new BigDecimal(map.get("ir_1").toString()).doubleValue()+new BigDecimal(map.get("pr_1").toString()).doubleValue()-new BigDecimal(map.get("pr_2").toString()).doubleValue());
 		}
         model.addAttribute("list", mapList);
         model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
@@ -5013,12 +5014,13 @@ public class FxController  extends BaseController {
 	    		//本期减少
 	    		map.put("count_6",(Integer.parseInt(map.get("count_2").toString())+Integer.parseInt(map.get("count_4").toString())));
 	    		map.put("pr_8",new BigDecimal(
-	    					(new BigDecimal(map.get("pr_1").toString()).doubleValue()+new BigDecimal(map.get("pr_4").toString()).doubleValue()+new BigDecimal(map.get("pr_6").toString()).doubleValue())
+	    					(new BigDecimal(map.get("pr_2").toString()).doubleValue()+new BigDecimal(map.get("pr_4").toString()).doubleValue()+new BigDecimal(map.get("pr_6").toString()).doubleValue())
 	    				).setScale(2, RoundingMode.UP).doubleValue());
 	    		
 	    		//本期结存
-	    		map.put("count_7",new BigDecimal(map.get("count_5").toString()).doubleValue()-new BigDecimal(map.get("count_6").toString()).doubleValue());
-	    		map.put("pr_9",new BigDecimal(map.get("pr_7").toString()).doubleValue()-new BigDecimal(map.get("pr_8").toString()).doubleValue());
+	    		map.put("count_7",new BigDecimal(map.get("init_5").toString()).intValue()+new BigDecimal(map.get("count_5").toString()).intValue()-new BigDecimal(map.get("count_6").toString()).intValue());
+	    		map.put("pr_9",new BigDecimal(map.get("ir_7").toString()).intValue()+new BigDecimal(map.get("pr_7").toString()).doubleValue()-new BigDecimal(map.get("pr_8").toString()).doubleValue());
+  
 	    		
 			}
 	        model.addAttribute("list", mapList);

+ 1 - 1
src/main/resources/templates/sys/finance/allList4.html

@@ -22,7 +22,7 @@
 	<span>位置:</span>
 	<ul class="placeul">
 		<li><a href="#">小塾管理</a></li>
-		<li><a href="#">小塾币使用情况-结算(旧模式)</a></li>
+		<li><a href="#">塾币模式结算表</a></li>
 	</ul>
 </div>
 <div class="rightinfo">

+ 6 - 7
src/main/resources/templates/sys/finance/allList6.html

@@ -35,7 +35,7 @@
 	<span>位置:</span>
 	<ul class="placeul">
 		<li><a href="#">小塾管理</a></li>
-		<li><a href="#">小塾币使用情况-结算(新模式)</a></li>
+		<li><a href="#">端口模式结算表</a></li>
 	</ul>
 </div>
 <div class="rightinfo">
@@ -72,14 +72,14 @@
 				<th>套餐名称</th>
 		    	<th>服务包名称</th>
 		    	
-		    	<th>服务包/月金额</th>
 		    	<th>结算月份</th>
 		    	<th>服务包结算金额</th>
 		    	
-		    	<th style="color: red">加油包/月金额</th>
+		    	
 		    	<th style="color: red">加油包/结算月份</th>
 		    	<th style="color: red">加油包/结算数</th>
 		    	<th style="color: red">加油包结算金额</th>
+		    	
 		    	<th >总结算金额</th>
 		    </tr>
 		</thead>
@@ -101,14 +101,13 @@
 					   <span th:case="4" >服务包4</span>
 					   <span th:case="5" >服务包5</span>
 					</td>
-					<td th:text="${item.get('moid')!=null ? item.get('price') : '0' }"></td>
+					
 					<td th:text="${item.get('moid')!=null ? item.get('balance_month') : ''   }"></td>
-					<td th:text="${item.get('sum_price_1')}"></td>
+					<td th:text="${item.get('moid')!=null ? item.get('price') : '0' }"></td>
 	
-					<td th:text="${item.get('price_1')}"></td>
 					<td th:text="${item.get('count_2')>0 ? item.get('balance_month') : ''   }"></td>
 					<td th:text="${item.get('count_2')>0 ? item.get('count_2') : ''   }"></td>
-					<td th:text="${item.get('sum_price_2')}"></td>
+					<td th:text="${item.get('price_1')}"></td>
 					
 					<td th:text="${item.get('sum_price_3')}"></td>
 			</tr>

+ 1 - 1
src/main/resources/templates/sys/fx/merchantBalanceOldList.html

@@ -91,7 +91,7 @@
 					</td>
 					<td th:text="${item.port_num}"></td>
 					
-					<td th:text="${item.init_1}"></td>
+					<td th:text="${item.init_3}"></td>
 					<td th:text="${item.ir_1}"></td>
 					
 					<td th:text="${item.count_1}"></td>