Kaynağa Gözat

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

csx 3 yıl önce
ebeveyn
işleme
de300830aa

+ 4 - 0
controllers/manager_center_api_controller.go Dosyayı Görüntüle

@@ -147,6 +147,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
147 147
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
148 148
 	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
149 149
 	prescribing_number_unit := c.GetString("prescribing_number_unit")
150
+	is_user, _ := c.GetInt64("is_user")
150 151
 	adminInfo := c.GetAdminUserInfo()
151 152
 	drugLib := &models.BaseDrugLib{
152 153
 		DrugName:                    drug_name,
@@ -211,6 +212,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
211 212
 		HospApprFlag:                hosp_appr_flag,
212 213
 		LmtUsedFlag:                 lmt_used_flag,
213 214
 		PrescribingNumberUnit:       prescribing_number_unit,
215
+		IsUse:                       is_user,
214 216
 	}
215 217
 
216 218
 	total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
@@ -308,6 +310,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
308 310
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
309 311
 	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
310 312
 	prescribing_number_unit := c.GetString("prescribing_number_unit")
313
+	is_user, _ := c.GetInt64("is_user")
311 314
 	adminInfo := c.GetAdminUserInfo()
312 315
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
313 316
 	drugLib := &models.BaseDrugLib{
@@ -376,6 +379,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
376 379
 		Total:                       total,
377 380
 		SingleDose:                  drug_dose,
378 381
 		ProvincesCode:               provinces_code,
382
+		IsUse:                       is_user,
379 383
 	}
380 384
 
381 385
 	err := service.UpdateBaseDrugLib(drugLib)

+ 24 - 11
controllers/mobile_api_controllers/patient_api_controller.go Dosyayı Görüntüle

@@ -741,8 +741,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
741 741
 								return
742 742
 							}
743 743
 							if prescribing_number_total <= total {
744
-								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
745
-
744
+								if medical.IsUse == 2 {
745
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
746
+								}
746 747
 							}
747 748
 
748 749
 						}
@@ -815,13 +816,24 @@ func (c *PatientApiController) ExecDoctorAdvice() {
815 816
 							}
816 817
 
817 818
 							if prescribing_number_total <= total {
818
-								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
819
-								c.ServeSuccessJSON(map[string]interface{}{
820
-									"msg":    "1",
821
-									"advice": advice,
822
-									"ids":    ids,
823
-								})
824
-								return
819
+								if medical.IsUse == 2 {
820
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
821
+									c.ServeSuccessJSON(map[string]interface{}{
822
+										"msg":    "1",
823
+										"advice": advice,
824
+										"ids":    ids,
825
+									})
826
+									return
827
+								}
828
+								if medical.IsUse == 1 {
829
+									c.ServeSuccessJSON(map[string]interface{}{
830
+										"msg":    "1",
831
+										"advice": advice,
832
+										"ids":    ids,
833
+									})
834
+									return
835
+								}
836
+
825 837
 							}
826 838
 						}
827 839
 					}
@@ -1085,9 +1097,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1085 1097
 						return
1086 1098
 					}
1087 1099
 					if prescribing_number_total <= total {
1088
-						service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1100
+						if medical.IsUse == 2 {
1101
+							service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1102
+						}
1089 1103
 					}
1090
-
1091 1104
 				}
1092 1105
 			}
1093 1106
 			for _, item := range advices {

+ 35 - 14
controllers/patient_api_controller.go Dosyayı Görüntüle

@@ -1759,13 +1759,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1759 1759
 					return
1760 1760
 				}
1761 1761
 				if prescribing_number_total <= total {
1762
-					service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1763
-					break
1764
-					c.ServeSuccessJSON(map[string]interface{}{
1765
-						"msg":    "1",
1766
-						"advice": advice,
1767
-					})
1768
-					return
1762
+					if medical.IsUse == 2 {
1763
+						service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1764
+						break
1765
+						c.ServeSuccessJSON(map[string]interface{}{
1766
+							"msg":    "1",
1767
+							"advice": advice,
1768
+						})
1769
+						return
1770
+					}
1771
+					if medical.IsUse == 1 {
1772
+						c.ServeSuccessJSON(map[string]interface{}{
1773
+							"msg":    "1",
1774
+							"advice": advice,
1775
+						})
1776
+						return
1777
+					}
1778
+
1769 1779
 				}
1770 1780
 
1771 1781
 			}
@@ -2010,13 +2020,24 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2010 2020
 					return
2011 2021
 				}
2012 2022
 				if prescribing_number_total <= total {
2013
-					service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2014
-					break
2015
-					c.ServeSuccessJSON(map[string]interface{}{
2016
-						"msg":    "1",
2017
-						"advice": advice,
2018
-					})
2019
-					return
2023
+					if medical.IsUse == 2 {
2024
+						service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2025
+						break
2026
+						c.ServeSuccessJSON(map[string]interface{}{
2027
+							"msg":    "1",
2028
+							"advice": advice,
2029
+						})
2030
+						return
2031
+					}
2032
+
2033
+					if medical.IsUse == 1 {
2034
+						c.ServeSuccessJSON(map[string]interface{}{
2035
+							"msg":    "1",
2036
+							"advice": advice,
2037
+						})
2038
+						return
2039
+					}
2040
+
2020 2041
 				}
2021 2042
 
2022 2043
 			}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1002 - 93
controllers/supply_order_api_contorller.go


+ 1 - 0
models/drug.go Dosyayı Görüntüle

@@ -71,6 +71,7 @@ type BaseDrugLib struct {
71 71
 	Total                 float64                `gorm:"column:total" json:"total" form:"total"`
72 72
 	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
73 73
 	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
74
+	IsUse                 int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
74 75
 }
75 76
 
