| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/paymentinfo"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- "encoding/json"
- "strconv"
- "time"
- )
- 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
- 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 获取实体
- // @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()
- }
- }
|