1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
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);
    }
}