| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.UuidUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | 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.entity.*; |
| | | 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.mapper.TCoursePackageMapper; |
| | | import com.dsh.course.feignclient.model.CourseOfStoreVo; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.service.ICoursePackagePaymentConfigService; |
| | | import com.dsh.course.service.TCoursePackageDiscountService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | 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 com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import com.dsh.course.util.httpClinet.HttpResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Resource |
| | | private CouponClient couponClient; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(coursePackage.getId()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours limit 0, 1")); |
| | | .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours").last(" limit 0, 1")); |
| | | CoursePackageListVo coursePackageListVo = new CoursePackageListVo(); |
| | | coursePackageListVo.setId(coursePackage.getId()); |
| | | coursePackageListVo.setName(coursePackage.getName()); |
| | |
| | | coursePackageListVo.setClassStartTime(coursePackage.getClassStartTime() + "-" + coursePackage.getClassEndTime()); |
| | | coursePackageListVo.setApplicantsNumber(integer); |
| | | coursePackageListVo.setPayType(coursePackage.getPayType()); |
| | | coursePackageListVo.setPlayPaiCoin(coursePackageListVo.getPlayPaiCoin()); |
| | | coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | |
| | | //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1"); |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1"); |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1"); |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1"); |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | StudentVo studentVo = new StudentVo(); |
| | | studentVo.setId(student.getId()); |
| | | studentVo.setPhone(student.getPhone()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(student.getBirthday()))); |
| | | if(null != student){ |
| | | studentVo.setId(student.getId()); |
| | | studentVo.setPhone(student.getPhone()); |
| | | studentVo.setName(student.getName()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(student.getBirthday()))); |
| | | } |
| | | coursePackageInfo.setStudent(studentVo); |
| | | return coursePackageInfo; |
| | | } |
| | |
| | | } |
| | | if(coupon.getType() == 1){//满减 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("num1"); |
| | | Double num2 = jsonObject.getDouble("num2"); |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | |
| | | } |
| | | if(coupon.getType() == 2){//代金券 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("num1"); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | |
| | | } |
| | | |
| | | if(paymentCourseVo.getPayType() == 1){//微信支付 |
| | | |
| | | return weChatPaymentCourse(uid, price, paymentCourseVo); |
| | | } |
| | | if(paymentCourseVo.getPayType() == 2){//支付宝支付 |
| | | |
| | | return aliPaymentCourse(uid, price, paymentCourseVo); |
| | | } |
| | | if(paymentCourseVo.getPayType() == 3){//玩湃币支付 |
| | | |
| | | if(appUser.getPlayPaiCoins() < price.intValue()){ |
| | | return ResultUtil.error("报名失败,玩湃币不足,请充值!"); |
| | | } |
| | | return playPaiCoinPaymentCourse(appUser, price, paymentCourseVo); |
| | | } |
| | | return null; |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | public ResultUtil weChatPaymentCourse(Integer uid, PaymentCourseVo paymentCourseVo){ |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | // coursePackagePayment |
| | | /** |
| | | * 课程微信支付 |
| | | * @param uid |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil weChatPaymentCourse(Integer uid, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(uid); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId()); |
| | | coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice)); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(1); |
| | | coursePackagePayment.setPayUserId(uid); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | } |
| | | |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("购买课程", "", code, paymentPrice.toString(), "/base/course/weChatPaymentCourseCallback", "APP", ""); |
| | | if(weixinpay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 1)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, ""); |
| | | if(resultUtil.getCode() == 200 && one.getPayStatus() == 1){ |
| | | /** |
| | | * SUCCESS—支付成功, |
| | | * REFUND—转入退款, |
| | | * NOTPAY—未支付, |
| | | * CLOSED—已关闭, |
| | | * REVOKED—已撤销(刷卡支付), |
| | | * USERPAYING--用户支付中, |
| | | * PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | */ |
| | | 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){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(3); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("SUCCESS".equals(s)){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(transaction_id); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("USERPAYING".equals(s)){ |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return weixinpay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程支付宝支付 |
| | | * @param uid |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil aliPaymentCourse(Integer uid, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(uid); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId()); |
| | | coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice)); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(1); |
| | | coursePackagePayment.setPayUserId(uid); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | } |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay("购买课程", "购买课程", "", code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 2)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && one.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("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(3); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 玩湃币支付课程 |
| | | * @param appUser |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil playPaiCoinPaymentCourse(AppUser appUser, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(appUser.getId()); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue()); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setPayUserId(appUser.getId()); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | } |
| | | |
| | | Integer playPaiCoins = appUser.getPlayPaiCoins(); |
| | | appUser.setPlayPaiCoins(playPaiCoins - paymentPrice.intValue()); |
| | | appUserClient.updateAppUser(appUser); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包管理列表数据 |
| | | * @param queryCoursePackageLists |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryCoursePackageLists(Page<Map<String, Object>> page, QueryCoursePackageLists queryCoursePackageLists) { |
| | | List<Map<String, Object>> list = this.baseMapper.queryCoursePackageLists(page, queryCoursePackageLists); |
| | | for (Map<String, Object> map : list) { |
| | | Integer id = Integer.valueOf(map.get("id").toString()); |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(id); |
| | | map.put("paymentNumber", integer); |
| | | |
| | | boolean cash = false; |
| | | boolean coin = false; |
| | | List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id)); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : coursePackagePaymentConfigs) { |
| | | if(0 != coursePackagePaymentConfig.getCashPayment()){ |
| | | cash = true; |
| | | } |
| | | if(0 != coursePackagePaymentConfig.getPlayPaiCoin()){ |
| | | coin = true; |
| | | } |
| | | } |
| | | map.put("payType", (cash ? "现金支付" : "") + (coin ? cash ? "&玩湃币支付" : "玩湃币支付" : "")); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加课包 |
| | | * @param coursePackage |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer addCoursePackage(TCoursePackage coursePackage) { |
| | | try { |
| | | this.baseMapper.insert(coursePackage); |
| | | //生成排课数据 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date date = sdf1.parse(sdf.format(new Date()) + " 00:00:00"); |
| | | List<String> list = Arrays.asList(coursePackage.getClassWeeks().split(";")); |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String[] split = classStartTime.split(":"); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | String[] split1 = classEndTime.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | s.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 13); |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | | while (true){ |
| | | int w = s.get(Calendar.DAY_OF_WEEK); |
| | | WeekEnum weekEnum = WeekEnum.getWeekEnum(w); |
| | | if(list.contains(weekEnum.getChineseName())){ |
| | | Calendar classDate = Calendar.getInstance(); |
| | | classDate.setTime(s.getTime()); |
| | | classDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | classDate.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | classDate.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar endDate = Calendar.getInstance(); |
| | | endDate.setTime(s.getTime()); |
| | | endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split1[0])); |
| | | endDate.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | endDate.set(Calendar.SECOND, 0); |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(coursePackage.getId()); |
| | | coursePackageScheduling.setClassDate(classDate.getTime()); |
| | | coursePackageScheduling.setEndDate(endDate.getTime()); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | } |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | if(s.getTimeInMillis() > timeInMillis){ |
| | | break; |
| | | } |
| | | } |
| | | return coursePackage.getId(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * @param coursePackage |
| | | */ |
| | | @Override |
| | | public void updateCoursePackageById(TCoursePackage coursePackage) { |
| | | try { |
| | | List<CoursePackageStudent> coursePackageStudents = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("coursePackageId", coursePackage.getId())); |
| | | List<Long> collect = coursePackageStudents.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | QueryWrapper<CoursePackageScheduling> coursePackageSchedulingQueryWrapper = new QueryWrapper<CoursePackageScheduling>().eq("coursePackageId", coursePackage.getId()); |
| | | if(collect.size() > 0){ |
| | | coursePackageSchedulingQueryWrapper.notIn("id", collect); |
| | | } |
| | | coursePackageSchedulingService.remove(coursePackageSchedulingQueryWrapper); |
| | | |
| | | this.baseMapper.updateById(coursePackage); |
| | | //生成排课数据 |
| | | Date date = null; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingService.getOne(new QueryWrapper<CoursePackageScheduling>().eq("coursePackageId", coursePackage.getId()).last(" and classDate > now() order by classDate desc limit 0, 1")); |
| | | if(null != coursePackageScheduling){ |
| | | date = sdf1.parse(sdf.format(coursePackageScheduling.getClassDate()) + " 00:00:00"); |
| | | }else{ |
| | | date = sdf1.parse(sdf.format(new Date()) + " 00:00:00"); |
| | | } |
| | | List<String> list = Arrays.asList(coursePackage.getClassWeeks().split(";")); |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String[] split = classStartTime.split(":"); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | String[] split1 = classEndTime.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | if(null != coursePackageScheduling){ |
| | | long time = sdf1.parse(sdf.format(new Date()) + " 00:00:00").getTime(); |
| | | int d = Long.valueOf(14L - ((s.getTimeInMillis() - time) / 86400000L)).intValue(); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + d); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 13); |
| | | } |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | | while (true){ |
| | | int w = s.get(Calendar.DAY_OF_WEEK); |
| | | WeekEnum weekEnum = WeekEnum.getWeekEnum(w); |
| | | if(list.contains(weekEnum.getChineseName())){ |
| | | Calendar classDate = Calendar.getInstance(); |
| | | classDate.setTime(s.getTime()); |
| | | classDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | classDate.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | classDate.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar endDate = Calendar.getInstance(); |
| | | endDate.setTime(s.getTime()); |
| | | endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split1[0])); |
| | | endDate.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | endDate.set(Calendar.SECOND, 0); |
| | | |
| | | CoursePackageScheduling coursePackageScheduling1 = new CoursePackageScheduling(); |
| | | coursePackageScheduling1.setCoursePackageId(coursePackage.getId()); |
| | | coursePackageScheduling1.setClassDate(classDate.getTime()); |
| | | coursePackageScheduling1.setEndDate(endDate.getTime()); |
| | | coursePackageScheduling1.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling1); |
| | | } |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | if(s.getTimeInMillis() > timeInMillis){ |
| | | break; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包审核列表 |
| | | * @param page |
| | | * @param queryExamineCoursePackageLists |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryExamineCoursePackageLists(Page<Map<String, Object>> page, QueryExamineCoursePackageLists queryExamineCoursePackageLists) { |
| | | List<Map<String, Object>> list = this.baseMapper.queryExamineCoursePackageLists(page, queryExamineCoursePackageLists); |
| | | for (Map<String, Object> map : list) { |
| | | Integer id = Integer.valueOf(map.get("id").toString()); |
| | | boolean cash = false; |
| | | boolean coin = false; |
| | | List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id)); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : coursePackagePaymentConfigs) { |
| | | if(0 != coursePackagePaymentConfig.getCashPayment()){ |
| | | cash = true; |
| | | } |
| | | if(0 != coursePackagePaymentConfig.getPlayPaiCoin()){ |
| | | coin = true; |
| | | } |
| | | } |
| | | map.put("payType", (cash ? "现金支付" : "") + (coin ? cash ? "&玩湃币支付" : "玩湃币支付" : "")); |
| | | } |
| | | return list; |
| | | } |
| | | } |