zoie před 2 roky
rodič
revize
7eb3a64d82

+ 28 - 0
Nats/Nats.go

@@ -0,0 +1,28 @@
+package Nats
+
+import (
+	"FollowUp_Notice/conf"
+	"fmt"
+	"github.com/nats-io/nats.go"
+)
+
+var Nats *nats.Conn
+
+func init() {
+	fmt.Println("============Nats init============")
+	var err error
+	// 连接Nats服务器
+	Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
+	if err != nil {
+		fmt.Println("nats 连接失败!")
+		panic(err)
+	}
+	fmt.Println("nats OK!")
+
+	go NatsInit()
+
+}
+
+func NatsInit() {
+
+}

+ 1 - 1
conf/app.conf

@@ -21,7 +21,7 @@ Redis_address = "192.168.192.251:6379"
 Redis_password = ""
 Redis_dbNum = "3"
 
-FilterExcludeURL = /Login_verification
+FilterExcludeURL = /Login_verification,/receivecallstatus
 FilterOnlyLoginCheckURL =
 
 # 静态资源

+ 8 - 4
controllers/Illness.go

@@ -51,9 +51,11 @@ func (c *IllnessController) Illness_List() {
 func (c *IllnessController) Illness_Add() {
 
 	T_name := c.GetString("T_name")
+	T_sort, _ := c.GetInt("T_sort")
 
 	var_ := Illness.Illness{
 		T_name:  T_name,
+		T_sort:  T_sort,
 		T_State: 1,
 		T_uid:   c.User.Id,
 	}
@@ -65,7 +67,7 @@ func (c *IllnessController) Illness_Add() {
 		return
 	}
 
-	System.Add_UserLogs_T(c.User.T_uuid, "仓库", "添加", var_)
+	System.Add_UserLogs_T(c.User.T_uuid, "疾病", "添加", var_)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
 	c.ServeJSON()
@@ -74,6 +76,7 @@ func (c *IllnessController) Illness_Add() {
 func (c *IllnessController) Illness_Edit() {
 	T_id, _ := c.GetInt("T_id")
 	T_name := c.GetString("T_name")
+	T_sort, _ := c.GetInt("T_sort")
 
 	Illness_r, err := Illness.Read_Illness_ById(T_id)
 	if err != nil {
@@ -85,14 +88,15 @@ func (c *IllnessController) Illness_Edit() {
 	if len(T_name) > 0 {
 		Illness_r.T_name = T_name
 	}
+	Illness_r.T_sort = T_sort
 
-	if err = Illness.Update_Illness(Illness_r, "T_name"); err != nil {
+	if err = Illness.Update_Illness(Illness_r, "T_name", "T_sort"); err != nil {
 		c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
 		c.ServeJSON()
 		return
 	}
 
-	System.Add_UserLogs_T(c.User.T_uuid, "仓库", "修改", Illness_r)
+	System.Add_UserLogs_T(c.User.T_uuid, "疾病", "修改", Illness_r)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -114,7 +118,7 @@ func (c *IllnessController) Illness_Del() {
 		return
 	}
 
-	System.Add_UserLogs(c.User.T_uuid, "仓库", "删除", strconv.Itoa(T_id))
+	System.Add_UserLogs(c.User.T_uuid, "疾病", "删除", strconv.Itoa(T_id))
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()

+ 88 - 44
controllers/Patient.go

@@ -9,7 +9,7 @@ import (
 	"FollowUp_Notice/models/Patient"
 	"FollowUp_Notice/models/System"
 	"FollowUp_Notice/models/Tag"
-	"fmt"
+	"encoding/json"
 	"git.baozhida.cn/ERP_libs/lib"
 	beego "github.com/beego/beego/v2/server/web"
 	"github.com/robfig/cron/v3"
@@ -190,14 +190,12 @@ func (c *PatientController) Patient_Edit() {
 		patient.T_phone = T_phone
 		cols = append(cols, "T_name")
 	}
-	if T_notice_phone > 0 {
-		patient.T_notice_phone = T_notice_phone
-		cols = append(cols, "T_notice_phone")
-	}
-	if T_notice_message > 0 {
-		patient.T_notice_message = T_notice_message
-		cols = append(cols, "T_notice_message")
-	}
+	patient.T_notice_phone = T_notice_phone
+	cols = append(cols, "T_notice_phone")
+
+	patient.T_notice_message = T_notice_message
+	cols = append(cols, "T_notice_message")
+
 	if len(T_notice_interval) > 0 {
 		patient.T_notice_interval = T_notice_interval
 		cols = append(cols, "T_notice_interval")
@@ -278,6 +276,52 @@ func (c *PatientController) Patient_Del() {
 
 }
 
+func (c *PatientController) VoiceCall_Status() {
+	// {"eventType":"callout","statusInfo":{"sessionId":"1201_14852_4294967295_20230529072219@callenabler245.huaweicaas.com","timestamp":"2023-05-29 07:22:19","caller":"+8651668971369","called":"+8618086869080"}}
+	logs.Println("VoiceCall RequestBody-", string(c.Ctx.Input.RequestBody))
+
+	type RequestBody struct {
+		EventType  string `json:"eventType"`
+		StatusInfo struct {
+			SessionId string `json:"sessionId"`
+			Timestamp string `json:"timestamp"`
+			Caller    string `json:"caller"`
+			Called    string `json:"called"`
+			StateCode string `json:"stateCode"`
+			StateDesc string `json:"stateDesc"`
+		} `json:"statusInfo"`
+	}
+
+	var body RequestBody
+	data := c.Ctx.Input.RequestBody
+	err := json.Unmarshal(data, &body)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
+		c.ServeJSON()
+	}
+	if body.EventType == "disconnect" {
+		r, err := Patient.Read_PatientSend_ByT_id(body.StatusInfo.SessionId)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "SessionId Err!"}
+			c.ServeJSON()
+			return
+		}
+		r.T_State = 0
+		r.T_remark = body.StatusInfo.StateDesc
+		err = Patient.Update_PatientSend(r, "T_State", "T_remark")
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改发送状态失败!"}
+			c.ServeJSON()
+			return
+		}
+
+	}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
+
 func Cron_Patient() {
 
 	//创建一个定时任务对象
@@ -307,8 +351,7 @@ func Cron_Patient_ChangeFollowUp() {
 	list, _ := Patient.Read_Patient_List(0, "", "", 0, 0, 2, 1, 0, 0, 0, 9999)
 	for _, v := range list {
 		nextTime, _ := lib.DateStrToTime(v.T_next_time)
-		expDate := nextTime.AddDate(0, 0, v.T_next_interval)
-		if expDate.Before(time.Now()) {
+		if nextTime.Before(time.Now()) {
 			var_ := Patient.Patient{Id: v.Id, T_follow_up: 2}
 			if err := Patient.Update_Patient(var_, "T_follow_up"); err != nil {
 				System.Add_SysLogs_T("复诊状态", "修改失败", var_)
@@ -338,22 +381,21 @@ func Cron_Patient_Notice() {
 		patientList, _ := Patient.Read_Patient_List(user.Id, "", "", 0, 0, 0, 1, 0, 0, 0, 9999)
 		for _, v := range patientList {
 			nextTime, _ := lib.DateStrToTime(v.T_next_time)
-			intervalList := strings.Split(strings.Trim(v.T_notice_interval, ","), ",")
 			var success bool
 			// 提前1天
-			if intervalList[0] == "1" && nextTime.AddDate(0, 0, -1) == nowDate {
+			if strings.Contains(v.T_notice_interval, "1") && nextTime.AddDate(0, 0, -1) == nowDate {
 				success = Send_Notice(nextTime, user, v)
 			}
 			// 提前2天
-			if intervalList[1] == "1" && nextTime.AddDate(0, 0, -2) == nowDate {
+			if strings.Contains(v.T_notice_interval, "2") && nextTime.AddDate(0, 0, -2) == nowDate {
 				success = Send_Notice(nextTime, user, v)
 			}
 			// 提前3天
-			if intervalList[2] == "1" && nextTime.AddDate(0, 0, -3) == nowDate {
+			if strings.Contains(v.T_notice_interval, "3") && nextTime.AddDate(0, 0, -3) == nowDate {
 				success = Send_Notice(nextTime, user, v)
 			}
 			// 提前7天
-			if intervalList[3] == "1" && nextTime.AddDate(0, 0, -7) == nowDate {
+			if strings.Contains(v.T_notice_interval, "7") && nextTime.AddDate(0, 0, -7) == nowDate {
 				success = Send_Notice(nextTime, user, v)
 			}
 			if success == true {
@@ -371,32 +413,33 @@ func Cron_Patient_Notice() {
 // 发送通知(短信、电话)
 func Send_Notice(nextTime time.Time, user Account.User_R, patient Patient.Patient_R) (Success bool) {
 
-	// 发送短信通知
-	//if patient.T_notice_message == 1 {
-	//	res, err := http.SmsXSend(user.T_template_id, patient.T_phone, patient.T_name, nextTime.Format("2006年01月02日"))
-	//	if err != nil {
-	//		System.Add_SysLogs_T("复诊通知", "短信通知失败", patient)
-	//	}
-	//	// 保存短信发送记录
-	//	smsSend := Patient.PatientSend{
-	//		T_uid:    user.Id,
-	//		T_pid:    patient.Id,
-	//		T_phone:  patient.T_phone,
-	//		T_type:   1,
-	//		T_Remark: "send_id:" + res.Send_id,
-	//		T_State:  1,
-	//	}
-	//	if res.Status == "error" {
-	//		smsSend.T_State = 0
-	//	}
-	//	if res.Status == "success" {
-	//		Success = true
-	//	}
-	//	_, err = Patient.Add_PatientSend(smsSend)
-	//	if err != nil {
-	//		System.Add_SysLogs_T("复诊通知", "添加发送记录失败", patient)
-	//	}
-	//}
+	//发送短信通知
+	if patient.T_notice_message == 1 {
+		res, err := http.SmsXSend(user.T_template_id, patient.T_phone, patient.T_name, nextTime.Format("2006年01月02日"))
+		if err != nil {
+			System.Add_SysLogs_T("复诊通知", "短信通知失败", patient)
+		}
+		// 保存短信发送记录
+		smsSend := Patient.PatientSend{
+			T_uid:    user.Id,
+			T_pid:    patient.Id,
+			T_phone:  patient.T_phone,
+			T_type:   1,
+			T_id:     res.Send_id,
+			T_remark: res.Status,
+			T_State:  1,
+		}
+		if res.Status == "error" {
+			smsSend.T_State = 0
+		}
+		if res.Status == "success" {
+			Success = true
+		}
+		_, err = Patient.Add_PatientSend(smsSend)
+		if err != nil {
+			System.Add_SysLogs_T("复诊通知", "添加发送记录失败", patient)
+		}
+	}
 
 	if patient.T_notice_phone == 1 {
 		playInfoList := http.GetPlayInfoList(conf.VoiceCall_Template, []string{user.T_user, patient.T_name, nextTime.Format("2006/01/02")})
@@ -409,8 +452,9 @@ func Send_Notice(nextTime time.Time, user Account.User_R, patient Patient.Patien
 			T_uid:    user.Id,
 			T_pid:    patient.Id,
 			T_phone:  patient.T_phone,
-			T_type:   1,
-			T_Remark: fmt.Sprintf("resultdesc:%s,sessionId:%s", res.Resultdesc, res.SessionId),
+			T_type:   2,
+			T_id:     res.SessionId,
+			T_remark: res.Resultdesc,
 			T_State:  1,
 		}
 		if res.Resultcode != "0" {

+ 3 - 3
controllers/Tag.go

@@ -67,7 +67,7 @@ func (c *TagController) Tag_Add() {
 		return
 	}
 
-	System.Add_UserLogs_T(c.User.T_uuid, "仓库", "添加", var_)
+	System.Add_UserLogs_T(c.User.T_uuid, "标签", "添加", var_)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Id}
 	c.ServeJSON()
@@ -96,7 +96,7 @@ func (c *TagController) Tag_Edit() {
 		return
 	}
 
-	System.Add_UserLogs_T(c.User.T_uuid, "仓库", "修改", Tag_r)
+	System.Add_UserLogs_T(c.User.T_uuid, "标签", "修改", Tag_r)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -118,7 +118,7 @@ func (c *TagController) Tag_Del() {
 		return
 	}
 
-	System.Add_UserLogs(c.User.T_uuid, "仓库", "删除", strconv.Itoa(T_id))
+	System.Add_UserLogs(c.User.T_uuid, "标签", "删除", strconv.Itoa(T_id))
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()

+ 209 - 12
controllers/User.go

@@ -111,7 +111,20 @@ func (c *UserController) Get() {
 
 // 个人信息
 func (c *UserController) Info() {
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Account.UserToUser_R(c.User)}
+	type Info struct {
+		User   Account.User_R
+		Notice struct {
+			Sms       int64
+			VoiceCall int64
+		}
+	}
+	month := time.Now().Format("2006-01")
+	var info Info
+	info.User = Account.UserToUser_R(c.User)
+	info.Notice.Sms = Patient.Read_PatientSend_Count_Month(c.User.Id, 0, 1, month)
+	info.Notice.VoiceCall = Patient.Read_PatientSend_Count_Month(c.User.Id, 0, 2, month)
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: info}
 	c.ServeJSON()
 	return
 }
@@ -362,14 +375,12 @@ func (c *UserController) Bill() {
 	T_type, _ := c.GetInt("T_type")
 	user, err := Account.Read_User_ByT_uuid(T_uuid)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
-		c.ServeJSON()
-		return
+		user = c.User
 	}
-	CompanyBill_List, cnt := Account.Read_UserBill_List(user.Id, "", T_type, page, page_z)
+	Bill_List, cnt := Account.Read_UserBill_List(user.Id, "", T_type, page, page_z)
 	var r_jsons lib.R_JSONS
 	r_jsons.Num = cnt
-	r_jsons.Data = CompanyBill_List
+	r_jsons.Data = Bill_List
 	r_jsons.Page = page
 	r_jsons.Page_size = int(math.Ceil(float64(cnt) / float64(page_z)))
 
@@ -431,7 +442,7 @@ func (c *UserController) Bill_Excel() {
 	f.SetRowHeight("Sheet1", 2, 25)
 	// 这里设置表头
 	f.SetCellValue("Sheet1", "A2", "编号")
-	f.SetCellValue("Sheet1", "B2", "说明")
+	f.SetCellValue("Sheet1", "B2", "消费项目")
 	f.SetCellValue("Sheet1", "C2", "扣费/充值")
 	f.SetCellValue("Sheet1", "D2", "金额(元)")
 	f.SetCellValue("Sheet1", "E2", "余额(元)")
@@ -446,10 +457,10 @@ func (c *UserController) Bill_Excel() {
 
 	line := 2
 	//T_type 1 充值 2扣费
-	CompanyBill_List, _ := Account.Read_UserBill_List(user.Id, T_month, 0, 0, 9999)
+	Bill_List, _ := Account.Read_UserBill_List(user.Id, T_month, 0, 0, 9999)
 
 	// 循环写入数据
-	for i, v := range CompanyBill_List {
+	for i, v := range Bill_List {
 		line++
 
 		f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
@@ -500,6 +511,192 @@ func (c *UserController) Bill_Excel() {
 
 }
 
+// 通知记录
+func (c *UserController) Send() {
+
+	// 分页参数 初始化
+	page, _ := c.GetInt("page")
+	T_month := c.GetString("T_month")
+	if page < 1 {
+		page = 1
+	}
+	page_z, _ := c.GetInt("page_z")
+	if page_z < 1 {
+		page_z = conf.Page_size
+	}
+	T_uuid := c.GetString("T_uuid")
+	user, err := Account.Read_User_ByT_uuid(T_uuid)
+	if err != nil {
+		user = c.User
+	}
+	T_patient_uuid := c.GetString("T_patient_uuid")
+	T_patient_Id := 0
+	if len(T_patient_uuid) > 0 {
+		patient, err := Patient.Read_Patient_ByT_uuid(T_patient_uuid)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_patient_uuid Err!"}
+			c.ServeJSON()
+			return
+		}
+		T_patient_Id = patient.Id
+	}
+
+	// 1 短信 2 电话
+	T_type, _ := c.GetInt("T_type")
+
+	send_List, cnt := Patient.Read_PatientSend_List(user.Id, T_patient_Id, T_type, T_month, page, page_z)
+	var r_jsons lib.R_JSONS
+	r_jsons.Num = cnt
+	r_jsons.Data = send_List
+	r_jsons.Page = page
+	r_jsons.Page_size = int(math.Ceil(float64(cnt) / float64(page_z)))
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
+	c.ServeJSON()
+	return
+
+}
+
+// 通知记录下载
+func (c *UserController) Send_Excel() {
+
+	T_month := c.GetString("T_month")
+	T_uuid := c.GetString("T_uuid")
+	T_type, _ := c.GetInt("T_type")
+	user, err := Account.Read_User_ByT_uuid(T_uuid)
+	if err != nil {
+		user = c.User
+	}
+
+	T_patient_uuid := c.GetString("T_patient_uuid")
+	T_patient_Id := 0
+	if len(T_patient_uuid) > 0 {
+		patient, err := Patient.Read_Patient_ByT_uuid(T_patient_uuid)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_patient_uuid Err!"}
+			c.ServeJSON()
+			return
+		}
+		T_patient_Id = patient.Id
+	}
+	var T_type_str string
+	if T_type == 1 {
+		T_type_str = "短信"
+	}
+	if T_type == 2 {
+		T_type_str = "电话"
+	}
+
+	filename := fmt.Sprintf("%s%s通知记录", user.T_user, T_type_str)
+
+	if len(T_month) > 0 {
+		_, err := time.Parse("2006-01", T_month)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
+			c.ServeJSON()
+			return
+		}
+		year, month := strings.Split(T_month, "-")[0], strings.Split(T_month, "-")[1]
+		filename = fmt.Sprintf("%s%s%s年%s月通知记录", user.T_user, T_type_str, year, month)
+	}
+
+	f := excelize.NewFile()
+
+	Style1, _ := f.NewStyle(
+		&excelize.Style{
+			Font:      &excelize.Font{Bold: true, Size: 16, Family: "宋体"},
+			Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+		})
+
+	Style2, _ := f.NewStyle(
+		&excelize.Style{
+			Font:      &excelize.Font{Bold: true, Size: 14, Family: "宋体"},
+			Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
+			Border: []excelize.Border{
+				{Type: "left", Color: "000000", Style: 1},
+				{Type: "top", Color: "000000", Style: 1},
+				{Type: "bottom", Color: "000000", Style: 1},
+				{Type: "right", Color: "000000", Style: 1},
+			},
+		})
+	f.MergeCell("Sheet1", "A1", "D1")
+	f.SetRowStyle("Sheet1", 1, 1, Style1)
+	f.SetCellValue("Sheet1", "A1", filename)
+	f.SetRowHeight("Sheet1", 1, 30)
+
+	f.SetCellStyle("Sheet1", "A2", "D2", Style2)
+	f.SetRowHeight("Sheet1", 2, 25)
+	// 这里设置表头
+	f.SetCellValue("Sheet1", "A2", "编号")
+	f.SetCellValue("Sheet1", "B2", "通知电话")
+	f.SetCellValue("Sheet1", "C2", "通知类型")
+	f.SetCellValue("Sheet1", "D2", "时间")
+	// 设置列宽
+	f.SetColWidth("Sheet1", "A", "A", 10)
+	f.SetColWidth("Sheet1", "B", "B", 15)
+	f.SetColWidth("Sheet1", "C", "C", 12)
+	f.SetColWidth("Sheet1", "D", "D", 30)
+
+	line := 2
+	//T_type 1 充值 2扣费
+	send_List, _ := Patient.Read_PatientSend_List(user.Id, T_patient_Id, T_type, T_month, 0, 9999)
+
+	// 循环写入数据
+	for i, v := range send_List {
+		line++
+
+		f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
+		f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.T_phone)
+		if v.T_type == 1 {
+			T_type_str = "短信"
+		}
+		if v.T_type == 2 {
+			T_type_str = "电话"
+		}
+		f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), T_type_str)
+		f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.CreateTime)
+
+	}
+	Style4, _ := f.NewStyle(
+		&excelize.Style{
+			Font:      &excelize.Font{Size: 12, Family: "宋体"},
+			Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
+			Border: []excelize.Border{
+				{Type: "left", Color: "000000", Style: 1},
+				{Type: "top", Color: "000000", Style: 1},
+				{Type: "bottom", Color: "000000", Style: 1},
+				{Type: "right", Color: "000000", Style: 1},
+			},
+		})
+
+	f.SetCellStyle("Sheet1", "A2", fmt.Sprintf("D%d", line), Style4)
+
+	timeStr := filename + fmt.Sprintf("(%s)", lib.GetRandstring(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 0))
+	// 保存文件
+	if err = f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
+		fmt.Println(err)
+	}
+
+	var url string
+	//// 上传 OSS
+	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
+	//删除目录
+	err = os.Remove("ofile/" + timeStr + ".xlsx")
+	if err != nil {
+		fmt.Println(err)
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
+	c.ServeJSON()
+	return
+
+}
+
 // 用户定时任务
 func Cron_User() {
 
@@ -526,8 +723,8 @@ func Cron_User_Money_Bill() {
 	userList, _ := Account.Read_User_List("", 0, 9999)
 	for _, user := range userList {
 		// 1 短信 2 电话
-		smsCount := Patient.Read_PatientSend_Count(user.Id, 0, 1, yesterday)
-		voiceCallCount := Patient.Read_PatientSend_Count(user.Id, 0, 2, yesterday)
+		smsCount := Patient.Read_PatientSend_Count_Yesterday(user.Id, 0, 1, yesterday)
+		voiceCallCount := Patient.Read_PatientSend_Count_Yesterday(user.Id, 0, 2, yesterday)
 		money := float64(smsCount)*conf.Sms_Fee + float64(voiceCallCount)*conf.VoiceCall_Fee
 		if money == 0 {
 			continue
@@ -542,7 +739,7 @@ func Cron_User_Money_Bill() {
 		bill := Account.UserBill{
 			T_uid:      user.Id,
 			T_type:     Account.FeeDeduction,
-			T_bill:     "扣费",
+			T_bill:     yesterday + "通知自动扣除",
 			T_charging: float32(money),
 			T_balance:  user.T_money - float32(money),
 		}

+ 1 - 0
main.go

@@ -63,6 +63,7 @@ func main() {
 
 	go controllers.Cron_User()    // 用户账单统计
 	go controllers.Cron_Patient() // 患者通知信息
+	//go controllers.Cron_Patient_Notice() // 患者通知信息
 	beego.Run()
 
 }

+ 2 - 2
models/Patient/Patient.go

@@ -72,7 +72,7 @@ func PatientToPatient_R(r Patient) (m Patient_R) {
 	m.T_number = r.T_number
 	m.T_name = r.T_name
 	m.T_age = r.T_age
-	m.T_tag = lib.SplitStringToIntIds(r.T_tag, ",")
+	m.T_tag = lib.SplitStringToIntIds(r.T_tag, "T")
 	for _, v := range m.T_tag {
 		m.T_tag_List = append(m.T_tag_List, Tag.Read_Tag_Get(v))
 	}
@@ -172,7 +172,7 @@ func Read_Patient_List(T_uid int, T_number, T_name string, T_tag, T_illness, T_n
 		cond = cond.And("T_name__icontains", T_name)
 	}
 	if T_tag > 0 {
-		cond = cond.And("T_tag", T_tag)
+		cond = cond.And("T_tag__icontains", fmt.Sprintf("T%d|", T_tag))
 	}
 	if T_illness > 0 {
 		cond = cond.And("T_illness", T_illness)

+ 82 - 7
models/Patient/PatientSend.go

@@ -1,6 +1,7 @@
 package Patient
 
 import (
+	"fmt"
 	"git.baozhida.cn/ERP_libs/lib"
 	"github.com/astaxie/beego/logs"
 	"github.com/beego/beego/v2/adapter/orm"
@@ -15,7 +16,8 @@ type PatientSend struct {
 	T_pid      int       `orm:"index;size(100);null"`                                  // 患者id
 	T_phone    string    `orm:"size(256);null"`                                        // 患者电话 18888888888
 	T_type     int       `orm:"index;size(4);null"`                                    // 1 短信 2 电话
-	T_Remark   string    `orm:"size(256);null"`                                        // 备注
+	T_id       string    `orm:"size(256);null"`                                        // 发送id
+	T_remark   string    `orm:"size(256);null"`                                        // 备注
 	T_State    int       `orm:"size(200);default(1)"`                                  // 0失败 1正常
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
 }
@@ -24,7 +26,8 @@ type PatientSend_R struct {
 	T_pid      int    // 患者电话
 	T_phone    string // 18888888888
 	T_type     int    // 1 短信   2 电话
-	T_Remark   string // 备注
+	T_id       string
+	T_remark   string // 备注
 	T_State    int
 	CreateTime string //auto_now_add 第一次保存时才设置时间
 }
@@ -43,7 +46,8 @@ func PatientSendToPatientSend_R(r PatientSend) (m PatientSend_R) {
 	m.T_pid = r.T_pid
 	m.T_phone = r.T_phone
 	m.T_type = r.T_type
-	m.T_Remark = r.T_Remark
+	m.T_id = r.T_id
+	m.T_remark = r.T_remark
 	m.T_State = r.T_State
 	m.CreateTime = r.CreateTime.Format("2006-01-02 15:04:05")
 
@@ -60,8 +64,31 @@ func Add_PatientSend(r PatientSend) (id int64, err error) {
 	return id, err
 }
 
+// 获取 ById
+func Read_PatientSend_ByT_id(T_id string) (r PatientSend, err error) {
+	o := orm.NewOrm()
+	qs := o.QueryTable(new(PatientSend))
+	err = qs.Filter("T_id", T_id).One(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return
+}
+
+// 修改
+func Update_PatientSend(m PatientSend, cols ...string) error {
+	o := orm.NewOrm()
+	num, err := o.Update(&m, cols...)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return err
+	}
+	fmt.Println("Number of records updated in database:", num)
+	return nil
+}
+
 // 获取列表
-func Read_PatientSend_List(T_uid, T_pid, T_type, page, page_z int) (r_ []PatientSend_R, cnt int64) {
+func Read_PatientSend_List(T_uid, T_pid, T_type int, T_date string, page, page_z int) (r_ []PatientSend_R, cnt int64) {
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 	qs := o.QueryTable(new(PatientSend))
@@ -74,11 +101,27 @@ func Read_PatientSend_List(T_uid, T_pid, T_type, page, page_z int) (r_ []Patient
 
 	// 过滤
 	cond := orm.NewCondition()
-	cond = cond.And("T_pid", T_pid)
+	if T_uid > 0 {
+		cond = cond.And("T_uid", T_uid)
+	}
+	if T_pid > 0 {
+		cond = cond.And("T_pid", T_pid)
+	}
+	if T_type > 0 {
+		cond = cond.And("T_type", T_type)
+	}
+	if len(T_date) > 0 {
+		cond = cond.And("CreateTime__startswith", T_date)
+	}
 
 	// 查询
 	var r []PatientSend
-	_, err := qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond)).OrderBy("-Id").All(&r)
+	var err error
+	if page_z == 9999 {
+		_, err = qs.SetCond((*orm2.Condition)(cond)).OrderBy("-Id").All(&r)
+	} else {
+		_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond)).OrderBy("-Id").All(&r)
+	}
 
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -99,7 +142,7 @@ func Read_PatientSend_List(T_uid, T_pid, T_type, page, page_z int) (r_ []Patient
 }
 
 // 获取列表
-func Read_PatientSend_Count(T_uid, T_pid, T_type int, date string) (cnt int64) {
+func Read_PatientSend_Count_Yesterday(T_uid, T_pid, T_type int, date string) (cnt int64) {
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 	qs := o.QueryTable(new(PatientSend))
@@ -130,3 +173,35 @@ func Read_PatientSend_Count(T_uid, T_pid, T_type int, date string) (cnt int64) {
 
 	return cnt
 }
+
+// 获取列表
+func Read_PatientSend_Count_Month(T_uid, T_pid, T_type int, month string) (cnt int64) {
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+	qs := o.QueryTable(new(PatientSend))
+
+	// 过滤
+	cond := orm.NewCondition()
+
+	if T_uid > 0 {
+		cond = cond.And("T_uid", T_uid)
+	}
+	if T_pid > 0 {
+		cond = cond.And("T_pid", T_pid)
+	}
+	if T_type > 0 {
+		cond = cond.And("T_type", T_type)
+	}
+
+	if len(month) > 0 {
+		cond = cond.And("CreateTime__startswith", month)
+	}
+
+	cnt, err := qs.SetCond((*orm2.Condition)(cond)).Count()
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+
+	return cnt
+}

+ 3 - 0
routers/Account.go

@@ -16,4 +16,7 @@ func init() {
 	beego.Router("/User/Pay", &controllers.UserController{}, "*:Pay")               // 充值
 	beego.Router("/User/Bill", &controllers.UserController{}, "*:Bill")             // 账单
 	beego.Router("/User/Bill_Excel", &controllers.UserController{}, "*:Bill_Excel") // 账单下载
+	beego.Router("/User/Info", &controllers.UserController{}, "*:Info")             // 个人信息
+	beego.Router("/User/Send", &controllers.UserController{}, "*:Send")             // 通知
+	beego.Router("/User/Send_Excel", &controllers.UserController{}, "*:Send_Excel") // 通知下载
 }

+ 3 - 0
routers/router.go

@@ -1,6 +1,7 @@
 package routers
 
 import (
+	"FollowUp_Notice/controllers"
 	errorlibs "git.baozhida.cn/ERP_libs/Error"
 	beego "github.com/beego/beego/v2/server/web"
 )
@@ -10,4 +11,6 @@ func init() {
 	beego.ErrorController(&errorlibs.ErrorController{})
 	//过滤器,拦截所有请求
 	beego.InsertFilter("/*", beego.BeforeRouter, RBACFilter)
+	beego.Router("/receivecallstatus", &controllers.PatientController{}, "*:VoiceCall_Status") // 删除患者
+
 }

+ 0 - 41
sub/msg.go

@@ -1,41 +0,0 @@
-package sub
-
-import (
-	"FollowUp_Notice/logs"
-	"io/ioutil"
-	"mime/multipart"
-	"net/http"
-	"strings"
-)
-
-func Message_Sand(PhoneNumbers string, TemplateCode string, TemplateParam string) string {
-
-	//示例模版ID:9vFM31,示例模版内容:【SUBMAIL】您的验证码是@var(code),请在@var(time)内输入。
-	//vars := make(map[string]string)
-	//vars["code"] = "123456"
-	//vars["time"] = "10分钟"
-	postdata := make(map[string]string)
-	postdata["appid"] = conf.APPID
-	postdata["signature"] = conf.APPKEY
-	postdata["project"] = TemplateCode
-	postdata["to"] = PhoneNumbers
-	//bs, _ := json.Marshal(vars)
-	postdata["vars"] = TemplateParam
-
-	logs.Println(postdata)
-	body := &bytes.Buffer{}
-	writer := multipart.NewWriter(body)
-	for key, val := range postdata {
-		_ = writer.WriteField(key, val)
-	}
-	contentType := writer.FormDataContentType()
-	writer.Close()
-	resp, _ := http.Post(API, contentType, body)
-	result, _ := ioutil.ReadAll(resp.Body)
-
-	logs.Println("_result.Body:", string(result))
-	if !strings.Contains(string(result), "success") {
-		return string(result)
-	}
-	return "发送成功!"
-}