wanglm hace 5 años
padre
commit
d0cc709086

+ 5 - 1
src/main/java/com/minpay/db/table/own/mapper/OrderManageMapper.java

@@ -34,7 +34,7 @@ public interface OrderManageMapper extends IMINMybatisEntityMapper {
 	/**
 	 * 查询累计收入
 	 */
-	String selectCountIncome();
+	String selectCountIncome(Map<String, String> m);
 	/**
 	 * 查询总机台数
 	 */
@@ -52,4 +52,8 @@ public interface OrderManageMapper extends IMINMybatisEntityMapper {
 	 * 总商品成本
 	 */
 	String selectAllCost();
+	/**
+	 * 预估利润
+	 */
+	String selectPredictIncome(Map<String, String> m);
 }

+ 72 - 24
src/main/java/com/minpay/shouhuo/invCardManageAction.java

@@ -18,12 +18,10 @@ import com.startup.minpay.frame.session.MINSession;
 import com.startup.minpay.frame.target.MINAction;
 import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
+import org.apache.commons.lang.StringUtils;
 
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 财务管理
@@ -53,6 +51,56 @@ public class invCardManageAction implements IMINAction {
 	/**  销售数据2 **/
 	public final static String SELECT_ALL_SALE = "selectAllSale";
 
+	/**  时间轴查询销售金额、预估利润 **/
+	public final static String SELECT_INCOME_BYDATE = "selectIncomeBydate";
+
+	/**
+	 * 时间轴查询销售金额、预估利润
+	 * @param session
+	 * @return
+	 * @throws Exception
+	 */
+	@MINAction(value = SELECT_INCOME_BYDATE)
+	public MINActionResult selectIncomeBydate (
+			@MINParam(key = "dateFlag") String dateFlag,
+			MINSession session) throws Exception {
+		MINActionResult res = new MINActionResult();
+		User user = session.getUser();
+		//获取当前时间
+		Date currentTime = new Date();
+		String nowDate = DateUtil.format(currentTime,"yyyyMMdd");
+		Map<String, String> m = new HashMap<String, String>();
+		//昨天
+		String yesDate = DateUtil.getDifferentDate(-1).substring(0,8);
+		//本周第一天
+		Calendar cal=Calendar.getInstance();
+		cal.add(Calendar.WEEK_OF_MONTH, 0);
+		cal.set(Calendar.DAY_OF_WEEK, 2);
+		Date weekFristDate = cal.getTime();
+		String weekDate = DateUtil.format(weekFristDate,"yyyyMMdd");
+		//按时间查询
+		if("0".equals(dateFlag)) {
+			m.put("nowDate", nowDate);
+		}else if("1".equals(dateFlag)) {
+			m.put("yesDate", yesDate);
+		}else if("2".equals(dateFlag)) {
+			m.put("weekDate", weekDate);
+		}
+		//查询累计收入
+		String countIncome = Service.lookup(IMINDataBaseService.class)
+				.getMybatisMapper(OrderManageMapper.class).selectCountIncome(m);
+		//查询预估利润
+		String predictIncome = Service.lookup(IMINDataBaseService.class)
+				.getMybatisMapper(OrderManageMapper.class).selectPredictIncome(m);
+		BigDecimal ljsr=new BigDecimal(countIncome);
+		BigDecimal ljzf=new BigDecimal(predictIncome);
+		predictIncome = (ljsr.subtract(ljzf)).toString();
+		//返回数据
+		res.set("countIncome", ljsr);
+		res.set("predictIncome", predictIncome);
+		return res;
+	}
+
 	/**
 	 * 总销售数量
 	 * @param session
@@ -117,26 +165,26 @@ public class invCardManageAction implements IMINAction {
 	 * @return
 	 * @throws Exception
 	 */
-	@MINAction(value = SELECT_ALL_INCOME)
-	public MINActionResult selectAllIncome (
-			MINSession session) throws Exception {
-		MINActionResult res = new MINActionResult();
-		User user = session.getUser();
-		//查询订单数
-		String orderNum = Service.lookup(IMINDataBaseService.class)
-				.getMybatisMapper(OrderManageMapper.class).selectCountOrderNum();
-		//查询累计收入
-		String countIncome = Service.lookup(IMINDataBaseService.class)
-				.getMybatisMapper(OrderManageMapper.class).selectCountIncome();
-		//查询总机台数
-		String countDevice = Service.lookup(IMINDataBaseService.class)
-				.getMybatisMapper(OrderManageMapper.class).selectCountDevice();
-		//返回数据
-		res.set("orderNum", orderNum);
-		res.set("countIncome", countIncome);
-		res.set("countDevice", countDevice);
-		return res;
-	}
+//	@MINAction(value = SELECT_ALL_INCOME)
+//	public MINActionResult selectAllIncome (
+//			MINSession session) throws Exception {
+//		MINActionResult res = new MINActionResult();
+//		User user = session.getUser();
+//		//查询订单数
+//		String orderNum = Service.lookup(IMINDataBaseService.class)
+//				.getMybatisMapper(OrderManageMapper.class).selectCountOrderNum();
+//		//查询累计收入
+//		String countIncome = Service.lookup(IMINDataBaseService.class)
+//				.getMybatisMapper(OrderManageMapper.class).selectCountIncome();
+//		//查询总机台数
+//		String countDevice = Service.lookup(IMINDataBaseService.class)
+//				.getMybatisMapper(OrderManageMapper.class).selectCountDevice();
+//		//返回数据
+//		res.set("orderNum", orderNum);
+//		res.set("countIncome", countIncome);
+//		res.set("countDevice", countDevice);
+//		return res;
+//	}
 
 	/**
 	 * 收入统计

+ 27 - 1
src/main/resources/com/minpay/db/table/own/mapper/OrderManageMapper.xml

@@ -154,9 +154,35 @@
 	</select>
 <!--	累计收入-->
 	<select id="selectCountIncome" resultType="java.lang.String" parameterType="java.util.Map">
-		select IFNULL(SUM(PIF_TRXAMOUT), 0.00)
+		select IFNULL(SUM(PIF_ORDERAMOUT), 0.00)
 		from vm_payment_inf
 		where PIF_STATUS = '1'
+		<if test="nowDate != null and nowDate != ''">
+			and substr(PIF_SUCCTIME,1,8) = #{nowDate,jdbcType=VARCHAR}
+		</if>
+		<if test="yesDate != null and yesDate != ''">
+			and substr(PIF_SUCCTIME,1,8) = #{yesDate,jdbcType=VARCHAR}
+		</if>
+		<if test="weekDate != null and weekDate != ''">
+			and substr(PIF_SUCCTIME,1,8) >= #{weekDate,jdbcType=VARCHAR}
+		</if>
+	</select>
+	<!--	预估利润-->
+	<select id="selectPredictIncome" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT IFNULL(SUM(VOD_AMOUNT), 0.00)
+		FROM vm_order_details, vm_payment_inf
+		WHERE VOD_IS_WINNING IN ('01', '02')
+		AND PIF_TRANFLOWNO = VOD_ORDER_ID
+		AND PIF_STATUS = '1'
+		<if test="nowDate != null and nowDate != ''">
+			and substr(PIF_SUCCTIME,1,8) = #{nowDate,jdbcType=VARCHAR}
+		</if>
+		<if test="yesDate != null and yesDate != ''">
+			and substr(PIF_SUCCTIME,1,8) = #{yesDate,jdbcType=VARCHAR}
+		</if>
+		<if test="weekDate != null and weekDate != ''">
+			and substr(PIF_SUCCTIME,1,8) >= #{weekDate,jdbcType=VARCHAR}
+		</if>
 	</select>
 	<!--	总机台数-->
 	<select id="selectCountDevice" resultType="java.lang.String" parameterType="java.util.Map">

+ 15 - 14
src/main/webapp/admin/incomeStatisticsManage/incomeStatistics.html

@@ -17,6 +17,11 @@
             <button class="layui-btn order-bnt2" id = "addUser">添加</button>
             <a href="#" id="toggle" class="top">收起</a>
         </div>
+<!--        <div class="tiaojian-part2 fr  demoTable">-->
+<!--            <button class="layui-btn  date-bnt0">今天</button>-->
+<!--            <button class="layui-btn  date-bnt1">昨天</button>-->
+<!--            <button class="layui-btn  date-bnt2">本周</button>-->
+<!--        </div>-->
     </div>
     <form class="layui-form"  action="javascript:void(0)"  id = "formName">
         <div class="order-select back-border" id="content">
@@ -54,20 +59,16 @@
                 changeSelectCon(0,"dates",'date',value)
             }
         });
-// 		$.request({
-// 			action : '../../invCardManageAction/selectAllIncome',
-// 			data : { },
-// 			success : function(data) {
-// 			    var orderNum = data.orderNum;
-// 			    var countIncome = data.countIncome;
-// 			    var countDevice = data.countDevice;
-// <!--				$("#orderNum").html(orderNum);-->
-// <!--				$("#countIncome").html(countIncome);-->
-// <!--				$("#countDevice").html(countDevice);-->
-// 				form.render();
-// 			}
-// 		});
-		form.render();
+		$.request({
+			action : '../../invCardManageAction/selectIncomeBydate',
+			data : { dateFlag:'0'},
+			success : function(data) {
+			    var countIncome = data.countIncome;
+			    var predictIncome = data.predictIncome;
+<!--				$("#countIncome").html(countIncome);-->
+<!--				$("#predictIncome").html(predictIncome);-->
+			}
+		});
 	})
 
 	var table;