|
|
|
@@ -2,10 +2,15 @@ package com.iformall.controller.datatower; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.annotation.SystemControllerLog; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.controller.base.BaseController; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.WxMerchantBUser; |
|
|
|
import com.iformall.domain.po.WxMerchantTradeDaily; |
|
|
|
import com.iformall.domain.vo.WxMerchantTradeDailyVo; |
|
|
|
import com.iformall.service.WxMerchantBUserService; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.service.WxMerchantTradeDailyService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
@@ -13,6 +18,7 @@ import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.collections.map.LinkedMap; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -28,7 +34,10 @@ public class WxMerchantTradeDailyController extends BaseController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxMerchantTradeDailyService wxMerchantTradeDailyService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxMerchantBUserService wxMerchantBUserService; |
|
|
|
@Autowired |
|
|
|
private WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获得昨日解单列表") |
|
|
|
@@ -88,91 +97,112 @@ public class WxMerchantTradeDailyController extends BaseController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// /** |
|
|
|
//// * 详情 |
|
|
|
//// * @param wxMerchantTradeDaily |
|
|
|
//// * @return |
|
|
|
//// */ |
|
|
|
//// @ApiOperation("详情") |
|
|
|
//// @GetMapping("findById") |
|
|
|
//// public ResultData findById(WxMerchantTradeDaily wxMerchantTradeDaily) { |
|
|
|
//// logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::findById"); |
|
|
|
//// String tenantId = getTenantId(); |
|
|
|
//// wxMerchantTradeDaily.setTenantId(tenantId); |
|
|
|
//// return new ResultData(wxMerchantTradeDailyService.getById(wxMerchantTradeDaily.getId())); |
|
|
|
//// } |
|
|
|
//// |
|
|
|
//// /** |
|
|
|
//// * 保存或编辑 |
|
|
|
//// * @param wxMerchantTradeDaily |
|
|
|
//// * @return |
|
|
|
//// */ |
|
|
|
//// @ApiOperation("保存或编辑") |
|
|
|
//// @PostMapping("saveOrUpdate") |
|
|
|
//// public ResultData saveOrUpdate(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { |
|
|
|
//// logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::saveOrUpdate"); |
|
|
|
//// wxMerchantTradeDaily.setTenantId(super.getTenantId()); |
|
|
|
//// wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily); |
|
|
|
//// return new ResultData(); |
|
|
|
//// } |
|
|
|
// |
|
|
|
// /** |
|
|
|
// * 列表 |
|
|
|
// * |
|
|
|
// * @param wxMerchantTradeDaily |
|
|
|
// * @return |
|
|
|
// */ |
|
|
|
// @ApiImplicitParams({ |
|
|
|
// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), |
|
|
|
// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) |
|
|
|
// }) |
|
|
|
// public ResultData list(WxMerchantTradeDaily wxMerchantTradeDaily, Integer pageNum,Integer pageSize) throws Exception{ |
|
|
|
// PageInfo<WxMerchantTradeDaily> pageInfo = wxMerchantTradeDailyService.listAsPage(wxMerchantTradeDaily, pageNum,pageSize); |
|
|
|
// List<WxMerchantTradeDaily> tradeDailyList = pageInfo.getList(); |
|
|
|
// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
// |
|
|
|
// //todo:看下数据是不是每天一条解单 |
|
|
|
// |
|
|
|
// String startTime = wxMerchantTradeDaily.getMonth()+"-01"; |
|
|
|
// String endTime = sd.format(DateUtils.getLastDayForMonth(sd.parse(startTime))); |
|
|
|
// List<String> days = DateUtils.getTjTimeList(startTime, endTime,"0"); |
|
|
|
// |
|
|
|
// Map<String,WxMerchantTradeDaily> resultMap = getMap(days); |
|
|
|
// |
|
|
|
// for (WxMerchantTradeDaily wx:tradeDailyList) { |
|
|
|
// resultMap.put(sd.format(wx.getCreateDate()),wx); |
|
|
|
// } |
|
|
|
// |
|
|
|
// List<WxMerchantTradeDaily> resultList = mapToList(resultMap); |
|
|
|
// //判断第1条是否是当天 |
|
|
|
// if(CollectionUtils.isNotEmpty(resultList)){ |
|
|
|
// if(sd.format(resultList.get(0).getCreateDate()).equals(sd.format(new Date()))){ |
|
|
|
// resultList.get(0).setIsToday(1); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// //todo如果是本月,截止日期应该是到当天,而不是整月 |
|
|
|
// |
|
|
|
/** |
|
|
|
* 详情 |
|
|
|
* @param wxMerchantTradeDaily |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ApiOperation("详情") |
|
|
|
@GetMapping("findById") |
|
|
|
public ResultData findById(WxMerchantTradeDaily wxMerchantTradeDaily) { |
|
|
|
logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::findById"); |
|
|
|
String tenantId = getTenantId(); |
|
|
|
wxMerchantTradeDaily.setTenantId(tenantId); |
|
|
|
return new ResultData(wxMerchantTradeDailyService.getById(wxMerchantTradeDaily.getId())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存或编辑 |
|
|
|
* @param wxMerchantTradeDaily |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ApiOperation("保存或编辑") |
|
|
|
@PostMapping("saveOrUpdate") |
|
|
|
public ResultData saveOrUpdate(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { |
|
|
|
logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::saveOrUpdate"); |
|
|
|
wxMerchantTradeDaily.setTenantId(super.getTenantId()); |
|
|
|
wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 列表 |
|
|
|
* |
|
|
|
* @param wxMerchantTradeDaily |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/list") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) |
|
|
|
}) |
|
|
|
public ResultData list(WxMerchantTradeDaily wxMerchantTradeDaily, Integer pageNum,Integer pageSize) throws Exception{ |
|
|
|
//根据userid查询merchantId |
|
|
|
WxMerchantBUser user = wxMerchantBUserService.getById(getUserId()); |
|
|
|
if (user==null) |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); |
|
|
|
if (merchant==null) |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
wxMerchantTradeDaily.setMerchantId(merchant.getId()); |
|
|
|
|
|
|
|
PageInfo<WxMerchantTradeDaily> pageInfo = wxMerchantTradeDailyService.listAsPage(wxMerchantTradeDaily, pageNum,pageSize); |
|
|
|
List<WxMerchantTradeDaily> tradeDailyList = pageInfo.getList(); |
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat sdMonth = new SimpleDateFormat("yyyy-MM"); |
|
|
|
|
|
|
|
String startTime = wxMerchantTradeDaily.getMonth()+"-01"; |
|
|
|
String endTime = sd.format(DateUtils.getLastDayForMonth(sd.parse(startTime))); |
|
|
|
//month为空默认本月第一天到今天 |
|
|
|
if(StringUtils.isBlank(wxMerchantTradeDaily.getMonth())){ |
|
|
|
startTime = sd.format(DateUtils.getFirstDayForCurrMonth()); |
|
|
|
endTime = sd.format(new Date()); |
|
|
|
}else { |
|
|
|
//如果是本月,截止到当天 |
|
|
|
if (sdMonth.format(new Date()).equals(wxMerchantTradeDaily.getMonth())) { |
|
|
|
endTime = sd.format(new Date()); |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> days = DateUtils.getTjTimeList(startTime, endTime,"0"); |
|
|
|
|
|
|
|
Map<String,WxMerchantTradeDaily> resultMap = getMap(days); |
|
|
|
|
|
|
|
for (WxMerchantTradeDaily wx:tradeDailyList) { |
|
|
|
resultMap.put(sd.format(wx.getCreateDate()),wx); |
|
|
|
} |
|
|
|
|
|
|
|
List<WxMerchantTradeDaily> resultList = mapToList(resultMap); |
|
|
|
//判断第1条是否是当天 |
|
|
|
if(CollectionUtils.isNotEmpty(resultList)){ |
|
|
|
if(sd.format(resultList.get(0).getCreateDate()).equals(sd.format(new Date()))){ |
|
|
|
resultList.get(0).setIsToday(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// pageInfo.setList(resultList); |
|
|
|
// return new ResultData(pageInfo); |
|
|
|
// } |
|
|
|
// |
|
|
|
// public List<WxMerchantTradeDaily> mapToList(Map<String,WxMerchantTradeDaily> map){ |
|
|
|
// List<WxMerchantTradeDaily> result = new ArrayList<>(); |
|
|
|
// for (String k:map.keySet()) { |
|
|
|
// result.add(map.get(k)); |
|
|
|
// } |
|
|
|
// return result; |
|
|
|
// } |
|
|
|
// |
|
|
|
// public Map<String,WxMerchantTradeDaily> getMap(List<String> days) throws Exception{ |
|
|
|
// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
// Map<String,WxMerchantTradeDaily> map = new LinkedMap(); |
|
|
|
// for (String d:days) { |
|
|
|
// WxMerchantTradeDaily w = new WxMerchantTradeDaily(); |
|
|
|
// w.setCreateDate(sd.parse(d)); |
|
|
|
// map.put(d,w); |
|
|
|
// for (WxMerchantTradeDaily w:resultList) { |
|
|
|
// System.out.println(sd.format(w.getCreateDate())+" "+w.getTradeAmt()); |
|
|
|
// System.out.println("---------"); |
|
|
|
// } |
|
|
|
// return map; |
|
|
|
// } |
|
|
|
return new ResultData(pageInfo); |
|
|
|
} |
|
|
|
|
|
|
|
public List<WxMerchantTradeDaily> mapToList(Map<String,WxMerchantTradeDaily> map){ |
|
|
|
List<WxMerchantTradeDaily> result = new ArrayList<>(); |
|
|
|
for (String k:map.keySet()) { |
|
|
|
result.add(map.get(k)); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public Map<String,WxMerchantTradeDaily> getMap(List<String> days) throws Exception{ |
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Map<String,WxMerchantTradeDaily> map = new LinkedMap(); |
|
|
|
for (int i = days.size()-1; i >=0 ; i--) { |
|
|
|
WxMerchantTradeDaily w = new WxMerchantTradeDaily(); |
|
|
|
w.setCreateDate(sd.parse(days.get(i))); |
|
|
|
map.put(days.get(i),w); |
|
|
|
} |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |