Browse Source

订单统计

xubh 4 years ago
parent
commit
adc035f4d9

+ 10 - 0
src/main/java/com/minpay/db/table/own/mapper/OrderManageMapper.java

@@ -62,4 +62,14 @@ public interface OrderManageMapper extends IMINMybatisEntityMapper {
 	List<Map<String, String>>  selectCountIncomeb(Map<String, String> m);
 
 	Map<String, String> selectOrderNumber(Map<String, String> m);
+	/**
+	 * 总实际金额(微信,支付宝,充值)
+	 */
+    String selectCountIncomeNew(Map map);
+	/**
+	 * 总商品成本(新)
+	 */
+	String selectPredictIncomeNew(Map map);
+
+	String queryOrderNum(Map map);
 }

+ 70 - 3
src/main/java/com/minpay/shouhuo/orderaction/InvCardManageAction.java

@@ -9,10 +9,11 @@ import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.DateUtil;
 import com.minpay.common.util.HttpPostUtil;
 import com.minpay.db.table.mapper.VmDeliveryInfMapper;
+import com.minpay.db.table.mapper.VmEquipmentInfMapper;
 import com.minpay.db.table.mapper.VmOrderDetailsMapper;
-import com.minpay.db.table.model.VmDeliveryInf;
-import com.minpay.db.table.model.VmOrderDetails;
+import com.minpay.db.table.model.*;
 import com.minpay.db.table.own.mapper.OrderManageMapper;
+import com.minpay.db.table.own.mapper.ShOrderMapper;
 import com.startup.minpay.frame.business.IMINAction;
 import com.startup.minpay.frame.business.res.MINActionResult;
 import com.startup.minpay.frame.constant.IMINBusinessConstant;
@@ -58,6 +59,9 @@ public class InvCardManageAction implements IMINAction {
 
 	/**  时间轴查询销售金额、预估利润 **/
 	public final static String SELECT_INCOME_BYDATE = "selectIncomeBydate";
+	/**  时间轴查询销售金额、预估利润 (新)**/
+	public final static String SELECT_INCOME_BYDATE_NEW = "selectIncomeBydateNew";
+
 
 	/**
 	 * 时间轴查询销售金额、预估利润
@@ -384,7 +388,70 @@ public class InvCardManageAction implements IMINAction {
 		return res;
 	}
 
+	/**
+	 * 时间轴查询销售金额、预估利润
+	 * @param session
+	 * @param dateFlag (时间轴 0)
+	 * @return
+	 * @throws Exception
+	 */
+	@MINAction(value = SELECT_INCOME_BYDATE_NEW)
+	public MINActionResult selectIncomeBydateNew (
+			@MINParam(key = "dateFlag") String dateFlag,
+			@MINParam(key = "page", defaultValue = "1") int page,
+			@MINParam(key = "limit", defaultValue = "3") int limit,
+			MINSession session) throws Exception {
+		MINActionResult res = new MINActionResult();
+		MINRowBounds rows = new MINRowBounds(page, limit);
+		User  user = session.getUser();
+		String dateString = "";
+		Map map = new HashMap();
+		if("0".equals(dateFlag)) { //当天
+			dateString = DateUtil.getCurrentDateString();
+			map.put("nowDate", dateString);
+		}else if("1".equals(dateFlag)) {//昨天
+			//昨天
+			dateString = DateUtil.getDifferentDate(-1).substring(0,8);
+			map.put("yesDate", dateString);
+		}else if("2".equals(dateFlag)) {//本周
+			dateString = DateUtil.getDifferentDate(-7).substring(0,8);
+			map.put("weekDate", dateString);
+		}
+		map.put("dateString", dateString);
+		/**查询商户机器*/
+		VmEquipmentInfExample vmEquipmentInfExample = new VmEquipmentInfExample();
+		vmEquipmentInfExample.createCriteria().andBranchidEqualTo(user.getBranchId());
+		List<VmEquipmentInf> equipmentInfList = Service.lookup(IMINDataBaseService.class)
+														.getMybatisMapper(VmEquipmentInfMapper.class)
+														.selectByExample(vmEquipmentInfExample,rows);
+		List<Map>  reslist = new ArrayList<>();
+
+		for (int i = 0; i < equipmentInfList.size(); i++) {
+			Map resmap = new HashMap();
+			VmEquipmentInf equipmentInf = equipmentInfList.get(i);
+			map.put("equipmentId",equipmentInf.getId());
+			//查询订单总数
+			String num = Service.lookup(IMINDataBaseService.class).getMybatisMapper(OrderManageMapper.class).queryOrderNum(map);
+			//实际入账
+			String countIncome = Service.lookup(IMINDataBaseService.class)
+					.getMybatisMapper(OrderManageMapper.class).selectCountIncomeNew(map);
+			//查询总成本价
+			String predictIncome = Service.lookup(IMINDataBaseService.class)
+					.getMybatisMapper(OrderManageMapper.class).selectPredictIncomeNew(map);
+			resmap.put("imeiAddr",equipmentInf.getImeiAddr()); //机器号
+			resmap.put("orderNum",num);	//订单总数
+			resmap.put("countIncome",countIncome);	//总收入(微信支付宝 充值)
+			resmap.put("predictIncome",predictIncome); //成本
+			resmap.put("profit",CommonUtil.subtract(countIncome,predictIncome)); //预计利润
+			reslist.add(resmap);
+		}
+		res.set(IMINBusinessConstant.F_PAGING_LAY, reslist);
+		res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
+		return res;
+	}
 
+	public static void main(String[] args) {
+		String yesDate = DateUtil.getDifferentDate(-1).substring(0,8);
 
-
+	}
 }

