| | |
| | | import com.dsh.account.enums.RechargeRecordEnum; |
| | | import com.dsh.account.feignclient.activity.*; |
| | | import com.dsh.account.feignclient.activity.model.*; |
| | | import com.dsh.account.feignclient.communityWorldCup.WorldCupPaymentClinet; |
| | | import com.dsh.account.feignclient.communityWorldCup.model.GetWorldCupPayment; |
| | | import com.dsh.account.feignclient.competition.DeductionCompetitionsClient; |
| | | import com.dsh.account.feignclient.competition.model.BillingDataRequestVo; |
| | | import com.dsh.account.feignclient.course.CoursePackageClient; |
| | |
| | | import com.dsh.account.feignclient.course.CoursePaymentClient; |
| | | import com.dsh.account.feignclient.course.VideoOfCourseListClient; |
| | | import com.dsh.account.feignclient.course.model.*; |
| | | import com.dsh.account.feignclient.other.ImgConfigClient; |
| | | import com.dsh.account.feignclient.other.RechargeConfigClient; |
| | | import com.dsh.account.feignclient.other.SiteClient; |
| | | import com.dsh.account.feignclient.other.StoreClient; |
| | | import com.dsh.account.feignclient.other.model.Store; |
| | | import com.dsh.account.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.account.feignclient.other.model.TImgConfig; |
| | | import com.dsh.account.feignclient.other.*; |
| | | import com.dsh.account.feignclient.other.model.*; |
| | | import com.dsh.account.mapper.*; |
| | | import com.dsh.account.model.*; |
| | | import com.dsh.account.model.AppUserByNameAndPhoneDTO; |
| | |
| | | import com.dsh.account.model.vo.classDetails.RegisteredCourse; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassInfoVo; |
| | | import com.dsh.account.model.vo.userBenefitDetail.*; |
| | | import com.dsh.account.service.IRefereeService; |
| | | import com.dsh.account.service.TAppGiftService; |
| | | import com.dsh.account.service.TAppUserService; |
| | | import com.dsh.account.service.UserIntegralChangesService; |
| | | import com.dsh.account.util.*; |
| | | import com.dsh.account.util.akeylogin.Md5Util; |
| | | import com.dsh.account.vo.GroupCityInfoVO; |
| | |
| | | @Resource |
| | | private ImgConfigClient icfgClient; |
| | | |
| | | |
| | | @Resource |
| | | private VideoOfCourseListClient voclClient; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private UserConponClient ucponClient; |
| | | |
| | | |
| | | @Resource |
| | | private CoursePackageClient cpageClient; |
| | |
| | | |
| | | @Resource |
| | | private SiteClient stClient; |
| | | @Autowired |
| | | |
| | | @Resource |
| | | private TAppUserMapper appUserMapper; |
| | | |
| | | @Autowired |
| | | private TAppGiftService appGiftService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IntroduceRewardsClient introduceRewardsClient; |
| | | |
| | | |
| | | private String aliAppid = "2021004105665036";//支付宝appid |
| | | |
| | |
| | | |
| | | @Resource |
| | | private UserCouponPaymentClient userCouponPaymentClient; |
| | | |
| | | @Autowired |
| | | private IRefereeService refereeService; |
| | | |
| | | @Resource |
| | | private WorldCupPaymentClinet worldCupPaymentClinet; |
| | | |
| | | @Autowired |
| | | private UserIntegralChangesService userIntegralChangesService; |
| | | |
| | | @Resource |
| | | private GameRecordClient gameRecordClient; |
| | | |
| | | |
| | | |
| | |
| | | return ResultUtil.error("请先开启定位", ""); |
| | | } |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(addAppUserVo.getLon(), addAppUserVo.getLat()); |
| | | Integer num = 0; |
| | | Integer activityId = null; |
| | | if (null != geocode) { |
| | | String province = geocode.get("province"); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String city = geocode.get("city"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | // 根据所在市code 查询是否有介绍有礼活动 |
| | | IntroduceRewards res = introduceRewardsClient.getGiftList(cityCode); |
| | | List<IntroduceRewards> res = introduceRewardsClient.getGiftList(cityCode); |
| | | if (res != null) { |
| | | num = res.getGiveClass(); |
| | | activityId = res.getId(); |
| | | if (ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())) { |
| | | List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getPhone, addAppUserVo.getInvitePhone())); |
| | | if (tAppUsers.size() > 0) { |
| | | addAppUserVo.setReferralUserId(tAppUsers.get(0).getId()); |
| | | for (IntroduceRewards re : res) { |
| | | Integer num = re.getGiveClass(); |
| | | Integer activityId = re.getId(); |
| | | if (ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())) { |
| | | List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getPhone, addAppUserVo.getInvitePhone())); |
| | | if (tAppUsers.size() > 0) { |
| | | addAppUserVo.setReferralUserId(tAppUsers.get(0).getId()); |
| | | } |
| | | } |
| | | } |
| | | if (num != 0) { |
| | | TAppGift tAppGift = new TAppGift(); |
| | | TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>() |
| | | .eq("phone", addAppUserVo.getInvitePhone())); |
| | | if (phone == null) { |
| | | return ResultUtil.error("推荐人手机号未注册玩湃会员!"); |
| | | } else { |
| | | tAppGift.setUserName(phone.getName()); |
| | | tAppGift.setUserPhone(phone.getPhone()); |
| | | if (num != 0) { |
| | | TAppGift tAppGift = new TAppGift(); |
| | | TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>() |
| | | .eq("phone", addAppUserVo.getInvitePhone())); |
| | | if (phone == null) { |
| | | return ResultUtil.error("推荐人手机号未注册玩湃会员!"); |
| | | } else { |
| | | tAppGift.setUserName(phone.getName()); |
| | | tAppGift.setUserPhone(phone.getPhone()); |
| | | } |
| | | tAppGift.setUserId(addAppUserVo.getReferralUserId()); |
| | | tAppGift.setNum(num); |
| | | tAppGift.setShareUserId(tAppUser.getId()); |
| | | tAppGift.setShareUserName(tAppUser.getPhone()); |
| | | tAppGift.setShareUserPhone(tAppUser.getPhone()); |
| | | tAppGift.setActivityId(activityId); |
| | | tAppGift.setInsertTime(new Date()); |
| | | appGiftService.save(tAppGift); |
| | | } |
| | | tAppGift.setUserId(addAppUserVo.getReferralUserId()); |
| | | tAppGift.setNum(num); |
| | | tAppGift.setShareUserId(tAppUser.getId()); |
| | | tAppGift.setShareUserName(tAppUser.getPhone()); |
| | | tAppGift.setShareUserPhone(tAppUser.getPhone()); |
| | | tAppGift.setActivityId(activityId); |
| | | tAppGift.setInsertTime(new Date()); |
| | | appGiftService.save(tAppGift); |
| | | } |
| | | } |
| | | } |
| | |
| | | tAppUser.setGender(loginWechatVo.getSex()); |
| | | tAppUser.setState(1); |
| | | tAppUser.setInsertTime(new Date()); |
| | | tAppUser.setProvince(""); |
| | | tAppUser.setProvinceCode(""); |
| | | tAppUser.setCity(""); |
| | | tAppUser.setCityCode(""); |
| | | this.baseMapper.insert(tAppUser); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public IndexOfUserBenefirVo queryBenefitDetails(Integer appUserId, String lon, String lat) { |
| | | IndexOfUserBenefirVo benefirVo = new IndexOfUserBenefirVo(); |
| | | |
| | | TAppUser appUser = this.getById(appUserId); |
| | | if (appUser.getHeadImg() != null) { |
| | | benefirVo.setUserHeadImg(appUser.getHeadImg()); |
| | |
| | | List<IntegralCommodity> convertibleGoods = mcClient.getConvertibleGoods(location); |
| | | benefirVo.setCommodities(convertibleGoods); |
| | | benefirVo.setImage(icfgClient.getImageConfig()); |
| | | Referee referee = refereeService.getOne(new QueryWrapper<Referee>().eq("phone", appUser.getPhone()).eq("state", 1)); |
| | | benefirVo.setReferee(null == referee ? 0 : 1); |
| | | return benefirVo; |
| | | } |
| | | |
| | |
| | | consumeDetail.setConsumeTime(paymentCompetition.getTime()); |
| | | consumeDetail.setConsumeAmount("-" + paymentCompetition.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(paymentCompetition.getDateTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | |
| | | consumeDetail.setConsumeTime(paymentCompetition.getTime()); |
| | | consumeDetail.setConsumeAmount("+" + paymentCompetition.getAmount()); |
| | | consumeDetail.setType(1); |
| | | consumeDetail.setDateTime(paymentCompetition.getDateTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | | // 3.课包购买 |
| | | // BillingRequestVo amountPayRecord = paymentClient.getAmountPayRecord(requestVo); |
| | | // if (ToolUtil.isNotEmpty(amountPayRecord.getRequests())){ |
| | | // for (BillingRequest coursePackagePayment : amountPayRecord.getRequests()) { |
| | | // ConsumeDetail consumeDetail = new ConsumeDetail(); |
| | | // consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg()); |
| | | // consumeDetail.setConsumeTime(coursePackagePayment.getTime()); |
| | | // consumeDetail.setConsumeAmount("-" + coursePackagePayment.getAmount()); |
| | | // consumeDetail.setType(2); |
| | | // details.add(consumeDetail); |
| | | // } |
| | | // } |
| | | |
| | | //2.0 |
| | | List<CourseCounsum> courseCounsums = paymentClient.getConsumes(requestVo); |
| | | //3.课包购买 |
| | | List<CoursePackageOrder> coursePackageOrder = paymentClient.getCoursePackageOrder(requestVo); |
| | | |
| | | for (CourseCounsum courseCounsum : courseCounsums) { |
| | | for (CoursePackageOrder order : coursePackageOrder) { |
| | | ConsumeDetail consumeDetail = new ConsumeDetail(); |
| | | String[] split = courseCounsum.getReason().split(";"); |
| | | consumeDetail.setConsumeName(split[0]); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(courseCounsum.getInsertTime())); |
| | | // if (courseCounsum.getChangeType()==3){ |
| | | consumeDetail.setConsumeAmount("-" + split[1]); |
| | | consumeDetail.setConsumeName("课程报名"); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(order.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + order.getCashPayment()); |
| | | consumeDetail.setType(2); |
| | | // } |
| | | // |
| | | // consumeDetail.setConsumeAmount("-" + coursePackagePayment.getAmount()); |
| | | // consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(order.getInsertTime().getTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | |
| | |
| | | consumeDetail.setConsumeAmount("-" + booking.getAmount()); |
| | | consumeDetail.setConsumeTime(booking.getTime()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(booking.getDateTime()); |
| | | details.add(consumeDetail); |
| | | } else { |
| | | ConsumeDetail consumeDetail1 = new ConsumeDetail(); |
| | | consumeDetail1.setConsumeName(RechargeRecordEnum.CANCEL_VENUE_RESERVATION.getMsg()); |
| | | consumeDetail1.setConsumeAmount("+" + booking.getAmount()); |
| | | consumeDetail1.setConsumeTime(booking.getTime()); |
| | | consumeDetail1.setDateTime(booking.getDateTime()); |
| | | consumeDetail1.setType(1); |
| | | details.add(consumeDetail1); |
| | | |
| | | ConsumeDetail consumeDetail2 = new ConsumeDetail(); |
| | | consumeDetail2.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg()); |
| | | consumeDetail2.setConsumeAmount("-" + booking.getAmount()); |
| | | consumeDetail2.setConsumeTime(booking.getTime1()); |
| | | consumeDetail2.setType(2); |
| | | consumeDetail2.setDateTime(booking.getDateTime()); |
| | | details.add(consumeDetail2); |
| | | |
| | | } |
| | | // details.add(consumeDetail); |
| | | } |
| | | } |
| | | |
| | | // 5.智慧球场 |
| | | GetTGameRecord getTGameRecord = new GetTGameRecord(); |
| | | getTGameRecord.setAppUserId(appUserId); |
| | | getTGameRecord.setStartTiem(monthStart); |
| | | getTGameRecord.setEndTime(monthEnd); |
| | | List<TGameRecord> tGameRecord = gameRecordClient.getTGameRecord(getTGameRecord); |
| | | for (TGameRecord gameRecord : tGameRecord) { |
| | | ConsumeDetail consumeDetail = new ConsumeDetail(); |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.SMART_STADIUM.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(gameRecord.getTime())); |
| | | consumeDetail.setConsumeAmount("-" + gameRecord.getMoney()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(gameRecord.getTime().getTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | |
| | | // 6.年度会员 |
| | | List<VipPayment> vipPayments = vipPaymentMapper.selectList(new QueryWrapper<VipPayment>() |
| | | .eq("payStatus", 2) |
| | |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(vipPayment.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + vipPayment.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(vipPayment.getPayTime().getTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime())); |
| | | consumeDetail.setConsumeAmount("-" + rechargeRecord.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(rechargeRecord.getPayTime().getTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | |
| | | details.addAll(consumeDetails); |
| | | |
| | | |
| | | //世界杯 |
| | | GetWorldCupPayment getWorldCupPayment = new GetWorldCupPayment(); |
| | | getWorldCupPayment.setAppUserId(appUserId); |
| | | getWorldCupPayment.setPayType("1,2"); |
| | | getWorldCupPayment.setStartTime(monthStart); |
| | | getWorldCupPayment.setEndTime(monthEnd); |
| | | List<WorldCupPayment> worldCupPayment = worldCupPaymentClinet.getWorldCupPayment(getWorldCupPayment); |
| | | for (WorldCupPayment cupPayment : worldCupPayment) { |
| | | ConsumeDetail consumeDetail = new ConsumeDetail(); |
| | | if(cupPayment.getPayStatus() != 3){ |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getCreateTime())); |
| | | consumeDetail.setConsumeAmount("-" + cupPayment.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(cupPayment.getPayTime().getTime()); |
| | | details.add(consumeDetail); |
| | | }else{ |
| | | consumeDetail = new ConsumeDetail(); |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getCreateTime())); |
| | | consumeDetail.setConsumeAmount("-" + cupPayment.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(cupPayment.getPayTime().getTime()); |
| | | details.add(consumeDetail); |
| | | |
| | | consumeDetail = new ConsumeDetail(); |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.CANCEL_WORLD_CIP_PAYMENT.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getCreateTime())); |
| | | consumeDetail.setConsumeAmount("+" + cupPayment.getRefundAmount()); |
| | | consumeDetail.setType(1); |
| | | consumeDetail.setDateTime(cupPayment.getRefundTime().getTime()); |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (details.size() > 0) { |
| | | Collections.sort(details, new Comparator<ConsumeDetail>() { |
| | | @Override |
| | | public int compare(ConsumeDetail record1, ConsumeDetail record2) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm"); |
| | | Date date1 = null; |
| | | Date date2 = null; |
| | | try { |
| | | date1 = dateFormat.parse(record1.getConsumeTime()); |
| | | date2 = dateFormat.parse(record2.getConsumeTime()); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 倒序排序 |
| | | return date2.compareTo(date1); |
| | | return record1.getDateTime().compareTo(record2.getDateTime()) * -1; |
| | | } |
| | | }); |
| | | |
| | |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | | |
| | | return details; |
| | | } |
| | | |
| | |
| | | if (tAppUser.getState() == 2) { |
| | | return ResultUtil.error("您的账号已被冻结"); |
| | | } |
| | | boolean newUser = false; |
| | | List<TAppUser> tAppUsers1 = appUserMapper.selectList(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, dto.getPhone()).eq(TAppUser::getState, 1)); |
| | | if (tAppUsers1.size() > 0) { |
| | | TAppUser tAppUser1 = tAppUsers1.get(0); |
| | |
| | | appUserMapper.updateById(tAppUser); |
| | | token = getToken(tAppUser); |
| | | map.put("token", token); |
| | | |
| | | newUser = true; |
| | | } |
| | | |
| | | // tAppUser.setPhone(dto.getPhone()); |
| | | |
| | | if (ToolUtil.isNotEmpty(dto.getInvitePhone())) { |
| | | if (newUser && ToolUtil.isNotEmpty(dto.getInvitePhone())) { |
| | | if (ToolUtil.isEmpty(dto.getLat()) || ToolUtil.isEmpty(dto.getLon())) { |
| | | return ResultUtil.error("请先开启定位"); |
| | | } |
| | | TAppUser tAppUser1 = appUserMapper.selectOne(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, dto.getInvitePhone()).eq(TAppUser::getState, 1)); |
| | | if (tAppUser1 != null) { |
| | | Map<String, String> geocode = null; |
| | | try { |
| | | geocode = gdMapGeocodingUtil.geocode(dto.getLon(), dto.getLat()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Integer num = 0; |
| | | if (null != geocode) { |
| | | String province = geocode.get("province"); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String city = geocode.get("city"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | IntroduceRewards giftList = introduceRewardsClient.getGiftList(cityCode); |
| | | num = giftList.getGiveClass(); |
| | | } |
| | | Integer userId = null; |
| | | if (ToolUtil.isNotEmpty(dto.getInvitePhone())) { |
| | | List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, dto.getInvitePhone())); |
| | | if (tAppUsers.size() > 0) { |
| | | userId = tAppUsers.get(0).getId(); |
| | | } |
| | | } |
| | | if (userId != null) { |
| | | TAppGift one = appGiftService.getOne(new LambdaQueryWrapper<TAppGift>().eq(TAppGift::getUserId, userId)); |
| | | if (one != null) { |
| | | one.setNum(one.getNum() + num); |
| | | appGiftService.updateById(one); |
| | | } else { |
| | | TAppGift tAppGift = new TAppGift(); |
| | | tAppGift.setUserId(userId); |
| | | tAppGift.setNum(num); |
| | | appGiftService.save(tAppGift); |
| | | TAppUser tAppUser1 = appUserMapper.selectOne(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getPhone, dto.getInvitePhone()).eq(TAppUser::getState, 1)); |
| | | if(null == tAppUser1){ |
| | | return ResultUtil.error("邀请人还未注册账号"); |
| | | } |
| | | Map<String, String> geocode = null; |
| | | try { |
| | | geocode = gdMapGeocodingUtil.geocode(dto.getLon(), dto.getLat()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (null != geocode) { |
| | | String cityCode = geocode.get("cityCode"); |
| | | // 根据所在市code 查询是否有介绍有礼活动 |
| | | List<IntroduceRewards> res = introduceRewardsClient.getGiftList(cityCode); |
| | | if (res != null) { |
| | | for (IntroduceRewards re : res) { |
| | | Integer num = re.getGiveClass(); |
| | | Integer activityId = re.getId(); |
| | | if (num != 0) { |
| | | TAppGift tAppGift = new TAppGift(); |
| | | tAppGift.setUserName(tAppUser1.getName()); |
| | | tAppGift.setUserPhone(tAppUser1.getPhone()); |
| | | tAppGift.setUserId(tAppUser1.getId()); |
| | | tAppGift.setNum(num); |
| | | tAppGift.setShareUserId(tAppUser.getId()); |
| | | tAppGift.setShareUserName(tAppUser.getPhone()); |
| | | tAppGift.setShareUserPhone(tAppUser.getPhone()); |
| | | tAppGift.setActivityId(activityId); |
| | | tAppGift.setInsertTime(new Date()); |
| | | appGiftService.save(tAppGift); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // appUserMapper.updateById(tAppUser); |
| | | |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | |
| | | } |
| | | //查询该用户是否超出限领数量 |
| | | Integer usercounts = userConponClient.queryCounts1(queryIds); |
| | | |
| | | if (usercounts == coupon.getPickUpQuantity()) { |
| | | return new ResultUtil<>(0, "限领数量已达最大"); |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | //生成支付订单 |
| | |
| | | return ResultUtil.success(returnId); |
| | | } |
| | | //积分+现金 |
| | | if(coupon.getRedemptionMethod() == 1){ |
| | | if(coupon.getRedemptionMethod() == 2){ |
| | | userCouponPaymentClient.addUserCouponPayment(userCouponPayment); |
| | | try { |
| | | if(exchangeType.getPayType() == 1){ |
| | | return weChatPaymentCoupon("购买优惠券", userCouponPayment); |
| | | String temp = "0"; |
| | | if (coupon.getPublisherType()!=null && coupon.getPublisherType() != 2){ |
| | | // 做分账 |
| | | temp = "1"; |
| | | } |
| | | return weChatPaymentCoupon("购买优惠券-"+temp, userCouponPayment); |
| | | } |
| | | if(exchangeType.getPayType() == 2){ |
| | | return aliPaymentCoupon("购买优惠券", userCouponPayment); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | System.out.println(exchangeType); |
| | | System.out.println("兑换积分商品"+exchangeType); |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | |
| | | return ResultUtil.error("超过发放数量"); |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | // 新增积分商品兑换记录 |
| | | UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise(); |
| | | pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId()); |
| | | pointsMerchandise.setUserId(userIdFormRedis); |
| | | //新增积分商品兑换记录 |
| | | UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise(); |
| | | pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId()); |
| | | pointsMerchandise.setUserId(userIdFormRedis); |
| | | pointsMerchandise.setGoodsNumber(goodsNums); |
| | | if (exchangeType.getGoodsType() == 2) { |
| | | pointsMerchandise.setStatus(2); |
| | | pointsMerchandise.setVerificationTime(new Date()); |
| | | } else { |
| | | pointsMerchandise.setStatus(1); |
| | | } |
| | | pointsMerchandise.setState(1); |
| | | if (exchangeType.getExchangeType() == 1) { |
| | | pointsMerchandise.setPayStatus(2); |
| | | pointsMerchandise.setPaymentTime(new Date()); |
| | | } else { |
| | | pointsMerchandise.setPayStatus(1); |
| | | } |
| | | if (merchandise.getUseScope() == 3) { |
| | | if (exchangeType.getGoodsType() == 2) { |
| | | pointsMerchandise.setStatus(2); |
| | | pointsMerchandise.setVerificationTime(new Date()); |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(merchandise.getCoursePackageId()); |
| | | pointsMerchandise.setStoreId(coursePackage.getStoreId()); |
| | | } else { |
| | | pointsMerchandise.setStatus(1); |
| | | pointsMerchandise.setStoreId(exchangeType.getStoreId()); |
| | | } |
| | | pointsMerchandise.setState(1); |
| | | if (exchangeType.getExchangeType() == 1) { |
| | | pointsMerchandise.setPayStatus(2); |
| | | } else { |
| | | 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); |
| | | pointsMerchandise.setInsertTime(new Date()); |
| | | returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | } |
| | | pointsMerchandise.setCode(code); |
| | | pointsMerchandise.setInsertTime(new Date()); |
| | | pointsMerchandise.setPayType(exchangeType.getExchangeType()); |
| | | if(null != merchandise.getIntegral()){ |
| | | pointsMerchandise.setIntegral(merchandise.getIntegral() * goodsNums); |
| | | } |
| | | if(exchangeType.getExchangeType() == 2 || exchangeType.getExchangeType() == 3){ |
| | | pointsMerchandise.setCash(merchandise.getCash()); |
| | | pointsMerchandise.setCashPayType(exchangeType.getPayType()); |
| | | } |
| | | |
| | | Double m = new BigDecimal((merchandise.getIntegral() == null ? 0 : merchandise.getIntegral())).add((merchandise.getCash() == null ? BigDecimal.ZERO : merchandise.getCash())).doubleValue(); |
| | | if((m * goodsNums) == 0) { |
| | | pointsMerchandise.setPayStatus(2); |
| | | pointsMerchandise.setPaymentTime(new Date()); |
| | | } |
| | | returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | if((m * goodsNums) == 0 && pointsMerchandise.getPayStatus() == 2){ |
| | | returnModel.setReturnId(returnId); |
| | | return ResultUtil.success(returnModel); |
| | | } |
| | | |
| | | System.err.println("兑换方式"+exchangeType); |
| | | switch (exchangeType.getExchangeType()) { |
| | | // 积分 |
| | | case 1: |
| | | boolean b = true; |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | b = dealAppUserIntegral(userIdFormRedis, tAppUser, merchandise.getIntegral()); |
| | | boolean b = dealAppUserIntegral(userIdFormRedis, tAppUser, merchandise.getIntegral() * goodsNums); |
| | | if (b) switch (exchangeType.getGoodsType()) { |
| | | case 2: |
| | | code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | List<CoursePackagePaymentConfig> courseConfigList = cpconClient.getCourseConfigList(merchandise.getCoursePackageId()); |
| | | CoursePackageOrder coursePackageOrder = new CoursePackageOrder(); |
| | | coursePackageOrder.setCode(code); |
| | | coursePackageOrder.setAppUserId(userIdFormRedis); |
| | | String ids = exchangeType.getStuIds().stream().map(s -> { |
| | | return String.valueOf(s); |
| | | }).collect(Collectors.joining(";")); |
| | | coursePackageOrder.setStudentIds(ids); |
| | | coursePackageOrder.setCoursePackageId(merchandise.getCoursePackageId()); |
| | | coursePackageOrder.setPayType(4); |
| | | CoursePackagePaymentConfig config = null; |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { |
| | | if (coursePackagePaymentConfig.getId().compareTo(merchandise.getCoursePackageConfigId()) == 0) { |
| | | coursePackageOrder.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackageOrder.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | |
| | | config = coursePackagePaymentConfig; |
| | | break; |
| | | } |
| | | } |
| | | coursePackageOrder.setPlayPaiCoin(merchandise.getIntegral()); |
| | | coursePackageOrder.setPayUserType(1); |
| | | coursePackageOrder.setPayStatus(2); |
| | | coursePackageOrder.setPayUserId(userIdFormRedis); |
| | | coursePackageOrder.setStatus(1); |
| | | coursePackageOrder.setState(1); |
| | | coursePackageOrder.setInsertTime(new Date()); |
| | | coursePackageOrder.setOrderType(2); |
| | | Long coursePackageOrderId = paymentClient.savePaymentCoursePackage(coursePackageOrder); |
| | | |
| | | AddCoursePackageOrderStudent addCoursePackageOrderStudent = new AddCoursePackageOrderStudent(); |
| | | addCoursePackageOrderStudent.setCoursePackageOrderId(coursePackageOrderId); |
| | | addCoursePackageOrderStudent.setCoursePackagePaymentConfig(config); |
| | | paymentClient.addCoursePackageOrderStudent(addCoursePackageOrderStudent); |
| | | 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; |
| | | } |
| | | if (b) { |
| | | 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.setPlayPaiCoin(merchandise.getIntegral()); |
| | | packagePayment.setAbsencesNumber(0); |
| | | packagePayment.setPayUserType(1); |
| | | packagePayment.setPayStatus(2); |
| | | packagePayment.setPayUserId(userIdFormRedis); |
| | | packagePayment.setStatus(1); |
| | | packagePayment.setState(1); |
| | | packagePayment.setCode(code); |
| | | packagePayment.setInsertTime(new Date()); |
| | | // paymentClient.savePaymentCoursePackage(packagePayment); |
| | | |
| | | OrderDto orderDto = new OrderDto(); |
| | | orderDto.setAppUserId(userIdFormRedis); |
| | | String joinedString = String.join(",", exchangeType.getStuIds().stream().map(Object::toString).collect(Collectors.toList())); |
| | | orderDto.setStuIds(joinedString); |
| | | orderDto.setClassId(merchandise.getCoursePackageId()); |
| | | orderDto.setClassHours(packagePayment.getClassHours()); |
| | | paymentClient.orderClass(orderDto); |
| | | |
| | | |
| | | } |
| | | 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 { |
| | | else { |
| | | return ResultUtil.error("用户积分不足!"); |
| | | } |
| | | break; |
| | | case 2: |
| | | // 积分+现金 |
| | | boolean dealt = true; |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | dealt = dealAppUserIntegral(userIdFormRedis, tAppUser, merchandise.getIntegral()); |
| | | } |
| | | |
| | | switch (exchangeType.getPayType()) { |
| | | case 1: |
| | | try { |
| | | if (merchandise.getType() == 2) { |
| | | return WechatPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code); |
| | | } else { |
| | | return WechatPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code); |
| | | List<CoursePackagePaymentConfig> courseConfigList = cpconClient.getCourseConfigList(merchandise.getCoursePackageId()); |
| | | CoursePackageOrder coursePackageOrder = new CoursePackageOrder(); |
| | | coursePackageOrder.setCode(code); |
| | | coursePackageOrder.setAppUserId(userIdFormRedis); |
| | | String ids = exchangeType.getStuIds().stream().map(s -> { |
| | | return String.valueOf(s); |
| | | }).collect(Collectors.joining(";")); |
| | | coursePackageOrder.setStudentIds(ids); |
| | | coursePackageOrder.setCoursePackageId(merchandise.getCoursePackageId()); |
| | | coursePackageOrder.setPayType(5); |
| | | CoursePackagePaymentConfig config = null; |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : courseConfigList) { |
| | | if (coursePackagePaymentConfig.getId().compareTo(merchandise.getCoursePackageConfigId()) == 0) { |
| | | coursePackageOrder.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackageOrder.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | break; |
| | | } |
| | | } |
| | | coursePackageOrder.setCashPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size()))); |
| | | coursePackageOrder.setPlayPaiCoin(merchandise.getIntegral() * exchangeType.getStuIds().size()); |
| | | coursePackageOrder.setPayUserType(1); |
| | | coursePackageOrder.setPayStatus(1); |
| | | coursePackageOrder.setPayUserId(userIdFormRedis); |
| | | coursePackageOrder.setStatus(1); |
| | | coursePackageOrder.setState(1); |
| | | coursePackageOrder.setInsertTime(new Date()); |
| | | coursePackageOrder.setOrderType(2); |
| | | paymentClient.savePaymentCoursePackage(coursePackageOrder); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,merchandise.getId()); |
| | | } else if (merchandise.getType() == 1){ |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | }else if(merchandise.getType() == 3){ |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | } |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | | } |
| | | case 2: |
| | | if (merchandise.getType() == 2) { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, returnId); |
| | | return AlipayPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, returnId); |
| | | } else { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, returnId); |
| | | return AlipayPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, returnId); |
| | | } |
| | | default: |
| | | break; |
| | |
| | | case 1: |
| | | try { |
| | | if (merchandise.getType() == 2) { |
| | | return WechatPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,merchandise.getId()); |
| | | } else { |
| | | return WechatPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | } |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | | } |
| | | case 2: |
| | | if (merchandise.getType() == 2) { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, returnId); |
| | | return AlipayPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, returnId); |
| | | } else { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, returnId); |
| | | return AlipayPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, returnId); |
| | | } |
| | | default: |
| | | break; |
| | |
| | | public ResultUtil weChatPaymentCoupon(String body, UserCouponPayment userCouponPayment) throws Exception { |
| | | String code = userCouponPayment.getCode(); |
| | | Double cash = userCouponPayment.getCash(); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(body, "", code, cash.toString(), "/base/coupon/weChatPaymentCouponCallback", "APP", ""); |
| | | Integer couponId = userCouponPayment.getCouponId(); |
| | | Coupon coupon = userConponClient.queryCouponById(couponId); |
| | | String temp ="0"; |
| | | if (coupon.getPublisherType()!=null&&coupon.getPublisherType()!=2){ |
| | | temp = "1"; |
| | | } |
| | | System.err.println("购买优惠券"); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(body+"-"+temp, "", code, cash.toString(), |
| | | "/base/coupon/weChatPaymentCouponCallback", "APP", ""); |
| | | if (weixinpay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | Thread.sleep(wait); |
| | | UserCouponPayment userCouponPayment1 = userCouponPaymentClient.getUserCouponPayment(code); |
| | | if (userCouponPayment1.getStatus() == 2) { |
| | | |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, ""); |
| | |
| | | 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) { |
| | | if ("REFUND".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) { |
| | | //有待支付的订单,这里不处理 |
| | | userCouponPayment1.setStatus(-1); |
| | | userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | |
| | | } |
| | | break; |
| | | } |
| | | if ("USERPAYING".equals(s)) { |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | public ResultUtil aliPaymentCoupon(String body, UserCouponPayment userCouponPayment) throws Exception { |
| | | String code = userCouponPayment.getCode(); |
| | | Double cash = userCouponPayment.getCash(); |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay(body, body, "", code, cash.toString(), "/base/coupon/aliPaymentCouponCallback"); |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | //有待支付的订单,这里不处理 |
| | | userCouponPayment1.setStatus(-1); |
| | | userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | if ("TRADE_FINISHED".equals(s)) { |
| | | // todo 资金结算 |
| | | |
| | | } |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | |
| | | userCouponPayment1.setPaymentTime(new Date()); |
| | | userCouponPayment1.setOrderNumber(tradeNo); |
| | | userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(userCouponPayment1.getCouponId()); |
| | | userCoupon.setUserId(userCouponPayment1.getUserId()); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | |
| | | if(null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()){ |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userCouponPayment1.getUserId()); |
| | | user.setIntegral(user.getIntegral() - userCouponPayment1.getIntegral().intValue()); |
| | | appUserService.updateById(user); |
| | | } |
| | | payMoneyUtil.confirm(smid,code,tradeNo,cash.toString()); |
| | | break; |
| | | |
| | | } |
| | | |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultUtil paymentCouponCallback(String code, String orderNumber) { |
| | | public ResultUtil paymentCouponCallback(String code, String orderNumber) throws Exception { |
| | | System.err.println("进入回调"); |
| | | UserCouponPayment userCouponPayment1 = userCouponPaymentClient.getUserCouponPayment(code); |
| | | if (userCouponPayment1.getStatus() == 2) { |
| | | return ResultUtil.success(); |
| | |
| | | |
| | | if(null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()){ |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userCouponPayment1.getUserId()); |
| | | user.setIntegral(user.getIntegral() - userCouponPayment1.getIntegral().intValue()); |
| | | appUserService.updateById(user); |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(userCouponPayment1.getUserId()); |
| | | vo.setIntegral(userCouponPayment1.getIntegral().intValue() * -1); |
| | | vo.setRemark("兑换优惠券"); |
| | | vo.setType(2); |
| | | userIntegralChangesService.saveUserIntegralChanges(vo); |
| | | } |
| | | Coupon coupon = ucponClient.queryCouponById(userCouponPayment1.getCouponId()); |
| | | // 创建一个两分钟后执行的线程 |
| | | new Thread(() -> { |
| | | try { |
| | | Thread.sleep(120000); |
| | | if (coupon!=null){ |
| | | if (coupon.getPublisherType()!=null&&coupon.getPublisherType()!=2){ |
| | | if (coupon.getPublisherType() == 1){ |
| | | System.err.println("进入分账逻辑"); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(coupon.getCityManagerId()); |
| | | System.err.println("分账比例:"+proportionByOperatorId); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(coupon.getCityManagerId()); |
| | | System.err.println("商户号"+s2); |
| | | System.err.println("分账比例"+bigDecimal1); |
| | | System.err.println("分账金额"+coupon.getCash().multiply(bigDecimal1)); |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(userCouponPayment1.getOrderNumber(), coupon.getCash().multiply(bigDecimal1), s2,""); |
| | | if (!fenzhang.getCode().equals(200)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | } |
| | | |
| | | } |
| | | } else if (coupon.getPublisherType() == 3){ |
| | | // 门店 向上查询运营商 |
| | | Store store = storeClient.queryStoreById(coupon.getCityManagerId()); |
| | | if (store.getOperatorId()==null || store.getOperatorId()==0){ |
| | | // 平台不分账 |
| | | }else{ |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(store.getOperatorId()); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(userCouponPayment1.getOrderNumber(), coupon.getCash().multiply(bigDecimal1), s2,"购买优惠券分账"); |
| | | if (!fenzhang.getCode().equals(200)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | }else{ |
| | | System.err.println("分账成功"); |
| | | return; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private ResultUtil AlipayPayment(BigDecimal cash, String code, Long returnId) { |
| | | ResultUtil alipay = payMoneyUtil.alipay("优惠卷", "优惠卷", String.valueOf(returnId), code, cash.toString(), |
| | | private ResultUtil AlipayPayment(Integer type, BigDecimal cash, String code, Long returnId) { |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营": type == 3 ? "购买门票" : "购买优惠券"); |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid,name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | |
| | | if ("TRADE_SUCCESS".equals(tradeStatus)) { |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setPaymentTime(new Date()); |
| | | userPointsMerchandise.setOrderNumber(tradeNo); |
| | | userPointsMerchandise.setPayType(2); |
| | | userPointsMerchandise.setCashPayType(2); |
| | | userPointsMerchandise.setInsertTime(null); |
| | | userPointsMerchandise.setUserId(null); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandise); |
| | | } |
| | | moneyOut(tradeNo, tradeNo); |
| | | break; |
| | | } |
| | | if ("TRADE_FINISHED".equals(tradeStatus)) { |
| | | // todo 资金结算 |
| | | payMoneyUtil.confirm(smid,code,tradeNo,cash.toString()); |
| | | break; |
| | | } |
| | | // if("REFUND".equals(tradeStatus) || "NOTPAY".equals(tradeStatus) || "CLOSED".equals(tradeStatus) || "REVOKED".equals(tradeStatus) || "PAYERROR".equals(tradeStatus) || num == 10){ |
| | |
| | | } |
| | | |
| | | |
| | | private ResultUtil WechatPayment(BigDecimal cash, String code) throws Exception { |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("课包", "", code, cash.toString(), |
| | | private ResultUtil WechatPayment(Integer type, BigDecimal cash, String code,Integer id) throws Exception { |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营": type == 3 ? "购买门票" : "购买优惠券"); |
| | | System.err.println("微信支付:"+name); |
| | | |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(id); |
| | | System.err.println("查询积分商品"+pointsMerchandise); |
| | | // 分账表示 0否1是 |
| | | String temp = "0"; |
| | | switch (type){ |
| | | case 1: |
| | | temp = "0"; |
| | | break; |
| | | case 2: |
| | | // 判断课包属于平台还是运营商 |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(pointsMerchandise.getCoursePackageId()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | if (store.getOperatorId() ==null || store.getOperatorId() == 0){ |
| | | // 平台课包 不分账 |
| | | }else{ |
| | | temp = "1"; |
| | | } |
| | | break; |
| | | case 3: |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | if (!integers.isEmpty()){ |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() ==null || store1.getOperatorId() == 0){ |
| | | // 平台门票 不分账 |
| | | }else{ |
| | | temp = "1"; |
| | | } |
| | | } |
| | | // 查询门票指定的门店 属于平台还是运营商 |
| | | break; |
| | | } |
| | | System.err.println("支付"); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(name+"-"+temp, "", code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback", "APP", ""); |
| | | System.err.println("提交支付"+weixinpay); |
| | | if (weixinpay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | List<UserPointsMerchandise> userPointsMerchandises = mcClient.queryUserPointMerchaseByCode(code); |
| | | if (userPointsMerchandises.get(0).getPayStatus() == 2) { |
| | | UserPointsMerchandise userPointsMerchandise = mcClient.queryUserPointMerchaseByCode(code).get(0); |
| | | if (userPointsMerchandise.getPayStatus() == 2) { |
| | | |
| | | |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, ""); |
| | | if (resultUtil.getCode() == 200 && userPointsMerchandises.get(0).getPayStatus() == 1) { |
| | | if (resultUtil.getCode() == 200 && userPointsMerchandise.getPayStatus() == 1) { |
| | | /** |
| | | * SUCCESS—支付成功, |
| | | * REFUND—转入退款, |
| | |
| | | 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) { |
| | | if ("REFUND".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); |
| | | userPointsMerchandise.setOrderNumber(transaction_id); |
| | | userPointsMerchandise.setPayType(1); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandise); |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setPaymentTime(new Date()); |
| | | userPointsMerchandise.setOrderNumber(transaction_id); |
| | | userPointsMerchandise.setCashPayType(1); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandise); |
| | | |
| | | TAppUser tAppUser = baseMapper.selectById(userPointsMerchandise.getUserId()); |
| | | dealAppUserIntegral(userPointsMerchandise.getUserId(), tAppUser, userPointsMerchandise.getIntegral()); |
| | | |
| | | //课程 |
| | | if(type == 2){ |
| | | CoursePackageOrder coursePackageOrder1 = paymentClient.getCoursePackageOrderByCode(code); |
| | | if(null != coursePackageOrder1){ |
| | | coursePackageOrder1.setPayStatus(2); |
| | | coursePackageOrder1.setOrderNumber(transaction_id); |
| | | coursePackageOrder1.setAppUserId(null); |
| | | paymentClient.updateCoursePackageOrder(coursePackageOrder1); |
| | | |
| | | GetCoursePackagePaymentConfig getCoursePackagePaymentConfig = new GetCoursePackagePaymentConfig(); |
| | | getCoursePackagePaymentConfig.setCoursePackageId(coursePackageOrder1.getCoursePackageId()); |
| | | getCoursePackagePaymentConfig.setClassHours(coursePackageOrder1.getClassHours()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = paymentClient.getCoursePackagePaymentConfig(getCoursePackagePaymentConfig); |
| | | |
| | | AddCoursePackageOrderStudent addCoursePackageOrderStudent = new AddCoursePackageOrderStudent(); |
| | | addCoursePackageOrderStudent.setCoursePackageOrderId(coursePackageOrder1.getId()); |
| | | addCoursePackageOrderStudent.setCoursePackagePaymentConfig(coursePackagePaymentConfig); |
| | | paymentClient.addCoursePackageOrderStudent(addCoursePackageOrderStudent); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | if ("USERPAYING".equals(s)) { |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber, Integer payType) { |
| | | List<UserPointsMerchandise> userPointsMerchandises = mcClient.queryUserPointMerchaseByCode(code); |
| | | if (userPointsMerchandises.get(0).getPayStatus() == 2) { |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) { |
| | | System.err.println("进入回调"+code); |
| | | UserPointsMerchandise userPointsMerchandise = mcClient.queryUserPointMerchaseByCode(code).get(0); |
| | | System.err.println("商品"+userPointsMerchandise); |
| | | if (userPointsMerchandise.getPayStatus() == 2) { |
| | | return ResultUtil.success(); |
| | | } |
| | | if (userPointsMerchandises.size() > 1) { |
| | | for (int i = 0; i < userPointsMerchandises.size(); i++) { |
| | | userPointsMerchandises.get(i).setOrderNumber(orderNumber + "-" + (i + 1)); |
| | | userPointsMerchandises.get(i).setPayType(payType); |
| | | userPointsMerchandises.get(i).setPayStatus(2); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandises.get(i)); |
| | | |
| | | Integer pointsMerchandiseId = userPointsMerchandises.get(i).getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | switch (pointsMerchandise.getType()) { |
| | | userPointsMerchandise.setOrderNumber(orderNumber); |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setPaymentTime(new Date()); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandise); |
| | | |
| | | TAppUser tAppUser = baseMapper.selectById(userPointsMerchandise.getUserId()); |
| | | dealAppUserIntegral(userPointsMerchandise.getUserId(), tAppUser, userPointsMerchandise.getIntegral()); |
| | | |
| | | Integer pointsMerchandiseId = userPointsMerchandise.getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | if(pointsMerchandise.getType() == 2){ |
| | | //课程 |
| | | CoursePackageOrder coursePackageOrder1 = paymentClient.getCoursePackageOrderByCode(code); |
| | | if(null != coursePackageOrder1){ |
| | | coursePackageOrder1.setPayStatus(2); |
| | | coursePackageOrder1.setOrderNumber(orderNumber); |
| | | coursePackageOrder1.setAppUserId(null); |
| | | paymentClient.updateCoursePackageOrder(coursePackageOrder1); |
| | | |
| | | GetCoursePackagePaymentConfig getCoursePackagePaymentConfig = new GetCoursePackagePaymentConfig(); |
| | | getCoursePackagePaymentConfig.setCoursePackageId(coursePackageOrder1.getCoursePackageId()); |
| | | getCoursePackagePaymentConfig.setClassHours(coursePackageOrder1.getClassHours()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = paymentClient.getCoursePackagePaymentConfig(getCoursePackagePaymentConfig); |
| | | |
| | | AddCoursePackageOrderStudent addCoursePackageOrderStudent = new AddCoursePackageOrderStudent(); |
| | | addCoursePackageOrderStudent.setCoursePackageOrderId(coursePackageOrder1.getId()); |
| | | addCoursePackageOrderStudent.setCoursePackagePaymentConfig(coursePackagePaymentConfig); |
| | | paymentClient.addCoursePackageOrderStudent(addCoursePackageOrderStudent); |
| | | } |
| | | } |
| | | // 创建一个2分钟后执行的线程 |
| | | new Thread(() -> { |
| | | try { |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | Thread.sleep(1000 * 60 * 2); |
| | | // 分账表示 0否1是 |
| | | String temp = "0"; |
| | | // 运营商id |
| | | Integer operatorId = 0; |
| | | System.err.println("商品"+pointsMerchandise); |
| | | switch (pointsMerchandise.getType()){ |
| | | case 1: |
| | | temp = "0"; |
| | | break; |
| | | case 2: |
| | | List<TCoursePackagePayment> coursePackagePaymentOfCode = paymentClient.getCoursePackagePaymentOfCode(code); |
| | | for (TCoursePackagePayment coursePackagePayment : coursePackagePaymentOfCode) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setPayType(payType); |
| | | coursePackagePayment.setOrderNumber(orderNumber); |
| | | coursePackagePayment.setCashPayment(pointsMerchandise.getCash()); |
| | | paymentClient.updatePaymentCoursePackage(coursePackagePayment); |
| | | // 判断课包属于平台还是运营商 |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(pointsMerchandise.getCoursePackageId()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | if (store.getOperatorId() ==null || store.getOperatorId() == 0){ |
| | | // 平台课包 不分账 |
| | | }else{ |
| | | temp = "1"; |
| | | operatorId = store.getOperatorId(); |
| | | } |
| | | break; |
| | | case 4: |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |
| | | case 3: |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | System.err.println("门店ids"+integers); |
| | | if (!integers.isEmpty()){ |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() ==null || store1.getOperatorId() == 0){ |
| | | // 平台门票 不分账 |
| | | }else{ |
| | | temp = "1"; |
| | | operatorId = store1.getOperatorId(); |
| | | } |
| | | } |
| | | // 查询门票指定的门店 属于平台还是运营商 |
| | | break; |
| | | } |
| | | System.err.println("运营商id"+operatorId); |
| | | if (operatorId != 0) { |
| | | //课程 |
| | | if(pointsMerchandise.getType() == 2){ |
| | | //课程 |
| | | CoursePackageOrder coursePackageOrder1 = paymentClient.getCoursePackageOrderByCode(code); |
| | | if(null != coursePackageOrder1){ |
| | | coursePackageOrder1.setPayStatus(2); |
| | | coursePackageOrder1.setOrderNumber(orderNumber); |
| | | coursePackageOrder1.setAppUserId(null); |
| | | paymentClient.updateCoursePackageOrder(coursePackageOrder1); |
| | | |
| | | GetCoursePackagePaymentConfig getCoursePackagePaymentConfig = new GetCoursePackagePaymentConfig(); |
| | | getCoursePackagePaymentConfig.setCoursePackageId(coursePackageOrder1.getCoursePackageId()); |
| | | getCoursePackagePaymentConfig.setClassHours(coursePackageOrder1.getClassHours()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = paymentClient.getCoursePackagePaymentConfig(getCoursePackagePaymentConfig); |
| | | |
| | | AddCoursePackageOrderStudent addCoursePackageOrderStudent = new AddCoursePackageOrderStudent(); |
| | | addCoursePackageOrderStudent.setCoursePackageOrderId(coursePackageOrder1.getId()); |
| | | addCoursePackageOrderStudent.setCoursePackagePaymentConfig(coursePackagePaymentConfig); |
| | | paymentClient.addCoursePackageOrderStudent(addCoursePackageOrderStudent); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(operatorId); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(operatorId); |
| | | |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(orderNumber, coursePackageOrder1.getCashPayment().multiply(bigDecimal1), s2,"运动营商品"); |
| | | if (!fenzhang.getCode().equals(200)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | System.err.println("门票"); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(operatorId); |
| | | System.err.println("分账比例"+proportionByOperatorId); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(operatorId); |
| | | System.err.println("微信商户号"+s2); |
| | | |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(orderNumber, pointsMerchandise.getCash().multiply(bigDecimal1), s2,"门票"); |
| | | if (!fenzhang.getCode().equals(200)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } else { |
| | | userPointsMerchandises.get(0).setOrderNumber(orderNumber); |
| | | userPointsMerchandises.get(0).setPayType(payType); |
| | | userPointsMerchandises.get(0).setPayStatus(2); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandises.get(0)); |
| | | |
| | | Integer pointsMerchandiseId = userPointsMerchandises.get(0).getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | switch (pointsMerchandise.getType()) { |
| | | case 2: |
| | | List<TCoursePackagePayment> coursePackagePaymentOfCode = paymentClient.getCoursePackagePaymentOfCode(code); |
| | | |
| | | TCoursePackagePayment packagePayment = coursePackagePaymentOfCode.get(0); |
| | | packagePayment.setPayStatus(2); |
| | | packagePayment.setPayType(payType); |
| | | packagePayment.setOrderNumber(orderNumber); |
| | | packagePayment.setCashPayment(pointsMerchandise.getCash()); |
| | | paymentClient.updatePaymentCoursePackage(packagePayment); |
| | | break; |
| | | case 4: |
| | | UserCoupon coupon = new UserCoupon(); |
| | | coupon.setCouponId(userPointsMerchandises.get(0).getPointsMerchandiseId()); |
| | | coupon.setUserId(userPointsMerchandises.get(0).getUserId()); |
| | | coupon.setStatus(1); |
| | | coupon.setInsertTime(new Date()); |
| | | ucponClient.insertToAppuserCoupon(coupon); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | | } |
| | | |