|
|
|
|
@ -16,21 +16,57 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.springblade.weixin.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.modules.desk.entity.Order; |
|
|
|
|
import org.springblade.modules.desk.mapper.OrderMapper; |
|
|
|
|
import org.springblade.modules.desk.service.IOrderService; |
|
|
|
|
import org.springblade.modules.system.entity.ApiScope; |
|
|
|
|
import org.springblade.modules.system.mapper.ApiScopeMapper; |
|
|
|
|
import org.springblade.modules.system.service.IApiScopeService; |
|
|
|
|
import org.springblade.weixin.dto.BuyCount; |
|
|
|
|
import org.springblade.weixin.entity.WeChatUser; |
|
|
|
|
import org.springblade.weixin.mapper.WeChatUserMapper; |
|
|
|
|
import org.springblade.weixin.service.IWeChatUserService; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 服务实现类 |
|
|
|
|
* |
|
|
|
|
* @author BladeX |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
public class WeChatUserServiceImpl extends BaseServiceImpl<WeChatUserMapper, WeChatUser> implements IWeChatUserService { |
|
|
|
|
|
|
|
|
|
private final WeChatUserMapper weChatUserMapper; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<WeChatUser> buyCount(IPage<WeChatUser> page, WeChatUser weChatUser) { |
|
|
|
|
IPage<WeChatUser> userIPage = this.page(page, Wrappers.<WeChatUser>lambdaQuery(weChatUser).select(WeChatUser::getUsername, WeChatUser::getPhone)); |
|
|
|
|
List<WeChatUser> records = userIPage.getRecords(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(records)) { |
|
|
|
|
List<BuyCount> buyCount = weChatUserMapper.buyCount(); |
|
|
|
|
Map<String, Integer> collect = buyCount.stream().collect(Collectors.toMap(BuyCount::getPhone, BuyCount::getCount)); |
|
|
|
|
|
|
|
|
|
records.forEach(weChatUser1 -> { |
|
|
|
|
Integer count = collect.get(weChatUser1.getPhone()); |
|
|
|
|
weChatUser1.setCount(count != null ? count : 0); |
|
|
|
|
}); |
|
|
|
|
userIPage.setRecords(records); |
|
|
|
|
} |
|
|
|
|
return userIPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|