pangjl před 4 roky
rodič
revize
befaded5d0

+ 21 - 0
src/main/java/com/minpay/common/util/DateUtil.java

@@ -772,5 +772,26 @@ public class DateUtil {
 	 return enddate;
 	     
  }
+	/**
+	 * 获取本月第一天
+	 * @return
+	 */
+	public static String getmindate(){
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(new Date());
+		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+
+		return String.valueOf(calendar.getTime());
+	}
+	/**
+	 * 获取本月最后一天
+	 * @return
+	 */
+	public static String getmaxdate(){
+		Calendar calendar2 = Calendar.getInstance();
+		calendar2.setTime(new Date());
+		calendar2.set(Calendar.DAY_OF_MONTH, calendar2.getActualMaximum(Calendar.DAY_OF_MONTH));
+		return String.valueOf(calendar2.getTime());
+	}
 		
 }

+ 7 - 0
src/main/java/com/minpay/db/table/own/mapper/MachineManageMapper.java

@@ -18,4 +18,11 @@ public interface MachineManageMapper extends  IMINMybatisEntityMapper{
 	List<Map<String, String>> queryProductz(Map<String, String> map, MINRowBounds rows);
 
 	List<Map<String, Object>> queryEquipment(Map<String, String> map, MINRowBounds rows);
+
+	//成本
+    String selectPredictIncome(Map<String, String> m);
+	//累计收入
+	String selectCountIncome(Map<String, String> m);
+	//订单数
+	String selectCountOrderNum(Map<String, String> m);
 }

+ 78 - 0
src/main/java/com/minpay/shouhuo/equmentaction/MachineManageAction.java

@@ -25,6 +25,7 @@ import com.startup.minpay.frame.target.MINAction;
 import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -56,6 +57,9 @@ public class MachineManageAction implements IMINAction {
     /**补货*/
     public final static String	EDIT_PROEQUREL_NUM			= "editProEquRelNum";
 
+    /**主页数据*/
+    public final static String	HOME_PAGE_DATA			= "homePageData";
+
     private boolean contains;
 
 
@@ -284,4 +288,78 @@ public class MachineManageAction implements IMINAction {
 
         return res;
     }
+    /**
+     * 主页数据
+     *
+     * @param session
+     * @return
+     * @throws MINBusinessException
+     */
+    @MINAction(value = HOME_PAGE_DATA)
+    public MINActionResult homePageData(
+            @MINParam(key = "dateFlag") String dateFlag,
+            @MINParam(key = "page", defaultValue = "1") int page,
+            @MINParam(key = "limit", defaultValue = "10") int limit,
+            MINSession session
+    ) throws MINBusinessException {
+
+        MINActionResult res = new MINActionResult();
+
+        MINRowBounds rows = new MINRowBounds(page, limit);
+        //获取当前时间
+        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);
+        //本月第一天
+        String monthFirstDay = DateUtil.getmindate();
+        //本月最后一天
+        String monthLastDay = DateUtil.getmaxdate();
+        String monthDate = monthFirstDay.concat(monthLastDay);
+        User user = session.getUser();
+        //操作员id
+        String uId = user.getId();
+        //渠道
+        // 查询条件
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("channel", "V01");
+        map.put("branchId",user.getBranchId());
+        List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
+                .getMybatisMapper(MachineManageMapper.class)
+                .queryEquipment(map, rows);
+        //格式化时间和状态
+        list = Service.lookup(IFormatService.class).formatDateTime(list, "createTime", "modifyTime");
+        list = new MINCopyFormat("{equState:'sttDesc',type:'typeDesc'}").format(list);
+        list = Service.lookup(IFormatService.class).formatEnum(list, "{sttDesc:'EQUIPMENT_STATE','typeDesc':'GAME_TYPE'}");
+        if (dateFlag.equals("1")){
+            m.put("nowDate",nowDate);
+        }else if (dateFlag.equals("2")){
+            m.put("yesDate",yesDate);
+        }else if (dateFlag.equals("3")){
+            m.put("monthDate",monthDate);
+        }
+        //成本
+        String chengben = Service.lookup(IMINDataBaseService.class)
+                .getMybatisMapper(MachineManageMapper.class)
+                .selectPredictIncome(m);
+        //营业额
+        String shouru = Service.lookup(IMINDataBaseService.class)
+                .getMybatisMapper(MachineManageMapper.class)
+                .selectCountIncome(m);
+        //订单数
+        String dingdanCount = Service.lookup(IMINDataBaseService.class)
+                .getMybatisMapper(MachineManageMapper.class)
+                .selectCountOrderNum(m);
+        //利润
+        String lirun = CommonUtil.subtract(shouru,chengben);
+        //传递数据
+        res.set("chengben",chengben);
+        res.set("shouru",shouru);
+        res.set("lirun",lirun);
+        res.set("dingdanCount",dingdanCount);
+        res.set(IMINBusinessConstant.F_PAGING_LAY, list);
+        res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
+        return res;
+    }
 }

+ 60 - 0
src/main/resources/com/minpay/db/table/own/mapper/MachineManageMapper.xml

@@ -220,4 +220,64 @@
 		</if>
 		ORDER BY equ.VEQ_STATE ASC, equ.VEQ_CREATE_TIME DESC, equ.VEQ_MACHINE_NO DESC
 	</select>
+	<!--	累计收入-->
+	<select id="selectCountIncome" resultType="java.lang.String" parameterType="java.util.Map">
+		select IFNULL(CAST(SUM(PIF_ORDERAMOUT) AS DECIMAL(15,2)), 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>
+		<if test="monthDate!=null and monthDate!= ''">
+			AND SUBSTR(PIF_SUCCTIME,1,8) BETWEEN SUBSTR((#{monthDate, jdbcType=VARCHAR}),1,8)
+			AND substr((#{monthDate, jdbcType=VARCHAR}),9,16)
+		</if>
+	</select>
+	<!--成本-->
+	<select id="selectPredictIncome" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT IFNULL(CAST(SUM(PRT_PRO_COST) AS DECIMAL(15,2)), 0.00)
+		FROM vm_order_details
+		LEFT JOIN vm_payment_inf ON PIF_TRANFLOWNO = VOD_ORDER_ID
+		LEFT JOIN vm_product_inf ON VOD_PRODUCT_ID = PRT_ID
+		WHERE VOD_IS_WINNING IN ('01', '02')
+		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>
+		<if test="monthDate!=null and monthDate!= ''">
+			AND SUBSTR(PIF_SUCCTIME,1,8) BETWEEN SUBSTR((#{monthDate, jdbcType=VARCHAR}),1,8)
+			AND substr((#{monthDate, jdbcType=VARCHAR}),9,16)
+		</if>
+	</select>
+	<!--	总订单数-->
+	<select id="selectCountOrderNum" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT COUNT(1)
+		FROM vm_order_inf
+		WHERE VOI_STATE = '00'
+		<if test="nowDate != null and nowDate != ''">
+			and substr(VOI_CREATE_TIME,1,8) = #{nowDate,jdbcType=VARCHAR}
+		</if>
+		<if test="yesDate != null and yesDate != ''">
+			and substr(VOI_CREATE_TIME,1,8) = #{yesDate,jdbcType=VARCHAR}
+		</if>
+		<if test="weekDate != null and weekDate != ''">
+			and substr(VOI_CREATE_TIME,1,8) >= #{weekDate,jdbcType=VARCHAR}
+		</if>
+		<if test="monthDate!=null and monthDate!= ''">
+			AND SUBSTR(VOI_CREATE_TIME,1,8) BETWEEN SUBSTR((#{monthDate, jdbcType=VARCHAR}),1,8)
+			AND substr((#{monthDate, jdbcType=VARCHAR}),9,16)
+		</if>
+	</select>
 </mapper>