76 77
 func (BaseDrugLib) TableName() string {

+ 16 - 13
models/drug_stock.go Dosyayı Görüntüle

@@ -1,19 +1,20 @@
1 1
 package models
2 2
 
3 3
 type DrugWarehouse struct {
4
-	ID               int64  `gorm:"column:id" json:"id" form:"id"`
5
-	WarehousingOrder string `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
6
-	OperationTime    int64  `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
7
-	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
8
-	Creater          int64  `gorm:"column:creater" json:"creater" form:"creater"`
9
-	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
-	Modifier         int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
11
-	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
12
-	Status           int64  `gorm:"column:status" json:"status" form:"status"`
13
-	WarehousingTime  int64  `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
14
-	Dealer           int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
15
-	Manufacturer     int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
16
-	Type             int64  `gorm:"column:type" json:"type" form:"type"`
4
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
5
+	WarehousingOrder  string `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
6
+	OperationTime     int64  `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
7
+	OrgId             int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
8
+	Creater           int64  `gorm:"column:creater" json:"creater" form:"creater"`
9
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
+	Modifier          int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
11
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
12
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
13
+	WarehousingTime   int64  `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
14
+	Dealer            int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
15
+	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
16
+	Type              int64  `gorm:"column:type" json:"type" form:"type"`
17
+	SupplyWarehouseId int64  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
17 18
 }
18 19
 
19 20
 func (DrugWarehouse) TableName() string {
@@ -78,6 +79,7 @@ type DrugWarehouseInfo struct {
78 79
 	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
79 80
 	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
80 81
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
82
+	SupplyWarehouseId int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
81 83
 }
82 84
 
83 85
 func (DrugWarehouseInfo) TableName() string {
@@ -380,6 +382,7 @@ type DrugFlow struct {
380 382
 	DrugWarehouseInfo       []*DrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
381 383
 	BaseDrugLib             BaseDrugLib          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
382 384
 	AdviceId                int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
385
+	SupplyWarehouseId       int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
383 386
 }
384 387
 
385 388
 func (DrugFlow) TableName() string {

+ 1 - 0
models/self_drug_models.go Dosyayı Görüntüle

@@ -74,6 +74,7 @@ type XtBaseDrug struct {
74 74
 	DoseUnit              string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
75 75
 	DrugDay               string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
76 76
 	MinPrice              float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
77
+	IsUse                 int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
77 78
 }
78 79
 
79 80
 func (XtBaseDrug) TableName() string {

+ 45 - 42
models/stock_models.go Dosyayı Görüntüle

@@ -49,21 +49,22 @@ func (Dealer) TableName() string {
49 49
 }
50 50
 
51 51
 type Warehousing struct {
52
-	ID               int64        `gorm:"column:id" json:"id"`
53
-	WarehousingOrder string       `gorm:"column:warehousing_order" json:"warehousing_order"`
54
-	OperationTime    int64        `gorm:"column:operation_time" json:"operation_time"`
55
-	OrgId            int64        `gorm:"column:org_id" json:"org_id"`
56
-	Creater          int64        `gorm:"column:creater" json:"creater"`
57
-	Ctime            int64        `gorm:"column:ctime" json:"ctime"`
58
-	Modifier         int64        `gorm:"column:modifier" json:"modifier"`
59
-	Mtime            int64        `gorm:"column:mtime" json:"mtime"`
60
-	Status           int64        `gorm:"column:status" json:"status"`
61
-	WarehousingTime  int64        `gorm:"column:warehousing_time" json:"warehousing_time"`
62
-	Dealer           int64        `gorm:"column:dealer" json:"dealer"`
63
-	Manufacturer     int64        `gorm:"column:manufacturer" json:"manufacturer"`
64
-	Manufacturers    Manufacturer `gorm:"ForeignKey:ID;AssociationForeignKey:Manufacturer" json:"Manufacturer"`
65
-	Dealers          Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
66
-	Type             int64        `gorm:"column:type" json:"type"`
52
+	ID                int64        `gorm:"column:id" json:"id"`
53
+	WarehousingOrder  string       `gorm:"column:warehousing_order" json:"warehousing_order"`
54
+	OperationTime     int64        `gorm:"column:operation_time" json:"operation_time"`
55
+	OrgId             int64        `gorm:"column:org_id" json:"org_id"`
56
+	Creater           int64        `gorm:"column:creater" json:"creater"`
57
+	Ctime             int64        `gorm:"column:ctime" json:"ctime"`
58
+	Modifier          int64        `gorm:"column:modifier" json:"modifier"`
59
+	Mtime             int64        `gorm:"column:mtime" json:"mtime"`
60
+	Status            int64        `gorm:"column:status" json:"status"`
61
+	WarehousingTime   int64        `gorm:"column:warehousing_time" json:"warehousing_time"`
62
+	Dealer            int64        `gorm:"column:dealer" json:"dealer"`
63
+	Manufacturer      int64        `gorm:"column:manufacturer" json:"manufacturer"`
64
+	Manufacturers     Manufacturer `gorm:"ForeignKey:ID;AssociationForeignKey:Manufacturer" json:"Manufacturer"`
65
+	Dealers           Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
66
+	Type              int64        `gorm:"column:type" json:"type"`
67
+	SupplyWarehouseId int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
67 68
 }
68 69
 
69 70
 func (Warehousing) TableName() string {
@@ -105,33 +106,34 @@ func (StWarehousingInfo) TableName() string {
105 106
 }
106 107
 
107 108
 type WarehousingInfo struct {
108
-	ID               int64       `gorm:"column:id" json:"id"`
109
-	WarehousingId    int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
110
-	GoodId           int64       `gorm:"column:good_id" json:"good_id"`
111
-	GoodTypeId       int64       `gorm:"column:good_type_id" json:"good_type_id"`
112
-	Number           string      `gorm:"column:number" json:"number"`
113
-	ProductDate      int64       `gorm:"column:product_date" json:"product_date"`
114
-	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date"`
115
-	WarehousingCount int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
116
-	WarehousingUnit  string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
117
-	Price            float64     `gorm:"column:price" json:"price"`
118
-	TotalPrice       float64     `gorm:"column:total_price" json:"total_price"`
119
-	Dealer           int64       `gorm:"column:dealer" json:"dealer"`
120
-	Manufacturer     int64       `gorm:"column:manufacturer" json:"manufacturer"`
121
-	Remark           string      `gorm:"column:remark" json:"remark"`
122
-	Ctime            int64       `gorm:"column:ctime" json:"ctime"`
123
-	Mtime            int64       `gorm:"column:mtime" json:"mtime"`
124
-	Status           int64       `gorm:"column:status" json:"status"`
125
-	OrgId            int64       `gorm:"column:org_id" json:"org_id"`
126
-	IsReturn         int64       `gorm:"column:is_return" json:"is_return"`
127
-	StockCount       int64       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
128
-	Warehousing      Warehousing `ForeignKey:WarehousingId json:"warehouse"`
129
-	WarehousingOrder string      `gorm:"column:warehousing_order" json:"warehousing_order"`
130
-	GoodInfo         GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
131
-	Type             int64       `gorm:"column:type" json:"type"`
132
-	LicenseNumber    string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
133
-	WarehouseInfoId  int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
134
-	PackingPrice     float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
109
+	ID                int64       `gorm:"column:id" json:"id"`
110
+	WarehousingId     int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
111
+	GoodId            int64       `gorm:"column:good_id" json:"good_id"`
112
+	GoodTypeId        int64       `gorm:"column:good_type_id" json:"good_type_id"`
113
+	Number            string      `gorm:"column:number" json:"number"`
114
+	ProductDate       int64       `gorm:"column:product_date" json:"product_date"`
115
+	ExpiryDate        int64       `gorm:"column:expiry_date" json:"expiry_date"`
116
+	WarehousingCount  int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
117
+	WarehousingUnit   string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
118
+	Price             float64     `gorm:"column:price" json:"price"`
119
+	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
120
+	Dealer            int64       `gorm:"column:dealer" json:"dealer"`
121
+	Manufacturer      int64       `gorm:"column:manufacturer" json:"manufacturer"`
122
+	Remark            string      `gorm:"column:remark" json:"remark"`
123
+	Ctime             int64       `gorm:"column:ctime" json:"ctime"`
124
+	Mtime             int64       `gorm:"column:mtime" json:"mtime"`
125
+	Status            int64       `gorm:"column:status" json:"status"`
126
+	OrgId             int64       `gorm:"column:org_id" json:"org_id"`
127
+	IsReturn          int64       `gorm:"column:is_return" json:"is_return"`
128
+	StockCount        int64       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
129
+	Warehousing       Warehousing `ForeignKey:WarehousingId json:"warehouse"`
130
+	WarehousingOrder  string      `gorm:"column:warehousing_order" json:"warehousing_order"`
131
+	GoodInfo          GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
132
+	Type              int64       `gorm:"column:type" json:"type"`
133
+	LicenseNumber     string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
134
+	WarehouseInfoId   int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
135
+	PackingPrice      float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
136
+	SupplyWarehouseId int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
135 137
 }
136 138
 
137 139
 func (WarehousingInfo) TableName() string {
@@ -583,6 +585,7 @@ type VmStockFlow struct {
583 585
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
584 586
 	ReturnCount             int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
585 587
 	ProjectId               int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
588
+	SupplyWarehouseId       int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
586 589
 }
587 590
 
588 591
 func (VmStockFlow) TableName() string {

+ 132 - 20
models/supply.models.go Dosyayı Görüntüle

@@ -155,6 +155,7 @@ type SupplierWarehouseInfo struct {
155 155
 	Checker          int64   `gorm:"column:checker" json:"checker" form:"checker"`
156 156
 	CheckTime        int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
157 157
 	IsWarehouse      int64   `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
158
+	ReturnRemake     string  `gorm:"column:return_remake" json:"return_remake" form:"return_remake"`
158 159
 }
159 160
 
160 161
 func (SupplierWarehouseInfo) TableName() string {
@@ -243,6 +244,7 @@ type SpSupplierWarehouseOut struct {
243 244
 	SupplierId       int64   `gorm:"column:supplier_id" json:"supplier_id" form:"supplier_id"`
244 245
 	Checker          int64   `gorm:"column:checker" json:"checker" form:"checker"`
245 246
 	CheckTime        int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
247
+	ReturnRemake     string  `gorm:"column:return_remake" json:"return_remake" form:"return_remake"`
246 248
 }
247 249
 
248 250
 func (SpSupplierWarehouseOut) TableName() string {
@@ -250,26 +252,27 @@ func (SpSupplierWarehouseOut) TableName() string {
250 252
 }
251 253
 
252 254
 type VmSupplierWarehouseOut struct {
253
-	ID                            int64                            `gorm:"column:id" json:"id" form:"id"`
254
-	Number                        string                           `gorm:"column:number" json:"number" form:"number"`
255
-	UserOrgId                     int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
256
-	Creater                       int64                            `gorm:"column:creater" json:"creater" form:"creater"`
257
-	Ctime                         int64                            `gorm:"column:ctime" json:"ctime" form:"ctime"`
258
-	Mtime                         int64                            `gorm:"column:mtime" json:"mtime" form:"mtime"`
259
-	Status                        int64                            `gorm:"column:status" json:"status" form:"status"`
260
-	RecordDate                    int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
261
-	IsCheck                       int64                            `gorm:"column:is_check" json:"is_check" form:"is_check"`
262
-	WarehousingId                 int64                            `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
263
-	GoodNumber                    string                           `gorm:"column:good_number" json:"good_number" form:"good_number"`
264
-	Arrearage                     float64                          `gorm:"column:arrearage" json:"arrearage" form:"arrearage"`
265
-	Payment                       float64                          `gorm:"column:payment" json:"payment" form:"payment"`
266
-	RateOfConcession              float64                          `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
267
-	DiscountAmount                float64                          `gorm:"column:discount_amount" json:"discount_amount" form:"discount_amount"`
268
-	DocumentDate                  int64                            `gorm:"column:document_date" json:"document_date" form:"document_date"`
269
-	SupplierId                    int64                            `gorm:"column:supplier_id" json:"supplier_id" form:"supplier_id"`
270
-	Checker                       int64                            `gorm:"column:checker" json:"checker" form:"checker"`
271
-	CheckTime                     int64                            `gorm:"column:check_time" json:"check_time" form:"check_time"`
272
-	SpSupplierWarehousingOutOrder []*SpSupplierWarehousingOutOrder `gorm:"ForeignKey:warehouse_out_id;AssociationForeignKey:ID" json:"orderOut"`
255
+	ID                               int64                               `gorm:"column:id" json:"id" form:"id"`
256
+	Number                           string                              `gorm:"column:number" json:"number" form:"number"`
257
+	UserOrgId                        int64                               `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
258
+	Creater                          int64                               `gorm:"column:creater" json:"creater" form:"creater"`
259
+	Ctime                            int64                               `gorm:"column:ctime" json:"ctime" form:"ctime"`
260
+	Mtime                            int64                               `gorm:"column:mtime" json:"mtime" form:"mtime"`
261
+	Status                           int64                               `gorm:"column:status" json:"status" form:"status"`
262
+	RecordDate                       int64                               `gorm:"column:record_date" json:"record_date" form:"record_date"`
263
+	IsCheck                          int64                               `gorm:"column:is_check" json:"is_check" form:"is_check"`
264
+	WarehousingId                    int64                               `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
265
+	GoodNumber                       string                              `gorm:"column:good_number" json:"good_number" form:"good_number"`
266
+	Arrearage                        float64                             `gorm:"column:arrearage" json:"arrearage" form:"arrearage"`
267
+	Payment                          float64                             `gorm:"column:payment" json:"payment" form:"payment"`
268
+	RateOfConcession                 float64                             `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
269
+	DiscountAmount                   float64                             `gorm:"column:discount_amount" json:"discount_amount" form:"discount_amount"`
270
+	DocumentDate                     int64                               `gorm:"column:document_date" json:"document_date" form:"document_date"`
271
+	SupplierId                       int64                               `gorm:"column:supplier_id" json:"supplier_id" form:"supplier_id"`
272
+	Checker                          int64                               `gorm:"column:checker" json:"checker" form:"checker"`
273
+	CheckTime                        int64                               `gorm:"column:check_time" json:"check_time" form:"check_time"`
274
+	SpSupplierWarehousingOutOrder    []*SpSupplierWarehousingOutOrder    `gorm:"ForeignKey:warehouse_out_id;AssociationForeignKey:ID" json:"orderOut"`
275
+	SpSupplierWarehousingCancelOrder []*SpSupplierWarehousingCancelOrder `gorm:"ForeignKey:warehouse_out_id;AssociationForeignKey:ID" json:"cancelOut"`
273 276
 }
274 277
 
275 278
 func (VmSupplierWarehouseOut) TableName() string {
@@ -300,3 +303,112 @@ type VSupplierWarehousingInfoOrder struct {
300 303
 func (VSupplierWarehousingInfoOrder) TableName() string {
301 304
 	return "xt_supplier_warehousing_info_order"
302 305
 }
306
+
307
+type SpSupplierWarehouseCancel struct {
308
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
309
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
310
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
311
+	Creater          int64   `gorm:"column:creater" json:"creater" form:"creater"`
312
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
313
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
314
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
315
+	RecordDate       int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
316
+	IsCheck          int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
317
+	WarehouseOutId   int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
318
+	RateOfConcession float64 `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
319
+	DiscountAmount   float64 `gorm:"column:discount_amount" json:"discount_amount" form:"discount_amount"`
320
+	DocumentDate     int64   `gorm:"column:document_date" json:"document_date" form:"document_date"`
321
+	SupplierId       int64   `gorm:"column:supplier_id" json:"supplier_id" form:"supplier_id"`
322
+	Checker          int64   `gorm:"column:checker" json:"checker" form:"checker"`
323
+	CheckTime        int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
324
+	Arrearage        float64 `gorm:"column:arrearage" json:"arrearage" form:"arrearage"`
325
+	Payment          float64 `gorm:"column:payment" json:"payment" form:"payment"`
326
+	ReturnRemark     string  `gorm:"column:return_remark" json:"return_remark" form:"return_remark"`
327
+}
328
+
329
+func (SpSupplierWarehouseCancel) TableName() string {
330
+	return "xt_supplier_warehouse_cancel"
331
+}
332
+
333
+type SpSupplierWarehousingCancelOrder struct {
334
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
335
+	ManufacturerId          int64   `gorm:"column:manufacturer_id" json:"manufacturer_id" form:"manufacturer_id"`
336
+	OrderNumber             string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
337
+	ProjectId               int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
338
+	GoodNumber              string  `gorm:"column:good_number" json:"good_number" form:"good_number"`
339
+	IsSource                int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
340
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
341
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
342
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
343
+	RateOfConcession        float64 `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
344
+	DiscountAmount          float64 `gorm:"column:discount_amount" json:"discount_amount" form:"discount_amount"`
345
+	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
346
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
347
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
348
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
349
+	WarehouseCancelId       int64   `gorm:"column:warehouse_cancel_id" json:"warehouse_cancel_id" form:"warehouse_cancel_id"`
350
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
351
+	ReturnNumber            string  `gorm:"column:return_number" json:"return_number" form:"return_number"`
352
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
353
+	SupplySpecificationName string  `gorm:"column:supply_specification_name" json:"supply_specification_name" form:"supply_specification_name"`
354
+	SupplyType              string  `gorm:"column:supply_type" json:"supply_type" form:"supply_type"`
355
+	SupplyTotal             string  `gorm:"column:supply_total" json:"supply_total" form:"supply_total"`
356
+	SupplyManufacturer      string  `gorm:"column:supply_manufacturer" json:"supply_manufacturer" form:"supply_manufacturer"`
357
+	Name                    string  `gorm:"column:name" json:"name" form:"name"`
358
+	SupplyUnit              string  `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
359
+	SupplyLicenseNumber     string  `gorm:"column:supply_license_number" json:"supply_license_number" form:"supply_license_number"`
360
+}
361
+
362
+func (SpSupplierWarehousingCancelOrder) TableName() string {
363
+	return "xt_supplier_warehousing_cancel_order"
364
+}
365
+
366
+type VmSpSupplierWarehouseCancel struct {
367
+	ID                               int64                               `gorm:"column:id" json:"id" form:"id"`
368
+	Number                           string                              `gorm:"column:number" json:"number" form:"number"`
369
+	UserOrgId                        int64                               `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
370
+	Creater                          int64                               `gorm:"column:creater" json:"creater" form:"creater"`
371
+	Ctime                            int64                               `gorm:"column:ctime" json:"ctime" form:"ctime"`
372
+	Mtime                            int64                               `gorm:"column:mtime" json:"mtime" form:"mtime"`
373
+	Status                           int64                               `gorm:"column:status" json:"status" form:"status"`
374
+	RecordDate                       int64                               `gorm:"column:record_date" json:"record_date" form:"record_date"`
375
+	IsCheck                          int64                               `gorm:"column:is_check" json:"is_check" form:"is_check"`
376
+	WarehouseOutId                   int64                               `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
377
+	RateOfConcession                 float64                             `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
378
+	DiscountAmount                   float64                             `gorm:"column:discount_amount" json:"discount_amount" form:"discount_amount"`
379
+	DocumentDate                     int64                               `gorm:"column:document_date" json:"document_date" form:"document_date"`
380
+	SupplierId                       int64                               `gorm:"column:supplier_id" json:"supplier_id" form:"supplier_id"`
381
+	Checker                          int64                               `gorm:"column:checker" json:"checker" form:"checker"`
382
+	CheckTime                        int64                               `gorm:"column:check_time" json:"check_time" form:"check_time"`
383
+	Arrearage                        float64                             `gorm:"column:arrearage" json:"arrearage" form:"arrearage"`
384
+	Payment                          float64                             `gorm:"column:payment" json:"payment" form:"payment"`
385
+	ReturnRemark                     string                              `gorm:"column:return_remark" json:"return_remark" form:"return_remark"`
386
+	SpSupplierWarehousingCancelOrder []*SpSupplierWarehousingCancelOrder `gorm:"ForeignKey:warehouse_cancel_id;AssociationForeignKey:ID" json:"cancelOrder"`
387
+}
388
+
389
+func (VmSpSupplierWarehouseCancel) TableName() string {
390
+	return "xt_supplier_warehouse_cancel"
391
+}
392
+
393
+type VmSpSupplierWarehousingOutOrder struct {
394
+	ProjectId      int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
395
+	IsSource       int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
396
+	Count          int64  `gorm:"column:count" json:"count" form:"count"`
397
+	WarehouseOutId int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
398
+	SupplyUnit     string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
399
+}
400
+
401
+func (VmSpSupplierWarehousingOutOrder) TableName() string {
402
+	return "xt_supplier_warehousing_out_order"
403
+}
404
+
405
+type VmSpSupplierWarehousingCancelOrder struct {
406
+	ProjectId  int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
407
+	IsSource   int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
408
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
409
+	SupplyUnit string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
410
+}
411
+
412
+func (VmSpSupplierWarehousingCancelOrder) TableName() string {
413
+	return "xt_supplier_warehousing_cancel_order"
414
+}

+ 4 - 4
service/patientmanage_service.go Dosyayı Görüntüle

@@ -439,11 +439,11 @@ func FindPatientByDialysisNoOne(orgID int64, dialysisNo string, id int64) (patie
439 439
 }
440 440
 
441 441
 func FindPatientByMobileOne(mobile string, orgID int64, id int64) (patient models.XtPatientsNew, err error) {
442
-	//err = readDb.Model(&models.XtPatientsNew{}).Where(" status=1 and user_org_id=? and   phone=? and id<>?", orgID, mobile, id).First(&patient).Error
443
-	//return
444
-	db := readDb.Table("xt_patients_new as x")
445
-	err = db.Not("phone = ?", mobile).Where("user_org_id = ? and id = ? and status =1", orgID, id).Find(&patient).Error
442
+	err = readDb.Model(&models.XtPatientsNew{}).Where(" status=1 and user_org_id=? and   phone=? and id<>?", orgID, mobile, id).First(&patient).Error
446 443
 	return
444
+	//db := readDb.Table("xt_patients_new as x")
445
+	//err = db.Not("phone = ?", mobile).Where("user_org_id = ? and id = ? and status =1", orgID, id).Find(&patient).Error
446
+	//return
447 447
 }
448 448
 
449 449
 func GetPatientData(phone string, orgid int64) (*models.XtPatientsNew, error) {

+ 262 - 14
service/supply_service.go Dosyayı Görüntüle

@@ -289,7 +289,7 @@ func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
289 289
 		db = db.Where("x.org_id = ?", orgid)
290 290
 	}
291 291
 
292
-	err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Find(&drug).Error
292
+	err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ? and (stock_max_number >0 or stock_min_number>0)", orgid).Find(&drug).Error
293 293
 	return drug, err
294 294
 }
295 295
 
@@ -313,7 +313,7 @@ func GetSupplierList(orgid int64) (suppler []*models.SpSupplierName, err error)
313 313
 
314 314
 func FindAllSupplyOrder(orgid int64) (total int64, err error) {
315 315
 
316
-	err = XTReadDB().Model(&models.SupplierWarehouseInfo{}).Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
316
+	err = XTReadDB().Model(&models.SupplierWarehouseInfo{}).Where("user_org_id = ?", orgid).Count(&total).Error
317 317
 	return total, err
318 318
 }
319 319
 
@@ -375,7 +375,7 @@ func GetSupplyWarehousingOrderInfoTwo(id int64, ids []string) (order []*models.S
375 375
 
376 376
 func ModefySupplyWarehouseInfo(id int64, info models.SupplierWarehouseInfo) error {
377 377
 
378
-	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"rate_of_concession": info.RateOfConcession, "discount_amount": info.DiscountAmount, "document_date": info.DocumentDate, "delivery_date": info.DeliveryDate, "supplier_id": info.SupplierId}).Error
378
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"rate_of_concession": info.RateOfConcession, "discount_amount": info.DiscountAmount, "document_date": info.DocumentDate, "delivery_date": info.DeliveryDate, "supplier_id": info.SupplierId, "return_remake": info.ReturnRemake}).Error
379 379
 	return err
380 380
 }
381 381
 
@@ -399,7 +399,7 @@ func GetPurchaseOrderDetail(id int64) (models.SupplierWarehouseInfo, error) {
399 399
 }
400 400
 
401 401
 func FindAllSupplyWarehouseOutOrder(orgid int64) (total int64, err error) {
402
-	err = XTReadDB().Model(&models.SpSupplierWarehouseOut{}).Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
402
+	err = XTReadDB().Model(&models.SpSupplierWarehouseOut{}).Where("user_org_id = ?", orgid).Count(&total).Error
403 403
 	return total, err
404 404
 }
405 405
 
@@ -427,28 +427,34 @@ func GetSupplyWarehouseOutById(id int64, user_org_id int64) (order []*models.SpS
427 427
 	return order, err
428 428
 }
429 429
 
430
+func GetSupplyWarehouseOutByIdOne(id int64, user_org_id int64, ids []string) (order []*models.SpSupplierWarehousingOutOrder, err error) {
431
+
432
+	err = XTReadDB().Where("warehouse_out_id = ? and status = 1 and user_org_id = ? and project_id in(?)", id, user_org_id, ids).Find(&order).Error
433
+	return order, err
434
+}
435
+
430 436
 func GetAllGoodOderList(check_id int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (out []*models.VmSupplierWarehouseOut, total int64, err error) {
431
-	db := XTReadDB().Model(&out).Where("status = 1")
437
+	db := XTReadDB().Model(&out).Where("sgj_xt.xt_supplier_warehouse_out.status = 1")
432 438
 	likeKey := "%" + keyword + "%"
433 439
 	offset := (page - 1) * limit
434 440
 	if check_id > 0 {
435
-		db = db.Where("xt_supplier_warehouse_out.is_check = ?", check_id)
441
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.is_check = ?", check_id)
436 442
 	}
437 443
 	if startime > 0 {
438
-		db = db.Where("xt_supplier_warehouse_out.record_date >= ?", startime)
444
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date >= ?", startime)
439 445
 	}
440 446
 	if endtime > 0 {
441
-		db = db.Where("xt_supplier_warehouse_out.record_date<=?", endtime)
447
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date<=?", endtime)
442 448
 	}
443 449
 
444 450
 	if len(keyword) > 0 {
445
-		db.Joins("join xt_supplier_name on xt_supplier_name.id = xt_supplier_warehouse_out.supplier_id")
446
-		db = db.Where("xt_supplier_warehouse_out.number like ? or xt_supplier_name.supplier_name like ? ", likeKey, likeKey).Group("xt_supplier_warehouse_out.id")
451
+		db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
452
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.good_number like ? or sgj_xt.xt_supplier_name.supplier_name  like ? ", likeKey, likeKey).Group("xt_supplier_warehouse_out.id")
447 453
 	}
448 454
 	if orgid > 0 {
449
-		db = db.Where("xt_supplier_warehouse_out.user_org_id = ?", orgid)
455
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.user_org_id = ?", orgid)
450 456
 	}
451
-	err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingOutOrder", "status= 1 and user_org_id = ?", orgid).Find(&out).Error
457
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingOutOrder", "status= 1 and user_org_id = ?", orgid).Preload("SpSupplierWarehousingCancelOrder", "status= 1 and user_org_id = ?", orgid).Find(&out).Error
452 458
 	return out, total, err
453 459
 }
454 460
 
@@ -460,13 +466,13 @@ func GetGoodOrderDetail(id int64, orgid int64) (models.SpSupplierWarehouseOut, e
460 466
 
461 467
 func UpdateGoodWarehouseOut(id int64, out models.SpSupplierWarehouseOut) error {
462 468
 
463
-	err := XTWriteDB().Model(&out).Where("id=? and status = 1", id).Updates(map[string]interface{}{"arrearage": out.Arrearage, "payment": out.Payment, "rate_of_concession": out.RateOfConcession, "discount_amount": out.DiscountAmount, "document_date": out.DocumentDate}).Error
469
+	err := XTWriteDB().Model(&out).Where("id=? and status = 1", id).Updates(map[string]interface{}{"arrearage": out.Arrearage, "payment": out.Payment, "rate_of_concession": out.RateOfConcession, "discount_amount": out.DiscountAmount, "document_date": out.DocumentDate, "return_remake": out.ReturnRemake}).Error
464 470
 	return err
465 471
 }
466 472
 
467 473
 func UpdateGoodWarehouseOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
468 474
 
469
-	err := XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Count, "amount": order.Amount, "remark": order.Amount, "supply_batch_number": order.SupplyBatchNumber, "supply_product_date": order.SupplyProductDate, "supply_expiry_date": order.SupplyExpiryDate, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplySpecificationName, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "manufacturer_id": order.ManufacturerId, "supply_license_number": order.SupplyLicenseNumber}).Error
475
+	err := XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Count, "remark": order.Remark, "supply_batch_number": order.SupplyBatchNumber, "supply_product_date": order.SupplyProductDate, "supply_expiry_date": order.SupplyExpiryDate, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplySpecificationName, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "manufacturer_id": order.ManufacturerId, "supply_license_number": order.SupplyLicenseNumber, "warehousing_id": order.WarehousingId, "warehouse_info_id": order.WarehouseInfoId}).Error
470 476
 	return err
471 477
 }
472 478
 
@@ -518,3 +524,245 @@ func CheckGoodOrder(id int64, orgid int64, out models.SpSupplierWarehouseOut) er
518 524
 	err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and user_org_id =? and status = 1", id, orgid).Updates(map[string]interface{}{"is_check": out.IsCheck, "checker": out.Checker, "check_time": out.CheckTime, "mtime": time.Now().Unix()}).Error
519 525
 	return err
520 526
 }
527
+
528
+func ModefySupplyWarehousing(is_warehose int64, warehousing_id int64, orgid int64) error {
529
+
530
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1 and user_org_id =?", warehousing_id, orgid).Updates(map[string]interface{}{"is_warehouse": is_warehose, "mtime": time.Now().Unix()}).Error
531
+	return err
532
+}
533
+
534
+func GetAllDoctorSix(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
535
+
536
+	err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = 1", orgid, appid).Find(&appRole).Error
537
+	return appRole, err
538
+}
539
+
540
+func GetSingleDrugWarehouseOrder(record_date int64, orgid int64) (*models.DrugWarehouse, error) {
541
+	warehouse := models.DrugWarehouse{}
542
+	var err error
543
+	err = XTReadDB().Model(&warehouse).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehouse).Error
544
+	if err == gorm.ErrRecordNotFound {
545
+		return nil, err
546
+	}
547
+	if err != nil {
548
+		return nil, err
549
+	}
550
+	return &warehouse, nil
551
+}
552
+
553
+func GetSindleWarehouse(record_date int64, orgid int64) (*models.Warehousing, error) {
554
+	warehousing := models.Warehousing{}
555
+	var err error
556
+	err = XTReadDB().Model(&warehousing).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehousing).Error
557
+	if err == gorm.ErrRecordNotFound {
558
+		return nil, err
559
+	}
560
+	if err != nil {
561
+		return nil, err
562
+	}
563
+	return &warehousing, nil
564
+}
565
+
566
+func GetLastWarehouseInfoByInfo(orgid int64) (models.Warehousing, error) {
567
+	warehousing := models.Warehousing{}
568
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&warehousing).Error
569
+	return warehousing, err
570
+}
571
+
572
+func GetSupplyCancelOrder(orgid int64) (total int64, err error) {
573
+	err = XTReadDB().Model(&models.SpSupplierWarehouseCancel{}).Where("user_org_id = ?", orgid).Count(&total).Error
574
+	return total, err
575
+}
576
+
577
+func CreateReturnCacelOrder(cancel models.SpSupplierWarehouseCancel) error {
578
+
579
+	err := XTWriteDB().Create(&cancel).Error
580
+	return err
581
+}
582
+
583
+func GetLastReturnCancelOrder(orgid int64) (models.SpSupplierWarehouseCancel, error) {
584
+
585
+	cancel := models.SpSupplierWarehouseCancel{}
586
+	err := XTReadDB().Where("user_org_id =? and status = 1", orgid).Find(&cancel).Error
587
+	return cancel, err
588
+}
589
+
590
+func CreateCancelReturnOrder(order *models.SpSupplierWarehousingCancelOrder) error {
591
+
592
+	err := XTWriteDB().Create(&order).Error
593
+	return err
594
+}
595
+
596
+func GetReturnCancelOrder(id int64, orgid int64) (models.SpSupplierWarehouseCancel, error) {
597
+
598
+	cancel := models.SpSupplierWarehouseCancel{}
599
+	err := XTReadDB().Where("id = ? and status= 1 and user_org_id =?", id, orgid).Find(&cancel).Error
600
+	return cancel, err
601
+}
602
+
603
+func GetReturnCancelOrderList(id int64, orgid int64) (order models.SpSupplierWarehousingCancelOrder, err error) {
604
+
605
+	err = XTReadDB().Where("warehouse_cancel_id = ? and user_org_id =? and status = 1", id, orgid).Find(&order).Error
606
+	return order, err
607
+}
608
+
609
+func GetAllGoodReturnOrderList(checkid int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (order []*models.VmSpSupplierWarehouseCancel, total int64, err error) {
610
+
611
+	db := XTReadDB().Table("sgj_xt.xt_supplier_warehouse_cancel").Where("sgj_xt.xt_supplier_warehouse_cancel.status = 1")
612
+	likeKey := "%" + keyword + "%"
613
+	offset := (page - 1) * limit
614
+	if checkid > 0 {
615
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.is_check = ?", checkid)
616
+	}
617
+	if len(keyword) > 0 {
618
+		db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
619
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.number like ? or sgj_xt.xt_supplier_name.supplier_name  like ? ", likeKey, likeKey).Group("xt_supplier_warehouse_cancel.id")
620
+	}
621
+	if startime > 0 {
622
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date >= ?", startime)
623
+	}
624
+
625
+	if endtime > 0 {
626
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date <= ?", endtime)
627
+	}
628
+	if orgid > 0 {
629
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.user_org_id = ?", orgid)
630
+	}
631
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingCancelOrder", "status= 1 and user_org_id = ?", orgid).Find(&order).Error
632
+	return order, total, err
633
+}
634
+
635
+func GetGoodReturnDetail(id int64, orgid int64) (models.VmSpSupplierWarehouseCancel, error) {
636
+	cancel := models.VmSpSupplierWarehouseCancel{}
637
+	db := XTReadDB().Model(&cancel).Where("status = 1")
638
+	if id > 0 {
639
+		db = db.Where("id = ?", id)
640
+	}
641
+	if orgid > 0 {
642
+		db = db.Where("user_org_id = ?", orgid)
643
+	}
644
+	err := db.Find(&cancel).Error
645
+	return cancel, err
646
+}
647
+
648
+func GetGoodReturnOrderDetail(id int64, orgid int64) (order []*models.SpSupplierWarehousingCancelOrder, err error) {
649
+
650
+	db := XTReadDB().Model(&order).Where("status =1")
651
+	if id > 0 {
652
+		db = db.Where("warehouse_cancel_id = ?", id)
653
+	}
654
+	if orgid > 0 {
655
+		db = db.Where("user_org_id = ?", orgid)
656
+	}
657
+	err = db.Find(&order).Error
658
+	return order, err
659
+}
660
+
661
+func UpdateWarehouseCancelOrder(order *models.SpSupplierWarehousingCancelOrder) error {
662
+
663
+	err = XTWriteDB().Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"manufacturer_id": order.ManufacturerId, "order_number": order.OrderNumber, "project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Price, "remark": order.Remark, "rate_of_concession": order.RateOfConcession, "discount_amount": order.DiscountAmount, "type": order.Type, "supply_specification_name": order.SupplySpecificationName, "supply_type": order.SupplyType, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "supply_license_number": order.SupplyLicenseNumber}).Error
664
+	return err
665
+}
666
+
667
+func UpdateWarehouseCancel(id int64, cancel models.SpSupplierWarehouseCancel) error {
668
+
669
+	err := XTWriteDB().Model(&cancel).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"rate_of_concession": cancel.RateOfConcession, "discount_amount": cancel.DiscountAmount, "document_date": cancel.DocumentDate, "supplier_id": cancel.SupplierId, "arrearage": cancel.Arrearage, "payment": cancel.Payment, "return_remark": cancel.ReturnRemark}).Error
670
+	return err
671
+}
672
+
673
+func GetSupplyCancelOrderById(warehouse_out_id int64, orgid int64) (*models.SpSupplierWarehouseCancel, error) {
674
+	cancel := models.SpSupplierWarehouseCancel{}
675
+	var err error
676
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", warehouse_out_id, orgid).Find(&cancel).Error
677
+	if err == gorm.ErrRecordNotFound {
678
+		return nil, err
679
+	}
680
+	if err != nil {
681
+		return nil, err
682
+	}
683
+	return &cancel, nil
684
+}
685
+
686
+func UpdateSupplyGoodOrder(id int64, out models.SpSupplierWarehouseOut) error {
687
+
688
+	err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"is_check": out.IsCheck, "checker": out.Checker, "check_time": out.CheckTime}).Error
689
+	return err
690
+}
691
+
692
+func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
693
+
694
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
695
+	return err
696
+}
697
+
698
+func UpdateDrugSupplyFlow(id int64, orgid int64) error {
699
+
700
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("supply_warehouse_id = ? and user_org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
701
+	return err
702
+}
703
+
704
+func UpdateGoodSupplyWarehousingInfo(id int64, orgid int64) error {
705
+
706
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
707
+	return err
708
+}
709
+
710
+func UpdateGoodSupplyFlow(id int64, orgid int64) error {
711
+
712
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("supply_warehouse_id = ? and user_org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
713
+	return err
714
+}
715
+
716
+func GetDrugSupplyWarehousingById(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
717
+
718
+	err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
719
+	return info, err
720
+}
721
+
722
+func UpdateSupplyWarehousing(id int64, orgid int64) error {
723
+
724
+	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
725
+	return err
726
+}
727
+
728
+func GetGoodSupplyWarehousingById(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
729
+
730
+	err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
731
+	return info, err
732
+}
733
+
734
+func UpdateGoodWarehousing(id int64, orgid int64) error {
735
+	err := XTWriteDB().Model(&models.Warehousing{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
736
+	return err
737
+}
738
+
739
+func UpdateSupplyWarehousingById(id int64, orgid int64) error {
740
+
741
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and user_org_id =? and status = 1", id, orgid).Updates(map[string]interface{}{"is_warehouse": 1}).Error
742
+	return err
743
+}
744
+
745
+func DeleteGoodOrder(id int64, orgid int64) error {
746
+
747
+	err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
748
+
749
+	err = XTWriteDB().Model(&models.SpSupplierWarehousingOutOrder{}).Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
750
+	return err
751
+}
752
+func GetSupplyCancelWarehouse(id int64, orgid int64) (cancel []*models.SpSupplierWarehouseCancel, err error) {
753
+
754
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
755
+	return cancel, err
756
+}
757
+
758
+func GetGoodOrderListById(id int64, orgid int64) (out []*models.VmSpSupplierWarehousingOutOrder, err error) {
759
+
760
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&out).Error
761
+	return out, err
762
+}
763
+
764
+func GetGoodCanceListById(id int64, orgid int64) (cancel []*models.VmSpSupplierWarehousingCancelOrder, err error) {
765
+
766
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
767
+	return cancel, err
768
+}