Browse Source

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

shikejing 3 years ago
parent
commit
5c4d739940

+ 9 - 0
common/common-entity/sql记录

@ -888,3 +888,12 @@ ALTER table base_org_notice add column create_user varchar(50) DEFAULT NULL
ALTER table base.base_security_monitoring_order add column `order_source` tinyint(4) DEFAULT '1' COMMENT '工单发起来源状态 1APP 2手环3居家报警'
-- 2021-05-19
CREATE TABLE `base_course_catalogue_read_time` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL COMMENT '用户code',
  `course_catalogue_id` varchar(50) DEFAULT NULL COMMENT '课程目录id',
  `course_id` varchar(50) DEFAULT NULL COMMENT '课程id',
  `read_time` varchar(20) DEFAULT NULL COMMENT '阅读时间,保留时间戳格式,单位s',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='记录用户阅读课程时长';

+ 63 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/CourseCatalogueReadTimeDO.java

@ -0,0 +1,63 @@
package com.yihu.jw.entity.care.course;
import javax.persistence.Column;
/***
 * @ClassName: CourseCatalogueReadTimeDO
 * @Description: 记录用户阅读课程时长
 * @Auther: shi kejing
 * @Date: 2021/5/19 9:00
 */
public class CourseCatalogueReadTimeDO {
    private String id;
    private String patient;
    private String courseCatalogueId;
    private String courseId;
    private String readTime;
    @Column(name = "id")
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getCourseCatalogueId() {
        return courseCatalogueId;
    }
    public void setCourseCatalogueId(String courseCatalogueId) {
        this.courseCatalogueId = courseCatalogueId;
    }
    public String getCourseId() {
        return courseId;
    }
    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }
    public String getReadTime() {
        return readTime;
    }
    public void setReadTime(String readTime) {
        this.readTime = readTime;
    }
}

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

