Browse Source

11月8日库存管理

XMLWAN 2 years ago
parent
commit
85f88576f6

+ 4 - 0
controllers/manager_center_api_controller.go View File

@@ -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 View File

@@ -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 View File

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

File diff suppressed because it is too large
+ 902 - 49
controllers/supply_order_api_contorller.go


+ 1 - 0
models/drug.go View File

@@ -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 View File

@@ -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 View File

@@ -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 View File

@@ -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 {

+ 130 - 20
models/supply.models.go View File

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

+ 4 - 4
service/patientmanage_service.go View File

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

+ 256 - 14
service/supply_service.go View File

@@ -124,7 +124,7 @@ func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
124 124
 		db = db.Where("x.org_id = ?", orgid)
125 125
 	}
126 126
 
127
-	err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Find(&drug).Error
127
+	err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ? and (stock_max_number >0 or stock_min_number>0)", orgid).Find(&drug).Error
128 128
 	return drug, err
129 129
 }
130 130
 
@@ -148,7 +148,7 @@ func GetSupplierList(orgid int64) (suppler []*models.SpSupplierName, err error)
148 148
 
149 149
 func FindAllSupplyOrder(orgid int64) (total int64, err error) {
150 150
 
151
-	err = XTReadDB().Model(&models.SupplierWarehouseInfo{}).Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
151
+	err = XTReadDB().Model(&models.SupplierWarehouseInfo{}).Where("user_org_id = ?", orgid).Count(&total).Error
152 152
 	return total, err
153 153
 }
154 154
 
