package com.ruoyi.auction.service.impl;
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
import com.alibaba.fastjson.JSONObject;
|
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayClient;
|
import com.alipay.api.DefaultAlipayClient;
|
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
import com.alipay.api.request.AlipayUserInfoShareRequest;
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.auction.controller.forepart.dto.AuctionSalesroomGoodsDTO;
|
import com.ruoyi.auction.controller.forepart.dto.ForepartAuctionBidRecordDTO;
|
import com.ruoyi.auction.controller.forepart.vo.ForepartAuctionSalesroomGoodsVO;
|
import com.ruoyi.auction.controller.forepart.vo.ForepartAuctionSalesroomVO;
|
import com.ruoyi.auction.controller.forepart.vo.MemberAuctionSalesroomInfoVO;
|
import com.ruoyi.auction.controller.forepart.vo.MemberAuctionSalesroomVO;
|
import com.ruoyi.auction.controller.management.dto.MgtAuctionSalesroomQuery;
|
import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomVO;
|
import com.ruoyi.auction.domain.AuctionBidRecord;
|
import com.ruoyi.auction.domain.AuctionSalesroom;
|
import com.ruoyi.auction.domain.AuctionSalesroomGoods;
|
import com.ruoyi.auction.domain.AuctionVideo;
|
import com.ruoyi.auction.mapper.AuctionSalesroomGoodsMapper;
|
import com.ruoyi.auction.mapper.AuctionSalesroomMapper;
|
import com.ruoyi.auction.service.IAuctionBidRecordService;
|
import com.ruoyi.auction.service.IAuctionSalesroomService;
|
import com.ruoyi.auction.service.IAuctionVideoService;
|
import com.ruoyi.auction.util.CreateQrCode;
|
import com.ruoyi.auction.util.HttpUtils;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.page.PageDTO;
|
import com.ruoyi.system.api.domain.AppMiniLoginVO;
|
import com.ruoyi.system.api.domain.GoodsSku;
|
import com.ruoyi.system.api.domain.OrderAuctionBond;
|
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
|
import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomDTO;
|
import com.ruoyi.system.api.feignClient.GoodsSkuClient;
|
import com.ruoyi.system.api.feignClient.OrderClient;
|
import com.ruoyi.system.api.feignClient.SysUserClient;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
import javax.annotation.Resource;
|
import org.apache.http.HttpResponse;
|
import org.apache.http.util.EntityUtils;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* <p>
|
* 拍卖场表 服务实现类
|
* </p>
|
*
|
* @author mitao
|
* @since 2024-05-16
|
*/
|
@Service
|
public class AuctionSalesroomServiceImpl extends ServiceImpl<AuctionSalesroomMapper, AuctionSalesroom> implements IAuctionSalesroomService {
|
@Resource
|
private IAuctionSalesroomService iAuctionSalesroomService;
|
|
@Resource
|
private IAuctionBidRecordService auctionBidRecordService;
|
|
@Resource
|
private AuctionSalesroomMapper auctionSalesroomMapper;
|
|
@Resource
|
private IAuctionVideoService iAuctionVideoService;
|
|
@Resource
|
private SysUserClient sysUserClient;
|
|
@Resource
|
private WxMaService wxMaService;
|
|
@Resource
|
private AuctionSalesroomGoodsMapper auctionSalesroomGoodsMapper;
|
|
@Resource
|
private GoodsSkuClient goodsSkuClient;
|
|
@Resource
|
private OrderClient orderClient;
|
|
|
//微信
|
private static final String ACCESS_TOKEN_HOST = "https://api.weixin.qq.com/cgi-bin/token";
|
|
private static final String WX_APPID = "wxb7f0ea286fc4e535";
|
|
private static final String WX_SECRET = "852a2512a6ab559cafc68bae5d4160ac";
|
|
|
//支付寶
|
/**
|
* Alipay客户端
|
*/
|
private AlipayClient alipayClient;
|
|
/**支付宝网关*/
|
/**
|
* 沙箱的
|
*/
|
private static final String ALIPAY_BORDER_DEV = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
|
/**
|
* 个人用户的
|
*/
|
private static final String ALIPAY_BORDER_PROD = "https://openapi.alipay.com/gateway.do";
|
/**
|
* appID
|
**/
|
private static final String APP_ID_PROD = "2021003196653501";
|
/**
|
* 私钥
|
*/
|
private static final String APP_PRIVATE_KEY = "";
|
/**
|
* 支付宝公钥
|
*/
|
private static final String ALIPAY_PUBLIC_KEY = "";
|
|
@Override
|
public PageDTO<AuctionSalesroom> getAuctionBidRecordList(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
|
Page<AuctionSalesroom> page = new Page<>(ationSalesroomGoodsDTO.getPageCurr(), ationSalesroomGoodsDTO.getPageSize());
|
LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
|
wrapper.eq(AuctionSalesroom::getSalesroomName,ationSalesroomGoodsDTO.getSalesroomName());
|
wrapper.eq(AuctionSalesroom::getDelFlag,0);
|
Page<AuctionSalesroom> page1=iAuctionSalesroomService.page(page, wrapper);
|
return PageDTO.of(page1);
|
}
|
|
@Override
|
public ForepartAuctionSalesroomVO getBaaner(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
|
LambdaQueryWrapper<AuctionVideo> wrapper=Wrappers.lambdaQuery();
|
wrapper.eq(AuctionVideo::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId());
|
wrapper.eq(AuctionVideo::getDelFlag,0);
|
AuctionVideo auctionVideo=iAuctionVideoService.getOne(wrapper);
|
ForepartAuctionSalesroomVO forepartAuctionSalesroomVO =new ForepartAuctionSalesroomVO();
|
AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(ationSalesroomGoodsDTO.getAuctionSalesroomId());
|
forepartAuctionSalesroomVO.setAuctionSalesroomStatus(auctionSalesroom.getStatus().getCode());
|
if (auctionVideo!=null){
|
forepartAuctionSalesroomVO.setUrl(auctionVideo.getPromotionVideoUrl());
|
}else{
|
forepartAuctionSalesroomVO.setUrl(auctionSalesroom.getCoverPic());
|
}
|
return forepartAuctionSalesroomVO;
|
}
|
|
@Override
|
public AuctionSalesroom getAuctionBidRecordOne(ForepartAuctionBidRecordDTO arepartAuctionBidRecordDTO) {
|
R<SysUser> r=sysUserClient.queryUserByPhone(arepartAuctionBidRecordDTO.getPhone());
|
SysUser sysUser=r.getData();
|
|
if (sysUser!=null){
|
throw new ServiceException("手机号未注册");
|
}
|
|
if (!sysUser.getPassword().equals(arepartAuctionBidRecordDTO.getPassword())){
|
throw new ServiceException("密码输入错误");
|
}
|
|
if (!sysUser.getUserType().equals("2")){
|
throw new ServiceException("该人员不是拍卖师");
|
}
|
|
LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
|
wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,arepartAuctionBidRecordDTO.getAuctionSalesroomQrcode());
|
wrapper.eq(AuctionSalesroom::getDelFlag,0);
|
AuctionSalesroom auctionBidRecord=iAuctionSalesroomService.getOne(wrapper);
|
return auctionBidRecord;
|
}
|
|
@Override
|
public AppMiniLoginVO actionMiniLogin(AppMiniLoginDTO appMiniLoginDto) {
|
try {
|
AppMiniLoginVO appMiniLoginVo = new AppMiniLoginVO();
|
if (appMiniLoginDto.getType()==1){
|
if (appMiniLoginDto.getAuth_code()== null || appMiniLoginDto.getAuth_code().length() == 0) {
|
} else {
|
AppMiniLoginVO user=new AppMiniLoginVO();
|
//String serverUrl, String appId, String privateKey, String format,String charset, String alipayPublicKey, String signType
|
//实例化客户端 参数:正式环境URL,Appid,商户私钥 PKCS8格式,字符编码格式,字符格式,支付宝公钥,签名方式
|
AlipayClient alipayClient = new DefaultAlipayClient(ALIPAY_BORDER_PROD,APP_ID_PROD, APP_PRIVATE_KEY, "json", "GBK", ALIPAY_PUBLIC_KEY, "RSA2");
|
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
// 值为authorization_code时,代表用code换取
|
request.setGrantType("authorization_code");
|
//授权码,用户对应用授权后得到的
|
request.setCode(appMiniLoginDto.getAuth_code());
|
//这里使用execute方法
|
AlipaySystemOauthTokenResponse response = null;
|
try {
|
response = alipayClient.execute(request);
|
} catch (AlipayApiException e) {
|
throw new RuntimeException(e);
|
}
|
//刷新令牌,上次换取访问令牌时得到。见出参的refresh_token字段
|
request.setRefreshToken(response.getAccessToken());
|
|
//返回成功时 就将唯一标识返回
|
if (response.isSuccess()) {
|
System.out.println("调用成功");
|
//我这里只返回了一个字段给前端用
|
String user1= response.getUserId();
|
appMiniLoginVo.setZfbuserid(response.getUserId());
|
AlipayUserInfoShareResponse alipayUserInfoShareResponse=getAliUserInfo(response.getAccessToken());
|
appMiniLoginVo.setPhone(alipayUserInfoShareResponse.getPhone());
|
R<SysUser> sysUserR = sysUserClient.queryUserByPhone(alipayUserInfoShareResponse.getPhone());
|
SysUser data = sysUserR.getData();
|
appMiniLoginVo.setSysUser(data);
|
}
|
}
|
}else{
|
WxMaJscode2SessionResult session = null;
|
String unionid;
|
String openid;
|
String sessionKey = null;
|
//获取session
|
session = wxMaService.getUserService().getSessionInfo(appMiniLoginDto.getCode());
|
if (session != null && StringUtils.isNotBlank(session.getOpenid())) {
|
unionid = session.getUnionid();
|
openid = session.getOpenid();
|
sessionKey = session.getSessionKey();
|
|
|
String responseAccessToken = getAccessTokenByWX();
|
|
JSONObject jsonAccessToken = JSONObject.parseObject(responseAccessToken);
|
String accessToken = jsonAccessToken.getString("access_token");
|
String errmsg = jsonAccessToken.getString("errmsg");
|
Long expiresIn = jsonAccessToken.getLong("expires_in");
|
if (StringUtils.isBlank(accessToken)) {
|
throw new ServiceException(errmsg);
|
}
|
String responseUserPhoneNumber = getMobileByWX(accessToken, appMiniLoginDto.getCode());
|
JSONObject jsonUserPhoneNumber = JSONObject.parseObject(responseUserPhoneNumber);
|
|
|
String phoneInfo = jsonUserPhoneNumber.getString("phone_info");
|
JSONObject jsonUserPhoneInfo = JSONObject.parseObject(phoneInfo);
|
String mobile = jsonUserPhoneInfo.getString("purePhoneNumber");
|
//获取用户
|
R<SysUser> sysUserR = sysUserClient.queryUserByPhone(mobile);
|
SysUser data = sysUserR.getData();
|
appMiniLoginVo.setSysUser(data);
|
|
appMiniLoginVo.setMiniOpenid(openid);
|
appMiniLoginVo.setWxUnionid(unionid);
|
appMiniLoginVo.setPhone(mobile);
|
appMiniLoginVo.setSessionKey(sessionKey);
|
}
|
}
|
return appMiniLoginVo;
|
} catch (Exception e) {
|
e.printStackTrace();
|
return null;
|
}
|
}
|
|
|
|
private AlipayUserInfoShareResponse getAliUserInfo (String accessToken) throws Exception {
|
|
AlipayClient alipayClient = new DefaultAlipayClient(ALIPAY_BORDER_PROD,APP_ID_PROD, APP_PRIVATE_KEY, "json", "GBK", ALIPAY_PUBLIC_KEY, "RSA2");
|
AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();
|
AlipayUserInfoShareResponse response = alipayClient.execute(request, accessToken);
|
if(response.isSuccess()){
|
System.out.println("获取会员信息 - 调用成功");
|
return response;
|
}
|
return null;
|
}
|
|
@Override
|
public PageDTO<MemberAuctionSalesroomVO> getMemberAuctionSalesroomList(MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) {
|
Page<MemberAuctionSalesroomVO> page = new Page<>();
|
page.setSize(memberAuctionSalesroomDTO.getPageSize());
|
page.setCurrent(memberAuctionSalesroomDTO.getPageCurr());
|
List<AuctionSalesroom> auctionSalesroomList=auctionSalesroomMapper.pageMemberAuctionSalesroomList(page,memberAuctionSalesroomDTO);
|
List<MemberAuctionSalesroomVO> List=new ArrayList<>();
|
for (AuctionSalesroom auctionSalesroom:auctionSalesroomList){
|
MemberAuctionSalesroomVO memberAuctionSalesroomVO=new MemberAuctionSalesroomVO();
|
memberAuctionSalesroomVO.setSalesroomName(auctionSalesroom.getSalesroomName());
|
memberAuctionSalesroomVO.setDescription(auctionSalesroom.getDescription());
|
memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus().getCode());
|
memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId());
|
memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic());
|
List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData();
|
if (data.size()>0){
|
memberAuctionSalesroomVO.setIsApply(2);
|
}else{
|
memberAuctionSalesroomVO.setIsApply(1);
|
}
|
MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1=new MemberAuctionSalesroomDTO();
|
memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getId());
|
List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData();
|
memberAuctionSalesroomVO.setApplyNum(data1.size());
|
List.add(memberAuctionSalesroomVO);
|
}
|
page.setRecords(List);
|
return PageDTO.of(page);
|
}
|
|
@Override
|
public MemberAuctionSalesroomInfoVO getMemberAuctionSalesroomInfo(MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) {
|
AuctionSalesroom byId = iAuctionSalesroomService.getById(memberAuctionSalesroomDTO.getAuctionSalesroomId());
|
MemberAuctionSalesroomInfoVO memberAuctionSalesroomInfoVO=new MemberAuctionSalesroomInfoVO();
|
memberAuctionSalesroomInfoVO.setId(byId.getId());
|
memberAuctionSalesroomInfoVO.setBound(byId.getBound());
|
memberAuctionSalesroomInfoVO.setAuthentication(byId.getAuthentication());
|
memberAuctionSalesroomInfoVO.setEndTime(byId.getEndTime());
|
memberAuctionSalesroomInfoVO.setSalesroomName(byId.getSalesroomName());
|
memberAuctionSalesroomInfoVO.setType(byId.getType());
|
memberAuctionSalesroomInfoVO.setDescription(byId.getDescription());
|
memberAuctionSalesroomInfoVO.setSharePic(byId.getSharePic());
|
memberAuctionSalesroomInfoVO.setShareTitle(byId.getShareTitle());
|
memberAuctionSalesroomInfoVO.setStartTime(byId.getStartTime());
|
memberAuctionSalesroomInfoVO.setStatus(byId.getStatus());
|
memberAuctionSalesroomInfoVO.setCoverPic(byId.getCoverPic());
|
List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData();
|
if (data.size()>0){
|
memberAuctionSalesroomInfoVO.setIsApply(2);
|
}else{
|
memberAuctionSalesroomInfoVO.setIsApply(1);
|
}
|
List<ForepartAuctionSalesroomGoodsVO> forepartAuctionSalesroomGoodsVOS=new ArrayList<>();
|
List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.getAuctionSalesroomGoods(memberAuctionSalesroomDTO);
|
for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods){
|
ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO=new ForepartAuctionSalesroomGoodsVO();
|
forepartAuctionSalesroomGoodsVO.setSalesroomId(byId.getId());
|
forepartAuctionSalesroomGoodsVO.setSalesroomName(byId.getSalesroomName());
|
GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(salesroomGoods.getGoodsSkuId(), SecurityConstants.INNER)
|
.getData();
|
forepartAuctionSalesroomGoodsVO.setGoodsSkuName(goodsSku.getSkuName());
|
forepartAuctionSalesroomGoodsVO.setGoodsSkuId(salesroomGoods.getId());
|
forepartAuctionSalesroomGoodsVO.setCoverPic(goodsSku.getCoverPic());
|
forepartAuctionSalesroomGoodsVO.setStartingPrice(salesroomGoods.getStartingPrice());
|
forepartAuctionSalesroomGoodsVO.setSalesroomStock(salesroomGoods.getSalesroomStock());
|
forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(salesroomGoods.getStatus().getCode());
|
|
LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery();
|
wrapper1.eq(AuctionBidRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId());
|
wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,byId.getId());
|
wrapper1.eq(AuctionBidRecord::getTargetId,salesroomGoods.getId());
|
wrapper1.eq(AuctionBidRecord::getDelFlag,0);
|
AuctionBidRecord list1 = auctionBidRecordService.getOne(wrapper1);
|
if (list1!=null){
|
forepartAuctionSalesroomGoodsVO.setIsBond(2);
|
if (list1.getStatus().getCode()==2){
|
forepartAuctionSalesroomGoodsVO.setIsStatus(2);
|
}else{
|
forepartAuctionSalesroomGoodsVO.setIsStatus(1);
|
}
|
}else{
|
forepartAuctionSalesroomGoodsVO.setIsBond(1);
|
forepartAuctionSalesroomGoodsVO.setIsStatus(1);
|
}
|
forepartAuctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO);
|
}
|
memberAuctionSalesroomInfoVO.setForepartAuctionSalesroomGoodsVO(forepartAuctionSalesroomGoodsVOS);
|
return memberAuctionSalesroomInfoVO;
|
}
|
|
@Override
|
public MemberAuctionSalesroomVO getMemberAuctionSalesroomSweep(MemberAuctionSalesroomDTO MemberAuctionSalesroomDTO) {
|
LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
|
wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,MemberAuctionSalesroomDTO.getSalesroomNO());
|
wrapper.eq(AuctionSalesroom::getDelFlag,0);
|
AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getOne(wrapper);
|
MemberAuctionSalesroomVO memberAuctionSalesroomVO=new MemberAuctionSalesroomVO();
|
memberAuctionSalesroomVO.setSalesroomName(auctionSalesroom.getSalesroomName());
|
memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus().getCode());
|
memberAuctionSalesroomVO.setDescription(auctionSalesroom.getDescription());
|
memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId());
|
return memberAuctionSalesroomVO;
|
}
|
|
|
public static String getAccessTokenByWX() throws Exception {
|
String host = ACCESS_TOKEN_HOST + "?appid=" + WX_APPID + "&secret=" + WX_SECRET + "&grant_type=client_credential";
|
Map<String, String> headers = new HashMap<>(8);
|
HttpResponse response = HttpUtils.doGet(host, "", "GET", headers, null);
|
return EntityUtils.toString(response.getEntity());
|
}
|
|
public static String getMobileByWX(String accessToken, String code) throws Exception {
|
Map<String, String> headers = new HashMap<>(16);
|
headers.put("Content-Type", "application/json");
|
headers.put("Accept", "application/json");
|
Map<String, String> querys = new HashMap<>(16);
|
Map<String, String> bodys = new HashMap<>(16);
|
querys.put("access_token", accessToken);
|
bodys.put("code", code);
|
String body = JSONObject.toJSONString(bodys);
|
String host = "https://api.weixin.qq.com/wxa/business/getuserphonenumber";
|
HttpResponse response = HttpUtils.doPost(host, "", "POST", headers, querys, body);
|
return EntityUtils.toString(response.getEntity());
|
}
|
|
/**
|
* 分页查询拍卖场
|
*
|
* @param query 拍卖场查询对象
|
* @return PageDTO<MgtAuctionSalesroomVO>
|
*/
|
@Override
|
public PageDTO<MgtAuctionSalesroomVO> getAuctionSalesroomPage(MgtAuctionSalesroomQuery query) {
|
// 分页查询
|
Page<AuctionSalesroom> page = this.lambdaQuery()
|
.select(AuctionSalesroom::getId, AuctionSalesroom::getSalesroomName,
|
AuctionSalesroom::getCreateTime, AuctionSalesroom::getStartTime,
|
AuctionSalesroom::getEndTime, AuctionSalesroom::getType,
|
AuctionSalesroom::getAuthentication, AuctionSalesroom::getStatus)
|
.like(StringUtils.isNotEmpty(query.getSalesroomName()),
|
AuctionSalesroom::getSalesroomName, query.getSalesroomName())
|
.eq(StringUtils.isNotNull(query.getAuthentication()),
|
AuctionSalesroom::getAuthentication, query.getAuthentication())
|
.eq(StringUtils.isNotNull(query.getStatus()), AuctionSalesroom::getStatus,
|
query.getStatus()).between(
|
StringUtils.isNotNull(query.getStartTime()) && StringUtils.isNotNull(
|
query.getEndTime()), AuctionSalesroom::getStartTime,
|
query.getStartTime(),
|
query.getEndTime())
|
.page(new Page<>(query.getPageCurr(), query.getPageSize()));
|
List<AuctionSalesroom> records = page.getRecords();
|
if (StringUtils.isNull(records)) {
|
return PageDTO.empty(page);
|
}
|
PageDTO<MgtAuctionSalesroomVO> auctionSalesroomVOPageDTO = PageDTO.of(page,
|
MgtAuctionSalesroomVO.class);
|
List<MgtAuctionSalesroomVO> list = auctionSalesroomVOPageDTO.getList();
|
List<Long> auctionSalesroomIdList = list.stream().map(MgtAuctionSalesroomVO::getId)
|
.collect(Collectors.toList());
|
// 所有拍卖场的拍卖商品
|
List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList(
|
Wrappers.<AuctionSalesroomGoods>lambdaQuery()
|
.in(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomIdList));
|
// 计算每个拍卖场所有拍品数量
|
Map<Long, Integer> map = auctionSalesroomGoods.stream()
|
.collect(Collectors.groupingBy(AuctionSalesroomGoods::getAuctionSalesroomId,
|
Collectors.summingInt(AuctionSalesroomGoods::getSalesroomStock)));
|
for (MgtAuctionSalesroomVO mgtAuctionSalesroomVO : list) {
|
Integer i = map.get(mgtAuctionSalesroomVO.getId());
|
if (StringUtils.isNotNull(i)) {
|
mgtAuctionSalesroomVO.setAuctionGoodsNum(i);
|
}
|
}
|
return auctionSalesroomVOPageDTO;
|
}
|
|
/**
|
* 查看二维码
|
*
|
* @param id 拍卖场id
|
* @return 二维码
|
*/
|
@Override
|
public String getQrCode(Long id) throws Exception {
|
AuctionSalesroom auctionSalesroom = this.getById(id);
|
String auctionSalesroomNo = auctionSalesroom.getAuctionSalesroomNo();
|
return CreateQrCode.createQRCode(auctionSalesroomNo);
|
}
|
}
|