| | |
| | | import com.dsh.course.entity.CoursePackagePaymentConfig; |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.dsh.course.entity.TCoursePackageDiscount; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | | import com.dsh.course.feignclient.account.StudentClient; |
| | | import com.dsh.course.feignclient.account.model.AppUser; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.feignclient.activity.CouponClient; |
| | | import com.dsh.course.feignclient.activity.UserCouponClient; |
| | | import com.dsh.course.feignclient.activity.model.Coupon; |
| | | import com.dsh.course.feignclient.activity.model.UserCoupon; |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.mapper.TCoursePackageMapper; |
| | |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.util.GDMapGeocodingUtil; |
| | | import com.dsh.course.util.GeodesyUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | @Resource |
| | | private UserCouponClient userCouponClient; |
| | | |
| | | @Resource |
| | | private CouponClient couponClient; |
| | | |
| | | |
| | | |
| | |
| | | coursePackageInfo.setStoreAddress(store.getAddress()); |
| | | coursePackageInfo.setLon(store.getLon()); |
| | | coursePackageInfo.setLat(store.getLat()); |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | coursePackageInfo.setDistance(wgs84); |
| | | if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){ |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | coursePackageInfo.setDistance(wgs84); |
| | | } |
| | | |
| | | String[] split = coursePackage.getClassWeeks().split(";"); |
| | | coursePackageInfo.setWeeks(Arrays.asList(split)); |
| | |
| | | coursePackagePaymentConfigVo.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType()); |
| | | coursePackagePaymentConfigVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低) |
| | | //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | |
| | | coursePackageInfo.setStudent(studentVo); |
| | | return coursePackageInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程包名支付 |
| | | * @param uid |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil paymentCourse(Integer uid, PaymentCourseVo paymentCourseVo) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | CoursePackageInfo coursePackageInfo = queryCourseInfo(uid, paymentCourseVo.getId(), null, null); |
| | | List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList(); |
| | | |
| | | String[] students = paymentCourseVo.getStudentIds().split(";"); |
| | | for (CoursePackagePaymentConfigVo coursePackagePaymentConfigVo : list) { |
| | | if(paymentCourseVo.getCoursePackagePaymentConfigId().compareTo(coursePackagePaymentConfigVo.getId()) == 0){ |
| | | Integer payType = coursePackagePaymentConfigVo.getPayType(); |
| | | if(payType == 1 && paymentCourseVo.getPayType() == 3){//现金支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | } |
| | | if(payType == 2 && paymentCourseVo.getPayType() != 3){//玩湃币支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | } |
| | | Double paymentPrice = coursePackagePaymentConfigVo.getPaymentPrice();//支付价 |
| | | paymentPrice = new BigDecimal(students.length).multiply(new BigDecimal(paymentPrice)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | Double playPaiCoin = coursePackagePaymentConfigVo.getPlayPaiCoin().doubleValue();//支付币 |
| | | playPaiCoin = new BigDecimal(students.length).multiply(new BigDecimal(playPaiCoin)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | if(payType == 1 && paymentPrice.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | if(payType == 2 && playPaiCoin.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Double price = paymentCourseVo.getPrice();//支付金额 |
| | | |
| | | //校验优惠券 |
| | | Long couponId = paymentCourseVo.getCouponId(); |
| | | if(null != couponId && paymentCourseVo.getPayType() != 3){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); |
| | | if(userCoupon.getStatus() == 2){ |
| | | return ResultUtil.error("优惠券已被核销"); |
| | | } |
| | | Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); |
| | | long time = coupon.getEndTime().getTime(); |
| | | if(System.currentTimeMillis() >= time){ |
| | | return ResultUtil.error("优惠券已过期"); |
| | | } |
| | | if(coupon.getType() == 1){//满减 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("num1"); |
| | | Double num2 = jsonObject.getDouble("num2"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | |
| | | price = new BigDecimal(price).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | if(coupon.getType() == 2){//代金券 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("num1"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | price = new BigDecimal(price).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | } |
| | | |
| | | if(paymentCourseVo.getPayType() == 1){//微信支付 |
| | | |
| | | } |
| | | if(paymentCourseVo.getPayType() == 2){//支付宝支付 |
| | | |
| | | } |
| | | if(paymentCourseVo.getPayType() == 3){//玩湃币支付 |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public ResultUtil weChatPaymentCourse(Integer uid, PaymentCourseVo paymentCourseVo){ |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | // coursePackagePayment |
| | | return ResultUtil.success(); |
| | | } |
| | | } |