Browse Source

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

csx 2 years ago
parent
commit
7e8adb5fce

+ 3 - 2
controllers/supply_order_api_contorller.go View File

@@ -454,14 +454,15 @@ func (this *SupplyOrderApiController) DelSupply() {
454 454
 	supply := models.SpSupplierName{
455 455
 		ID: suid,
456 456
 	}
457
-	err := service.DelSupply(supply, orgId)
457
+	shiwu, err := service.DelSupply(supply, orgId)
458 458
 	if err != nil {
459 459
 		utils.ErrorLog(err.Error())
460 460
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
461 461
 		return
462 462
 	}
463 463
 	this.ServeSuccessJSON(map[string]interface{}{
464
-		"list": "删除成功",
464
+		"list":  "删除成功",
465
+		"shiwu": shiwu,
465 466
 	})
466 467
 	return
467 468
 }

+ 10 - 10
models/supply.models.go View File

@@ -2,16 +2,16 @@ package models
2 2
 
3 3
 //供应商联系人
4 4
 type SpSupplierContacts struct {
5
-	ID           int64  `gorm:"column:id" json:"id" from:"id"`
6
-	Name         string `gorm:"column:name" json:"name" from:"name"`
7
-	Phone        string `gorm:"column:phone" json:"phone" from:"phone"`
8
-	Address      string `gorm:"column:address" json:"address" from:"address"`
9
-	IsFirst      int64  `gorm:"column:is_first" json:"is_first" from:"is_first"`
10
-	SupplierCode string `gorm:"column:supplier_code" json:"supplier_code" from:"supplier_code"`
11
-	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" from:"user_org_id"`
12
-	Status       int64  `gorm:"column:status" json:"status" from:"status"`
13
-	Ctime        int64  `gorm:"column:ctime" json:"ctime" from:"ctime"`
14
-	Mtime        int64  `gorm:"column:mtime" json:"mtime" from:"mtime"`
5
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
6
+	Name         string `gorm:"column:name" json:"name" form:"name"`
7
+	Phone        string `gorm:"column:phone" json:"phone" form:"phone"`
8
+	Address      string `gorm:"column:address" json:"address" form:"address"`
9
+	IsFirst      int64  `gorm:"column:is_first" json:"is_first" form:"is_first"`
10
+	SupplierCode string `gorm:"column:supplier_code" json:"supplier_code" form:"supplier_code"`
11
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
12
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
13
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
14
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
15 15
 }
16 16
 
