|
@ -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));
|