| | |
| | | import com.alipay.api.request.AlipayTradeOrderSettleRequest; |
| | | import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; |
| | | import com.alipay.api.response.AlipayTradeOrderSettleResponse; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | commodity.setGoodsType(4); |
| | | commodity.setShopIds(ucponClient.getCouponStoreIds(allCoupon.getId())); |
| | | commodity.setNums(ucponClient.getRedeemedQuantity(allCoupon.getId())); |
| | | commodity.setUseScope(allCoupon.getUseScope()); |
| | | goods.add(commodity); |
| | | } |
| | | } |
| | |
| | | if (request.getShopId()!=null){ |
| | | if (goods.size() > 0 ){ |
| | | goods = goods.stream() |
| | | .filter(merchandise -> merchandise.getShopIds().contains(request.getShopId())) |
| | | .filter( merchandise ->(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 2)||(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 1)||merchandise.getShopIds().contains(request.getShopId())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private UserConponClient userConponClient; |
| | | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | System.out.println("exchangeType:--->"); |
| | | |
| | | //如果是兑换优惠卷 |
| | | if (exchangeType.getGoodsType()==4){ |
| | | //查询优惠卷 |
| | | Coupon coupon = userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | //查询该优惠卷的数量够不够 |
| | | List<Integer> queryIds = new ArrayList<>(); |
| | | queryIds.add(coupon.getId()); |
| | | queryIds.add(userIdFormRedis); |
| | | Integer counts = userConponClient.queryCounts(queryIds); |
| | | if (coupon.getQuantityIssued()-counts == 0){ |
| | | return new ResultUtil(0,"当前数量不足"); |
| | | } |
| | | //查询该用户是否超出限领数量 |
| | | Integer usercounts = userConponClient.queryCounts1(queryIds); |
| | | |
| | | if (usercounts == coupon.getPickUpQuantity()){ |
| | | return new ResultUtil<>(0,"限领数量已达最大"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(exchangeType.getGoodId()); |
| | | userCoupon.setUserId(userIdFormRedis); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | |
| | | |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userIdFormRedis); |
| | | if (user.getIntegral()<coupon.getIntegral().intValue()){ |
| | | return new ResultUtil<>(0,"当前用户积分不足"); |
| | | } |
| | | |
| | | user.setIntegral(user.getIntegral()-coupon.getIntegral().intValue()); |
| | | |
| | | appUserService.updateById(user); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | System.out.println(exchangeType); |
| | | try { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if(userPointsMerchandises.get(0).getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && userPointsMerchandises.get(0).getPayStatus() == 1){ |
| | | // ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode().equals("10000") && userPointsMerchandises.get(0).getPayStatus() == 1){ |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("tradeStatus"); |
| | | String tradeNo = data1.get("tradeNo"); |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | // String tradeNo = data1.get("tradeNo"); |
| | | |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String tradeStatus = resultUtil.getTradeStatus(); |
| | | System.out.println("ssssss"+tradeStatus); |
| | | if("REFUND".equals(tradeStatus) || "NOTPAY".equals(tradeStatus) || "CLOSED".equals(tradeStatus) || "REVOKED".equals(tradeStatus) || "PAYERROR".equals(tradeStatus) || num == 10){ |
| | | mcClient.deletePaymentRecord(code); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | if("TRADE_SUCCESS".equals(tradeStatus)){ |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setOrderNumber(tradeNo); |
| | |
| | | moneyOut(tradeNo,tradeNo); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | | if("WAIT_BUYER_PAY".equals(tradeStatus)){ |
| | | num++; |
| | | } |
| | | } |