17 17
 func (SpSupplierContacts) TableName() string {

+ 8 - 6
service/supply_service.go View File

@@ -21,7 +21,7 @@ func GetSupplyList(ctype int64, page int64, limit int64, keyword string, orgid i
21 21
 	if len(keyword) > 0 {
22 22
 		keyword = "%" + keyword + "%" //联系人
23 23
 		db = db.Joins("left join xt_supplier_contacts on xt_supplier_contacts.supplier_code = xt_supplier_name.supplier_code")
24
-		db = db.Where("xt_supplier_contacts.name like ? or xt_supplier_name.supplier_code like ? or xt_supplier_name.supplier_name like ? ", keyword, keyword, keyword).Group("xt_supplier_name.id")
24
+		db = db.Where("xt_supplier_contacts.status = 1 and xt_supplier_contacts.user_org_id = ? and xt_supplier_contacts.name like ? or xt_supplier_name.supplier_code like ? or xt_supplier_name.supplier_name like ? ", orgid, keyword, keyword, keyword).Group("xt_supplier_name.id")
25 25
 	}
26 26
 	if ctype > 0 {
27 27
 		db = db.Where("xt_supplier_name.supplier_type = ?", ctype)
@@ -169,30 +169,32 @@ func GetSupplyAndContactOne(id, orgId int64) (supply models.SpSupplierName, cont
169 169
 }
170 170
 
171 171
 //删除供应商及联系人
172
-func DelSupply(supply models.SpSupplierName, orgId int64) error {
172
+func DelSupply(supply models.SpSupplierName, orgId int64) (shiwu string, err error) {
173 173
 	tx := XTWriteDB().Begin()
174 174
 	defer func() {
175 175
 		if err != nil {
176
+			shiwu = "失败"
176 177
 			tx.Rollback()
177 178
 		} else {
179
+			shiwu = "成功"
178 180
 			tx.Commit()
179 181
 		}
180 182
 	}()
181 183
 	//删除供应商
182
-	err := tx.Model(&supply).Update("status", 0).Error
184
+	err = tx.Model(&supply).Update("status", 0).Error
183 185
 	if err != nil {
184
-		return err
186
+		return shiwu, err
185 187
 	}
186 188
 	var spcode models.SpSupplierName
187 189
 	//获取供应商编号
188 190
 	err = tx.Model(&models.SpSupplierName{}).Select("supplier_code").Where("user_org_id = ? and id = ?", orgId, supply.ID).First(&spcode).Error
189 191
 	if err != nil {
190
-		return err
192
+		return shiwu, err
191 193
 	}
192 194
 	//删除联系人
193 195
 	err = tx.Model(&models.SpSupplierContacts{}).Where("supplier_code = ? and user_org_id = ?", spcode.SupplierCode, orgId).Update("status", 0).Error
194 196
 
195
-	return err
197
+	return shiwu, err
196 198
 }
197 199
 
198 200
 //保存供应商和联系人

+ 8 - 0
service/warhouse_service.go View File

@@ -526,6 +526,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
526 526
 			WarehouseInfoId:         warehouse.ID,
527 527
 			Count:                   deliver_number,
528 528
 			AdviceId:                advice.ID,
529
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
529 530
 		}
530 531
 
531 532
 		drugflow := models.DrugFlow{
@@ -552,6 +553,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
552 553
 			SystemTime:              advice.AdviceDate,
553 554
 			WarehousingDetailId:     warehouse.ID,
554 555
 			AdviceId:                advice.ID,
556
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
555 557
 		}
556 558
 
557 559
 		CreateDrugFlowOne(drugflow)
@@ -674,6 +676,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
674 676
 			Count:                   stock_number,
675 677
 			CountUnit:               drup.MinUnit,
676 678
 			AdviceId:                advice.ID,
679
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
677 680
 		}
678 681
 
679 682
 		drugflow := models.DrugFlow{
@@ -700,6 +703,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
700 703
 			SystemTime:              advice.AdviceDate,
701 704
 			WarehousingDetailId:     warehouse.ID,
702 705
 			AdviceId:                advice.ID,
706
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
703 707
 		}
704 708
 
705 709
 		CreateDrugFlowOne(drugflow)
@@ -2344,6 +2348,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2344 2348
 			WarehouseInfoId:         warehouse.ID,
2345 2349
 			Count:                   deliver_number,
2346 2350
 			AdviceId:                advice.ID,
2351
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
2347 2352
 		}
2348 2353
 
2349 2354
 		drugflow := models.DrugFlow{
@@ -2468,6 +2473,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2468 2473
 			Count:                   stock_number,
2469 2474
 			CountUnit:               drup.MinUnit,
2470 2475
 			AdviceId:                advice.ID,
2476
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
2471 2477
 		}
2472 2478
 
2473 2479
 		drugflow := models.DrugFlow{
@@ -2494,6 +2500,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2494 2500
 			SystemTime:              advice.RecordDate,
2495 2501
 			WarehousingDetailId:     warehouse.ID,
2496 2502
 			AdviceId:                advice.ID,
2503
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
2497 2504
 		}
2498 2505
 
2499 2506
 		CreateDrugFlowOne(drugflow)
@@ -2549,6 +2556,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2549 2556
 			BatchNumber:       warehouse.BatchNumber,
2550 2557
 			MaxUnit:           warehouse.MaxUnit,
2551 2558
 			WarehousingInfoId: warehouse.WarehousingInfoId,
2559
+			SupplyWarehouseId: warehouse.SupplyWarehouseId,
2552 2560
 		}
2553 2561
 		errThree := UpDateDrugWarehouseInfoByStock(&info)
2554 2562
 		if errThree != nil {