csx 4 years ago
parent
commit
318c90c6c5

+ 60 - 65
controllers/base_api_controller.go View File

@@ -2,11 +2,10 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	//"XT_New/models"
5
+	"XT_New/models"
6 6
 
7 7
 	//"XT_New/models"
8 8
 	"XT_New/service"
9
-	"fmt"
10 9
 	"strconv"
11 10
 	"strings"
12 11
 )
@@ -67,36 +66,36 @@ type BaseAuthAPIController struct {
67 66
 func (this *BaseAuthAPIController) Prepare() {
68 67
 	this.BaseAPIController.Prepare()
69 68
 	if this.GetAdminUserInfo() == nil {
70
-		//var userAdmin models.AdminUser
71
-		//userAdmin.Id = 558
72
-		//userAdmin.Mobile = "13318464649"
73
-		//
74
-		////userAdmin.Id = 597
75
-		////userAdmin.Mobile = "19874122664"
76
-		//userAdmin.IsSuperAdmin = false
77
-		//userAdmin.Status = 1
78
-		//userAdmin.CreateTime = 1530786071
79
-		//userAdmin.ModifyTime = 1530786071
80
-		//var subscibe models.ServeSubscibe
81
-		//subscibe.ID = 1
82
-		//subscibe.OrgId = 4
83
-		//subscibe.PeriodStart = 1538035409
84
-		//subscibe.PeriodEnd = 1569571409
85
-		//subscibe.State = 1
86
-		//subscibe.Status = 1
87
-		//subscibe.CreatedTime = 1538035409
88
-		//subscibe.UpdatedTime = 1538035409
89
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
90
-		//subscibes[4] = &subscibe
91
-		//var adminUserInfo service.AdminUserInfo
92
-		//adminUserInfo.CurrentOrgId = 4
93
-		//adminUserInfo.CurrentAppId = 18
94
-		//adminUserInfo.AdminUser = &userAdmin
95
-		//adminUserInfo.Subscibes = subscibes
96
-		//this.SetSession("admin_user_info", &adminUserInfo)
97
-
98
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
99
-		this.StopRun()
69
+		var userAdmin models.AdminUser
70
+		userAdmin.Id = 558
71
+		userAdmin.Mobile = "13318464649"
72
+
73
+		//userAdmin.Id = 597
74
+		//userAdmin.Mobile = "19874122664"
75
+		userAdmin.IsSuperAdmin = false
76
+		userAdmin.Status = 1
77
+		userAdmin.CreateTime = 1530786071
78
+		userAdmin.ModifyTime = 1530786071
79
+		var subscibe models.ServeSubscibe
80
+		subscibe.ID = 1
81
+		subscibe.OrgId = 4
82
+		subscibe.PeriodStart = 1538035409
83
+		subscibe.PeriodEnd = 1569571409
84
+		subscibe.State = 1
85
+		subscibe.Status = 1
86
+		subscibe.CreatedTime = 1538035409
87
+		subscibe.UpdatedTime = 1538035409
88
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
89
+		subscibes[4] = &subscibe
90
+		var adminUserInfo service.AdminUserInfo
91
+		adminUserInfo.CurrentOrgId = 4
92
+		adminUserInfo.CurrentAppId = 18
93
+		adminUserInfo.AdminUser = &userAdmin
94
+		adminUserInfo.Subscibes = subscibes
95
+		this.SetSession("admin_user_info", &adminUserInfo)
96
+
97
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
98
+		//this.StopRun()
100 99
 
101 100
 	}
102 101
 
@@ -116,7 +115,6 @@ func (this *BaseAuthAPIController) Prepare() {
116 115
 			} else {
117 116
 				roles = strings.Split(role.RoleIds, ",")
118 117
 			}
119
-			fmt.Println(roles)
120 118
 
121 119
 			//获取该用户下所有角色的权限总集
122 120
 			var userRolePurviews string
@@ -132,7 +130,6 @@ func (this *BaseAuthAPIController) Prepare() {
132 130
 			}
133 131
 			//该用户所拥有角色的权限的总集
134 132
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
135
-			fmt.Println(userRolePurviewsArr)
136 133
 			//系统所记录的权限列表
137 134
 			allPermission, _ := service.GetAllFunctionPurview()
138 135
 
@@ -181,7 +178,6 @@ func (this *BaseAuthAPIController) Prepare() {
181 178
 			} else {
182 179
 				roles = strings.Split(role.RoleIds, ",")
183 180
 			}
184
-			fmt.Println(roles)
185 181
 
186 182
 			//获取该用户下所有角色的权限总集
187 183
 			var userRolePurviews string
@@ -197,7 +193,6 @@ func (this *BaseAuthAPIController) Prepare() {
197 193
 			}
198 194
 			//该用户所拥有角色的权限的总集
199 195
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
200
-			fmt.Println(userRolePurviewsArr)
201 196
 			//系统所记录的权限列表
202 197
 			allPermission, _ := service.GetAllFunctionPurview()
203 198
 
@@ -313,35 +308,35 @@ type BaseServeAPIController struct {
313 308
 func (this *BaseServeAPIController) Prepare() {
314 309
 	this.BaseAPIController.Prepare()
315 310
 	if this.GetAdminUserInfo() == nil {
316
-		//var userAdmin models.AdminUser
317
-		//userAdmin.Id = 558
318
-		//userAdmin.Mobile = "13535547901"
319
-		////userAdmin.Id = 597
320
-		////userAdmin.Mobile = "19874122664"
321
-		//userAdmin.IsSuperAdmin = false
322
-		//userAdmin.Status = 1
323
-		//userAdmin.CreateTime = 1530786071
324
-		//userAdmin.ModifyTime = 1530786071
325
-		//var subscibe models.ServeSubscibe
326
-		//subscibe.ID = 1
327
-		//subscibe.OrgId = 4
328
-		//subscibe.PeriodStart = 1538035409
329
-		//subscibe.PeriodEnd = 1569571409
330
-		//subscibe.State = 1
331
-		//subscibe.Status = 1
332
-		//subscibe.CreatedTime = 1538035409
333
-		//subscibe.UpdatedTime = 1538035409
334
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
335
-		//subscibes[4] = &subscibe
336
-		//var adminUserInfo service.AdminUserInfo
337
-		//adminUserInfo.CurrentOrgId = 4
338
-		//adminUserInfo.CurrentAppId = 18
339
-		//adminUserInfo.AdminUser = &userAdmin
340
-		//adminUserInfo.Subscibes = subscibes
341
-		//this.SetSession("admin_user_info", &adminUserInfo)
342
-
343
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
344
-		this.StopRun()
311
+		var userAdmin models.AdminUser
312
+		userAdmin.Id = 558
313
+		userAdmin.Mobile = "13535547901"
314
+		//userAdmin.Id = 597
315
+		//userAdmin.Mobile = "19874122664"
316
+		userAdmin.IsSuperAdmin = false
317
+		userAdmin.Status = 1
318
+		userAdmin.CreateTime = 1530786071
319
+		userAdmin.ModifyTime = 1530786071
320
+		var subscibe models.ServeSubscibe
321
+		subscibe.ID = 1
322
+		subscibe.OrgId = 4
323
+		subscibe.PeriodStart = 1538035409
324
+		subscibe.PeriodEnd = 1569571409
325
+		subscibe.State = 1
326
+		subscibe.Status = 1
327
+		subscibe.CreatedTime = 1538035409
328
+		subscibe.UpdatedTime = 1538035409
329
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
330
+		subscibes[4] = &subscibe
331
+		var adminUserInfo service.AdminUserInfo
332
+		adminUserInfo.CurrentOrgId = 4
333
+		adminUserInfo.CurrentAppId = 18
334
+		adminUserInfo.AdminUser = &userAdmin
335
+		adminUserInfo.Subscibes = subscibes
336
+		this.SetSession("admin_user_info", &adminUserInfo)
337
+
338
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
339
+		//this.StopRun()
345 340
 	}
346 341
 
347 342
 	//if adminUserInfo.AppRole != nil {

+ 3 - 0
controllers/data_api_controller.go View File

@@ -49,6 +49,9 @@ func DataApiRegistRouters() {
49 49
 	beego.Router("/api/filed/show", &DataApiController{}, "Post:ModifyFiledIsShow")
50 50
 	beego.Router("/article/hanleupdatetwo", &DataApiController{}, "Get:GetHandleData")
51 51
 	beego.Router("/article/updatedatatwo", &DataApiController{}, "Post:UpdateDataTwo")
52
+
53
+	//beego.Router("/api/dictionary/getconfiglist", &DataApiController{}, "get,post:GetDictionaryConfigList")
54
+
52 55
 }
53 56
 
54 57
 //GetPatientsList 取配置信息列表

File diff suppressed because it is too large
+ 1484 - 0
controllers/manager_center_api_controller.go


+ 20 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2942,7 +2942,6 @@ func (c *DialysisAPIController) CreateConsumables() {
2942 2942
 					Modifier:   0,
2943 2943
 				}
2944 2944
 				record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
2945
-				fmt.Println(record_count)
2946 2945
 				if record_count == 0 {
2947 2946
 					beforePrepares = append(beforePrepares, prepare)
2948 2947
 				}
@@ -3037,6 +3036,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3037 3036
 
3038 3037
 			}
3039 3038
 		}
3039
+		updateBeforePrepares = RemoveRepeatedGood(updateBeforePrepares)
3040 3040
 		if len(updateBeforePrepares) > 0 {
3041 3041
 			for _, item := range updateBeforePrepares {
3042 3042
 				errs = service.UpdateDialysisBeforePrepareTwo(item)
@@ -3074,6 +3074,8 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
3074 3074
 
3075 3075
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
3076 3076
 
3077
+	consumables = RemoveRepeatedGood(consumables)
3078
+
3077 3079
 	if record.IsOpen == 1 {
3078 3080
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3079 3081
 		if err == gorm.ErrRecordNotFound {
@@ -3251,6 +3253,7 @@ func (c *DialysisAPIController) EditConsumables() {
3251 3253
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3252 3254
 		return
3253 3255
 	}
3256
+
3254 3257
 	var beforePrepares []*models.DialysisBeforePrepare
3255 3258
 
3256 3259
 	var newBeforePrepares []*models.DialysisBeforePrepare
@@ -3260,6 +3263,7 @@ func (c *DialysisAPIController) EditConsumables() {
3260 3263
 	if record.IsOpen == 1 {
3261 3264
 
3262 3265
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3266
+
3263 3267
 			goods, _ := dataBody["goods"].([]interface{})
3264 3268
 			if len(goods) > 0 {
3265 3269
 				for _, item := range goods {
@@ -3980,6 +3984,7 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
3980 3984
 	return
3981 3985
 
3982 3986
 }
3987
+
3983 3988
 func (c *DialysisAPIController) CreateOtherStockOutInfo() {
3984 3989
 	patient_id, _ := c.GetInt64("patient_id", 0)
3985 3990
 	record_date := c.GetString("record_time")
@@ -4046,14 +4051,26 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4046 4051
 					Creater:    adminUser.AdminUser.Id,
4047 4052
 					Modifier:   0,
4048 4053
 				}
4049
-				beforePrepares = append(beforePrepares, prepare)
4054
+				record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
4055
+				if record_count == 0 {
4056
+					beforePrepares = append(beforePrepares, prepare)
4057
+				} else if record_count == 1 {
4058
+					service.UpdateDialysisBeforePrepareTwo(prepare)
4059
+				}
4050 4060
 
4051 4061
 			}
4052 4062
 		}
4053 4063
 	}
4054
-	service.CreateDialysisBeforePrepare(beforePrepares)
4064
+	beforePrepares = RemoveRepeatedGood(beforePrepares)
4065
+
4066
+	if len(beforePrepares) > 0 {
4067
+		service.CreateDialysisBeforePrepare(beforePrepares)
4068
+	}
4055 4069
 
4056 4070
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
4071
+
4072
+	consumables = RemoveRepeatedGood(consumables)
4073
+
4057 4074
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
4058 4075
 	if record.IsOpen == 1 {
4059 4076
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)

+ 1 - 0
controllers/public_api_controller.go View File

@@ -27,6 +27,7 @@ func PublicApiRegistRouters() {
27 27
 	beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
28 28
 	beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
29 29
 	beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
30
+	beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
30 31
 
31 32
 }
32 33
 

+ 7 - 181
controllers/stock_good_api_controller.go View File

@@ -20,13 +20,13 @@ func StockGoodApiRegistRouters() {
20 20
 	beego.Router("/api/stock/good/type/list", &StockGoodApiController{}, "get:GetGoodTypeList")
21 21
 	beego.Router("/api/type/delete", &StockGoodApiController{}, "post:DeleteGoodType")
22 22
 	beego.Router("/api/stock/good/type/get", &StockGoodApiController{}, "get:GetGoodType")
23
-
24
-	beego.Router("/api/stock/good/info/create", &StockGoodApiController{}, "post:CreateGoodInfo")
25
-	beego.Router("/api/stock/good/info/modify", &StockGoodApiController{}, "post:ModifyGoodInfo")
26
-	beego.Router("/api/stock/good/info/list", &StockGoodApiController{}, "get:GetGoodInfoList")
27
-	beego.Router("/api/info/delete", &StockGoodApiController{}, "post:DeleteGoodInfo")
28
-	beego.Router("/api/stock/good/info/get", &StockGoodApiController{}, "get:GetGoodInfoByGoodId")
29
-	beego.Router("/api/stock/good/info", &StockGoodApiController{}, "get:GetGoodInfoById")
23
+	//
24
+	//beego.Router("/api/stock/good/info/create", &StockGoodApiController{}, "post:CreateGoodInfo")
25
+	//beego.Router("/api/stock/good/info/modify", &StockGoodApiController{}, "post:ModifyGoodInfo")
26
+	//beego.Router("/api/stock/good/info/list", &StockGoodApiController{}, "get:GetGoodInfoList")
27
+	//beego.Router("/api/info/delete", &StockGoodApiController{}, "post:DeleteGoodInfo")
28
+	//beego.Router("/api/stock/good/info/get", &StockGoodApiController{}, "get:GetGoodInfoByGoodId")
29
+	//beego.Router("/api/stock/good/info", &StockGoodApiController{}, "get:GetGoodInfoById")
30 30
 
31 31
 	beego.Router("/api/stock/good/type/all", &StockGoodApiController{}, "get:GetAllGoodType")
32 32
 	beego.Router("/api/stock/good/info/all", &StockGoodApiController{}, "get:GetAllGoodInfo")
@@ -159,180 +159,6 @@ func (c *StockGoodApiController) GetGoodType() {
159 159
 
160 160
 }
161 161
 
162
-func (c *StockGoodApiController) CreateGoodInfo() {
163
-	good_id, _ := c.GetInt64("good_id", 0)
164
-	specification_name := c.GetString("specification_name")
165
-	good_unit, _ := c.GetInt64("good_unit", -1)
166
-	buy_price, _ := c.GetFloat("buy_price", 0)
167
-	sell_price, _ := c.GetFloat("sell_price", 0)
168
-	remark := c.GetString("remark")
169
-	manufacturer, _ := c.GetInt64("manufacturer", 0)
170
-	dealer, _ := c.GetInt64("dealer", 0)
171
-	expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
172
-	stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
173
-	is_reuse, _ := c.GetInt64("is_reuse", 0)
174
-
175
-	adminUserInfo := c.GetAdminUserInfo()
176
-
177
-	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
178
-	if totals > 0 {
179
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
180
-		return
181
-	}
182
-
183
-	total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
184
-	code := strconv.FormatInt(total+1, 10)
185
-	code = "24000000" + code
186
-
187
-	goodInfo := models.GoodInfo{
188
-		GoodCode:               code,
189
-		SpecificationName:      specification_name,
190
-		GoodTypeId:             good_id,
191
-		GoodUnit:               good_unit,
192
-		BuyPrice:               buy_price,
193
-		SellPrice:              sell_price,
194
-		Remark:                 remark,
195
-		Ctime:                  time.Now().Unix(),
196
-		Manufacturer:           manufacturer,
197
-		Dealer:                 dealer,
198
-		ExpiryDateWarnDayCount: expiry_date_warn_day_count,
199
-		StockWarnCount:         stock_warn_count,
200
-		IsReuse:                is_reuse,
201
-		Status:                 1,
202
-		OrgId:                  adminUserInfo.CurrentOrgId,
203
-		Creater:                adminUserInfo.AdminUser.Id,
204
-	}
205
-	err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
206
-	if err == nil {
207
-		c.ServeSuccessJSON(map[string]interface{}{
208
-			"goodInfo": goodInfos,
209
-		})
210
-	} else {
211
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
212
-	}
213
-
214
-}
215
-
216
-func (c *StockGoodApiController) ModifyGoodInfo() {
217
-	id, _ := c.GetInt64("id", 0)
218
-	good_id, _ := c.GetInt64("good_id", 0)
219
-	specification_name := c.GetString("specification_name")
220
-	good_unit, _ := c.GetInt64("good_unit", -1)
221
-	buy_price, _ := c.GetFloat("buy_price", 0)
222
-	sell_price, _ := c.GetFloat("sell_price", 0)
223
-	remark := c.GetString("remark")
224
-	manufacturer, _ := c.GetInt64("manufacturer", 0)
225
-	dealer, _ := c.GetInt64("dealer", 0)
226
-	expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
227
-	stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
228
-	is_reuse, _ := c.GetInt64("is_reuse", 0)
229
-	code := c.GetString("good_code")
230
-
231
-	adminUserInfo := c.GetAdminUserInfo()
232
-
233
-	//totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
234
-	//if totals > 0 {
235
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
236
-	//	return
237
-	//}
238
-
239
-	goodInfo := models.GoodInfo{
240
-		ID:                     id,
241
-		GoodCode:               code,
242
-		SpecificationName:      specification_name,
243
-		GoodTypeId:             good_id,
244
-		GoodUnit:               good_unit,
245
-		BuyPrice:               buy_price,
246
-		SellPrice:              sell_price,
247
-		Remark:                 remark,
248
-		Mtime:                  time.Now().Unix(),
249
-		Manufacturer:           manufacturer,
250
-		Dealer:                 dealer,
251
-		ExpiryDateWarnDayCount: expiry_date_warn_day_count,
252
-		StockWarnCount:         stock_warn_count,
253
-		IsReuse:                is_reuse,
254
-		Status:                 1,
255
-		OrgId:                  adminUserInfo.CurrentOrgId,
256
-		Modifier:               adminUserInfo.AdminUser.Id,
257
-	}
258
-	err, goodInfos := service.ModifyGoodInfo(&goodInfo)
259
-	if err == nil {
260
-		c.ServeSuccessJSON(map[string]interface{}{
261
-			"goodInfo": goodInfos,
262
-		})
263
-	} else {
264
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
265
-	}
266
-
267
-}
268
-func (c *StockGoodApiController) GetGoodInfoList() {
269
-	page, _ := c.GetInt64("page", 1)
270
-	limit, _ := c.GetInt64("limit", 7)
271
-	keyword := c.GetString("keyword")
272
-
273
-	adminUserInfo := c.GetAdminUserInfo()
274
-	goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword)
275
-	if err == nil {
276
-		c.ServeSuccessJSON(map[string]interface{}{
277
-			"list":  goodInfos,
278
-			"total": total,
279
-		})
280
-	} else {
281
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
282
-	}
283
-
284
-}
285
-func (c *StockGoodApiController) DeleteGoodInfo() {
286
-	id, _ := c.GetInt64("id", 0)
287
-	adminUserInfo := c.GetAdminUserInfo()
288
-
289
-	total, _ := service.FindWarehouseInfoTotalByGoodId(id)
290
-	total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
291
-
292
-	if total > 0 {
293
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
294
-		return
295
-	}
296
-	if total2 > 0 {
297
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
298
-		return
299
-	}
300
-
301
-	err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
302
-	if err == nil {
303
-		c.ServeSuccessJSON(map[string]interface{}{
304
-			"msg": "删除成功",
305
-		})
306
-	} else {
307
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
308
-	}
309
-
310
-}
311
-
312
-func (c *StockGoodApiController) GetGoodInfoByGoodId() {
313
-	id, _ := c.GetInt64("id", 0)
314
-	goodInfo, err := service.FindGoodInfoByGoodId(id)
315
-	if err == nil {
316
-		c.ServeSuccessJSON(map[string]interface{}{
317
-			"list": goodInfo,
318
-		})
319
-	} else {
320
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
321
-	}
322
-}
323
-
324
-func (c *StockGoodApiController) GetGoodInfoById() {
325
-	id, _ := c.GetInt64("id", 0)
326
-	goodInfo, err := service.FindGoodInfoById(id)
327
-	if err == nil {
328
-		c.ServeSuccessJSON(map[string]interface{}{
329
-			"goodInfo": goodInfo,
330
-		})
331
-	} else {
332
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
333
-	}
334
-}
335
-
336 162
 func (c *StockGoodApiController) GetAllGoodType() {
337 163
 	adminUserInfo := c.GetAdminUserInfo()
338 164
 	goodTypes, err := service.FindAllGoodType(adminUserInfo.CurrentOrgId)

+ 4 - 0
enums/error_code.go View File

@@ -204,6 +204,8 @@ const ( // ErrorCode
204 204
 	ErrorCodeDoctorAdviceEmpty = 20052
205 205
 
206 206
 	ErrorCodeOpenStocktWrong = 20053
207
+
208
+	ErrorCodeDrugRepeatDataException = 20054
207 209
 )
208 210
 
209 211
 var ErrCodeMsgs = map[int]string{
@@ -404,6 +406,8 @@ var ErrCodeMsgs = map[int]string{
404 406
 
405 407
 	ErrorCodeDoctorAdviceEmpty: "没有更多了",
406 408
 	ErrorCodeOpenStocktWrong:   "未开启自动扣减功能,无法出库",
409
+
410
+	ErrorCodeDrugRepeatDataException: "该药已经存在,无法添加",
407 411
 }
408 412
 
409 413
 type SGJError struct {

+ 46 - 0
models/data_models.go View File

@@ -23,6 +23,52 @@ func (Dataconfig) TableName() string {
23 23
 	return "xt_data_config"
24 24
 }
25 25
 
26
+type DictionaryDataconfig struct {
27
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
28
+	ParentId       int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
29
+	Module         string `gorm:"column:module" json:"module" form:"module"`
30
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
31
+	Name           string `gorm:"column:name" json:"name" form:"name"`
32
+	FieldName      string `gorm:"column:field_name" json:"field_name" form:"field_name"`
33
+	Value          int    `gorm:"column:value" json:"value" form:"value"`
34
+	CreatedTime    string `gorm:"column:create_time" json:"create_time" form:"create_time"`
35
+	UpdatedTime    string `gorm:"column:update_time" json:"update_time" form:"update_time"`
36
+	CreateUserId   int64  `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
37
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
38
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
39
+	DeleteIdSystem int64  `gorm:"column:delete_id_system" json:"delete_id_system" form:"delete_id_system"`
40
+	Title          string `gorm:"column:title" json:"title" form:"title"`
41
+	Content        string `gorm:"column:content" json:"content" form:"content"`
42
+	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
43
+}
44
+
45
+func (DictionaryDataconfig) TableName() string {
46
+	return "xt_drug_data_config"
47
+}
48
+
49
+type DictionaryConfigViewModel struct {
50
+	ID           int64                   `gorm:"column:id" json:"id" form:"id"`
51
+	ParentId     int64                   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
52
+	Module       string                  `gorm:"column:module" json:"module" form:"module"`
53
+	OrgId        int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
54
+	Name         string                  `gorm:"column:name" json:"name" form:"name"`
55
+	FieldName    string                  `gorm:"column:field_name" json:"field_name" form:"field_name"`
56
+	Value        int                     `gorm:"column:value" json:"value" form:"value"`
57
+	CreatedTime  string                  `gorm:"column:create_time" json:"create_time" form:"create_time"`
58
+	UpdatedTime  string                  `gorm:"column:update_time" json:"update_time" form:"update_time"`
59
+	CreateUserId int64                   `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
60
+	Status       int64                   `gorm:"column:status" json:"status" form:"status"`
61
+	Remark       string                  `gorm:"column:remark" json:"remark" form:"remark"`
62
+	Title        string                  `gorm:"column:title" json:"title" form:"title"`
63
+	Content      string                  `gorm:"column:content" json:"content" form:"content"`
64
+	Order        int64                   `gorm:"column:orders" json:"orders" form:"orders"`
65
+	Childs       []*DictionaryDataconfig `json:"childs" `
66
+}
67
+
68
+func (DictionaryConfigViewModel) TableName() string {
69
+	return "xt_drug_data_config"
70
+}
71
+
26 72
 type ConfigViewModel struct {
27 73
 	ID           int64         `gorm:"column:id" json:"id" form:"id"`
28 74
 	ParentId     int64         `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`

+ 43 - 22
models/good_models.go View File

@@ -20,28 +20,49 @@ func (GoodsType) TableName() string {
20 20
 }
21 21
 
22 22
 type GoodInfo struct {
23
-	ID                     int64     `gorm:"column:id" json:"id"`
24
-	GoodCode               string    `gorm:"column:good_code" json:"good_code"`
25
-	SpecificationName      string    `gorm:"column:specification_name" json:"specification_name"`
26
-	GoodTypeId             int64     `gorm:"column:good_type_id" json:"good_type_id"`
27
-	GoodUnit               int64     `gorm:"column:good_unit" json:"good_unit"`
28
-	BuyPrice               float64   `gorm:"column:buy_price" json:"buy_price"`
29
-	SellPrice              float64   `gorm:"column:sell_price" json:"sell_price"`
30
-	Remark                 string    `gorm:"column:remark" json:"remark"`
31
-	Ctime                  int64     `gorm:"column:ctime" json:"ctime"`
32
-	Mtime                  int64     `gorm:"column:mtime" json:"mtime"`
33
-	Manufacturer           int64     `gorm:"column:manufacturer" json:"manufacturer"`
34
-	Dealer                 int64     `gorm:"column:dealer" json:"dealer"`
35
-	ExpiryDateWarnDayCount int64     `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count"`
36
-	StockWarnCount         int64     `gorm:"column:stock_warn_count" json:"stock_warn_count"`
37
-	IsReuse                int64     `gorm:"column:is_reuse" json:"is_reuse"`
38
-	Status                 int64     `gorm:"column:status" json:"status"`
39
-	FilmArea               string    `gorm:"column:film_area" json:"film_area"`
40
-	IsUse                  int64     `gorm:"column:is_use" json:"is_use"`
41
-	FilmMaterialQuality    string    `gorm:"column:film_material_quality" json:"film_material_quality"`
42
-	OrgId                  int64     `gorm:"column:org_id" json:"org_id"`
43
-	Modifier               int64     `gorm:"column:modifier" json:"modifier"`
44
-	Creater                int64     `gorm:"column:creater" json:"creater"`
23
+	ID                     int64     `gorm:"column:id" json:"id" form:"id"`
24
+	GoodCode               string    `gorm:"column:good_code" json:"good_code" form:"good_code"`
25
+	SpecificationName      string    `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
26
+	GoodTypeId             int64     `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
27
+	GoodUnit               int64     `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
28
+	BuyPrice               float64   `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
29
+	SellPrice              float64   `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
30
+	Remark                 string    `gorm:"column:remark" json:"remark" form:"remark"`
31
+	Ctime                  int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
32
+	Mtime                  int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
33
+	Manufacturer           int64     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
34
+	Dealer                 int64     `gorm:"column:dealer" json:"dealer" form:"dealer"`
35
+	ExpiryDateWarnDayCount int64     `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
36
+	StockWarnCount         int64     `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
37
+	IsReuse                int64     `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
38
+	Status                 int64     `gorm:"column:status" json:"status" form:"status"`
39
+	FilmArea               string    `gorm:"column:film_area" json:"film_area" form:"film_area"`
40
+	IsUse                  int64     `gorm:"column:is_use" json:"is_use" form:"is_use"`
41
+	FilmMaterialQuality    string    `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
42
+	OrgId                  int64     `gorm:"column:org_id" json:"org_id" form:"org_id"`
43
+	Modifier               int64     `gorm:"column:modifier" json:"modifier" form:"modifier"`
44
+	Creater                int64     `gorm:"column:creater" json:"creater" form:"creater"`
45
+	GoodName               string    `gorm:"column:good_name" json:"good_name" form:"good_name"`
46
+	Pinyin                 string    `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
47
+	Wubi                   string    `gorm:"column:wubi" json:"wubi" form:"wubi"`
48
+	GoodKind               int64     `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
49
+	MedicalInsuranceLevel  int64     `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
50
+	RetailPrice            float64   `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
51
+	MedicalInsuranceNumber string    `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
52
+	IsSpecialDiseases      int64     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
53
+	IsRecord               int64     `gorm:"column:is_record" json:"is_record" form:"is_record"`
54
+	StatisticsCategory     int64     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
55
+	GoodStatus             int64     `gorm:"column:good_status" json:"good_status" form:"good_status"`
56
+	DefaultCount           int64     `gorm:"column:default_count" json:"default_count" form:"default_count"`
57
+	Sign                   int64     `gorm:"column:sign" json:"sign" form:"sign"`
58
+	IsDefault              int64     `gorm:"column:is_default" json:"is_default" form:"is_default"`
59
+	IsChargeUse            int64     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
60
+	IsChargePredict        int64     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
61
+	IsStatisticsWork       int64     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
62
+	Sort                   int64     `gorm:"column:sort" json:"sort" form:"sort"`
63
+	IsDoctorUse            int64     `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
64
+	Agent                  string    `gorm:"column:agent" json:"agent" form:"agent"`
65
+	GoodNumber             string    `gorm:"column:good_number" json:"good_number" form:"good_number"`
45 66
 	GoodsType              GoodsType `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" `
46 67
 }
47 68
 

+ 5 - 5
models/monitor_models.go View File

@@ -16,11 +16,11 @@ type VMMonitorDialysisSchedule struct {
16 16
 	DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId" json:"device_zone"`
17 17
 	TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
18 18
 
19
-	DialysisOrder            MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
20
-	Prescription             DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
21
-	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
22
-	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
23
-	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
19
+	DialysisOrder            MonitorDialysisOrder    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
20
+	Prescription             DialysisPrescription    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
21
+	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
22
+	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
23
+	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
24 24
 }
25 25
 
26 26
 func (VMMonitorDialysisSchedule) TableName() string {

+ 4 - 0
models/stock_models.go View File

@@ -16,6 +16,8 @@ type Manufacturer struct {
16 16
 	OrgId            int64  `gorm:"column:org_id" json:"org_id"`
17 17
 	Status           int64  `gorm:"column:status" json:"status"`
18 18
 	ManufacturerCode string `gorm:"column:manufacturer_code" json:"manufacturer_code"`
19
+	PinYin           string `gorm:"column:pinyin" json:"pinyin"`
20
+	WuBi             string `gorm:"column:wubi" json:"wubi"`
19 21
 }
20 22
 
21 23
 func (Manufacturer) TableName() string {
@@ -38,6 +40,8 @@ type Dealer struct {
38 40
 	OrgId          int64  `gorm:"column:org_id" json:"org_id"`
39 41
 	Status         int64  `gorm:"column:status" json:"status"`
40 42
 	DealerCode     string `gorm:"column:dealer_code" json:"dealer_code"`
43
+	PinYin         string `gorm:"column:pinyin" json:"pinyin"`
44
+	WuBi           string `gorm:"column:wubi" json:"wubi"`
41 45
 }
42 46
 
43 47
 func (Dealer) TableName() string {

+ 3 - 0
routers/router.go View File

@@ -51,6 +51,8 @@ func init() {
51 51
 	controllers.GobalConfigRegistRouters()
52 52
 	controllers.IntegrationConfigRegistRouters()
53 53
 	controllers.PCIndexEvaluationApiControllersRegisterRouters()
54
+	controllers.ManagerCenterRegistRouters()
55
+	controllers.DrugStockManagerApiRegistRouters()
54 56
 
55 57
 	m_api.MobileAPIControllersRegisterRouters()
56 58
 	new_m_api.NewMobileAPIControllersRegisterRouters()
@@ -66,4 +68,5 @@ func init() {
66 68
 	new_m_api.StaffScheduleApiControllersRegisterRouters()
67 69
 	controllers.DialysisPrameteRoutes()
68 70
 	new_m_api.DialysisParameterApiControllersRegisterRouters()
71
+
69 72
 }

+ 11 - 11
service/patient_service.go View File

@@ -994,18 +994,18 @@ func GetPatientScheduleList(orgID int64, patientID int64, page int64, limit int6
994 994
 	return
995 995
 }
996 996
 
997
-func GetMonitorRecord(orgID int64, date int64, partition int64) ([]*models.VMMonitorDialysisSchedule, error) {
998
-	var mds []*models.VMMonitorDialysisSchedule
997
+func GetMonitorRecord(orgID int64, date int64, partition int64) ([]*models.NewVMMonitorDialysisSchedule, error) {
998
+	var mds []*models.NewVMMonitorDialysisSchedule
999 999
 	db := readDb.
1000
-		Model(&models.VMMonitorDialysisSchedule{}).
1000
+		Model(&models.NewVMMonitorDialysisSchedule{}).
1001 1001
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1002 1002
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1003 1003
 		Preload("TreatmentMode", "status = 1").
1004
-		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
1005
-		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
1006
-		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
1007
-		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
1008
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
1004
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, date).
1005
+		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, date).
1006
+		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ? ", orgID, date).
1007
+		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? AND monitoring_date = ?", orgID, date).
1008
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, date).
1009 1009
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1010 1010
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1011 1011
 		Where("status = 1 AND user_org_id = ?", orgID)
@@ -1019,7 +1019,7 @@ func GetMonitorRecord(orgID int64, date int64, partition int64) ([]*models.VMMon
1019 1019
 	return mds, err
1020 1020
 }
1021 1021
 
1022
-func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*models.VMMonitorDialysisSchedule, error) {
1022
+func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*models.MonitorDialysisSchedule, error) {
1023 1023
 	var patients []*models.Patients
1024 1024
 	getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
1025 1025
 	if getPatientErr != nil {
@@ -1031,7 +1031,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1031 1031
 	}
1032 1032
 
1033 1033
 	db := readDb.
1034
-		Model(&models.VMMonitorDialysisSchedule{}).
1034
+		Model(&models.MonitorDialysisSchedule{}).
1035 1035
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1036 1036
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1037 1037
 		Preload("TreatmentMode", "status = 1").
@@ -1043,7 +1043,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1043 1043
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1044 1044
 		Where("status = 1 AND user_org_id = ? AND patient_id in (?)", orgID, patientIDs)
1045 1045
 
1046
-	var schedules []*models.VMMonitorDialysisSchedule
1046
+	var schedules []*models.MonitorDialysisSchedule
1047 1047
 	err := db.Offset(20 * (page - 1)).Limit(20).Order("schedule_date desc").Find(&schedules).Error
1048 1048
 	return schedules, err
1049 1049
 }

+ 589 - 2
service/stock_service.go View File

@@ -172,6 +172,7 @@ func AddSigleGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
172 172
 }
173 173
 
174 174
 func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
175
+
175 176
 	err := writeDb.Model(&models.GoodInfo{}).Where("id = ? AND status = 1", goodInfo.ID).Updates(map[string]interface{}{
176 177
 		"good_type_id":               goodInfo.GoodTypeId,
177 178
 		"modifier":                   goodInfo.Modifier,
@@ -186,6 +187,27 @@ func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
186 187
 		"expiry_date_warn_day_count": goodInfo.ExpiryDateWarnDayCount,
187 188
 		"stock_warn_count":           goodInfo.StockWarnCount,
188 189
 		"is_reuse":                   goodInfo.IsReuse,
190
+		"good_name":                  goodInfo.GoodName,
191
+		"pinyin":                     goodInfo.Pinyin,
192
+		"wubi":                       goodInfo.Wubi,
193
+		"good_kind":                  goodInfo.GoodKind,
194
+		"medical_insurance_level":    goodInfo.MedicalInsuranceLevel,
195
+		"retail_price":               goodInfo.RetailPrice,
196
+		"medical_insurance_number":   goodInfo.MedicalInsuranceNumber,
197
+		"is_special_diseases":        goodInfo.IsSpecialDiseases,
198
+		"is_record":                  goodInfo.IsRecord,
199
+		"statistics_category":        goodInfo.StatisticsCategory,
200
+		"good_status":                goodInfo.GoodStatus,
201
+		"default_count":              goodInfo.DefaultCount,
202
+		"sign":                       goodInfo.Sign,
203
+		"is_default":                 goodInfo.IsDefault,
204
+		"is_charge_use":              goodInfo.IsChargeUse,
205
+		"is_charge_predict":          goodInfo.IsChargePredict,
206
+		"is_statistics_work":         goodInfo.IsStatisticsWork,
207
+		"sort":                       goodInfo.Sort,
208
+		"is_doctor_use":              goodInfo.IsDoctorUse,
209
+		"agent":                      goodInfo.Agent,
210
+		"good_number":                goodInfo.GoodNumber,
189 211
 	}).Error
190 212
 
191 213
 	writeDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND org_id = ?", goodInfo.ID, goodInfo.OrgId).Updates(map[string]interface{}{"good_type_id": goodInfo.GoodTypeId})
@@ -198,14 +220,26 @@ func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
198 220
 
199 221
 }
200 222
 
201
-func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string) (list []*models.GoodInfo, total int64, err error) {
223
+func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_use int64, is_charge int64, good_kind int64) (list []*models.GoodInfo, total int64, err error) {
202 224
 	offset := (page - 1) * limit
203 225
 	db := readDb.Model(&models.GoodInfo{})
204 226
 	db = db.Where("org_id = ? AND status = 1", orgId)
205 227
 	if len(keyword) > 0 {
206 228
 		likeKey := "%" + keyword + "%"
207 229
 		db = db.Where("good_code LIKE ? OR specification_name LIKE ?", likeKey, likeKey)
230
+	} else {
231
+		if is_use > 0 {
232
+			db = db.Where("good_status = ?", is_use)
233
+		}
234
+		if is_charge > 0 {
235
+			db = db.Where(" good_status = ?", is_charge)
236
+		}
237
+		if good_kind > 0 {
238
+			db = db.Where(" good_kind = ?", good_kind)
239
+		}
240
+
208 241
 	}
242
+
209 243
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
210 244
 	return
211 245
 }
@@ -251,12 +285,24 @@ func AddSigleWarehouse(warehouse *models.Warehousing) error {
251 285
 
252 286
 }
253 287
 
288
+func AddSigleDrugWarehouse(warehouse *models.DrugWarehouse) error {
289
+	err := writeDb.Create(&warehouse).Error
290
+	return err
291
+
292
+}
293
+
254 294
 func AddSigleSalesReturn(salesReturn *models.SalesReturn) error {
255 295
 	err := writeDb.Create(&salesReturn).Error
256 296
 	return err
257 297
 
258 298
 }
259 299
 
300
+func AddSigleDrugSalesReturn(salesReturn *models.DrugSalesReturn) error {
301
+	err := writeDb.Create(&salesReturn).Error
302
+	return err
303
+
304
+}
305
+
260 306
 func UpDateGoodReturnStatus(ids []string) {
261 307
 	writeDb.Model(&models.WarehousingInfo{}).Where("id IN (?)", ids).Update(map[string]interface{}{"is_return": 1})
262 308
 
@@ -309,6 +355,49 @@ func CreateWarehousingInfo(warehousingInfo []*models.WarehousingInfo) (err error
309 355
 
310 356
 }
311 357
 
358
+func CreateDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo) (err error) {
359
+	if len(warehousingInfo) > 0 {
360
+		utx := writeDb.Begin()
361
+		if len(warehousingInfo) > 0 {
362
+			thisSQL := "INSERT INTO xt_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price) VALUES "
363
+			insertParams := make([]string, 0)
364
+			insertData := make([]interface{}, 0)
365
+			for _, info := range warehousingInfo {
366
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
367
+				insertData = append(insertData, info.WarehousingId)
368
+				insertData = append(insertData, info.DrugId)
369
+				insertData = append(insertData, info.Number)
370
+				insertData = append(insertData, info.ProductDate)
371
+				insertData = append(insertData, info.ExpiryDate)
372
+				insertData = append(insertData, info.WarehousingCount)
373
+				insertData = append(insertData, info.Price)
374
+				insertData = append(insertData, info.TotalPrice)
375
+				insertData = append(insertData, info.Dealer)
376
+				insertData = append(insertData, info.Manufacturer)
377
+				insertData = append(insertData, info.Remark)
378
+				insertData = append(insertData, info.Ctime)
379
+				insertData = append(insertData, info.Mtime)
380
+				insertData = append(insertData, info.Status)
381
+				insertData = append(insertData, info.OrgId)
382
+				insertData = append(insertData, info.WarehousingOrder)
383
+				insertData = append(insertData, info.Type)
384
+				insertData = append(insertData, info.RetailPrice)
385
+				insertData = append(insertData, info.RetailTotalPrice)
386
+
387
+			}
388
+			thisSQL += strings.Join(insertParams, ", ")
389
+			err = utx.Exec(thisSQL, insertData...).Error
390
+			if err != nil {
391
+				utx.Rollback()
392
+				return
393
+			}
394
+		}
395
+		utx.Commit()
396
+	}
397
+	return
398
+
399
+}
400
+
312 401
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
313 402
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
314 403
 
@@ -316,6 +405,13 @@ func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err err
316 405
 
317 406
 }
318 407
 
408
+func FindLastDrugWarehousingInfo(order string) (info models.DrugWarehouseInfo, err error) {
409
+	err = readDb.Model(&models.DrugWarehouseInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
410
+
411
+	return info, err
412
+
413
+}
414
+
319 415
 func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.Warehousing, total int64, err error) {
320 416
 	db := readDb.Model(&models.Warehousing{})
321 417
 	db = db.Where("xt_warehouse.org_id = ? AND xt_warehouse.status = 1 AND xt_warehouse.type = ?", orgId, types)
@@ -339,17 +435,128 @@ func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int6
339 435
 	return
340 436
 }
341 437
 
438
+type VMDrugWarehouse struct {
439
+	ID               int64                `gorm:"column:id" json:"id" form:"id"`
440
+	WarehousingOrder string               `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
441
+	OperationTime    int64                `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
442
+	OrgId            int64                `gorm:"column:org_id" json:"org_id" form:"org_id"`
443
+	Creater          int64                `gorm:"column:creater" json:"creater" form:"creater"`
444
+	Ctime            int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
445
+	Modifier         int64                `gorm:"column:modifier" json:"modifier" form:"modifier"`
446
+	Mtime            int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
447
+	Status           int64                `gorm:"column:status" json:"status" form:"status"`
448
+	WarehousingTime  int64                `gorm:"column:warehousing_time" json:"warehousing_time" form:"warehousing_time"`
449
+	Dealer           int64                `gorm:"column:dealer" json:"dealer" form:"dealer"`
450
+	Manufacturer     int64                `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
451
+	Type             int64                `gorm:"column:type" json:"type" form:"type"`
452
+	Manufacturers    *models.Manufacturer `gorm:"ForeignKey:Manufacturer;AssociationForeignKey:ID" json:"manufacturers"`
453
+	Dealers          *models.Dealer       `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
454
+}
455
+
456
+func (VMDrugWarehouse) TableName() string {
457
+	return "xt_drug_warehouse"
458
+}
459
+
460
+type VMDrugWarehouseInfo struct {
461
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
462
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
463
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
464
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
465
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
466
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
467
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
468
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
469
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
470
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
471
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
472
+	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
473
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
474
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
475
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
476
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
477
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
478
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
479
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
480
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
481
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
482
+	Drug             *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
483
+}
484
+
485
+func (VMDrugWarehouseInfo) TableName() string {
486
+	return "xt_drug_warehouse_info"
487
+}
488
+
489
+type Drug struct {
490
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
491
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
492
+	DrugSpec        float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
493
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
494
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
495
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
496
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
497
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
498
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
499
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
500
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
501
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
502
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
503
+}
504
+
505
+func (Drug) TableName() string {
506
+	return "xt_base_drug"
507
+}
508
+
509
+func FindAllDrugWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*VMDrugWarehouse, total int64, err error) {
510
+	db := readDb.Model(&VMDrugWarehouse{})
511
+	db = db.Where("xt_drug_warehouse.org_id = ? AND xt_drug_warehouse.status = 1", orgId)
512
+	db = db.Preload("Manufacturers", "status = 1 AND org_id = ?", orgId)
513
+	db = db.Preload("Dealers", "status = 1 AND org_id = ?", orgId)
514
+	if len(keywords) > 0 {
515
+		likeKey := "%" + keywords + "%"
516
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse.creater")
517
+		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse.manufacturer")
518
+		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse.warehousing_order LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_warehouse.id")
519
+	}
520
+	if startTime > 0 {
521
+		db = db.Where("xt_drug_warehouse.operation_time >=?", startTime)
522
+	}
523
+	if endTime > 0 {
524
+		db = db.Where("xt_drug_warehouse.operation_time<= ?", endTime)
525
+	}
526
+	db = db.Count(&total)
527
+	offset := (page - 1) * limit
528
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
529
+	return
530
+}
531
+
342 532
 func FindWarehousingInfoById(id int64) (list []*models.WarehousingInfo, err error) {
343 533
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? AND status = 1", id).Find(&list).Error
344 534
 	return list, err
345 535
 }
346 536
 
537
+func FindDrugWarehousingInfoById(id int64, org_id int64) (list []*VMDrugWarehouseInfo, err error) {
538
+	err = readDb.Model(&VMDrugWarehouseInfo{}).Preload("Drug", "status = 1 AND org_id = ? AND find_in_set('停用',drug_status) = 0", org_id).Where("warehousing_id = ? AND status = 1", id).Find(&list).Error
539
+	return list, err
540
+}
541
+
347 542
 func FindWarehousingById(id int64) (warehousing models.Warehousing, err error) {
348 543
 	err = readDb.Model(&models.Warehousing{}).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
349 544
 	return warehousing, err
350 545
 
351 546
 }
352 547
 
548
+func FindDrugWarehousingById(id int64, org_id int64) (warehousing VMDrugWarehouse, err error) {
549
+	err = readDb.Model(&VMDrugWarehouse{}).Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
550
+	return warehousing, err
551
+
552
+}
553
+
554
+//func FindDrugWarehousingById(id int64) (warehousing models.DrugWarehouse, err error) {
555
+//	err = readDb.Model(&models.DrugWarehouse{}).Where("id = ? AND status = 1 ", id).First(&warehousing).Error
556
+//	return warehousing, err
557
+//
558
+//}
559
+
353 560
 func GetInfoByIds(ids []string) (info []*models.WarehousingInfo, err error) {
354 561
 	err = readDb.Model(&models.WarehousingInfo{}).Preload("Warehousing", "status = 1").Where("id in (?) AND status = 1", ids).Find(&info).Error
355 562
 	return
@@ -396,6 +603,44 @@ func CreateSalesReturnInfo(salesReturnInfo []*models.SalesReturnInfo) (err error
396 603
 
397 604
 }
398 605
 
606
+func CreateDrugSalesReturnInfo(salesReturnInfo []*models.DrugSalesReturnInfo) (err error) {
607
+	if len(salesReturnInfo) > 0 {
608
+		utx := writeDb.Begin()
609
+		if len(salesReturnInfo) > 0 {
610
+			thisSQL := "INSERT INTO xt_sales_return_info (drug_id,sales_return_id, count, price,total,ctime,status,org_id,order_number,type,dealer,manufacturer,retail_price,retail_total_price) VALUES "
611
+			insertParams := make([]string, 0)
612
+			insertData := make([]interface{}, 0)
613
+			for _, info := range salesReturnInfo {
614
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
615
+				insertData = append(insertData, info.DrugId)
616
+				insertData = append(insertData, info.SalesReturnId)
617
+				insertData = append(insertData, info.Count)
618
+				insertData = append(insertData, info.Price)
619
+				insertData = append(insertData, info.Total)
620
+				insertData = append(insertData, info.Ctime)
621
+				insertData = append(insertData, info.Status)
622
+				insertData = append(insertData, info.OrgId)
623
+				insertData = append(insertData, info.OrderNumber)
624
+				insertData = append(insertData, info.Type)
625
+				insertData = append(insertData, info.Dealer)
626
+				insertData = append(insertData, info.Manufacturer)
627
+				insertData = append(insertData, info.RetailPrice)
628
+				insertData = append(insertData, info.RetailTotalPrice)
629
+
630
+			}
631
+			thisSQL += strings.Join(insertParams, ", ")
632
+			err = utx.Exec(thisSQL, insertData...).Error
633
+			if err != nil {
634
+				utx.Rollback()
635
+				return
636
+			}
637
+		}
638
+		utx.Commit()
639
+	}
640
+	return
641
+
642
+}
643
+
399 644
 func FindAllSalesReturnTotal(org_id int64) (total int64, err error) {
400 645
 	err = readDb.Model(&models.SalesReturn{}).Where("org_id = ?", org_id).Count(&total).Error
401 646
 	return total, err
@@ -408,6 +653,12 @@ func FindAllCancelStockTotal(org_id int64) (total int64, err error) {
408 653
 
409 654
 }
410 655
 
656
+func FindAllDrugCancelStockTotal(org_id int64) (total int64, err error) {
657
+	err = readDb.Model(&models.DrugCancelStock{}).Where("org_id = ?", org_id).Count(&total).Error
658
+	return total, err
659
+
660
+}
661
+
411 662
 func FindAllReturnList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.SalesReturn, total int64, err error) {
412 663
 	db := readDb.Model(&models.SalesReturn{})
413 664
 	db = db.Where("xt_sales_return.org_id = ? AND xt_sales_return.status = 1 AND xt_sales_return.type = ?", orgId, types)
@@ -431,6 +682,29 @@ func FindAllReturnList(orgId int64, page int64, limit int64, startTime int64, en
431 682
 	return
432 683
 }
433 684
 
685
+func FindAllDrugReturnList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.SalesReturn, total int64, err error) {
686
+	db := readDb.Model(&models.SalesReturn{})
687
+	db = db.Where("xt_drug_sales_return.org_id = ? AND xt_drug_sales_return.status = 1 ", orgId)
688
+
689
+	if len(keywords) > 0 {
690
+		likeKey := "%" + keywords + "%"
691
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_sales_return.creater")
692
+		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_sales_return.manufacturer")
693
+		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_sales_return.order_number LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_sales_return.id")
694
+	}
695
+
696
+	if startTime > 0 {
697
+		db = db.Where("xt_drug_sales_return.opera_time >=?", startTime)
698
+	}
699
+	if endTime > 0 {
700
+		db = db.Where("xt_drug_sales_return.opera_time<= ?", endTime)
701
+	}
702
+	db = db.Count(&total)
703
+	offset := (page - 1) * limit
704
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_sales_return.ctime desc").Find(&list).Error
705
+	return
706
+}
707
+
434 708
 func FindReturnInfoById(id int64) (list []*models.SalesReturnInfo, err error) {
435 709
 	err = readDb.Model(&models.SalesReturnInfo{}).Where("sales_return_id = ? AND status = 1", id).Find(&list).Error
436 710
 	return list, err
@@ -441,6 +715,11 @@ func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err erro
441 715
 	return list, err
442 716
 }
443 717
 
718
+func FindDrugCancelStockInfoById(id int64) (list []*models.DrugCancelStockInfo, err error) {
719
+	err = readDb.Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
720
+	return list, err
721
+}
722
+
444 723
 func FindAllWarehousingInfo(orgId int64, page int64, limit int64, startTime int64, endTime int64) (list []*models.WarehousingInfo, total int64, err error) {
445 724
 	db := readDb.Model(&models.WarehousingInfo{})
446 725
 	db = db.Where("org_id = ? AND status = 1", orgId)
@@ -464,12 +743,24 @@ func FindAllWarehouseOut(org_id int64) (total int64, err error) {
464 743
 
465 744
 }
466 745
 
746
+func FindAllDrugWarehouseOut(org_id int64) (total int64, err error) {
747
+	err = readDb.Model(&models.DrugWarehouseOut{}).Where("org_id = ?", org_id).Count(&total).Error
748
+	return total, err
749
+
750
+}
751
+
467 752
 func AddSigleWarehouseOut(warehouseOut *models.WarehouseOut) error {
468 753
 	err := writeDb.Create(&warehouseOut).Error
469 754
 	return err
470 755
 
471 756
 }
472 757
 
758
+func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
759
+	err := writeDb.Create(&warehouseOut).Error
760
+	return err
761
+
762
+}
763
+
473 764
 func CreateWarehousingOutInfo(warehouseOutInfo []*models.WarehouseOutInfo) (err error) {
474 765
 	if len(warehouseOutInfo) > 0 {
475 766
 		utx := writeDb.Begin()
@@ -510,6 +801,47 @@ func CreateWarehousingOutInfo(warehouseOutInfo []*models.WarehouseOutInfo) (err
510 801
 
511 802
 }
512 803
 
804
+func CreateDrugWarehousingOutInfo(warehouseOutInfo []*models.DrugWarehouseOutInfo) (err error) {
805
+	if len(warehouseOutInfo) > 0 {
806
+		utx := writeDb.Begin()
807
+		if len(warehouseOutInfo) > 0 {
808
+			thisSQL := "INSERT INTO xt_drug_warehouse_out_info (warehouse_out_id, drug_id, product_date,expiry_date,count,price,total_price,remark,ctime,status,org_id,warehouse_out_order_number,type,dealer,manufacturer,retail_price,retail_total_price) VALUES "
809
+			insertParams := make([]string, 0)
810
+			insertData := make([]interface{}, 0)
811
+			for _, info := range warehouseOutInfo {
812
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
813
+				insertData = append(insertData, info.WarehouseOutId)
814
+				insertData = append(insertData, info.DrugId)
815
+				insertData = append(insertData, info.ProductDate)
816
+				insertData = append(insertData, info.ExpiryDate)
817
+				insertData = append(insertData, info.Count)
818
+				insertData = append(insertData, info.Price)
819
+				insertData = append(insertData, info.TotalPrice)
820
+				insertData = append(insertData, info.Remark)
821
+				insertData = append(insertData, info.Ctime)
822
+				insertData = append(insertData, info.Status)
823
+				insertData = append(insertData, info.OrgId)
824
+				insertData = append(insertData, info.WarehouseOutOrderNumber)
825
+				insertData = append(insertData, info.Type)
826
+				insertData = append(insertData, info.Dealer)
827
+				insertData = append(insertData, info.Manufacturer)
828
+				insertData = append(insertData, info.RetailPrice)
829
+				insertData = append(insertData, info.RetailTotalPrice)
830
+
831
+			}
832
+			thisSQL += strings.Join(insertParams, ", ")
833
+			err = utx.Exec(thisSQL, insertData...).Error
834
+			if err != nil {
835
+				utx.Rollback()
836
+				return
837
+			}
838
+		}
839
+		utx.Commit()
840
+	}
841
+	return
842
+
843
+}
844
+
513 845
 func FindLastWarehousingOutInfo(order string) (info models.WarehouseOutInfo, err error) {
514 846
 	err = readDb.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_order_number = ? AND status = 1", order).Last(&info).Error
515 847
 
@@ -517,6 +849,13 @@ func FindLastWarehousingOutInfo(order string) (info models.WarehouseOutInfo, err
517 849
 
518 850
 }
519 851
 
852
+func FindLastDrugWarehousingOutInfo(order string) (info models.DrugWarehouseOutInfo, err error) {
853
+	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_order_number = ? AND status = 1", order).Last(&info).Error
854
+
855
+	return info, err
856
+
857
+}
858
+
520 859
 func FindAllWarehouseOutList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.WarehouseOut, total int64, err error) {
521 860
 	db := readDb.Model(&models.WarehouseOut{})
522 861
 	db = db.Where("xt_warehouse_out.org_id = ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.type = ?", orgId, types)
@@ -542,11 +881,41 @@ func FindAllWarehouseOutList(orgId int64, page int64, limit int64, startTime int
542 881
 	return
543 882
 }
544 883
 
884
+func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.DrugWarehouseOut, total int64, err error) {
885
+	db := readDb.Model(&models.DrugWarehouseOut{})
886
+	db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
887
+
888
+	if len(keywords) > 0 {
889
+		likeKey := "%" + keywords + "%"
890
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
891
+		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse_out.manufacturer")
892
+		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse_out.warehouse_out_order_number LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_warehouse_out.id")
893
+	}
894
+
895
+	if startTime > 0 {
896
+		db = db.Where("xt_drug_warehouse_out.ctime >=?", startTime)
897
+	}
898
+	if endTime > 0 {
899
+		db = db.Where("xt_drug_warehouse_out.ctime<= ?", endTime)
900
+	}
901
+	db = db.Count(&total)
902
+	offset := (page - 1) * limit
903
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
904
+	return list, total, err
905
+
906
+	return
907
+}
908
+
545 909
 func FindWarehouseOutInfoById(id int64) (list []*models.WarehouseOutInfo, err error) {
546 910
 	err = readDb.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? AND status = 1 AND count <> 0 AND good_id <> 0", id).Order("good_type_id desc").Find(&list).Error
547 911
 	return list, err
548 912
 }
549 913
 
914
+func FindDrugWarehouseOutInfoById(id int64) (list []*models.DrugWarehouseOutInfo, err error) {
915
+	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? AND status = 1 AND count <> 0 AND good_id <> 0", id).Order("good_type_id desc").Find(&list).Error
916
+	return list, err
917
+}
918
+
550 919
 func FindWarehouseInfoByGoodId(good_id int64) (int64, *models.WarehousingInfo) {
551 920
 	info := &models.WarehousingInfo{}
552 921
 	type WarehouseInfoCountAmount struct {
@@ -600,6 +969,12 @@ func AddSigleCancelStock(cancelStock *models.CancelStock) error {
600 969
 
601 970
 }
602 971
 
972
+func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
973
+	err := writeDb.Create(&cancelStock).Error
974
+	return err
975
+
976
+}
977
+
603 978
 func CreateCancelStockInfo(cancelStockInfo []*models.CancelStockInfo) (err error) {
604 979
 	if len(cancelStockInfo) > 0 {
605 980
 		utx := writeDb.Begin()
@@ -636,6 +1011,44 @@ func CreateCancelStockInfo(cancelStockInfo []*models.CancelStockInfo) (err error
636 1011
 
637 1012
 }
638 1013
 
1014
+func CreateDrugCancelStockInfo(cancelStockInfo []*models.DrugCancelStockInfo) (err error) {
1015
+	if len(cancelStockInfo) > 0 {
1016
+		utx := writeDb.Begin()
1017
+		if len(cancelStockInfo) > 0 {
1018
+			thisSQL := "INSERT INTO xt_drug_cancel_stock_info (drug_id,cancel_stock_id, count, price,total,ctime,status,org_id,order_number,type,dealer,manufacturer,retail_price,retail_total_price) VALUES "
1019
+			insertParams := make([]string, 0)
1020
+			insertData := make([]interface{}, 0)
1021
+			for _, info := range cancelStockInfo {
1022
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
1023
+				insertData = append(insertData, info.DrugId)
1024
+				insertData = append(insertData, info.CancelStockId)
1025
+				insertData = append(insertData, info.Count)
1026
+				insertData = append(insertData, info.Price)
1027
+				insertData = append(insertData, info.Total)
1028
+				insertData = append(insertData, info.Ctime)
1029
+				insertData = append(insertData, info.Status)
1030
+				insertData = append(insertData, info.OrgId)
1031
+				insertData = append(insertData, info.OrderNumber)
1032
+				insertData = append(insertData, info.Type)
1033
+				insertData = append(insertData, info.Dealer)
1034
+				insertData = append(insertData, info.Manufacturer)
1035
+				insertData = append(insertData, info.RetailPrice)
1036
+				insertData = append(insertData, info.RetailTotalPrice)
1037
+
1038
+			}
1039
+			thisSQL += strings.Join(insertParams, ", ")
1040
+			err = utx.Exec(thisSQL, insertData...).Error
1041
+			if err != nil {
1042
+				utx.Rollback()
1043
+				return
1044
+			}
1045
+		}
1046
+		utx.Commit()
1047
+	}
1048
+	return
1049
+
1050
+}
1051
+
639 1052
 func FindAllCancelStockList(orgId int64) (list []*models.CancelStock, err error) {
640 1053
 	db := readDb.Model(&models.CancelStock{})
641 1054
 	db = db.Where("org_id = ? AND status = 1", orgId)
@@ -727,6 +1140,11 @@ func UpDateWarehouseStatus(id int64) (err error) {
727 1140
 	return
728 1141
 }
729 1142
 
1143
+func UpDateDrugWarehouseStatus(id int64) (err error) {
1144
+	err = readDb.Model(&models.DrugWarehouseInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1145
+	return
1146
+}
1147
+
730 1148
 func DeleteWarehouse(ids []string) (err error) {
731 1149
 	ut := writeDb.Begin()
732 1150
 	err = ut.Model(&models.Warehousing{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -743,6 +1161,22 @@ func DeleteWarehouse(ids []string) (err error) {
743 1161
 	return
744 1162
 }
745 1163
 
1164
+func DeleteDrugWarehouse(ids []string) (err error) {
1165
+	ut := writeDb.Begin()
1166
+	err = ut.Model(&models.DrugWarehouse{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1167
+	if err != nil {
1168
+		ut.Rollback()
1169
+		return
1170
+	}
1171
+	err = ut.Model(&models.DrugWarehouseInfo{}).Where("warehousing_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1172
+	if err != nil {
1173
+		ut.Rollback()
1174
+		return
1175
+	}
1176
+	ut.Commit()
1177
+	return
1178
+}
1179
+
746 1180
 func FindWareHouseById(orderNumber string) (*models.Warehousing, error) {
747 1181
 	warehouse := &models.Warehousing{}
748 1182
 	err := readDb.Model(&models.Warehousing{}).Where("warehousing_order = ? AND status = 1", orderNumber).First(&warehouse).Error
@@ -754,6 +1188,12 @@ func FindWareHouseOutById(id int64) (*models.WarehouseOut, error) {
754 1188
 	return warehouseOut, err
755 1189
 }
756 1190
 
1191
+func FindDrugWareHouseOutById(id int64) (*models.DrugWarehouseOut, error) {
1192
+	warehouseOut := &models.DrugWarehouseOut{}
1193
+	err := readDb.Model(&models.DrugWarehouseOut{}).Where("id = ? AND status = 1", id).First(&warehouseOut).Error
1194
+	return warehouseOut, err
1195
+}
1196
+
757 1197
 func FindWarehouseInfoByOrderNumber(orderNumber string) (info []*models.WarehousingInfo, err error) {
758 1198
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", orderNumber).Find(&info).Error
759 1199
 	return
@@ -805,11 +1245,20 @@ func UpDateWarehousingInfo(info *models.WarehousingInfo) (err error) {
805 1245
 	return err
806 1246
 }
807 1247
 
1248
+func UpDateDrugWarehousingInfo(info *models.DrugWarehouseInfo) (err error) {
1249
+	err = writeDb.Save(&info).Error
1250
+	return err
1251
+}
1252
+
808 1253
 func EditWarehousing(warehouse models.Warehousing) {
809 1254
 	err = readDb.Model(&models.Warehousing{}).Where("warehousing_order = ? AND status = 1", warehouse.WarehousingOrder).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehousing_time": warehouse.WarehousingTime, "modifier": warehouse.Modifier, "dealer": warehouse.Dealer, "manufacturer": warehouse.Manufacturer}).Error
810 1255
 
811 1256
 }
812 1257
 
1258
+func EditDrugWarehousing(warehouse models.DrugWarehouse) {
1259
+	err = readDb.Model(&models.DrugWarehouse{}).Where("warehousing_order = ? AND status = 1", warehouse.WarehousingOrder).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehousing_time": warehouse.WarehousingTime, "modifier": warehouse.Modifier, "dealer": warehouse.Dealer, "manufacturer": warehouse.Manufacturer}).Error
1260
+
1261
+}
813 1262
 func FindAllWarehouse(org_id int64, types int64) (list []*models.Warehousing, err error) {
814 1263
 	err = readDb.Model(&models.Warehousing{}).Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ? ", org_id).Where("org_id = ? AND status = 1 AND type = ?", org_id, types).Find(&list).Error
815 1264
 	return list, err
@@ -838,35 +1287,83 @@ func DeleteSalesReturn(ids []string) (err error) {
838 1287
 	return
839 1288
 }
840 1289
 
1290
+func DeleteDrugSalesReturn(ids []string) (err error) {
1291
+	ut := writeDb.Begin()
1292
+	err = ut.Model(&models.DrugSalesReturn{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1293
+	if err != nil {
1294
+		ut.Rollback()
1295
+		return
1296
+	}
1297
+	err = ut.Model(&models.DrugSalesReturnInfo{}).Where("sales_return_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1298
+	if err != nil {
1299
+		ut.Rollback()
1300
+		return
1301
+	}
1302
+	ut.Commit()
1303
+	return
1304
+}
1305
+
841 1306
 func FindAllSalesReturnInfoById(id int64) (list []*models.SalesReturnInfo, err error) {
842 1307
 	err = readDb.Model(&models.SalesReturnInfo{}).Where("sales_return_id = ? AND status = 1", id).Find(&list).Error
843 1308
 	return
844 1309
 }
845 1310
 
1311
+func FindAllDrugSalesReturnInfoById(id int64) (list []*models.DrugSalesReturnInfo, err error) {
1312
+	err = readDb.Model(&models.DrugSalesReturnInfo{}).Where("sales_return_id = ? AND status = 1", id).Find(&list).Error
1313
+	return
1314
+}
1315
+
846 1316
 func FindAllSalesReturnById(id int64) (salesReturn models.SalesReturn, err error) {
847
-	err = readDb.Model(&models.SalesReturnInfo{}).Where("id = ? AND status = 1", id).First(&salesReturn).Error
1317
+	err = readDb.Model(&models.SalesReturn{}).Where("id = ? AND status = 1", id).First(&salesReturn).Error
1318
+	return
1319
+}
1320
+
1321
+func FindAllDrugSalesReturnById(id int64) (salesReturn models.DrugSalesReturn, err error) {
1322
+	err = readDb.Model(&models.DrugSalesReturn{}).Where("id = ? AND status = 1", id).First(&salesReturn).Error
848 1323
 	return
849 1324
 }
1325
+
850 1326
 func UpDateSaleReturnStatus(id int64) (err error) {
851 1327
 	err = readDb.Model(&models.SalesReturnInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
852 1328
 	return
853 1329
 }
854 1330
 
1331
+func UpDateDrugSaleReturnStatus(id int64) (err error) {
1332
+	err = readDb.Model(&models.DrugSalesReturnInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1333
+	return
1334
+}
1335
+
855 1336
 func FindSalesReturnById(id int64) (salesReturn models.SalesReturn, err error) {
856 1337
 	err = readDb.Model(&models.SalesReturn{}).Where("id = ? AND status = 1", id).First(&salesReturn).Error
857 1338
 	return salesReturn, err
858 1339
 
859 1340
 }
860 1341
 
1342
+func FindDrugSalesReturnById(id int64) (salesReturn models.DrugSalesReturn, err error) {
1343
+	err = readDb.Model(&models.DrugSalesReturn{}).Where("id = ? AND status = 1", id).First(&salesReturn).Error
1344
+	return salesReturn, err
1345
+
1346
+}
1347
+
861 1348
 func EditSaleReturn(sales models.SalesReturn) {
862 1349
 	err = readDb.Model(&models.SalesReturn{}).Where("id = ? AND status = 1", sales.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "return_time": sales.ReturnTime, "dealer": sales.Dealer, "manufacturer": sales.Manufacturer}).Error
863 1350
 
1351
+}
1352
+
1353
+func EditDrugSaleReturn(sales models.DrugSalesReturn) {
1354
+	err = readDb.Model(&models.DrugSalesReturn{}).Where("id = ? AND status = 1", sales.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "return_time": sales.ReturnTime, "dealer": sales.Dealer, "manufacturer": sales.Manufacturer}).Error
1355
+
864 1356
 }
865 1357
 func UpDateSalesReturnInfo(info *models.SalesReturnInfo) (err error) {
866 1358
 	err = writeDb.Save(&info).Error
867 1359
 	return err
868 1360
 }
869 1361
 
1362
+func UpDateDrugSalesReturnInfo(info *models.DrugSalesReturnInfo) (err error) {
1363
+	err = writeDb.Save(&info).Error
1364
+	return err
1365
+}
1366
+
870 1367
 func DeleteWarehouseOut(ids []string) (err error) {
871 1368
 	ut := writeDb.Begin()
872 1369
 	err = ut.Model(&models.WarehouseOut{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -882,20 +1379,51 @@ func DeleteWarehouseOut(ids []string) (err error) {
882 1379
 	ut.Commit()
883 1380
 	return
884 1381
 }
1382
+
1383
+func DeleteDrugWarehouseOut(ids []string) (err error) {
1384
+	ut := writeDb.Begin()
1385
+	err = ut.Model(&models.DrugWarehouseOut{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1386
+	if err != nil {
1387
+		ut.Rollback()
1388
+		return
1389
+	}
1390
+	err = ut.Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1391
+	if err != nil {
1392
+		ut.Rollback()
1393
+		return
1394
+	}
1395
+	ut.Commit()
1396
+	return
1397
+}
1398
+
885 1399
 func UpDateWarehouseOutStatus(id int64) (err error) {
886 1400
 	err = readDb.Model(&models.WarehouseOutInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
887 1401
 	return
888 1402
 }
889 1403
 
1404
+func UpDateDrugWarehouseOutStatus(id int64) (err error) {
1405
+	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1406
+	return
1407
+}
1408
+
890 1409
 func EditWarehouseOut(warehouseOut models.WarehouseOut) {
891 1410
 	err = readDb.Model(&models.WarehouseOut{}).Where("id = ? AND status = 1", warehouseOut.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehouse_out_time": warehouseOut.WarehouseOutTime, "dealer": warehouseOut.Dealer, "manufacturer": warehouseOut.Manufacturer}).Error
892 1411
 }
893 1412
 
1413
+func EditDrugWarehouseOut(warehouseOut models.DrugWarehouseOut) {
1414
+	err = readDb.Model(&models.DrugWarehouseOut{}).Where("id = ? AND status = 1", warehouseOut.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehouse_out_time": warehouseOut.WarehouseOutTime, "dealer": warehouseOut.Dealer, "manufacturer": warehouseOut.Manufacturer}).Error
1415
+}
1416
+
894 1417
 func UpDateWarehouseOutInfo(info *models.WarehouseOutInfo) (err error) {
895 1418
 	err = writeDb.Save(&info).Error
896 1419
 	return err
897 1420
 }
898 1421
 
1422
+func UpDateDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) (err error) {
1423
+	err = writeDb.Save(&info).Error
1424
+	return err
1425
+}
1426
+
899 1427
 func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.CancelStock, total int64, err error) {
900 1428
 	db := readDb.Model(&models.CancelStock{})
901 1429
 	db = db.Where("xt_cancel_stock.org_id = ? AND xt_cancel_stock.status = 1 AND xt_cancel_stock.type = ?", orgId, types)
@@ -918,6 +1446,28 @@ func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, en
918 1446
 	return
919 1447
 }
920 1448
 
1449
+func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string) (list []*models.DrugCancelStock, total int64, err error) {
1450
+	db := readDb.Model(&models.DrugCancelStock{})
1451
+	db = db.Where("xt_drug_cancel_stock.org_id = ? AND xt_drug_cancel_stock.status = 1", orgId)
1452
+	if len(keywords) > 0 {
1453
+		likeKey := "%" + keywords + "%"
1454
+		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_cancel_stock.creater")
1455
+		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_cancel_stock.manufacturer")
1456
+		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_cancel_stock.order_number LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_cancel_stock.id")
1457
+	}
1458
+
1459
+	if startTime > 0 {
1460
+		db = db.Where("xt_drug_cancel_stock.opera_time >=?", startTime)
1461
+	}
1462
+	if endTime > 0 {
1463
+		db = db.Where("xt_drug_cancel_stock.opera_time<= ?", endTime)
1464
+	}
1465
+	db = db.Count(&total)
1466
+	offset := (page - 1) * limit
1467
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_cancel_stock.ctime desc").Find(&list).Error
1468
+	return
1469
+}
1470
+
921 1471
 func DeleteCancelStock(ids []string) (err error) {
922 1472
 	ut := writeDb.Begin()
923 1473
 	err = ut.Model(&models.CancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -934,27 +1484,64 @@ func DeleteCancelStock(ids []string) (err error) {
934 1484
 	return
935 1485
 }
936 1486
 
1487
+func DeleteDrugCancelStock(ids []string) (err error) {
1488
+	ut := writeDb.Begin()
1489
+	err = ut.Model(&models.DrugCancelStock{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1490
+	if err != nil {
1491
+		ut.Rollback()
1492
+		return
1493
+	}
1494
+	err = ut.Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1495
+	if err != nil {
1496
+		ut.Rollback()
1497
+		return
1498
+	}
1499
+	ut.Commit()
1500
+	return
1501
+}
1502
+
937 1503
 func UpDateCancleStockStatus(id int64) (err error) {
938 1504
 	err = readDb.Model(&models.CancelStockInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
939 1505
 	return
940 1506
 }
941 1507
 
1508
+func UpDateDrugCancleStockStatus(id int64) (err error) {
1509
+	err = readDb.Model(&models.DrugCancelStockInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1510
+	return
1511
+}
1512
+
942 1513
 func EditCancelStock(sales models.CancelStock) {
943 1514
 	err = readDb.Model(&models.CancelStock{}).Where("id = ? AND status = 1", sales.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "return_time": sales.ReturnTime, "dealer": sales.Dealer, "manufacturer": sales.Manufacturer}).Error
944 1515
 
945 1516
 }
946 1517
 
1518
+func EditDrugCancelStock(sales models.DrugCancelStock) {
1519
+	err = readDb.Model(&models.DrugCancelStock{}).Where("id = ? AND status = 1", sales.ID).Update(map[string]interface{}{"mtime": time.Now().Unix(), "return_time": sales.ReturnTime, "dealer": sales.Dealer, "manufacturer": sales.Manufacturer}).Error
1520
+
1521
+}
1522
+
947 1523
 func FindCancelStockById(id int64) (cancelStock models.CancelStock, err error) {
948 1524
 	err = readDb.Model(&models.CancelStock{}).Where("id = ? AND status = 1", id).First(&cancelStock).Error
949 1525
 	return cancelStock, err
950 1526
 
951 1527
 }
952 1528
 
1529
+func FindDrugCancelStockById(id int64) (cancelStock models.DrugCancelStock, err error) {
1530
+	err = readDb.Model(&models.DrugCancelStock{}).Where("id = ? AND status = 1", id).First(&cancelStock).Error
1531
+	return cancelStock, err
1532
+
1533
+}
1534
+
953 1535
 func UpDateCancelStockInfo(info *models.CancelStockInfo) (err error) {
954 1536
 	err = writeDb.Save(&info).Error
955 1537
 	return err
956 1538
 }
957 1539
 
1540
+func UpDateDrugCancelStockInfo(info *models.DrugCancelStockInfo) (err error) {
1541
+	err = writeDb.Save(&info).Error
1542
+	return err
1543
+}
1544
+
958 1545
 func FindWarehouseOutList(org_id int64, types int64) (list []*models.WarehouseOut, err error) {
959 1546
 	err = readDb.Model(&models.WarehouseOut{}).Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ? ", org_id).Where("org_id = ? AND status = 1 AND type = ?", org_id, types).Find(&list).Error
960 1547
 	return list, err