|
|
|
@@ -29,14 +29,14 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMerchantTradeDailyMapper wxMerchantTradeDailyMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxMerchantBUserService wxMerchantBUserService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@@ -64,7 +64,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
if (record.getId() == null) { |
|
|
|
//record.setId(UUID.randomUUID().toString().replaceAll("-", "")); |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setCreateDate(new Date()); |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
wxMerchantTradeDailyMapper.insert(record); |
|
|
|
@@ -84,16 +84,16 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
|
|
|
|
WxMerchantBUser user = wxMerchantBUserService.getById(userId); |
|
|
|
|
|
|
|
if (user==null) |
|
|
|
if (user == null) |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
|
|
|
|
WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); |
|
|
|
|
|
|
|
if (merchant==null) |
|
|
|
if (merchant == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
|
|
|
|
WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); |
|
|
|
if (mall==null) |
|
|
|
if (mall == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
|
|
|
|
|
|
|
|
@@ -101,15 +101,15 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
|
|
|
|
wxMerchantTradeDaily.setMerchantId(merchant.getId()); |
|
|
|
|
|
|
|
SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); |
|
|
|
|
|
|
|
|
|
|
|
List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); |
|
|
|
|
|
|
|
if (tradeList.size() > 0 ) { |
|
|
|
if (tradeList.size() > 0) { |
|
|
|
wxMerchantTradeDaily = tradeList.get(0); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(volume+""); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(volume + ""); |
|
|
|
wxMerchantTradeDaily.setUpdateDate(new Date()); |
|
|
|
wxMerchantTradeDailyMapper.updateById(wxMerchantTradeDaily); |
|
|
|
return new ResultData(wxMerchantTradeDaily); |
|
|
|
@@ -120,7 +120,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
wxMerchantTradeDaily.setTenantId(merchant.getTenantId()); |
|
|
|
wxMerchantTradeDaily.setMerchantId(merchant.getId()); |
|
|
|
wxMerchantTradeDaily.setbUserId(userId); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(volume+""); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(volume + ""); |
|
|
|
wxMerchantTradeDaily.setCreateDate(new Date()); |
|
|
|
wxMerchantTradeDaily.setUpdateDate(new Date()); |
|
|
|
wxMerchantTradeDailyMapper.insert(wxMerchantTradeDaily); |
|
|
|
@@ -147,7 +147,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
if (tradeList.size() > 0) { |
|
|
|
wxMerchantTradeDaily = tradeList.get(0); |
|
|
|
wxMerchantTradeDaily.setUpdateDate(new Date()); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(tradeDaily.getTradeAmt()+""); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(tradeDaily.getTradeAmt() + ""); |
|
|
|
wxMerchantTradeDaily.setTradeCount(tradeDaily.getTradeCount()); |
|
|
|
wxMerchantTradeDaily.setProof(tradeDaily.getProof()); |
|
|
|
wxMerchantTradeDailyMapper.updateById(wxMerchantTradeDaily); |
|
|
|
@@ -158,7 +158,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
wxMerchantTradeDaily.setId(idWorker.nextId()); |
|
|
|
wxMerchantTradeDaily.setTenantId(tradeDaily.getTenantId()); |
|
|
|
wxMerchantTradeDaily.setMerchantId(tradeDaily.getMerchantId()); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(tradeDaily.getTradeAmt()+""); |
|
|
|
wxMerchantTradeDaily.setTradeAmt(tradeDaily.getTradeAmt() + ""); |
|
|
|
wxMerchantTradeDaily.setCreateDate(new Date()); |
|
|
|
wxMerchantTradeDaily.setUpdateDate(new Date()); |
|
|
|
wxMerchantTradeDaily.setTradeCount(tradeDaily.getTradeCount()); |
|
|
|
@@ -183,20 +183,31 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
//没有商户ID导出全部数据 |
|
|
|
List<WxMerchantTradeDailyVo> list = wxMerchantTradeDailyMapper.findVoList(tradeDaily); |
|
|
|
|
|
|
|
list.stream().forEach(m->{ |
|
|
|
list.stream().forEach(m -> { |
|
|
|
//商铺信息 |
|
|
|
m.setShopVos(wxShopMapper.findShopVoList(m.getMerchantId())); |
|
|
|
}); |
|
|
|
//商铺信息 |
|
|
|
|
|
|
|
excelService.exportExcel(list, "商户解单数据", "商户解单数据", WxMerchantTradeDailyVo.class, "商户解单数据.xlsx", response, false); |
|
|
|
excelService.exportExcel(list, "商户解单数据", "商户解单数据", WxMerchantTradeDailyVo.class, "商户解单数据.xlsx", response, false); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData summary(WxMerchantTradeDaily record) { |
|
|
|
List<WxMerchantTradeDailyVo> voList = wxMerchantTradeDailyMapper.findVoList(record); |
|
|
|
Integer tradeAmt = voList.stream().collect(Collectors.summingInt(WxMerchantTradeDailyVo::getTradeAmt)); |
|
|
|
Integer tradeCount = voList.stream().collect(Collectors.summingInt(WxMerchantTradeDailyVo::getTradeCount)); |
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
data.put("tradeAmt", tradeAmt); |
|
|
|
data.put("tradeCount", tradeCount); |
|
|
|
return new ResultData(data); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData getVolumeOfMonth(Long merchantId) { |
|
|
|
|
|
|
|
WxMerchant merchant = wxMerchantService.getById(merchantId); |
|
|
|
if (merchant==null) |
|
|
|
if (merchant == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); |
|
|
|
wxMerchantTradeDaily.setMerchantId(merchantId); |
|
|
|
@@ -205,7 +216,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
wxMerchantTradeDaily.setStartTime(startTime); |
|
|
|
wxMerchantTradeDaily.setEndTime(endTime); |
|
|
|
List<WxMerchantTradeDailyVo> recordList = wxMerchantTradeDailyMapper.findVoList(wxMerchantTradeDaily); |
|
|
|
Map<String,WxMerchantTradeDailyVo> recordMap = recordList.stream().collect(Collectors.toMap(WxMerchantTradeDailyVo::getReportDate, r -> r)); |
|
|
|
Map<String, WxMerchantTradeDailyVo> recordMap = recordList.stream().collect(Collectors.toMap(WxMerchantTradeDailyVo::getReportDate, r -> r)); |
|
|
|
|
|
|
|
List<WxMerchantTradeDailyVo> tradeList = new ArrayList<>(); |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
@@ -215,14 +226,14 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
cal.setTime(new Date()); |
|
|
|
cal.add(Calendar.DAY_OF_YEAR, -i); |
|
|
|
WxMerchantTradeDailyVo trade = recordMap.get(fmt.format(cal.getTime())); |
|
|
|
if (trade != null){ |
|
|
|
if (trade != null) { |
|
|
|
trade.setReportDate(fmtv.format(cal.getTime())); |
|
|
|
trade.setTenantId(null); |
|
|
|
trade.setMerchantId(null); |
|
|
|
trade.setMerchantName(null); |
|
|
|
tradeList.add(trade); |
|
|
|
}else { |
|
|
|
trade = new WxMerchantTradeDailyVo(); |
|
|
|
} else { |
|
|
|
trade = new WxMerchantTradeDailyVo(); |
|
|
|
trade.setTradeAmt(0); |
|
|
|
trade.setReportDate(fmtv.format(cal.getTime())); |
|
|
|
tradeList.add(trade); |
|
|
|
@@ -241,7 +252,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
wxMerchantTradeDaily.setTenantId(tenantId); |
|
|
|
|
|
|
|
List<WxMerchantTradeDaily> recordList = wxMerchantTradeDailyMapper.findTotalListOfMonth(wxMerchantTradeDaily); |
|
|
|
Map<String,WxMerchantTradeDaily> recordMap = recordList.stream().collect(Collectors.toMap(WxMerchantTradeDaily::getReportDate, r -> r)); |
|
|
|
Map<String, WxMerchantTradeDaily> recordMap = recordList.stream().collect(Collectors.toMap(WxMerchantTradeDaily::getReportDate, r -> r)); |
|
|
|
|
|
|
|
List<WxMerchantTradeDaily> tradeList = new ArrayList<>(); |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
@@ -252,11 +263,11 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
cal.add(Calendar.DAY_OF_MONTH, -i); |
|
|
|
System.out.println(fmt.format(cal.getTime())); |
|
|
|
WxMerchantTradeDaily trade = recordMap.get(fmt.format(cal.getTime())); |
|
|
|
if (trade != null){ |
|
|
|
if (trade != null) { |
|
|
|
trade.setReportDate(fmtv.format(cal.getTime())); |
|
|
|
tradeList.add(trade); |
|
|
|
}else { |
|
|
|
trade = new WxMerchantTradeDaily(); |
|
|
|
} else { |
|
|
|
trade = new WxMerchantTradeDaily(); |
|
|
|
trade.setTradeAmt("0"); |
|
|
|
trade.setReportDate(fmtv.format(cal.getTime())); |
|
|
|
tradeList.add(trade); |
|
|
|
@@ -269,30 +280,30 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData getVolume(WxMerchantTradeDaily merchantTradeDaily,Long userId) { |
|
|
|
public ResultData getVolume(WxMerchantTradeDaily merchantTradeDaily, Long userId) { |
|
|
|
WxMerchantBUser user = wxMerchantBUserService.getById(userId); |
|
|
|
if (user==null) |
|
|
|
if (user == null) |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); |
|
|
|
if (merchant==null) |
|
|
|
if (merchant == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); |
|
|
|
if (mall==null) |
|
|
|
if (mall == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
|
|
|
|
WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); |
|
|
|
wxMerchantTradeDaily.setMerchantId(merchant.getId()); |
|
|
|
|
|
|
|
if(merchantTradeDaily.getReportDate() != null){ |
|
|
|
if (merchantTradeDaily.getReportDate() != null) { |
|
|
|
wxMerchantTradeDaily.setReportDate(merchantTradeDaily.getReportDate()); |
|
|
|
}else { |
|
|
|
SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
} else { |
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); |
|
|
|
} |
|
|
|
|
|
|
|
List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); |
|
|
|
|
|
|
|
if (tradeList.size() > 0 ) { |
|
|
|
if (tradeList.size() > 0) { |
|
|
|
wxMerchantTradeDaily = tradeList.get(0); |
|
|
|
return new ResultData(wxMerchantTradeDaily); |
|
|
|
} |
|
|
|
@@ -306,16 +317,16 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
|
|
|
|
WxMerchantBUser user = wxMerchantBUserService.getById(userId); |
|
|
|
|
|
|
|
if (user==null) |
|
|
|
if (user == null) |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
|
|
|
|
WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); |
|
|
|
|
|
|
|
if (merchant==null) |
|
|
|
if (merchant == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
|
|
|
|
WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); |
|
|
|
if (mall==null) |
|
|
|
if (mall == null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
|
|
|
|
|
|
|
|
@@ -323,11 +334,11 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ |
|
|
|
|
|
|
|
wxMerchantTradeDaily.setMerchantId(merchant.getId()); |
|
|
|
|
|
|
|
SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); |
|
|
|
|
|
|
|
return new ResultData(wxMerchantTradeDailyMapper.findListOfWeek(wxMerchantTradeDaily)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |