| | |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | System.out.println("exchangeType:--->"); |
| | | System.out.println(exchangeType); |
| | |
| | | pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId()); |
| | | pointsMerchandise.setUserId(userIdFormRedis); |
| | | pointsMerchandise.setStatus(1); |
| | | pointsMerchandise.setState(1); |
| | | if (merchandise.getUseScope() == 3){ |
| | | if (exchangeType.getGoodsType() == 2){ |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(merchandise.getCoursePackageId()); |
| | |
| | | packagePayment.setPayUserId(userIdFormRedis); |
| | | packagePayment.setStatus(1); |
| | | packagePayment.setState(1); |
| | | packagePayment.setInsertTime(new Date()); |
| | | packagePayment.setCode(code); |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | } |
| | |
| | | coupon.setCouponId(exchangeType.getGoodId()); |
| | | coupon.setUserId(userIdFormRedis); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | } |
| | | break; |
| | |
| | | case 2: |
| | | // 积分+现金 |
| | | boolean dealt = dealAppUserIntegral(userIdFormRedis,tAppUser,merchandise.getIntegral()); |
| | | if (dealt){ |
| | | switch (exchangeType.getGoodsType()){ |
| | | // 1实物 2课包 3门票 4优惠券 |
| | | case 2: |
| | | Integer stuNums = 0; |
| | | if (ToolUtil.isNotEmpty(exchangeType.getStuIds())){ |
| | | stuNums = exchangeType.getStuIds().size(); |
| | | }else { |
| | | stuNums = 1; |
| | | } |
| | | for (int i = 0; i < stuNums; i++) { |
| | | List<CoursePackagePaymentConfig> courseConfigList = cpconClient.getCourseConfigList(merchandise.getCoursePackageId()); |
| | | TCoursePackagePayment packagePayment = new TCoursePackagePayment(); |
| | | packagePayment.setAppUserId(userIdFormRedis); |
| | | packagePayment.setStudentId(exchangeType.getStuIds().get(i)); |
| | | packagePayment.setCoursePackageId(merchandise.getCoursePackageId()); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { |
| | | if (Objects.equals(coursePackagePaymentConfig.getId(), merchandise.getCoursePackageConfigId())) { |
| | | packagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | break; |
| | | } |
| | | } |
| | | packagePayment.setPlayPaiCoin(merchandise.getIntegral()); |
| | | packagePayment.setAbsencesNumber(0); |
| | | packagePayment.setPayUserType(1); |
| | | packagePayment.setPayStatus(1); |
| | | packagePayment.setPayUserId(userIdFormRedis); |
| | | packagePayment.setStatus(1); |
| | | packagePayment.setState(1); |
| | | packagePayment.setInsertTime(new Date()); |
| | | packagePayment.setCode(code); |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | } |
| | | break; |
| | | case 4: |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(exchangeType.getGoodId()); |
| | | coupon.setUserId(userIdFormRedis); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }else { |
| | | return ResultUtil.error("用户积分不足!"); |
| | | } |
| | | switch (exchangeType.getPayType()) { |
| | | case 1: |
| | | try { |
| | |
| | | } |
| | | break; |
| | | case 3: |
| | | // 现金 |
| | | switch (exchangeType.getGoodsType()){ |
| | | case 2: |
| | | Integer stuNums = 0; |
| | | if (ToolUtil.isNotEmpty(exchangeType.getStuIds())){ |
| | | stuNums = exchangeType.getStuIds().size(); |
| | | }else { |
| | | stuNums = 1; |
| | | } |
| | | for (int i = 0; i < stuNums; i++) { |
| | | List<CoursePackagePaymentConfig> courseConfigList = cpconClient.getCourseConfigList(merchandise.getCoursePackageId()); |
| | | TCoursePackagePayment packagePayment = new TCoursePackagePayment(); |
| | | packagePayment.setAppUserId(userIdFormRedis); |
| | | packagePayment.setStudentId(exchangeType.getStuIds().get(i)); |
| | | packagePayment.setCoursePackageId(merchandise.getCoursePackageId()); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { |
| | | if (Objects.equals(coursePackagePaymentConfig.getId(), merchandise.getCoursePackageConfigId())) { |
| | | packagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | packagePayment.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | break; |
| | | } |
| | | } |
| | | packagePayment.setCashPayment(merchandise.getCash()); |
| | | packagePayment.setAbsencesNumber(0); |
| | | packagePayment.setPayUserType(1); |
| | | packagePayment.setPayStatus(1); |
| | | packagePayment.setPayUserId(userIdFormRedis); |
| | | packagePayment.setStatus(1); |
| | | packagePayment.setState(1); |
| | | packagePayment.setInsertTime(new Date()); |
| | | packagePayment.setCode(code); |
| | | paymentClient.savePaymentCoursePackage(packagePayment); |
| | | } |
| | | break; |
| | | case 4: |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(exchangeType.getGoodId()); |
| | | coupon.setUserId(userIdFormRedis); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | switch (exchangeType.getPayType()) { |
| | | case 1: |
| | | try { |
| | |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("tradeStatus"); |
| | | String tradeNo = data1.get("tradeNo"); |
| | | // if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | // coursePackagePayment.setState(3); |
| | | // couPayClient.delPaymentCoursePackage(coursePackagePayment.getId()); |
| | | // break; |
| | | // } |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | mcClient.deletePaymentRecord(code); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | mcClient.deletePaymentRecord(code); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("trade_state"); |
| | | String transaction_id = data1.get("transaction_id"); |
| | | // if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | // coursePackagePayment.setState(3); |
| | | // couPayClient.delPaymentCoursePackage(coursePackagePayment.getId()); |
| | | // break; |
| | | // } |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | mcClient.deletePaymentRecord(code); |
| | | break; |
| | | } |
| | | if("SUCCESS".equals(s)){ |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |
| | |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |