|
|
|
@@ -404,6 +404,74 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long,WxMerchant> getMerchantMap(List<Long> merchantIdList,TenantEntity tenantEntity) { |
|
|
|
Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>(); |
|
|
|
if (merchantIdList.size() > 0 ){ |
|
|
|
WxMerchant mq = new WxMerchant(); |
|
|
|
mq.updateTenantInfo(tenantEntity); |
|
|
|
mq.setIds(merchantIdList); |
|
|
|
List<WxMerchant> merchantList = wxMerchantMapper.findList(mq); |
|
|
|
if (null != merchantList && merchantList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < merchantList.size();i++){ |
|
|
|
WxMerchant m = merchantList.get(i); |
|
|
|
merchantMap.put(m.getId(), m); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return merchantMap; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long,WxCoupon> getCouponMap(List<Long> couponIdList,TenantEntity tenantEntity) { |
|
|
|
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); |
|
|
|
if (couponIdList.size() > 0 ){ |
|
|
|
WxCoupon cq = new WxCoupon(); |
|
|
|
cq.updateTenantInfo(tenantEntity); |
|
|
|
cq.setIds(couponIdList); |
|
|
|
List<WxCoupon> couponList = wxCouponMapper.findList(cq); |
|
|
|
if (null != couponList && couponList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < couponList.size();i++){ |
|
|
|
WxCoupon c = couponList.get(i); |
|
|
|
couponMap.put(c.getId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return couponMap; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long,WxMerchantSubsidy> getOrderSubsidyMap(List<Long> merchantSubsidyOrderIdList,TenantEntity tenantEntity){ |
|
|
|
Map<Long,WxMerchantSubsidy> orderSubsidyMap = new HashMap<Long,WxMerchantSubsidy>(); |
|
|
|
if (merchantSubsidyOrderIdList.size() > 0 ){ |
|
|
|
WxMerchantSubsidy msq = new WxMerchantSubsidy(); |
|
|
|
msq.updateTenantInfo(tenantEntity); |
|
|
|
msq.setOrderIdList(merchantSubsidyOrderIdList); |
|
|
|
List<WxMerchantSubsidy> msqList = wxMerchantSubsidyMapper.findList(msq); |
|
|
|
if (null != msqList && msqList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < msqList.size();i++){ |
|
|
|
WxMerchantSubsidy c = msqList.get(i); |
|
|
|
orderSubsidyMap.put(c.getOrderId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return orderSubsidyMap; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long,WxCUserBasicInfo> getUserMap(List<Long> userIdList,TenantEntity tenantEntity) { |
|
|
|
Map<Long,WxCUserBasicInfo> userMap = new HashMap<Long,WxCUserBasicInfo>(); |
|
|
|
if (userIdList.size() > 0 ){ |
|
|
|
WxCUserBasicInfo u = new WxCUserBasicInfo(); |
|
|
|
u.setFinalTenantId(tenantEntity.getFinalTenantId()); |
|
|
|
u.setIds(userIdList); |
|
|
|
List<WxCUserBasicInfo> msqList = wxCUserBasicInfoMapper.findList(u); |
|
|
|
if (null != msqList && msqList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < msqList.size();i++){ |
|
|
|
WxCUserBasicInfo c = msqList.get(i); |
|
|
|
userMap.put(c.getId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return userMap; |
|
|
|
} |
|
|
|
|
|
|
|
private List<WxCardSpendVo> handleToCardSpendVoList(List<WxCardSpend> list,TenantEntity tenantEntity) { |
|
|
|
if (null != list && list.size() > 0 ){ |
|
|
|
List<Long> merchantIdList = new ArrayList<Long>(); |
|
|
|
@@ -428,19 +496,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>(); |
|
|
|
if (merchantIdList.size() > 0 ){ |
|
|
|
WxMerchant mq = new WxMerchant(); |
|
|
|
mq.updateTenantInfo(tenantEntity); |
|
|
|
mq.setIds(merchantIdList); |
|
|
|
List<WxMerchant> merchantList = wxMerchantMapper.findList(mq); |
|
|
|
if (null != merchantList && merchantList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < merchantList.size();i++){ |
|
|
|
WxMerchant m = merchantList.get(i); |
|
|
|
merchantMap.put(m.getId(), m); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<Long,WxMerchant> merchantMap = getMerchantMap(merchantIdList, tenantEntity); |
|
|
|
|
|
|
|
|
|
|
|
Map<Long,Long> cardCouponIdMap = new HashMap<Long,Long>(); |
|
|
|
if (cardInfoIdList.size() > 0 ){ |
|
|
|
@@ -459,47 +516,11 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); |
|
|
|
if (couponIdList.size() > 0 ){ |
|
|
|
WxCoupon cq = new WxCoupon(); |
|
|
|
cq.updateTenantInfo(tenantEntity); |
|
|
|
cq.setIds(couponIdList); |
|
|
|
List<WxCoupon> couponList = wxCouponMapper.findList(cq); |
|
|
|
if (null != couponList && couponList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < couponList.size();i++){ |
|
|
|
WxCoupon c = couponList.get(i); |
|
|
|
couponMap.put(c.getId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<Long,WxCoupon> couponMap = getCouponMap(couponIdList, tenantEntity); |
|
|
|
|
|
|
|
Map<Long,WxMerchantSubsidy> orderSubsidyMap = new HashMap<Long,WxMerchantSubsidy>(); |
|
|
|
if (merchantSubsidyOrderIdList.size() > 0 ){ |
|
|
|
WxMerchantSubsidy msq = new WxMerchantSubsidy(); |
|
|
|
msq.updateTenantInfo(tenantEntity); |
|
|
|
msq.setOrderIdList(merchantSubsidyOrderIdList); |
|
|
|
List<WxMerchantSubsidy> msqList = wxMerchantSubsidyMapper.findList(msq); |
|
|
|
if (null != msqList && msqList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < msqList.size();i++){ |
|
|
|
WxMerchantSubsidy c = msqList.get(i); |
|
|
|
orderSubsidyMap.put(c.getOrderId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<Long,WxMerchantSubsidy> orderSubsidyMap = getOrderSubsidyMap(merchantSubsidyOrderIdList, tenantEntity); |
|
|
|
|
|
|
|
Map<Long,WxCUserBasicInfo> userMap = new HashMap<Long,WxCUserBasicInfo>(); |
|
|
|
if (userIdList.size() > 0 ){ |
|
|
|
WxCUserBasicInfo u = new WxCUserBasicInfo(); |
|
|
|
u.setFinalTenantId(tenantEntity.getFinalTenantId()); |
|
|
|
u.setIds(userIdList); |
|
|
|
List<WxCUserBasicInfo> msqList = wxCUserBasicInfoMapper.findList(u); |
|
|
|
if (null != msqList && msqList.size() > 0 ){ |
|
|
|
for (int i = 0 ;i < msqList.size();i++){ |
|
|
|
WxCUserBasicInfo c = msqList.get(i); |
|
|
|
userMap.put(c.getId(),c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Map<Long,WxCUserBasicInfo> userMap = getUserMap(userIdList, tenantEntity); |
|
|
|
|
|
|
|
List<WxCardSpendVo> retList = new ArrayList<WxCardSpendVo>(); |
|
|
|
for (int i = 0 ; i < list.size(); i++ ){ |
|
|
|
@@ -543,7 +564,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
} catch (InvocationTargetException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@@ -615,12 +635,79 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> sumCardSpendForMerchant(WxCardSpendVo record) { |
|
|
|
return wxCardSpendMapper.sumCardSpendVoForMerchant(record); |
|
|
|
handleQueryParam(record); |
|
|
|
List<Long> merchantIdList = wxCardSpendMapper.getMerchantIdList(record); |
|
|
|
Map<Long,WxMerchant> merchantMap = this.getMerchantMap(merchantIdList, record); |
|
|
|
WxMerchantSubsidy sq = getWxMerchantSubsidyQuery(record,merchantIdList); |
|
|
|
List<Map<String,Object>> merchantSubsidyMap = wxMerchantSubsidyMapper.sumByMerchantId(sq); |
|
|
|
Map<Long,Map<String,Integer>> msmap = new HashMap<Long,Map<String,Integer>>(); |
|
|
|
if (null != merchantSubsidyMap && merchantSubsidyMap.size() > 0 ) { |
|
|
|
for (int i = 0 ; i < merchantSubsidyMap.size(); i++) { |
|
|
|
Map<String,Object> result = merchantSubsidyMap.get(i) ; |
|
|
|
Map<String,Integer> submap = new HashMap<String,Integer>(); |
|
|
|
submap.put("sum_subsidy", (Integer)result.get("sum_subsidy")); |
|
|
|
submap.put("sum_real_subsidy", (Integer)result.get("sum_real_subsidy")); |
|
|
|
msmap.put((Long)result.get("merchant_id"), submap) ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<Map<String, Object>> resultList = wxCardSpendMapper.sumCardSpendVoForMerchant(record); |
|
|
|
if (null != resultList && resultList.size() > 0 ) { |
|
|
|
for (int i = 0 ; i < resultList.size(); i++) { |
|
|
|
Map<String,Object> result = resultList.get(i); |
|
|
|
Long merchantId = (Long)result.get("merchant_id") ; |
|
|
|
if (null != merchantId) { |
|
|
|
WxMerchant merchant = merchantMap.get(merchantId); |
|
|
|
if (null != merchant) { |
|
|
|
result.put("merchantName", merchant.getName()); |
|
|
|
} |
|
|
|
Map<String,Integer> busmap = msmap.get(merchantId); |
|
|
|
if (null != busmap) { |
|
|
|
result.put("sum_subsidy", (null == busmap.get("sum_subsidy"))?0:busmap.get("sum_subsidy")); |
|
|
|
result.put("sum_real_subsidy", (null == busmap.get("sum_real_subsidy")?0:busmap.get("sum_real_subsidy"))); |
|
|
|
}else { |
|
|
|
result.put("sum_subsidy", 0); |
|
|
|
result.put("sum_real_subsidy", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
private WxMerchantSubsidy getWxMerchantSubsidyQuery(WxCardSpendVo record,List<Long> merchantIdList) { |
|
|
|
WxMerchantSubsidy sq = new WxMerchantSubsidy(); |
|
|
|
sq.updateTenantInfo(record); |
|
|
|
sq.setStatus(record.getStatus()); |
|
|
|
sq.setSourceList(record.getSources()); |
|
|
|
sq.setCardSpendListShow(record.getCardSpendListShow()); |
|
|
|
if (null != merchantIdList && merchantIdList.size() > 0 ) { |
|
|
|
sq.setMerchantIdList(merchantIdList); |
|
|
|
} |
|
|
|
return sq; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> sumCardSpendForOwner(WxCardSpendVo record) { |
|
|
|
return wxCardSpendMapper.sumCardSpendVoForOwner(record); |
|
|
|
handleQueryParam(record); |
|
|
|
List<Long> merchantIdList = wxCardSpendMapper.getMerchantIdList(record); |
|
|
|
WxMerchantSubsidy sq = getWxMerchantSubsidyQuery(record,merchantIdList); |
|
|
|
Map<String,Integer> submap = wxMerchantSubsidyMapper.sum(sq); |
|
|
|
List<Map<String, Object>> resultList = wxCardSpendMapper.sumCardSpendVoForOwner(record); |
|
|
|
if (null != resultList && resultList.size() > 0 ) { |
|
|
|
for (int i = 0 ; i < resultList.size(); i++) { |
|
|
|
Map<String,Object> result = resultList.get(i); |
|
|
|
if (null != submap) { |
|
|
|
result.put("sum_subsidy", (null == submap.get("sum_subsidy"))?0:submap.get("sum_subsidy")); |
|
|
|
result.put("sum_real_subsidy", (null == submap.get("sum_real_subsidy")?0:submap.get("sum_real_subsidy"))); |
|
|
|
}else { |
|
|
|
result.put("sum_subsidy", 0); |
|
|
|
result.put("sum_real_subsidy", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|