|  | @@ -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),
 | 
	
		
			
				|  |  |  		}
 |