@ -13,6 +13,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -96,4 +97,171 @@ public class PatientCourseEndpoint extends EnvelopRestEndpoint {
            return Envelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseByCourse")
    @ApiOperation(value = "在线报名-根据课程展示")
    public ObjEnvelop getCourseByCourse(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude,
            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage) {
        try {
            JSONObject json = courseService.getCourseByCourse(longitude,latitude, pageSize, currentPage);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseByOrg")
    @ApiOperation(value = "在线报名-根据机构展示")
    public ObjEnvelop getCourseByOrg(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude
//            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
//            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage
    ) {
        try {
            JSONObject json = courseService.getCourseByOrg(longitude,latitude);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseByteacher")
    @ApiOperation(value = "在线报名-根据教师展示")
    public ObjEnvelop getCourseByteacher(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude
//            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
//            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage
    ) {
        try {
            JSONObject json = courseService.getCourseByteacher(longitude,latitude);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseInfo")
    @ApiOperation(value = "在线报名-获取课程详情")
    public ObjEnvelop getCourseInfo(
            @ApiParam(name = "id", value = "课程id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id
    ) {
        try {
            JSONObject json = courseService.getCourseInfo(id);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCatalogue")
    @ApiOperation(value = "在线报名-获取课程目录")
    public ObjEnvelop getCatalogue(
            @ApiParam(name = "id", value = "课程id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "patient", value = "居民code", defaultValue = "808080eb7955aa9301795b8bad3f0078") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            JSONObject json = courseService.getCatalogue(id,patient);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getOrgInfoById")
    @ApiOperation(value = "在线报名-获取机构详情")
    public ObjEnvelop getOrgInfoById(
            @ApiParam(name = "id", value = "机构id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id
    ) {
        try {
            JSONObject json = courseService.getOrgInfoById(id);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getTecInfoById")
    @ApiOperation(value = "在线报名-获取教师详情(根据教师id)")
    public ObjEnvelop getTecInfoById(
            @ApiParam(name = "doctor", value = "教师id", defaultValue = "402803816babc778016babca89ea0032") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "orgCode", value = "机构code", defaultValue = "xm10086") @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "page", value = "page", defaultValue = "1") @RequestParam(value = "page", required = true) int page,
            @ApiParam(name = "size", value = "size", defaultValue = "10") @RequestParam(value = "size", required = true) int size
    ) {
        try {
            JSONObject json = courseService.getTecInfoById(doctor,orgCode,page,size);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCoursrOrderStatusByPatient")
    @ApiOperation(value = "在线报名-获取居民订单(根据居民id)")
    public ObjEnvelop getCoursrOrderStatusByPatient(
            @ApiParam(name = "patient", value = "居民id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "status", defaultValue = "0") @RequestParam(value = "status", required = true) int status,
            @ApiParam(name = "page", value = "page", defaultValue = "1") @RequestParam(value = "page", required = true) int page,
            @ApiParam(name = "size", value = "size", defaultValue = "10") @RequestParam(value = "size", required = true) int size
    ) {
        try {
            JSONObject json = courseService.getCoursrOrderStatusByPatient(patient,status,page,size);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getOrderInfo")
    @ApiOperation(value = "在线报名-获取订单详情(根据orderId)")
    public ObjEnvelop getOrderInfo(
            @ApiParam(name = "根据orderId", value = "订单id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "根据orderId", required = true) String 根据orderId
    ) {
        try {
            JSONObject json = courseService.getOrderInfo(根据orderId);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    //购买课程
    @GetMapping("buyCourseOrder")
    @ApiOperation(value = "在线报名-购买课程")
    public ObjEnvelop buyCourseOrder(
            @ApiParam(name = "patient", value = "居民id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "patientName", value = "居民name", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "patientName", required = true) String patientName,
            @ApiParam(name = "courseId", value = "课程id", defaultValue = "1") @RequestParam(value = "courseId", required = true) String courseId,
            @ApiParam(name = "courseName", value = "课程name", defaultValue = "1") @RequestParam(value = "courseName", required = true) String courseName,
            @ApiParam(name = "orgCode", value = "机构code", defaultValue = "1") @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "orgName", value = "机构name", defaultValue = "1") @RequestParam(value = "orgName", required = true) String orgName,
            @ApiParam(name = "price", value = "居民id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "price", required = true) BigDecimal price,
            @ApiParam(name = "payType", value = "1-微信支付,2-线下支付", defaultValue = "1") @RequestParam(value = "payType", required = true) String payType
    ) {
        try {
            int json = courseService.buyCourseOrder(patient,patientName,courseId,courseName,orgCode,orgName,price,payType);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    //申请退款
    //直播间
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -8,12 +9,20 @@ 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.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
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.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -21,6 +30,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -55,6 +66,10 @@ public class CourseService {
    @Autowired
    private PatientOrderRefundDao patientOrderRefundDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
@ -121,26 +136,22 @@ public class CourseService {
        if(flag){
            //支付信息
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(id);
            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);
            }
            JSONObject json = new JSONObject();
            json.put("payPrice",businessOrderDO.getPayPrice());
            json.put("payTime",businessOrderDO.getPayTime());
            json.put("payType",businessOrderDO.getPayType());
            resJson.put("businessOrderDO",json);
        }
        if("5".equals(status)||"6".equals(status)){
            //退款信息
            PatientOrderRefundDO refundDO = patientOrderRefundDao.findByTypeAndOrderId(type,id);
            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);
            }
            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);
        }
        return resJson;
@ -321,14 +332,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') createTime " +
        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 " +
                " 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') createTime  " +
                " SELECT id,`status`,course_name title,pay_type payType,price,2 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTtime  " +
                " from base_course_sales_order_record " + filter+" ";
        String sql = "SELECT * from ( " + sqlUnion + " ) a " +
                " ORDER BY a.createTime desc " +
                " ORDER BY a.createTtime desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
@ -361,4 +372,310 @@ public class CourseService {
        return result;
    }
    //根据机构坐标进行排序
    public JSONObject getCourseByCourse(String lon2,String lat2, int pageSize,int currentPage){
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        List<Map<String , Object>> currentPageList = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,code,`name`,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                obj.put("code",mapList.get(0).get("code"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            List aList = new ArrayList();
            if (list.size() > 0){
                for (int i =0;i<list.size();i++){
                    String sql1 = "SELECT * FROM base_course WHERE del = 1 AND org_code = '"+list.get(i).get("code")+"'" ;
                    List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql1);
                    if (amapList.size() > 0){
                        aList.add(amapList.get(0));
                    }
                }
                if (aList.size() > 0 ){
                    if (aList != null && aList.size() > 0) {
                        int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
                        for (int i = 0; i < pageSize && i < aList.size() - currIdx; i++) {
                            Map<String, Object> data = (Map<String, Object>) aList.get(currIdx + i);
                            currentPageList.add(data);
                        }
                    }
                }
            }
            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseByOrg(String lon2,String lat2){ //, int pageSize,int currentPage
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,`name`,photo,address,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("photo",mapList.get(0).get("photo"));
                obj.put("address",mapList.get(0).get("address"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            object.put("object",list);
//            List<Map<String , Object>> currentPageList = new ArrayList<>();
//            if (list.size() > 0 ){
//                if (list != null && list.size() > 0) {
//                    int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
//                    for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
//                        Map<String, Object> data = list.get(currIdx + i);
//                        currentPageList.add(data);
//                    }
//                }
//            }
//            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseByteacher(String lon2,String lat2){ //, int pageSize,int currentPage
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        List<Map<String , Object>> currentPageList = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,`name`,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            List aList = new ArrayList();
            if (list.size() > 0){
                for (int i =0;i<list.size();i++){
                    String sql1 = "SELECT id,`name`,job_title_code,job_title_name,visit_hospital,visit_hospital_name FROM base_doctor WHERE doctor_level = 3 AND enabled = 1 AND locked = 0 AND del = 1 and  visit_hospital = '"+list.get(i).get("id")+"'" ;
                    List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql1);
                    if (amapList.size() > 0){
                        aList.add(amapList.get(0));
                    }
                }
            object.put("object",aList);
//                if (list.size() > 0 ){
//                    if (list != null && list.size() > 0) {
//                        int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
//                        for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
//                            Map<String, Object> data = list.get(currIdx + i);
//                            currentPageList.add(data);
//                        }
//                    }
//                }
            }
//            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseInfo(String id){
        JSONObject object = new JSONObject();
        String sql = "SELECT * FROM base_course WHERE id = '"+id+"' AND del = 1 ";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() > 0){
            object.put("doctor",mapList.get(0).get("doctor"));
            object.put("doctorName",mapList.get(0).get("doctor_name"));
            List<BaseDoctorHospitalDO> baseDoctorHospitalDO = doctorHospitalDao.findByDoctorCode(mapList.get(0).get("doctor").toString());
            object.put("org",baseDoctorHospitalDO.get(0).getOrgCode());
            object.put("orgName",baseDoctorHospitalDO.get(0).getOrgName());
            object.put("jobTitleCode",baseDoctorHospitalDO.get(0).getDoctorDutyCode());
            object.put("jobTitleName",baseDoctorHospitalDO.get(0).getDoctorDutyName());
            object.put("introduction",mapList.get(0).get("introduction")); // 课程简介
        }
        return object;
    }
    public JSONObject getCatalogue(String id,String patient){
        JSONObject object = new JSONObject();
        String sql = "SELECT cc.* FROM base_course_catalogue cc,base_course c WHERE cc.course_id = '"+id+"' AND cc.course_id = c.id AND c.del = 1";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        JSONArray array = new JSONArray();
        if (mapList.size() > 0){
            for (int i = 0; i < mapList.size() ; i++){
                //  根据居民code,查询居民是否阅读过本课程
                String readSql = "SELECT read_time FROM base_course_catalogue_read_time WHERE course_id = '"+mapList.get(i).get("course_id")+"' AND course_catalogue_id = '"+id+"' AND patient = '"+patient+"'";
                List<Map<String , Object>> readMapList = jdbcTemplate.queryForList(readSql);
                if (readMapList.size() > 0){
                    mapList.add(readMapList.get(0));
                }
                array.add(mapList.get(i));
            }
        }
        object.put("object",array);
        return object;
    }
    public JSONObject getOrgInfoById(String id){
        JSONObject object = new JSONObject();
        String sql = "SELECT o.id,o.`code`,o.`name`,o.mobile,o.photo,o.address,o.intro,rs.start_time startTime,rs.end_time endTime,rs.num,rs.fee,rs.id rsId \n" +
                "FROM base_org o,base_recruit_students rs\n" +
                "WHERE o.id = '"+id+"' AND o.type = 4 AND o.del = 1 AND o.`code` = rs.org_code AND rs.del = 1";
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() > 0){
            object.put("id",mapList.get(0).get("id"));//机构id
            object.put("name",mapList.get(0).get("name"));//机构名称
            object.put("mobile",mapList.get(0).get("mobile"));//机构联系方式
            object.put("photo",mapList.get(0).get("photo"));//机构图片
            object.put("address",mapList.get(0).get("address"));//机构地址
            object.put("intro",mapList.get(0).get("intro"));//机构简介
            object.put("startTime",mapList.get(0).get("startTime"));//招生开始时间
            object.put("endTime",mapList.get(0).get("endTime"));//招生结束时间
            object.put("num",mapList.get(0).get("num"));//招生名额
            object.put("fee",mapList.get(0).get("fee"));//报名费用
            String sql1 = "SELECT COUNT(*) count\n" +
                    "FROM base_org o,base_recruit_students_record rsr,base_recruit_students rs\n" +
                    "WHERE o.`code` = rsr.org_code AND rsr.recruit_students_id = '"+mapList.get(0).get("rsId")+"' AND o.`code` = '"+mapList.get(0).get("code")+"' AND (`status` = 3 OR `status` = 6);\n";
            Integer count = jdbcTemplate.queryForObject(sql1,Integer.class);
            String sql2 = "SELECT * FROM base_course WHERE del = 1 AND org_code = '"+mapList.get(0).get("code")+"'" ;
            List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql2);
            if (amapList.size() > 0){
                object.put("allCourse",amapList);//课程
            }else {
                object.put("allCourse","");//课程
            }
            String sql3 = "SELECT *  FROM base_doctor d,base_doctor_hospital dh\n" +
                    "WHERE d.doctor_level = 3 AND d.locked = 0 AND d.enabled = 1 AND d.del = 1 AND d.id = dh.doctor_code AND dh.del = 1 AND dh.org_code = '"+mapList.get(0).get("code")+"'" ;
            List<Map<String , Object >> bmapList = jdbcTemplate.queryForList(sql3);
            if (bmapList.size() > 0){
                object.put("allDoctor",bmapList);//教师
            }else {
                object.put("allDoctor","");//教师
            }
            object.put("count",count);//已报名人数
        }
        return object;
    }
    public JSONObject getTecInfoById(String doctor,String orgCode,int page,int size){
        JSONObject object = new JSONObject();
        //老师的基本信息
        String sql = "SELECT d.id,d.name,d.job_title_code jobTitleCode,d.job_title_name jobTitleName,dh.org_code orgCode,dh.org_name orgName\n" +
                "FROM base_doctor d,base_doctor_hospital dh\n" +
                "WHERE d.id = '"+doctor+"' AND dh.org_code = '"+orgCode+"' AND d.enabled = 1 AND d.locked = 0 AND d.del = 1 AND dh.del = 1 AND dh.doctor_code = d.id";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        object.put("doctorInfo",mapList.get(0));
        if (mapList.size() > 0){
            page = page - 1;
            size = (page+1)*size;
            String sql1 = "SELECT * FROM base_course WHERE doctor = '"+doctor+"' AND del = 1 limit "+page+","+size+"";
            List<Map<String , Object>> mapList1 = jdbcTemplate.queryForList(sql1);
            if (mapList1.size() > 0){
                object.put("allCourse",mapList1);
            }else {
                object.put("allCourse","");
            }
        }
        return  object;
    }
    public JSONObject getCoursrOrderStatusByPatient(String patient,int status,int page,int size){
        page = page - 1;
        size = (page+1)*10;
        JSONObject object = new JSONObject();
        String sql = "SELECT id,course_name courseName,buy_time buyTime,pay_type payType,status FROM base_course_sales_order_record WHERE patient = '"+patient+"'";
        if (status > 0){
            sql += " and status = "+status+" ";
        }
        sql += " order by create_time desc limit "+page+","+size+" ";
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        String sql1 = "SELECT id,org_code orgCode,org_name orgName,pay_type payType,create_time createTime,status FROM base_recruit_students_record WHERE patient = '"+patient+"'";
        if (status > 0){
            sql1 += " and status = "+status+" ";
        }
        sql1 += " order by create_time desc limit "+page+","+size+"  ";
        List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql1);
        object.put("course",mapList);
        object.put("org",mapList1);
        return object;
    }
    public JSONObject getOrderInfo(String orderId){
        JSONObject object = new JSONObject();
        String sql = "SELECT id,course_name courseName,order_no orderNo,buy_time buyTime,pay_type payType,status orderStatus FROM base_course_sales_order_record WHERE id = '"+orderId+"'";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() < 0){
            sql = "SELECT id,org_code orgCode,org_name orgName,order_no orderNo,pay_type payType,create_time createTime,status FROM base_recruit_students_record WHERE patient = '"+orderId+"'";
            mapList = jdbcTemplate.queryForList(sql);
        }
        if (mapList.size() > 0 && mapList.get(0).get("status").equals(6)){
            String sql1 = "select status,create_time createTime,refund_price refundPrice,refund_desc refundDesc,enclosure from base_patient_order_refund where order_id = '"+mapList.get(0).get("id")+"' " ;
            List<Map<String , Object>> mapList1 = jdbcTemplate.queryForList(sql1);
            mapList.get(0).put("refundStatus",mapList1.get(0).get("status"));       //退款状态
            mapList.get(0).put("createTime",mapList1.get(0).get("createTime"));     //退款申请时间
            mapList.get(0).put("refundPrice",mapList1.get(0).get("refundPrice"));      //退款金额
            mapList.get(0).put("refundDesc",mapList1.get(0).get("refundDesc"));     //退款原因
            mapList.get(0).put("enclosure",mapList1.get(0).get("enclosure"));   //附件
        }
        object.put("object",mapList);
        return object;
    }
    public int buyCourseOrder(String patient, String patientName, String courseId, String courseName, String orgCode, String orgName, BigDecimal price,String payType){
        CourseSalesOrderRecordDO recordDO = new CourseSalesOrderRecordDO();
        recordDO.setBuyTime(new Date());
        recordDO.setPatient(patient);
        recordDO.setPatientName(patientName);
        recordDO.setCourseId(courseId);
        recordDO.setCourseName(courseName);
        recordDO.setOrgCode(orgCode);
        recordDO.setOrgName(orgName);
        recordDO.setPrice(price);
        recordDO.setPayType(payType);
        long  timeNew =  System.currentTimeMillis(); // 13位数的时间戳
        recordDO.setOrderNo(timeNew+"");
        courseSalesOrderRecordDao.save(recordDO);
        return 1;
    }
}