| | |
| | | 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()); |
| | | } |
| | | } |
| | |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | System.out.println("exchangeType:--->"); |
| | | |
| | | ReturnModel returnModel = new ReturnModel(); |
| | | Long returnId = null; |
| | | //如果是兑换优惠卷 |
| | | if (exchangeType.getGoodsType()==4){ |
| | | //查询优惠卷 |
| | |
| | | if (usercounts == coupon.getPickUpQuantity()){ |
| | | return new ResultUtil<>(0,"限领数量已达最大"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(exchangeType.getGoodId()); |
| | |
| | | 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(); |
| | | //记录 |
| | | // UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise(); |
| | | // pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId()); |
| | | // pointsMerchandise.setUserId(userIdFormRedis); |
| | | // pointsMerchandise.setStatus(1); |
| | | // pointsMerchandise.setState(1); |
| | | // pointsMerchandise.setPayStatus(1); |
| | | //// if (merchandise.getUseScope() == 3){ |
| | | //// if (exchangeType.getGoodsType() == 2){ |
| | | //// CoursePackage coursePackage = cpageClient.queryCoursePackageById(merchandise.getCoursePackageId()); |
| | | //// pointsMerchandise.setStoreId(coursePackage.getStoreId()); |
| | | //// }else { |
| | | //// pointsMerchandise.setStoreId(exchangeType.getStoreId()); |
| | | //// } |
| | | //// } |
| | | //// pointsMerchandise.setCode(code); |
| | | // returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | |
| | | return ResultUtil.success(returnId); |
| | | } |
| | | |
| | | |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | PointsMerchandise merchandise = mcClient.selectPointsMerchandiseById(exchangeType.getGoodId()); |
| | | |
| | | if (ToolUtil.isEmpty(merchandise)){ |
| | | return ResultUtil.error("商品不存在"); |
| | | } |
| | |
| | | } |
| | | } |
| | | pointsMerchandise.setCode(code); |
| | | mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | } |
| | | |
| | | switch (exchangeType.getExchangeType()){ |
| | |
| | | break; |
| | | } |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | returnModel.setReturnId(returnId); |
| | | return ResultUtil.success(returnModel); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | |
| | | 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++; |
| | | } |
| | | } |