@@ -210,7 +210,7 @@ func GetSupplyWarehousingOrderInfoTwo(id int64, ids []string) (order []*models.S
210 210
 
211 211
 func ModefySupplyWarehouseInfo(id int64, info models.SupplierWarehouseInfo) error {
212 212
 
213
-	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
213
+	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
214 214
 	return err
215 215
 }
216 216
 
@@ -234,7 +234,7 @@ func GetPurchaseOrderDetail(id int64) (models.SupplierWarehouseInfo, error) {
234 234
 }
235 235
 
236 236
 func FindAllSupplyWarehouseOutOrder(orgid int64) (total int64, err error) {
237
-	err = XTReadDB().Model(&models.SpSupplierWarehouseOut{}).Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
237
+	err = XTReadDB().Model(&models.SpSupplierWarehouseOut{}).Where("user_org_id = ?", orgid).Count(&total).Error
238 238
 	return total, err
239 239
 }
240 240
 
@@ -263,27 +263,27 @@ func GetSupplyWarehouseOutById(id int64, user_org_id int64) (order []*models.SpS
263 263
 }
264 264
 
265 265
 func GetAllGoodOderList(check_id int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (out []*models.VmSupplierWarehouseOut, total int64, err error) {
266
-	db := XTReadDB().Model(&out).Where("status = 1")
266
+	db := XTReadDB().Model(&out).Where("sgj_xt.xt_supplier_warehouse_out.status = 1")
267 267
 	likeKey := "%" + keyword + "%"
268 268
 	offset := (page - 1) * limit
269 269
 	if check_id > 0 {
270
-		db = db.Where("xt_supplier_warehouse_out.is_check = ?", check_id)
270
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.is_check = ?", check_id)
271 271
 	}
272 272
 	if startime > 0 {
273
-		db = db.Where("xt_supplier_warehouse_out.record_date >= ?", startime)
273
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date >= ?", startime)
274 274
 	}
275 275
 	if endtime > 0 {
276
-		db = db.Where("xt_supplier_warehouse_out.record_date<=?", endtime)
276
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date<=?", endtime)
277 277
 	}
278 278
 
279 279
 	if len(keyword) > 0 {
280
-		db.Joins("join xt_supplier_name on xt_supplier_name.id = xt_supplier_warehouse_out.supplier_id")
281
-		db = db.Where("xt_supplier_warehouse_out.number like ? or xt_supplier_name.supplier_name like ? ", likeKey, likeKey).Group("xt_supplier_warehouse_out.id")
280
+		db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
281
+		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")
282 282
 	}
283 283
 	if orgid > 0 {
284
-		db = db.Where("xt_supplier_warehouse_out.user_org_id = ?", orgid)
284
+		db = db.Where("sgj_xt.xt_supplier_warehouse_out.user_org_id = ?", orgid)
285 285
 	}
286
-	err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingOutOrder", "status= 1 and user_org_id = ?", orgid).Find(&out).Error
286
+	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
287 287
 	return out, total, err
288 288
 }
289 289
 
@@ -295,13 +295,13 @@ func GetGoodOrderDetail(id int64, orgid int64) (models.SpSupplierWarehouseOut, e
295 295
 
296 296
 func UpdateGoodWarehouseOut(id int64, out models.SpSupplierWarehouseOut) error {
297 297
 
298
-	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
298
+	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
299 299
 	return err
300 300
 }
301 301
 
302 302
 func UpdateGoodWarehouseOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
303 303
 
304
-	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
304
+	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
305 305
 	return err
306 306
 }
307 307
 
@@ -353,3 +353,245 @@ func CheckGoodOrder(id int64, orgid int64, out models.SpSupplierWarehouseOut) er
353 353
 	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
354 354
 	return err
355 355
 }
356
+
357
+func ModefySupplyWarehousing(is_warehose int64, warehousing_id int64, orgid int64) error {
358
+
359
+	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
360
+	return err
361
+}
362
+
363
+func GetAllDoctorSix(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
364
+
365
+	err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = 1", orgid, appid).Find(&appRole).Error
366
+	return appRole, err
367
+}
368
+
369
+func GetSingleDrugWarehouseOrder(record_date int64, orgid int64) (*models.DrugWarehouse, error) {
370
+	warehouse := models.DrugWarehouse{}
371
+	var err error
372
+	err = XTReadDB().Model(&warehouse).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehouse).Error
373
+	if err == gorm.ErrRecordNotFound {
374
+		return nil, err
375
+	}
376
+	if err != nil {
377
+		return nil, err
378
+	}
379
+	return &warehouse, nil
380
+}
381
+
382
+func GetSindleWarehouse(record_date int64, orgid int64) (*models.Warehousing, error) {
383
+	warehousing := models.Warehousing{}
384
+	var err error
385
+	err = XTReadDB().Model(&warehousing).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehousing).Error
386
+	if err == gorm.ErrRecordNotFound {
387
+		return nil, err
388
+	}
389
+	if err != nil {
390
+		return nil, err
391
+	}
392
+	return &warehousing, nil
393
+}
394
+
395
+func GetLastWarehouseInfoByInfo(orgid int64) (models.Warehousing, error) {
396
+	warehousing := models.Warehousing{}
397
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&warehousing).Error
398
+	return warehousing, err
399
+}
400
+
401
+func GetSupplyCancelOrder(orgid int64) (total int64, err error) {
402
+	err = XTReadDB().Model(&models.SpSupplierWarehouseCancel{}).Where("user_org_id = ?", orgid).Count(&total).Error
403
+	return total, err
404
+}
405
+
406
+func CreateReturnCacelOrder(cancel models.SpSupplierWarehouseCancel) error {
407
+
408
+	err := XTWriteDB().Create(&cancel).Error
409
+	return err
410
+}
411
+
412
+func GetLastReturnCancelOrder(orgid int64) (models.SpSupplierWarehouseCancel, error) {
413
+
414
+	cancel := models.SpSupplierWarehouseCancel{}
415
+	err := XTReadDB().Where("user_org_id =? and status = 1", orgid).Find(&cancel).Error
416
+	return cancel, err
417
+}
418
+
419
+func CreateCancelReturnOrder(order *models.SpSupplierWarehousingCancelOrder) error {
420
+
421
+	err := XTWriteDB().Create(&order).Error
422
+	return err
423
+}
424
+
425
+func GetReturnCancelOrder(id int64, orgid int64) (models.SpSupplierWarehouseCancel, error) {
426
+
427
+	cancel := models.SpSupplierWarehouseCancel{}
428
+	err := XTReadDB().Where("id = ? and status= 1 and user_org_id =?", id, orgid).Find(&cancel).Error
429
+	return cancel, err
430
+}
431
+
432
+func GetReturnCancelOrderList(id int64, orgid int64) (order models.SpSupplierWarehousingCancelOrder, err error) {
433
+
434
+	err = XTReadDB().Where("warehouse_cancel_id = ? and user_org_id =? and status = 1", id, orgid).Find(&order).Error
435
+	return order, err
436
+}
437
+
438
+func GetAllGoodReturnOrderList(checkid int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (order []*models.VmSpSupplierWarehouseCancel, total int64, err error) {
439
+
440
+	db := XTReadDB().Table("sgj_xt.xt_supplier_warehouse_cancel").Where("sgj_xt.xt_supplier_warehouse_cancel.status = 1")
441
+	likeKey := "%" + keyword + "%"
442
+	offset := (page - 1) * limit
443
+	if checkid > 0 {
444
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.is_check = ?", checkid)
445
+	}
446
+	if len(keyword) > 0 {
447
+		db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
448
+		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")
449
+	}
450
+	if startime > 0 {
451
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date >= ?", startime)
452
+	}
453
+
454
+	if endtime > 0 {
455
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date <= ?", endtime)
456
+	}
457
+	if orgid > 0 {
458
+		db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.user_org_id = ?", orgid)
459
+	}
460
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingCancelOrder", "status= 1 and user_org_id = ?", orgid).Find(&order).Error
461
+	return order, total, err
462
+}
463
+
464
+func GetGoodReturnDetail(id int64, orgid int64) (models.VmSpSupplierWarehouseCancel, error) {
465
+	cancel := models.VmSpSupplierWarehouseCancel{}
466
+	db := XTReadDB().Model(&cancel).Where("status = 1")
467
+	if id > 0 {
468
+		db = db.Where("id = ?", id)
469
+	}
470
+	if orgid > 0 {
471
+		db = db.Where("user_org_id = ?", orgid)
472
+	}
473
+	err := db.Find(&cancel).Error
474
+	return cancel, err
475
+}
476
+
477
+func GetGoodReturnOrderDetail(id int64, orgid int64) (order []*models.SpSupplierWarehousingCancelOrder, err error) {
478
+
479
+	db := XTReadDB().Model(&order).Where("status =1")
480
+	if id > 0 {
481
+		db = db.Where("warehouse_cancel_id = ?", id)
482
+	}
483
+	if orgid > 0 {
484
+		db = db.Where("user_org_id = ?", orgid)
485
+	}
486
+	err = db.Find(&order).Error
487
+	return order, err
488
+}
489
+
490
+func UpdateWarehouseCancelOrder(order *models.SpSupplierWarehousingCancelOrder) error {
491
+
492
+	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
493
+	return err
494
+}
495
+
496
+func UpdateWarehouseCancel(id int64, cancel models.SpSupplierWarehouseCancel) error {
497
+
498
+	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
499
+	return err
500
+}
501
+
502
+func GetSupplyCancelOrderById(warehouse_out_id int64, orgid int64) (*models.SpSupplierWarehouseCancel, error) {
503
+	cancel := models.SpSupplierWarehouseCancel{}
504
+	var err error
505
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", warehouse_out_id, orgid).Find(&cancel).Error
506
+	if err == gorm.ErrRecordNotFound {
507
+		return nil, err
508
+	}
509
+	if err != nil {
510
+		return nil, err
511
+	}
512
+	return &cancel, nil
513
+}
514
+
515
+func UpdateSupplyGoodOrder(id int64, out models.SpSupplierWarehouseOut) error {
516
+
517
+	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
518
+	return err
519
+}
520
+
521
+func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
522
+
523
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
524
+	return err
525
+}
526
+
527
+func UpdateDrugSupplyFlow(id int64, orgid int64) error {
528
+
529
+	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
530
+	return err
531
+}
532
+
533
+func UpdateGoodSupplyWarehousingInfo(id int64, orgid int64) error {
534
+
535
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
536
+	return err
537
+}
538
+
539
+func UpdateGoodSupplyFlow(id int64, orgid int64) error {
540
+
541
+	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
542
+	return err
543
+}
544
+
545
+func GetDrugSupplyWarehousingById(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
546
+
547
+	err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
548
+	return info, err
549
+}
550
+
551
+func UpdateSupplyWarehousing(id int64, orgid int64) error {
552
+
553
+	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
554
+	return err
555
+}
556
+
557
+func GetGoodSupplyWarehousingById(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
558
+
559
+	err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
560
+	return info, err
561
+}
562
+
563
+func UpdateGoodWarehousing(id int64, orgid int64) error {
564
+	err := XTWriteDB().Model(&models.Warehousing{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
565
+	return err
566
+}
567
+
568
+func UpdateSupplyWarehousingById(id int64, orgid int64) error {
569
+
570
+	err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and user_org_id =? and status = 1", id, orgid).Updates(map[string]interface{}{"is_warehouse": 1}).Error
571
+	return err
572
+}
573
+
574
+func DeleteGoodOrder(id int64, orgid int64) error {
575
+
576
+	err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
577
+
578
+	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
579
+	return err
580
+}
581
+func GetSupplyCancelWarehouse(id int64, orgid int64) (cancel []*models.SpSupplierWarehouseCancel, err error) {
582
+
583
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
584
+	return cancel, err
585
+}
586
+
587
+func GetGoodOrderListById(id int64, orgid int64) (out []*models.VmSpSupplierWarehousingOutOrder, err error) {
588
+
589
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&out).Error
590
+	return out, err
591
+}
592
+
593
+func GetGoodCanceListById(id int64, orgid int64) (cancel []*models.VmSpSupplierWarehousingCancelOrder, err error) {
594
+
595
+	err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
596
+	return cancel, err
597
+}