| | |
| | | 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.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | 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.dto.MgtAuctionSalesroomGoodsQuery; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionSalesroomQuery; |
| | | import com.ruoyi.auction.controller.management.dto.MgtScreenBidPage; |
| | | import com.ruoyi.auction.controller.management.dto.MgtScreenSalesroomGoodsDTO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtScreenVideoDTO; |
| | | import com.ruoyi.auction.controller.management.vo.MgtAuctionBidRecordVO; |
| | | import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomGoodsVO; |
| | | 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.auction.mapper.AuctionSalesroomGoodsMapper; |
| | | import com.ruoyi.auction.mapper.AuctionSalesroomMapper; |
| | | import com.ruoyi.auction.service.IAuctionBidRecordService; |
| | | import com.ruoyi.auction.service.IAuctionBrowseRecordService; |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.auction.service.IAuctionSalesroomGoodsService; |
| | | 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.Constants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.AuctionGoodsStatusEnum; |
| | | import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; |
| | | import com.ruoyi.common.core.enums.AuctionStartStatusEnum; |
| | | import com.ruoyi.common.core.enums.BidStatusEnum; |
| | | import com.ruoyi.common.core.enums.BondStatusEnum; |
| | | import com.ruoyi.common.core.enums.ClientTypeEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.IDhelper; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | 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.system.api.RemoteFileService; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | 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.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.domain.OrderAuctionBond; |
| | | import com.ruoyi.system.api.domain.PromotionVideo; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.domain.WebsocketMessageDTO; |
| | | import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO; |
| | | import com.ruoyi.system.api.domain.dto.BidVO; |
| | | 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.MemberClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | 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; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class AuctionSalesroomServiceImpl extends ServiceImpl<AuctionSalesroomMapper, AuctionSalesroom> implements IAuctionSalesroomService { |
| | | @Resource |
| | | private IAuctionSalesroomService iAuctionSalesroomService; |
| | | |
| | | @Resource |
| | | private IAuctionBidRecordService auctionBidRecordService; |
| | |
| | | private AuctionSalesroomGoodsMapper auctionSalesroomGoodsMapper; |
| | | |
| | | @Resource |
| | | private IAuctionSalesroomGoodsService auctionSalesroomGoodsService; |
| | | |
| | | @Resource |
| | | private IAuctionGoodsService auctionGoodsService; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | @Resource |
| | | private MemberClient memberClient; |
| | | |
| | | @Resource |
| | | private IAuctionBrowseRecordService iAuctionBrowseRecordService; |
| | | |
| | | @Resource |
| | | private PromotionClient promotionClient; |
| | | |
| | | |
| | | @Resource |
| | | private AuctionBidRecordMapper auctionBidRecordMapper; |
| | | |
| | | @Resource |
| | | private RemoteFileService remoteFileService; |
| | | public static RequestConfig config = RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).build(); |
| | | // 配置您申请的KEY,在个人中心->我的数据,接口名称上方查看 |
| | | public static final String APPKEY = ""; |
| | | //明文查询地址 |
| | | public static String query_url = "http://op.juhe.cn/idcard/query?key=" + APPKEY; |
| | | |
| | | |
| | | //微信 |
| | | 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_APPID = "wxe91f1af7638aa5dd"; |
| | | |
| | | private static final String WX_SECRET = "852a2512a6ab559cafc68bae5d4160ac"; |
| | | |
| | | private static final String WX_SECRET = "a787e1a462715604e0c9528b6d8960d1"; |
| | | |
| | | //支付寶 |
| | | /** |
| | |
| | | /** |
| | | * appID |
| | | **/ |
| | | private static final String APP_ID_PROD = "2021003196653501"; |
| | | private static final String APP_ID_PROD = "2021004150664294"; |
| | | /** |
| | | * 私钥 |
| | | */ |
| | | private static final String APP_PRIVATE_KEY = ""; |
| | | private static final String APP_PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC3ap1qQ5GTe+syB8Tu/fH8nRdpjA7yNgLINR/kFq1VFzxDref7DQDUDWXt+s5QZyBjL1UfbQWtA96F+OpgmIiNMdZSn9FH/w5XSqSd7B4nAa1sgfdLdZDvm+crqzn8OzyEJTrO8tihF+9K+btBl37s3QfmmzCRl1PAAMGqfy/JcQ2aivY+hxb25V0kD5AAXM7mVC2zzcBrykzafQCXEnDC7ls4Hjy0agmq1bKSx8SLYTsXAzZiGk9E7yh76nDAB+P1+kKPEYJXociU3k4YRR7l+6tzBPd+/mVkL34nuV5IiAK/795CrP/9gC50nZK/6CqSPDlQlOaAaJ2uZvAOeKx3AgMBAAECggEAMzw5+swjJ0KvYYtgDK6tYTZ0qswwBKLnxgto/CsFgkZ6VCGJMszgFVwkxASSi00zc+Ft8thehIUXLO9qcU9Knb51MyFnsafi1qmIMIEbryO90RjA/rg5o2U2fzFWgkn9zqAjvFmEAAQSmSwHjfwGvZ3Erjtdpt3RzEmpz7m1nJxYuZ2JLdo8AIY+iYn1NeDxHMi27RtqsZje7RV5YXrqKtMMzW2atmj+Dbn/E1pxpF0Dz6l0TqQh5B+9j1XlPTZKcYOYHNI0ACV+dV1NZsqmdhX0lKtQbsj/Q67vhq7uCmQRKcEka/5Z0X/TOKbwJE6i2/YEuA4PUGLpBMZQXhSGYQKBgQD50IuUTG6fg1dqFt9bJXxq2i1lkIHvzaCkHqVnTMyTDs+VcO2S6YaAFy6BLSI933qvHLogkhqnHiN+BRHe/M5+4TAOx30SQlJYa5ojpNFwMnRSZgxLoEddwlfj6qTnCgDW3CsUPR85x85NjIhONy75muNnNG8GHdn3blk2Y7KhpwKBgQC79TQhz5eJ6cwiWPWMWnnSAVvFKW4iPZjkbk+Sl7JXuqzvsdE47gGN0Vk8iYWEc2WrnQY6vf7WnamQYi+Gr5ySfTSt9qwvRx0IRzHdSZkOsHJLBCnAt+Pf+pSBc2Z788iUXVbDRAIfF6YYG44P3jHspbnGPJt14PP0sHbPmh7YsQKBgGzGGYChJyndjpprCyYs1FfSWCH5IhrAdkn/7hVko08FC+4OFeP6Os5bSayFcntua4UEBSdZdrF9tgaRPo7RlTg55SsKQbNJnYFSmPMcOPWZgny+YmwrheeVT5+188eF24eypi9Rzd7i2Tl7D36/GH0mrA2sDwuiw92w9rdwAb/RAoGAf6RDZPqvNI87e8/h4RDITd9yTPCXxFUEcYygKTMvf/hb3ONq7DhlgcO70CqsK4iacPLP+jBw0Zp8PnsPP24e7DRvA/zSbcDjbG285URH1vvogh0vpZq7+60WENsnq+GgQ3EnrK+QqUDMIO8FiK0iRk09XexmvqSnx3HXHaDSdeECgYB9htO5mOn2/ugIeMw11g+JJkZ/hzE55/6fLf7zh3yel5EflmAdYRv0lHafjyXIzNrAnBgD95x4LKGLi9A5AMo9SJJu0ZOg1KujKPVY4ByCm9SO7ErJDuHI4AhtewdHhYDpnXMakoxm/medSjlt7GCVv7E/eDpNZs+MLi9MiTFx2g=="; |
| | | /** |
| | | * 支付宝公钥 |
| | | */ |
| | | private static final String ALIPAY_PUBLIC_KEY = ""; |
| | | private static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlW2RMACojdqTa8H+j6411Lm5UipGXXbQiswq50rUflwjTj843zNVaVpk8uJmbdmtUBJlmblgBS/a31O4L4LrHB8WxJ+w0f9DBNTq9T6b80MiAVnU/3gXK365DmbzPWS5pR9wEgJVHnfOFUbsB5AVFHV0m9hUZcPv7xveuEp3BEoD5smaDJByR+KgFw0Q0JgINhhE6bsEa3UgJ198af269LtQ5HJl1TWLI8aeqW14HrxyADIt49NB9KZ8MOdKP+66HWcrXlipKFHtccy3dff72DqPmFdESoXfLXKZyhU5w9v4Q5F6UoAGTPwl9KQwikTobNeJ/7su7X3AB6+C14J4sQIDAQAB"; |
| | | |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | |
| | | @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.like(AuctionSalesroom::getSalesroomName,ationSalesroomGoodsDTO.getSalesroomName()); |
| | | wrapper.eq(AuctionSalesroom::getDelFlag,0); |
| | | Page<AuctionSalesroom> page1=iAuctionSalesroomService.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); |
| | | AuctionVideo auctionVideo=iAuctionVideoService.getOne(wrapper); |
| | | ForepartAuctionSalesroomVO forepartAuctionSalesroomVO =new ForepartAuctionSalesroomVO(); |
| | | AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(ationSalesroomGoodsDTO.getAuctionSalesroomId()); |
| | | AuctionSalesroom auctionSalesroom = this.getById( |
| | | ationSalesroomGoodsDTO.getAuctionSalesroomId()); |
| | | forepartAuctionSalesroomVO.setAuctionSalesroomStatus(auctionSalesroom.getStatus().getCode()); |
| | | if (auctionVideo!=null){ |
| | | forepartAuctionSalesroomVO.setUrl(auctionVideo.getPromotionVideoUrl()); |
| | |
| | | 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 (!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); |
| | | AuctionSalesroom auctionBidRecord = this.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 (appMiniLoginDto.getType()==1) { |
| | | if (appMiniLoginDto.getAuth_code() == null || appMiniLoginDto.getAuth_code().length() == 0) { |
| | | } else {*/ |
| | | /* //1. 获取验签和解密所需要的参数 |
| | | Map<String, String> openapiResult = JSON.parseObject(appMiniLoginDto.getAuth_code(), |
| | | new TypeReference<Map<String, String>>() { |
| | | }, Feature.OrderedField); |
| | | String signType = "RSA2"; |
| | | String charset = "UTF-8"; |
| | | String encryptType = "AES"; |
| | | String sign = openapiResult.get("sign"); |
| | | String content = openapiResult.get("response"); |
| | | |
| | | //返回成功时 就将唯一标识返回 |
| | | 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); |
| | | //如果密文的 |
| | | boolean isDataEncrypted = !content.startsWith("{"); |
| | | boolean signCheckPass = false; |
| | | |
| | | //2. 验签 |
| | | String signContent = content; |
| | | |
| | | //如果是加密的报文则需要在密文的前后添加双引号 |
| | | if (isDataEncrypted) { |
| | | signContent = "\"" + signContent + "\""; |
| | | } |
| | | try { |
| | | signCheckPass = AlipaySignature.rsaCheck(signContent, sign, ALIPAY_PUBLIC_KEY, charset, signType); |
| | | } catch (AlipayApiException e) { |
| | | //验签异常, 日志 |
| | | } |
| | | if (!signCheckPass) { |
| | | //验签不通过(异常或者报文被篡改),终止流程(不需要做解密) |
| | | } |
| | | |
| | | //3. 解密 |
| | | String plainData = null; |
| | | if (isDataEncrypted) { |
| | | try { |
| | | plainData = AlipayEncrypt.decryptContent(content, encryptType, "XABBSOeWDakvuG9TDez4Qg==", charset); |
| | | } catch (AlipayApiException e) { |
| | | //解密异常, 记录日志 |
| | | e.getMessage(); |
| | | } |
| | | } else { |
| | | plainData = content; |
| | | } |
| | | |
| | | Map<String, String> openapiResult1 = JSON.parseObject(plainData, |
| | | new TypeReference<Map<String, String>>() { |
| | | }, Feature.OrderedField); |
| | | */ |
| | | /* R<SysUser> sysUserR = sysUserClient.queryUserByPhone(appMiniLoginDto.getAuth_code()); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | appMiniLoginVo.setPhone(appMiniLoginDto.getAuth_code()); |
| | | } |
| | | }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 = null; |
| | | try { |
| | | responseAccessToken = getAccessTokenByWX(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | String responseAccessToken = getAccessTokenByWX(); |
| | | |
| | | JSONObject jsonAccessToken = JSONObject.parseObject(responseAccessToken); |
| | | 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 responseUserPhoneNumber = null; |
| | | try { |
| | | responseUserPhoneNumber = getMobileByWX(accessToken, appMiniLoginDto.getCode()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | 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); |
| | | //获取用户*/ |
| | | /* R<SysUser> sysUserR = sysUserClient.queryUserByPhone(appMiniLoginDto.getCode()); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | appMiniLoginVo.setPhone(appMiniLoginDto.getCode()); |
| | | }*/ |
| | | |
| | | appMiniLoginVo.setMiniOpenid(openid); |
| | | appMiniLoginVo.setWxUnionid(unionid); |
| | | appMiniLoginVo.setPhone(mobile); |
| | | appMiniLoginVo.setSessionKey(sessionKey); |
| | | } |
| | | } |
| | | R<SysUser> sysUserR = sysUserClient.queryUserByPhone(appMiniLoginDto.getPhone()); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | appMiniLoginVo.setPhone(appMiniLoginDto.getPhone()); |
| | | 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 AppMiniLoginVO isMiniLogin(AppMiniLoginDTO appMiniLoginDto) { |
| | | AppMiniLoginVO appMiniLoginVo = new AppMiniLoginVO(); |
| | | R<SysUser> sysUserR = sysUserClient.queryUserByPhone(appMiniLoginDto.getPhone()); |
| | | SysUser data = sysUserR.getData(); |
| | | appMiniLoginVo.setSysUser(data); |
| | | appMiniLoginVo.setPhone(appMiniLoginDto.getCode()); |
| | | return appMiniLoginVo; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageDTO<MemberAuctionSalesroomVO> getMemberAuctionSalesroomList(MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) { |
| | |
| | | memberAuctionSalesroomVO.setDescription(auctionSalesroom.getDescription()); |
| | | memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus().getCode()); |
| | | memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId()); |
| | | memberAuctionSalesroomVO.setStartTime(auctionSalesroom.getStartTime()); |
| | | memberAuctionSalesroomVO.setEndTime(auctionSalesroom.getEndTime()); |
| | | memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic()); |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | if (data.size()>0){ |
| | | memberAuctionSalesroomVO.setBond(auctionSalesroom.getBond()); |
| | | memberAuctionSalesroomVO.setAuthentication(auctionSalesroom.getAuthentication()); |
| | | memberAuctionSalesroomDTO.setAuctionSalesroomId(auctionSalesroom.getId()); |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | if (data!=null&&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); |
| | | List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData(); |
| | | if(data1!=null){ |
| | | memberAuctionSalesroomVO.setApplyNum(data1.size()); |
| | | List.add(memberAuctionSalesroomVO); |
| | | }else{ |
| | | memberAuctionSalesroomVO.setApplyNum(0); |
| | | } |
| | | |
| | | |
| | | } |
| | | page.setRecords(List); |
| | | return PageDTO.of(page); |
| | |
| | | |
| | | @Override |
| | | public MemberAuctionSalesroomInfoVO getMemberAuctionSalesroomInfo(MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) { |
| | | AuctionSalesroom byId = iAuctionSalesroomService.getById(memberAuctionSalesroomDTO.getAuctionSalesroomId()); |
| | | AuctionSalesroom byId = this.getById(memberAuctionSalesroomDTO.getAuctionSalesroomId()); |
| | | MemberAuctionSalesroomInfoVO memberAuctionSalesroomInfoVO=new MemberAuctionSalesroomInfoVO(); |
| | | memberAuctionSalesroomInfoVO.setId(byId.getId()); |
| | | memberAuctionSalesroomInfoVO.setBound(byId.getBond()); |
| | |
| | | memberAuctionSalesroomInfoVO.setStartTime(byId.getStartTime()); |
| | | memberAuctionSalesroomInfoVO.setStatus(byId.getStatus()); |
| | | memberAuctionSalesroomInfoVO.setCoverPic(byId.getCoverPic()); |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | if (data.size()>0){ |
| | | memberAuctionSalesroomInfoVO.setIsApply(2); |
| | | }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()); |
| | | wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,byId.getId()); |
| | |
| | | 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::getBrowseType,AuctionOrderTypeEnum.AUCTION_ITEMS); |
| | | 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; |
| | | } |
| | | |
| | |
| | | LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,MemberAuctionSalesroomDTO.getSalesroomNO()); |
| | | wrapper.eq(AuctionSalesroom::getDelFlag,0); |
| | | AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getOne(wrapper); |
| | | AuctionSalesroom auctionSalesroom = this.getOne(wrapper); |
| | | MemberAuctionSalesroomVO memberAuctionSalesroomVO=new MemberAuctionSalesroomVO(); |
| | | memberAuctionSalesroomVO.setSalesroomName(auctionSalesroom.getSalesroomName()); |
| | | memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus().getCode()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void SaveBid(BidVO bidVO) { |
| | | public void CancelSignUpNow(MemberAuctionSalesroomBondDTO memberAuctionSalesroomBondDTO) { |
| | | if (memberAuctionSalesroomBondDTO.getBondType()==2){ |
| | | OrderAuctionBond orderAuctionBond = orderClient.getOrderAuctionBondone(memberAuctionSalesroomBondDTO, SecurityConstants.INNER).getData(); |
| | | |
| | | List<RefundDTO> refundDTOList = new ArrayList<>(); |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); |
| | | refundDTO.setAmount(orderAuctionBond.getBond()); |
| | | |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionBidRecord::getAuctionSalesroomId,memberAuctionSalesroomBondDTO.getAuctionSalesroomId()); |
| | | wrapper.eq(AuctionBidRecord::getAuctionType,2); |
| | | wrapper.eq(AuctionBidRecord::getStatus,BidStatusEnum.SUCCESSFUL); |
| | | wrapper.eq(AuctionBidRecord::getDelFlag, 0); |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordMapper.selectOne(wrapper); |
| | | if (auctionBidRecord!=null){ |
| | | throw new ServiceException("当前拍卖场中标拍品订单未完成,请完成后再试。"); |
| | | } |
| | | // 远程调用订单服务进行退款 |
| | | Map<String, Object> data = orderClient.refund(refundDTOList, |
| | | SecurityConstants.INNER).getData(); |
| | | // 处理退款返回结果 |
| | | List<String> successfulOrders = new ArrayList<>(); |
| | | List<String> failedOrders = new ArrayList<>(); |
| | | |
| | | data.forEach((key, value) -> { |
| | | if ((boolean) value) { |
| | | successfulOrders.add(key); |
| | | } else { |
| | | failedOrders.add(key); |
| | | } |
| | | }); |
| | | // 退款成功的订单修改状态 |
| | | List<Long> ids = new ArrayList<>(); |
| | | ids.add(orderAuctionBond.getId()); |
| | | // 远程调用订单服务修改订单状态 |
| | | orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.REFUNDED,SecurityConstants.INNER); |
| | | |
| | | }else{ |
| | | OrderAuctionBond orderAuctionBond = orderClient.getOrderAuctionBondone1(memberAuctionSalesroomBondDTO, SecurityConstants.INNER).getData(); |
| | | List<RefundDTO> refundDTOList = new ArrayList<>(); |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); |
| | | refundDTO.setAmount(orderAuctionBond.getBond()); |
| | | |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(AuctionBidRecord::getTargetId, memberAuctionSalesroomBondDTO.getAuctionGoodsId()); |
| | | wrapper.eq(AuctionBidRecord::getAuctionType,1); |
| | | wrapper.eq(AuctionBidRecord::getStatus,BidStatusEnum.SUCCESSFUL); |
| | | wrapper.eq(AuctionBidRecord::getDelFlag, 0); |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordMapper.selectOne(wrapper); |
| | | if (auctionBidRecord!=null){ |
| | | throw new ServiceException("当前拍卖场中标拍品订单未完成,请完成后再试。"); |
| | | } |
| | | |
| | | // 远程调用订单服务进行退款 |
| | | Map<String, Object> data = orderClient.refund(refundDTOList, |
| | | SecurityConstants.INNER).getData(); |
| | | // 处理退款返回结果 |
| | | List<String> successfulOrders = new ArrayList<>(); |
| | | List<String> failedOrders = new ArrayList<>(); |
| | | |
| | | data.forEach((key, value) -> { |
| | | if ((boolean) value) { |
| | | successfulOrders.add(key); |
| | | } else { |
| | | failedOrders.add(key); |
| | | } |
| | | }); |
| | | // 退款成功的订单修改状态 |
| | | List<Long> ids = new ArrayList<>(); |
| | | ids.add(orderAuctionBond.getId()); |
| | | // 远程调用订单服务修改订单状态 |
| | | orderClient.updateOrderAuctionBondStatus(ids,BondStatusEnum.REFUNDED,SecurityConstants.INNER); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void SaveBid(BidDTO bidVO) { |
| | | Member membeOne = memberClient.getMembeOne(bidVO.getMemberId(), SecurityConstants.INNER).getData(); |
| | | if (bidVO.getAuctionType()==2){ |
| | | AuctionSalesroomGoods byId = auctionSalesroomGoodsService.getById(bidVO.getTargetId()); |
| | | if (byId.getStartingPrice().doubleValue()<bidVO.getLastBidAmount().doubleValue()){ |
| | | AuctionSalesroomGoods byId = auctionSalesroomGoodsMapper.selectById(bidVO.getTargetId()); |
| | | if (byId.getStartingPrice().doubleValue()>bidVO.getLastBidAmount().doubleValue()){ |
| | | throw new ServiceException("出价不能比起拍价低"); |
| | | } |
| | | BigDecimal bigDecimal=byId.getStartingPrice().add(byId.getMinimumMarkupAmount()); |
| | | if (bigDecimal.doubleValue()<bidVO.getLastBidAmount().doubleValue()){ |
| | | if (bigDecimal.doubleValue()>bidVO.getLastBidAmount().doubleValue()){ |
| | | throw new ServiceException("出价不能比每次最少加价低"); |
| | | } |
| | | |
| | |
| | | AuctionBidRecord one = auctionBidRecordService.getOne(wrapper1); |
| | | if (one!=null){ |
| | | BigDecimal bigDecimal1=one.getLastBidAmount().add(byId.getMinimumMarkupAmount()); |
| | | if (bigDecimal1.doubleValue()<bidVO.getLastBidAmount().doubleValue()){ |
| | | if (bigDecimal1.doubleValue()>bidVO.getLastBidAmount().doubleValue()){ |
| | | throw new ServiceException("出价不能比上次出价加每次最少加价低"); |
| | | } |
| | | one.setLastBidAmount(bidVO.getLastBidAmount()); |
| | |
| | | one.setTargetId(bidVO.getTargetId()); |
| | | one.setMemberId(bidVO.getMemberId()); |
| | | one.setLastBidTime(LocalDateTime.now()); |
| | | one.setNickname(membeOne.getNickname()); |
| | | one.setPhone(membeOne.getPhone()); |
| | | one.setAuctionType(AuctionOrderTypeEnum.AUCTION_ITEMS); |
| | | one.setStatus(BidStatusEnum.ELIMINATE); |
| | | one.setBidCount(1); |
| | |
| | | } |
| | | |
| | | |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper2=Wrappers.lambdaQuery(); |
| | | wrapper2.eq(AuctionBidRecord::getAuctionSalesroomId,bidVO.getAuctionSalesroomId()); |
| | | wrapper2.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId()); |
| | | wrapper2.eq(AuctionBidRecord::getDelFlag,0); |
| | | wrapper2.orderByDesc(AuctionBidRecord::getLastBidAmount); |
| | | AuctionBidRecord one2 = auctionBidRecordService.getOne(wrapper1); |
| | | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId()); |
| | | map.put("byId", byId.getStatus()); |
| | | map.put("lastBidAmount",one2.getLastBidAmount()); |
| | | map.put("message_type", "BidRecor"); |
| | | map.put("type",3); |
| | | String msg = null; |
| | | try { |
| | | msg = objectMapper.writeValueAsString(map); |
| | | } catch (JsonProcessingException e) { |
| | | } |
| | | String finalMsg = msg; |
| | | sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg) |
| | | .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); |
| | | |
| | | |
| | | |
| | | |
| | | }else { |
| | | AuctionGoods byId = auctionGoodsService.getById(bidVO.getTargetId()); |
| | | if (byId.getStartingPrice().doubleValue()<bidVO.getLastBidAmount().doubleValue()){ |
| | | if (byId.getStartingPrice().doubleValue()>bidVO.getLastBidAmount().doubleValue()){ |
| | | throw new ServiceException("出价不能比起拍价低"); |
| | | } |
| | | BigDecimal bigDecimal=byId.getStartingPrice().add(byId.getMinimumMarkupAmount()); |
| | | if (bigDecimal.doubleValue()<bidVO.getLastBidAmount().doubleValue()){ |
| | | if (bigDecimal.doubleValue()>bidVO.getLastBidAmount().doubleValue()){ |
| | | throw new ServiceException("出价不能比每次最少加价低"); |
| | | } |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery(); |
| | |
| | | one.setLastBidTime(LocalDateTime.now()); |
| | | one.setBidCount(one.getBidCount()+1); |
| | | auctionBidRecordService.updateById(one); |
| | | |
| | | |
| | | }else{ |
| | | one=new AuctionBidRecord(); |
| | | one.setAuctionSalesroomId(bidVO.getAuctionSalesroomId()); |
| | |
| | | one.setLastBidAmount(bidVO.getLastBidAmount()); |
| | | auctionBidRecordService.save(one); |
| | | } |
| | | |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper2=Wrappers.lambdaQuery(); |
| | | wrapper2.eq(AuctionBidRecord::getAuctionSalesroomId,bidVO.getAuctionSalesroomId()); |
| | | wrapper2.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId()); |
| | | wrapper2.eq(AuctionBidRecord::getDelFlag,0); |
| | | wrapper2.orderByDesc(AuctionBidRecord::getLastBidAmount); |
| | | AuctionBidRecord one2 = auctionBidRecordService.getOne(wrapper1); |
| | | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId()); |
| | | map.put("byId", byId.getStartStatus()); |
| | | map.put("lastBidAmount",one2.getLastBidAmount()); |
| | | map.put("message_type", "BidRecor"); |
| | | map.put("type",4); |
| | | String msg = null; |
| | | try { |
| | | msg = objectMapper.writeValueAsString(map); |
| | | } catch (JsonProcessingException e) { |
| | | } |
| | | String finalMsg = msg; |
| | | sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg) |
| | | .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | query.getEndTime()), AuctionSalesroom::getStartTime, |
| | | query.getStartTime(), |
| | | query.getEndTime()) |
| | | .orderByDesc(AuctionSalesroom::getCreateTime) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | |
| | | List<AuctionSalesroom> records = page.getRecords(); |
| | | if (StringUtils.isNull(records)) { |
| | | return PageDTO.empty(page); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveAuctionSalesroom(MgtAuctionSalesroomDTO dto) { |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | 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 url = remoteFileService.obsUpload( |
| | | CreateQrCode.createQRCodeStream(nextId.toString())).getData(); |
| | | auctionSalesroom.setQrCode(url); |
| | | // 添加 |
| | | this.save(auctionSalesroom); |
| | | List<GoodsStockUpdDTO> goodsStockUpdDTOS = auctionSalesroomGoods.stream().map(item -> { |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(item.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock(item.getSalesroomStock() * -1); |
| | | return goodsStockUpdDTO; |
| | | }).collect(Collectors.toList()); |
| | | goodsSkuClient.updGoodsStock(goodsStockUpdDTOS, SecurityConstants.INNER); |
| | | } else { |
| | | // 编辑 |
| | | AuctionSalesroom auctionSalesroomOrg = this.getById(id); |
| | |
| | | } |
| | | auctionSalesroom.setId(auctionSalesroomOrg.getId()); |
| | | this.updateById(auctionSalesroom); |
| | | List<AuctionSalesroomGoods> list = auctionSalesroomGoodsMapper.selectList( |
| | | Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .eq(AuctionSalesroomGoods::getAuctionSalesroomId, id)); |
| | | // 封装库存修改实体 |
| | | List<GoodsStockUpdDTO> goodsStockUpdDTOS = list.stream() |
| | | .flatMap(salesroomGoods -> auctionSalesroomGoods.stream() |
| | | .filter(auctionSalesroomGood -> salesroomGoods.getId() |
| | | .equals(auctionSalesroomGood.getId())) |
| | | .map(auctionSalesroomGood -> { |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(salesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock(salesroomGoods.getSalesroomStock() |
| | | - auctionSalesroomGood.getSalesroomStock()); |
| | | return goodsStockUpdDTO; |
| | | })) |
| | | .collect(Collectors.toList()); |
| | | goodsSkuClient.updGoodsStock(goodsStockUpdDTOS, SecurityConstants.INNER); |
| | | // 移除原来地拍卖商品 |
| | | auctionSalesroomGoodsService.remove(Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | auctionSalesroomGoodsMapper.delete(Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .eq(AuctionSalesroomGoods::getAuctionSalesroomId, id)); |
| | | } |
| | | for (AuctionSalesroomGoods auctionSalesroomGood : auctionSalesroomGoods) { |
| | | auctionSalesroomGood.setAuctionSalesroomId(id); |
| | | auctionSalesroomGood.setAuctionSalesroomId(auctionSalesroom.getId()); |
| | | } |
| | | // 添加拍卖商品 |
| | | auctionSalesroomGoodsService.saveBatch(auctionSalesroomGoods); |
| | | for (AuctionSalesroomGoods auctionSalesroomGoodss:auctionSalesroomGoods){ |
| | | auctionSalesroomGoodsMapper.insert(auctionSalesroomGoodss); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<WdMemberAuctionSalesroomVO> getWdAuctionSalesroomList(MemberAuctionSalesroomDTO MemberAuctionSalesroomDTO) { |
| | | MemberAuctionSalesroomDTO memberAuctionSalesroomDTO =new MemberAuctionSalesroomDTO(); |
| | | memberAuctionSalesroomDTO.setMemberId(MemberAuctionSalesroomDTO.getMemberId()); |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | Set<Long> goodsSkuIdList = null; |
| | | goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId) |
| | | .collect(Collectors.toSet()); |
| | | Page<WdMemberAuctionSalesroomVO> page = new Page<>(); |
| | | page.setSize(memberAuctionSalesroomDTO.getPageSize()); |
| | | page.setCurrent(memberAuctionSalesroomDTO.getPageCurr()); |
| | | MemberAuctionSalesroomWdDTO memberAuctionSalesroomWdDTO=new MemberAuctionSalesroomWdDTO(); |
| | | if (goodsSkuIdList.size()>0){ |
| | | memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList); |
| | | }else{ |
| | | Set<Long> goodsSkuIdList1 = new HashSet<>(); |
| | | goodsSkuIdList1.add(0L); |
| | | memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList1); |
| | | } |
| | | |
| | | if(MemberAuctionSalesroomDTO.getStatus()!=4){ |
| | | if (MemberAuctionSalesroomDTO.getStatus()==0){ |
| | | memberAuctionSalesroomWdDTO.setStatus(5); |
| | | }else{ |
| | | memberAuctionSalesroomWdDTO.setStatus(MemberAuctionSalesroomDTO.getStatus()); |
| | | } |
| | | |
| | | } |
| | | List<AuctionSalesroom> auctionSalesroomList=auctionSalesroomMapper.pageMemberAuctionSalesroomWdList(page,memberAuctionSalesroomWdDTO); |
| | | List<WdMemberAuctionSalesroomVO> List=new ArrayList<>(); |
| | | for (AuctionSalesroom auctionSalesroom:auctionSalesroomList){ |
| | | WdMemberAuctionSalesroomVO memberAuctionSalesroomVO=new WdMemberAuctionSalesroomVO(); |
| | | memberAuctionSalesroomVO.setSalesroomName(auctionSalesroom.getSalesroomName()); |
| | | memberAuctionSalesroomVO.setDescription(auctionSalesroom.getDescription()); |
| | | memberAuctionSalesroomVO.setStatus(auctionSalesroom.getStatus().getCode()); |
| | | memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId()); |
| | | memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic()); |
| | | MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1=new MemberAuctionSalesroomDTO(); |
| | | memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getId()); |
| | | memberAuctionSalesroomDTO1.setMemberId(MemberAuctionSalesroomDTO.getMemberId()); |
| | | List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData(); |
| | | if (data1.size()>0){ |
| | | memberAuctionSalesroomVO.setBondTime(data1.get(0).getCreateTime()); |
| | | } |
| | | |
| | | List.add(memberAuctionSalesroomVO); |
| | | } |
| | | page.setRecords(List); |
| | | return PageDTO.of(page); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 查看详情 |
| | | * @param id 拍卖会id |
| | | * @param isScreen 是否为大屏控制台 |
| | | * @return MgtAuctionSalesroomVO |
| | | */ |
| | | @Override |
| | | public MgtAuctionSalesroomVO getAuctionSalesroom(Long id, Boolean isScreen) { |
| | | // 获取拍卖场 |
| | | AuctionSalesroom auctionSalesroom = this.getById(id); |
| | | MgtAuctionSalesroomVO mgtAuctionSalesroomVO = BeanUtils.copyBean(auctionSalesroom, |
| | | MgtAuctionSalesroomVO.class); |
| | | List<AuctionSalesroomGoods> list; |
| | | if (isScreen) { |
| | | list = getAuctionSalesroomGoods(id, Boolean.FALSE); |
| | | } else { |
| | | list = getAuctionSalesroomGoods(id, null); |
| | | } |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | List<MgtAuctionSalesroomGoodsVO> mgtAuctionSalesroomGoodsVOS = BeanUtils.copyList(list, |
| | | MgtAuctionSalesroomGoodsVO.class); |
| | | Set<Long> goodsIdList = mgtAuctionSalesroomGoodsVOS.stream() |
| | | .map(MgtAuctionSalesroomGoodsVO::getGoodsSkuId).collect( |
| | | Collectors.toSet()); |
| | | // 获取商品信息 |
| | | List<GoodsSku> goodsSkuList = goodsSkuClient.getGoodsListByIds(goodsIdList, |
| | | SecurityConstants.INNER).getData(); |
| | | Map<Long, GoodsSku> goodsSkuMap = goodsSkuList.stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | |
| | | // 封装商品名称 |
| | | for (MgtAuctionSalesroomGoodsVO vo : mgtAuctionSalesroomGoodsVOS) { |
| | | GoodsSku goodsSku = goodsSkuMap.get(vo.getGoodsSkuId()); |
| | | if (StringUtils.isNotNull(goodsSku)) { |
| | | vo.setGoodsSkuName(goodsSku.getSkuName()); |
| | | vo.setSpec(goodsSku.getSpec()); |
| | | } |
| | | } |
| | | mgtAuctionSalesroomVO.setAuctionSalesroomGoodsVOS(mgtAuctionSalesroomGoodsVOS); |
| | | } |
| | | return mgtAuctionSalesroomVO; |
| | | } |
| | | |
| | | private List<AuctionSalesroomGoods> getAuctionSalesroomGoods(Long id, Boolean isBackup) { |
| | | // 获取拍卖场商品 |
| | | LambdaQueryWrapper<AuctionSalesroomGoods> wrappers = new LambdaQueryWrapper<AuctionSalesroomGoods>(); |
| | | wrappers.eq(AuctionSalesroomGoods::getAuctionSalesroomId, id); |
| | | wrappers.eq(StringUtils.isNotNull(isBackup), AuctionSalesroomGoods::getBackupStatus, |
| | | isBackup); |
| | | wrappers.orderByDesc(AuctionSalesroomGoods::getSortNum); |
| | | return auctionSalesroomGoodsMapper.selectList(wrappers); |
| | | } |
| | | |
| | | /** |
| | | * 查看详情-出价记录 |
| | | * |
| | | * @param query 拍卖场出价记录查询对象 |
| | | * @return PageDTO<MgtAuctionBidRecordVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtAuctionBidRecordVO> getAuctionSalesroomBidRecordList( |
| | | MgtAuctionSaleroomBidRecordQuery query) { |
| | | Page<AuctionBidRecord> page = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, query.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .orderByDesc(query.getSortType() == 1, AuctionBidRecord::getLastBidAmount) |
| | | .orderByDesc(query.getSortType() == 2, AuctionBidRecord::getBidCount) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | if (StringUtils.isNull(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | PageDTO<MgtAuctionBidRecordVO> mgtAuctionBidRecordVOPageDTO = PageDTO.of(page, |
| | | MgtAuctionBidRecordVO.class); |
| | | List<MgtAuctionBidRecordVO> list = mgtAuctionBidRecordVOPageDTO.getList(); |
| | | Set<Long> goodsIdList = list.stream().map(MgtAuctionBidRecordVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | Set<Long> memberIdList = list.stream().map(MgtAuctionBidRecordVO::getMemberId) |
| | | .collect(Collectors.toSet()); |
| | | List<GoodsSku> goodsSkuList = goodsSkuClient.getGoodsListByIds(goodsIdList, |
| | | SecurityConstants.INNER) |
| | | .getData(); |
| | | List<Member> memberList = memberClient.getMemberListByIds(memberIdList, |
| | | SecurityConstants.INNER) |
| | | .getData(); |
| | | Map<Long, GoodsSku> goodsSkuMap = goodsSkuList.stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | Map<Long, Member> memberMap = memberList.stream() |
| | | .collect(Collectors.toMap(Member::getId, Function.identity())); |
| | | for (MgtAuctionBidRecordVO vo : list) { |
| | | GoodsSku goodsSku = goodsSkuMap.get(vo.getGoodsSkuId()); |
| | | Member member = memberMap.get(vo.getMemberId()); |
| | | if (StringUtils.isNotNull(goodsSku)) { |
| | | vo.setGoodsSkuName(goodsSku.getSkuName()); |
| | | } |
| | | if (StringUtils.isNotNull(member)) { |
| | | vo.setMemberName(member.getNickname()); |
| | | vo.setPhone(member.getPhone()); |
| | | } |
| | | } |
| | | return mgtAuctionBidRecordVOPageDTO; |
| | | } |
| | | |
| | | /** |
| | | * 大屏操作台分页查询拍卖场 |
| | | * |
| | | * @param query 拍卖场查询对象 |
| | | * @return PageDTO<MgtAuctionSalesroomVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtAuctionSalesroomVO> getAuctionSalesroom4ScreenPage( |
| | | MgtAuctionSalesroomQuery query) { |
| | | // 分页查询 |
| | | Page<AuctionSalesroom> page = this.lambdaQuery() |
| | | .select(AuctionSalesroom::getId, AuctionSalesroom::getSalesroomName, |
| | | AuctionSalesroom::getStartTime, AuctionSalesroom::getStatus) |
| | | .like(StringUtils.isNotEmpty(query.getSalesroomName()), |
| | | AuctionSalesroom::getSalesroomName, query.getSalesroomName()) |
| | | .eq(StringUtils.isNotNull(query.getStatus()), AuctionSalesroom::getStatus, |
| | | query.getStatus()) |
| | | .ne(AuctionSalesroom::getStatus, AuctionStartStatusEnum.ENDED) |
| | | .between(StringUtils.isNotNull(query.getStartTime()) && StringUtils.isNotNull( |
| | | query.getEndTime()), AuctionSalesroom::getStartTime, query.getStartTime(), |
| | | query.getEndTime()) |
| | | .orderByAsc(AuctionSalesroom::getStartTime) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | List<AuctionSalesroom> records = page.getRecords(); |
| | | if (StringUtils.isNull(records)) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(page, MgtAuctionSalesroomVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 进入详情 |
| | | * |
| | | * @param id 拍卖会id |
| | | * @return 大屏操作台拍卖场视图对象 |
| | | */ |
| | | @Override |
| | | public MgtAuctionSalesroomScreenVO getAuctionSalesroomDetail(Long id) { |
| | | MgtAuctionSalesroomVO mgtAuctionSalesroomVO = this.getAuctionSalesroom(id, Boolean.TRUE); |
| | | MgtAuctionSalesroomScreenVO vo = BeanUtils.copyBean( |
| | | mgtAuctionSalesroomVO, MgtAuctionSalesroomScreenVO.class); |
| | | if (vo.getStatus().equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = vo.getAuctionSalesroomGoodsVOS(); |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoodsVOS)) { |
| | | List<MgtAuctionSalesroomGoodsVO> collect = auctionSalesroomGoodsVOS.stream() |
| | | .peek(goods -> { |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, goods.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | long bidCount = list.stream() |
| | | .filter(item -> BidStatusEnum.SUCCESSFUL.equals( |
| | | item.getStatus())) |
| | | .count(); |
| | | goods.setBidCount((int) bidCount); |
| | | goods.setBidQuantity((int) bidCount); |
| | | goods.setBidPersonCount(list.size()); |
| | | } |
| | | if (goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) { |
| | | vo.setCurrentAuctionSalesroomGoods(goods); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | vo.setAuctionSalesroomGoodsVOS(collect); |
| | | if (StringUtils.isNotNull(vo.getCurrentAuctionSalesroomGoods())) { |
| | | int index = collect.indexOf(vo.getCurrentAuctionSalesroomGoods()); |
| | | vo.setNextAuctionSalesroomGoods(collect.get(index + 1)); |
| | | // 分页查询当前拍品出价信息 |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, |
| | | vo.getCurrentAuctionSalesroomGoods().getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | vo.setMgtAuctionBidRecordVOList(CollUtils.emptyList()); |
| | | } |
| | | vo.setMgtAuctionBidRecordVOList( |
| | | BeanUtils.copyList(list, MgtAuctionBidRecordVO.class)); |
| | | } else { |
| | | vo.setNextAuctionSalesroomGoods(collect.get(0)); |
| | | } |
| | | } |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 进入详情-出价会员列表 |
| | | * |
| | | * @param mgtScreenBidPage 分页参数对象 |
| | | * @return PageDTO<MgtAuctionBidRecordVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtAuctionBidRecordVO> getScreenBidRecordList( |
| | | MgtScreenBidPage mgtScreenBidPage) { |
| | | MgtAuctionSalesroomVO mgtAuctionSalesroomVO = this.getAuctionSalesroom( |
| | | mgtScreenBidPage.getId(), Boolean.TRUE); |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = mgtAuctionSalesroomVO.getAuctionSalesroomGoodsVOS(); |
| | | if (StringUtils.isEmpty(auctionSalesroomGoodsVOS)) { |
| | | return PageDTO.empty(0L, 0L); |
| | | } |
| | | AtomicReference<Long> currentAuctionGoodsId = new AtomicReference<>(); |
| | | auctionSalesroomGoodsVOS.stream() |
| | | .filter(item -> item.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) |
| | | .findFirst().ifPresent(goods -> { |
| | | currentAuctionGoodsId.set(goods.getId()); |
| | | }); |
| | | Page<AuctionBidRecord> page = auctionBidRecordService.lambdaQuery() |
| | | .eq(StringUtils.isNotNull(currentAuctionGoodsId.get()), |
| | | AuctionBidRecord::getTargetId, |
| | | currentAuctionGoodsId.get()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .page(new Page<>(mgtScreenBidPage.getPageCurr(), mgtScreenBidPage.getPageSize())); |
| | | if (StringUtils.isNotEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(page, MgtAuctionBidRecordVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 添加商品 |
| | | * |
| | | * @param dto 大屏操作台添加商品数据传输对象 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void addGoods(MgtScreenSalesroomGoodsDTO dto) { |
| | | GoodsSku data = goodsSkuClient.getGoodsSkuOne(dto.getGoodsSkuId(), SecurityConstants.INNER) |
| | | .getData(); |
| | | if (StringUtils.isNull(data)) { |
| | | throw new ServiceException("商品不存在"); |
| | | } |
| | | // 扣减库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(data.getId()); |
| | | goodsStockUpdDTO.setAuctionStock(dto.getSalesroomStock() * -1); |
| | | R<?> result = goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | if (result.getCode() != Constants.SUCCESS) { |
| | | throw new ServiceException("添加商品失败"); |
| | | } |
| | | AuctionSalesroomGoods auctionSalesroomGoods = BeanUtils.copyBean(dto, |
| | | AuctionSalesroomGoods.class); |
| | | auctionSalesroomGoods.setBackupStatus(false); |
| | | auctionSalesroomGoodsMapper.insert(auctionSalesroomGoods); |
| | | } |
| | | |
| | | /** |
| | | * 获取备选拍品列表的分页数据 |
| | | * |
| | | * @param query 拍卖场商品关系查询对象 |
| | | * @return PageDTO<MgtAuctionSalesroomGoodsVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtAuctionSalesroomGoodsVO> backupGoods(MgtAuctionSalesroomGoodsQuery query) { |
| | | Page<AuctionSalesroomGoods> page = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | Set<Long> goodsSkuIdSet = null; |
| | | if (StringUtils.isNotBlank(query.getGoodsName())) { |
| | | List<GoodsSku> data = goodsSkuClient.getGoodsByName(query.getGoodsName(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNotEmpty(data)) { |
| | | goodsSkuIdSet = data.stream().map(GoodsSku::getId) |
| | | .collect(Collectors.toSet()); |
| | | } else { |
| | | return PageDTO.empty(page); |
| | | } |
| | | } |
| | | page = auctionSalesroomGoodsMapper.selectPage( |
| | | new Page<>(query.getPageCurr(), query.getPageSize()), |
| | | Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .eq(AuctionSalesroomGoods::getAuctionSalesroomId, |
| | | query.getAuctionSalesroomId()) |
| | | .eq(AuctionSalesroomGoods::getBackupStatus, Boolean.TRUE) |
| | | .in(StringUtils.isNotEmpty(goodsSkuIdSet), |
| | | AuctionSalesroomGoods::getGoodsSkuId, goodsSkuIdSet)); |
| | | if (StringUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | Set<Long> skuIdList = page.getRecords().stream().map(AuctionSalesroomGoods::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | List<GoodsSku> goodsSkuList = goodsSkuClient.getGoodsListByIds(skuIdList, |
| | | SecurityConstants.INNER).getData(); |
| | | Map<Long, GoodsSku> goodsSkuMap = goodsSkuList.stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, e -> e)); |
| | | PageDTO<MgtAuctionSalesroomGoodsVO> mgtAuctionSalesroomGoodsVOPageDTO = PageDTO.of(page, |
| | | MgtAuctionSalesroomGoodsVO.class); |
| | | mgtAuctionSalesroomGoodsVOPageDTO.getList().forEach(item -> { |
| | | item.setGoodsSkuName(goodsSkuMap.get(item.getGoodsSkuId()).getSkuName()); |
| | | }); |
| | | return mgtAuctionSalesroomGoodsVOPageDTO; |
| | | } |
| | | |
| | | /** |
| | | * 选择备选商品 |
| | | * |
| | | * @param idStr 备选商品id集合 |
| | | */ |
| | | @Override |
| | | public void addBackupGoods(String idStr) { |
| | | String[] idArr = idStr.split(","); |
| | | List<Long> idList = Arrays.stream(idArr).map(Long::valueOf).collect(Collectors.toList()); |
| | | List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList( |
| | | Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .in(AuctionSalesroomGoods::getId, idList) |
| | | .eq(AuctionSalesroomGoods::getBackupStatus, Boolean.TRUE)); |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoods)) { |
| | | auctionSalesroomGoods.forEach(item -> { |
| | | item.setStatus(AuctionGoodsStatusEnum.WAITING); |
| | | item.setBackupStatus(Boolean.FALSE); |
| | | }); |
| | | auctionSalesroomGoodsMapper.updateBatchById(auctionSalesroomGoods); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 结束当前拍卖商品 |
| | | * |
| | | * @param id 拍卖场商品id |
| | | */ |
| | | @Override |
| | | public void stopCurrentGoods(Long id) throws JsonProcessingException { |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id); |
| | | if (StringUtils.isNull(auctionSalesroomGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS); |
| | | map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString()); |
| | | map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString()); |
| | | map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus()); |
| | | map.put("message_type", "stop"); |
| | | map.put("type", "2"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | sysUserClient.pushAll(msg, SecurityConstants.INNER); |
| | | } |
| | | |
| | | /** |
| | | * 开始下一拍卖商品 |
| | | * |
| | | * @param id 拍卖场商品id |
| | | */ |
| | | @Override |
| | | public void startNextGoods(Long id) throws JsonProcessingException { |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id); |
| | | if (StringUtils.isNull(auctionSalesroomGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS); |
| | | map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString()); |
| | | map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString()); |
| | | map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus()); |
| | | map.put("message_type", "start"); |
| | | map.put("type", "2"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | sysUserClient.pushAll(msg, SecurityConstants.INNER); |
| | | } |
| | | |
| | | /** |
| | | * 播放视频 |
| | | * |
| | | * @param dto 大屏播放视频对象 |
| | | */ |
| | | @Override |
| | | public void play(MgtScreenVideoDTO dto) { |
| | | PromotionVideo data = promotionClient.getPromotionVideoOne(dto.getVideoId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNull(data)) { |
| | | throw new ServiceException("视频不存在"); |
| | | } |
| | | iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq |
| | | (AuctionVideo::getAuctionSalesroomId, dto.getAuctionSalesroomId())); |
| | | AuctionVideo auctionVideo = new AuctionVideo(); |
| | | auctionVideo.setAuctionSalesroomId(dto.getAuctionSalesroomId()); |
| | | auctionVideo.setPromotionVideoId(dto.getVideoId()); |
| | | auctionVideo.setPromotionVideoUrl(data.getVideoUrl()); |
| | | iAuctionVideoService.save(auctionVideo); |
| | | } |
| | | |
| | | /** |
| | | * 结束播放 |
| | | * |
| | | * @param auctionSalesroomId 拍卖场id |
| | | */ |
| | | @Override |
| | | public void stopPlay(Long auctionSalesroomId) { |
| | | iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq |
| | | (AuctionVideo::getAuctionSalesroomId, auctionSalesroomId)); |
| | | } |
| | | |
| | | /** |
| | | * 开始当前拍卖场 |
| | | * |
| | | * @param auctionSalesroomId 拍卖场id |
| | | */ |
| | | @Override |
| | | public void startCurrentAuctionSalesroom(Long auctionSalesroomId) |
| | | throws JsonProcessingException { |
| | | // 修改拍卖场开始状态 |
| | | 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); |
| | | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", auctionSalesroom.getId().toString()); |
| | | map.put("AuctionTypeEnum", auctionSalesroom.getStatus()); |
| | | map.put("message_type", "start"); |
| | | map.put("type", "1"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) |
| | | .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER); |
| | | } |
| | | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | @Transactional |
| | | public void stopCurrentAuctionSalesroom(Long auctionSalesroomId) |
| | | throws JsonProcessingException { |
| | | 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); |
| | | long count = auctionSalesroomGoods.stream() |
| | | .filter(goods -> goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) |
| | | .count(); |
| | | if (count > 0) { |
| | | throw new ServiceException("当前拍卖场正在拍卖商品,不能停止"); |
| | | } |
| | | // 修改拍卖场开始状态 |
| | | AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); |
| | | auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); |
| | | auctionSalesroom.setEndTime(LocalDateTime.now()); |
| | | auctionSalesroomMapper.updateById(auctionSalesroom); |
| | | |
| | | 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); |
| | | } |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", auctionSalesroom.getId().toString()); |
| | | map.put("AuctionTypeEnum",auctionSalesroom.getStatus()); |
| | | map.put("message_type", "end"); |
| | | map.put("type", "1"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) |
| | | .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER); |
| | | } |
| | | |
| | | @Override |
| | | public List<AuctionSalesroom> getAuctionSalesroomByIds( |
| | | Collection<Long> auctionSalesroomGoodsIdSet) { |
| | | List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList( |
| | | Wrappers.lambdaQuery(AuctionSalesroomGoods.class) |
| | | .in(AuctionSalesroomGoods::getId, auctionSalesroomGoodsIdSet)); |
| | | Set<Long> auctionSalesroomIdSet = auctionSalesroomGoods.stream() |
| | | .map(AuctionSalesroomGoods::getAuctionSalesroomId).collect( |
| | | Collectors.toSet()); |
| | | return this.listByIds(auctionSalesroomIdSet); |
| | | } |
| | | } |