+ 93 - 0
src/main/resources/com/minpay/db/table/own/mapper/OrderManageMapper.xml

@@ -327,4 +327,97 @@
 		AND	a.VOI_BRANCHID  = #{branchId,jdbcType=VARCHAR}
 		</if>
 	</select>
+
+
+	<select id="selectCountIncomeNew" resultType="java.lang.String" parameterType="java.util.Map">
+		select IFNULL(CAST(SUM(PIF_ORDERAMOUT) AS DECIMAL(15,2)), 0.00)
+		from vm_payment_inf, vm_order_inf
+		where PIF_STATUS = '1'
+		and (PIF_PAYTYPE in ('91', '92') or PIF_TRANSTYPE = '00')
+		and PIF_TRANFLOWNO = VOI_ID
+		<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="branchId != null and branchId != ''">
+			AND	VOI_BRANCHID  = #{branchId,jdbcType=VARCHAR}
+		</if>
+		<if test="equipmentId != null and equipmentId != ''">
+			AND	VOI_EQUIPMENT_ID  = #{equipmentId,jdbcType=VARCHAR}
+		</if>
+	</select>
+	<!--成本-->
+	<select id="selectPredictIncomeNew" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT IFNULL(CAST(SUM(VCI_COST_PRICE) AS DECIMAL(15,2)), 0.00)
+		FROM vm_order_details a
+		join vm_order_inf vo on vo.VOI_ID = a.VOD_ORDER_ID
+		join vm_payment_inf b on PIF_TRANFLOWNO = VOD_ORDER_ID
+		left join vm_pro_equ_rel c on c.VCI_ID = a.VOD_PRO_EQU_REL_ID
+		WHERE PIF_STATUS = '1' and VOI_PAY_MODE != '93'
+		<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="branchId != null and branchId != ''">
+			AND	VOI_BRANCHID  = #{branchId,jdbcType=VARCHAR}
+		</if>
+		<if test="equipmentId != null and equipmentId != ''">
+			AND	vo.VOI_EQUIPMENT_ID  = #{equipmentId,jdbcType=VARCHAR}
+		</if>
+	</select>
+	<select id="selectorderNew" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT IFNULL(CAST(SUM(VCI_COST_PRICE) AS DECIMAL(15,2)), 0.00)
+		FROM vm_order_details a
+		join vm_order_inf vo on vo.VOI_ID = a.VOD_ORDER_ID
+		join vm_payment_inf b on PIF_TRANFLOWNO = VOD_ORDER_ID
+		left join vm_pro_equ_rel c on c.VCI_ID = a.VOD_PRO_EQU_REL_ID
+		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="branchId != null and branchId != ''">
+			AND	VOI_BRANCHID  = #{branchId,jdbcType=VARCHAR}
+		</if>
+		<if test="equipmentId != null and equipmentId != ''">
+			AND	vo.VOI_EQUIPMENT_ID  = #{equipmentId,jdbcType=VARCHAR}
+		</if>
+	</select>
+	<select id="queryOrderNum" resultType="java.lang.String" parameterType="java.util.Map">
+		SELECT count(1)
+		FROM vm_order_details a
+		join vm_order_inf vo on vo.VOI_ID = a.VOD_ORDER_ID
+		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="branchId != null and branchId != ''">
+			AND	VOI_BRANCHID  = #{branchId,jdbcType=VARCHAR}
+		</if>
+		<if test="equipmentId != null and equipmentId != ''">
+			AND	vo.VOI_EQUIPMENT_ID  = #{equipmentId,jdbcType=VARCHAR}
+		</if>
+	</select>
+
 </mapper>