Просмотр исходного кода

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 3 лет назад
Родитель
Сommit
2e261c349a

+ 15 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/CourseDO.java

@ -8,6 +8,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
@ -83,6 +84,11 @@ public class CourseDO extends UuidIdentityEntityWithOperator {
     */
    private Integer del;
    /**
     * 小节
     */
    List<CourseCatalogueDO> catalogueDOList;
    @Column(name = "type")
    public String getType() {
        return type;
@ -236,4 +242,13 @@ public class CourseDO extends UuidIdentityEntityWithOperator {
    public void setLiveDuration(String liveDuration) {
        this.liveDuration = liveDuration;
    }
    @Transient
    public List<CourseCatalogueDO> getCatalogueDOList() {
        return catalogueDOList;
    }
    public void setCatalogueDOList(List<CourseCatalogueDO> catalogueDOList) {
        this.catalogueDOList = catalogueDOList;
    }
}

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/PatientOrderRefundDO.java

@ -154,8 +154,8 @@ public class PatientOrderRefundDO extends UuidIdentityEntity{
        this.refundTime = refundTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
@ -164,8 +164,8 @@ public class PatientOrderRefundDO extends UuidIdentityEntity{
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "buy_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getBuyTime() {
        return buyTime;
    }

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/DoctorCourseEndpoint.java

@ -1,10 +1,22 @@
package com.yihu.jw.care.endpoint.course;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.course.CourseService;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
@ -17,4 +29,27 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "医生课程信息", description = "医生课程信息")
public class DoctorCourseEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private CourseService courseService;
    @GetMapping(value = "myCourseList")
    @ApiOperation(value = "我的课程列表")
    public PageEnvelop myCourseList(
            @ApiParam(name = "doctor", value = "doctor") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "type", value = "课程类型 1直播 2视频 3文本") @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "3") @RequestParam(value = "size") int size) {
        try{
            JSONObject result = courseService.myCourseList(doctor, type, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            Long count = result.getLongValue(ResponseContant.count);
            return PageEnvelop.getSuccessListWithPage("查询成功",(List<CourseDO>)result.get(ResponseContant.resultMsg),page,size,count);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError("查询失败");
    }
}

+ 101 - 15
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -1,8 +1,14 @@
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.course.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
@ -10,10 +16,13 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
@ -47,6 +56,10 @@ public class CourseService {
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private PatientOrderRefundDao patientOrderRefundDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    public String getOrderNo(String type){
        return type + System.currentTimeMillis()+(int)(Math.random() * 900)+100 +"";
@ -110,22 +123,26 @@ public class CourseService {
        if(flag){
            //支付信息
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(id);
            JSONObject json = new JSONObject();
            json.put("payPrice",businessOrderDO.getPayPrice());
            json.put("payTime",businessOrderDO.getPayTime());
            json.put("payType",businessOrderDO.getPayType());
            resJson.put("businessOrderDO",json);
            if(businessOrderDO!=null){
                JSONObject json = new JSONObject();
                json.put("payPrice",businessOrderDO.getPayPrice());
                json.put("payTime",DateUtil.dateToStrLong(businessOrderDO.getPayTime()));
                json.put("payType",businessOrderDO.getPayType());
                resJson.put("businessOrderDO",json);
            }
        }
        if("5".equals(status)||"6".equals(status)){
            //退款信息
            PatientOrderRefundDO refundDO = patientOrderRefundDao.findByTypeAndOrderId(type,id);
            JSONObject json = new JSONObject();
            json.put("createTime",refundDO.getCreateTime());
            json.put("refundPrice",refundDO.getRefundPrice());
            json.put("status",refundDO.getStatus());
            json.put("refundDesc",refundDO.getRefundDesc());
            json.put("enclosure",refundDO.getEnclosure());
            resJson.put("refundDO",json);
            if(refundDO!=null){
                JSONObject json = new JSONObject();
                json.put("createTime", DateUtil.dateToStrLong(refundDO.getCreateTime()));
                json.put("refundPrice",refundDO.getRefundPrice());
                json.put("status",refundDO.getStatus());
                json.put("refundDesc",refundDO.getRefundDesc());
                json.put("enclosure",refundDO.getEnclosure());
                resJson.put("refundDO",json);
            }
        }
        return resJson;
@ -167,6 +184,75 @@ public class CourseService {
        return map;
    }
    /**
     * 新增课程
     * @param doctorId
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject addCourse(String doctorId,String jsonData){
        JSONObject result = new JSONObject();
        JSONObject json = JSON.parseObject(jsonData);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
        CourseDO courseDO = null;
        try{
            courseDO = objectMapper.readValue(json.getJSONObject("course").toString(), CourseDO.class);
        }catch (Exception e){
            e.printStackTrace();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "传参有误");
        }
        courseDO.setStatus("1");
        courseDO.setDel(1);
        courseDO.setDoctor(doctorId);
        courseDO.setDoctorName(doctorDO.getName());
        courseDO.setOrgCode(baseDoctorHospitalDO.get(0).getOrgCode());
        courseDO.setOrgName(baseDoctorHospitalDO.get(0).getOrgName());
        if("1".equals(courseDO.getType())){
            //直播课程
            courseDO.setLiveStatus("1");
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        return result;
    }
    /**
     * 教师我的课程
     * @param doctor
     * @param page
     * @param size
     * @return
     */
    public JSONObject myCourseList(String doctor,String type, int page, int size) {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 3 : size;
        String filter = " where a.doctor = '"+doctor+"' ";
        if(!StringUtil.isBlank(type)){
            filter += " and a.type = '"+type+"' ";
        }
        String sql = "SELECT * from base_course a " +filter +
                " ORDER BY a.create_time desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT count(a.id) FROM base_course a " +filter ;
        List<CourseDO> sqlResultlist = jdbcTemplate.query(finalSql,new BeanPropertyRowMapper<>(CourseDO.class));
        Long count = jdbcTemplate.queryForObject(countSql, Long.class);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 居民我的订单列表
@ -185,14 +271,14 @@ public class CourseService {
            filter += " and status = "+ status +" ";
        }
        String sqlUnion = " SELECT id,`status`,recruit_name title,pay_type payType,price,1 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTtime " +
        String sqlUnion = " SELECT id,`status`,recruit_name title,pay_type payType,price,1 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTime " +
                " from base_recruit_students_record " + filter+
                " UNION ALL " +
                " SELECT id,`status`,course_name title,pay_type payType,price,2 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTtime  " +
                " SELECT id,`status`,course_name title,pay_type payType,price,2 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTime  " +
                " from base_course_sales_order_record " + filter+" ";
        String sql = "SELECT * from ( " + sqlUnion + " ) a " +
                " ORDER BY a.createTtime desc " +
                " ORDER BY a.createTime desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));

+ 0 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -1,7 +1,6 @@
package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.sun.xml.internal.rngom.parse.host.Base;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;