Pre Merge pull request !24 from yuxuntoo/dev
This commit is contained in:
commit
d0799e2380
|
|
@ -16,6 +16,7 @@
|
|||
package com.jeequan.jeepay.mgr.ctrl.isv;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jeequan.jeepay.components.mq.model.ResetIsvMchAppInfoConfigMQ;
|
||||
|
|
@ -23,6 +24,7 @@ import com.jeequan.jeepay.components.mq.vender.IMQSender;
|
|||
import com.jeequan.jeepay.core.aop.MethodLog;
|
||||
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
|
||||
import com.jeequan.jeepay.core.entity.IsvInfo;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.ApiRes;
|
||||
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
|
||||
import com.jeequan.jeepay.service.impl.IsvInfoService;
|
||||
|
|
@ -34,6 +36,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.baomidou.mybatisplus.core.enums.SqlKeyword.*;
|
||||
|
||||
/**
|
||||
* 服务商管理类
|
||||
*
|
||||
|
|
@ -57,6 +61,7 @@ public class IsvInfoController extends CommonCtrl {
|
|||
@RequestMapping(value="", method = RequestMethod.GET)
|
||||
public ApiRes list() {
|
||||
IsvInfo isvInfo = getObject(IsvInfo.class);
|
||||
|
||||
LambdaQueryWrapper<IsvInfo> wrapper = IsvInfo.gw();
|
||||
if (StringUtils.isNotEmpty(isvInfo.getIsvNo())) {
|
||||
wrapper.eq(IsvInfo::getIsvNo, isvInfo.getIsvNo());
|
||||
|
|
@ -67,9 +72,12 @@ public class IsvInfoController extends CommonCtrl {
|
|||
if (isvInfo.getState() != null) {
|
||||
wrapper.eq(IsvInfo::getState, isvInfo.getState());
|
||||
}
|
||||
wrapper.orderByDesc(IsvInfo::getCreatedAt);
|
||||
IPage<IsvInfo> pages = isvInfoService.page(getIPage(true), wrapper);
|
||||
|
||||
if(StringUtils.isNotEmpty((String)isvInfo.getExt().get("orderItem"))){
|
||||
setOrderBy(wrapper,true,(String)isvInfo.getExt().get("orderItem"));
|
||||
}else{
|
||||
wrapper.orderByDesc(IsvInfo::getCreatedAt);
|
||||
}
|
||||
IPage<IsvInfo> pages = isvInfoService.pageForIsv(getIPage(true), wrapper);
|
||||
return ApiRes.page(pages);
|
||||
}
|
||||
|
||||
|
|
@ -146,4 +154,24 @@ public class IsvInfoController extends CommonCtrl {
|
|||
}
|
||||
return ApiRes.ok(isvInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置动态字段排序
|
||||
* TODO 提取公共方法,供调用
|
||||
* @param queryWrapper
|
||||
* @param asc 是否升序
|
||||
* @param column 排序字段
|
||||
* @param <T> 泛型
|
||||
*/
|
||||
public static <T> void setOrderBy(LambdaQueryWrapper<T> queryWrapper, boolean asc,String column) {
|
||||
try {
|
||||
if(StringUtils.isEmpty(column)){
|
||||
return;
|
||||
}
|
||||
ISqlSegment[] sqlSegments = {ORDER_BY, ()->column, asc ? ASC : DESC};
|
||||
queryWrapper.getExpression().add(sqlSegments);
|
||||
} catch (Exception e) {
|
||||
throw new BizException("动态排序异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.IsvInfo;
|
||||
|
|
@ -22,10 +25,18 @@ import com.jeequan.jeepay.core.entity.MchInfo;
|
|||
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
|
||||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.service.mapper.IsvInfoMapper;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务商信息表 服务实现类
|
||||
|
|
@ -69,4 +80,30 @@ public class IsvInfoService extends ServiceImpl<IsvInfoMapper, IsvInfo> {
|
|||
throw new BizException("删除服务商失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务商列表信息
|
||||
* @param page
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
public IPage<IsvInfo> pageForIsv(IPage page,Wrapper queryWrapper) {
|
||||
IPage<IsvInfo> pages = isvInfoService.page(page, queryWrapper);
|
||||
List<String> isvNos = pages.getRecords().stream().map(isvInfo -> isvInfo.getIsvNo()).collect(Collectors.toList());
|
||||
List<Map<String, Object>> computMchList = mchInfoService.computeMchNum(isvNos);
|
||||
Map<String, Object[]> isvNoKeyArray = computMchList.stream().collect(Collectors.toMap(map -> (String) map.get("isv_no"), map1 -> new Object[]{map1.get("normal_num"), map1.get("stop_num")}));
|
||||
pages.getRecords().stream().forEach(isvInfo -> {
|
||||
// 有效商户数量
|
||||
isvInfo.addExt("normalMchNum",Optional.ofNullable(isvNoKeyArray)
|
||||
.map(map->map.get(isvInfo.getIsvNo()))
|
||||
.map(obj->(Long)obj[0])
|
||||
.orElse(0L));
|
||||
// 无效商户数量
|
||||
isvInfo.addExt("stopMchNum",Optional.ofNullable(isvNoKeyArray)
|
||||
.map(map->map.get(isvInfo.getIsvNo()))
|
||||
.map(obj->(Long)obj[1])
|
||||
.orElse(0L));
|
||||
});
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ package com.jeequan.jeepay.service.impl;
|
|||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
|
||||
|
|
@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -178,4 +180,17 @@ public class MchInfoService extends ServiceImpl<MchInfoMapper, MchInfo> {
|
|||
throw new BizException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分组及条件,计算商户的数量,此处包含了在用数量及停用数量
|
||||
* @param isvNos 服务商号集合
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> computeMchNum(List<String> isvNos){
|
||||
if(CollectionUtils.isEmpty(isvNos)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Map<String, Object>> mchNumList = baseMapper.computeMchNum(isvNos);
|
||||
return mchNumList;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,10 @@ package com.jeequan.jeepay.service.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
|
@ -28,4 +32,6 @@ import com.jeequan.jeepay.core.entity.MchInfo;
|
|||
*/
|
||||
public interface MchInfoMapper extends BaseMapper<MchInfo> {
|
||||
|
||||
/** 通过服务商号,统计服务商下有多少有效用户及无效用户 **/
|
||||
List<Map<String,Object>> computeMchNum(@Param("isvNos") List<String> isvNos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,19 @@
|
|||
<result column="updated_at" property="updatedAt" />
|
||||
</resultMap>
|
||||
|
||||
<select id="computeMchNum" resultType="java.util.Map" parameterType="java.util.List">
|
||||
SELECT
|
||||
isv_no,
|
||||
ifnull( count( CASE WHEN state = 1 THEN 1 END ), 0 ) AS normal_num,
|
||||
ifnull( count( CASE WHEN state = 0 THEN 0 END ), 0 ) AS stop_num
|
||||
FROM
|
||||
t_mch_info
|
||||
WHERE
|
||||
isv_no IN
|
||||
<foreach collection="isvNos" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
isv_no
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue