44323
2023-12-28 c31f9914a85889bbe090d907ed53cc7a2fdcf8b6
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/CoursePackagePaymentController.java
@@ -13,20 +13,26 @@
import com.dsh.course.feignClient.other.SiteClient;
import com.dsh.course.feignClient.other.StoreClient;
import com.dsh.course.feignClient.other.model.Banner;
import com.dsh.course.util.UUIDUtil;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.modular.system.model.*;
import com.dsh.course.entity.CoursePackageOrderStudent;
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.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -93,8 +99,6 @@
        if(UserExt.getUser().getObjectType()==3){
            List<TStore> list1 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getId, UserExt.getUser().getObjectId()));
            model.addAttribute("stores",list1);
        }else {
            model.addAttribute("stores",new ArrayList<>());
        }
        model.addAttribute("coursePackageType",tCoursePackageTypes);
        return PREFIX + "cpPayment_add.html";
@@ -103,8 +107,8 @@
     *  添加购课记录
     */
    @ResponseBody
    @PostMapping(value = "/addCoursePackagePayment/{id}")
    public ResultUtil addCoach(@RequestBody TCoursePackagePayment tCoursePackagePayment, @PathVariable("id")Integer id) {
    @PostMapping(value = "/addCoursePackagePayment")
    public Object addCoach(@RequestBody TCoursePackagePayment tCoursePackagePayment) {
        Integer objectId = UserExt.getUser().getObjectId();
        Integer objectType = UserExt.getUser().getObjectType();
        String name = UserExt.getUser().getName();
@@ -112,26 +116,32 @@
        // 获取课包id
        Integer coursePackageId = tCoursePackagePayment.getCoursePackageId();
        List<TCoursePackageDiscount> list = coursePackageDiscountClient.queryByCoursePackageId(coursePackageId);
        // 获取当前课包价格配置
        CoursePackagePaymentConfig coursePackagePaymentConfigs = coursePackagePaymentConfigClient.getById(id);
        Integer coursePackageId1 = tCoursePackagePayment.getCoursePackageId();
        TCoursePackage tCoursePackage = coursePackageClient.queryById(coursePackageId1);
        Double cashPayment = coursePackagePaymentConfigs.getCashPayment();
        String c1 = Double.toString(cashPayment);
        BigDecimal bigDecimal = new BigDecimal(c1);
        tCoursePackagePayment.setCashPayment(bigDecimal);
        Date currentDate = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(currentDate);
        calendar.add(Calendar.DAY_OF_MONTH, 20);
        Date updatedDate = calendar.getTime();
        tCoursePackagePayment.setOriginalPrice(cashPayment);
        tCoursePackagePayment.setUseTime(updatedDate);
        tCoursePackagePayment.setPlayPaiCoin(coursePackagePaymentConfigs.getPlayPaiCoin());
        coursePackagePaymentClient.addCoursePackagePayment(tCoursePackagePayment);
        return ResultUtil.success("添加成功");
        tCoursePackagePayment.setOriginalPrice(tCoursePackagePayment.getCashPayment().doubleValue());
        // 获取所选课时的课包价格配置
        if (tCoursePackagePayment.getCoursePackageConfigId()!=null) {
            List<CoursePackagePaymentConfig> coursePackagePaymentConfigs =
                    coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList1
                            (tCoursePackagePayment.getCoursePackageConfigId());
            if (coursePackagePaymentConfigs.size() != 0) {
                CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigs.get(0);
                tCoursePackagePayment.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
            }
        }else {
            List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(coursePackageId);
            CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigs.get(0);
            tCoursePackagePayment.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
        tCoursePackagePayment.setCode(code);
        return coursePackagePaymentClient.addCoursePackagePayment(tCoursePackagePayment);
    }
    /**
     * 获取列表
     */
@@ -200,9 +210,20 @@
    @RequestMapping(value = "/getCoursePackageConfig")
    @ResponseBody
    public List<CoursePackagePaymentConfig> getCoursePackageConfig(Integer id) {
        if (id == null){
            return null;
        }
        return coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
    }
    @RequestMapping(value = "/getCoursePackageType")
    @ResponseBody
    public Integer getCoursePackageType(Integer id) {
        TCoursePackage coursePackage = coursePackageClient.queryById(id);
        return coursePackage.getType();
    }
}