package oilsupplier import ( "encoding/json" "strconv" "time" "dashoo.cn/backend/api/business/bankapi" "dashoo.cn/backend/api/business/oilsupplier/supplier" "dashoo.cn/backend/api/business/oilsupplier/suppliercert" "dashoo.cn/backend/api/business/paymentinfo" . "dashoo.cn/backend/api/controllers" "dashoo.cn/business2/permission" "dashoo.cn/utils" //"wayne-master/src/backend/util/integer" ) type PaymentInfoController struct { BaseController } // @Title 获取列表 // @Description get user by token // @Success 200 {object} []paymentinfo.PaymentinfoList // @router /list [get] func (this *PaymentInfoController) GetEntityList() { //获取分页信息 page := this.GetPageInfoForm() orderby := "p.Id" where := " 1=1 " asc := " DESC" SupplierTypeCode := this.GetString("SupplierTypeCode") SupplierName := this.GetString("SupplierName") IsPay := this.GetString("IsPay") if IsPay != "" { where = where + " and p.IsPay = '" + IsPay + "'" } if SupplierTypeCode != "" { where = where + " and c.SupplierTypeCode like '%" + SupplierTypeCode + "%'" } if SupplierName != "" { where = where + " and s.SupplierName like '%" + SupplierName + "%'" } //svc := suppliercert.GetOilSupplierCertService(utils.DBE) //var list []suppliercert.OilSupplierCert svcPerm := permission.GetPermissionService(utils.DBE) isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord") if !svcPerm.IsAdmin(this.User.Id) && !isauth { where = where + " and p.CreateUserId = '" + this.User.Id + "'" } var paylist []paymentinfo.PaymentinfoList svc := paymentinfo.GetPaymentService(utils.DBE) total := svc.GetPaymentinfoList(page.CurrentPage, page.Size, orderby, asc, &paylist, where) //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where) var datainfo DataInfo datainfo.Items = paylist datainfo.CurrentItemCount = total datainfo.PageIndex = page.CurrentPage datainfo.ItemsPerPage = page.Size this.Data["json"] = &datainfo this.ServeJSON() } // @Title 获取列表 // @Description get user by token // @Success 200 {object} []paymentinfo.PaymentinfoList // @router /get-bill-list [post] func (this *PaymentInfoController) GetBillList() { var icbcBillQueryParam bankapi.ICBCBillQueryParam var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &icbcBillQueryParam) var supplierEntity supplier.OilSupplier supplierSvc := supplier.GetOilSupplierService(utils.DBE) supplierWhere := "1=1 and CommercialNo='" + icbcBillQueryParam.CommercialNo + "'" supplierSvc.DBE.Where(supplierWhere).Get(&supplierEntity) var billList []paymentinfo.OilPaymentInfo billWhere := "1=1 and SupplierId='" + strconv.Itoa(supplierEntity.Id) + "'" svc := paymentinfo.GetPaymentService(utils.DBE) svc.DBE.Where(billWhere).OrderBy("Id DESC").Find(&billList) //获取分页信息 //page := this.GetPageInfoForm() var datainfo DataInfo datainfo.Items = billList //datainfo.CurrentItemCount = integer.Int2Int64(len(billList)) // datainfo.CurrentItemCount = 10 datainfo.CurrentItemCount = int64(len(billList)) datainfo.PageIndex = 1 datainfo.ItemsPerPage = 1000 this.Data["json"] = &datainfo this.ServeJSON() } // @Title 获取实体 // @Description 获取实体 // @Success 200 {object} paymentinfo.PaymentinfoList // @router /get/:id [get] func (this *PaymentInfoController) GetEntity() { Id := this.Ctx.Input.Param(":id") var model []paymentinfo.PaymentinfoList svc := paymentinfo.GetPaymentService(utils.DBE) svc.GetPaymentinfoById(Id, &model) this.Data["json"] = &model[0] this.ServeJSON() } // @Title 修改实体 // @Description 修改实体 // @Param body body paymentinfo.Paymentinfo // @Success 200 {object} controllers.Request // @router /update/:id [post] func (this *PaymentInfoController) UpdateEntity() { id := this.Ctx.Input.Param(":id") var errinfo ErrorInfo if id == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } var model paymentinfo.OilPaymentInfo svc := paymentinfo.GetPaymentService(utils.DBE) var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) model.ModifiedOn = time.Now() model.ModifiedBy = this.User.Realname model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() cols := []string{ "IsPay", "PayMode", "PayDate", "BankSerialNum", "BankName", "Remark", "ModifiedOn", "ModifiedUserId", "ModifiedBy", } _, err := svc.UpdateEntityByIdCols(id, &model, cols) if model.IsPay == "2" { var certentity suppliercert.OilSupplierCert certentity.Status = suppliercert.STOREING_STATUS certentity.Step = 5 cols = []string{ "Status", "Step", } _, err = svc.UpdateEntityByIdCols(strconv.Itoa(model.SupplierCertId), &certentity, cols) } if err == nil { errinfo.Message = "修改成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } }