|
|
@@ -1,11 +1,10 @@ |
|
|
package com.iformall.service.impl; |
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.iformall.domain.po.WxMall; |
|
|
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
|
|
import com.iformall.domain.po.WxMerchantTradeDaily; |
|
|
|
|
|
import com.iformall.domain.po.WxShop; |
|
|
|
|
|
|
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.enums.EnumCarCmd; |
|
|
import com.iformall.enums.EnumCarCmd; |
|
|
|
|
|
import com.iformall.enums.EnumCouponChannelStatus; |
|
|
|
|
|
import com.iformall.enums.EnumMerchantStatus; |
|
|
import com.iformall.enums.EnumShopStatus; |
|
|
import com.iformall.enums.EnumShopStatus; |
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.service.DataTowerService; |
|
|
import com.iformall.service.DataTowerService; |
|
|
@@ -53,6 +52,197 @@ public class DataTowerServiceImpl implements DataTowerService { |
|
|
WxBillRentMapper wxBillRentMapper; |
|
|
WxBillRentMapper wxBillRentMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
WxCouponOrderMapper wxCouponOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
WxCouponChannelMapper wxCouponChannelMapper; |
|
|
|
|
|
@Override |
|
|
|
|
|
public Map<String, Object> queryRunningMobile(String tenantId) { |
|
|
|
|
|
WxShop wxShop = new WxShop(); |
|
|
|
|
|
wxShop.setTenantId(tenantId); |
|
|
|
|
|
wxShop.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
|
|
List<WxShop> rentedList = wxShopMapper.findList(wxShop); |
|
|
|
|
|
wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); |
|
|
|
|
|
List<WxShop> unrentedList = wxShopMapper.findList(wxShop); |
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> dataMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
//出租与未出租*********************************************** |
|
|
|
|
|
HashMap<String, Object> shopMap = new HashMap<>(); |
|
|
|
|
|
int rentedCount = rentedList.size(); |
|
|
|
|
|
int unrentedCount = unrentedList.size(); |
|
|
|
|
|
int total = rentedCount + unrentedCount; |
|
|
|
|
|
if (total == 0) { |
|
|
|
|
|
shopMap.put("rentedCount", 0); |
|
|
|
|
|
shopMap.put("unrentedCount", 0); |
|
|
|
|
|
shopMap.put("rentedPercent", "--"); |
|
|
|
|
|
shopMap.put("unrentedPercent", "--"); |
|
|
|
|
|
} else { |
|
|
|
|
|
shopMap.put("rentedCount", rentedCount); |
|
|
|
|
|
shopMap.put("unrentedCount", unrentedCount); |
|
|
|
|
|
double rentedPercent = new BigDecimal(((double) rentedCount / total) * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
double unrentedPercent = new BigDecimal(((double) unrentedCount / total) * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
shopMap.put("rentedPercent", rentedPercent + "%"); |
|
|
|
|
|
shopMap.put("unrentedPercent", unrentedPercent + "%"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dataMap.put("shop",shopMap); |
|
|
|
|
|
|
|
|
|
|
|
//租金*********************************************** |
|
|
|
|
|
HashMap<String, Object> rentMap = new HashMap<>(); |
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
params.put("tenantId", tenantId); |
|
|
|
|
|
Calendar calendar = Calendar.getInstance();//日历对象 |
|
|
|
|
|
calendar.setTime(new Date());//设置当前日期 |
|
|
|
|
|
calendar.add(Calendar.MONTH, -1);//月份减一 |
|
|
|
|
|
params.put("receiveDate", DateUtils.date2String(calendar.getTime(), "yyyy-MM")); |
|
|
|
|
|
Map<String, Object> payinfo = wxBillRentMapper.queryPayInfo(params); |
|
|
|
|
|
if (payinfo != null) { |
|
|
|
|
|
BigDecimal receivableAmount = (BigDecimal) payinfo.get("receivepay"); |
|
|
|
|
|
BigDecimal receivedAmount = (BigDecimal) payinfo.get("pay"); |
|
|
|
|
|
if (receivableAmount.longValue() > 0) { |
|
|
|
|
|
BigDecimal divide = receivedAmount.divide(receivableAmount, 2, BigDecimal.ROUND_HALF_UP); |
|
|
|
|
|
double receivedPercent = divide.multiply(new BigDecimal(100)).doubleValue(); |
|
|
|
|
|
rentMap.put("receivedPercent", receivedPercent + "%"); |
|
|
|
|
|
} else { |
|
|
|
|
|
rentMap.put("receivedPercent", "--"); |
|
|
|
|
|
} |
|
|
|
|
|
rentMap.put("receivableAmount", receivableAmount.longValue()); |
|
|
|
|
|
rentMap.put("receivedAmount", receivedAmount.longValue()); |
|
|
|
|
|
rentMap.put("arrearsAmount", receivableAmount.subtract(receivedAmount).longValue()); |
|
|
|
|
|
} else { |
|
|
|
|
|
rentMap.put("receivableAmount", 0); |
|
|
|
|
|
rentMap.put("receivedAmount", 0); |
|
|
|
|
|
rentMap.put("arrearsAmount", 0); |
|
|
|
|
|
rentMap.put("receivedPercent", "--"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dataMap.put("rent",rentMap); |
|
|
|
|
|
|
|
|
|
|
|
//上报*********************************************** |
|
|
|
|
|
HashMap<String, Object> reportMap = new HashMap<>(); |
|
|
|
|
|
WxMerchant wxMerchant = new WxMerchant(); |
|
|
|
|
|
wxMerchant.setTenantId(tenantId); |
|
|
|
|
|
wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); |
|
|
|
|
|
List<WxMerchant> merchants = wxMerchantMapper.findList(wxMerchant); |
|
|
|
|
|
|
|
|
|
|
|
WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); |
|
|
|
|
|
wxMerchantTradeDaily.setTenantId(tenantId); |
|
|
|
|
|
String reportDate = DateUtils.getTimeBefore(1, new Date()); |
|
|
|
|
|
wxMerchantTradeDaily.setReportDate(reportDate); |
|
|
|
|
|
List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); |
|
|
|
|
|
int merchantCount = merchants.size(); |
|
|
|
|
|
int tradeCount = tradeList.size(); |
|
|
|
|
|
if (merchantCount > 0 && tradeCount > 0) { |
|
|
|
|
|
double reportPercent = new BigDecimal(((double) tradeCount / merchantCount) * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
reportMap.put("reportPercent", reportPercent + "%"); |
|
|
|
|
|
} else { |
|
|
|
|
|
reportMap.put("reportPercent", "--"); |
|
|
|
|
|
} |
|
|
|
|
|
reportMap.put("reportCount", tradeCount); |
|
|
|
|
|
reportMap.put("silenceCount", merchantCount - tradeCount); |
|
|
|
|
|
int reportTotal = tradeList.stream().mapToInt(WxMerchantTradeDaily::getTradeAmt).sum(); |
|
|
|
|
|
reportMap.put("reportTotal", reportTotal); |
|
|
|
|
|
|
|
|
|
|
|
dataMap.put("report",reportMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//今日车流量*********************************************** |
|
|
|
|
|
HashMap<String, Object> carMap = new HashMap<>(); |
|
|
|
|
|
HashMap<Object, Object> paramsCar = new HashMap<>(); |
|
|
|
|
|
paramsCar.put("tenantId", tenantId); |
|
|
|
|
|
paramsCar.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_OUT.getCode()); |
|
|
|
|
|
String startdate = DateUtils.getTimeBefore(30, new Date()); |
|
|
|
|
|
String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); |
|
|
|
|
|
|
|
|
|
|
|
List<String> tjTimeList = DateUtils.getTjTimeList(startdate, systemTime, "0"); |
|
|
|
|
|
|
|
|
|
|
|
paramsCar.put("startdate", startdate + " 00:00:00"); |
|
|
|
|
|
paramsCar.put("enddate", systemTime + " 23:59:59"); |
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> historylist = wxCarCmdLogMapper.queryHistory(paramsCar); |
|
|
|
|
|
|
|
|
|
|
|
Map<Object, Object> collect = historylist.stream().collect(Collectors.toMap(m -> { |
|
|
|
|
|
return m.get("create_date"); |
|
|
|
|
|
}, m -> { |
|
|
|
|
|
return m.get("carcount"); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
TreeMap<Object, Object> historymap = new TreeMap<>(); |
|
|
|
|
|
for (String date : tjTimeList) { |
|
|
|
|
|
Object o = collect.get(date); |
|
|
|
|
|
if (o == null) { |
|
|
|
|
|
historymap.put(date.substring(5).replace("-", "/"), 0L); |
|
|
|
|
|
} else { |
|
|
|
|
|
historymap.put(date.substring(5).replace("-", "/"), o); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long todaycar = (long) historymap.get(DateUtils.getSystemTime("MM/dd")); |
|
|
|
|
|
carMap.put("carCount", todaycar); |
|
|
|
|
|
|
|
|
|
|
|
//环比 |
|
|
|
|
|
long yesterdaycar = (long) historymap.get(tjTimeList.get(8 - 2).substring(5).replace("-", "/")); |
|
|
|
|
|
if (yesterdaycar > 0) { |
|
|
|
|
|
double hbd = (double) (todaycar - yesterdaycar) / yesterdaycar * 100; |
|
|
|
|
|
double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
carMap.put("increasedPercent", hb); |
|
|
|
|
|
} else { |
|
|
|
|
|
carMap.put("increasedPercent", "--"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//上周同期 |
|
|
|
|
|
long last = (long) historymap.get(tjTimeList.get(0).substring(5).replace("-", "/")); |
|
|
|
|
|
if (last > 0) { |
|
|
|
|
|
double lasthbd = (double) (todaycar - last) / last * 100; |
|
|
|
|
|
double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
carMap.put("increasedPercentWeek", lasthb); |
|
|
|
|
|
} else { |
|
|
|
|
|
carMap.put("increasedPercentWeek", "--"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dataMap.put("car",carMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//今日券数据*********************************************** |
|
|
|
|
|
HashMap<String, Object> couponMap = new HashMap<>(); |
|
|
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
|
|
cal.setTime(new Date()); |
|
|
|
|
|
cal.set(Calendar.HOUR_OF_DAY, 0); |
|
|
|
|
|
cal.set(Calendar.MINUTE, 0); |
|
|
|
|
|
cal.set(Calendar.SECOND, 0); |
|
|
|
|
|
cal.set(Calendar.MILLISECOND, 0); |
|
|
|
|
|
Date startTime = cal.getTime(); |
|
|
|
|
|
cal.add(Calendar.DAY_OF_YEAR, 1); |
|
|
|
|
|
Date endTime = cal.getTime(); |
|
|
|
|
|
|
|
|
|
|
|
long verifiedCount = wxCouponOrderMapper.findVerifiedCount(tenantId,startTime,endTime); |
|
|
|
|
|
long orderedCount = wxCouponOrderMapper.findOrderedCount(tenantId,startTime,endTime); |
|
|
|
|
|
couponMap.put("verifiedCount", verifiedCount); |
|
|
|
|
|
couponMap.put("orderedCount", orderedCount); |
|
|
|
|
|
WxCouponChannel wxCouponChannel = new WxCouponChannel(); |
|
|
|
|
|
wxCouponChannel.setTenantId(tenantId); |
|
|
|
|
|
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); |
|
|
|
|
|
long couponCount = wxCouponChannelMapper.countCoupon(wxCouponChannel); |
|
|
|
|
|
couponMap.put("couponCount", couponCount); |
|
|
|
|
|
|
|
|
|
|
|
dataMap.put("coupon",couponMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//客流*********************************************** |
|
|
|
|
|
HashMap<String, Object> visitorMap = new HashMap<>(); |
|
|
|
|
|
visitorMap.put("todayCount", 8888); |
|
|
|
|
|
visitorMap.put("increasedPercent", "5%"); |
|
|
|
|
|
visitorMap.put("increasedPercentWeek", "5%"); |
|
|
|
|
|
dataMap.put("visitor",visitorMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dataMap; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Map<String, Object> queryRunning(String tenantId) { |
|
|
public Map<String, Object> queryRunning(String tenantId) { |
|
|
WxShop wxShop = new WxShop(); |
|
|
WxShop wxShop = new WxShop(); |
|
|
|