| | |
| | | package com.ruoyi.auction.service.impl; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.internal.util.AlipayEncrypt; |
| | | import com.alipay.api.internal.util.AlipaySignature; |
| | | 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.google.common.collect.Lists; |
| | | import com.ruoyi.system.api.domain.dto.AuctionSalesroomGoodsDTO; |
| | | import com.ruoyi.system.api.domain.dto.ForepartAuctionBidRecordDTO; |
| | | import com.ruoyi.system.api.domain.vo.ForepartAuctionSalesroomGoodsVO; |
| | | import com.ruoyi.system.api.domain.vo.ForepartAuctionSalesroomVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomVO; |
| | | import com.google.zxing.WriterException; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionSaleroomBidRecordQuery; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionSalesroomDTO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionSalesroomGoodsDTO; |
| | |
| | | import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomScreenVO; |
| | | import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomVO; |
| | | import com.ruoyi.auction.domain.AuctionBidRecord; |
| | | import com.ruoyi.auction.domain.AuctionBrowseRecord; |
| | | import com.ruoyi.auction.domain.AuctionSalesroomGoods; |
| | | import com.ruoyi.auction.domain.AuctionVideo; |
| | | import com.ruoyi.auction.mapper.AuctionBidRecordMapper; |
| | |
| | | import com.ruoyi.common.core.utils.page.Checker; |
| | | import com.ruoyi.common.core.utils.page.CollUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.AppMiniLoginVO; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | |
| | | import com.ruoyi.system.api.domain.PromotionVideo; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO; |
| | | import com.ruoyi.system.api.domain.dto.AuctionSalesroomDTO; |
| | | import com.ruoyi.system.api.domain.dto.BidDTO; |
| | | import com.ruoyi.system.api.domain.dto.ForepartAuctionBidRecordDTO; |
| | | import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomBondDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomWdDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderAuctionBondDTO; |
| | | import com.ruoyi.system.api.domain.dto.RefundDTO; |
| | | import com.ruoyi.system.api.domain.vo.ForepartAuctionSalesroomGoodsVO; |
| | | import com.ruoyi.system.api.domain.vo.ForepartAuctionSalesroomVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberAuctionSalesroomVO; |
| | | import com.ruoyi.system.api.domain.vo.PayInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.WdMemberAuctionSalesroomVO; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | |
| | | import com.ruoyi.system.api.feignClient.PromotionClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | |
| | | @Override |
| | | public PageDTO<AuctionSalesroom> getAuctionBidRecordList(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { |
| | | Page<AuctionSalesroom> page = new Page<>(ationSalesroomGoodsDTO.getPageCurr(), ationSalesroomGoodsDTO.getPageSize()); |
| | | public List<AuctionSalesroom> getAuctionBidRecordList(AuctionSalesroomDTO ationSalesroomGoodsDTO) { |
| | | LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionSalesroom::getSalesroomName,ationSalesroomGoodsDTO.getSalesroomName()); |
| | | wrapper.eq(AuctionSalesroom::getDelFlag,0); |
| | | Page<AuctionSalesroom> page1 = this.page(page, wrapper); |
| | | return PageDTO.of(page1); |
| | | List<AuctionSalesroom> page1 = this.list(wrapper); |
| | | return page1; |
| | | } |
| | | |
| | | @Override |
| | | public ForepartAuctionSalesroomVO getBaaner(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { |
| | | public ForepartAuctionSalesroomVO getBaaner(AuctionSalesroomDTO ationSalesroomGoodsDTO) { |
| | | LambdaQueryWrapper<AuctionVideo> wrapper=Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionVideo::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); |
| | | wrapper.eq(AuctionVideo::getDelFlag,0); |
| | |
| | | public AuctionSalesroom getAuctionBidRecordOne(ForepartAuctionBidRecordDTO arepartAuctionBidRecordDTO) { |
| | | R<SysUser> r=sysUserClient.queryUserByPhone(arepartAuctionBidRecordDTO.getPhone()); |
| | | SysUser sysUser=r.getData(); |
| | | |
| | | if (sysUser!=null){ |
| | | if (sysUser==null){ |
| | | throw new ServiceException("手机号未注册"); |
| | | } |
| | | |
| | | if (!sysUser.getPassword().equals(arepartAuctionBidRecordDTO.getPassword())){ |
| | | if (!SecurityUtils.matchesPassword(arepartAuctionBidRecordDTO.getPassword(), sysUser.getPassword())){ |
| | | throw new ServiceException("密码输入错误"); |
| | | } |
| | | |
| | |
| | | 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字段 |
| | | |
| | | //返回成功时 就将唯一标识返回 |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | //我这里只返回了一个字段给前端用 |
| | | String user1= response.getOpenId(); |
| | | appMiniLoginVo.setZfbuserid(response.getOpenId()); |
| | | AlipayUserInfoShareResponse alipayUserInfoShareResponse= null; |
| | | try { |
| | | AlipayUserInfoShareRequest request1 = new AlipayUserInfoShareRequest(); |
| | | AlipayUserInfoShareResponse response1 = alipayClient.execute(request1, response.getAccessToken()); |
| | | appMiniLoginVo.setPhone(response1.getPhone()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | R<SysUser> sysUserR = sysUserClient.queryUserByPhone(alipayUserInfoShareResponse.getPhone()); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | String response = JSON.parseObject(appMiniLoginDto.getAuth_code()).getString("response"); |
| | | |
| | | //1. 获取验签和解密所需要的参数 |
| | | Map<String, String> openapiResult = JSON.parseObject(appMiniLoginDto.getAuth_code(), |
| | | new TypeReference<Map<String, String>>() { |
| | |
| | | plainData = content; |
| | | } |
| | | |
| | | Map<String, String> openapiResult1 = JSON.parseObject(plainData, |
| | | new TypeReference<Map<String, String>>() { |
| | | }, Feature.OrderedField); |
| | | |
| | | R<SysUser> sysUserR = sysUserClient.queryUserByPhone(openapiResult1.get("mobile")); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | appMiniLoginVo.setPhone(openapiResult1.get("mobile")); |
| | | } |
| | | }else{ |
| | | |
| | |
| | | forepartAuctionSalesroomGoodsVO.setCoverPic(goodsSku.getCoverPic()); |
| | | forepartAuctionSalesroomGoodsVO.setStartingPrice(salesroomGoods.getStartingPrice()); |
| | | forepartAuctionSalesroomGoodsVO.setSalesroomStock(salesroomGoods.getSalesroomStock()); |
| | | forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(salesroomGoods.getStatus().getCode()); |
| | | forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(salesroomGoods.getStatus()); |
| | | forepartAuctionSalesroomGoodsVO.setYears(String.valueOf(goodsSku.getYears())); |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery(); |
| | | wrapper1.eq(AuctionBidRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId()); |
| | |
| | | forepartAuctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO); |
| | | } |
| | | memberAuctionSalesroomInfoVO.setForepartAuctionSalesroomGoodsVO(forepartAuctionSalesroomGoodsVOS); |
| | | |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime newTime7 = now.minusDays(7); |
| | | |
| | | LambdaQueryWrapper<AuctionBrowseRecord> wrapper3=Wrappers.lambdaQuery(); |
| | | wrapper3.eq(AuctionBrowseRecord::getDelFlag,0); |
| | | wrapper3.eq(AuctionBrowseRecord::getTargetId,memberAuctionSalesroomDTO.getAuctionSalesroomId()); |
| | | wrapper3.eq(AuctionBrowseRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId()); |
| | | wrapper3.ge(AuctionBrowseRecord::getCreateTime, now) |
| | | .le(AuctionBrowseRecord::getCreateTime, newTime7); |
| | | List<AuctionBrowseRecord> list = iAuctionBrowseRecordService.list(wrapper3); |
| | | if (list.size()==0){ |
| | | AuctionBrowseRecord auctionBrowseRecord=new AuctionBrowseRecord(); |
| | | auctionBrowseRecord.setBrowseType(AuctionOrderTypeEnum.AUCTION_ITEMS); |
| | | auctionBrowseRecord.setMemberId(memberAuctionSalesroomDTO.getMemberId()); |
| | | auctionBrowseRecord.setTargetId(memberAuctionSalesroomDTO.getAuctionSalesroomId()); |
| | | iAuctionBrowseRecordService.save(auctionBrowseRecord); |
| | | } |
| | | |
| | | |
| | | return memberAuctionSalesroomInfoVO; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void saveAuctionSalesroom(MgtAuctionSalesroomDTO dto) { |
| | | public void saveAuctionSalesroom(MgtAuctionSalesroomDTO dto) |
| | | throws IOException, WriterException { |
| | | Long id = dto.getId(); |
| | | AuctionSalesroom auctionSalesroom = BeanUtils.copyBean(dto, AuctionSalesroom.class); |
| | | List<MgtAuctionSalesroomGoodsDTO> auctionSalesroomGoodsDTOS = dto.getAuctionSalesroomGoodsDTOS(); |
| | |
| | | // 生成唯一编号 |
| | | Long nextId = IDhelper.getNextId(); |
| | | auctionSalesroom.setAuctionSalesroomNo(nextId.toString()); |
| | | String qrCodeToObs = CreateQrCode.createQRCodeToObs(nextId.toString()); |
| | | auctionSalesroom.setQrCode(qrCodeToObs); |
| | | // 添加 |
| | | this.save(auctionSalesroom); |
| | | List<GoodsStockUpdDTO> goodsStockUpdDTOS = auctionSalesroomGoods.stream().map(item -> { |
| | |
| | | .eq(AuctionSalesroomGoods::getAuctionSalesroomId, id)); |
| | | } |
| | | for (AuctionSalesroomGoods auctionSalesroomGood : auctionSalesroomGoods) { |
| | | auctionSalesroomGood.setAuctionSalesroomId(id); |
| | | auctionSalesroomGood.setAuctionSalesroomId(auctionSalesroom.getId()); |
| | | } |
| | | // 添加拍卖商品 |
| | | for (AuctionSalesroomGoods auctionSalesroomGoodss:auctionSalesroomGoods){ |
| | |
| | | MgtAuctionSalesroomVO.class); |
| | | List<AuctionSalesroomGoods> list; |
| | | if (isScreen) { |
| | | list = getAuctionSalesroomGoods(id, Boolean.TRUE); |
| | | list = getAuctionSalesroomGoods(id, Boolean.FALSE); |
| | | } else { |
| | | list = getAuctionSalesroomGoods(id, null); |
| | | } |
| | |
| | | mgtScreenBidPage.getId(), Boolean.TRUE); |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = mgtAuctionSalesroomVO.getAuctionSalesroomGoodsVOS(); |
| | | if (StringUtils.isEmpty(auctionSalesroomGoodsVOS)) { |
| | | throw new ServiceException("该拍卖会暂无拍卖商品"); |
| | | return PageDTO.empty(0L, 0L); |
| | | } |
| | | AtomicReference<Long> currentAuctionGoodsId = new AtomicReference<>(); |
| | | auctionSalesroomGoodsVOS.stream() |
| | |
| | | iAuctionVideoService.save(auctionVideo); |
| | | } |
| | | |
| | | /** |
| | | * 结束播放 |
| | | * |
| | | * @param auctionSalesroomId 拍卖场id |
| | | */ |
| | | @Override |
| | | public void stopPlay(Long auctionSalesroomId) { |
| | | iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq |
| | | (AuctionVideo::getAuctionSalesroomId, 1L)); |
| | | } |
| | | |
| | | /** |
| | | * 开始当前拍卖场 |
| | | * |
| | | * @param auctionSalesroomId 拍卖场id |
| | | */ |
| | | @Override |
| | | public void startCurrentAuctionSalesroom(Long auctionSalesroomId) { |
| | | // 修改拍卖场开始状态 |
| | | AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); |
| | | auctionSalesroom.setStatus(AuctionStartStatusEnum.IN_AUCTION); |
| | | auctionSalesroom.setStartTime(LocalDateTime.now()); |
| | | auctionSalesroomMapper.updateById(auctionSalesroom); |
| | | // 修改拍卖商品开始状态 |
| | | LambdaQueryWrapper<AuctionSalesroomGoods> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionSalesroomGoods::getStatus, AuctionGoodsStatusEnum.WAITING); |
| | | wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomId); |
| | | wrapper.orderByDesc(AuctionSalesroomGoods::getSortNum); |
| | | wrapper.last("limit 1"); |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectOne( |
| | | wrapper); |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); |
| | | auctionSalesroomGoods.setStartTime(LocalDateTime.now()); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | } |
| | | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | @Transactional |
| | | public void stopCurrentAuctionSalesroom(Long auctionSalesroomId) { |
| | | // 修改拍卖场开始状态 |
| | | AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); |
| | | auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); |
| | | auctionSalesroom.setEndTime(LocalDateTime.now()); |
| | | auctionSalesroomMapper.updateById(auctionSalesroom); |
| | | LambdaQueryWrapper<AuctionSalesroomGoods> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionSalesroomGoods::getStatus, AuctionGoodsStatusEnum.WAITING); |
| | | wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomId); |
| | | wrapper.orderByDesc(AuctionSalesroomGoods::getSortNum); |
| | | List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList( |
| | | wrapper); |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoods)) { |
| | | List<GoodsStockUpdDTO> dtoList = new ArrayList<>(); |
| | | for (AuctionSalesroomGoods salesroomGoods : auctionSalesroomGoods) { |
| | | salesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(salesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock(salesroomGoods.getSalesroomStock()); |
| | | dtoList.add(goodsStockUpdDTO); |
| | | } |
| | | // 批量更新商品库存 |
| | | auctionSalesroomGoodsMapper.updateBatchById(auctionSalesroomGoods); |
| | | goodsSkuClient.updGoodsStock(dtoList, SecurityConstants.INNER); |
| | | } |
| | | // 退保证金 |
| | | List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList( |
| | | Wrappers.<AuctionBidRecord>lambdaQuery() |
| | | .eq(AuctionBidRecord::getAuctionSalesroomId, auctionSalesroomId) |
| | | .eq(AuctionBidRecord::getStatus, BidStatusEnum.ELIMINATE)); |
| | | List<Long> memberIdlist = auctionBidRecordList.stream().map(AuctionBidRecord::getMemberId) |
| | | .collect(Collectors.toList()); |
| | | if (StringUtils.isNotEmpty(memberIdlist)) { |
| | | OrderAuctionBondDTO orderAuctionBondDTO = new OrderAuctionBondDTO(); |
| | | orderAuctionBondDTO.setAuctionSalesroomId(auctionSalesroom.getId()); |
| | | orderAuctionBondDTO.setUserList(memberIdlist); |
| | | orderClient.getOrderAuctionBond(orderAuctionBondDTO, SecurityConstants.INNER); |
| | | } |
| | | } |
| | | } |