| | |
| | | import com.github.binarywang.wxpay.service.WxPayService; |
| | | import com.google.common.collect.Lists; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.UserStatus; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.ip.IpUtils; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.*; |
| | | import com.ruoyi.system.api.model.QwH5LoginVo; |
| | | import com.ruoyi.system.api.model.QwUserDetailDto; |
| | | import com.ruoyi.system.api.service.*; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import lombok.extern.log4j.Log4j2; |
| | |
| | | |
| | | @Value("${wx.pay.callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | goodsRealPrice = goodsTotalPrice; |
| | | // 处理优惠券 |
| | | if (null != memberCouponId) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId.toString()); |
| | | System.err.println(JSON.toJSONString(appMemberCouponVoMap)); |
| | | System.err.println(memberCouponId); |
| | | System.err.println(JSON.toJSONString(appMemberCouponVo)); |
| | | if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) { |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | | if (couponType == 1 && appMemberCouponVo.getMoneyThreshold() != null && appMemberCouponVo.getDiscountMoney() != null) { |
| | |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } |
| | | } else if (couponType == 2 && appMemberCouponVo.getDiscountPercent() != null) { |
| | | discountPercent = appMemberCouponVo.getDiscountPercent(); |
| | |
| | | discountMoney = goodsTotalPrice.subtract(goodsRealPrice); |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } else if (couponType == 3 && appMemberCouponVo.getDiscountMoney() != null) { |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | if (goodsTotalPrice.compareTo(discountMoney) > 0) { |
| | |
| | | } |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | sureOrderGoodsVo.setAppMemberCouponVoList(appGoodsMemberCouponVoList); |
| | | } |
| | | } |
| | | /*if (appMemberCouponVoList != null && !appMemberCouponVoList.isEmpty()) { |
| | | // 获取商品关联优惠券 |
| | | appGoodsMemberCouponVoList = new ArrayList<>(); |
| | | for(AppSureOrderGoodsVo sureOrderGoodsVo : appSureOrderGoodsVoList){ |
| | | for (AppMemberCouponVo entity : appMemberCouponVoList) { |
| | | if (StringUtils.isBlank(entity.getRelGoodsIds())) { |
| | | if (entity.getCouponType() == 1 && entity.getMoneyThreshold() != null && entity.getDiscountMoney() != null) { |
| | | moneyThreshold = entity.getMoneyThreshold(); |
| | | if (sureOrderGoodsVo.getGoodsTotalPrice().compareTo(moneyThreshold) >= 0) { |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | } else if (entity.getRelGoodsIds().contains(sureOrderGoodsVo.getGoodsId())) { |
| | | if (entity.getCouponType() == 1 && entity.getMoneyThreshold() != null && entity.getDiscountMoney() != null) { |
| | | moneyThreshold = entity.getMoneyThreshold(); |
| | | if (sureOrderGoodsVo.getGoodsTotalPrice().compareTo(moneyThreshold) >= 0) { |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | sureOrderGoodsVo.setAppMemberCouponVoList(appGoodsMemberCouponVoList); |
| | | } |
| | | }*/ |
| | | // 设置订单相关金额 |
| | | appSureOrderVo.setOrderGoodsMoney(orderGoodsMoney); |
| | | appSureOrderVo.setCouponDiscount(couponDiscount); |
| | |
| | | goodsRealPrice = goodsTotalPrice; |
| | | // 如果使用了优惠券,计算优惠后的价格 |
| | | if (memberCouponId != null) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId.toString()); |
| | | if(null == appMemberCouponVo){ |
| | | throw new ServiceException("优惠券已使用"); |
| | | } |
| | | // 如果优惠券适用于该商品 |
| | | if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) { |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | |
| | | */ |
| | | @Override |
| | | public MerHomeShopTotalVo getMerHomeTotal(MerHomeShopTotalVo merHomeShopTotalVo) { |
| | | Long shopId = merHomeShopTotalVo.getShopId(); |
| | | // 查询用户信息 |
| | | QwUserDetailDto qwUserDetail = new QwUserDetailDto(); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | qwUserDetail.setUserid(userId.toString()); |
| | | // 查询用户信息 |
| | | R<QwH5LoginVo> userResult = remoteShopService.qwH5Login(qwUserDetail); |
| | | if(userResult==null){ |
| | | throw new ServiceException(AppErrorConstant.USER_NO_SHOP); |
| | | } |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | if (401 == userResult.getCode()) |
| | | { |
| | | throw new ServiceException("商户已被冻结,请联系管理员",401); |
| | | } |
| | | QwH5LoginVo userInfo = userResult.getData(); |
| | | SysUser user = userInfo.getSysUser(); |
| | | String username = user.getUserName(); |
| | | // IP黑名单校验 |
| | | String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); |
| | | if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) |
| | | { |
| | | throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); |
| | | } |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | | // 查询用户商户 |
| | | R<ShopRelUserVo> shopResult = remoteShopService.getShopByUserId(user.getUserId()); |
| | | if (R.FAIL == userResult.getCode()) { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | ShopRelUserVo shopInfo = shopResult.getData(); |
| | | if(null == shopInfo){ |
| | | throw new ServiceException("未查询到商户信息"); |
| | | } |
| | | Long shopId = shopInfo.getShopId(); |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | if(-1 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已删除,请联系管理员"); |
| | | } |
| | | if(0 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已冻结,请联系管理员"); |
| | | } |
| | | if(2 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已终止合作,请联系管理员"); |
| | | } |
| | | |
| | | |
| | | shopId = merHomeShopTotalVo.getShopId(); |
| | | |
| | | //获取今日到店 |
| | | Integer todayShop = userServiceRecordService.countShopServicePerson(shopId); |
| | | //获取待处理订单和营业额 |
| | |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public MerVerifyCouponVo sureVerifyCoupon(MerVerifyCouponDto merVerifyCouponDto) { |
| | | MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()).getData(); |
| | | R<MerVerifyCouponGetVo> verifyCoupon = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()); |
| | | if(verifyCoupon.getCode() != 200){ |
| | | throw new ServiceException(verifyCoupon.getMsg()); |
| | | } |
| | | MerVerifyCouponGetVo verifyCouponGetVo = verifyCoupon.getData(); |
| | | MemberCoupon memberCoupon = verifyCouponGetVo.getMemberCoupon(); |
| | | ShopRelUserVo shopRelUserVo = remoteShopService.getShopByUserId(merVerifyCouponDto.getUserId()).getData(); |
| | | Long userId = verifyCouponGetVo.getUserId(); |
| | |
| | | // 创建MerVerifyCouponVo对象 |
| | | MerVerifyCouponVo merVerifyCouponVo = new MerVerifyCouponVo(); |
| | | // 调用remoteCouponService的getVerifyCoupon方法获取MerVerifyCouponGetVo对象 |
| | | MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(Long.valueOf(verifyCode)).getData(); |
| | | R<MerVerifyCouponGetVo> verifyCoupon = remoteCouponService.getVerifyCoupon(Long.valueOf(verifyCode)); |
| | | if(verifyCoupon.getCode() != 200){ |
| | | throw new ServiceException(verifyCoupon.getMsg()); |
| | | } |
| | | MerVerifyCouponGetVo verifyCouponGetVo = verifyCoupon.getData(); |
| | | MemberCoupon memberCoupon = verifyCouponGetVo.getMemberCoupon(); |
| | | // 检查优惠券状态 |
| | | int couponStatus = memberCoupon.getCouponStatus(); |