Compare commits
100
Commits
8229e13bfa
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72424dc070 | ||
|
|
bb3dcd4e1d | ||
|
|
5d4fcf993e | ||
|
|
cfdac70e94 | ||
|
|
b349acb4b4 | ||
|
|
3f5807aad2 | ||
|
|
da13b9dfaf | ||
|
|
d95e2bc0ec | ||
|
|
f6f6845692 | ||
|
|
86f3cc2fbc | ||
|
|
b74a8aa898 | ||
|
|
3205005b9a | ||
|
|
5f2baaace7 | ||
|
|
338d56beda | ||
|
|
0cff5b3f8d | ||
|
|
dc9dee6c98 | ||
|
|
943ee17b2a | ||
|
|
b27d12995d | ||
|
|
d1e3e6223b | ||
|
|
613feb2dd0 | ||
|
|
76c1c3b849 | ||
|
|
a349f447f9 | ||
|
|
b6f4d04b46 | ||
|
|
6ca0a5ff52 | ||
|
|
2985ebe260 | ||
|
|
ff73c074bc | ||
|
|
edc4497b69 | ||
|
|
f9ae5275d1 | ||
|
|
7e7b4d6eb0 | ||
|
|
01c1a4617c | ||
|
|
66fd805c1a | ||
|
|
eb11666b46 | ||
|
|
261e4b8267 | ||
|
|
ff7959deec | ||
|
|
d137034b1c | ||
|
|
f6e50fb04e | ||
|
|
6a9688b34f | ||
|
|
fce126bbbd | ||
|
|
9937ef8e0c | ||
|
|
ffff3ee5f3 | ||
|
|
7a7b51382b | ||
|
|
e840e99388 | ||
|
|
c786568d99 | ||
|
|
8cd2095983 | ||
|
|
32734e14f1 | ||
|
|
92781a3624 | ||
|
|
ffbc1c83c2 | ||
|
|
226b106997 | ||
|
|
5b5997f2e2 | ||
|
|
198f37fa42 | ||
|
|
916b788b1b | ||
|
|
b450125512 | ||
|
|
7fc14a3642 | ||
|
|
89dad42646 | ||
|
|
efc60d1244 | ||
|
|
542a8f71ad | ||
|
|
ed72e480f1 | ||
|
|
18a2ce1dde | ||
|
|
e3111beda8 | ||
|
|
75c1575830 | ||
|
|
0fb3681628 | ||
|
|
1b33c1f241 | ||
|
|
74b5610514 | ||
|
|
49fc422218 | ||
|
|
773e3bdc43 | ||
|
|
0ee06842c6 | ||
|
|
f5d9cf462e | ||
|
|
33372af1fc | ||
|
|
7b2ef6e239 | ||
|
|
86ef379053 | ||
|
|
1c29997b9a | ||
|
|
9070e69a66 | ||
|
|
d94aa44654 | ||
|
|
a10fb58886 | ||
|
|
8ebd97e153 | ||
|
|
da819de61b | ||
|
|
beb791a4ce | ||
|
|
7a51cec28b | ||
|
|
bdd3990fa6 | ||
|
|
deef662a31 | ||
|
|
daa4ff7bff | ||
|
|
88d138f2c0 | ||
|
|
9ee32f80ed | ||
|
|
0a0f85321a | ||
|
|
a4df927d7d | ||
|
|
ba7fb4ae8c | ||
|
|
4edbca5f67 | ||
|
|
406d91a81a | ||
|
|
f787ac0061 | ||
|
|
1ad8ffab1e | ||
|
|
c1cb96c01e | ||
|
|
0f8693f1c8 | ||
|
|
83a54826b6 | ||
|
|
f8e208077a | ||
|
|
a04a499a43 | ||
|
|
4133c7e26b | ||
|
|
b0c42eb5af | ||
|
|
a4698621bf | ||
|
|
7518739384 | ||
|
|
bcd23e9583 |
@@ -19,3 +19,4 @@
|
||||
.git/
|
||||
.DS_Store/
|
||||
data/
|
||||
docs/
|
||||
|
||||
@@ -35,12 +35,14 @@ type sysSetting struct {
|
||||
type userDoctorManage struct {
|
||||
UserDoctor // 医生列表
|
||||
DoctorAccount
|
||||
DoctorPharmacy // 医生药房管理
|
||||
}
|
||||
|
||||
// Basic 基础数据
|
||||
type basic struct {
|
||||
Department // 科室管理
|
||||
Hospital // 医院管理
|
||||
Pharmacy // 药房管理
|
||||
DiseaseClassExpertise // 专长管理
|
||||
Bank // 银行管理
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
cav2 "hospital-admin-api/extend/ca_v2"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type CaV2 struct{}
|
||||
|
||||
// GetServiceURL 获取云证书生命周期管理界面链接地址
|
||||
func (r *CaV2) GetServiceURL(c *gin.Context) {
|
||||
caRequest := requests.CaV2Request{}
|
||||
req := caRequest.GetServiceURL
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if msg := req.ValidateBusinessFields(); msg != "" {
|
||||
responses.FailWithMessage(msg, c)
|
||||
return
|
||||
}
|
||||
|
||||
client := cav2.NewClientFromConfig()
|
||||
result, err := client.GetServiceURL(cav2.GetServiceURLRequest{
|
||||
CertType: req.CertType,
|
||||
Type: req.Type,
|
||||
EntityID: req.EntityID,
|
||||
UserName: req.UserName,
|
||||
UserIDCard: req.UserIDCard,
|
||||
UserPhone: req.UserPhone,
|
||||
Email: req.Email,
|
||||
EnterpriseName: req.EnterpriseName,
|
||||
SocialCreditCode: req.SocialCreditCode,
|
||||
DeptPerson: req.DeptPerson,
|
||||
DeptPersonCode: req.DeptPersonCode,
|
||||
DeptPersonPhone: req.DeptPersonPhone,
|
||||
AgentName: req.AgentName,
|
||||
AgentIDCard: req.AgentIDCard,
|
||||
AuthMethod: req.AuthMethod,
|
||||
})
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// CertSign 云证书签名
|
||||
func (r *CaV2) CertSign(c *gin.Context) {
|
||||
caRequest := requests.CaV2Request{}
|
||||
req := caRequest.CertSign
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
client := cav2.NewClientFromConfig()
|
||||
result, err := client.CertSign(cav2.CertSignRequest{
|
||||
EntityID: req.EntityID,
|
||||
RequestID: req.RequestID,
|
||||
BusinessType: req.BusinessType,
|
||||
ToSign: req.ToSign,
|
||||
NotifyURL: req.NotifyURL,
|
||||
JumpURL: req.JumpURL,
|
||||
ExtParam: req.ExtParam,
|
||||
})
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetCertSignResult 获取云证书签名结果
|
||||
func (r *CaV2) GetCertSignResult(c *gin.Context) {
|
||||
caRequest := requests.CaV2Request{}
|
||||
req := caRequest.GetCertSignResult
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
client := cav2.NewClientFromConfig()
|
||||
result, err := client.GetCertSignResult(cav2.GetCertSignResultRequest{
|
||||
RequestID: req.RequestID,
|
||||
})
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// PasswordLessSignInfo 云证书免密签署状态查询
|
||||
func (r *CaV2) PasswordLessSignInfo(c *gin.Context) {
|
||||
caRequest := requests.CaV2Request{}
|
||||
req := caRequest.PasswordLessSignInfo
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
client := cav2.NewClientFromConfig()
|
||||
result, err := client.PasswordLessSignInfo(cav2.PasswordLessSignInfoRequest{
|
||||
EntityID: req.EntityID,
|
||||
})
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DoctorPharmacy struct{}
|
||||
|
||||
// GetDoctorPharmacies 获取指定医生绑定的药房列表
|
||||
func (r *DoctorPharmacy) GetDoctorPharmacies(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
id = c.Param("doctor_id")
|
||||
}
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少医生ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
list, err := doctorPharmacyService.GetDoctorPharmacies(doctorId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(list, c)
|
||||
}
|
||||
|
||||
// BindDoctorPharmacies 批量设置/覆盖医生绑定的药房列表
|
||||
func (r *DoctorPharmacy) BindDoctorPharmacies(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
id = c.Param("doctor_id")
|
||||
}
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少医生ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
req := requests.BindDoctorPharmacies{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
_, err = doctorPharmacyService.BindDoctorPharmacies(doctorId, req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// AddDoctorPharmacy 为医生新增单个药房绑定
|
||||
func (r *DoctorPharmacy) AddDoctorPharmacy(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
id = c.Param("doctor_id")
|
||||
}
|
||||
|
||||
var doctorId int64
|
||||
if id != "" {
|
||||
doctorId, _ = strconv.ParseInt(id, 10, 64)
|
||||
}
|
||||
|
||||
req := requests.AddDoctorPharmacy{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if doctorId == 0 && req.DoctorId != "" {
|
||||
doctorId, _ = strconv.ParseInt(req.DoctorId, 10, 64)
|
||||
}
|
||||
|
||||
if doctorId == 0 {
|
||||
responses.FailWithMessage("缺少医生ID", c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
_, err := doctorPharmacyService.AddDoctorPharmacy(doctorId, req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// UnbindDoctorPharmacy 解除医生与指定药房的绑定(DELETE /admin/doctor/pharmacy/:id)
|
||||
func (r *DoctorPharmacy) UnbindDoctorPharmacy(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
if idStr == "" {
|
||||
idStr = c.Param("doctor_pharmacy_id")
|
||||
}
|
||||
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err != nil || id == 0 {
|
||||
responses.FailWithMessage("缺少ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
|
||||
// 1. 优先作为 doctor_pharmacy_id 判定
|
||||
dp, _ := doctorPharmacyDao.GetDoctorPharmacyById(id)
|
||||
if dp != nil {
|
||||
_, err = doctorPharmacyService.UnbindDoctorPharmacyById(id)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 若作为 doctor_id,从 query 或 body 获取 pharmacy_id
|
||||
pharmacyIdStr := c.Query("pharmacy_id")
|
||||
if pharmacyIdStr != "" {
|
||||
pharmacyId, err := strconv.ParseInt(pharmacyIdStr, 10, 64)
|
||||
if err == nil && pharmacyId >= 0 {
|
||||
_, err = doctorPharmacyService.UnbindDoctorPharmacy(id, pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
responses.FailWithMessage("未找到绑定记录或缺少药房ID", c)
|
||||
}
|
||||
|
||||
// UnbindDoctorPharmacyPost 解绑药房(POST /admin/doctor/pharmacy/unbind)
|
||||
func (r *DoctorPharmacy) UnbindDoctorPharmacyPost(c *gin.Context) {
|
||||
req := requests.UnbindDoctorPharmacy{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
|
||||
// 优先按 doctor_pharmacy_id
|
||||
if req.DoctorPharmacyId != "" {
|
||||
dpid, err := strconv.ParseInt(req.DoctorPharmacyId, 10, 64)
|
||||
if err == nil && dpid > 0 {
|
||||
_, err = doctorPharmacyService.UnbindDoctorPharmacyById(dpid)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 其次按 doctor_id + pharmacy_id
|
||||
if req.DoctorId != "" && req.PharmacyId != "" {
|
||||
docId, err1 := strconv.ParseInt(req.DoctorId, 10, 64)
|
||||
pharId, err2 := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err1 == nil && err2 == nil {
|
||||
_, err := doctorPharmacyService.UnbindDoctorPharmacy(docId, pharId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
responses.FailWithMessage("缺少解绑参数", c)
|
||||
}
|
||||
|
||||
// SetDefaultDoctorPharmacy 设置默认药房(PUT /admin/doctor/pharmacy/default/:id)
|
||||
func (r *DoctorPharmacy) SetDefaultDoctorPharmacy(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err != nil || id == 0 {
|
||||
responses.FailWithMessage("缺少ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
|
||||
// 1. 优先作为 doctor_pharmacy_id 判定
|
||||
dp, _ := doctorPharmacyDao.GetDoctorPharmacyById(id)
|
||||
if dp != nil {
|
||||
_, err = doctorPharmacyService.SetDefaultPharmacyById(id)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 若作为 doctor_id,从 query 或 body 获取 pharmacy_id
|
||||
pharmacyIdStr := c.Query("pharmacy_id")
|
||||
if pharmacyIdStr != "" {
|
||||
pharmacyId, err := strconv.ParseInt(pharmacyIdStr, 10, 64)
|
||||
if err == nil && pharmacyId >= 0 {
|
||||
_, err = doctorPharmacyService.SetDefaultPharmacy(id, pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
responses.FailWithMessage("未找到绑定记录或缺少药房ID", c)
|
||||
}
|
||||
|
||||
// SetDefaultDoctorPharmacyPut 设置默认药房(PUT /admin/doctor/pharmacy/default)
|
||||
func (r *DoctorPharmacy) SetDefaultDoctorPharmacyPut(c *gin.Context) {
|
||||
req := requests.SetDefaultDoctorPharmacy{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
doctorPharmacyService := service.DoctorPharmacyService{}
|
||||
|
||||
// 优先按 doctor_pharmacy_id
|
||||
if req.DoctorPharmacyId != "" {
|
||||
dpid, err := strconv.ParseInt(req.DoctorPharmacyId, 10, 64)
|
||||
if err == nil && dpid > 0 {
|
||||
_, err = doctorPharmacyService.SetDefaultPharmacyById(dpid)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 其次按 doctor_id + pharmacy_id
|
||||
if req.DoctorId != "" && req.PharmacyId != "" {
|
||||
docId, err1 := strconv.ParseInt(req.DoctorId, 10, 64)
|
||||
pharId, err2 := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err1 == nil && err2 == nil {
|
||||
_, err := doctorPharmacyService.SetDefaultPharmacy(docId, pharId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
}
|
||||
@@ -272,6 +272,24 @@ func (r *Export) OrderInquiryForAccount(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquirys, err := orderInquiryDao.GetOrderInquiryForAccountExportListSearch(req)
|
||||
@@ -416,6 +434,24 @@ func (r *Export) OrderInquiry(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquirys, err := orderInquiryDao.GetOrderInquiryExportListSearch(req)
|
||||
@@ -465,6 +501,24 @@ func (r *Export) OrderProduct(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProducts, err := orderProductDao.GetOrderProductExportListSearch(req)
|
||||
@@ -499,6 +553,72 @@ func (r *Export) OrderProduct(c *gin.Context) {
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
// OrderPrescription 抄方的处方
|
||||
func (r *Export) OrderTransferPrescription(c *gin.Context) {
|
||||
orderPrescriptionRequest := requests.OrderPrescriptionRequest{}
|
||||
req := orderPrescriptionRequest.OrderPrescriptionExportList
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescriptions, err := orderPrescriptionDao.GetOrderTransferPrescriptionExportListSearch(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
exportService := service.ExportService{}
|
||||
ossAddress, err := exportService.OrderPrescription(orderPrescriptions)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前登陆用户id
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId != 0 {
|
||||
// 记录日志
|
||||
logExport := &model.LogExport{
|
||||
AdminUserId: userId,
|
||||
ExportModule: "处方",
|
||||
ExportFile: utils.RemoveOssDomain(ossAddress),
|
||||
}
|
||||
|
||||
logExportDao := dao.LogExportDao{}
|
||||
_, _ = logExportDao.AddLogExportUnTransaction(logExport)
|
||||
}
|
||||
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
// OrderPrescription 处方
|
||||
func (r *Export) OrderPrescription(c *gin.Context) {
|
||||
orderPrescriptionRequest := requests.OrderPrescriptionRequest{}
|
||||
@@ -514,6 +634,24 @@ func (r *Export) OrderPrescription(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescriptions, err := orderPrescriptionDao.GetOrderPrescriptionExportListSearch(req)
|
||||
@@ -643,3 +781,51 @@ func (r *Export) OrderService(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
// PharmacyDoctor 药房关联医生
|
||||
func (r *Export) PharmacyDoctor(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.PharmacyDoctorExportList
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
list, err := doctorPharmacyDao.GetPharmacyDoctorExportListSearch(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
exportService := service.ExportService{}
|
||||
ossAddress, err := exportService.PharmacyDoctor(list)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前登陆用户id
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId != 0 {
|
||||
// 记录日志
|
||||
logExport := &model.LogExport{
|
||||
AdminUserId: userId,
|
||||
ExportModule: "药房关联医生",
|
||||
ExportFile: utils.RemoveOssDomain(ossAddress),
|
||||
}
|
||||
|
||||
logExportDao := dao.LogExportDao{}
|
||||
_, _ = logExportDao.AddLogExportUnTransaction(logExport)
|
||||
}
|
||||
|
||||
responses.OkWithData(ossAddress, c)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,29 @@ func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
// 后台用户id
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
// 正式lixiumei user_id 测试 lixiumei user_id
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
status := 1
|
||||
req.MultiPointStatus = &status
|
||||
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryPageSearch(req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
@@ -84,6 +107,40 @@ func (r *OrderInquiry) GetOrderInquiry(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
// PutAnnualReviewHide 修改问诊订单年度审查隐藏状态
|
||||
func (r *OrderInquiry) PutAnnualReviewHide(c *gin.Context) {
|
||||
id := c.Param("order_inquiry_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
orderInquiryId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
req := requests.PutAnnualReviewHide{}
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
orderInquiryService := service.OrderInquiryService{}
|
||||
err = orderInquiryService.PutAnnualReviewHide(orderInquiryId, *req.AnnualReviewHide)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// CancelOrderInquiry 取消问诊订单
|
||||
func (r *OrderInquiry) CancelOrderInquiry(c *gin.Context) {
|
||||
@@ -165,6 +222,29 @@ func (r *OrderInquiry) GetOrderInquiryRecordPage(c *gin.Context) {
|
||||
req.GetOrderInquiryRecordPage.PageSize = 20
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
// 后台用户id
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
// 正式lixiumei user_id 测试 lixiumei user_id
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
status := 1
|
||||
req.GetOrderInquiryRecordPage.MultiPointStatus = &status
|
||||
|
||||
annualReviewHide := 0
|
||||
req.GetOrderInquiryRecordPage.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryRecordPageSearch(req.GetOrderInquiryRecordPage, req.GetOrderInquiryRecordPage.Page, req.GetOrderInquiryRecordPage.PageSize)
|
||||
if err != nil {
|
||||
@@ -281,6 +361,24 @@ func (r *OrderInquiry) GetOrderInquiryForAccountPage(c *gin.Context) {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryForAccountPageSearch(req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
@@ -10,6 +9,8 @@ import (
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type OrderPrescription struct{}
|
||||
@@ -37,6 +38,24 @@ func (r *OrderPrescription) GetOrderPrescriptionPage(c *gin.Context) {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescription, total, err := orderPrescriptionDao.GetOrderPrescriptionPageSearch(req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
@@ -55,6 +74,47 @@ func (r *OrderPrescription) GetOrderPrescriptionPage(c *gin.Context) {
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionTransferPage 获取抄方的处方列表-分页
|
||||
func (r *OrderPrescription) GetOrderPrescriptionTransferPage(c *gin.Context) {
|
||||
orderPrescriptionRequest := requests.OrderPrescriptionRequest{}
|
||||
req := orderPrescriptionRequest.GetOrderPrescriptionPage
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Page == 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescription, total, err := orderPrescriptionDao.GetOrderPrescriptionTransferPageSearch(req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
GetOrderPrescriptionPage := dto.GetOrderPrescriptionListDto(orderPrescription)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = GetOrderPrescriptionPage
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetOrderPrescription 处方详情
|
||||
func (r *OrderPrescription) GetOrderPrescription(c *gin.Context) {
|
||||
id := c.Param("order_prescription_id")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
@@ -10,6 +9,8 @@ import (
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type OrderProduct struct{}
|
||||
@@ -37,6 +38,24 @@ func (r *OrderProduct) GetOrderProductPage(c *gin.Context) {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
// 获取配置
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 年度审查
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
annualReviewHide := 0
|
||||
req.AnnualReviewHide = &annualReviewHide
|
||||
}
|
||||
}
|
||||
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProduct, total, err := orderProductDao.GetOrderProductPageSearch(req, req.Page, req.PageSize)
|
||||
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Pharmacy struct{}
|
||||
|
||||
// GetPharmacyPage 获取药房列表-分页
|
||||
func (r *Pharmacy) GetPharmacyPage(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.GetPharmacyPage
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacies, total, err := pharmacyDao.GetPharmacyPageSearch(req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
resList := dto.GetPharmacyListDto(pharmacies)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = resList
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetPharmacyList 获取药房列表(下拉/限制条件)
|
||||
func (r *Pharmacy) GetPharmacyList(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.GetPharmacyList
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
if req.PharmacyName != "" {
|
||||
maps["pharmacy_name"] = req.PharmacyName
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
maps["pharmacy_code"] = req.PharmacyCode
|
||||
}
|
||||
if req.Status != nil {
|
||||
maps["status"] = *req.Status
|
||||
} else {
|
||||
maps["status"] = 1 // 默认只查正常启用的
|
||||
}
|
||||
if req.IsPickup != nil {
|
||||
maps["is_pickup"] = *req.IsPickup
|
||||
}
|
||||
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacies, err := pharmacyDao.GetPharmacyList(maps)
|
||||
if err != nil {
|
||||
responses.Ok(c)
|
||||
return
|
||||
}
|
||||
|
||||
resList := dto.GetPharmacyListDto(pharmacies)
|
||||
responses.OkWithData(resList, c)
|
||||
}
|
||||
|
||||
// GetPharmacy 获取药房详情
|
||||
func (r *Pharmacy) GetPharmacy(c *gin.Context) {
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
pharmacyDto, err := pharmacyService.GetPharmacy(pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(pharmacyDto, c)
|
||||
}
|
||||
|
||||
// AddPharmacy 新增药房
|
||||
func (r *Pharmacy) AddPharmacy(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.AddPharmacy
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
_, err := pharmacyService.AddPharmacy(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// PutPharmacy 修改药房
|
||||
func (r *Pharmacy) PutPharmacy(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.PutPharmacy
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
_, err = pharmacyService.PutPharmacy(pharmacyId, req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// PutPharmacyStatus 修改药房状态
|
||||
func (r *Pharmacy) PutPharmacyStatus(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.PutPharmacyStatus
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
_, err = pharmacyService.PutPharmacyStatus(pharmacyId, req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// DeletePharmacy 删除药房
|
||||
func (r *Pharmacy) DeletePharmacy(c *gin.Context) {
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
_, err = pharmacyService.DeletePharmacy(pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorPage 获取药房绑定的医生列表-分页
|
||||
func (r *Pharmacy) GetPharmacyDoctorPage(c *gin.Context) {
|
||||
req := requests.GetPharmacyDoctorPage{}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
result, err := pharmacyService.GetPharmacyDoctorPage(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorList 获取药房绑定的医生列表
|
||||
func (r *Pharmacy) GetPharmacyDoctorList(c *gin.Context) {
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
id = c.Param("id")
|
||||
}
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少药房ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
list, err := pharmacyService.GetPharmacyDoctorList(pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(list, c)
|
||||
}
|
||||
|
||||
// GetAffectedDoctors 获取药房下线受影响医生列表(预检接口)
|
||||
func (r *Pharmacy) GetAffectedDoctors(c *gin.Context) {
|
||||
id := c.Param("pharmacy_id")
|
||||
if id == "" {
|
||||
id = c.Param("id")
|
||||
}
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少药房ID参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
result, err := pharmacyService.GetAffectedDoctors(pharmacyId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// BatchTransferAndAction 批量迁移医生默认药房并执行药房操作(禁用/删除)
|
||||
func (r *Pharmacy) BatchTransferAndAction(c *gin.Context) {
|
||||
pharmacyRequest := requests.PharmacyRequest{}
|
||||
req := pharmacyRequest.BatchTransferAndAction
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
pharmacyService := service.PharmacyService{}
|
||||
_, err := pharmacyService.BatchTransferAndAction(req)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
@@ -49,7 +49,8 @@ func (r *UserDoctor) GetUserDoctorPage(c *gin.Context) {
|
||||
if systemConfig.IsAnnualReview == 1 {
|
||||
// 后台用户id
|
||||
adminUserId := c.GetInt64("UserId")
|
||||
if adminUserId == 1845704393354121216 {
|
||||
// 正式lixiumei user_id 测试 lixiumei user_id
|
||||
if adminUserId == 1845704393354121216 || adminUserId == 1732273543535661056 {
|
||||
status := 1
|
||||
req.GetUserDoctorPage.MultiPointStatus = &status
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DoctorInquiryConfigDao struct {
|
||||
@@ -39,6 +40,7 @@ func (r *DoctorInquiryConfigDao) DeleteDoctorInquiryConfig(tx *gorm.DB, maps int
|
||||
|
||||
// EditDoctorInquiryConfigById 修改医生问诊配置-问诊配置id
|
||||
func (r *DoctorInquiryConfigDao) EditDoctorInquiryConfigById(tx *gorm.DB, inquiryConfigId int64, data interface{}) error {
|
||||
// 使用Debug()打印执行的SQL
|
||||
err := tx.Model(&model.DoctorInquiryConfig{}).Where("inquiry_config_id = ?", inquiryConfigId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorPharmacyDao struct{}
|
||||
|
||||
// GetDoctorPharmacyById 获取绑定关系-主键id
|
||||
func (r *DoctorPharmacyDao) GetDoctorPharmacyById(doctorPharmacyId int64) (m *model.DoctorPharmacy, err error) {
|
||||
err = global.Db.Where("doctor_pharmacy_id = ?", doctorPharmacyId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorPharmacyListByDoctorId 获取医生绑定的药房列表(带预加载药房详情)
|
||||
func (r *DoctorPharmacyDao) GetDoctorPharmacyListByDoctorId(doctorId int64) (m []*model.DoctorPharmacy, err error) {
|
||||
err = global.Db.Preload("Pharmacy").Where("doctor_id = ? AND status = 1", doctorId).Order("is_default desc, created_at desc").Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// GORM 在外键为 0 时会自动跳过 Preload,因此针对未能预加载的记录进行兜底补全
|
||||
var zeroPharmacy *model.Pharmacy
|
||||
for _, dp := range m {
|
||||
if dp.Pharmacy == nil {
|
||||
if dp.PharmacyId == 0 {
|
||||
if zeroPharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
zeroPharmacy = &ph
|
||||
}
|
||||
}
|
||||
dp.Pharmacy = zeroPharmacy
|
||||
} else {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = ?", dp.PharmacyId).First(&ph).Error; err == nil {
|
||||
dp.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorPharmacyByDoctorAndPharmacy 获取某医生与某药房的绑定关系
|
||||
func (r *DoctorPharmacyDao) GetDoctorPharmacyByDoctorAndPharmacy(doctorId, pharmacyId int64) (m *model.DoctorPharmacy, err error) {
|
||||
err = global.Db.Where("doctor_id = ? AND pharmacy_id = ?", doctorId, pharmacyId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddDoctorPharmacy 新增绑定
|
||||
func (r *DoctorPharmacyDao) AddDoctorPharmacy(tx *gorm.DB, m *model.DoctorPharmacy) (*model.DoctorPharmacy, error) {
|
||||
if err := tx.Create(m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteDoctorPharmacy 删除绑定记录
|
||||
func (r *DoctorPharmacyDao) DeleteDoctorPharmacy(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.DoctorPharmacy{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteDoctorPharmacyById 根据绑定关系主键id删除
|
||||
func (r *DoctorPharmacyDao) DeleteDoctorPharmacyById(tx *gorm.DB, doctorPharmacyId int64) error {
|
||||
err := tx.Where("doctor_pharmacy_id = ?", doctorPharmacyId).Delete(&model.DoctorPharmacy{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteDoctorPharmacyByDoctorAndPharmacy 解绑指定医生和指定药房
|
||||
func (r *DoctorPharmacyDao) DeleteDoctorPharmacyByDoctorAndPharmacy(tx *gorm.DB, doctorId, pharmacyId int64) error {
|
||||
err := tx.Where("doctor_id = ? AND pharmacy_id = ?", doctorId, pharmacyId).Delete(&model.DoctorPharmacy{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetDoctorDefaultPharmacy 重置医生的默认药房(设为非默认)
|
||||
func (r *DoctorPharmacyDao) ResetDoctorDefaultPharmacy(tx *gorm.DB, doctorId int64) error {
|
||||
err := tx.Model(&model.DoctorPharmacy{}).Where("doctor_id = ?", doctorId).Update("is_default", 0).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetDefaultPharmacy 设指定药房为默认
|
||||
func (r *DoctorPharmacyDao) SetDefaultPharmacy(tx *gorm.DB, doctorId, pharmacyId int64) error {
|
||||
err := tx.Model(&model.DoctorPharmacy{}).Where("doctor_id = ? AND pharmacy_id = ?", doctorId, pharmacyId).Update("is_default", 1).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetDefaultPharmacyById 根据主键设为默认
|
||||
func (r *DoctorPharmacyDao) SetDefaultPharmacyById(tx *gorm.DB, doctorPharmacyId int64) error {
|
||||
err := tx.Model(&model.DoctorPharmacy{}).Where("doctor_pharmacy_id = ?", doctorPharmacyId).Update("is_default", 1).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorPageSearch 获取药房绑定的医生列表-分页
|
||||
func (r *DoctorPharmacyDao) GetPharmacyDoctorPageSearch(pharmacyId int64, req requests.GetPharmacyDoctorPage, page, pageSize int) (m []*model.DoctorPharmacy, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
query := global.Db.Model(&model.DoctorPharmacy{}).
|
||||
Where("gdxz_doctor_pharmacy.pharmacy_id = ? AND gdxz_doctor_pharmacy.status = 1", pharmacyId)
|
||||
|
||||
// 如果有医生姓名或手机号筛选,做表连接
|
||||
needJoinDoctor := req.DoctorName != "" || req.Mobile != ""
|
||||
if needJoinDoctor {
|
||||
query = query.Joins("JOIN gdxz_user_doctor ON gdxz_user_doctor.doctor_id = gdxz_doctor_pharmacy.doctor_id")
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where("gdxz_user_doctor.user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
if req.Mobile != "" {
|
||||
query = query.Joins("JOIN gdxz_user ON gdxz_user.user_id = gdxz_user_doctor.user_id").
|
||||
Where("gdxz_user.mobile LIKE ?", "%"+req.Mobile+"%")
|
||||
}
|
||||
}
|
||||
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Order("gdxz_doctor_pharmacy.is_default desc, gdxz_doctor_pharmacy.created_at desc").
|
||||
Preload("UserDoctor.User").
|
||||
Preload("UserDoctor.Hospital").
|
||||
Scopes(model.Paginate(page, pageSize)).
|
||||
Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorListByPharmacyId 获取药房绑定的所有医生列表
|
||||
func (r *DoctorPharmacyDao) GetPharmacyDoctorListByPharmacyId(pharmacyId int64) (m []*model.DoctorPharmacy, err error) {
|
||||
err = global.Db.Preload("UserDoctor.User").
|
||||
Preload("UserDoctor.Hospital").
|
||||
Where("pharmacy_id = ? AND status = 1", pharmacyId).
|
||||
Order("is_default desc, created_at desc").
|
||||
Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDefaultPharmacyDoctorListByPharmacyId 获取将该药房设为默认药房的医生列表
|
||||
func (r *DoctorPharmacyDao) GetDefaultPharmacyDoctorListByPharmacyId(pharmacyId int64) (m []*model.DoctorPharmacy, err error) {
|
||||
err = global.Db.Preload("UserDoctor").
|
||||
Preload("UserDoctor.User").
|
||||
Preload("UserDoctor.Hospital").
|
||||
Where("pharmacy_id = ? AND status = 1 AND is_default = 1", pharmacyId).
|
||||
Order("created_at desc").
|
||||
Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorPharmacyCountsByPharmacyId 获取药房绑定的医生数量(有效绑定数、设为默认药房数)
|
||||
func (r *DoctorPharmacyDao) GetDoctorPharmacyCountsByPharmacyId(pharmacyId int64) (totalCount int64, defaultCount int64, err error) {
|
||||
err = global.Db.Model(&model.DoctorPharmacy{}).
|
||||
Where("pharmacy_id = ? AND status = 1", pharmacyId).
|
||||
Count(&totalCount).Error
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
err = global.Db.Model(&model.DoctorPharmacy{}).
|
||||
Where("pharmacy_id = ? AND status = 1 AND is_default = 1", pharmacyId).
|
||||
Count(&defaultCount).Error
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return totalCount, defaultCount, nil
|
||||
}
|
||||
|
||||
// GetOtherPharmaciesByDoctorIds 批量获取一组医生绑定的其他有效药房
|
||||
func (r *DoctorPharmacyDao) GetOtherPharmaciesByDoctorIds(doctorIds []int64, excludePharmacyId int64) (m []*model.DoctorPharmacy, err error) {
|
||||
if len(doctorIds) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
err = global.Db.Preload("Pharmacy").
|
||||
Where("doctor_id IN (?) AND status = 1 AND pharmacy_id != ?", doctorIds, excludePharmacyId).
|
||||
Order("is_default desc, created_at desc").
|
||||
Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// GORM 在外键为 0 时会自动跳过 Preload,因此针对未能预加载的记录进行兜底补全
|
||||
var zeroPharmacy *model.Pharmacy
|
||||
for _, dp := range m {
|
||||
if dp.Pharmacy == nil {
|
||||
if dp.PharmacyId == 0 {
|
||||
if zeroPharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
zeroPharmacy = &ph
|
||||
}
|
||||
}
|
||||
dp.Pharmacy = zeroPharmacy
|
||||
} else {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = ?", dp.PharmacyId).First(&ph).Error; err == nil {
|
||||
dp.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorExportListSearch 获取药房关联医生列表-导出
|
||||
func (r *DoctorPharmacyDao) GetPharmacyDoctorExportListSearch(req requests.PharmacyDoctorExportList) (m []*model.DoctorPharmacy, err error) {
|
||||
query := global.Db.Model(&model.DoctorPharmacy{}).
|
||||
Where("gdxz_doctor_pharmacy.status = 1")
|
||||
|
||||
// 药房id过滤
|
||||
if req.PharmacyId != "" {
|
||||
pharmacyId, _ := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if pharmacyId >= 0 {
|
||||
query = query.Where("gdxz_doctor_pharmacy.pharmacy_id = ?", pharmacyId)
|
||||
}
|
||||
}
|
||||
|
||||
// 1:当前搜索数据
|
||||
if req.Type == 1 {
|
||||
needJoinDoctor := req.DoctorName != "" || req.Mobile != ""
|
||||
if needJoinDoctor {
|
||||
query = query.Joins("JOIN gdxz_user_doctor ON gdxz_user_doctor.doctor_id = gdxz_doctor_pharmacy.doctor_id")
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where("gdxz_user_doctor.user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
if req.Mobile != "" {
|
||||
query = query.Joins("JOIN gdxz_user ON gdxz_user.user_id = gdxz_user_doctor.user_id").
|
||||
Where("gdxz_user.mobile LIKE ?", "%"+req.Mobile+"%")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2:当前选中数据
|
||||
if req.Type == 2 {
|
||||
if req.Id == "" {
|
||||
return nil, errors.New("未提供需导出数据编号")
|
||||
}
|
||||
id := strings.Split(req.Id, ",")
|
||||
query = query.Where("gdxz_doctor_pharmacy.doctor_pharmacy_id IN (?) OR gdxz_doctor_pharmacy.doctor_id IN (?)", id, id)
|
||||
}
|
||||
|
||||
// 3:全部数据(无额外搜索条件)
|
||||
|
||||
err = query.Order("gdxz_doctor_pharmacy.is_default desc, gdxz_doctor_pharmacy.created_at desc").
|
||||
Preload("Pharmacy").
|
||||
Preload("UserDoctor.User").
|
||||
Preload("UserDoctor.Hospital").
|
||||
Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// GORM 在外键为 0 时会自动跳过 Preload,因此针对未能预加载的记录进行兜底补全
|
||||
var zeroPharmacy *model.Pharmacy
|
||||
for _, dp := range m {
|
||||
if dp.Pharmacy == nil {
|
||||
if dp.PharmacyId == 0 {
|
||||
if zeroPharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
zeroPharmacy = &ph
|
||||
}
|
||||
}
|
||||
dp.Pharmacy = zeroPharmacy
|
||||
} else {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = ?", dp.PharmacyId).First(&ph).Error; err == nil {
|
||||
dp.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
+220
-182
@@ -106,190 +106,11 @@ func (r *OrderInquiryDao) GetOrderInquiryPageSearch(req requests.GetOrderInquiry
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "mobile")
|
||||
})
|
||||
|
||||
// 订单类型
|
||||
if req.InquiryType != nil {
|
||||
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||
}
|
||||
|
||||
// 订单问诊方式
|
||||
if req.InquiryMode != nil {
|
||||
query = query.Where("inquiry_mode = ?", req.InquiryMode)
|
||||
}
|
||||
|
||||
// 问诊订单状态
|
||||
if req.InquiryStatus != nil {
|
||||
query = query.Where("inquiry_status = ?", req.InquiryStatus)
|
||||
}
|
||||
|
||||
// 问诊订单退款状态
|
||||
if req.InquiryRefundStatus != nil {
|
||||
query = query.Where("inquiry_refund_status = ?", req.InquiryRefundStatus)
|
||||
}
|
||||
|
||||
// 支付渠道
|
||||
if req.InquiryPayChannel != nil {
|
||||
query = query.Where("inquiry_pay_channel = ?", req.InquiryPayChannel)
|
||||
}
|
||||
|
||||
// 支付状态
|
||||
if req.InquiryPayStatus != nil {
|
||||
query = query.Where("inquiry_pay_status = ?", req.InquiryPayStatus)
|
||||
}
|
||||
|
||||
// 系统订单编号
|
||||
if req.InquiryNo != "" {
|
||||
query = query.Where("inquiry_no = ?", req.InquiryNo)
|
||||
}
|
||||
|
||||
// 第三方支付流水号
|
||||
if req.EscrowTradeNo != "" {
|
||||
query = query.Where("escrow_trade_no = ?", req.EscrowTradeNo)
|
||||
}
|
||||
|
||||
// 支付时间
|
||||
if req.PayTime != "" {
|
||||
payTime := strings.Split(req.PayTime, "&")
|
||||
if len(payTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", payTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", payTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("pay_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 接诊时间
|
||||
if req.ReceptionTime != "" {
|
||||
receptionTime := strings.Split(req.ReceptionTime, "&")
|
||||
if len(receptionTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", receptionTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", receptionTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("reception_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单完成时间
|
||||
if req.CompleteTime != "" {
|
||||
completeTime := strings.Split(req.CompleteTime, "&")
|
||||
if len(completeTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", completeTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", completeTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("complete_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单结束时间
|
||||
if req.FinishTime != "" {
|
||||
finishTime := strings.Split(req.FinishTime, "&")
|
||||
if len(finishTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", finishTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", finishTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("finish_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 是否提现
|
||||
if req.IsWithdrawal != nil {
|
||||
query = query.Where("is_withdrawal = ?", req.IsWithdrawal)
|
||||
}
|
||||
|
||||
// 订单取消时间
|
||||
if req.CancelTime != "" {
|
||||
cancelTime := strings.Split(req.CancelTime, "&")
|
||||
if len(cancelTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("cancel_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 创建时间
|
||||
if req.CreatedAt != "" {
|
||||
createdAt := strings.Split(req.CreatedAt, "&")
|
||||
if len(createdAt) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", createdAt[0])
|
||||
endTime, _ := time.Parse("2006-01-02", createdAt[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
if req.PatientName != "" {
|
||||
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者
|
||||
if req.Mobile != "" {
|
||||
// 患者
|
||||
patientSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
|
||||
query = query.Where("user_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery)
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRecordPageSearch 获取问诊记录列表-分页
|
||||
func (r *OrderInquiryDao) GetOrderInquiryRecordPageSearch(req requests.GetOrderInquiryRecordPage, page, pageSize int) (m []*model.OrderInquiry, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderInquiry{})
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 医生姓名
|
||||
if req.DoctorName != "" {
|
||||
// 多点执业状态
|
||||
if req.MultiPointStatus != nil {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
Where("multi_point_status = ?", req.MultiPointStatus)
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
@@ -446,6 +267,213 @@ func (r *OrderInquiryDao) GetOrderInquiryRecordPageSearch(req requests.GetOrderI
|
||||
query = query.Where("user_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery)
|
||||
}
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Where("annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRecordPageSearch 获取问诊记录列表-分页
|
||||
func (r *OrderInquiryDao) GetOrderInquiryRecordPageSearch(req requests.GetOrderInquiryRecordPage, page, pageSize int) (m []*model.OrderInquiry, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderInquiry{})
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 医生姓名
|
||||
if req.DoctorName != "" {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 多点执业状态
|
||||
if req.MultiPointStatus != nil {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("multi_point_status = ?", req.MultiPointStatus)
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "mobile")
|
||||
})
|
||||
|
||||
// 订单类型
|
||||
if req.InquiryType != nil {
|
||||
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||
}
|
||||
|
||||
// 订单问诊方式
|
||||
if req.InquiryMode != nil {
|
||||
query = query.Where("inquiry_mode = ?", req.InquiryMode)
|
||||
}
|
||||
|
||||
// 问诊订单状态
|
||||
if req.InquiryStatus != nil {
|
||||
query = query.Where("inquiry_status = ?", req.InquiryStatus)
|
||||
}
|
||||
|
||||
// 问诊订单退款状态
|
||||
if req.InquiryRefundStatus != nil {
|
||||
query = query.Where("inquiry_refund_status = ?", req.InquiryRefundStatus)
|
||||
}
|
||||
|
||||
// 支付渠道
|
||||
if req.InquiryPayChannel != nil {
|
||||
query = query.Where("inquiry_pay_channel = ?", req.InquiryPayChannel)
|
||||
}
|
||||
|
||||
// 支付状态
|
||||
if req.InquiryPayStatus != nil {
|
||||
query = query.Where("inquiry_pay_status = ?", req.InquiryPayStatus)
|
||||
}
|
||||
|
||||
// 系统订单编号
|
||||
if req.InquiryNo != "" {
|
||||
query = query.Where("inquiry_no = ?", req.InquiryNo)
|
||||
}
|
||||
|
||||
// 第三方支付流水号
|
||||
if req.EscrowTradeNo != "" {
|
||||
query = query.Where("escrow_trade_no = ?", req.EscrowTradeNo)
|
||||
}
|
||||
|
||||
// 支付时间
|
||||
if req.PayTime != "" {
|
||||
payTime := strings.Split(req.PayTime, "&")
|
||||
if len(payTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", payTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", payTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("pay_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 接诊时间
|
||||
if req.ReceptionTime != "" {
|
||||
receptionTime := strings.Split(req.ReceptionTime, "&")
|
||||
if len(receptionTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", receptionTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", receptionTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("reception_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单完成时间
|
||||
if req.CompleteTime != "" {
|
||||
completeTime := strings.Split(req.CompleteTime, "&")
|
||||
if len(completeTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", completeTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", completeTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("complete_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单结束时间
|
||||
if req.FinishTime != "" {
|
||||
finishTime := strings.Split(req.FinishTime, "&")
|
||||
if len(finishTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", finishTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", finishTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("finish_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 是否提现
|
||||
if req.IsWithdrawal != nil {
|
||||
query = query.Where("is_withdrawal = ?", req.IsWithdrawal)
|
||||
}
|
||||
|
||||
// 订单取消时间
|
||||
if req.CancelTime != "" {
|
||||
cancelTime := strings.Split(req.CancelTime, "&")
|
||||
if len(cancelTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("cancel_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 创建时间
|
||||
if req.CreatedAt != "" {
|
||||
createdAt := strings.Split(req.CreatedAt, "&")
|
||||
if len(createdAt) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", createdAt[0])
|
||||
endTime, _ := time.Parse("2006-01-02", createdAt[1])
|
||||
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
|
||||
query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
if req.PatientName != "" {
|
||||
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者
|
||||
if req.Mobile != "" {
|
||||
// 患者
|
||||
patientSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
|
||||
query = query.Where("user_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery)
|
||||
}
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Where("annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
@@ -609,6 +637,11 @@ func (r *OrderInquiryDao) GetOrderInquiryForAccountPageSearch(req requests.GetOr
|
||||
query = query.Where("user_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Where("annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
@@ -758,6 +791,11 @@ func (r *OrderInquiryDao) GetOrderInquiryForAccountExportListSearch(req requests
|
||||
}
|
||||
}
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Where("annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 当前选中数据
|
||||
if req.Type == 2 {
|
||||
if req.Id == "" {
|
||||
|
||||
+495
-13
@@ -2,12 +2,13 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type OrderPrescriptionDao struct {
|
||||
@@ -15,7 +16,21 @@ type OrderPrescriptionDao struct {
|
||||
|
||||
// GetById 获取处方-处方id
|
||||
func (r *OrderPrescriptionDao) GetById(orderPrescriptionId int64) (m *model.OrderPrescription, err error) {
|
||||
err = global.Db.First(&m, orderPrescriptionId).Error
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
// 药房
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
err = query.First(&m, orderPrescriptionId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -82,6 +97,15 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Joins("JOIN gdxz_order_inquiry ON gdxz_order_inquiry.order_inquiry_id = gdxz_order_prescription.order_inquiry_id")
|
||||
query = query.Where("gdxz_order_inquiry.annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 药房表
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 患者表
|
||||
query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
@@ -100,9 +124,29 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr
|
||||
// 处方关联疾病表
|
||||
query = query.Preload("OrderPrescriptionIcd")
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
// 患者家庭成员表
|
||||
query = query.Preload("PatientFamily")
|
||||
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 处方编号
|
||||
if req.PrescriptionCode != "" {
|
||||
query = query.Where("prescription_code = ?", req.PrescriptionCode)
|
||||
@@ -166,7 +210,7 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr
|
||||
|
||||
// 药品订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
subQuery := global.Db.Model(&model.OrderProduct{}).
|
||||
Select("order_prescription_id").
|
||||
Where("order_product_no = ?", req.OrderProductNo)
|
||||
query = query.Where("order_prescription_id IN (?)", subQuery)
|
||||
@@ -233,11 +277,231 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionExportListSearch 获取处方列表-导出
|
||||
func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests.OrderPrescriptionExportList) (m []*model.OrderPrescription, err error) {
|
||||
// GetOrderPrescriptionTransferPageSearch 获取抄方的处方列表-分页
|
||||
func (r *OrderPrescriptionDao) GetOrderPrescriptionTransferPageSearch(req requests.GetOrderPrescriptionPage, page, pageSize int) (m []*model.OrderPrescription, total int64, err error) {
|
||||
var totalRecords int64
|
||||
prescriptionTable := (&model.OrderPrescription{}).TableName()
|
||||
inquiryTable := (&model.OrderInquiry{}).TableName()
|
||||
doctorTable := (&model.UserDoctor{}).TableName()
|
||||
userTable := (&model.User{}).TableName()
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
|
||||
// 关联问诊表,只查询TransferDoctorId不等于null的记录
|
||||
query = query.Joins("INNER JOIN " + inquiryTable + " ON " + prescriptionTable + ".order_inquiry_id = " + inquiryTable + ".order_inquiry_id").
|
||||
Where(inquiryTable + ".transfer_doctor_id IS NOT NULL")
|
||||
|
||||
// 关联抄方医生表
|
||||
query = query.Joins("LEFT JOIN " + doctorTable + " ON " + inquiryTable + ".doctor_id = " + doctorTable + ".doctor_id")
|
||||
|
||||
// 关联抄方医生对应的用户表(用于按用户姓名查询)
|
||||
query = query.Joins("LEFT JOIN " + userTable + " ON " + doctorTable + ".user_id = " + userTable + ".user_id")
|
||||
|
||||
// 患者表
|
||||
query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 用户表
|
||||
query = query.Preload("UserPatient.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 药师表
|
||||
query = query.Preload("UserPharmacist", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 处方关联疾病表
|
||||
query = query.Preload("OrderPrescriptionIcd")
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
// 患者家庭成员表
|
||||
query = query.Preload("PatientFamily")
|
||||
|
||||
// 药房表
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 处方编号
|
||||
if req.PrescriptionCode != "" {
|
||||
query = query.Where(prescriptionTable+".prescription_code = ?", req.PrescriptionCode)
|
||||
}
|
||||
|
||||
// 医生名称 - 查询抄方医生名称
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where(userTable+".user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
if req.PatientName != "" {
|
||||
query = query.Where(prescriptionTable+".patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者/就诊人(医生部分改为抄方医生)
|
||||
if req.Mobile != "" {
|
||||
// 就诊人
|
||||
patientFamilySubQuery := global.Db.Model(&model.PatientFamily{}).
|
||||
Select("family_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
// 患者
|
||||
patientUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
patientSubQuery := global.Db.Model(&model.UserPatient{}).
|
||||
Select("patient_id").
|
||||
Where(gorm.Expr("user_id IN (?)", patientUserSubQuery))
|
||||
|
||||
// 抄方医生:通过手机号找到 user_id -> doctor_id(抄方医生)
|
||||
transferDoctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", transferDoctorUserSubQuery))
|
||||
|
||||
// 使用 OR 条件:患者匹配 OR 抄方医生匹配 OR 就诊人匹配(整体加括号)
|
||||
query = query.Where(
|
||||
gorm.Expr("("+prescriptionTable+".patient_id IN (?) OR "+inquiryTable+".doctor_id IN (?) OR "+prescriptionTable+".family_id IN (?))",
|
||||
patientSubQuery, transferDoctorSubQuery, patientFamilySubQuery),
|
||||
)
|
||||
}
|
||||
|
||||
// 处方状态
|
||||
if req.PrescriptionStatus != nil {
|
||||
query = query.Where(prescriptionTable+".prescription_status = ?", req.PrescriptionStatus)
|
||||
}
|
||||
|
||||
// 药师审核状态
|
||||
if req.PharmacistAuditStatus != nil {
|
||||
query = query.Where(prescriptionTable+".pharmacist_audit_status = ?", req.PharmacistAuditStatus)
|
||||
}
|
||||
|
||||
// 问诊订单编号
|
||||
if req.InquiryNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where("inquiry_no = ?", req.InquiryNo)
|
||||
query = query.Where(prescriptionTable+".order_inquiry_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 药品订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderProduct{}).
|
||||
Select("order_prescription_id").
|
||||
Where("order_product_no = ?", req.OrderProductNo)
|
||||
query = query.Where(prescriptionTable+".order_prescription_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 药师审核时间
|
||||
if req.PharmacistVerifyTime != "" {
|
||||
pharmacistVerifyTime := strings.Split(req.PharmacistVerifyTime, "&")
|
||||
if len(pharmacistVerifyTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where(prescriptionTable+".pharmacist_verify_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 医生开具处方时间
|
||||
if req.DoctorCreatedTime != "" {
|
||||
doctorCreatedTime := strings.Split(req.DoctorCreatedTime, "&")
|
||||
if len(doctorCreatedTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", doctorCreatedTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", doctorCreatedTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where(prescriptionTable+".doctor_created_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 处方过期时间
|
||||
if req.ExpiredTime != "" {
|
||||
expiredTime := strings.Split(req.ExpiredTime, "&")
|
||||
if len(expiredTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", expiredTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", expiredTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where(prescriptionTable+".expired_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order(prescriptionTable + ".created_at desc")
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionExportListSearch 获取抄方的处方列表-导出
|
||||
func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req requests.OrderPrescriptionExportList) (m []*model.OrderPrescription, err error) {
|
||||
|
||||
prescriptionTable := (&model.OrderPrescription{}).TableName()
|
||||
inquiryTable := (&model.OrderInquiry{}).TableName()
|
||||
userTable := (&model.User{}).TableName()
|
||||
doctorTable := (&model.UserDoctor{}).TableName()
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Where(inquiryTable + ".annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 关联问诊表,只查询TransferDoctorId不等于null的记录
|
||||
query = query.Joins("INNER JOIN " + inquiryTable + " ON " + prescriptionTable + ".order_inquiry_id = " + inquiryTable + ".order_inquiry_id").
|
||||
Where(inquiryTable + ".transfer_doctor_id IS NOT NULL")
|
||||
|
||||
// 关联抄方医生表
|
||||
query = query.Joins("LEFT JOIN " + doctorTable + " ON " + inquiryTable + ".doctor_id = " + doctorTable + ".doctor_id")
|
||||
|
||||
// 关联抄方医生对应的用户表(用于按用户姓名查询)
|
||||
query = query.Joins("LEFT JOIN " + userTable + " ON " + doctorTable + ".user_id = " + userTable + ".user_id")
|
||||
|
||||
// 患者表
|
||||
query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
@@ -261,19 +525,44 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests
|
||||
// 处方关联疾病表
|
||||
query = query.Preload("OrderPrescriptionIcd")
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
// 患者家庭成员表
|
||||
query = query.Preload("PatientFamily")
|
||||
|
||||
// 药房表
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 当前搜索数据
|
||||
if req.Type == 1 {
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where(prescriptionTable+".pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 处方编号
|
||||
if req.PrescriptionCode != "" {
|
||||
query = query.Where("prescription_code = ?", req.PrescriptionCode)
|
||||
}
|
||||
|
||||
// 医生名称
|
||||
// // 医生名称
|
||||
// if req.DoctorName != "" {
|
||||
// query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
// }
|
||||
// 医生名称 - 查询抄方医生名称
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
query = query.Where(userTable+".user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
@@ -281,7 +570,7 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests
|
||||
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者/就诊人
|
||||
// 手机号-医生/患者/就诊人(医生部分改为抄方医生)
|
||||
if req.Mobile != "" {
|
||||
// 就诊人
|
||||
patientFamilySubQuery := global.Db.Model(&model.PatientFamily{}).
|
||||
@@ -297,16 +586,20 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests
|
||||
Select("patient_id").
|
||||
Where(gorm.Expr("user_id IN (?)", patientUserSubQuery))
|
||||
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
// 抄方医生:通过手机号找到 user_id -> doctor_id(抄方医生)
|
||||
transferDoctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
Where(gorm.Expr("user_id IN (?)", transferDoctorUserSubQuery))
|
||||
|
||||
query = query.Where("patient_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery).Or("family_id IN (?)", patientFamilySubQuery)
|
||||
// 使用 OR 条件:患者匹配 OR 抄方医生匹配 OR 就诊人匹配(整体加括号)
|
||||
query = query.Where(
|
||||
gorm.Expr("("+prescriptionTable+".patient_id IN (?) OR "+inquiryTable+".doctor_id IN (?) OR "+prescriptionTable+".family_id IN (?))",
|
||||
patientSubQuery, transferDoctorSubQuery, patientFamilySubQuery),
|
||||
)
|
||||
}
|
||||
|
||||
// 处方状态
|
||||
@@ -329,7 +622,196 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests
|
||||
|
||||
// 药品订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderProduct{}).
|
||||
Select("order_prescription_id").
|
||||
Where("order_product_no = ?", req.OrderProductNo)
|
||||
query = query.Where("order_prescription_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 药师审核时间
|
||||
if req.PharmacistVerifyTime != "" {
|
||||
pharmacistVerifyTime := strings.Split(req.PharmacistVerifyTime, "&")
|
||||
if len(pharmacistVerifyTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", pharmacistVerifyTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where("pharmacist_verify_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 医生开具处方时间
|
||||
if req.DoctorCreatedTime != "" {
|
||||
doctorCreatedTime := strings.Split(req.DoctorCreatedTime, "&")
|
||||
if len(doctorCreatedTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", doctorCreatedTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", doctorCreatedTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where("doctor_created_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 处方过期时间
|
||||
if req.ExpiredTime != "" {
|
||||
expiredTime := strings.Split(req.ExpiredTime, "&")
|
||||
if len(expiredTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", expiredTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", expiredTime[1])
|
||||
|
||||
if startTime == endTime {
|
||||
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||
}
|
||||
|
||||
query = query.Where("expired_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当前选中数据
|
||||
if req.Type == 2 {
|
||||
if req.Id == "" {
|
||||
return nil, errors.New("未提供需导出数据编号")
|
||||
}
|
||||
|
||||
id := strings.Split(req.Id, ",")
|
||||
query = query.Where("order_prescription_id IN (?)", id)
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
err = query.Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionExportListSearch 获取处方列表-导出
|
||||
func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests.OrderPrescriptionExportList) (m []*model.OrderPrescription, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Joins("JOIN gdxz_order_inquiry ON gdxz_order_inquiry.order_inquiry_id = gdxz_order_prescription.order_inquiry_id")
|
||||
query = query.Where("gdxz_order_inquiry.annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 患者表
|
||||
query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 用户表
|
||||
query = query.Preload("UserPatient.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 医生表
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 药师表
|
||||
query = query.Preload("UserPharmacist", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 处方关联疾病表
|
||||
query = query.Preload("OrderPrescriptionIcd")
|
||||
|
||||
// 患者家庭成员表
|
||||
query = query.Preload("PatientFamily")
|
||||
|
||||
// 药房表
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 当前搜索数据
|
||||
if req.Type == 1 {
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where("gdxz_order_prescription.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 处方编号
|
||||
if req.PrescriptionCode != "" {
|
||||
query = query.Where("prescription_code = ?", req.PrescriptionCode)
|
||||
}
|
||||
|
||||
// 医生名称
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
if req.PatientName != "" {
|
||||
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者/就诊人
|
||||
if req.Mobile != "" {
|
||||
// 就诊人
|
||||
patientFamilySubQuery := global.Db.Model(&model.PatientFamily{}).
|
||||
Select("family_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
// 患者
|
||||
patientUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
patientSubQuery := global.Db.Model(&model.UserPatient{}).
|
||||
Select("patient_id").
|
||||
Where(gorm.Expr("user_id IN (?)", patientUserSubQuery))
|
||||
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
|
||||
query = query.Where("patient_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery).Or("family_id IN (?)", patientFamilySubQuery)
|
||||
}
|
||||
|
||||
// 处方状态
|
||||
if req.PrescriptionStatus != nil {
|
||||
query = query.Where("prescription_status = ?", req.PrescriptionStatus)
|
||||
}
|
||||
|
||||
// 药师审核状态
|
||||
if req.PharmacistAuditStatus != nil {
|
||||
query = query.Where("pharmacist_audit_status = ?", req.PharmacistAuditStatus)
|
||||
}
|
||||
|
||||
// 问诊订单编号
|
||||
if req.InquiryNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where("inquiry_no = ?", req.InquiryNo)
|
||||
query = query.Where("order_inquiry_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 药品订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
subQuery := global.Db.Model(&model.OrderProduct{}).
|
||||
Select("order_prescription_id").
|
||||
Where("order_product_no = ?", req.OrderProductNo)
|
||||
query = query.Where("order_prescription_id IN (?)", subQuery)
|
||||
|
||||
+148
-15
@@ -2,13 +2,14 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
type OrderProductDao struct {
|
||||
@@ -25,7 +26,21 @@ func (r *OrderProductDao) GetOrderProductById(orderProductId int64) (m *model.Or
|
||||
|
||||
// GetOrderProductPreloadById 获取药品订单数据-加载全部关联-药品订单id
|
||||
func (r *OrderProductDao) GetOrderProductPreloadById(orderProductId int64) (m *model.OrderProduct, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, orderProductId).Error
|
||||
query := global.Db.Model(&model.OrderProduct{})
|
||||
|
||||
// 预加载所有关联
|
||||
query = query.Preload(clause.Associations)
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
err = query.First(&m, orderProductId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -108,21 +123,58 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderProduct{})
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Joins("JOIN gdxz_order_inquiry ON gdxz_order_inquiry.order_inquiry_id = gdxz_order_product.order_inquiry_id")
|
||||
query = query.Where("gdxz_order_inquiry.annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 药品数据
|
||||
query = query.Preload("OrderProductItem")
|
||||
|
||||
// 药房数据
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 医生姓名
|
||||
// 医生姓名 - 同时查询原医生和抄方医生
|
||||
if req.DoctorName != "" {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
// 原医生查询条件
|
||||
originalDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
// 抄方医生查询条件
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
// 查询抄方医生对应的问诊订单ID
|
||||
inquirySubQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where(gorm.Expr("doctor_id IN (?)", transferDoctorSubQuery))
|
||||
|
||||
// 使用 OR 条件:原医生匹配 OR 抄方医生匹配
|
||||
// 通过嵌套 Where 子查询把 OR 条件包在一组括号里,避免影响其它条件
|
||||
orCond := global.Db.
|
||||
Where(gorm.Expr("doctor_id IN (?)", originalDoctorSubQuery)).
|
||||
Or(gorm.Expr("order_inquiry_id IN (?)", inquirySubQuery))
|
||||
|
||||
query = query.Where(orCond)
|
||||
}
|
||||
|
||||
// 处方
|
||||
@@ -132,7 +184,11 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
||||
|
||||
// 问诊订单
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("order_inquiry_id", "patient_name_mask", "patient_sex", "patient_age")
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "doctor_id")
|
||||
})
|
||||
})
|
||||
|
||||
// 患者名称
|
||||
@@ -172,6 +228,16 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
||||
query = query.Where("order_product_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 处方编号
|
||||
if req.PrescriptionCode != "" {
|
||||
// 处方编号存在于处方表中,这里通过处方表查询出对应的处方ID,再反查商品订单
|
||||
subQuery := global.Db.Model(&model.OrderPrescription{}).
|
||||
Select("order_prescription_id").
|
||||
Where("prescription_code = ?", req.PrescriptionCode)
|
||||
|
||||
query = query.Where("order_prescription_id IN (?)", subQuery)
|
||||
}
|
||||
|
||||
// 订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
query = query.Where("order_product_no = ?", req.OrderProductNo)
|
||||
@@ -302,7 +368,7 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
||||
query = query.Where("consignee_tel LIKE ?", "%"+req.ConsigneeTel+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者
|
||||
// 手机号-医生/患者 - 同时查询原医生和抄方医生
|
||||
if req.Mobile != "" {
|
||||
// 患者
|
||||
patientUserSubQuery := global.Db.Model(&model.User{}).
|
||||
@@ -313,16 +379,37 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
|
||||
Select("patient_id").
|
||||
Where(gorm.Expr("user_id IN (?)", patientUserSubQuery))
|
||||
|
||||
// 医生
|
||||
// 原医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
originalDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
|
||||
query = query.Where("patient_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery)
|
||||
// 抄方医生
|
||||
transferDoctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", transferDoctorUserSubQuery))
|
||||
|
||||
// 查询抄方医生对应的问诊订单ID
|
||||
inquirySubQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where(gorm.Expr("doctor_id IN (?)", transferDoctorSubQuery))
|
||||
|
||||
// 使用 OR 条件:患者匹配 OR 原医生匹配 OR 抄方医生匹配
|
||||
// 通过嵌套 Where 子查询把 OR 条件包在一组括号里,避免影响其它条件
|
||||
orCond := global.Db.
|
||||
Where("patient_id IN (?)", patientSubQuery).
|
||||
Or("doctor_id IN (?)", originalDoctorSubQuery).
|
||||
Or(gorm.Expr("order_inquiry_id IN (?)", inquirySubQuery))
|
||||
|
||||
query = query.Where(orCond)
|
||||
}
|
||||
|
||||
// 排序
|
||||
@@ -345,6 +432,12 @@ func (r *OrderProductDao) GetOrderProductExportListSearch(req requests.OrderProd
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderProduct{})
|
||||
|
||||
// 年度审查隐藏
|
||||
if req.AnnualReviewHide != nil {
|
||||
query = query.Joins("JOIN gdxz_order_inquiry ON gdxz_order_inquiry.order_inquiry_id = gdxz_order_product.order_inquiry_id")
|
||||
query = query.Where("gdxz_order_inquiry.annual_review_hide = ?", req.AnnualReviewHide)
|
||||
}
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
@@ -359,11 +452,20 @@ func (r *OrderProductDao) GetOrderProductExportListSearch(req requests.OrderProd
|
||||
return db.Select("order_prescription_id", "prescription_code")
|
||||
})
|
||||
|
||||
// 问诊订单
|
||||
// query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
// return db.Select("order_inquiry_id", "patient_name", "patient_name_mask", "patient_sex", "patient_age")
|
||||
// })
|
||||
// 问诊订单
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("order_inquiry_id", "patient_name", "patient_name_mask", "patient_sex", "patient_age")
|
||||
return db.Preload("UserDoctor.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "mobile")
|
||||
}).Preload("TransferUserDoctor.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "mobile")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// 患者
|
||||
query = query.Preload("UserPatient.User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("user_id", "user_name", "mobile")
|
||||
@@ -375,15 +477,46 @@ func (r *OrderProductDao) GetOrderProductExportListSearch(req requests.OrderProd
|
||||
// 药品列表-药品
|
||||
query = query.Preload("OrderProductItem.Product")
|
||||
|
||||
// 药房数据
|
||||
query = query.Preload("Pharmacy")
|
||||
|
||||
// 当前搜索数据
|
||||
if req.Type == 1 {
|
||||
// 医生姓名
|
||||
// 药房筛选
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where("gdxz_order_product.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
// 医生姓名 - 同时查询原医生和抄方医生
|
||||
if req.DoctorName != "" {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
// 原医生查询条件
|
||||
originalDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
// 抄方医生查询条件
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
// 查询抄方医生对应的问诊订单ID
|
||||
inquirySubQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where(gorm.Expr("doctor_id IN (?)", transferDoctorSubQuery))
|
||||
|
||||
// 使用 OR 条件:原医生匹配 OR 抄方医生匹配
|
||||
// 通过嵌套 Where 子查询把 OR 条件包在一组括号里,避免影响其它条件
|
||||
orCond := global.Db.
|
||||
Where(gorm.Expr("doctor_id IN (?)", originalDoctorSubQuery)).
|
||||
Or(gorm.Expr("order_inquiry_id IN (?)", inquirySubQuery))
|
||||
|
||||
query = query.Where(orCond)
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type PharmacyDao struct{}
|
||||
|
||||
// GetPharmacyById 获取药房数据-药房id
|
||||
func (r *PharmacyDao) GetPharmacyById(pharmacyId int64) (m *model.Pharmacy, err error) {
|
||||
err = global.Db.Where("pharmacy_id = ? AND status != ?", pharmacyId, 2).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetPharmacyByCode 获取药房数据-药房代码
|
||||
func (r *PharmacyDao) GetPharmacyByCode(code string) (m *model.Pharmacy, err error) {
|
||||
err = global.Db.Where("pharmacy_code = ? AND status != ?", code, 2).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddPharmacy 新增药房
|
||||
func (r *PharmacyDao) AddPharmacy(tx *gorm.DB, m *model.Pharmacy) (*model.Pharmacy, error) {
|
||||
if err := tx.Create(m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// EditPharmacyById 修改药房-药房id
|
||||
func (r *PharmacyDao) EditPharmacyById(tx *gorm.DB, pharmacyId int64, data interface{}) error {
|
||||
err := tx.Model(&model.Pharmacy{}).Where("pharmacy_id = ?", pharmacyId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeletePharmacyById 软删除药房-药房id
|
||||
func (r *PharmacyDao) DeletePharmacyById(tx *gorm.DB, pharmacyId int64) error {
|
||||
err := tx.Model(&model.Pharmacy{}).Where("pharmacy_id = ?", pharmacyId).Update("status", 2).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPharmacyList 获取药房列表
|
||||
func (r *PharmacyDao) GetPharmacyList(maps interface{}) (m []*model.Pharmacy, err error) {
|
||||
err = global.Db.Where(maps).Where("status != ?", 2).Order("created_at desc").Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetPharmacyPageSearch 获取药房列表-分页
|
||||
func (r *PharmacyDao) GetPharmacyPageSearch(req requests.GetPharmacyPage, page, pageSize int) (m []*model.Pharmacy, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
query := global.Db.Model(&model.Pharmacy{}).Where("status != ?", 2)
|
||||
|
||||
if req.PharmacyName != "" {
|
||||
query = query.Where("pharmacy_name LIKE ?", "%"+req.PharmacyName+"%")
|
||||
}
|
||||
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
if req.Status != nil {
|
||||
query = query.Where("status = ?", *req.Status)
|
||||
}
|
||||
|
||||
if req.IsPickup != nil {
|
||||
query = query.Where("is_pickup = ?", *req.IsPickup)
|
||||
}
|
||||
|
||||
if req.ProvinceId != 0 {
|
||||
query = query.Where("province_id = ?", req.ProvinceId)
|
||||
}
|
||||
|
||||
if req.CityId != nil {
|
||||
query = query.Where("city_id = ?", req.CityId)
|
||||
}
|
||||
|
||||
if req.CountyId != nil {
|
||||
query = query.Where("county_id = ?", req.CountyId)
|
||||
}
|
||||
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
+59
-6
@@ -15,10 +15,16 @@ type ProductDao struct {
|
||||
|
||||
// GetProductById 获取商品数据-商品id
|
||||
func (r *ProductDao) GetProductById(productId int64) (m *model.Product, err error) {
|
||||
err = global.Db.First(&m, productId).Error
|
||||
err = global.Db.Preload("Pharmacy").First(&m, productId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if m != nil && m.Pharmacy == nil && m.PharmacyId == 0 {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
m.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -85,7 +91,7 @@ func (r *ProductDao) GetProductPageSearch(req requests.GetProductPage, page, pag
|
||||
// 库存表
|
||||
query = query.Preload("ProductPlatformAmount", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("amount_id", "product_platform_id", "product_platform_code", "stock")
|
||||
})
|
||||
}).Preload("Pharmacy")
|
||||
|
||||
// 商品名称
|
||||
if req.ProductName != "" {
|
||||
@@ -132,6 +138,16 @@ func (r *ProductDao) GetProductPageSearch(req requests.GetProductPage, page, pag
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 所属药房ID
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
|
||||
// 所属药房编码
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
@@ -171,6 +187,7 @@ func (r *ProductDao) GetProductPageSearch(req requests.GetProductPage, page, pag
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
fillZeroPharmacy(m)
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
@@ -182,7 +199,7 @@ func (r *ProductDao) GetProductExportListSearch(req requests.ProductExportList)
|
||||
// 库存表
|
||||
query = query.Preload("ProductPlatformAmount", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("amount_id", "product_platform_id", "product_platform_code", "stock")
|
||||
})
|
||||
}).Preload("Pharmacy")
|
||||
|
||||
// 当前搜索数据
|
||||
if req.Type == 1 {
|
||||
@@ -226,6 +243,16 @@ func (r *ProductDao) GetProductExportListSearch(req requests.ProductExportList)
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 所属药房ID
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
|
||||
// 所属药房编码
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
@@ -259,7 +286,7 @@ func (r *ProductDao) GetProductExportListSearch(req requests.ProductExportList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fillZeroPharmacy(m)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -271,7 +298,7 @@ func (r *ProductDao) GetProductListSearch(req requests.GetProductList) (m []*mod
|
||||
// 库存表
|
||||
query = query.Preload("ProductPlatformAmount", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("amount_id", "product_platform_id", "product_platform_code", "stock")
|
||||
})
|
||||
}).Preload("Pharmacy")
|
||||
|
||||
// 商品id
|
||||
if req.ProductId != "" {
|
||||
@@ -323,6 +350,16 @@ func (r *ProductDao) GetProductListSearch(req requests.GetProductList) (m []*mod
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 所属药房ID
|
||||
if req.PharmacyId != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_id = ?", req.PharmacyId)
|
||||
}
|
||||
|
||||
// 所属药房编码
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("gdxz_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
@@ -348,6 +385,22 @@ func (r *ProductDao) GetProductListSearch(req requests.GetProductList) (m []*mod
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fillZeroPharmacy(m)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// fillZeroPharmacy 补全因 GORM 零值跳过预加载的 pharmacy_id = 0 药房实体
|
||||
func fillZeroPharmacy(products []*model.Product) {
|
||||
var zeroPharmacy *model.Pharmacy
|
||||
for _, p := range products {
|
||||
if p.Pharmacy == nil && p.PharmacyId == 0 {
|
||||
if zeroPharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
zeroPharmacy = &ph
|
||||
}
|
||||
}
|
||||
p.Pharmacy = zeroPharmacy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
@@ -16,6 +18,9 @@ func (r *ProductPlatformDao) GetProductPlatformById(productPlatformId int64) (m
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if m != nil {
|
||||
fillPlatformPharmacy([]*model.ProductPlatform{m})
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -25,6 +30,7 @@ func (r *ProductPlatformDao) GetProductPlatformList(maps interface{}) (m []*mode
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fillPlatformPharmacy(m)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -90,6 +96,37 @@ func (r *ProductPlatformDao) GetPlatformProductPageSearch(req requests.GetPlatfo
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 所属药房ID
|
||||
if req.PharmacyId != "" {
|
||||
pId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err == nil {
|
||||
var ph model.Pharmacy
|
||||
var dbErr error
|
||||
if pId == 0 {
|
||||
dbErr = global.Db.Where("pharmacy_id = 0").First(&ph).Error
|
||||
} else {
|
||||
dbErr = global.Db.Where("pharmacy_id = ? AND status != 2", pId).First(&ph).Error
|
||||
}
|
||||
if dbErr == nil {
|
||||
if ph.PharmacyCode != "" {
|
||||
query = query.Where("pharmacy_code = ?", ph.PharmacyCode)
|
||||
} else {
|
||||
query = query.Where("(pharmacy_code = '' OR pharmacy_code IS NULL)")
|
||||
}
|
||||
} else if pId == 0 {
|
||||
// 兜底:若数据库暂无 pharmacy_id = 0 的记录,仍匹配 pharmacy_code 为空的默认商品
|
||||
query = query.Where("(pharmacy_code = '' OR pharmacy_code IS NULL)")
|
||||
} else {
|
||||
query = query.Where("1 = 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方药房编码
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
@@ -112,6 +149,7 @@ func (r *ProductPlatformDao) GetPlatformProductPageSearch(req requests.GetPlatfo
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
fillPlatformPharmacy(m)
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
@@ -140,6 +178,36 @@ func (r *ProductPlatformDao) GetPlatformProductListSearch(req requests.GetPlatfo
|
||||
query = query.Where("product_pharmacy_code LIKE ?", "%"+req.ProductPharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 所属药房ID
|
||||
if req.PharmacyId != "" {
|
||||
pId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err == nil {
|
||||
var ph model.Pharmacy
|
||||
var dbErr error
|
||||
if pId == 0 {
|
||||
dbErr = global.Db.Where("pharmacy_id = 0").First(&ph).Error
|
||||
} else {
|
||||
dbErr = global.Db.Where("pharmacy_id = ? AND status != 2", pId).First(&ph).Error
|
||||
}
|
||||
if dbErr == nil {
|
||||
if ph.PharmacyCode != "" {
|
||||
query = query.Where("pharmacy_code = ?", ph.PharmacyCode)
|
||||
} else {
|
||||
query = query.Where("(pharmacy_code = '' OR pharmacy_code IS NULL)")
|
||||
}
|
||||
} else if pId == 0 {
|
||||
query = query.Where("(pharmacy_code = '' OR pharmacy_code IS NULL)")
|
||||
} else {
|
||||
query = query.Where("1 = 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方药房编码
|
||||
if req.PharmacyCode != "" {
|
||||
query = query.Where("pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%")
|
||||
}
|
||||
|
||||
// 批准文号
|
||||
if req.LicenseNumber != "" {
|
||||
query = query.Where("license_number LIKE ?", "%"+req.LicenseNumber+"%")
|
||||
@@ -157,5 +225,68 @@ func (r *ProductPlatformDao) GetPlatformProductListSearch(req requests.GetPlatfo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fillPlatformPharmacy(m)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// fillPlatformPharmacy 批量补全平台商品的所属药房实体
|
||||
func fillPlatformPharmacy(list []*model.ProductPlatform) {
|
||||
if len(list) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 1. 收集非空的 pharmacy_code
|
||||
var codes []string
|
||||
codeMap := make(map[string]bool)
|
||||
for _, item := range list {
|
||||
if item.PharmacyCode != "" && !codeMap[item.PharmacyCode] {
|
||||
codeMap[item.PharmacyCode] = true
|
||||
codes = append(codes, item.PharmacyCode)
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 批量查出对应药房
|
||||
pharmacyByCode := make(map[string]*model.Pharmacy)
|
||||
if len(codes) > 0 {
|
||||
var pharmacies []*model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_code IN ? AND status != 2", codes).Find(&pharmacies).Error; err == nil {
|
||||
for _, ph := range pharmacies {
|
||||
pharmacyByCode[ph.PharmacyCode] = ph
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 兜底获取默认药房 (pharmacy_id = 0)
|
||||
var zeroPharmacy *model.Pharmacy
|
||||
hasLoadedZero := false
|
||||
getZeroPharmacy := func() *model.Pharmacy {
|
||||
if !hasLoadedZero {
|
||||
hasLoadedZero = true
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = 0").First(&ph).Error; err == nil {
|
||||
zeroPharmacy = &ph
|
||||
}
|
||||
}
|
||||
return zeroPharmacy
|
||||
}
|
||||
|
||||
// 4. 回填
|
||||
for _, item := range list {
|
||||
if item.PharmacyCode != "" {
|
||||
if ph, ok := pharmacyByCode[item.PharmacyCode]; ok {
|
||||
item.Pharmacy = ph
|
||||
} else {
|
||||
zPh := getZeroPharmacy()
|
||||
if zPh != nil && zPh.PharmacyCode == item.PharmacyCode {
|
||||
item.Pharmacy = zPh
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// pharmacy_code 为空,默认归属到 pharmacy_id = 0
|
||||
zPh := getZeroPharmacy()
|
||||
if zPh != nil {
|
||||
item.Pharmacy = zPh
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ type Login struct {
|
||||
NickName string `json:"nick_name"` // 昵称
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Token string `json:"token"` // 用户名
|
||||
RoleName string `json:"role_name"` // 角色名
|
||||
}
|
||||
|
||||
// GetLoginFullAvatar 返回带有指定字符串的头像路径
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorPharmacyDto struct {
|
||||
DoctorPharmacyId string `json:"doctor_pharmacy_id"` // 绑定关系id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
PharmacyId string `json:"pharmacy_id"` // 药房id
|
||||
PharmacyName string `json:"pharmacy_name"` // 药房名称
|
||||
PharmacyCode string `json:"pharmacy_code"` // 药房代码
|
||||
Postage float64 `json:"postage"` // 基础邮费
|
||||
FreeShippingThreshold float64 `json:"free_shipping_threshold"` // 满XX包邮门槛金额
|
||||
IsPickup int `json:"is_pickup"` // 是否支持自提(0:否 1:是)
|
||||
Telephone string `json:"telephone"` // 电话
|
||||
Province string `json:"province"` // 省份
|
||||
City string `json:"city"` // 城市
|
||||
County string `json:"county"` // 区县
|
||||
Address string `json:"address"` // 详细地址
|
||||
FullAddress string `json:"full_address"` // 完整地址
|
||||
IsDefault int `json:"is_default"` // 是否默认药房(0:否 1:是)
|
||||
Status int `json:"status"` // 状态(0:禁用 1:正常)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 绑定时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
func GetDoctorPharmacyDto(m *model.DoctorPharmacy) *DoctorPharmacyDto {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
dto := &DoctorPharmacyDto{
|
||||
DoctorPharmacyId: fmt.Sprintf("%d", m.DoctorPharmacyId),
|
||||
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
IsDefault: m.IsDefault,
|
||||
Status: m.Status,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
if m.Pharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = ?", m.PharmacyId).First(&ph).Error; err == nil {
|
||||
m.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
if m.Pharmacy != nil {
|
||||
dto.PharmacyName = m.Pharmacy.PharmacyName
|
||||
dto.PharmacyCode = m.Pharmacy.PharmacyCode
|
||||
dto.Postage = m.Pharmacy.Postage
|
||||
dto.FreeShippingThreshold = m.Pharmacy.FreeShippingThreshold
|
||||
dto.IsPickup = m.Pharmacy.IsPickup
|
||||
dto.Telephone = m.Pharmacy.Telephone
|
||||
dto.Province = m.Pharmacy.Province
|
||||
dto.City = m.Pharmacy.City
|
||||
dto.County = m.Pharmacy.County
|
||||
dto.Address = m.Pharmacy.Address
|
||||
dto.FullAddress = fmt.Sprintf("%s%s%s%s", m.Pharmacy.Province, m.Pharmacy.City, m.Pharmacy.County, m.Pharmacy.Address)
|
||||
}
|
||||
return dto
|
||||
}
|
||||
|
||||
func GetDoctorPharmacyListDto(list []*model.DoctorPharmacy) []*DoctorPharmacyDto {
|
||||
res := make([]*DoctorPharmacyDto, len(list))
|
||||
for i, v := range list {
|
||||
res[i] = GetDoctorPharmacyDto(v)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -11,6 +11,7 @@ type OrderInquiryDto struct {
|
||||
UserId string `json:"user_id"` // 用户id-患者
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
DoctorId string `json:"doctor_id"` // 医生id(未分配时为null)
|
||||
TransferDoctorId string `json:"transfer_doctor_id"` // 接受抄方的医生id
|
||||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
@@ -39,6 +40,7 @@ type OrderInquiryDto struct {
|
||||
PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码)
|
||||
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||
AnnualReviewHide int `json:"annual_review_hide"` // 年度审查隐藏(0:否 1:是)
|
||||
PatientMobile string `json:"patient_mobile"` // 患者电话
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
UserName string `json:"user_name"` // 用户姓名(患者)
|
||||
@@ -61,11 +63,17 @@ func GetOrderInquiryDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
doctorId = fmt.Sprintf("%v", m.DoctorId)
|
||||
}
|
||||
|
||||
var transferDoctorId string
|
||||
if m.TransferDoctorId != 0 {
|
||||
transferDoctorId = fmt.Sprintf("%v", m.TransferDoctorId)
|
||||
}
|
||||
|
||||
return &OrderInquiryDto{
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
DoctorId: doctorId,
|
||||
TransferDoctorId: transferDoctorId,
|
||||
PatientId: fmt.Sprintf("%d", m.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", m.FamilyId),
|
||||
InquiryType: m.InquiryType,
|
||||
@@ -95,6 +103,7 @@ func GetOrderInquiryDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
PatientNameMask: m.PatientNameMask,
|
||||
PatientSex: m.PatientSex,
|
||||
PatientAge: m.PatientAge,
|
||||
AnnualReviewHide: m.AnnualReviewHide,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
@@ -113,6 +122,7 @@ func GetOrderInquiryListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@@ -141,6 +151,7 @@ func GetOrderInquiryListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
PatientNameMask: v.PatientNameMask,
|
||||
PatientSex: v.PatientSex,
|
||||
PatientAge: v.PatientAge,
|
||||
AnnualReviewHide: v.AnnualReviewHide,
|
||||
PatientMobile: v.User.Mobile,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
@@ -172,6 +183,7 @@ func GetOrderInquiryRecordListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@@ -192,6 +204,7 @@ func GetOrderInquiryRecordListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
PatientNameMask: v.PatientNameMask,
|
||||
PatientSex: v.PatientSex,
|
||||
PatientAge: v.PatientAge,
|
||||
AnnualReviewHide: v.AnnualReviewHide,
|
||||
PatientMobile: v.User.Mobile,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
@@ -228,6 +241,7 @@ func GetOrderInquiryForAccountListDto(m []*model.OrderInquiry) []*OrderInquiryDt
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@@ -255,6 +269,7 @@ func GetOrderInquiryForAccountListDto(m []*model.OrderInquiry) []*OrderInquiryDt
|
||||
PatientNameMask: v.PatientNameMask,
|
||||
PatientSex: v.PatientSex,
|
||||
PatientAge: v.PatientAge,
|
||||
AnnualReviewHide: v.AnnualReviewHide,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
@@ -279,11 +294,17 @@ func GetOrderInquiryRecordDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
doctorId = fmt.Sprintf("%v", m.DoctorId)
|
||||
}
|
||||
|
||||
var transferDoctorId string
|
||||
if m.TransferDoctorId != 0 {
|
||||
transferDoctorId = fmt.Sprintf("%v", m.TransferDoctorId)
|
||||
}
|
||||
|
||||
return &OrderInquiryDto{
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
DoctorId: doctorId,
|
||||
TransferDoctorId: transferDoctorId,
|
||||
PatientId: fmt.Sprintf("%d", m.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", m.FamilyId),
|
||||
InquiryType: m.InquiryType,
|
||||
@@ -313,6 +334,7 @@ func GetOrderInquiryRecordDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
PatientNameMask: m.PatientNameMask,
|
||||
PatientSex: m.PatientSex,
|
||||
PatientAge: m.PatientAge,
|
||||
AnnualReviewHide: m.AnnualReviewHide,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
|
||||
@@ -37,11 +37,31 @@ type OrderPrescriptionDto struct {
|
||||
OrderPrescriptionIcd string `json:"order_prescription_icd"` // 处方诊断疾病
|
||||
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
||||
OrderPrescriptionProduct []*OrderPrescriptionProductDto `json:"order_prescription_product"` // 处方商品
|
||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 原始医生
|
||||
InquiryDoctor *UserDoctorDto `json:"inquiry_doctor"` // 问诊医生信息
|
||||
TransferUserDoctor *UserDoctorDto `json:"transfer_prescription_doctor"` // 接受抄方的医生(抄方处方医生信息)
|
||||
PharmacyId string `json:"pharmacy_id"` // 药房id
|
||||
PharmacyCode string `json:"pharmacy_code"` // 药房代码
|
||||
PharmacyName string `json:"pharmacy_name"` // 药房名称
|
||||
Pharmacy *PharmacyDto `json:"pharmacy"` // 药房详情
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto {
|
||||
pharmacyName := m.PharmacyName
|
||||
pharmacyCode := m.PharmacyCode
|
||||
var pharmacyDto *PharmacyDto
|
||||
if m.Pharmacy != nil {
|
||||
pharmacyDto = GetPharmacyDto(m.Pharmacy)
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = m.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = m.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
return &OrderPrescriptionDto{
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
@@ -66,6 +86,10 @@ func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto {
|
||||
PatientSex: m.PatientSex,
|
||||
PatientAge: m.PatientAge,
|
||||
DoctorAdvice: m.DoctorAdvice,
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
PharmacyCode: pharmacyCode,
|
||||
PharmacyName: pharmacyName,
|
||||
Pharmacy: pharmacyDto,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
@@ -77,6 +101,19 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
pharmacyName := v.PharmacyName
|
||||
pharmacyCode := v.PharmacyCode
|
||||
var pharmacyDto *PharmacyDto
|
||||
if v.Pharmacy != nil {
|
||||
pharmacyDto = GetPharmacyDto(v.Pharmacy)
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
response := &OrderPrescriptionDto{
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||
@@ -101,6 +138,10 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript
|
||||
PatientSex: v.PatientSex,
|
||||
PatientAge: v.PatientAge,
|
||||
DoctorAdvice: v.DoctorAdvice,
|
||||
PharmacyId: fmt.Sprintf("%d", v.PharmacyId),
|
||||
PharmacyCode: pharmacyCode,
|
||||
PharmacyName: pharmacyName,
|
||||
Pharmacy: pharmacyDto,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
@@ -125,6 +166,16 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript
|
||||
response = response.LoadOrderPrescriptionIcdString(v.OrderPrescriptionIcd)
|
||||
}
|
||||
|
||||
// 加载问诊医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil {
|
||||
response = response.LoadInquiryDoctor(v.OrderInquiry.UserDoctor)
|
||||
}
|
||||
|
||||
// 加载接受抄方的医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.TransferUserDoctor != nil {
|
||||
response = response.LoadTransferUserDoctor(v.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
@@ -205,3 +256,19 @@ func (r *OrderPrescriptionDto) LoadOrderProductId(m *model.OrderProduct) *OrderP
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserDoctor 加载问诊医生信息
|
||||
func (r *OrderPrescriptionDto) LoadInquiryDoctor(m *model.UserDoctor) *OrderPrescriptionDto {
|
||||
if m != nil {
|
||||
r.InquiryDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadTransferUserDoctor 加载接受抄方的医生信息
|
||||
func (r *OrderPrescriptionDto) LoadTransferUserDoctor(m *model.UserDoctor) *OrderPrescriptionDto {
|
||||
if m != nil {
|
||||
r.TransferUserDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
+90
-1
@@ -13,6 +13,7 @@ type OrderProductDto struct {
|
||||
OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id;NOT NULL
|
||||
OrderId string `json:"order_id"` // 订单id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
TransferDoctorId string `json:"transfer_doctor_id"` // 接受抄方的医生id
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
OrderProductNo string `json:"order_product_no"` // 订单编号
|
||||
@@ -55,12 +56,19 @@ type OrderProductDto struct {
|
||||
OrderProductRefund *OrderProductRefundDto `json:"order_product_refund"` // 退款数据
|
||||
OrderProductItem []*OrderProductItemDto `json:"order_product_item"` // 商品数据
|
||||
OrderProductLogistics *OrderProductLogisticsDto `json:"order_product_logistics"` // 物流数据
|
||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据
|
||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 原始医生
|
||||
InquiryDoctor *UserDoctorDto `json:"inquiry_doctor"` // 问诊医生信息
|
||||
TransferUserDoctor *UserDoctorDto `json:"transfer_prescription_doctor"` // 接受抄方的医生(抄方处方医生信息)
|
||||
IsTransferOrder int `json:"is_transfer_order"` // 是否为抄方订单
|
||||
OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据
|
||||
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
||||
OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷
|
||||
ProductName string `json:"product_name"` // 药品数据
|
||||
DiscountAmount float64 `json:"discount_amount"` // 优惠金额
|
||||
PharmacyId string `json:"pharmacy_id"` // 药房id
|
||||
PharmacyCode string `json:"pharmacy_code"` // 药房代码
|
||||
PharmacyName string `json:"pharmacy_name"` // 药房名称
|
||||
Pharmacy *PharmacyDto `json:"pharmacy"` // 药房详情
|
||||
}
|
||||
|
||||
// OrderProductConsigneeDto 药品订单收货人数据
|
||||
@@ -77,6 +85,19 @@ type OrderProductConsigneeDto struct {
|
||||
}
|
||||
|
||||
func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto {
|
||||
pharmacyName := m.PharmacyName
|
||||
pharmacyCode := m.PharmacyCode
|
||||
var pharmacyDto *PharmacyDto
|
||||
if m.Pharmacy != nil {
|
||||
pharmacyDto = GetPharmacyDto(m.Pharmacy)
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = m.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = m.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
return &OrderProductDto{
|
||||
OrderProductId: fmt.Sprintf("%d", m.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
@@ -113,6 +134,10 @@ func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto {
|
||||
AddressMask: m.AddressMask,
|
||||
ConsigneeNameMask: m.ConsigneeNameMask,
|
||||
ConsigneeTelMask: m.ConsigneeTelMask,
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
PharmacyCode: pharmacyCode,
|
||||
PharmacyName: pharmacyName,
|
||||
Pharmacy: pharmacyDto,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
@@ -139,6 +164,19 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
pharmacyName := v.PharmacyName
|
||||
pharmacyCode := v.PharmacyCode
|
||||
var pharmacyDto *PharmacyDto
|
||||
if v.Pharmacy != nil {
|
||||
pharmacyDto = GetPharmacyDto(v.Pharmacy)
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
response := &OrderProductDto{
|
||||
OrderProductId: fmt.Sprintf("%d", v.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||
@@ -165,6 +203,10 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
|
||||
ConsigneeNameMask: v.ConsigneeNameMask,
|
||||
ConsigneeTelMask: v.ConsigneeTelMask,
|
||||
PatientMobile: v.UserPatient.User.Mobile,
|
||||
PharmacyId: fmt.Sprintf("%d", v.PharmacyId),
|
||||
PharmacyCode: pharmacyCode,
|
||||
PharmacyName: pharmacyName,
|
||||
Pharmacy: pharmacyDto,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
@@ -179,6 +221,21 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
|
||||
response = response.LoadOrderInquiryAttr(v.OrderInquiry)
|
||||
}
|
||||
|
||||
// 加载原问诊医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil {
|
||||
response = response.LoadInquiryDoctor(v.OrderInquiry.UserDoctor)
|
||||
}
|
||||
|
||||
//加载问诊类型
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil && v.OrderInquiry.TransferUserDoctor != nil {
|
||||
response = response.LoadIsTransferOrder(v.OrderInquiry.UserDoctor, v.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 加载接受抄方的医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.TransferUserDoctor != nil {
|
||||
response = response.LoadTransferUserDoctor(v.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 加载处方编号
|
||||
if v.OrderPrescription != nil {
|
||||
response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
|
||||
@@ -205,12 +262,44 @@ func (r *OrderProductDto) LoadDoctorName(m *model.UserDoctor) *OrderProductDto {
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
// LoadUserDoctor 加载问诊医生信息
|
||||
func (r *OrderProductDto) LoadInquiryDoctor(m *model.UserDoctor) *OrderProductDto {
|
||||
if m != nil {
|
||||
r.InquiryDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserDoctor 加载问诊类型
|
||||
func (r *OrderProductDto) LoadIsTransferOrder(m *model.UserDoctor, n *model.UserDoctor) *OrderProductDto {
|
||||
if m != nil && n != nil {
|
||||
if(int(m.DoctorId) != int(n.DoctorId)){
|
||||
r.IsTransferOrder = 1
|
||||
}else{
|
||||
r.IsTransferOrder = 0
|
||||
}
|
||||
}else{
|
||||
r.IsTransferOrder = 0
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadTransferUserDoctor 加载接受抄方的医生信息
|
||||
func (r *OrderProductDto) LoadTransferUserDoctor(m *model.UserDoctor) *OrderProductDto {
|
||||
if m != nil {
|
||||
r.TransferUserDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadOrderInquiryAttr 加载问诊属性
|
||||
func (r *OrderProductDto) LoadOrderInquiryAttr(m *model.OrderInquiry) *OrderProductDto {
|
||||
if m != nil {
|
||||
r.PatientNameMask = m.PatientNameMask
|
||||
r.PatientSex = m.PatientSex
|
||||
r.PatientAge = m.PatientAge
|
||||
r.TransferDoctorId = string(m.TransferDoctorId)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type PharmacyDto struct {
|
||||
PharmacyId string `json:"pharmacy_id"` // 主键id
|
||||
PharmacyName string `json:"pharmacy_name"` // 药房名称
|
||||
PharmacyCode string `json:"pharmacy_code"` // 药房代码
|
||||
Postage float64 `json:"postage"` // 基础邮费
|
||||
FreeShippingThreshold float64 `json:"free_shipping_threshold"` // 满XX包邮门槛金额
|
||||
IsPickup int `json:"is_pickup"` // 是否支持自提(0:否 1:是)
|
||||
Telephone string `json:"telephone"` // 电话
|
||||
ProvinceId int `json:"province_id"` // 省份id
|
||||
Province string `json:"province"` // 省份
|
||||
CityId int `json:"city_id"` // 城市id
|
||||
City string `json:"city"` // 城市
|
||||
CountyId int `json:"county_id"` // 区县id
|
||||
County string `json:"county"` // 区县
|
||||
Address string `json:"address"` // 详细地址
|
||||
FullAddress string `json:"full_address"` // 完整地址(省市区+详细地址)
|
||||
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetPharmacyDto(m *model.Pharmacy) *PharmacyDto {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
fullAddress := fmt.Sprintf("%s%s%s%s", m.Province, m.City, m.County, m.Address)
|
||||
return &PharmacyDto{
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
PharmacyName: m.PharmacyName,
|
||||
PharmacyCode: m.PharmacyCode,
|
||||
Postage: m.Postage,
|
||||
FreeShippingThreshold: m.FreeShippingThreshold,
|
||||
IsPickup: m.IsPickup,
|
||||
Telephone: m.Telephone,
|
||||
ProvinceId: m.ProvinceId,
|
||||
Province: m.Province,
|
||||
CityId: m.CityId,
|
||||
City: m.City,
|
||||
CountyId: m.CountyId,
|
||||
County: m.County,
|
||||
Address: m.Address,
|
||||
FullAddress: fullAddress,
|
||||
Status: m.Status,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetPharmacyListDto(m []*model.Pharmacy) []PharmacyDto {
|
||||
responses := make([]PharmacyDto, len(m))
|
||||
for i, v := range m {
|
||||
responses[i] = *GetPharmacyDto(v)
|
||||
}
|
||||
return responses
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type PharmacyDoctorDto struct {
|
||||
DoctorPharmacyId string `json:"doctor_pharmacy_id"` // 绑定关系id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 医生姓名
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
DoctorTitle int `json:"doctor_title"` // 职称代码
|
||||
DoctorTitleName string `json:"doctor_title_name"` // 职称名称
|
||||
DepartmentCustomId string `json:"department_custom_id"` // 科室id
|
||||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称
|
||||
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
||||
HospitalId string `json:"hospital_id"` // 医院id
|
||||
HospitalName string `json:"hospital_name"` // 医院名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
IsDefault int `json:"is_default"` // 是否为默认药房(0:否 1:是)
|
||||
Status int `json:"status"` // 状态(1:正常)
|
||||
BindTime model.LocalTime `json:"bind_time"` // 绑定时间
|
||||
}
|
||||
|
||||
var doctorTitleMap = map[int]string{
|
||||
1: "主任医师",
|
||||
2: "主任中医师",
|
||||
3: "副主任医师",
|
||||
4: "副主任中医师",
|
||||
5: "主治医师",
|
||||
6: "住院医师",
|
||||
}
|
||||
|
||||
func GetPharmacyDoctorDto(m *model.DoctorPharmacy) *PharmacyDoctorDto {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
dto := &PharmacyDoctorDto{
|
||||
DoctorPharmacyId: fmt.Sprintf("%d", m.DoctorPharmacyId),
|
||||
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||
IsDefault: m.IsDefault,
|
||||
Status: m.Status,
|
||||
BindTime: m.CreatedAt,
|
||||
}
|
||||
|
||||
if m.UserDoctor != nil {
|
||||
dto.UserId = fmt.Sprintf("%d", m.UserDoctor.UserId)
|
||||
dto.UserName = m.UserDoctor.UserName
|
||||
dto.Avatar = m.UserDoctor.Avatar
|
||||
dto.DoctorTitle = m.UserDoctor.DoctorTitle
|
||||
dto.DoctorTitleName = doctorTitleMap[m.UserDoctor.DoctorTitle]
|
||||
dto.DepartmentCustomId = fmt.Sprintf("%d", m.UserDoctor.DepartmentCustomId)
|
||||
dto.DepartmentCustomName = m.UserDoctor.DepartmentCustomName
|
||||
dto.DepartmentCustomMobile = m.UserDoctor.DepartmentCustomMobile
|
||||
dto.HospitalId = fmt.Sprintf("%d", m.UserDoctor.HospitalID)
|
||||
|
||||
if m.UserDoctor.Hospital != nil {
|
||||
dto.HospitalName = m.UserDoctor.Hospital.HospitalName
|
||||
}
|
||||
|
||||
if m.UserDoctor.User != nil {
|
||||
dto.Mobile = m.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
return dto
|
||||
}
|
||||
|
||||
func GetPharmacyDoctorListDto(list []*model.DoctorPharmacy) []PharmacyDoctorDto {
|
||||
res := make([]PharmacyDoctorDto, len(list))
|
||||
for i, v := range list {
|
||||
res[i] = *GetPharmacyDoctorDto(v)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// GetDoctorTitleName 获取医生职称名称
|
||||
func GetDoctorTitleName(title int) string {
|
||||
return doctorTitleMap[title]
|
||||
}
|
||||
|
||||
// BoundPharmacySimpleDto 医生绑定的药房简要信息
|
||||
type BoundPharmacySimpleDto struct {
|
||||
PharmacyId string `json:"pharmacy_id"`
|
||||
PharmacyName string `json:"pharmacy_name"`
|
||||
PharmacyCode string `json:"pharmacy_code"`
|
||||
IsDefault int `json:"is_default"`
|
||||
}
|
||||
|
||||
// AffectedDoctorItemDto 受影响的医生明细
|
||||
type AffectedDoctorItemDto struct {
|
||||
DoctorId string `json:"doctor_id"`
|
||||
DoctorPharmacyId string `json:"doctor_pharmacy_id"`
|
||||
UserId string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
Mobile string `json:"mobile"`
|
||||
DoctorTitleName string `json:"doctor_title_name"`
|
||||
HospitalId string `json:"hospital_id"`
|
||||
HospitalName string `json:"hospital_name"`
|
||||
DepartmentCustomId string `json:"department_custom_id"`
|
||||
DepartmentCustomName string `json:"department_custom_name"`
|
||||
IsDefault int `json:"is_default"` // 在当前待下线药房是否为默认(1:是 0:否)
|
||||
OtherBoundPharmacies []BoundPharmacySimpleDto `json:"other_bound_pharmacies"` // 该医生名下绑定的其他可用药房
|
||||
}
|
||||
|
||||
// PharmacyAffectedDoctorsDto 下线预检受影响医生列表响应
|
||||
type PharmacyAffectedDoctorsDto struct {
|
||||
PharmacyId string `json:"pharmacy_id"`
|
||||
PharmacyName string `json:"pharmacy_name"`
|
||||
PharmacyCode string `json:"pharmacy_code"`
|
||||
Status int `json:"status"`
|
||||
DefaultDoctorCount int64 `json:"default_doctor_count"`
|
||||
TotalDoctorCount int64 `json:"total_doctor_count"`
|
||||
DoctorList []AffectedDoctorItemDto `json:"doctor_list"`
|
||||
}
|
||||
+21
-1
@@ -9,6 +9,10 @@ import (
|
||||
type ProductDto struct {
|
||||
ProductId string `json:"product_id"` // 主键id
|
||||
ProductPlatformId string `json:"product_platform_id"` // 处方平台商品id
|
||||
PharmacyId string `json:"pharmacy_id"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code"` // 所属药房编码
|
||||
PharmacyName string `json:"pharmacy_name"` // 所属药房名称
|
||||
Pharmacy *PharmacyDto `json:"pharmacy"` // 所属药房详情
|
||||
ProductStatus int `json:"product_status"` // 商品状态(1:正常 2:下架)
|
||||
IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是)
|
||||
PrescriptionNum int `json:"prescription_num"` // 处方可开具的数量
|
||||
@@ -36,9 +40,11 @@ type ProductDto struct {
|
||||
|
||||
// GetProductDto 商品详情
|
||||
func GetProductDto(m *model.Product) *ProductDto {
|
||||
return &ProductDto{
|
||||
dto := &ProductDto{
|
||||
ProductId: fmt.Sprintf("%d", m.ProductId),
|
||||
ProductPlatformId: fmt.Sprintf("%d", m.ProductPlatformId),
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
PharmacyCode: m.PharmacyCode,
|
||||
ProductStatus: m.ProductStatus,
|
||||
IsDelete: m.IsDelete,
|
||||
PrescriptionNum: m.PrescriptionNum,
|
||||
@@ -62,6 +68,13 @@ func GetProductDto(m *model.Product) *ProductDto {
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
|
||||
if m.Pharmacy != nil {
|
||||
dto.Pharmacy = GetPharmacyDto(m.Pharmacy)
|
||||
dto.PharmacyName = m.Pharmacy.PharmacyName
|
||||
}
|
||||
|
||||
return dto
|
||||
}
|
||||
|
||||
// GetProductListDto 商品列表
|
||||
@@ -74,6 +87,8 @@ func GetProductListDto(m []*model.Product) []*ProductDto {
|
||||
response := &ProductDto{
|
||||
ProductId: fmt.Sprintf("%d", v.ProductId),
|
||||
ProductPlatformId: fmt.Sprintf("%d", v.ProductPlatformId),
|
||||
PharmacyId: fmt.Sprintf("%d", v.PharmacyId),
|
||||
PharmacyCode: v.PharmacyCode,
|
||||
ProductStatus: v.ProductStatus,
|
||||
IsDelete: v.IsDelete,
|
||||
PrescriptionNum: v.PrescriptionNum,
|
||||
@@ -98,6 +113,11 @@ func GetProductListDto(m []*model.Product) []*ProductDto {
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
if v.Pharmacy != nil {
|
||||
response.Pharmacy = GetPharmacyDto(v.Pharmacy)
|
||||
response.PharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
|
||||
// 加载商品库存
|
||||
if v.ProductPlatformAmount != nil {
|
||||
response = response.LoadProductAmount(v.ProductPlatformAmount)
|
||||
|
||||
+20
-21
@@ -12,6 +12,10 @@ type ProductPlatformDto struct {
|
||||
ProductType int `json:"product_type"` // 药品类型(0:未知 1:中成药 2:西药)
|
||||
ProductPlatformCode string `json:"product_platform_code"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code"` // 第三方药房编码
|
||||
PharmacyName string `json:"pharmacy_name"` // 所属药房名称
|
||||
Pharmacy *PharmacyDto `json:"pharmacy"` // 所属药房详情
|
||||
ProductSpec string `json:"product_spec"` // 商品规格
|
||||
LicenseNumber string `json:"license_number"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer"` // 生产厂家
|
||||
@@ -26,13 +30,16 @@ type ProductPlatformDto struct {
|
||||
|
||||
// GetProductPlatformDto 平台商品详情
|
||||
func GetProductPlatformDto(m *model.ProductPlatform) *ProductPlatformDto {
|
||||
return &ProductPlatformDto{
|
||||
dto := &ProductPlatformDto{
|
||||
ProductPlatformId: fmt.Sprintf("%d", m.ProductPlatformId),
|
||||
ProductName: m.ProductName,
|
||||
ProductPrice: m.ProductPrice,
|
||||
ProductType: m.ProductType,
|
||||
ProductPlatformCode: m.ProductPlatformCode,
|
||||
ProductPharmacyCode: m.ProductPharmacyCode,
|
||||
PharmacyId: "0",
|
||||
PharmacyCode: m.PharmacyCode,
|
||||
PharmacyName: "",
|
||||
ProductSpec: m.ProductSpec,
|
||||
LicenseNumber: m.LicenseNumber,
|
||||
Manufacturer: m.Manufacturer,
|
||||
@@ -43,6 +50,17 @@ func GetProductPlatformDto(m *model.ProductPlatform) *ProductPlatformDto {
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
|
||||
if m.Pharmacy != nil {
|
||||
dto.Pharmacy = GetPharmacyDto(m.Pharmacy)
|
||||
dto.PharmacyId = fmt.Sprintf("%d", m.Pharmacy.PharmacyId)
|
||||
dto.PharmacyName = m.Pharmacy.PharmacyName
|
||||
if dto.PharmacyCode == "" {
|
||||
dto.PharmacyCode = m.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
return dto
|
||||
}
|
||||
|
||||
// GetProductPlatformListDto 平台商品列表
|
||||
@@ -52,26 +70,7 @@ func GetProductPlatformListDto(m []*model.ProductPlatform) []*ProductPlatformDto
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &ProductPlatformDto{
|
||||
ProductPlatformId: fmt.Sprintf("%d", v.ProductPlatformId),
|
||||
ProductName: v.ProductName,
|
||||
ProductPrice: v.ProductPrice,
|
||||
ProductType: v.ProductType,
|
||||
ProductPlatformCode: v.ProductPlatformCode,
|
||||
ProductPharmacyCode: v.ProductPharmacyCode,
|
||||
ProductSpec: v.ProductSpec,
|
||||
LicenseNumber: v.LicenseNumber,
|
||||
Manufacturer: v.Manufacturer,
|
||||
SingleUnit: v.SingleUnit,
|
||||
PackagingUnit: v.PackagingUnit,
|
||||
PackagingCount: v.PackagingCount,
|
||||
RetailUnit: v.RetailUnit,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
responses[i] = GetProductPlatformDto(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -37,6 +37,7 @@ type UserDoctorDto struct {
|
||||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是)
|
||||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||||
IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是)
|
||||
IsTransferPrescription int `json:"is_transfer_prescription"` // 是否接受抄方(0:否 1:是)
|
||||
QrCode string `json:"qr_code"` // 分享二维码
|
||||
BeGoodAt string `json:"be_good_at"` // 擅长
|
||||
BriefIntroduction string `json:"brief_introduction"` // 医生简介
|
||||
@@ -51,6 +52,7 @@ type UserDoctorDto struct {
|
||||
Hospital *HospitalDto `json:"hospital"` // 医院
|
||||
UserDoctorInfo *UserDoctorInfoDto `json:"user_doctor_info"` // 医生详情
|
||||
DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长
|
||||
DoctorPharmacy []*DoctorPharmacyDto `json:"doctor_pharmacy"` // 医生药房
|
||||
DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡
|
||||
InquiryType string `json:"inquiry_type"` // 服务类型
|
||||
UserCaCert *UserCaCertDto `json:"user_ca_cert"` // ca监管证书
|
||||
@@ -77,6 +79,7 @@ type UserDoctorPendingDto struct {
|
||||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation"` // 是否平台深度合作医生(0:否 1:是)
|
||||
IsEnterpriseDeepCooperation int `json:"is_enterprise_deep_cooperation"` // 是否企业深度合作医生(0:否 1:是)
|
||||
IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation"` // 是否先思达合作医生(0:否 1:是)
|
||||
IsTransferPrescription int `json:"is_transfer_prescription"` // 是否接受抄方(0:否 1:是)
|
||||
IsRecommend int `json:"is_recommend"` // 是否首页推荐(0:否 1:是)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
@@ -143,8 +146,10 @@ func GetUserDoctorDto(m *model.UserDoctor) *UserDoctorDto {
|
||||
PraiseRate: m.PraiseRate,
|
||||
AvgResponseTime: m.AvgResponseTime,
|
||||
NumberOfFans: m.NumberOfFans,
|
||||
IsPlatformDeepCooperation: m.IsPlatformDeepCooperation,
|
||||
IsSysDiagnoCooperation: m.IsSysDiagnoCooperation,
|
||||
IsPlatformDeepCooperation: m.IsPlatformDeepCooperation,
|
||||
IsEnterpriseDeepCooperation: m.IsEnterpriseDeepCooperation,
|
||||
IsSysDiagnoCooperation: m.IsSysDiagnoCooperation,
|
||||
IsTransferPrescription: m.IsTransferPrescription,
|
||||
QrCode: utils.AddOssDomain(m.QrCode),
|
||||
BeGoodAt: m.BeGoodAt,
|
||||
BriefIntroduction: m.BriefIntroduction,
|
||||
@@ -182,7 +187,9 @@ func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto {
|
||||
PraiseRate: v.PraiseRate,
|
||||
AvgResponseTime: v.AvgResponseTime,
|
||||
NumberOfFans: v.NumberOfFans,
|
||||
IsPlatformDeepCooperation: v.IsPlatformDeepCooperation,
|
||||
IsPlatformDeepCooperation: v.IsPlatformDeepCooperation,
|
||||
IsEnterpriseDeepCooperation: v.IsEnterpriseDeepCooperation,
|
||||
IsTransferPrescription: v.IsTransferPrescription,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
@@ -241,6 +248,7 @@ func GetUserDoctorPendingDto(m *model.UserDoctor) *UserDoctorPendingDto {
|
||||
IsPlatformDeepCooperation: m.IsPlatformDeepCooperation,
|
||||
IsEnterpriseDeepCooperation: m.IsEnterpriseDeepCooperation,
|
||||
IsSysDiagnoCooperation: m.IsSysDiagnoCooperation,
|
||||
IsTransferPrescription: m.IsTransferPrescription,
|
||||
IsRecommend: m.IsRecommend,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorPharmacy 医生-药房关联表
|
||||
type DoctorPharmacy struct {
|
||||
DoctorPharmacyId int64 `gorm:"column:doctor_pharmacy_id;type:bigint(20);primary_key;comment:主键id" json:"doctor_pharmacy_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
|
||||
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(20);comment:药房id;NOT NULL" json:"pharmacy_id"`
|
||||
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:是否默认药房(0:否 1:是)" json:"is_default"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常)" json:"status"`
|
||||
Model
|
||||
Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"`
|
||||
}
|
||||
|
||||
func (m *DoctorPharmacy) TableName() string {
|
||||
return "gdxz_doctor_pharmacy"
|
||||
}
|
||||
|
||||
func (m *DoctorPharmacy) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.DoctorPharmacyId == 0 {
|
||||
m.DoctorPharmacyId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// OrderInquiry 订单-问诊表
|
||||
@@ -13,6 +14,7 @@ type OrderInquiry struct {
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
||||
TransferDoctorId int64 `gorm:"column:transfer_doctor_id;type:bigint(19);comment:接受抄方的医生id" json:"transfer_doctor_id"`
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||
@@ -41,8 +43,10 @@ type OrderInquiry struct {
|
||||
PatientNameMask string `gorm:"column:patient_name_mask;type:varchar(255);comment:患者姓名-就诊人(掩码)" json:"patient_name_mask"`
|
||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
||||
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 患者
|
||||
AnnualReviewHide int `gorm:"column:annual_review_hide;type:tinyint(1);default:0;comment:年度审查隐藏(0:否 1:是)" json:"annual_review_hide"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
TransferUserDoctor *UserDoctor `gorm:"foreignKey:TransferDoctorId;references:doctor_id" json:"transfer_user_doctor"` // 接受抄方的医生
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 患者
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,16 @@ type OrderPrescription struct {
|
||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);comment:患者性别-就诊人(1:男 2:女)" json:"patient_sex"`
|
||||
PatientAge int `gorm:"column:patient_age;type:int(11);comment:患者年龄-就诊人" json:"patient_age"`
|
||||
DoctorAdvice string `gorm:"column:doctor_advice;type:varchar(255);comment:医嘱" json:"doctor_advice"`
|
||||
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(19);default:0;comment:开方药房id" json:"pharmacy_id"`
|
||||
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:开方药房代码快照" json:"pharmacy_code"`
|
||||
PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:开方药房名称快照" json:"pharmacy_name"`
|
||||
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊订单
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
UserPharmacist *UserPharmacist `gorm:"foreignKey:PharmacistId;references:pharmacist_id" json:"user_pharmacist"` // 药师
|
||||
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
|
||||
OrderPrescriptionIcd []*OrderPrescriptionIcd `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription_icd"` // 处方疾病
|
||||
PatientFamily *PatientFamily `gorm:"foreignKey:FamilyId;references:family_id" json:"patient_family"` // 家庭成员
|
||||
Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"` // 药房
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,15 @@ type OrderProduct struct {
|
||||
ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"`
|
||||
ConsigneeTel string `gorm:"column:consignee_tel;type:varchar(50);comment:收货人电话" json:"consignee_tel"`
|
||||
ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(50);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
|
||||
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(19);default:0;comment:发货药房id" json:"pharmacy_id"`
|
||||
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:发货药房代码快照" json:"pharmacy_code"`
|
||||
PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:发货药房名称快照" json:"pharmacy_name"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
|
||||
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
|
||||
OrderPrescription *OrderPrescription `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription"` // 处方
|
||||
OrderProductItem []*OrderProductItem `gorm:"foreignKey:OrderProductId;references:order_product_id" json:"order_product_item"` // 处方
|
||||
Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"` // 药房
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Pharmacy 药房信息表
|
||||
type Pharmacy struct {
|
||||
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(20);primary_key;comment:主键id" json:"pharmacy_id"`
|
||||
PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:药房名称;NOT NULL" json:"pharmacy_name"`
|
||||
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:药房代码;NOT NULL" json:"pharmacy_code"`
|
||||
Postage float64 `gorm:"column:postage;type:decimal(10,2);default:0.00;comment:基础邮费" json:"postage"`
|
||||
FreeShippingThreshold float64 `gorm:"column:free_shipping_threshold;type:decimal(10,2);default:0.00;comment:满XX包邮门槛金额" json:"free_shipping_threshold"`
|
||||
IsPickup int `gorm:"column:is_pickup;type:tinyint(1);default:0;comment:是否支持自提(0:否 1:是)" json:"is_pickup"`
|
||||
Telephone string `gorm:"column:telephone;type:varchar(30);comment:电话" json:"telephone"`
|
||||
ProvinceId int `gorm:"column:province_id;type:int(11);default:0;comment:省份id" json:"province_id"`
|
||||
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
||||
CityId int `gorm:"column:city_id;type:int(11);default:0;comment:城市id" json:"city_id"`
|
||||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||||
CountyId int `gorm:"column:county_id;type:int(11);default:0;comment:区县id" json:"county_id"`
|
||||
County string `gorm:"column:county;type:varchar(50);comment:区县" json:"county"`
|
||||
Address string `gorm:"column:address;type:varchar(255);comment:地址" json:"address"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *Pharmacy) TableName() string {
|
||||
return "gdxz_pharmacy"
|
||||
}
|
||||
|
||||
func (m *Pharmacy) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.PharmacyId == 0 {
|
||||
m.PharmacyId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
type Product struct {
|
||||
ProductId int64 `gorm:"column:product_id;type:bigint(19);primary_key;comment:主键id" json:"product_id"`
|
||||
ProductPlatformId int64 `gorm:"column:product_platform_id;type:bigint(19);comment:处方平台商品id" json:"product_platform_id"`
|
||||
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(20) unsigned;default:0;comment:所属药房ID" json:"pharmacy_id"`
|
||||
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);default:'';comment:所属药房编码" json:"pharmacy_code"`
|
||||
ProductStatus int `gorm:"column:product_status;type:tinyint(1);default:1;comment:商品状态(1:正常 2:下架)" json:"product_status"`
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:是否删除(0:否 1:是)" json:"is_delete"`
|
||||
PrescriptionNum int `gorm:"column:prescription_num;type:int(11);default:5;comment:处方可开具的数量" json:"prescription_num"`
|
||||
@@ -32,6 +34,7 @@ type Product struct {
|
||||
AvailableDays float64 `gorm:"column:available_days;type:float(10,2);comment:可用天数(3)" json:"available_days"`
|
||||
ProductRemarks string `gorm:"column:product_remarks;type:varchar(255);comment:商品备注" json:"product_remarks"`
|
||||
ProductPlatformAmount *ProductPlatformAmount `gorm:"foreignKey:ProductPlatformId;references:product_platform_id" json:"product_platform_amount"` // 库存
|
||||
Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"` // 所属药房
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,16 @@ type ProductPlatform struct {
|
||||
ProductType int `gorm:"column:product_type;type:tinyint(4);default:1;comment:药品类型(0:未知 1:中成药 2:西药)" json:"product_type"`
|
||||
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:处方平台商品编码" json:"product_platform_code"`
|
||||
ProductPharmacyCode string `gorm:"column:product_pharmacy_code;type:varchar(100);comment:第三方药店商品编码" json:"product_pharmacy_code"`
|
||||
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);default:'';comment:第三方药房编码" json:"pharmacy_code"`
|
||||
ProductSpec string `gorm:"column:product_spec;type:varchar(255);comment:商品规格" json:"product_spec"`
|
||||
LicenseNumber string `gorm:"column:license_number;type:varchar(255);comment:批准文号" json:"license_number"`
|
||||
Manufacturer string `gorm:"column:manufacturer;type:varchar(255);comment:生产厂家" json:"manufacturer"`
|
||||
SingleUnit string `gorm:"column:single_unit;type:varchar(50);comment:单次剂量单位" json:"single_unit"`
|
||||
PackagingUnit string `gorm:"column:packaging_unit;type:varchar(20);comment:基本包装单位" json:"packaging_unit"`
|
||||
PackagingCount string `gorm:"column:packaging_count;type:varchar(20);comment:基本包装数量" json:"packaging_count"`
|
||||
RetailUnit string `gorm:"column:retail_unit;type:varchar(20);comment:零售单位" json:"retail_unit"`
|
||||
RetailUnit string `gorm:"column:retail_unit;type:varchar(20);comment:零售单位" json:"retail_unit"`
|
||||
Model
|
||||
Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyCode;references:pharmacy_code" json:"pharmacy,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ProductPlatform) TableName() string {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserDoctor 用户-医生表
|
||||
@@ -42,6 +43,7 @@ type UserDoctor struct {
|
||||
IsPlatformDeepCooperation int `gorm:"column:is_platform_deep_cooperation;type:tinyint(1);default:0;comment:是否平台深度合作医生(0:否 1:是)" json:"is_platform_deep_cooperation"`
|
||||
IsEnterpriseDeepCooperation int `gorm:"column:is_enterprise_deep_cooperation;type:tinyint(1);default:0;comment:是否企业深度合作医生(0:否 1:是)" json:"is_enterprise_deep_cooperation"`
|
||||
IsSysDiagnoCooperation int `gorm:"column:is_sys_diagno_cooperation;type:tinyint(1);default:0;comment:是否先思达合作医生(0:否 1:是)" json:"is_sys_diagno_cooperation"`
|
||||
IsTransferPrescription int `gorm:"column:is_transfer_prescription;type:tinyint(1);default:0;comment:是否接受抄方(0:否 1:是)" json:"is_transfer_prescription"`
|
||||
QrCode string `gorm:"column:qr_code;type:varchar(255);comment:分享二维码" json:"qr_code"`
|
||||
BeGoodAt string `gorm:"column:be_good_at;type:text;comment:擅长" json:"be_good_at"`
|
||||
BriefIntroduction string `gorm:"column:brief_introduction;type:text;comment:医生简介" json:"brief_introduction"`
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package requests
|
||||
|
||||
import "strings"
|
||||
|
||||
type CaV2Request struct {
|
||||
GetServiceURL GetCaV2ServiceURL
|
||||
CertSign GetCaV2CertSign
|
||||
GetCertSignResult GetCaV2CertSignResult
|
||||
PasswordLessSignInfo GetCaV2PasswordLessSignInfo
|
||||
}
|
||||
|
||||
type GetCaV2ServiceURL struct {
|
||||
CertType string `json:"certType" form:"certType" validate:"required,oneof=Personal Organizational OrgPerson" label:"证书类型"`
|
||||
Type string `json:"type" form:"type" validate:"required,oneof=BUSINESS_CENTER CERT_APPLY CERT_RENEW CERT_UPDATE CERT_REVOKE" label:"业务类型"`
|
||||
EntityID string `json:"entityId" form:"entityId" validate:"required" label:"用户唯一标识"`
|
||||
UserName string `json:"userName" form:"userName"`
|
||||
UserIDCard string `json:"userIdCard" form:"userIdCard"`
|
||||
UserPhone string `json:"userPhone" form:"userPhone"`
|
||||
Email string `json:"email" form:"email"`
|
||||
EnterpriseName string `json:"enterpriseName" form:"enterpriseName"`
|
||||
SocialCreditCode string `json:"socialCreditCode" form:"socialCreditCode"`
|
||||
DeptPerson string `json:"deptPerson" form:"deptPerson"`
|
||||
DeptPersonCode string `json:"deptPersonCode" form:"deptPersonCode"`
|
||||
DeptPersonPhone string `json:"deptPersonPhone" form:"deptPersonPhone"`
|
||||
AgentName string `json:"agentName" form:"agentName"`
|
||||
AgentIDCard string `json:"agentIdCard" form:"agentIdCard"`
|
||||
AuthMethod string `json:"authMethod" form:"authMethod" validate:"omitempty,oneof=face sms" label:"认证方式"`
|
||||
}
|
||||
|
||||
func (r GetCaV2ServiceURL) ValidateBusinessFields() string {
|
||||
switch r.CertType {
|
||||
case "Personal":
|
||||
if strings.TrimSpace(r.UserName) == "" || strings.TrimSpace(r.UserIDCard) == "" || strings.TrimSpace(r.UserPhone) == "" {
|
||||
return "个人证书必须填写 userName、userIdCard、userPhone"
|
||||
}
|
||||
case "Organizational":
|
||||
if strings.TrimSpace(r.EnterpriseName) == "" ||
|
||||
strings.TrimSpace(r.SocialCreditCode) == "" ||
|
||||
strings.TrimSpace(r.DeptPerson) == "" ||
|
||||
strings.TrimSpace(r.DeptPersonCode) == "" ||
|
||||
strings.TrimSpace(r.DeptPersonPhone) == "" {
|
||||
return "企业证书必须填写 enterpriseName、socialCreditCode、deptPerson、deptPersonCode、deptPersonPhone"
|
||||
}
|
||||
case "OrgPerson":
|
||||
if strings.TrimSpace(r.UserName) == "" ||
|
||||
strings.TrimSpace(r.UserIDCard) == "" ||
|
||||
strings.TrimSpace(r.UserPhone) == "" {
|
||||
return "企业个人证书必须填写 userName、userIdCard、userPhone"
|
||||
}
|
||||
if strings.TrimSpace(r.EnterpriseName) == "" ||
|
||||
strings.TrimSpace(r.SocialCreditCode) == "" ||
|
||||
strings.TrimSpace(r.DeptPerson) == "" ||
|
||||
strings.TrimSpace(r.DeptPersonCode) == "" ||
|
||||
strings.TrimSpace(r.DeptPersonPhone) == "" {
|
||||
return "企业个人证书必须填写 enterpriseName、socialCreditCode、deptPerson、deptPersonCode、deptPersonPhone"
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetCaV2CertSign struct {
|
||||
EntityID string `json:"entityId" form:"entityId" validate:"required" label:"用户唯一标识"`
|
||||
RequestID string `json:"requestId" form:"requestId" validate:"required" label:"业务流水号"`
|
||||
BusinessType string `json:"businessType" form:"businessType" validate:"required,oneof=businessCenter certApply certRenewcertRenew certUpdate certRevoke certInfo certSign certUpdatePin" label:"业务类型"`
|
||||
ToSign string `json:"toSign" form:"toSign" validate:"required" label:"签名原文"`
|
||||
NotifyURL string `json:"notifyUrl" form:"notifyUrl"`
|
||||
JumpURL string `json:"jumpUrl" form:"jumpUrl"`
|
||||
ExtParam string `json:"extParam" form:"extParam"`
|
||||
}
|
||||
|
||||
type GetCaV2CertSignResult struct {
|
||||
RequestID string `json:"requestId" form:"requestId" validate:"required" label:"业务流水号"`
|
||||
}
|
||||
|
||||
type GetCaV2PasswordLessSignInfo struct {
|
||||
EntityID string `json:"entityId" form:"entityId" validate:"required" label:"用户唯一标识"`
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package requests
|
||||
|
||||
type DoctorPharmacyRequest struct {
|
||||
BindDoctorPharmacies // 批量绑定药房
|
||||
AddDoctorPharmacy // 新增单个药房绑定
|
||||
UnbindDoctorPharmacy // 解绑药房
|
||||
SetDefaultDoctorPharmacy // 设置默认药房
|
||||
}
|
||||
|
||||
// BindDoctorPharmacies 批量绑定药房
|
||||
type BindDoctorPharmacies struct {
|
||||
PharmacyIds []string `json:"pharmacy_ids" form:"pharmacy_ids" label:"药房id列表"`
|
||||
DefaultPharmacyId string `json:"default_pharmacy_id" form:"default_pharmacy_id" label:"默认药房id"`
|
||||
}
|
||||
|
||||
// AddDoctorPharmacy 单个药房绑定
|
||||
type AddDoctorPharmacy struct {
|
||||
DoctorId string `json:"doctor_id" form:"doctor_id" label:"医生id"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id" validate:"required"`
|
||||
IsDefault *int `json:"is_default" form:"is_default" label:"是否默认" validate:"omitempty,oneof=0 1"`
|
||||
}
|
||||
|
||||
// UnbindDoctorPharmacy 解除药房绑定
|
||||
type UnbindDoctorPharmacy struct {
|
||||
DoctorPharmacyId string `json:"doctor_pharmacy_id" form:"doctor_pharmacy_id" label:"绑定关系id"`
|
||||
DoctorId string `json:"doctor_id" form:"doctor_id" label:"医生id"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
}
|
||||
|
||||
// SetDefaultDoctorPharmacy 设置默认药房
|
||||
type SetDefaultDoctorPharmacy struct {
|
||||
DoctorPharmacyId string `json:"doctor_pharmacy_id" form:"doctor_pharmacy_id" label:"绑定关系id"`
|
||||
DoctorId string `json:"doctor_id" form:"doctor_id" label:"医生id"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
}
|
||||
@@ -8,6 +8,12 @@ type OrderInquiryRequest struct {
|
||||
GetOrderInquiryForAccountPage // 获取账户关联问诊订单列表-分页
|
||||
OrderInquiryForAccountExportList // 医生账户-关联订单-导出
|
||||
OrderInquiryExportList // 问诊订单列表-导出
|
||||
PutAnnualReviewHide // 修改问诊订单年度审查隐藏状态
|
||||
}
|
||||
|
||||
// PutAnnualReviewHide 修改问诊订单年度审查隐藏状态
|
||||
type PutAnnualReviewHide struct {
|
||||
AnnualReviewHide *int `json:"annual_review_hide" form:"annual_review_hide" validate:"required,oneof=0 1" label:"年度审查隐藏"`
|
||||
}
|
||||
|
||||
// GetOrderInquiryPage 获取问诊订单列表-分页
|
||||
@@ -15,6 +21,7 @@ type GetOrderInquiryPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||
MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"多点执业状态"` // 医生多点执业认证状态
|
||||
InquiryType *int `json:"inquiry_type" form:"inquiry_type" label:"订单类型"` // (1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
InquiryMode *int `json:"inquiry_mode" form:"inquiry_mode" label:"订单问诊方式"` // (1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
InquiryStatus *int `json:"inquiry_status" form:"inquiry_status" label:"问诊订单状态"` // 1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消
|
||||
@@ -32,6 +39,7 @@ type GetOrderInquiryPage struct {
|
||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 用于内部传递隐藏条件
|
||||
}
|
||||
|
||||
// CancelOrderInquiry 取消问诊订单
|
||||
@@ -45,6 +53,7 @@ type GetOrderInquiryRecordPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||
MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"多点执业状态"` // 医生多点执业认证状态
|
||||
InquiryType *int `json:"inquiry_type" form:"inquiry_type" label:"订单类型"` // (1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
InquiryMode *int `json:"inquiry_mode" form:"inquiry_mode" label:"订单问诊方式"` // (1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
InquiryStatus *int `json:"inquiry_status" form:"inquiry_status" label:"问诊订单状态"` // 1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消
|
||||
@@ -62,6 +71,7 @@ type GetOrderInquiryRecordPage struct {
|
||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 用于内部传递隐藏条件
|
||||
}
|
||||
|
||||
// GetOrderInquiryImPage 获取问诊订单im内容列表-分页
|
||||
@@ -88,6 +98,7 @@ type GetOrderInquiryForAccountPage struct {
|
||||
IsWithdrawal *int `json:"is_withdrawal" form:"is_withdrawal" label:"是否提现"` // 0:否 1:是 2:提现中
|
||||
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 用于内部传递隐藏条件
|
||||
}
|
||||
|
||||
// OrderInquiryForAccountExportList 医生账户-关联订单-导出
|
||||
@@ -107,6 +118,7 @@ type OrderInquiryForAccountExportList struct {
|
||||
IsWithdrawal *int `json:"is_withdrawal" form:"is_withdrawal" label:"是否提现"` // 0:否 1:是 2:提现中
|
||||
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 用于内部传递隐藏条件
|
||||
}
|
||||
|
||||
// OrderInquiryExportList 问诊订单列表-导出
|
||||
@@ -131,4 +143,5 @@ type OrderInquiryExportList struct {
|
||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 用于内部传递隐藏条件
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ type GetOrderPrescriptionPage struct {
|
||||
ExpiredTime string `json:"expired_time" form:"expired_time" label:"处方过期时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"问诊订单编号"`
|
||||
OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"药品订单编号"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件
|
||||
}
|
||||
|
||||
// OrderPrescriptionExportList 处方-导出
|
||||
@@ -37,4 +41,8 @@ type OrderPrescriptionExportList struct {
|
||||
ExpiredTime string `json:"expired_time" form:"expired_time" label:"处方过期时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"问诊订单编号"`
|
||||
OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"药品订单编号"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ type GetOrderProductPage struct {
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||
ProductName string `json:"product_name" form:"product_name" label:"药品名称"`
|
||||
CommonName string `json:"common_name" form:"common_name" label:"药品通用名"`
|
||||
PrescriptionCode string `json:"prescription_code" form:"prescription_code" label:"处方编号"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件
|
||||
}
|
||||
|
||||
// CancelOrderProduct 取消药品订单
|
||||
@@ -65,4 +70,8 @@ type OrderProductExportList struct {
|
||||
ConsigneeTel string `json:"consignee_tel" form:"cancel_reason" label:"收货人电话"`
|
||||
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package requests
|
||||
|
||||
type PharmacyRequest struct {
|
||||
GetPharmacyList // 获取药房列表
|
||||
GetPharmacyPage // 获取药房列表-分页
|
||||
AddPharmacy // 新增药房
|
||||
PutPharmacy // 修改药房
|
||||
PutPharmacyStatus // 修改药房状态
|
||||
GetPharmacyDoctorPage // 药房绑定的医生列表-分页
|
||||
GetPharmacyDoctorList // 药房绑定的医生列表
|
||||
PharmacyDoctorExportList // 药房关联医生-导出
|
||||
BatchTransferAndAction // 批量迁移医生默认药房并执行药房操作
|
||||
}
|
||||
|
||||
// PharmacyDoctorExportList 药房关联医生-导出
|
||||
type PharmacyDoctorExportList struct {
|
||||
Type int `json:"type" form:"type" label:"类型" validate:"required,oneof=1 2 3"` // 1:当前搜索数据 2:当前选择数据 3:全部数据
|
||||
Id string `json:"id" form:"id" label:"id"` // 选择数据的id(doctor_pharmacy_id或doctor_id),逗号分隔
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"` // 药房id
|
||||
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"` // 医生姓名
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"` // 手机号
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorPage 药房绑定的医生列表-分页
|
||||
type GetPharmacyDoctorPage struct {
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id" validate:"required"`
|
||||
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorList 药房绑定的医生列表
|
||||
type GetPharmacyDoctorList struct {
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"`
|
||||
}
|
||||
|
||||
// GetPharmacyList 获取药房列表
|
||||
type GetPharmacyList struct {
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
Status *int `json:"status" form:"status" label:"状态"`
|
||||
IsPickup *int `json:"is_pickup" form:"is_pickup" label:"是否支持自提"`
|
||||
}
|
||||
|
||||
// GetPharmacyPage 获取药房列表-分页
|
||||
type GetPharmacyPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"`
|
||||
Status *int `json:"status" form:"status" label:"状态"`
|
||||
IsPickup *int `json:"is_pickup" form:"is_pickup" label:"是否支持自提"`
|
||||
ProvinceId int `json:"province_id" form:"province_id" label:"省份id"`
|
||||
CityId *int `json:"city_id" form:"city_id" label:"城市id"`
|
||||
CountyId *int `json:"county_id" form:"county_id" label:"区县id"`
|
||||
}
|
||||
|
||||
// AddPharmacy 新增药房
|
||||
type AddPharmacy struct {
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称" validate:"required"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码" validate:"required"`
|
||||
Postage *float64 `json:"postage" form:"postage" label:"邮费" validate:"required,gte=0"`
|
||||
FreeShippingThreshold *float64 `json:"free_shipping_threshold" form:"free_shipping_threshold" label:"满XX包邮" validate:"required,gte=0"`
|
||||
IsPickup *int `json:"is_pickup" form:"is_pickup" label:"是否支持自提" validate:"required,oneof=0 1"`
|
||||
Telephone string `json:"telephone" form:"telephone" label:"电话"`
|
||||
ProvinceId int `json:"province_id" form:"province_id" label:"省份id"`
|
||||
CityId int `json:"city_id" form:"city_id" label:"城市id"`
|
||||
CountyId int `json:"county_id" form:"county_id" label:"区县id"`
|
||||
Address string `json:"address" form:"address" label:"地址" validate:"required"`
|
||||
Status *int `json:"status" form:"status" label:"状态" validate:"omitempty,oneof=0 1"`
|
||||
}
|
||||
|
||||
// PutPharmacy 修改药房
|
||||
type PutPharmacy struct {
|
||||
PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称" validate:"required"`
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码" validate:"required"`
|
||||
Postage *float64 `json:"postage" form:"postage" label:"邮费" validate:"required,gte=0"`
|
||||
FreeShippingThreshold *float64 `json:"free_shipping_threshold" form:"free_shipping_threshold" label:"满XX包邮" validate:"required,gte=0"`
|
||||
IsPickup *int `json:"is_pickup" form:"is_pickup" label:"是否支持自提" validate:"required,oneof=0 1"`
|
||||
Telephone string `json:"telephone" form:"telephone" label:"电话"`
|
||||
ProvinceId int `json:"province_id" form:"province_id" label:"省份id"`
|
||||
CityId int `json:"city_id" form:"city_id" label:"城市id"`
|
||||
CountyId int `json:"county_id" form:"county_id" label:"区县id"`
|
||||
Address string `json:"address" form:"address" label:"地址" validate:"required"`
|
||||
Status *int `json:"status" form:"status" label:"状态" validate:"omitempty,oneof=0 1"`
|
||||
}
|
||||
|
||||
// PutPharmacyStatus 修改药房状态
|
||||
type PutPharmacyStatus struct {
|
||||
Status *int `json:"status" form:"status" label:"状态" validate:"required,oneof=0 1"`
|
||||
}
|
||||
|
||||
// BatchTransferDoctorItem 单个医生的迁移配置
|
||||
type BatchTransferDoctorItem struct {
|
||||
DoctorId string `json:"doctor_id" form:"doctor_id" label:"医生id" validate:"required"`
|
||||
TargetPharmacyId string `json:"target_pharmacy_id" form:"target_pharmacy_id" label:"目标药房id" validate:"required"`
|
||||
}
|
||||
|
||||
// BatchTransferAndAction 批量迁移医生默认药房并执行药房操作
|
||||
type BatchTransferAndAction struct {
|
||||
SourcePharmacyId string `json:"source_pharmacy_id" form:"source_pharmacy_id" label:"原药房id" validate:"required"`
|
||||
Action string `json:"action" form:"action" label:"操作类型" validate:"required,oneof=disable delete"`
|
||||
UnbindSource *int `json:"unbind_source" form:"unbind_source" label:"是否解绑原药房"` // 1:是 0:否,若action为delete则强制解绑
|
||||
Transfers []BatchTransferDoctorItem `json:"transfers" form:"transfers" label:"迁移列表" validate:"required,dive"`
|
||||
}
|
||||
@@ -19,6 +19,8 @@ type GetPlatformProductPage struct {
|
||||
ProductType *int `json:"product_type" form:"product_type" label:"药品类型"` // 药品类型(0:未知 1:中成药 2:西药)
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"第三方药房编码"` // 第三方药房编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
}
|
||||
@@ -29,6 +31,8 @@ type GetPlatformProductList struct {
|
||||
ProductType *int `json:"product_type" form:"product_type" label:"药品类型"` // 药品类型(0:未知 1:中成药 2:西药)
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"第三方药房编码"` // 第三方药房编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
}
|
||||
@@ -45,6 +49,8 @@ type GetProductPage struct {
|
||||
ProductPlatformId string `json:"product_platform_id" form:"product_platform_id" label:"平台商品id"` // 处方平台商品id
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"所属药房编码"` // 所属药房编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
ProductRemarks string `json:"product_remarks" form:"product_remarks" label:"商品备注"` // 商品备注
|
||||
@@ -63,6 +69,8 @@ type GetProductList struct {
|
||||
ProductPlatformId string `json:"product_platform_id" form:"product_platform_id" label:"平台商品id"` // 处方平台商品id
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"所属药房编码"` // 所属药房编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
ProductRemarks string `json:"product_remarks" form:"product_remarks" label:"商品备注"` // 商品备注
|
||||
@@ -85,6 +93,8 @@ type AddProduct struct {
|
||||
IsMajing *int `json:"is_majing" form:"is_majing" label:"是否麻精药品"` // 是否麻精药品(0:否 1:是)
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台商品编码" validate:"required"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"第三方药店商品编码" validate:"required"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"所属药房编码"` // 所属药房编码
|
||||
ProductCoverImg string `json:"product_cover_img" form:"product_cover_img" label:"商品封面图"` // 商品封面图
|
||||
ProductSpec string `json:"product_spec" form:"product_spec" label:"商品规格" validate:"required"` // 商品规格
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号" validate:"required"` // 批准文号
|
||||
@@ -128,6 +138,8 @@ type ProductExportList struct {
|
||||
ProductPlatformId string `json:"product_platform_id" form:"product_platform_id" label:"平台商品id"` // 处方平台商品id
|
||||
ProductPlatformCode string `json:"product_platform_code" form:"product_platform_code" label:"处方平台编码"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code" form:"product_pharmacy_code" label:"药店编码"` // 第三方药店商品编码
|
||||
PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"所属药房ID"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"所属药房编码"` // 所属药房编码
|
||||
LicenseNumber string `json:"license_number" form:"license_number" label:"批准文号"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer" form:"manufacturer" label:"生产厂家"` // 生产厂家
|
||||
ProductRemarks string `json:"product_remarks" form:"product_remarks" label:"商品备注"` // 商品备注
|
||||
|
||||
@@ -48,6 +48,7 @@ type PutUserDoctor struct {
|
||||
HospitalId string `json:"hospital_id" form:"hospital_id" validate:"required" label:"所属医院id"`
|
||||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation" form:"is_platform_deep_cooperation" label:"平台深度合作医生"` // 是否平台深度合作医生(0:否 1:是)
|
||||
IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation" form:"is_sys_diagno_cooperation" label:"是否先思达合作医生)"` // 是否先思达合作医生(0:否 1:是)
|
||||
IsTransferPrescription int `json:"is_transfer_prescription" form:"is_transfer_prescription" label:"是否接受抄方"` // 是否接受抄方(0:否 1:是)
|
||||
BeGoodAt string `json:"be_good_at" form:"be_good_at" validate:"required" label:"擅长"`
|
||||
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
||||
LicenseCert []string `json:"license_cert" form:"license_cert" label:"医师执业证"`
|
||||
@@ -57,6 +58,7 @@ type PutUserDoctor struct {
|
||||
IdCardBack string `json:"id_card_back" form:"id_card_back" label:"身份证背面图片"`
|
||||
SignImage string `json:"sign_image" form:"sign_image" label:"签名图片"`
|
||||
DoctorExpertise []string `json:"doctor_expertise" form:"doctor_expertise" label:"专长"`
|
||||
DoctorPharmacy []string `json:"doctor_pharmacy" form:"doctor_pharmacy" label:"药房"`
|
||||
Email string `json:"email" form:"email" label:"邮箱"`
|
||||
BankId string `json:"bank_id" form:"bank_id" validate:"required_with_all=BankCardCode BankCardProvinceId BankCardCityId BankCardCountyId" label:"银行id"`
|
||||
BankCardCode string `json:"bank_card_code" form:"bank_card_code" validate:"required_with_all=BankId BankCardProvinceId BankCardCityId BankCardCountyId" label:"银行卡号"`
|
||||
@@ -78,6 +80,7 @@ type AddUserDoctor struct {
|
||||
HospitalId string `json:"hospital_id" form:"hospital_id" validate:"required" label:"所属医院id"`
|
||||
IsPlatformDeepCooperation int `json:"is_platform_deep_cooperation" form:"is_platform_deep_cooperation" label:"平台深度合作医生"` // 是否平台深度合作医生(0:否 1:是)
|
||||
IsSysDiagnoCooperation int `json:"is_sys_diagno_cooperation" form:"is_sys_diagno_cooperation" label:"是否先思达合作医生)"` // 是否先思达合作医生(0:否 1:是)
|
||||
IsTransferPrescription int `json:"is_transfer_prescription" form:"is_transfer_prescription" label:"是否接受抄方"` // 是否接受抄方(0:否 1:是)
|
||||
BeGoodAt string `json:"be_good_at" form:"be_good_at" validate:"required" label:"擅长"`
|
||||
BriefIntroduction string `json:"brief_introduction" form:"brief_introduction" validate:"required" label:"医生简介"`
|
||||
LicenseCert []string `json:"license_cert" form:"license_cert" validate:"required" label:"医师执业证"`
|
||||
@@ -88,6 +91,7 @@ type AddUserDoctor struct {
|
||||
SignImage string `json:"sign_image" form:"sign_image" label:"签名图片"`
|
||||
CardNum string `json:"card_num" form:"card_num" validate:"required" label:"证件号码"`
|
||||
DoctorExpertise []string `json:"doctor_expertise" form:"doctor_expertise" label:"专长"`
|
||||
DoctorPharmacy []string `json:"doctor_pharmacy" form:"doctor_pharmacy" label:"药房"`
|
||||
Email string `json:"email" form:"email" label:"邮箱"`
|
||||
BankId string `json:"bank_id" form:"bank_id" validate:"required_with_all=BankCardCode BankCardProvinceId BankCardCityId BankCardCountyId" label:"银行id"`
|
||||
BankCardCode string `json:"bank_card_code" form:"bank_card_code" validate:"required_with_all=BankId BankCardProvinceId BankCardCityId BankCardCountyId" label:"银行卡号"`
|
||||
|
||||
+115
-1
@@ -2,13 +2,14 @@ package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/controller"
|
||||
"hospital-admin-api/api/exception"
|
||||
"hospital-admin-api/api/middlewares"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/consts"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Init 初始化路由
|
||||
@@ -97,6 +98,15 @@ func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
}
|
||||
}
|
||||
|
||||
caV2 := controller.CaV2{}
|
||||
caV2Group := r.Group("/open/ca/v2")
|
||||
{
|
||||
caV2Group.POST("/service-url", caV2.GetServiceURL)
|
||||
caV2Group.POST("/cert-sign", caV2.CertSign)
|
||||
caV2Group.POST("/cert-sign/result", caV2.GetCertSignResult)
|
||||
caV2Group.POST("/passwordless-sign-info", caV2.PasswordLessSignInfo)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// adminRouter 公共路由-验证权限
|
||||
@@ -151,6 +161,13 @@ func basicRouter(r *gin.Engine, api controller.Api) {
|
||||
hospitalGroup.GET("/list", api.Hospital.GetHospitalList)
|
||||
}
|
||||
|
||||
// 药房管理-基础数据
|
||||
pharmacyGroup := basicGroup.Group("/pharmacy")
|
||||
{
|
||||
// 获取药房列表
|
||||
pharmacyGroup.GET("/list", api.Pharmacy.GetPharmacyList)
|
||||
}
|
||||
|
||||
// 医生专长管理-基础数据
|
||||
expertiseGroup := basicGroup.Group("/expertise")
|
||||
{
|
||||
@@ -354,6 +371,31 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 新增医生
|
||||
doctorGroup.POST("", api.UserDoctor.AddUserDoctor)
|
||||
|
||||
// 医生药房管理
|
||||
doctorPharmacyGroup := doctorGroup.Group("/pharmacy")
|
||||
{
|
||||
// 获取医生绑定的药房列表
|
||||
doctorPharmacyGroup.GET("/:doctor_id", api.DoctorPharmacy.GetDoctorPharmacies)
|
||||
|
||||
// 批量设置医生绑定的药房列表
|
||||
doctorPharmacyGroup.PUT("/:doctor_id", api.DoctorPharmacy.BindDoctorPharmacies)
|
||||
|
||||
// 为医生新增单个药房绑定
|
||||
doctorPharmacyGroup.POST("", api.DoctorPharmacy.AddDoctorPharmacy)
|
||||
doctorPharmacyGroup.POST("/:doctor_id", api.DoctorPharmacy.AddDoctorPharmacy)
|
||||
|
||||
// 解除医生与指定药房的绑定
|
||||
doctorPharmacyGroup.DELETE("/:id", api.DoctorPharmacy.UnbindDoctorPharmacy)
|
||||
doctorPharmacyGroup.POST("/unbind", api.DoctorPharmacy.UnbindDoctorPharmacyPost)
|
||||
|
||||
// 设置医生的默认药房
|
||||
doctorPharmacyGroup.PUT("/default/:id", api.DoctorPharmacy.SetDefaultDoctorPharmacy)
|
||||
doctorPharmacyGroup.PUT("/default", api.DoctorPharmacy.SetDefaultDoctorPharmacyPut)
|
||||
|
||||
// 药房关联医生-导出
|
||||
doctorPharmacyGroup.POST("/export", api.Export.PharmacyDoctor)
|
||||
}
|
||||
|
||||
// 身份审核列表
|
||||
doctorPendingGroup := doctorGroup.Group("/pending")
|
||||
{
|
||||
@@ -431,6 +473,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
|
||||
// 获取问诊订单im内容列表-分页
|
||||
inquiryGroup.GET("/im", api.OrderInquiry.GetOrderInquiryImPage)
|
||||
|
||||
// 修改问诊订单年度审查隐藏状态
|
||||
inquiryGroup.PUT("/hide/:order_inquiry_id", api.OrderInquiry.PutAnnualReviewHide)
|
||||
}
|
||||
|
||||
// 药品订单
|
||||
@@ -531,6 +576,15 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
|
||||
// 处方详情
|
||||
prescriptionGroup.GET("/:order_prescription_id", api.OrderPrescription.GetOrderPrescription)
|
||||
|
||||
prescriptionTransferGroup := prescriptionGroup.Group("/transfer")
|
||||
{
|
||||
// 获取抄方的处方列表-分页
|
||||
prescriptionTransferGroup.GET("", api.OrderPrescription.GetOrderPrescriptionTransferPage)
|
||||
|
||||
// 抄方的处方详情
|
||||
prescriptionTransferGroup.GET("/:order_prescription_id", api.OrderPrescription.GetOrderPrescription)
|
||||
}
|
||||
}
|
||||
|
||||
// 问诊管理
|
||||
@@ -747,6 +801,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
{
|
||||
// 处方
|
||||
prescriptionGroup.POST("", api.Export.OrderPrescription)
|
||||
|
||||
// 抄方的处方
|
||||
prescriptionGroup.POST("/transfer", api.Export.OrderTransferPrescription)
|
||||
}
|
||||
|
||||
// 药品
|
||||
@@ -755,6 +812,13 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 系统药品
|
||||
productGroup.POST("", api.Export.Product)
|
||||
}
|
||||
|
||||
// 药房
|
||||
pharmacyGroup := exportGroup.Group("/pharmacy")
|
||||
{
|
||||
// 药房关联医生
|
||||
pharmacyGroup.POST("/doctor", api.Export.PharmacyDoctor)
|
||||
}
|
||||
}
|
||||
|
||||
// 商品管理
|
||||
@@ -860,6 +924,46 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
hospitalGroup.PUT("/:hospital_id", api.Hospital.PutHospital)
|
||||
}
|
||||
|
||||
// 药房管理
|
||||
pharmacyGroup := basicGroup.Group("/pharmacy")
|
||||
{
|
||||
// 获取药房列表-分页
|
||||
pharmacyGroup.POST("/page", api.Pharmacy.GetPharmacyPage)
|
||||
|
||||
// 获取药房列表
|
||||
pharmacyGroup.GET("/list", api.Pharmacy.GetPharmacyList)
|
||||
|
||||
// 获取药房详情
|
||||
pharmacyGroup.GET("/:pharmacy_id", api.Pharmacy.GetPharmacy)
|
||||
|
||||
// 新增药房
|
||||
pharmacyGroup.POST("", api.Pharmacy.AddPharmacy)
|
||||
|
||||
// 修改药房
|
||||
pharmacyGroup.PUT("/:pharmacy_id", api.Pharmacy.PutPharmacy)
|
||||
|
||||
// 修改药房状态
|
||||
pharmacyGroup.PUT("/status/:pharmacy_id", api.Pharmacy.PutPharmacyStatus)
|
||||
|
||||
// 删除药房
|
||||
pharmacyGroup.DELETE("/:pharmacy_id", api.Pharmacy.DeletePharmacy)
|
||||
|
||||
// 药房绑定的医生列表-分页
|
||||
pharmacyGroup.POST("/doctor/page", api.Pharmacy.GetPharmacyDoctorPage)
|
||||
|
||||
// 药房绑定的医生列表
|
||||
pharmacyGroup.GET("/doctor/:pharmacy_id", api.Pharmacy.GetPharmacyDoctorList)
|
||||
|
||||
// 药房关联医生-导出
|
||||
pharmacyGroup.POST("/doctor/export", api.Export.PharmacyDoctor)
|
||||
|
||||
// 获取药房下线受影响医生列表(预检接口)
|
||||
pharmacyGroup.GET("/affected-doctors/:pharmacy_id", api.Pharmacy.GetAffectedDoctors)
|
||||
|
||||
// 批量迁移医生默认药房并执行药房操作(禁用/删除)
|
||||
pharmacyGroup.POST("/batch-transfer-and-action", api.Pharmacy.BatchTransferAndAction)
|
||||
}
|
||||
|
||||
// 科普分类管理
|
||||
articleClassGroup := basicGroup.Group("/article/class")
|
||||
{
|
||||
@@ -880,6 +984,16 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
}
|
||||
}
|
||||
|
||||
// 药房兼容路由(兼容无 /basic 前缀的 /admin/pharmacy/*)
|
||||
adminPharmacyGroup := adminGroup.Group("/pharmacy")
|
||||
{
|
||||
// 获取药房下线受影响医生列表(预检接口)
|
||||
adminPharmacyGroup.GET("/affected-doctors/:pharmacy_id", api.Pharmacy.GetAffectedDoctors)
|
||||
|
||||
// 批量迁移医生默认药房并执行药房操作(禁用/删除)
|
||||
adminPharmacyGroup.POST("/batch-transfer-and-action", api.Pharmacy.BatchTransferAndAction)
|
||||
}
|
||||
|
||||
// 文章管理
|
||||
articleGroup := adminGroup.Group("/article")
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
@@ -12,6 +11,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// InquiryConfigService 问诊配置
|
||||
@@ -372,7 +373,6 @@ func (r *DoctorInquiryConfigService) PutDoctorInquiryConfig(inquiryConfigId int6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改医生服务设置-疑难会诊
|
||||
if doctorInquiryConfig.InquiryType == 1 && doctorInquiryConfig.InquiryMode == 6 {
|
||||
// 获取医生服务设置-疑难会诊
|
||||
@@ -408,9 +408,7 @@ func (r *DoctorInquiryConfigService) PutDoctorInquiryConfig(inquiryConfigId int6
|
||||
return false, errors.New("修改失败")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -456,3 +456,23 @@ func (r *OrderInquiryService) GetOrderInquiryDoctorAmount(inquiryStatus int, amo
|
||||
|
||||
return doctorAmount
|
||||
}
|
||||
|
||||
// PutAnnualReviewHide 修改问诊订单年度审查隐藏状态
|
||||
func (r *OrderInquiryService) PutAnnualReviewHide(orderInquiryId int64, annualReviewHide int) error {
|
||||
// 获取问诊订单数据
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, err := orderInquiryDao.GetOrderInquiryById(orderInquiryId)
|
||||
if err != nil || orderInquiry == nil {
|
||||
return errors.New("订单数据错误")
|
||||
}
|
||||
|
||||
// 修改问诊订单
|
||||
orderInquiryData := make(map[string]interface{})
|
||||
orderInquiryData["annual_review_hide"] = annualReviewHide
|
||||
err = orderInquiryDao.EditOrderInquiryById(global.Db, orderInquiryId, orderInquiryData)
|
||||
if err != nil {
|
||||
return errors.New("修改隐藏状态失败")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -764,6 +764,11 @@ func (r *UserCaCertService) GetHospitalCloudCert() (g *dto.UserCaCertDto, err er
|
||||
maps["ca_pin"] = userId
|
||||
maps["type"] = 2
|
||||
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||
if userCaCert == nil {
|
||||
// 如果找不到证书,可以返回 nil,或者返回一个特定的业务 error (如: errors.New("暂无医院证书"))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
g = dto.GetUserCaCertDto(userCaCert)
|
||||
|
||||
return g, nil
|
||||
|
||||
@@ -42,6 +42,9 @@ func (b *AdminService) Login(LoginRequest requests.Login) (*dto.Login, error) {
|
||||
return nil, errors.New("您的账号已被禁用,请联系管理员处理")
|
||||
}
|
||||
|
||||
roleDao := dao.AdminRoleDao{}
|
||||
adminRole, err := roleDao.GetAdminRoleFirstById(adminUser.RoleID)
|
||||
|
||||
token := &utils.Token{
|
||||
UserId: strconv.FormatInt(adminUser.UserID, 10),
|
||||
RoleId: strconv.FormatInt(adminUser.RoleID, 10),
|
||||
@@ -60,6 +63,7 @@ func (b *AdminService) Login(LoginRequest requests.Login) (*dto.Login, error) {
|
||||
NickName: adminUser.NickName,
|
||||
Avatar: adminUser.Avatar,
|
||||
Token: jwt,
|
||||
RoleName: adminRole.RoleName,
|
||||
}
|
||||
|
||||
result.GetLoginFullAvatar()
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DoctorPharmacyService struct{}
|
||||
|
||||
// GetDoctorPharmacies 获取指定医生绑定的药房列表
|
||||
func (r *DoctorPharmacyService) GetDoctorPharmacies(doctorId int64) ([]*dto.DoctorPharmacyDto, error) {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
list, err := doctorPharmacyDao.GetDoctorPharmacyListByDoctorId(doctorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dto.GetDoctorPharmacyListDto(list), nil
|
||||
}
|
||||
|
||||
// BindDoctorPharmacies 批量绑定医生药房(全量覆盖)
|
||||
func (r *DoctorPharmacyService) BindDoctorPharmacies(doctorId int64, req requests.BindDoctorPharmacies) (bool, error) {
|
||||
// 校验医生是否存在
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
doctor, err := userDoctorDao.GetUserDoctorById(doctorId)
|
||||
if err != nil || doctor == nil {
|
||||
return false, errors.New("医生不存在或已删除")
|
||||
}
|
||||
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
var defaultPharmacyId int64 = -1
|
||||
if req.DefaultPharmacyId != "" {
|
||||
defaultPharmacyId, _ = strconv.ParseInt(req.DefaultPharmacyId, 10, 64)
|
||||
}
|
||||
|
||||
// 开启事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
|
||||
// 删除原绑定记录
|
||||
if err := doctorPharmacyDao.DeleteDoctorPharmacy(tx, map[string]interface{}{"doctor_id": doctorId}); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("清空原绑定关系失败")
|
||||
}
|
||||
|
||||
// 遍历新增绑定
|
||||
for i, v := range req.PharmacyIds {
|
||||
pharmacyId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil || pharmacyId < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 检查药房是否存在且正常
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("选择的药房不存在或已被禁用")
|
||||
}
|
||||
|
||||
isDefault := 0
|
||||
if defaultPharmacyId >= 0 && pharmacyId == defaultPharmacyId {
|
||||
isDefault = 1
|
||||
} else if defaultPharmacyId < 0 && i == 0 {
|
||||
// 未指定默认药房时,默认第1个为默认药房
|
||||
isDefault = 1
|
||||
}
|
||||
|
||||
dp := &model.DoctorPharmacy{
|
||||
DoctorId: doctorId,
|
||||
PharmacyId: pharmacyId,
|
||||
IsDefault: isDefault,
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
_, err = doctorPharmacyDao.AddDoctorPharmacy(tx, dp)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("保存绑定关系失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// AddDoctorPharmacy 新增单个药房绑定
|
||||
func (r *DoctorPharmacyService) AddDoctorPharmacy(doctorId int64, req requests.AddDoctorPharmacy) (bool, error) {
|
||||
if doctorId == 0 && req.DoctorId != "" {
|
||||
doctorId, _ = strconv.ParseInt(req.DoctorId, 10, 64)
|
||||
}
|
||||
if doctorId == 0 {
|
||||
return false, errors.New("医生id无效")
|
||||
}
|
||||
|
||||
pharmacyId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err != nil || pharmacyId < 0 {
|
||||
return false, errors.New("药房id无效")
|
||||
}
|
||||
|
||||
// 校验药房
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return false, errors.New("药房不存在或已禁用")
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
// 检查是否已绑定
|
||||
exist, _ := doctorPharmacyDao.GetDoctorPharmacyByDoctorAndPharmacy(doctorId, pharmacyId)
|
||||
if exist != nil {
|
||||
return false, errors.New("该药房已绑定,请勿重复添加")
|
||||
}
|
||||
|
||||
isDefault := 0
|
||||
if req.IsDefault != nil && *req.IsDefault == 1 {
|
||||
isDefault = 1
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 如果要设为默认,先将该医生现有的其他药房设为非默认
|
||||
if isDefault == 1 {
|
||||
if err := doctorPharmacyDao.ResetDoctorDefaultPharmacy(tx, doctorId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("重置默认药房失败")
|
||||
}
|
||||
} else {
|
||||
// 检查当前是否已有绑定药房,若无任何药房,则当前第一个自动作为默认
|
||||
existingList, _ := doctorPharmacyDao.GetDoctorPharmacyListByDoctorId(doctorId)
|
||||
if len(existingList) == 0 {
|
||||
isDefault = 1
|
||||
}
|
||||
}
|
||||
|
||||
dp := &model.DoctorPharmacy{
|
||||
DoctorId: doctorId,
|
||||
PharmacyId: pharmacyId,
|
||||
IsDefault: isDefault,
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
_, err = doctorPharmacyDao.AddDoctorPharmacy(tx, dp)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("添加绑定失败")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UnbindDoctorPharmacyById 根据绑定记录ID解绑
|
||||
func (r *DoctorPharmacyService) UnbindDoctorPharmacyById(doctorPharmacyId int64) (bool, error) {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
exist, err := doctorPharmacyDao.GetDoctorPharmacyById(doctorPharmacyId)
|
||||
if err != nil || exist == nil {
|
||||
return false, errors.New("未找到绑定记录")
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := doctorPharmacyDao.DeleteDoctorPharmacyById(tx, doctorPharmacyId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("解绑失败")
|
||||
}
|
||||
|
||||
// 如果解绑的是默认药房,尝试将剩余的第一个药房设为默认
|
||||
if exist.IsDefault == 1 {
|
||||
list, _ := doctorPharmacyDao.GetDoctorPharmacyListByDoctorId(exist.DoctorId)
|
||||
if len(list) > 0 {
|
||||
_ = doctorPharmacyDao.SetDefaultPharmacy(tx, exist.DoctorId, list[0].PharmacyId)
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UnbindDoctorPharmacy 解绑单个药房(支持通过 doctor_pharmacy_id 或 (doctor_id, pharmacy_id))
|
||||
func (r *DoctorPharmacyService) UnbindDoctorPharmacy(doctorId, pharmacyId int64) (bool, error) {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
exist, err := doctorPharmacyDao.GetDoctorPharmacyByDoctorAndPharmacy(doctorId, pharmacyId)
|
||||
if err != nil || exist == nil {
|
||||
return false, errors.New("未找到绑定记录")
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := doctorPharmacyDao.DeleteDoctorPharmacyByDoctorAndPharmacy(tx, doctorId, pharmacyId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("解绑失败")
|
||||
}
|
||||
|
||||
// 如果解绑的是默认药房,尝试将剩余的第一个药房设为默认
|
||||
if exist.IsDefault == 1 {
|
||||
list, _ := doctorPharmacyDao.GetDoctorPharmacyListByDoctorId(doctorId)
|
||||
if len(list) > 0 {
|
||||
_ = doctorPharmacyDao.SetDefaultPharmacy(tx, doctorId, list[0].PharmacyId)
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// SetDefaultPharmacyById 根据绑定关系主键设为默认
|
||||
func (r *DoctorPharmacyService) SetDefaultPharmacyById(doctorPharmacyId int64) (bool, error) {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
exist, err := doctorPharmacyDao.GetDoctorPharmacyById(doctorPharmacyId)
|
||||
if err != nil || exist == nil {
|
||||
return false, errors.New("该药房未绑定,无法设为默认")
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := doctorPharmacyDao.ResetDoctorDefaultPharmacy(tx, exist.DoctorId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("重置默认药房状态失败")
|
||||
}
|
||||
|
||||
if err := doctorPharmacyDao.SetDefaultPharmacyById(tx, doctorPharmacyId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("设置默认药房失败")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// SetDefaultPharmacy 设为默认药房(通过 doctor_id 和 pharmacy_id)
|
||||
func (r *DoctorPharmacyService) SetDefaultPharmacy(doctorId, pharmacyId int64) (bool, error) {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
exist, err := doctorPharmacyDao.GetDoctorPharmacyByDoctorAndPharmacy(doctorId, pharmacyId)
|
||||
if err != nil || exist == nil {
|
||||
return false, errors.New("该药房未绑定,无法设为默认")
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := doctorPharmacyDao.ResetDoctorDefaultPharmacy(tx, doctorId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("重置默认药房状态失败")
|
||||
}
|
||||
|
||||
if err := doctorPharmacyDao.SetDefaultPharmacy(tx, doctorId, pharmacyId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("设置默认药房失败")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
+150
-7
@@ -246,6 +246,8 @@ type OrderInquiry struct {
|
||||
// OrderProductData 药品订单
|
||||
type OrderProductData struct {
|
||||
OrderProductNo string // 订单编号
|
||||
PharmacyName string // 发货药房
|
||||
PharmacyCode string // 药房代码
|
||||
OrderProductStatus string // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
AmountTotal float64 // 订单金额
|
||||
CouponAmountTotal float64 // 优惠卷总金额
|
||||
@@ -325,6 +327,8 @@ type OrderServicePackageDto struct {
|
||||
|
||||
// OrderPrescriptionData 处方
|
||||
type OrderPrescriptionData struct {
|
||||
PharmacyName string // 开方药房
|
||||
PharmacyCode string // 药房代码
|
||||
DoctorName string // 医生姓名
|
||||
PharmacistName string // 药师姓名
|
||||
PrescriptionStatus string // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||||
@@ -371,9 +375,26 @@ type ProductData struct {
|
||||
FrequencyUse string // 使用频率(例:1天3次)
|
||||
AvailableDays float64 // 可用天数(3)
|
||||
ProductRemarks string // 商品备注
|
||||
PharmacyName string // 所属药房
|
||||
PharmacyCode string // 所属药房编码
|
||||
CreatedAt string // 创建时间
|
||||
}
|
||||
|
||||
// PharmacyDoctorData 药房关联医生
|
||||
type PharmacyDoctorData struct {
|
||||
PharmacyName string // 药房名称
|
||||
PharmacyCode string // 药房代码
|
||||
DoctorName string // 医生姓名
|
||||
Mobile string // 手机号
|
||||
DoctorTitle string // 医生职称
|
||||
HospitalName string // 医院名称
|
||||
DepartmentCustomName string // 科室名称
|
||||
DepartmentCustomMobile string // 科室电话
|
||||
IsDefault string // 是否默认药房(0:否 1:是)
|
||||
Status string // 状态(0:禁用 1:正常)
|
||||
CreatedAt string // 关联时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1497,6 +1518,8 @@ func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
|
||||
func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "系统订单编号", CellType: "string", NumberFmt: "", ColWidth: 25, Colour: "#FFD700"},
|
||||
{Value: "发货药房", CellType: "string", NumberFmt: "", ColWidth: 25, Colour: "#FFD700"},
|
||||
{Value: "药房代码", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"},
|
||||
{Value: "订单状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"},
|
||||
{Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||||
{Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||||
@@ -1545,9 +1568,22 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
pharmacyName := v.PharmacyName
|
||||
pharmacyCode := v.PharmacyCode
|
||||
if v.Pharmacy != nil {
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
data := OrderProductData{
|
||||
OrderProductNo: v.OrderProductNo,
|
||||
EscrowTradeNo: v.EscrowTradeNo,
|
||||
PharmacyName: pharmacyName,
|
||||
PharmacyCode: pharmacyCode,
|
||||
OrderProductStatus: utils.OrderProductStatusToString(v.OrderProductStatus),
|
||||
PayChannel: utils.PayChannelToString(v.PayChannel),
|
||||
PayStatus: utils.PayStatusToString(v.PayStatus),
|
||||
@@ -1571,13 +1607,13 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
|
||||
ConsigneeTel: v.ConsigneeTel,
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil {
|
||||
// 医生姓名
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
data.DoctorName = v.OrderInquiry.UserDoctor.UserName
|
||||
|
||||
if v.UserDoctor.User != nil {
|
||||
// 医生电话
|
||||
data.DoctorMobile = v.UserDoctor.User.Mobile
|
||||
// 医生电话
|
||||
if v.OrderInquiry.UserDoctor.User != nil {
|
||||
data.DoctorMobile = v.OrderInquiry.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1641,11 +1677,15 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
|
||||
|
||||
// 处理药品列表
|
||||
for _, item := range v.OrderProductItem {
|
||||
var availableDays float64
|
||||
if item.Product != nil {
|
||||
availableDays = item.Product.AvailableDays
|
||||
}
|
||||
productItem := OrderProductItemData{
|
||||
ProductName: item.ProductName,
|
||||
ProductPlatformCode: item.ProductPlatformCode,
|
||||
ProductSpec: item.ProductSpec,
|
||||
AvailableDays: item.Product.AvailableDays,
|
||||
AvailableDays: availableDays,
|
||||
ProductAmount: fmt.Sprintf("%d", item.Amount),
|
||||
ProductPrice: item.ProductPrice,
|
||||
}
|
||||
@@ -1789,6 +1829,8 @@ func (r *ExportService) OrderServicePackage(d []*model.OrderServicePackage) (str
|
||||
// OrderPrescription 处方
|
||||
func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "开方药房", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "药房代码", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "药师姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "处方状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
@@ -1815,7 +1857,20 @@ func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string,
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
pharmacyName := v.PharmacyName
|
||||
pharmacyCode := v.PharmacyCode
|
||||
if v.Pharmacy != nil {
|
||||
if pharmacyName == "" {
|
||||
pharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
data := OrderPrescriptionData{
|
||||
PharmacyName: pharmacyName,
|
||||
PharmacyCode: pharmacyCode,
|
||||
PrescriptionStatus: utils.PrescriptionStatusToString(v.PrescriptionStatus),
|
||||
PharmacistAuditStatus: utils.PharmacistAuditStatusToString(v.PharmacistAuditStatus),
|
||||
PharmacistFailReason: v.PharmacistFailReason,
|
||||
@@ -1830,7 +1885,10 @@ func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string,
|
||||
DoctorAdvice: v.DoctorAdvice,
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
if v.OrderInquiry !=nil && v.OrderInquiry.UserDoctor != nil {
|
||||
// 医生姓名
|
||||
data.DoctorName = v.OrderInquiry.UserDoctor.UserName
|
||||
}else if(v.UserDoctor !=nil){
|
||||
// 医生姓名
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
}
|
||||
@@ -1937,11 +1995,22 @@ func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||||
{Value: "使用频率(例:1天3次)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "可用天数(3)", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||
{Value: "商品备注", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||||
{Value: "所属药房", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "所属药房编码", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
pharmacyName := ""
|
||||
pharmacyCode := v.PharmacyCode
|
||||
if v.Pharmacy != nil {
|
||||
pharmacyName = v.Pharmacy.PharmacyName
|
||||
if pharmacyCode == "" {
|
||||
pharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
data := ProductData{
|
||||
ProductName: v.ProductName,
|
||||
CommonName: v.CommonName,
|
||||
@@ -1963,6 +2032,8 @@ func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||||
FrequencyUse: v.FrequencyUse,
|
||||
AvailableDays: v.AvailableDays,
|
||||
ProductRemarks: v.ProductRemarks,
|
||||
PharmacyName: pharmacyName,
|
||||
PharmacyCode: pharmacyCode,
|
||||
}
|
||||
|
||||
if v.ProductPlatformAmount != nil {
|
||||
@@ -1996,3 +2067,75 @@ func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// PharmacyDoctor 药房关联医生
|
||||
func (r *ExportService) PharmacyDoctor(d []*model.DoctorPharmacy) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "药房名称", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "药房代码", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医生职称", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医院名称", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "科室名称", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||||
{Value: "科室电话", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "是否默认药房", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "状态", CellType: "string", NumberFmt: "", ColWidth: 15},
|
||||
{Value: "关联时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := PharmacyDoctorData{
|
||||
IsDefault: utils.IsDefaultToString(v.IsDefault),
|
||||
Status: "正常",
|
||||
}
|
||||
if v.Status == 0 {
|
||||
data.Status = "禁用"
|
||||
}
|
||||
|
||||
if v.Pharmacy != nil {
|
||||
data.PharmacyName = v.Pharmacy.PharmacyName
|
||||
data.PharmacyCode = v.Pharmacy.PharmacyCode
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
data.DoctorTitle = utils.DoctorTitleToString(v.UserDoctor.DoctorTitle)
|
||||
data.DepartmentCustomName = v.UserDoctor.DepartmentCustomName
|
||||
data.DepartmentCustomMobile = v.UserDoctor.DepartmentCustomMobile
|
||||
if v.UserDoctor.Hospital != nil {
|
||||
data.HospitalName = v.UserDoctor.Hospital.HospitalName
|
||||
}
|
||||
if v.UserDoctor.User != nil {
|
||||
data.Mobile = v.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
data.CreatedAt = time.Time(v.CreatedAt).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||||
ossPath := "admin/export/药房关联医生" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||
|
||||
// 上传oss
|
||||
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/extend/aliyun"
|
||||
@@ -246,9 +247,15 @@ func (r *OrderService) ReportPreProduct(orderProductId, adminUserId int64) (bool
|
||||
|
||||
presRequests[0] = presRequest
|
||||
|
||||
// 终端代码:优先使用订单关联药房的代码,未配置则使用全局配置
|
||||
terminalCode := config.C.Pre.PrePlatTerminalCode
|
||||
if orderProduct.PharmacyCode != "" {
|
||||
terminalCode = orderProduct.PharmacyCode
|
||||
}
|
||||
|
||||
// 处理上传数据-基础数据
|
||||
ReportPreRequest := prescription.ReportPreRequest{
|
||||
TerminalCode: "ZD-10003",
|
||||
TerminalCode: terminalCode,
|
||||
OrderNo: orderProduct.OrderProductNo, // 订单编号
|
||||
TransactNo: orderProduct.EscrowTradeNo, // 流水单号
|
||||
PayDate: time.Time(orderProduct.PayTime).Format("2006-01-02 15:04:05"), // 支付时间
|
||||
|
||||
@@ -82,5 +82,15 @@ func (r *OrderPrescriptionService) GetOrderPrescription(OrderPrescriptionId int6
|
||||
// 加载药品订单id
|
||||
g.LoadOrderProductId(orderProduct)
|
||||
|
||||
// 加载原始医生信息
|
||||
if orderPrescription.OrderInquiry != nil && orderPrescription.OrderInquiry.UserDoctor != nil {
|
||||
g.LoadInquiryDoctor(orderPrescription.OrderInquiry.UserDoctor)
|
||||
}
|
||||
|
||||
// 加载接受抄方的医生信息
|
||||
if orderPrescription.OrderInquiry != nil && orderPrescription.OrderInquiry.TransferUserDoctor != nil {
|
||||
g.LoadTransferUserDoctor(orderPrescription.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
@@ -68,9 +68,24 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (g *dto.Orde
|
||||
// 加载医生数据
|
||||
g.UserDoctor = userDoctor
|
||||
|
||||
// 加载原始医生信息
|
||||
if orderProduct.OrderInquiry != nil && orderProduct.OrderInquiry.UserDoctor != nil {
|
||||
g.LoadInquiryDoctor(orderProduct.OrderInquiry.UserDoctor)
|
||||
}
|
||||
|
||||
// 加载接受抄方的医生信息
|
||||
if orderProduct.OrderInquiry != nil && orderProduct.OrderInquiry.TransferUserDoctor != nil {
|
||||
g.LoadTransferUserDoctor(orderProduct.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 加载问诊病例
|
||||
g.LoadOrderInquiryCase(orderInquiryCase)
|
||||
|
||||
// 加载问诊类型
|
||||
if orderProduct.OrderInquiry != nil && orderProduct.OrderInquiry.UserDoctor != nil && orderProduct.OrderInquiry.TransferUserDoctor != nil{
|
||||
g.LoadIsTransferOrder(orderProduct.OrderInquiry.UserDoctor, orderProduct.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 加载处方数据
|
||||
g.LoadOrderPrescription(orderPrescription)
|
||||
|
||||
|
||||
@@ -0,0 +1,607 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PharmacyService struct{}
|
||||
|
||||
// AddPharmacy 新增药房
|
||||
func (r *PharmacyService) AddPharmacy(req requests.AddPharmacy) (bool, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
|
||||
// 检测药房代码是否已存在
|
||||
existPharmacy, err := pharmacyDao.GetPharmacyByCode(req.PharmacyCode)
|
||||
if err == nil && existPharmacy != nil {
|
||||
return false, errors.New("药房代码已存在,请勿重复添加")
|
||||
}
|
||||
|
||||
var province string
|
||||
var city string
|
||||
var county string
|
||||
|
||||
areaDao := dao.AreaDao{}
|
||||
if req.ProvinceId != 0 {
|
||||
area, err := areaDao.GetAreaById(req.ProvinceId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("省份数据错误")
|
||||
}
|
||||
province = area.AreaName
|
||||
}
|
||||
|
||||
if req.CityId != 0 {
|
||||
area, err := areaDao.GetAreaById(req.CityId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("城市数据错误")
|
||||
}
|
||||
city = area.AreaName
|
||||
}
|
||||
|
||||
if req.CountyId != 0 {
|
||||
area, err := areaDao.GetAreaById(req.CountyId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("区县数据错误")
|
||||
}
|
||||
county = area.AreaName
|
||||
}
|
||||
|
||||
status := 1
|
||||
if req.Status != nil {
|
||||
status = *req.Status
|
||||
}
|
||||
|
||||
// 开启事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
pharmacy := &model.Pharmacy{
|
||||
PharmacyName: req.PharmacyName,
|
||||
PharmacyCode: req.PharmacyCode,
|
||||
Postage: *req.Postage,
|
||||
FreeShippingThreshold: *req.FreeShippingThreshold,
|
||||
IsPickup: *req.IsPickup,
|
||||
Telephone: req.Telephone,
|
||||
ProvinceId: req.ProvinceId,
|
||||
Province: province,
|
||||
CityId: req.CityId,
|
||||
City: city,
|
||||
CountyId: req.CountyId,
|
||||
County: county,
|
||||
Address: req.Address,
|
||||
Status: status,
|
||||
}
|
||||
|
||||
pharmacy, err = pharmacyDao.AddPharmacy(tx, pharmacy)
|
||||
if err != nil || pharmacy == nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// PutPharmacy 修改药房
|
||||
func (r *PharmacyService) PutPharmacy(pharmacyId int64, req requests.PutPharmacy) (bool, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return false, errors.New("药房不存在或已删除")
|
||||
}
|
||||
|
||||
// 如果修改了代码,需检查新代码是否被其他药房占用
|
||||
if req.PharmacyCode != pharmacy.PharmacyCode {
|
||||
exist, err := pharmacyDao.GetPharmacyByCode(req.PharmacyCode)
|
||||
if err == nil && exist != nil && exist.PharmacyId != pharmacyId {
|
||||
return false, errors.New("药房代码已被占用")
|
||||
}
|
||||
}
|
||||
|
||||
// 若修改为禁用,校验是否有医生设为默认药房
|
||||
if req.Status != nil && *req.Status == 0 && pharmacy.Status == 1 {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
totalCount, defaultCount, err := doctorPharmacyDao.GetDoctorPharmacyCountsByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return false, errors.New("查询药房关联医生失败")
|
||||
}
|
||||
if defaultCount > 0 {
|
||||
return false, fmt.Errorf("该药房已被 %d 位医生设为默认药房(共 %d 位医生绑定),无法禁用。请先在【药房关联医生】中调整默认药房或解除绑定后再试", defaultCount, totalCount)
|
||||
}
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
fmt.Println(rec)
|
||||
}
|
||||
}()
|
||||
|
||||
pharmacyData := make(map[string]interface{})
|
||||
|
||||
if req.PharmacyName != pharmacy.PharmacyName {
|
||||
pharmacyData["pharmacy_name"] = req.PharmacyName
|
||||
}
|
||||
|
||||
if req.PharmacyCode != pharmacy.PharmacyCode {
|
||||
pharmacyData["pharmacy_code"] = req.PharmacyCode
|
||||
}
|
||||
|
||||
if *req.Postage != pharmacy.Postage {
|
||||
pharmacyData["postage"] = *req.Postage
|
||||
}
|
||||
|
||||
if *req.FreeShippingThreshold != pharmacy.FreeShippingThreshold {
|
||||
pharmacyData["free_shipping_threshold"] = *req.FreeShippingThreshold
|
||||
}
|
||||
|
||||
if *req.IsPickup != pharmacy.IsPickup {
|
||||
pharmacyData["is_pickup"] = *req.IsPickup
|
||||
}
|
||||
|
||||
if req.Telephone != pharmacy.Telephone {
|
||||
pharmacyData["telephone"] = req.Telephone
|
||||
}
|
||||
|
||||
if req.ProvinceId != 0 && req.ProvinceId != pharmacy.ProvinceId {
|
||||
areaDao := dao.AreaDao{}
|
||||
area, err := areaDao.GetAreaById(req.ProvinceId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("省份数据错误")
|
||||
}
|
||||
pharmacyData["province_id"] = req.ProvinceId
|
||||
pharmacyData["province"] = area.AreaName
|
||||
}
|
||||
|
||||
if req.CityId != 0 && req.CityId != pharmacy.CityId {
|
||||
areaDao := dao.AreaDao{}
|
||||
area, err := areaDao.GetAreaById(req.CityId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("城市数据错误")
|
||||
}
|
||||
pharmacyData["city_id"] = req.CityId
|
||||
pharmacyData["city"] = area.AreaName
|
||||
}
|
||||
|
||||
if req.CountyId != 0 && req.CountyId != pharmacy.CountyId {
|
||||
areaDao := dao.AreaDao{}
|
||||
area, err := areaDao.GetAreaById(req.CountyId)
|
||||
if err != nil || area == nil {
|
||||
return false, errors.New("区县数据错误")
|
||||
}
|
||||
pharmacyData["county_id"] = req.CountyId
|
||||
pharmacyData["county"] = area.AreaName
|
||||
}
|
||||
|
||||
if req.Address != pharmacy.Address {
|
||||
pharmacyData["address"] = req.Address
|
||||
}
|
||||
|
||||
if req.Status != nil && *req.Status != pharmacy.Status {
|
||||
pharmacyData["status"] = *req.Status
|
||||
}
|
||||
|
||||
if len(pharmacyData) > 0 {
|
||||
err = pharmacyDao.EditPharmacyById(tx, pharmacyId, pharmacyData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// PutPharmacyStatus 修改药房状态
|
||||
func (r *PharmacyService) PutPharmacyStatus(pharmacyId int64, req requests.PutPharmacyStatus) (bool, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return false, errors.New("药房不存在或已删除")
|
||||
}
|
||||
|
||||
// 若修改为禁用,校验是否有医生设为默认药房
|
||||
if req.Status != nil && *req.Status == 0 {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
totalCount, defaultCount, err := doctorPharmacyDao.GetDoctorPharmacyCountsByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return false, errors.New("查询药房关联医生失败")
|
||||
}
|
||||
if defaultCount > 0 {
|
||||
return false, fmt.Errorf("该药房已被 %d 位医生设为默认药房(共 %d 位医生绑定),无法禁用。请先在【药房关联医生】中调整默认药房或解除绑定后再试", defaultCount, totalCount)
|
||||
}
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"status": *req.Status,
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
err = pharmacyDao.EditPharmacyById(tx, pharmacyId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// DeletePharmacy 软删除药房
|
||||
func (r *PharmacyService) DeletePharmacy(pharmacyId int64) (bool, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return false, errors.New("药房不存在或已删除")
|
||||
}
|
||||
|
||||
// 删除药房前校验:若有关联医生(特别是默认药房),拦截禁止删除
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
totalCount, defaultCount, err := doctorPharmacyDao.GetDoctorPharmacyCountsByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return false, errors.New("查询药房关联医生失败")
|
||||
}
|
||||
if defaultCount > 0 {
|
||||
return false, fmt.Errorf("该药房已被 %d 位医生设为默认药房(共 %d 位医生绑定),无法删除。请先在【药房关联医生】中调整默认药房或解除绑定后再试", defaultCount, totalCount)
|
||||
}
|
||||
if totalCount > 0 {
|
||||
return false, fmt.Errorf("该药房仍有 %d 位医生绑定,无法删除。请先在【药房关联医生】中解除绑定后再试", totalCount)
|
||||
}
|
||||
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
err = pharmacyDao.DeletePharmacyById(tx, pharmacyId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetPharmacy 药房详情
|
||||
func (r *PharmacyService) GetPharmacy(pharmacyId int64) (*dto.PharmacyDto, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) || pharmacy == nil {
|
||||
return nil, errors.New("未找到相关药房信息")
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dto.GetPharmacyDto(pharmacy), nil
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorPage 获取药房绑定的医生列表-分页
|
||||
func (r *PharmacyService) GetPharmacyDoctorPage(req requests.GetPharmacyDoctorPage) (map[string]interface{}, error) {
|
||||
pharmacyId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err != nil || pharmacyId < 0 {
|
||||
return nil, errors.New("药房id无效")
|
||||
}
|
||||
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return nil, errors.New("药房不存在或已被删除")
|
||||
}
|
||||
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 20
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
list, total, err := doctorPharmacyDao.GetPharmacyDoctorPageSearch(pharmacyId, req, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resList := dto.GetPharmacyDoctorListDto(list)
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = resList
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetPharmacyDoctorList 获取药房绑定的全部医生列表
|
||||
func (r *PharmacyService) GetPharmacyDoctorList(pharmacyId int64) ([]dto.PharmacyDoctorDto, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return nil, errors.New("药房不存在或已被删除")
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
list, err := doctorPharmacyDao.GetPharmacyDoctorListByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dto.GetPharmacyDoctorListDto(list), nil
|
||||
}
|
||||
|
||||
// GetAffectedDoctors 获取药房下线受影响医生列表(预检接口)
|
||||
func (r *PharmacyService) GetAffectedDoctors(pharmacyId int64) (*dto.PharmacyAffectedDoctorsDto, error) {
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if err != nil || pharmacy == nil {
|
||||
return nil, errors.New("药房不存在或已删除")
|
||||
}
|
||||
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
totalCount, defaultCount, err := doctorPharmacyDao.GetDoctorPharmacyCountsByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询药房关联医生数量失败")
|
||||
}
|
||||
|
||||
// 获取将当前药房设为默认药房的受影响医生列表(仅默认药房受影响的医生需要重新指定默认药房)
|
||||
list, err := doctorPharmacyDao.GetDefaultPharmacyDoctorListByPharmacyId(pharmacyId)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询受影响医生列表失败")
|
||||
}
|
||||
|
||||
// 收集所有医生ID
|
||||
doctorIds := make([]int64, 0, len(list))
|
||||
for _, dp := range list {
|
||||
doctorIds = append(doctorIds, dp.DoctorId)
|
||||
}
|
||||
|
||||
// 批量查询这些医生绑定的其他有效药房
|
||||
otherMap := make(map[int64][]dto.BoundPharmacySimpleDto)
|
||||
if len(doctorIds) > 0 {
|
||||
otherList, err := doctorPharmacyDao.GetOtherPharmaciesByDoctorIds(doctorIds, pharmacyId)
|
||||
if err == nil {
|
||||
for _, dp := range otherList {
|
||||
if dp.Pharmacy != nil && dp.Pharmacy.Status == 1 {
|
||||
otherMap[dp.DoctorId] = append(otherMap[dp.DoctorId], dto.BoundPharmacySimpleDto{
|
||||
PharmacyId: strconv.FormatInt(dp.Pharmacy.PharmacyId, 10),
|
||||
PharmacyName: dp.Pharmacy.PharmacyName,
|
||||
PharmacyCode: dp.Pharmacy.PharmacyCode,
|
||||
IsDefault: dp.IsDefault,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doctorItems := make([]dto.AffectedDoctorItemDto, 0, len(list))
|
||||
for _, dp := range list {
|
||||
item := dto.AffectedDoctorItemDto{
|
||||
DoctorId: strconv.FormatInt(dp.DoctorId, 10),
|
||||
DoctorPharmacyId: strconv.FormatInt(dp.DoctorPharmacyId, 10),
|
||||
IsDefault: dp.IsDefault,
|
||||
}
|
||||
if dp.UserDoctor != nil {
|
||||
item.UserId = strconv.FormatInt(dp.UserDoctor.UserId, 10)
|
||||
item.UserName = dp.UserDoctor.UserName
|
||||
item.DoctorTitleName = dto.GetDoctorTitleName(dp.UserDoctor.DoctorTitle)
|
||||
item.HospitalId = strconv.FormatInt(dp.UserDoctor.HospitalID, 10)
|
||||
if dp.UserDoctor.Hospital != nil {
|
||||
item.HospitalName = dp.UserDoctor.Hospital.HospitalName
|
||||
}
|
||||
item.DepartmentCustomId = strconv.FormatInt(dp.UserDoctor.DepartmentCustomId, 10)
|
||||
item.DepartmentCustomName = dp.UserDoctor.DepartmentCustomName
|
||||
if dp.UserDoctor.User != nil {
|
||||
item.Mobile = dp.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
if others, ok := otherMap[dp.DoctorId]; ok {
|
||||
item.OtherBoundPharmacies = others
|
||||
} else {
|
||||
item.OtherBoundPharmacies = []dto.BoundPharmacySimpleDto{}
|
||||
}
|
||||
doctorItems = append(doctorItems, item)
|
||||
}
|
||||
|
||||
res := &dto.PharmacyAffectedDoctorsDto{
|
||||
PharmacyId: strconv.FormatInt(pharmacy.PharmacyId, 10),
|
||||
PharmacyName: pharmacy.PharmacyName,
|
||||
PharmacyCode: pharmacy.PharmacyCode,
|
||||
Status: pharmacy.Status,
|
||||
DefaultDoctorCount: defaultCount,
|
||||
TotalDoctorCount: totalCount,
|
||||
DoctorList: doctorItems,
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// BatchTransferAndAction 批量迁移医生默认药房并执行药房操作(禁用/删除)
|
||||
func (r *PharmacyService) BatchTransferAndAction(req requests.BatchTransferAndAction) (bool, error) {
|
||||
sourcePharmacyId, err := strconv.ParseInt(req.SourcePharmacyId, 10, 64)
|
||||
if err != nil || sourcePharmacyId < 0 {
|
||||
return false, errors.New("原药房id无效")
|
||||
}
|
||||
|
||||
if req.Action != "disable" && req.Action != "delete" {
|
||||
return false, errors.New("操作类型仅支持 disable(禁用) 或 delete(删除)")
|
||||
}
|
||||
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
sourcePharmacy, err := pharmacyDao.GetPharmacyById(sourcePharmacyId)
|
||||
if err != nil || sourcePharmacy == nil {
|
||||
return false, errors.New("原药房不存在或已删除")
|
||||
}
|
||||
|
||||
// 查询当前以原药房为默认药房的所有医生
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
var defaultDoctorPharmacies []*model.DoctorPharmacy
|
||||
err = global.Db.Where("pharmacy_id = ? AND status = 1 AND is_default = 1", sourcePharmacyId).Find(&defaultDoctorPharmacies).Error
|
||||
if err != nil {
|
||||
return false, errors.New("查询受影响医生失败")
|
||||
}
|
||||
|
||||
defaultDoctorMap := make(map[int64]bool)
|
||||
for _, dp := range defaultDoctorPharmacies {
|
||||
defaultDoctorMap[dp.DoctorId] = true
|
||||
}
|
||||
|
||||
// 校验 transfers
|
||||
transferDoctorMap := make(map[int64]int64) // doctorId -> targetPharmacyId
|
||||
targetPharmacyIdSet := make(map[int64]bool)
|
||||
|
||||
for _, item := range req.Transfers {
|
||||
docId, err := strconv.ParseInt(item.DoctorId, 10, 64)
|
||||
if err != nil || docId <= 0 {
|
||||
return false, errors.New("迁移配置中包含无效的医生id: " + item.DoctorId)
|
||||
}
|
||||
targetPharId, err := strconv.ParseInt(item.TargetPharmacyId, 10, 64)
|
||||
if err != nil || targetPharId < 0 {
|
||||
return false, errors.New("迁移配置中包含无效的目标药房id: " + item.TargetPharmacyId)
|
||||
}
|
||||
if targetPharId == sourcePharmacyId {
|
||||
return false, errors.New("目标药房不能是当前待下线的药房自身")
|
||||
}
|
||||
if _, exists := transferDoctorMap[docId]; exists {
|
||||
return false, fmt.Errorf("医生(ID: %d)存在重复迁移配置,每位医生只能指定一个默认药房", docId)
|
||||
}
|
||||
transferDoctorMap[docId] = targetPharId
|
||||
targetPharmacyIdSet[targetPharId] = true
|
||||
}
|
||||
|
||||
// 强校验:原药房名下所有默认医生必须全部指定了替代药房
|
||||
for docId := range defaultDoctorMap {
|
||||
if _, ok := transferDoctorMap[docId]; !ok {
|
||||
return false, fmt.Errorf("医生(ID: %d)当前以此药房为默认药房,必须为其指定替代药房", docId)
|
||||
}
|
||||
}
|
||||
|
||||
// 校验所有目标药房必须存在且处于正常状态 (status = 1)
|
||||
if len(targetPharmacyIdSet) > 0 {
|
||||
var targetPharIds []int64
|
||||
for id := range targetPharmacyIdSet {
|
||||
targetPharIds = append(targetPharIds, id)
|
||||
}
|
||||
|
||||
var targetPharmacies []*model.Pharmacy
|
||||
err = global.Db.Where("pharmacy_id IN (?)", targetPharIds).Find(&targetPharmacies).Error
|
||||
if err != nil {
|
||||
return false, errors.New("查询目标药房信息失败")
|
||||
}
|
||||
|
||||
targetMap := make(map[int64]*model.Pharmacy)
|
||||
for _, ph := range targetPharmacies {
|
||||
targetMap[ph.PharmacyId] = ph
|
||||
}
|
||||
|
||||
for _, targetId := range targetPharIds {
|
||||
ph, exists := targetMap[targetId]
|
||||
if !exists || ph == nil {
|
||||
return false, fmt.Errorf("目标药房(ID: %d)不存在或已被删除", targetId)
|
||||
}
|
||||
if ph.Status != 1 {
|
||||
return false, fmt.Errorf("目标药房【%s】处于禁用状态,无法作为替代药房", ph.PharmacyName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 开启事务执行迁移与药房操作
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
// 逐个医生处理目标药房绑定与默认设置
|
||||
for docId, targetPharId := range transferDoctorMap {
|
||||
// 1. 重置该医生名下现有的所有药房为非默认
|
||||
if err := doctorPharmacyDao.ResetDoctorDefaultPharmacy(tx, docId); err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("重置医生默认药房失败")
|
||||
}
|
||||
|
||||
// 2. 检查该医生是否已绑定目标药房
|
||||
existTarget, _ := doctorPharmacyDao.GetDoctorPharmacyByDoctorAndPharmacy(docId, targetPharId)
|
||||
if existTarget != nil {
|
||||
// 更新为 status = 1, is_default = 1
|
||||
err = tx.Model(&model.DoctorPharmacy{}).
|
||||
Where("doctor_pharmacy_id = ?", existTarget.DoctorPharmacyId).
|
||||
Updates(map[string]interface{}{
|
||||
"is_default": 1,
|
||||
"status": 1,
|
||||
}).Error
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("更新目标药房绑定关系失败")
|
||||
}
|
||||
} else {
|
||||
// 新增绑定记录
|
||||
newBinding := &model.DoctorPharmacy{
|
||||
DoctorId: docId,
|
||||
PharmacyId: targetPharId,
|
||||
IsDefault: 1,
|
||||
Status: 1,
|
||||
}
|
||||
_, err = doctorPharmacyDao.AddDoctorPharmacy(tx, newBinding)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增目标药房绑定关系失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 处理医生与原药房关系
|
||||
if req.Action == "delete" || (req.UnbindSource != nil && *req.UnbindSource == 1) {
|
||||
_ = doctorPharmacyDao.DeleteDoctorPharmacyByDoctorAndPharmacy(tx, docId, sourcePharmacyId)
|
||||
}
|
||||
}
|
||||
|
||||
// 执行原药房下线操作
|
||||
if req.Action == "disable" {
|
||||
// 若选择了解绑原药房,清空原药房所有绑定记录
|
||||
if req.UnbindSource != nil && *req.UnbindSource == 1 {
|
||||
_ = doctorPharmacyDao.DeleteDoctorPharmacy(tx, map[string]interface{}{"pharmacy_id": sourcePharmacyId})
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"status": 0,
|
||||
}
|
||||
err = pharmacyDao.EditPharmacyById(tx, sourcePharmacyId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("修改药房状态失败: " + err.Error())
|
||||
}
|
||||
} else if req.Action == "delete" {
|
||||
// 删除药房必须清空所有关联记录,防止外键孤儿数据
|
||||
_ = doctorPharmacyDao.DeleteDoctorPharmacy(tx, map[string]interface{}{"pharmacy_id": sourcePharmacyId})
|
||||
|
||||
err = pharmacyDao.DeletePharmacyById(tx, sourcePharmacyId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("删除药房失败: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
+50
-4
@@ -27,8 +27,14 @@ func (r *ProductService) GetProductPlatform(productPlatformId int64) (g *dto.Pro
|
||||
// 获取商品库存
|
||||
var quantity int
|
||||
|
||||
pharmacyCode := productPlatform.PharmacyCode
|
||||
if pharmacyCode == "" && productPlatform.Pharmacy != nil {
|
||||
pharmacyCode = productPlatform.Pharmacy.PharmacyCode
|
||||
}
|
||||
|
||||
ReportPreRequest := prescription.GetProdStockRequest{
|
||||
DrugCode: productPlatform.ProductPharmacyCode,
|
||||
PharmacyCode: pharmacyCode,
|
||||
DrugCode: productPlatform.ProductPharmacyCode,
|
||||
}
|
||||
|
||||
result, err := ReportPreRequest.GetProdStock()
|
||||
@@ -94,16 +100,53 @@ func (r *ProductService) AddProduct(userId string, req requests.AddProduct) (boo
|
||||
return false, errors.New("平台商品不存在")
|
||||
}
|
||||
|
||||
// 检测商品是否重复
|
||||
// 确定所属药房信息
|
||||
pharmacyDao := dao.PharmacyDao{}
|
||||
var pharmacyId int64 = 0
|
||||
var pharmacyCode string = ""
|
||||
|
||||
if req.PharmacyId != "" {
|
||||
pId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
|
||||
if err == nil && pId >= 0 {
|
||||
pharmacyId = pId
|
||||
pharmacy, _ := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if pharmacy != nil {
|
||||
pharmacyCode = pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
} else if req.PharmacyCode != "" {
|
||||
pharmacyCode = req.PharmacyCode
|
||||
pharmacy, _ := pharmacyDao.GetPharmacyByCode(pharmacyCode)
|
||||
if pharmacy != nil {
|
||||
pharmacyId = pharmacy.PharmacyId
|
||||
}
|
||||
} else if productPlatform.PharmacyCode != "" {
|
||||
pharmacyCode = productPlatform.PharmacyCode
|
||||
pharmacy, _ := pharmacyDao.GetPharmacyByCode(pharmacyCode)
|
||||
if pharmacy != nil {
|
||||
pharmacyId = pharmacy.PharmacyId
|
||||
}
|
||||
}
|
||||
|
||||
// 若仍无编码,查询对应药房编码(如默认药房 0)
|
||||
if pharmacyCode == "" {
|
||||
pharmacy, _ := pharmacyDao.GetPharmacyById(pharmacyId)
|
||||
if pharmacy != nil {
|
||||
pharmacyCode = pharmacy.PharmacyCode
|
||||
}
|
||||
}
|
||||
|
||||
// 检测同一药房下商品是否重复
|
||||
maps := make(map[string]interface{})
|
||||
maps["product_platform_id"] = req.ProductPlatformId
|
||||
maps["pharmacy_id"] = pharmacyId
|
||||
products, err := productDao.GetProductList(maps)
|
||||
if err != nil {
|
||||
return false, errors.New("商品重复添加")
|
||||
}
|
||||
|
||||
if len(products) != 0 {
|
||||
return false, errors.New("商品重复添加")
|
||||
return false, errors.New("该药房已添加此商品,请勿重复添加")
|
||||
}
|
||||
|
||||
// 处理图片
|
||||
@@ -120,6 +163,8 @@ func (r *ProductService) AddProduct(userId string, req requests.AddProduct) (boo
|
||||
// 新增商品表
|
||||
product := &model.Product{
|
||||
ProductPlatformId: productPlatform.ProductPlatformId,
|
||||
PharmacyId: pharmacyId,
|
||||
PharmacyCode: pharmacyCode,
|
||||
ProductStatus: *req.ProductStatus,
|
||||
ProductName: req.ProductName,
|
||||
CommonName: req.CommonName,
|
||||
@@ -149,7 +194,8 @@ func (r *ProductService) AddProduct(userId string, req requests.AddProduct) (boo
|
||||
|
||||
// 获取商品库存
|
||||
ReportPreRequest := prescription.GetProdStockRequest{
|
||||
DrugCode: product.ProductPharmacyCode,
|
||||
PharmacyCode: product.PharmacyCode,
|
||||
DrugCode: product.ProductPharmacyCode,
|
||||
}
|
||||
|
||||
result, err := ReportPreRequest.GetProdStock()
|
||||
|
||||
@@ -60,6 +60,11 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse
|
||||
// 加载医生专长
|
||||
getUserDoctorResponse.DoctorExpertise = doctorExpertise
|
||||
|
||||
// 加载医生药房
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
doctorPharmacies, _ := doctorPharmacyDao.GetDoctorPharmacyListByDoctorId(doctorId)
|
||||
getUserDoctorResponse.DoctorPharmacy = dto.GetDoctorPharmacyListDto(doctorPharmacies)
|
||||
|
||||
// 加载医生银行卡
|
||||
getUserDoctorResponse.LoadDoctorBankCard(doctorBankCard)
|
||||
|
||||
@@ -175,6 +180,11 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
||||
userDoctorData["is_sys_diagno_cooperation"] = req.IsSysDiagnoCooperation
|
||||
}
|
||||
|
||||
// 处理是否接受抄方
|
||||
if userDoctor.IsTransferPrescription != req.IsTransferPrescription {
|
||||
userDoctorData["is_transfer_prescription"] = req.IsTransferPrescription
|
||||
}
|
||||
|
||||
// 是否推荐
|
||||
if userDoctor.IsRecommend != req.IsRecommend {
|
||||
userDoctorData["is_recommend"] = req.IsRecommend
|
||||
@@ -547,6 +557,47 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
||||
}
|
||||
}
|
||||
|
||||
// 修改药房数据
|
||||
if len(req.DoctorPharmacy) > 0 {
|
||||
doctorPharmacyDao := dao.DoctorPharmacyDao{}
|
||||
|
||||
// 删除原绑定
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = userDoctor.DoctorId
|
||||
err = doctorPharmacyDao.DeleteDoctorPharmacy(tx, maps)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("清空药房绑定失败")
|
||||
}
|
||||
|
||||
for i, v := range req.DoctorPharmacy {
|
||||
pharmacyId, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("药房数据错误")
|
||||
}
|
||||
|
||||
isDefault := 0
|
||||
if i == 0 {
|
||||
isDefault = 1
|
||||
}
|
||||
|
||||
// 新增药房绑定数据
|
||||
doctorPharmacy := &model.DoctorPharmacy{
|
||||
DoctorId: userDoctor.DoctorId,
|
||||
PharmacyId: pharmacyId,
|
||||
IsDefault: isDefault,
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
_, err = doctorPharmacyDao.AddDoctorPharmacy(tx, doctorPharmacy)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改医生银行卡数据-新增
|
||||
if doctorBankCard == nil {
|
||||
if provinceId != 0 && cityId != 0 && countyId != 0 && bankId != 0 && bankCardCode != "" {
|
||||
@@ -970,6 +1021,7 @@ func (r *UserDoctorService) AddUserDoctor(userId string, req requests.AddUserDoc
|
||||
HospitalID: hospitalId,
|
||||
IsPlatformDeepCooperation: req.IsPlatformDeepCooperation,
|
||||
IsSysDiagnoCooperation: req.IsSysDiagnoCooperation,
|
||||
IsTransferPrescription: req.IsTransferPrescription,
|
||||
BeGoodAt: req.BeGoodAt,
|
||||
BriefIntroduction: req.BriefIntroduction,
|
||||
}
|
||||
|
||||
+13
-3
@@ -53,6 +53,11 @@ ca-online:
|
||||
ca-online-app-secret: adf718ebc1fb4bb7b158de9117d1313a
|
||||
ca-online-api-url: http://testmicrosrv.scca.com.cn:9527
|
||||
|
||||
ca-online-v2:
|
||||
ca-online-app-id: SCCA1951838127584579586
|
||||
ca-online-app-secret: a26bf6c8b78b4099939ab09accbc9a80
|
||||
ca-online-api-url: http://testmicrosrv.scca.com.cn:9647
|
||||
|
||||
# [腾讯im]
|
||||
#im:
|
||||
# im-app-id: 1400798221
|
||||
@@ -102,10 +107,15 @@ wechat:
|
||||
|
||||
# [处方平台]
|
||||
pre:
|
||||
# pre-plat-client-id: ZD-004
|
||||
# pre-plat-client-secret: 0baa5927164710b9f800bf33546b6da3
|
||||
# pre-plat-app-url: http://49.233.3.200:6304/api/thridapi/
|
||||
# pre-plat-pharmacy-code: JG-10009
|
||||
pre-plat-client-id: ZD-004
|
||||
pre-plat-client-secret: 0baa5927164710b9f800bf33546b6da3
|
||||
pre-plat-app-url: http://49.233.3.200:6304/api/thridapi/
|
||||
pre-plat-pharmacy-code: JG-10009
|
||||
pre-plat-client-secret: 0baa5927164710b9f800bf33546b6da4
|
||||
pre-plat-app-url: http://cf-thirdapi-test.yctang.net/api/thridapi/
|
||||
pre-plat-pharmacy-code: ZD-10198
|
||||
pre-plat-terminal-code: ZD-10003
|
||||
|
||||
# [rabbitMq]
|
||||
amqp:
|
||||
|
||||
@@ -46,6 +46,11 @@ ca-online:
|
||||
ca-online-app-secret:
|
||||
ca-online-api-url:
|
||||
|
||||
ca-online-v2:
|
||||
ca-online-app-id:
|
||||
ca-online-app-secret:
|
||||
ca-online-api-url:
|
||||
|
||||
# [腾讯im]
|
||||
im:
|
||||
im-app-id:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package config
|
||||
|
||||
type CaOnlineV2 struct {
|
||||
CaOnlineAppID string `mapstructure:"ca-online-app-id" json:"ca-online-app-id" yaml:"ca-online-app-id"`
|
||||
CaOnlineAppSecret string `mapstructure:"ca-online-app-secret" json:"ca-online-app-secret" yaml:"ca-online-app-secret"`
|
||||
CaOnlineAPIURL string `mapstructure:"ca-online-api-url" json:"ca-online-api-url" yaml:"ca-online-api-url"`
|
||||
}
|
||||
+15
-14
@@ -3,18 +3,19 @@ package config
|
||||
var C Config
|
||||
|
||||
type Config struct {
|
||||
Port int `mapstructure:"port" json:"port" yaml:"port"`
|
||||
Env string `mapstructure:"env" json:"Env" yaml:"Env"`
|
||||
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
|
||||
Log Log `mapstructure:"log" json:"log" yaml:"log"`
|
||||
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
|
||||
Jwt Jwt `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
|
||||
Oss Oss `mapstructure:"oss" json:"oss" yaml:"oss"`
|
||||
Snowflake int64 `mapstructure:"snowflake" json:"snowflake" yaml:"snowflake"`
|
||||
CaOnline CaOnline `mapstructure:"ca-online" json:"ca-online" yaml:"ca-online"`
|
||||
Im Im `mapstructure:"im" json:"im" yaml:"im"`
|
||||
Dysms Dysms `mapstructure:"dysms" json:"dysms" yaml:"dysms"`
|
||||
Wechat Wechat `mapstructure:"wechat" json:"wechat" yaml:"wechat"`
|
||||
Pre Pre `mapstructure:"pre" json:"pre" yaml:"pre"` // 处方平台
|
||||
Amqp Amqp `mapstructure:"amqp" json:"amqp" yaml:"amqp"`
|
||||
Port int `mapstructure:"port" json:"port" yaml:"port"`
|
||||
Env string `mapstructure:"env" json:"Env" yaml:"Env"`
|
||||
Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
|
||||
Log Log `mapstructure:"log" json:"log" yaml:"log"`
|
||||
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
|
||||
Jwt Jwt `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
|
||||
Oss Oss `mapstructure:"oss" json:"oss" yaml:"oss"`
|
||||
Snowflake int64 `mapstructure:"snowflake" json:"snowflake" yaml:"snowflake"`
|
||||
CaOnline CaOnline `mapstructure:"ca-online" json:"ca-online" yaml:"ca-online"`
|
||||
CaOnlineV2 CaOnlineV2 `mapstructure:"ca-online-v2" json:"ca-online-v2" yaml:"ca-online-v2"`
|
||||
Im Im `mapstructure:"im" json:"im" yaml:"im"`
|
||||
Dysms Dysms `mapstructure:"dysms" json:"dysms" yaml:"dysms"`
|
||||
Wechat Wechat `mapstructure:"wechat" json:"wechat" yaml:"wechat"`
|
||||
Pre Pre `mapstructure:"pre" json:"pre" yaml:"pre"` // 处方平台
|
||||
Amqp Amqp `mapstructure:"amqp" json:"amqp" yaml:"amqp"`
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ type Pre struct {
|
||||
PrePlatClientSecret string `mapstructure:"pre-plat-client-secret" json:"pre-plat-client-secret" yaml:"pre-plat-client-secret"`
|
||||
PrePlatAppUrl string `mapstructure:"pre-plat-app-url" json:"pre-plat-app-url" yaml:"pre-plat-app-url"`
|
||||
PrePlatPharmacyCode string `mapstructure:"pre-plat-pharmacy-code" json:"pre-plat-pharmacy-code" yaml:"pre-plat-pharmacy-code"`
|
||||
PrePlatTerminalCode string `mapstructure:"pre-plat-terminal-code" json:"pre-plat-terminal-code" yaml:"pre-plat-terminal-code"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package cav2
|
||||
|
||||
import "net/url"
|
||||
|
||||
func (c *Client) CheckCIdAndName(request CheckCIdAndNameRequest) error {
|
||||
form := url.Values{}
|
||||
setValue(form, "requestId", request.RequestID)
|
||||
setValue(form, "cName", request.CName)
|
||||
setValue(form, "cId", request.CID)
|
||||
return c.postForm("/scca-ocr-server/authapi/checkCIdAndName", form, nil)
|
||||
}
|
||||
|
||||
func (c *Client) FetchH5FaceURL(request FetchH5FaceURLRequest) (string, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "cName", request.CName)
|
||||
setValue(form, "cId", request.CID)
|
||||
setValue(form, "orderNo", request.OrderNo)
|
||||
setValue(form, "redirectUrl", request.RedirectURL)
|
||||
return c.postFormForString("/scca-ocr-server/authapi/fetchH5FaceUrl", form)
|
||||
}
|
||||
|
||||
func (c *Client) FetchH5FaceResult(request FetchH5FaceResultRequest) (*FetchH5FaceResultResponse, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "orderNo", request.OrderNo)
|
||||
|
||||
response := &FetchH5FaceResultResponse{}
|
||||
if err := c.postForm("/scca-ocr-server/authapi/fetchH5FaceResult", form, response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *Client) CheckEnterprise(request CheckEnterpriseRequest) error {
|
||||
form := url.Values{}
|
||||
setValue(form, "cName", request.CName)
|
||||
setValue(form, "cId", request.CID)
|
||||
setValue(form, "registrationNumber", request.RegistrationNumber)
|
||||
setValue(form, "enterpriseName", request.EnterpriseName)
|
||||
return c.postForm("/scca-ocr-server/authapi/checkEnterprise", form, nil)
|
||||
}
|
||||
|
||||
func (c *Client) CheckEnterprise3(request CheckEnterprise3Request) error {
|
||||
form := url.Values{}
|
||||
setValue(form, "cName", request.CName)
|
||||
setValue(form, "registrationNumber", request.RegistrationNumber)
|
||||
setValue(form, "enterpriseName", request.EnterpriseName)
|
||||
setValue(form, "requestId", request.RequestID)
|
||||
return c.postForm("/scca-ocr-server/authapi/checkDeptAndIndividualInfo3", form, nil)
|
||||
}
|
||||
|
||||
func (c *Client) PhoneVerification(request PhoneVerificationRequest) error {
|
||||
form := url.Values{}
|
||||
setValue(form, "realName", request.RealName)
|
||||
setValue(form, "idCard", request.IDCard)
|
||||
setValue(form, "phoneNumber", request.PhoneNumber)
|
||||
return c.postForm("/scca-ocr-server/authapi/phoneVerification", form, nil)
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cav2
|
||||
|
||||
import "net/url"
|
||||
|
||||
func (c *Client) GetServiceURL(request GetServiceURLRequest) (*GetServiceURLResponse, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "certType", request.CertType)
|
||||
setValue(form, "type", request.Type)
|
||||
setValue(form, "entityId", request.EntityID)
|
||||
setValue(form, "userName", request.UserName)
|
||||
setValue(form, "userIdCard", request.UserIDCard)
|
||||
setValue(form, "userPhone", request.UserPhone)
|
||||
setValue(form, "email", request.Email)
|
||||
setValue(form, "enterpriseName", request.EnterpriseName)
|
||||
setValue(form, "socialCreditCode", request.SocialCreditCode)
|
||||
setValue(form, "deptPerson", request.DeptPerson)
|
||||
setValue(form, "deptPersonCode", request.DeptPersonCode)
|
||||
setValue(form, "deptPersonPhone", request.DeptPersonPhone)
|
||||
setValue(form, "agentName", request.AgentName)
|
||||
setValue(form, "agentIdCard", request.AgentIDCard)
|
||||
setValue(form, "authMethod", request.AuthMethod)
|
||||
|
||||
response := &GetServiceURLResponse{}
|
||||
if err := c.postForm("/open/api/data/getServiceUrl", form, response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *Client) CertSign(request CertSignRequest) (*CertSignResponse, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "entityId", request.EntityID)
|
||||
setValue(form, "requestId", request.RequestID)
|
||||
setValue(form, "businessType", request.BusinessType)
|
||||
setValue(form, "toSign", request.ToSign)
|
||||
setValue(form, "notifyUrl", request.NotifyURL)
|
||||
setValue(form, "jumpUrl", request.JumpURL)
|
||||
setValue(form, "extParam", request.ExtParam)
|
||||
|
||||
response := &CertSignResponse{}
|
||||
if err := c.postForm("/open/api/data/certSign", form, response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetCertSignResult(request GetCertSignResultRequest) (*GetCertSignResultResponse, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "requestId", request.RequestID)
|
||||
|
||||
response := &GetCertSignResultResponse{}
|
||||
if err := c.postForm("/open/api/data/getCertSignResult", form, response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *Client) PasswordLessSignInfo(request PasswordLessSignInfoRequest) (*PasswordLessSignInfoResponse, error) {
|
||||
form := url.Values{}
|
||||
setValue(form, "entityId", request.EntityID)
|
||||
|
||||
response := &PasswordLessSignInfoResponse{}
|
||||
if err := c.postForm("/open/api/data/passwordLessSignInfo", form, response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package cav2
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/global"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
BaseURL string
|
||||
AppID string
|
||||
AppSecret string
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
func NewClient(baseURL, appID, appSecret string) *Client {
|
||||
return &Client{
|
||||
BaseURL: strings.TrimRight(baseURL, "/"),
|
||||
AppID: appID,
|
||||
AppSecret: appSecret,
|
||||
HTTPClient: &http.Client{
|
||||
Timeout: 15 * time.Second,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewClientFromConfig() *Client {
|
||||
baseURL := config.C.CaOnlineV2.CaOnlineAPIURL
|
||||
appID := config.C.CaOnlineV2.CaOnlineAppID
|
||||
appSecret := config.C.CaOnlineV2.CaOnlineAppSecret
|
||||
|
||||
if baseURL == "" {
|
||||
baseURL = config.C.CaOnline.CaOnlineApiUrl
|
||||
}
|
||||
if appID == "" {
|
||||
appID = config.C.CaOnline.CaOnlineAppId
|
||||
}
|
||||
if appSecret == "" {
|
||||
appSecret = config.C.CaOnline.CaOnlineAppSecret
|
||||
}
|
||||
|
||||
return NewClient(
|
||||
baseURL,
|
||||
appID,
|
||||
appSecret,
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Client) postForm(path string, form url.Values, out interface{}) error {
|
||||
if c == nil {
|
||||
return errors.New("ca v2 client is nil")
|
||||
}
|
||||
if c.BaseURL == "" || c.AppID == "" || c.AppSecret == "" {
|
||||
return errors.New("ca v2 client config is incomplete")
|
||||
}
|
||||
if c.HTTPClient == nil {
|
||||
c.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
||||
}
|
||||
|
||||
payload := strings.NewReader(form.Encode())
|
||||
req, err := http.NewRequest(http.MethodPost, c.BaseURL+path, payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header.Set("app_id", c.AppID)
|
||||
signature := c.signature(form)
|
||||
req.Header.Set("signature", signature)
|
||||
|
||||
c.logUpstreamRequest(path, form, signature)
|
||||
|
||||
resp, err := c.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
c.logUpstreamError(path, form, "request_error", err.Error())
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
c.logUpstreamError(path, form, "read_body_error", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
c.logUpstreamResponse(path, form, resp.StatusCode, string(respBody))
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("ca v2 request failed: http %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
var envelope responseEnvelope
|
||||
if err := json.Unmarshal(respBody, &envelope); err != nil {
|
||||
c.logUpstreamError(path, form, "unmarshal_error", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
if envelope.ResultCode != 0 {
|
||||
if envelope.ResultMsg != "" {
|
||||
c.logUpstreamError(path, form, "upstream_business_error", envelope.ResultMsg)
|
||||
return errors.New(envelope.ResultMsg)
|
||||
}
|
||||
return fmt.Errorf("ca v2 request failed with code %d", envelope.ResultCode)
|
||||
}
|
||||
|
||||
if out == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
body := strings.TrimSpace(string(envelope.Body))
|
||||
if body == "" || body == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return json.Unmarshal(envelope.Body, out)
|
||||
}
|
||||
|
||||
func (c *Client) postFormForString(path string, form url.Values) (string, error) {
|
||||
var raw json.RawMessage
|
||||
if err := c.postForm(path, form, &raw); err != nil {
|
||||
return "", err
|
||||
}
|
||||
body := strings.TrimSpace(string(raw))
|
||||
if body == "" || body == "null" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var text string
|
||||
if err := json.Unmarshal(raw, &text); err == nil {
|
||||
return text, nil
|
||||
}
|
||||
|
||||
var data map[string]string
|
||||
if err := json.Unmarshal(raw, &data); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, key := range []string{"url", "authUrl", "faceUrl", "h5Url"} {
|
||||
if value := strings.TrimSpace(data[key]); value != "" {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("ca v2 string body not found")
|
||||
}
|
||||
|
||||
func (c *Client) signature(form url.Values) string {
|
||||
keys := make([]string, 0, len(form))
|
||||
for key := range form {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
values := make([]string, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
for _, value := range form[key] {
|
||||
values = append(values, value)
|
||||
}
|
||||
}
|
||||
|
||||
h := hmac.New(sha1.New, []byte(c.AppSecret))
|
||||
h.Write([]byte(strings.Join(values, "&")))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func setValue(form url.Values, key, value string) {
|
||||
if strings.TrimSpace(value) == "" {
|
||||
return
|
||||
}
|
||||
form.Set(key, value)
|
||||
}
|
||||
|
||||
func (c *Client) logUpstreamRequest(path string, form url.Values, signature string) {
|
||||
if global.Logger == nil {
|
||||
return
|
||||
}
|
||||
|
||||
global.Logger.WithFields(logrus.Fields{
|
||||
"module": "ca_v2",
|
||||
"upstream_path": path,
|
||||
"request_form": form.Encode(),
|
||||
"request_params": form,
|
||||
"signature": signature,
|
||||
}).Info("ca v2 upstream request")
|
||||
}
|
||||
|
||||
func (c *Client) logUpstreamResponse(path string, form url.Values, statusCode int, body string) {
|
||||
if global.Logger == nil {
|
||||
return
|
||||
}
|
||||
|
||||
global.Logger.WithFields(logrus.Fields{
|
||||
"module": "ca_v2",
|
||||
"upstream_path": path,
|
||||
"upstream_status": statusCode,
|
||||
"request_form": form.Encode(),
|
||||
"response_body": body,
|
||||
}).Info("ca v2 upstream response")
|
||||
}
|
||||
|
||||
func (c *Client) logUpstreamError(path string, form url.Values, stage string, message string) {
|
||||
if global.Logger == nil {
|
||||
return
|
||||
}
|
||||
|
||||
global.Logger.WithFields(logrus.Fields{
|
||||
"module": "ca_v2",
|
||||
"stage": stage,
|
||||
"upstream_path": path,
|
||||
"request_form": form.Encode(),
|
||||
}).Error(message)
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package cav2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetServiceURL(t *testing.T) {
|
||||
var gotForm url.Values
|
||||
signClient := NewClient("http://unused", "test-app", "test-secret")
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/open/api/data/getServiceUrl" {
|
||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||
}
|
||||
if r.Method != http.MethodPost {
|
||||
t.Fatalf("unexpected method: %s", r.Method)
|
||||
}
|
||||
if err := r.ParseForm(); err != nil {
|
||||
t.Fatalf("parse form: %v", err)
|
||||
}
|
||||
gotForm = r.PostForm
|
||||
|
||||
expectedSignature := signClient.signature(r.PostForm)
|
||||
if r.Header.Get("app_id") != "test-app" {
|
||||
t.Fatalf("unexpected app_id: %s", r.Header.Get("app_id"))
|
||||
}
|
||||
if r.Header.Get("signature") != expectedSignature {
|
||||
t.Fatalf("unexpected signature: %s", r.Header.Get("signature"))
|
||||
}
|
||||
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"result_code": 0,
|
||||
"result_msg": "",
|
||||
"success": true,
|
||||
"body": map[string]string{
|
||||
"webToken": "token-1",
|
||||
"url": "https://example.test/h5",
|
||||
"expireTime": "2026-05-01 10:00:00",
|
||||
},
|
||||
})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(server.URL, "test-app", "test-secret")
|
||||
response, err := client.GetServiceURL(GetServiceURLRequest{
|
||||
CertType: "Personal",
|
||||
Type: "CERT_APPLY",
|
||||
EntityID: "user-1",
|
||||
UserName: "Alice",
|
||||
UserIDCard: "123456",
|
||||
UserPhone: "13800000000",
|
||||
AuthMethod: "face",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("GetServiceURL error: %v", err)
|
||||
}
|
||||
|
||||
if gotForm.Get("entityId") != "user-1" {
|
||||
t.Fatalf("unexpected entityId: %s", gotForm.Get("entityId"))
|
||||
}
|
||||
if response.WebToken != "token-1" || response.URL != "https://example.test/h5" {
|
||||
t.Fatalf("unexpected response: %+v", response)
|
||||
}
|
||||
if string(response.ExpireTime) != "2026-05-01 10:00:00" {
|
||||
t.Fatalf("unexpected expireTime: %s", response.ExpireTime)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetServiceURLWithNumericExpireTime(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"result_code": 0,
|
||||
"result_msg": "",
|
||||
"success": true,
|
||||
"body": map[string]interface{}{
|
||||
"webToken": "token-2",
|
||||
"url": "https://example.test/h5-2",
|
||||
"expireTime": 1745918720,
|
||||
},
|
||||
})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(server.URL, "test-app", "test-secret")
|
||||
response, err := client.GetServiceURL(GetServiceURLRequest{
|
||||
CertType: "Personal",
|
||||
Type: "CERT_APPLY",
|
||||
EntityID: "user-2",
|
||||
UserName: "Bob",
|
||||
UserIDCard: "654321",
|
||||
UserPhone: "13900000000",
|
||||
AuthMethod: "face",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("GetServiceURL error: %v", err)
|
||||
}
|
||||
|
||||
if string(response.ExpireTime) != "1745918720" {
|
||||
t.Fatalf("unexpected expireTime: %s", response.ExpireTime)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetchH5FaceURLWithStringBody(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"result_code": 0,
|
||||
"result_msg": "",
|
||||
"success": true,
|
||||
"body": "https://example.test/face-h5",
|
||||
})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(server.URL, "test-app", "test-secret")
|
||||
link, err := client.FetchH5FaceURL(FetchH5FaceURLRequest{
|
||||
CName: "Alice",
|
||||
CID: "123456",
|
||||
OrderNo: "order-1",
|
||||
RedirectURL: "https://callback.test/result",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("FetchH5FaceURL error: %v", err)
|
||||
}
|
||||
if link != "https://example.test/face-h5" {
|
||||
t.Fatalf("unexpected link: %s", link)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckEnterpriseSuccessWithoutBody(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"result_code": 0,
|
||||
"result_msg": "",
|
||||
"success": true,
|
||||
"body": nil,
|
||||
})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient(server.URL, "test-app", "test-secret")
|
||||
err := client.CheckEnterprise(CheckEnterpriseRequest{
|
||||
CName: "法人A",
|
||||
CID: "510000000000000000",
|
||||
RegistrationNumber: "91510000TEST",
|
||||
EnterpriseName: "测试企业",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CheckEnterprise error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package cav2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type responseEnvelope struct {
|
||||
ResultCode int `json:"result_code"`
|
||||
ResultMsg string `json:"result_msg"`
|
||||
Success bool `json:"success"`
|
||||
Body json.RawMessage `json:"body"`
|
||||
}
|
||||
|
||||
type GetServiceURLRequest struct {
|
||||
CertType string `json:"certType"`
|
||||
Type string `json:"type"`
|
||||
EntityID string `json:"entityId"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
UserIDCard string `json:"userIdCard,omitempty"`
|
||||
UserPhone string `json:"userPhone,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
EnterpriseName string `json:"enterpriseName,omitempty"`
|
||||
SocialCreditCode string `json:"socialCreditCode,omitempty"`
|
||||
DeptPerson string `json:"deptPerson,omitempty"`
|
||||
DeptPersonCode string `json:"deptPersonCode,omitempty"`
|
||||
DeptPersonPhone string `json:"deptPersonPhone,omitempty"`
|
||||
AgentName string `json:"agentName,omitempty"`
|
||||
AgentIDCard string `json:"agentIdCard,omitempty"`
|
||||
AuthMethod string `json:"authMethod,omitempty"`
|
||||
}
|
||||
|
||||
type GetServiceURLResponse struct {
|
||||
WebToken string `json:"webToken"`
|
||||
URL string `json:"url"`
|
||||
ExpireTime flexibleString `json:"expireTime"`
|
||||
}
|
||||
|
||||
type CertSignRequest struct {
|
||||
EntityID string `json:"entityId"`
|
||||
RequestID string `json:"requestId"`
|
||||
BusinessType string `json:"businessType"`
|
||||
ToSign string `json:"toSign"`
|
||||
NotifyURL string `json:"notifyUrl,omitempty"`
|
||||
JumpURL string `json:"jumpUrl,omitempty"`
|
||||
ExtParam string `json:"extParam,omitempty"`
|
||||
}
|
||||
|
||||
type CertSignResponse struct {
|
||||
RequestID string `json:"requestId"`
|
||||
BusinessType string `json:"businessType"`
|
||||
SignType string `json:"signType"`
|
||||
SignP7 string `json:"signP7"`
|
||||
ToSignEncoding string `json:"toSignEncoding"`
|
||||
SignURL string `json:"signUrl"`
|
||||
}
|
||||
|
||||
type GetCertSignResultRequest struct {
|
||||
RequestID string `json:"requestId"`
|
||||
}
|
||||
|
||||
type GetCertSignResultResponse struct {
|
||||
RequestID string `json:"requestId"`
|
||||
BusinessType string `json:"businessType"`
|
||||
SignType string `json:"signType"`
|
||||
SignP7 string `json:"signP7"`
|
||||
ToSignEncoding string `json:"toSignEncoding"`
|
||||
}
|
||||
|
||||
type PasswordLessSignInfoRequest struct {
|
||||
EntityID string `json:"entityId"`
|
||||
}
|
||||
|
||||
type PasswordLessSignInfoResponse struct {
|
||||
CertDN string `json:"certDn"`
|
||||
NotAfter string `json:"notafter"`
|
||||
CertSN string `json:"certSn"`
|
||||
EnableTime string `json:"enableTime"`
|
||||
DisableTime string `json:"disableTime"`
|
||||
DataStatus int `json:"dataStatus"`
|
||||
}
|
||||
|
||||
type CheckCIdAndNameRequest struct {
|
||||
RequestID string `json:"requestId"`
|
||||
CName string `json:"cName"`
|
||||
CID string `json:"cId"`
|
||||
}
|
||||
|
||||
type FetchH5FaceURLRequest struct {
|
||||
CName string `json:"cName"`
|
||||
CID string `json:"cId"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
RedirectURL string `json:"redirectUrl"`
|
||||
}
|
||||
|
||||
type FetchH5FaceResultRequest struct {
|
||||
OrderNo string `json:"orderNo"`
|
||||
}
|
||||
|
||||
type FetchH5FaceResultResponse struct {
|
||||
Code string `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
LiveRate string `json:"liveRate"`
|
||||
Similarity string `json:"similarity"`
|
||||
OccurredTime string `json:"occurredTime"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
IDNo string `json:"idNo"`
|
||||
Name string `json:"name"`
|
||||
IDType string `json:"idType"`
|
||||
Photo string `json:"photo"`
|
||||
Video string `json:"video"`
|
||||
}
|
||||
|
||||
type CheckEnterpriseRequest struct {
|
||||
CName string `json:"cName"`
|
||||
CID string `json:"cId"`
|
||||
RegistrationNumber string `json:"registrationNumber"`
|
||||
EnterpriseName string `json:"enterpriseName"`
|
||||
}
|
||||
|
||||
type CheckEnterprise3Request struct {
|
||||
CName string `json:"cName"`
|
||||
RegistrationNumber string `json:"registrationNumber"`
|
||||
EnterpriseName string `json:"enterpriseName"`
|
||||
RequestID string `json:"requestId,omitempty"`
|
||||
}
|
||||
|
||||
type PhoneVerificationRequest struct {
|
||||
RealName string `json:"realName"`
|
||||
IDCard string `json:"idCard"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
}
|
||||
|
||||
type flexibleString string
|
||||
|
||||
func (s *flexibleString) UnmarshalJSON(data []byte) error {
|
||||
raw := strings.TrimSpace(string(data))
|
||||
if raw == "" || raw == "null" {
|
||||
*s = ""
|
||||
return nil
|
||||
}
|
||||
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err == nil {
|
||||
*s = flexibleString(str)
|
||||
return nil
|
||||
}
|
||||
|
||||
var number json.Number
|
||||
if err := json.Unmarshal(data, &number); err == nil {
|
||||
*s = flexibleString(number.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
var integer int64
|
||||
if err := json.Unmarshal(data, &integer); err == nil {
|
||||
*s = flexibleString(strconv.FormatInt(integer, 10))
|
||||
return nil
|
||||
}
|
||||
|
||||
var floatValue float64
|
||||
if err := json.Unmarshal(data, &floatValue); err == nil {
|
||||
*s = flexibleString(strconv.FormatFloat(floatValue, 'f', -1, 64))
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -127,6 +127,35 @@ type reportPreResponse struct {
|
||||
ResultDesc string `json:"resultDesc"` // 描述
|
||||
}
|
||||
|
||||
// UnmarshalJSON 自定义反序列化,处理 resultCode 可能是数字或字符串的情况
|
||||
func (r *reportPreResponse) UnmarshalJSON(data []byte) error {
|
||||
// 使用临时结构体来处理可能的不同类型
|
||||
var temp struct {
|
||||
ResultCode interface{} `json:"resultCode"`
|
||||
ResultDesc string `json:"resultDesc"`
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &temp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 处理 ResultCode,可能是数字或字符串
|
||||
switch v := temp.ResultCode.(type) {
|
||||
case float64:
|
||||
// 如果是数字,转换为字符串
|
||||
r.ResultCode = fmt.Sprintf("%.0f", v)
|
||||
case int:
|
||||
r.ResultCode = fmt.Sprintf("%d", v)
|
||||
case string:
|
||||
r.ResultCode = v
|
||||
default:
|
||||
r.ResultCode = fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
r.ResultDesc = temp.ResultDesc
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取商品库存返回数据
|
||||
type getProdStockResponse struct {
|
||||
ResultCode string `json:"resultCode"` // 操作编码
|
||||
@@ -289,20 +318,25 @@ func NoticePreOrderCancel(orderNo string) (bool, error) {
|
||||
func (r ReportPreRequest) ReportPre() (bool, error) {
|
||||
jsonData, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-序列化请求参数失败", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
utils.LogJsonInfo("上报处方平台:", jsonData)
|
||||
|
||||
// 准备请求体
|
||||
requestBody := bytes.NewBuffer(jsonData)
|
||||
|
||||
// 设置请求 URL
|
||||
url := config.C.Pre.PrePlatAppUrl + "v1/preOrder/receivePreOrder"
|
||||
|
||||
// 打印请求信息
|
||||
utils.LogJsonInfo("上报处方平台-请求URL", url)
|
||||
utils.LogJsonInfo("上报处方平台-请求参数", r)
|
||||
utils.LogJsonInfo("上报处方平台-请求体", requestBody.String())
|
||||
|
||||
// 创建 POST 请求
|
||||
req, err := http.NewRequest("POST", url, requestBody)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-创建请求失败", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -311,8 +345,10 @@ func (r ReportPreRequest) ReportPre() (bool, error) {
|
||||
|
||||
token, _ := global.Redis.Get(context.Background(), "prescription_token").Result()
|
||||
if token == "" {
|
||||
utils.LogJsonInfo("上报处方平台-缓存中无token,重新获取", nil)
|
||||
token, err = GetToken()
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-获取token失败", err)
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
@@ -323,6 +359,7 @@ func (r ReportPreRequest) ReportPre() (bool, error) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-发送请求失败", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -330,44 +367,73 @@ func (r ReportPreRequest) ReportPre() (bool, error) {
|
||||
_ = Body.Close()
|
||||
}(resp.Body)
|
||||
|
||||
// 检查响应状态码
|
||||
if resp.StatusCode != 200 {
|
||||
return false, errors.New("返回数据错误")
|
||||
}
|
||||
|
||||
var response reportPreResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||
// 读取响应体原始内容(用于日志)
|
||||
responseBodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-读取响应体失败", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 打印响应状态码和原始响应内容
|
||||
utils.LogJsonInfo("上报处方平台-响应状态码", fmt.Sprintf("statusCode: %d", resp.StatusCode))
|
||||
utils.LogJsonInfo("上报处方平台-响应体原始内容", string(responseBodyBytes))
|
||||
|
||||
// 检查响应状态码
|
||||
if resp.StatusCode != 200 {
|
||||
utils.LogJsonErr("上报处方平台-响应状态码错误", fmt.Sprintf("statusCode: %d, responseBody: %s", resp.StatusCode, string(responseBodyBytes)))
|
||||
return false, errors.New("返回数据错误")
|
||||
}
|
||||
|
||||
// 解析响应数据
|
||||
var response reportPreResponse
|
||||
err = json.Unmarshal(responseBodyBytes, &response)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("上报处方平台-解析响应数据失败", fmt.Sprintf("error: %v, responseBody: %s", err, string(responseBodyBytes)))
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 打印解析后的响应数据
|
||||
utils.LogJsonInfo("上报处方平台-解析后的响应数据", response)
|
||||
|
||||
if response.ResultCode != "1000" {
|
||||
utils.LogJsonErr("上报处方平台-业务处理失败", response)
|
||||
if response.ResultDesc != "" {
|
||||
return false, errors.New(response.ResultDesc)
|
||||
}
|
||||
return false, errors.New("上报处方平台失败")
|
||||
}
|
||||
|
||||
utils.LogJsonInfo("上报处方平台-成功", response)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetProdStock 获取商品库存
|
||||
func (r GetProdStockRequest) GetProdStock() (*GetProdStockDataResponse, error) {
|
||||
r.PharmacyCode = config.C.Pre.PrePlatPharmacyCode
|
||||
if r.PharmacyCode == "" {
|
||||
r.PharmacyCode = config.C.Pre.PrePlatPharmacyCode
|
||||
}
|
||||
jsonData, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("获取商品库存-序列化请求参数失败", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
utils.LogJsonInfo("获取商品库存-请求参数:", r)
|
||||
|
||||
// 准备请求体
|
||||
requestBody := bytes.NewBuffer(jsonData)
|
||||
|
||||
// 设置请求 URL
|
||||
url := config.C.Pre.PrePlatAppUrl + "v1/pharmacy/pharmacyInventory"
|
||||
|
||||
// 打印请求信息
|
||||
utils.LogJsonInfo("获取商品库存-请求URL:", url)
|
||||
utils.LogJsonInfo("获取商品库存-请求体:", requestBody.String())
|
||||
|
||||
// 创建 POST 请求
|
||||
req, err := http.NewRequest("POST", url, requestBody)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("获取商品库存-创建请求失败", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -378,6 +444,7 @@ func (r GetProdStockRequest) GetProdStock() (*GetProdStockDataResponse, error) {
|
||||
if token == "" {
|
||||
token, err = GetToken()
|
||||
if err != nil {
|
||||
utils.LogJsonErr("获取商品库存-获取token失败", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -388,6 +455,7 @@ func (r GetProdStockRequest) GetProdStock() (*GetProdStockDataResponse, error) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("获取商品库存-发送请求失败", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -397,21 +465,28 @@ func (r GetProdStockRequest) GetProdStock() (*GetProdStockDataResponse, error) {
|
||||
|
||||
// 检查响应状态码
|
||||
if resp.StatusCode != 200 {
|
||||
utils.LogJsonErr("获取商品库存-响应状态码错误", fmt.Sprintf("statusCode: %d", resp.StatusCode))
|
||||
return nil, errors.New("返回数据错误")
|
||||
}
|
||||
|
||||
var response getProdStockResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||
if err != nil {
|
||||
utils.LogJsonErr("获取商品库存-解析响应数据失败", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if response.ResultCode != "1000" {
|
||||
utils.LogJsonErr("获取商品库存-业务处理失败", response)
|
||||
if response.ResultDesc != "" {
|
||||
return nil, errors.New(response.ResultDesc)
|
||||
}
|
||||
return nil, errors.New("获取商品库存失败")
|
||||
}
|
||||
|
||||
utils.LogJsonInfo("获取商品库存-成功", response.Data)
|
||||
if len(response.Data) == 0 {
|
||||
return &GetProdStockDataResponse{Quantity: "0"}, nil
|
||||
}
|
||||
return &response.Data[0], nil
|
||||
}
|
||||
|
||||
@@ -35,9 +35,15 @@ func (r RefundRequest) Refund(orderType int) (*refunddomestic.Refund, error) {
|
||||
|
||||
} else if orderType == 2 || orderType == 3 {
|
||||
// 药品/检测
|
||||
mchId = config.C.Wechat.Pay1636644248.MchId
|
||||
mchCertificateSerialNumber = config.C.Wechat.Pay1636644248.MchCertificateSerialNumber
|
||||
v3ApiSecret = config.C.Wechat.Pay1636644248.V3ApiSecret
|
||||
|
||||
// mchId = config.C.Wechat.Pay1636644248.MchId
|
||||
// mchCertificateSerialNumber = config.C.Wechat.Pay1636644248.MchCertificateSerialNumber
|
||||
// v3ApiSecret = config.C.Wechat.Pay1636644248.V3ApiSecret
|
||||
|
||||
// 之前为北京欣欣账户,现改为成都欣欣账户
|
||||
mchId = config.C.Wechat.Pay1659662936.MchId
|
||||
mchCertificateSerialNumber = config.C.Wechat.Pay1659662936.MchCertificateSerialNumber
|
||||
v3ApiSecret = config.C.Wechat.Pay1659662936.V3ApiSecret
|
||||
} else if orderType == 4 {
|
||||
// 服务包
|
||||
mchId = config.C.Wechat.Pay1659662936.MchId
|
||||
|
||||
+43
-15
@@ -199,9 +199,11 @@ func fillDataWithMerge(f *excelize.File, sheetName string, header []HeaderCellDa
|
||||
}
|
||||
|
||||
// 设置单元格样式
|
||||
err = setCellStyle(f, sheetName, axis, header[i], alignment)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
if colOffset < len(header) {
|
||||
err = setCellStyle(f, sheetName, axis, header[colOffset], alignment)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
// 设置行高 35-第一行
|
||||
@@ -214,23 +216,33 @@ func fillDataWithMerge(f *excelize.File, sheetName string, header []HeaderCellDa
|
||||
mergeNum = mergeNum + 1
|
||||
mergeNumSlice = append(mergeNumSlice, colName)
|
||||
} else {
|
||||
var sliceFieldNum int // 切片字段数量
|
||||
|
||||
// 最大切片数量,此数量为其余需合并的数量
|
||||
if filedNumSlice < field.Len() {
|
||||
filedNumSlice = field.Len()
|
||||
}
|
||||
|
||||
elemType := field.Type().Elem()
|
||||
if elemType.Kind() == reflect.Ptr {
|
||||
elemType = elemType.Elem()
|
||||
}
|
||||
numSliceFields := 0
|
||||
if elemType.Kind() == reflect.Struct {
|
||||
numSliceFields = elemType.NumField()
|
||||
}
|
||||
|
||||
for j := 0; j < field.Len(); j++ {
|
||||
item := field.Index(j).Interface()
|
||||
v1 := reflect.ValueOf(item)
|
||||
if v1.Kind() == reflect.Ptr {
|
||||
v1 = v1.Elem()
|
||||
}
|
||||
|
||||
for i2 := 0; i2 < field.Index(j).NumField(); i2++ {
|
||||
for i2 := 0; i2 < v1.NumField(); i2++ {
|
||||
// 获取字段值
|
||||
cellValue := v1.Field(i2).Interface()
|
||||
|
||||
// 获取列名
|
||||
colName, err := excelize.ColumnNumberToName(i + i2 + 1)
|
||||
colName, err := excelize.ColumnNumberToName(colOffset + i2 + 1)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -245,9 +257,11 @@ func fillDataWithMerge(f *excelize.File, sheetName string, header []HeaderCellDa
|
||||
}
|
||||
|
||||
// 设置单元格样式
|
||||
err = setCellStyle(f, sheetName, axis, header[i+i2], alignment)
|
||||
if err != nil {
|
||||
return row, err
|
||||
if colOffset+i2 < len(header) {
|
||||
err = setCellStyle(f, sheetName, axis, header[colOffset+i2], alignment)
|
||||
if err != nil {
|
||||
return row, err
|
||||
}
|
||||
}
|
||||
|
||||
// 设置行高 35-第一行
|
||||
@@ -255,14 +269,28 @@ func fillDataWithMerge(f *excelize.File, sheetName string, header []HeaderCellDa
|
||||
if err != nil {
|
||||
return row, err
|
||||
}
|
||||
|
||||
sliceFieldNum = i2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 列偏移量需增加上切片字段数量
|
||||
colOffset = colOffset + sliceFieldNum
|
||||
if field.Len() == 0 {
|
||||
for i2 := 0; i2 < numSliceFields; i2++ {
|
||||
colName, err := excelize.ColumnNumberToName(colOffset + i2 + 1)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
axis = colName + fmt.Sprintf("%d", row+1)
|
||||
if colOffset+i2 < len(header) {
|
||||
_ = setCellStyle(f, sheetName, axis, header[colOffset+i2], alignment)
|
||||
}
|
||||
_ = f.SetRowHeight(sheetName, row+1, 35)
|
||||
}
|
||||
}
|
||||
|
||||
// 列偏移量需增加上切片字段数量(减1是因为循环末尾有colOffset++)
|
||||
if numSliceFields > 0 {
|
||||
colOffset = colOffset + numSliceFields - 1
|
||||
}
|
||||
}
|
||||
|
||||
colOffset++
|
||||
@@ -325,7 +353,7 @@ func setCellStyle(f *excelize.File, sheetName, axis string, header HeaderCellDat
|
||||
}
|
||||
}
|
||||
|
||||
if header.CellType == "float" {
|
||||
if header.CellType == "float" || header.CellType == "float64" {
|
||||
style.NumFmt = 2
|
||||
customNumFmt := "0.000"
|
||||
style.CustomNumFmt = &customNumFmt
|
||||
|
||||
Reference in New Issue
Block a user