From e030255c23c7ba3e2cbad1036a810d6d72fa864f Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 26 十月 2023 18:04:58 +0800
Subject: [PATCH] 修改bug
---
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java | 144 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 126 insertions(+), 18 deletions(-)
diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java
index b271101..fbd60e7 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java
@@ -1,6 +1,7 @@
package com.dsh.guns.modular.system.controller.code;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.feignClient.account.AppUserClient;
import com.dsh.course.feignClient.account.CityManagerClient;
import com.dsh.course.feignClient.account.model.CityManager;
@@ -15,19 +16,23 @@
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.modular.system.model.*;
+import com.dsh.guns.modular.system.model.TCoursePackagePayment;
+import com.dsh.guns.modular.system.model.dto.CoursePackage;
import com.dsh.guns.modular.system.service.ICityService;
import com.dsh.guns.modular.system.service.ICoursePackageService;
import com.dsh.guns.modular.system.service.IStoreService;
import com.dsh.guns.modular.system.util.ResultUtil;
+import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* 广告管理控制器
@@ -57,8 +62,7 @@
private CoursePackagePaymentConfigClient coursePackagePaymentConfigClient;
@Autowired
private CoursePackageClient coursePackageClient;
- @Autowired
- private SiteClient siteClient;
+
/**
* 跳转到购课记录页面
*/
@@ -80,31 +84,114 @@
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
model.addAttribute("list",list);
Integer roleType = UserExt.getUser().getObjectType();
+ if (roleType==2){
+ Integer objectId = UserExt.getUser().getObjectId();
+ List<TStore> operatorId = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId));
+ model.addAttribute("stores",operatorId);
+ }else{
+ model.addAttribute("stores",new ArrayList<>());
+ }
+ // 获取所有课包类型
+ List<TCoursePackageType> tCoursePackageTypes = coursePackageTypeClient.queryAllCoursePackageType();
model.addAttribute("roleType",roleType);
+ if(UserExt.getUser().getObjectType()==3){
+ List<TStore> list1 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getId, UserExt.getUser().getObjectId()));
+ model.addAttribute("stores",list1);
+ }
+ model.addAttribute("coursePackageType",tCoursePackageTypes);
return PREFIX + "cpPayment_add.html";
}
/**
* 添加购课记录
*/
@ResponseBody
- @RequestMapping(value = "/addCoursePackagePayment")
- public ResultUtil addCoach(@RequestBody TCoursePackagePayment tCoursePackagePayment) {
+ @PostMapping(value = "/addCoursePackagePayment/{id}")
+ public ResultUtil addCoach(@RequestBody TCoursePackagePayment tCoursePackagePayment, @PathVariable("id")Integer id) {
Integer objectId = UserExt.getUser().getObjectId();
+ Integer objectType = UserExt.getUser().getObjectType();
+ String name = UserExt.getUser().getName();
tCoursePackagePayment.setPayUserId(objectId);
// 获取课包id
Integer coursePackageId = tCoursePackagePayment.getCoursePackageId();
-
List<TCoursePackageDiscount> list = coursePackageDiscountClient.queryByCoursePackageId(coursePackageId);
- TCoursePackageDiscount tCoursePackageDiscount1 = list.get(0);
- Integer coursePackagePaymentConfigId = tCoursePackageDiscount1.getCoursePackagePaymentConfigId();
- List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(coursePackageId);
- // 获取siteId 判断预约人数
- // todo
+ // 获取当前课包价格配置
Integer coursePackageId1 = tCoursePackagePayment.getCoursePackageId();
TCoursePackage tCoursePackage = coursePackageClient.queryById(coursePackageId1);
- Integer siteId = tCoursePackage.getSiteId();
-// tCoursePackagePayment.setCashPayment();
-// tCoursePackagePayment.setPlayPaiCoin();
+ Date currentDate = new Date();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(currentDate);
+ calendar.add(Calendar.DAY_OF_MONTH, 20);
+ Date updatedDate = calendar.getTime();
+ tCoursePackagePayment.setOriginalPrice(tCoursePackagePayment.getCashPayment().doubleValue());
+ tCoursePackagePayment.setUseTime(updatedDate);
+ // 查询当前课包有没有课包折扣
+ List<TCoursePackageDiscount> tCoursePackageDiscounts = coursePackageDiscountClient.queryByCoursePackageId(coursePackageId);
+ // 判断当前用户是不是会员
+ Integer appUserId = tCoursePackagePayment.getAppUserId();
+ Date vipEndTime = appUserClient.queryAppUser1(appUserId).getVipEndTime();
+ for (TCoursePackageDiscount tCoursePackageDiscount : tCoursePackageDiscounts) {
+ JSONObject jsonObject = JSONObject.fromObject(tCoursePackageDiscount.getContent());
+ switch (tCoursePackageDiscount.getType()){
+ case 1:
+ // 是会员
+ if (!vipEndTime.before(new Date())){
+ // 会员折扣金额
+ double discountMember = jsonObject.getDouble("discountMember");
+ Double aDouble = new Double(discountMember);
+ if (aDouble!=null){
+ String value = String.valueOf(discountMember);
+ BigDecimal bigDecimal = new BigDecimal(value);
+ tCoursePackagePayment.setCashPayment(bigDecimal);
+ }
+ }
+ break;
+ case 2:
+ // 判断当前用户是否已经购买过当前课包
+ List<com.dsh.course.feignClient.course.model.TCoursePackagePayment> result= coursePackagePaymentClient.getByUserIdAndCoursePackageId(tCoursePackagePayment.getAppUserId(),tCoursePackagePayment.getCoursePackageId());
+ // 已经购买了
+ if (result.size()!=0){
+ // 会员续课折扣
+ double continuingMember = jsonObject.getDouble("continuingMember");
+ // 用户续课折扣
+ double continuingUser = jsonObject.getDouble("continuingUser");
+ // 是会员享受会员续课折扣
+ if (!vipEndTime.before(new Date())){
+ String value = String.valueOf(continuingMember);
+ BigDecimal bigDecimal = new BigDecimal(value);
+ tCoursePackagePayment.setCashPayment(bigDecimal);
+ }else{ // 否则享受用户续课折扣
+ String value = String.valueOf(continuingUser);
+ BigDecimal bigDecimal = new BigDecimal(value);
+ tCoursePackagePayment.setCashPayment(bigDecimal);
+ }
+ }
+ break;
+ case 3:
+ // 限时折扣判断是否在有效期
+ String timeFrameStart = jsonObject.getString("timeFrameStart");
+ String timeFrameEnd = jsonObject.getString("timeFrameEnd");
+ SimpleDateFormat format = new SimpleDateFormat(timeFrameStart);
+ SimpleDateFormat format1 = new SimpleDateFormat(timeFrameEnd);
+ try {
+ Date parse = format.parse(timeFrameStart);
+ Date parse1 = format1.parse(timeFrameEnd);
+ if (new Date().after(parse) && new Date().before(parse1)){
+ double continuingMember = jsonObject.getDouble("discountMember");
+ String value = String.valueOf(continuingMember);
+ BigDecimal bigDecimal = new BigDecimal(value);
+ tCoursePackagePayment.setCashPayment(bigDecimal);
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ break;
+ case 4:
+ // 赠送课时
+
+ break;
+ }
+ }
+ coursePackagePaymentClient.addCoursePackagePayment(tCoursePackagePayment);
return ResultUtil.success("添加成功");
}
/**
@@ -113,11 +200,24 @@
@RequestMapping(value = "/listAll")
@ResponseBody
public List<CoursePackagePaymentVO> listAll(CoursePackagePaymentQuery query) {
+ Integer objectType = UserExt.getUser().getObjectType();
+ List<Integer> ids =new ArrayList<>();
+ if(objectType==3){
+ // 找出当前门店的课包
+ ids = coursePackageClient.queryIdsByStore(UserExt.getUser().getObjectId());
+ query.setIds(ids);
+ }
+ if (objectType == 2){
+ Integer objectId = UserExt.getUser().getObjectId();
+ List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId))
+ .stream().map(TStore::getId).collect(Collectors.toList());
+ query.setStoreIds(operatorId);
+ }
return coursePackagePaymentClient.listAll(query);
}
/**
- * 获取列表
+ * 手动支付
*/
@RequestMapping(value = "/pay")
@ResponseBody
@@ -156,6 +256,14 @@
return storeClient.getStore(city);
}
+ /**
+ * 根据课包id 获取课时规格
+ */
+ @RequestMapping(value = "/getCoursePackageConfig")
+ @ResponseBody
+ public List<CoursePackagePaymentConfig> getCoursePackageConfig(Integer id) {
+ return coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
+ }
}
--
Gitblit v1.7.1