123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598 |
- package service
-
- import (
- "XT_New/models"
- "github.com/jinzhu/gorm"
- "strconv"
- "time"
- )
-
-
- func DelSupply(supply models.SpSupplierName) error {
- err := XTWriteDB().Model(&supply).Update("status", 0).Error
- return err
- }
-
-
- func SaveSupplyAndContact(thisStockIn []interface{}, orgId, supplierType, tcreater int64, supplierCode, supplierName, number, bank, bankAccount string, vatRate float64) error {
- tx := XTWriteDB().Begin()
- defer func() {
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- for _, item := range thisStockIn {
- items := item.(map[string]interface{})
- name := items["name"].(string)
- phone := items["phone"].(string)
- address := items["address"].(string)
- isfirst, _ := strconv.ParseInt(items["isfirst"].(string), 10, 64)
-
- spcontacts := models.SpSupplierContacts{
- Name: name,
- Phone: phone,
- Address: address,
- IsFirst: isfirst,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
- err = SaveContacts(spcontacts, tx)
- if isfirst == 1 {
- var spconid []*models.SpSupplierContacts
- spconid, err = SaveContactsId(tx)
-
- if err != nil {
- return err
- }
- tmpid := spconid[0].ID
-
- supply := models.SpSupplierName{
- SupplierCode: supplierCode,
- SupplierName: supplierName,
- SupplierType: supplierType,
- VatRate: vatRate,
- Number: number,
- Bank: bank,
- BankAccount: bankAccount,
- UserOrgId: orgId,
- Status: 1,
- ContactsId: tmpid,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Creater: tcreater,
- Modify: tcreater,
- }
- err = SaveSupply(supply, tx)
- if err != nil {
- return err
- }
-
- }
- if err != nil {
- return err
- }
- }
- return err
- }
-
-
- func GetSuppliyCode() (spcode []*models.SpSupplierName, err error) {
-
- err = XTReadDB().Model(&models.SpSupplierName{}).Select("supplier_code").Where("supplier_code like 'gys%' ").Order("supplier_code desc").First(&spcode).Error
- return spcode, err
- }
-
-
- func FindSupplierName(supplierName string) (sbool bool, err error) {
- var total int
- err = XTReadDB().Model(&models.SpSupplierName{}).Where("supplier_name = ? and status = 1", supplierName).Count(&total).Error
- if total != 0 {
- sbool = true
- } else {
- sbool = false
- }
- return sbool, err
- }
-
-
- func SaveSupply(supply models.SpSupplierName, tx *gorm.DB) error {
- err := tx.Create(&supply).Error
- return err
- }
-
-
- func SaveContactsId(tx *gorm.DB) (spconid []*models.SpSupplierContacts, err error) {
- err = tx.Model(&models.SpSupplierContacts{}).Select("id").Order("id desc").First(&spconid).Error
- return
- }
-
-
- func SaveContacts(spcontacts models.SpSupplierContacts, tx *gorm.DB) error {
- err := tx.Create(&spcontacts).Error
- return err
- }
-
- func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
-
- db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
-
- if orgid > 0 {
- db = db.Where("x.org_id = ?", orgid)
- }
-
- err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ? and (stock_max_number >0 or stock_min_number>0)", orgid).Find(&drug).Error
- return drug, err
- }
-
- func GetSupplyGoodList(orgid int64) (good []*models.SpGoodInformation, err error) {
-
- db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1")
-
- if orgid > 0 {
- db = db.Where("x.org_id = ?", orgid)
- }
-
- err = db.Preload("GoodWarehouseInfo", "status = 1 and org_id = ?", orgid).Find(&good).Error
- return good, err
- }
-
- func GetSupplierList(orgid int64) (suppler []*models.SpSupplierName, err error) {
-
- err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&suppler).Error
- return suppler, err
- }
-
- func FindAllSupplyOrder(orgid int64) (total int64, err error) {
-
- err = XTReadDB().Model(&models.SupplierWarehouseInfo{}).Where("user_org_id = ?", orgid).Count(&total).Error
- return total, err
- }
-
- func CreateSupplyWarehouse(info models.SupplierWarehouseInfo) error {
-
- err := XTWriteDB().Create(&info).Error
- return err
- }
-
- func FindLastSupplyWarehouseInfo(orgid int64) (models.SupplierWarehouseInfo, error) {
- info := models.SupplierWarehouseInfo{}
- err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Last(&info).Error
- return info, err
- }
-
- func CreateSupplyWarehousingOrder(order *models.SupplierWarehousingInfoOrder) error {
-
- err := XTWriteDB().Create(&order).Error
- return err
- }
-
- func GetAllPurchaseOrderList(check_id int64, startime int64, endtime int64, keyword string, page int64, limit int64, orgid int64) (info []*models.VmSupplierWarehouseInfo, total int64, err error) {
-
- db := XTReadDB().Model(&info).Where("sgj_xt.xt_supplier_warehouse_info.status = 1")
- likeKey := "%" + keyword + "%"
- offset := (page - 1) * limit
- if check_id > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_info.is_check = ?", check_id)
- }
- if startime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_info.record_date >= ?", startime)
- }
- if endtime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_info.record_date<=?", endtime)
- }
-
- if len(keyword) > 0 {
- db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_info.supplier_id")
- db = db.Where("sgj_xt.xt_supplier_warehouse_info.number like ? or sgj_xt.xt_supplier_name.supplier_name like ? ", likeKey, likeKey).Group("sgj_xt.xt_supplier_warehouse_info.id")
- }
- if orgid > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_info.user_org_id = ?", orgid)
- }
- err = db.Count(&total).Offset(offset).Limit(limit).Preload("SupplierWarehousingInfoOrder", "status= 1 and user_org_id = ?", orgid).Preload("SpSupplierWarehouseOut", "status = 1 and user_org_id =?", orgid).Find(&info).Error
- return info, total, err
- }
-
- func GetSupplyWarehousingOrderInfo(id int64) (order []*models.SupplierWarehousingInfoOrder, err error) {
-
- err = XTReadDB().Where("warehousing_id = ? and status = 1", id).Find(&order).Error
- return order, err
- }
-
- func GetSupplyWarehousingOrderInfoTwo(id int64, ids []string) (order []*models.SupplierWarehousingInfoOrder, err error) {
-
- err = XTReadDB().Where("warehousing_id = ? and status = 1 and project_id in(?)", id, ids).Find(&order).Error
- return order, err
- }
-
- func ModefySupplyWarehouseInfo(id int64, info models.SupplierWarehouseInfo) error {
-
- 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
- return err
- }
-
- func ModifySupplyWarehouseOrder(order *models.SupplierWarehousingInfoOrder) error {
-
- err := XTWriteDB().Model(&models.SupplierWarehousingInfoOrder{}).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{}).Updates(map[string]interface{}{"is_source": order.IsSource, "count": order.Count, "price": order.Price, "amount": order.Amount, "remark": order.Remark, "project_id": order.ProjectId, "supply_license_number": order.SupplyLicenseNumber, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "manufacturer_id": order.ManufacturerId}).Error
- return err
- }
-
- func UpdateSupplyWaresing(id int64, info models.SupplierWarehouseInfo) error {
-
- err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"is_check": info.IsCheck, "checker": info.Checker, "check_time": info.CheckTime, "mtime": time.Now().Unix()}).Error
- return err
- }
-
- func GetPurchaseOrderDetail(id int64) (models.SupplierWarehouseInfo, error) {
-
- info := models.SupplierWarehouseInfo{}
- err := XTReadDB().Model(&info).Where("id =? and status =1", id).Find(&info).Error
- return info, err
- }
-
- func FindAllSupplyWarehouseOutOrder(orgid int64) (total int64, err error) {
- err = XTReadDB().Model(&models.SpSupplierWarehouseOut{}).Where("user_org_id = ?", orgid).Count(&total).Error
- return total, err
- }
-
- func FindSupplyWarehouseOutById(orgid int64) (models.SpSupplierWarehouseOut, error) {
- out := models.SpSupplierWarehouseOut{}
- err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Last(&out).Error
- return out, err
- }
-
- func CreateSupplyWarehouseOut(out models.SpSupplierWarehouseOut) error {
-
- err := XTWriteDB().Create(&out).Error
- return err
- }
-
- func CreateSupplyWarehousOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
-
- err := XTWriteDB().Create(&order).Error
- return err
- }
-
- func GetSupplyWarehouseOutById(id int64, user_org_id int64) (order []*models.SpSupplierWarehousingOutOrder, err error) {
-
- err = XTReadDB().Where("warehouse_out_id = ? and status = 1 and user_org_id = ?", id, user_org_id).Find(&order).Error
- return order, err
- }
-
- func GetAllGoodOderList(check_id int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (out []*models.VmSupplierWarehouseOut, total int64, err error) {
- db := XTReadDB().Model(&out).Where("sgj_xt.xt_supplier_warehouse_out.status = 1")
- likeKey := "%" + keyword + "%"
- offset := (page - 1) * limit
- if check_id > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_out.is_check = ?", check_id)
- }
- if startime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date >= ?", startime)
- }
- if endtime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_out.record_date<=?", endtime)
- }
-
- if len(keyword) > 0 {
- db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
- 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")
- }
- if orgid > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_out.user_org_id = ?", orgid)
- }
- 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
- return out, total, err
- }
-
- func GetGoodOrderDetail(id int64, orgid int64) (models.SpSupplierWarehouseOut, error) {
- out := models.SpSupplierWarehouseOut{}
- err := XTReadDB().Where("id = ? and user_org_id = ? and status = 1", id, orgid).Find(&out).Error
- return out, err
- }
-
- func UpdateGoodWarehouseOut(id int64, out models.SpSupplierWarehouseOut) error {
-
- 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
- return err
- }
-
- func UpdateGoodWarehouseOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
-
- 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
- return err
- }
-
- func DeletePurchOrder(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- err = XTWriteDB().Model(&models.SupplierWarehousingInfoOrder{}).Where("warehousing_id =? and user_org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- return err
- }
-
- func GetAllPurcaseOrderById(id int64, orgid int64) (order []*models.VSupplierWarehousingInfoOrder, err error) {
-
- err = XTReadDB().Model(&order).Where("warehousing_id = ? and user_org_id = ? and status =1", id, orgid).Find(&order).Error
- return order, err
- }
-
- func GetAllGoodOrderById(id int64, orgid int64) (order []*models.VSpSupplierWarehousingOutOrder, err error) {
- db := XTReadDB().Table("xt_supplier_warehousing_out_order as o").Where("o.status = 1")
- if id > 0 {
- db = db.Where("o.warehousing_id = ?", id)
- }
- if orgid > 0 {
- db = db.Where("o.user_org_id =?", orgid)
- }
- err = db.Select("o.id,o.order_number,o.project_id,o.count as count,o.supply_unit,o.is_source").Find(&order).Error
- return order, err
- }
-
- func GetAllGoodOrderByIdTwo(id int64, orgid int64) (order []*models.SpSupplierWarehousingOutOrder, err error) {
-
- err = XTReadDB().Where("warehousing_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&order).Error
- return order, err
- }
-
- func GetGoodOrderList(id int64, orgid int64) (info []*models.SpSupplierWarehouseOut, err error) {
-
- err = XTReadDB().Where("warehousing_id = ? and status = 1 and user_org_id = ?", id, orgid).Find(&info).Error
- return info, err
- }
-
- func GetReturnOrder(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"is_check": 2, "mtime": time.Now().Unix(), "check_time": 0, "checker": 0}).Error
- return err
- }
-
- func CheckGoodOrder(id int64, orgid int64, out models.SpSupplierWarehouseOut) error {
-
- 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
- return err
- }
-
- func ModefySupplyWarehousing(is_warehose int64, warehousing_id int64, orgid int64) error {
-
- 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
- return err
- }
-
- func GetAllDoctorSix(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
-
- err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = 1", orgid, appid).Find(&appRole).Error
- return appRole, err
- }
-
- func GetSingleDrugWarehouseOrder(record_date int64, orgid int64) (*models.DrugWarehouse, error) {
- warehouse := models.DrugWarehouse{}
- var err error
- err = XTReadDB().Model(&warehouse).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehouse).Error
- if err == gorm.ErrRecordNotFound {
- return nil, err
- }
- if err != nil {
- return nil, err
- }
- return &warehouse, nil
- }
-
- func GetSindleWarehouse(record_date int64, orgid int64) (*models.Warehousing, error) {
- warehousing := models.Warehousing{}
- var err error
- err = XTReadDB().Model(&warehousing).Where("warehousing_time = ? and org_id = ? and status = 1", record_date, orgid).Find(&warehousing).Error
- if err == gorm.ErrRecordNotFound {
- return nil, err
- }
- if err != nil {
- return nil, err
- }
- return &warehousing, nil
- }
-
- func GetLastWarehouseInfoByInfo(orgid int64) (models.Warehousing, error) {
- warehousing := models.Warehousing{}
- err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&warehousing).Error
- return warehousing, err
- }
-
- func GetSupplyCancelOrder(orgid int64) (total int64, err error) {
- err = XTReadDB().Model(&models.SpSupplierWarehouseCancel{}).Where("user_org_id = ?", orgid).Count(&total).Error
- return total, err
- }
-
- func CreateReturnCacelOrder(cancel models.SpSupplierWarehouseCancel) error {
-
- err := XTWriteDB().Create(&cancel).Error
- return err
- }
-
- func GetLastReturnCancelOrder(orgid int64) (models.SpSupplierWarehouseCancel, error) {
-
- cancel := models.SpSupplierWarehouseCancel{}
- err := XTReadDB().Where("user_org_id =? and status = 1", orgid).Find(&cancel).Error
- return cancel, err
- }
-
- func CreateCancelReturnOrder(order *models.SpSupplierWarehousingCancelOrder) error {
-
- err := XTWriteDB().Create(&order).Error
- return err
- }
-
- func GetReturnCancelOrder(id int64, orgid int64) (models.SpSupplierWarehouseCancel, error) {
-
- cancel := models.SpSupplierWarehouseCancel{}
- err := XTReadDB().Where("id = ? and status= 1 and user_org_id =?", id, orgid).Find(&cancel).Error
- return cancel, err
- }
-
- func GetReturnCancelOrderList(id int64, orgid int64) (order models.SpSupplierWarehousingCancelOrder, err error) {
-
- err = XTReadDB().Where("warehouse_cancel_id = ? and user_org_id =? and status = 1", id, orgid).Find(&order).Error
- return order, err
- }
-
- func GetAllGoodReturnOrderList(checkid int64, keyword string, page int64, limit int64, startime int64, endtime int64, orgid int64) (order []*models.VmSpSupplierWarehouseCancel, total int64, err error) {
-
- db := XTReadDB().Table("sgj_xt.xt_supplier_warehouse_cancel").Where("sgj_xt.xt_supplier_warehouse_cancel.status = 1")
- likeKey := "%" + keyword + "%"
- offset := (page - 1) * limit
- if checkid > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.is_check = ?", checkid)
- }
- if len(keyword) > 0 {
- db = db.Joins("join sgj_xt.xt_supplier_name on sgj_xt.xt_supplier_name.id = sgj_xt.xt_supplier_warehouse_out.supplier_id")
- 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")
- }
- if startime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date >= ?", startime)
- }
-
- if endtime > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.record_date <= ?", endtime)
- }
- if orgid > 0 {
- db = db.Where("sgj_xt.xt_supplier_warehouse_cancel.user_org_id = ?", orgid)
- }
- err = db.Count(&total).Offset(offset).Limit(limit).Preload("SpSupplierWarehousingCancelOrder", "status= 1 and user_org_id = ?", orgid).Find(&order).Error
- return order, total, err
- }
-
- func GetGoodReturnDetail(id int64, orgid int64) (models.VmSpSupplierWarehouseCancel, error) {
- cancel := models.VmSpSupplierWarehouseCancel{}
- db := XTReadDB().Model(&cancel).Where("status = 1")
- if id > 0 {
- db = db.Where("id = ?", id)
- }
- if orgid > 0 {
- db = db.Where("user_org_id = ?", orgid)
- }
- err := db.Find(&cancel).Error
- return cancel, err
- }
-
- func GetGoodReturnOrderDetail(id int64, orgid int64) (order []*models.SpSupplierWarehousingCancelOrder, err error) {
-
- db := XTReadDB().Model(&order).Where("status =1")
- if id > 0 {
- db = db.Where("warehouse_cancel_id = ?", id)
- }
- if orgid > 0 {
- db = db.Where("user_org_id = ?", orgid)
- }
- err = db.Find(&order).Error
- return order, err
- }
-
- func UpdateWarehouseCancelOrder(order *models.SpSupplierWarehousingCancelOrder) error {
-
- 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
- return err
- }
-
- func UpdateWarehouseCancel(id int64, cancel models.SpSupplierWarehouseCancel) error {
-
- 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
- return err
- }
-
- func GetSupplyCancelOrderById(warehouse_out_id int64, orgid int64) (*models.SpSupplierWarehouseCancel, error) {
- cancel := models.SpSupplierWarehouseCancel{}
- var err error
- err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", warehouse_out_id, orgid).Find(&cancel).Error
- if err == gorm.ErrRecordNotFound {
- return nil, err
- }
- if err != nil {
- return nil, err
- }
- return &cancel, nil
- }
-
- func UpdateSupplyGoodOrder(id int64, out models.SpSupplierWarehouseOut) error {
-
- 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
- return err
- }
-
- func UpdateDrugSupplyWarehousingInfo(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
- return err
- }
-
- func UpdateDrugSupplyFlow(id int64, orgid int64) error {
-
- 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
- return err
- }
-
- func UpdateGoodSupplyWarehousingInfo(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
- return err
- }
-
- func UpdateGoodSupplyFlow(id int64, orgid int64) error {
-
- 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
- return err
- }
-
- func GetDrugSupplyWarehousingById(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
-
- err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
- return info, err
- }
-
- func UpdateSupplyWarehousing(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
- return err
- }
-
- func GetGoodSupplyWarehousingById(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
-
- err = XTReadDB().Where("supply_warehouse_id <> ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
- return info, err
- }
-
- func UpdateGoodWarehousing(id int64, orgid int64) error {
- err := XTWriteDB().Model(&models.Warehousing{}).Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
- return err
- }
-
- func UpdateSupplyWarehousingById(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and user_org_id =? and status = 1", id, orgid).Updates(map[string]interface{}{"is_warehouse": 1}).Error
- return err
- }
-
- func DeleteGoodOrder(id int64, orgid int64) error {
-
- err := XTWriteDB().Model(&models.SpSupplierWarehouseOut{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0}).Error
-
- 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
- return err
- }
- func GetSupplyCancelWarehouse(id int64, orgid int64) (cancel []*models.SpSupplierWarehouseCancel, err error) {
-
- err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
- return cancel, err
- }
-
- func GetGoodOrderListById(id int64, orgid int64) (out []*models.VmSpSupplierWarehousingOutOrder, err error) {
-
- err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&out).Error
- return out, err
- }
-
- func GetGoodCanceListById(id int64, orgid int64) (cancel []*models.VmSpSupplierWarehousingCancelOrder, err error) {
-
- err = XTReadDB().Where("warehouse_out_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&cancel).Error
- return cancel, err
- }
|