package paymentinfo import ( . "dashoo.cn/utils/db" "github.com/go-xorm/xorm" "strconv" ) type PaymentService struct { ServiceBase } func GetPaymentService(xormEngine *xorm.Engine) *PaymentService { s := new(PaymentService) s.DBE = xormEngine return s } func (s *PaymentService) GetPaymentinfoList(pageIndex, itemsPerPage int64, order string, asc string, entitiesPtr interface{}, where string) (total int64) { var err error var resultsSlice []map[string][]byte sqlconunt := "SELECT COUNT(Id) FROM OilPaymentInfo WHERE IsPay = '1' " sql := "SELECT c.SupplierTypeCode,c.SupplierTypeName,s.SupplierName,p.* " + "FROM OilPaymentInfo p " + "LEFT JOIN OilSupplier s ON p.SupplierId = s.Id " + "LEFT JOIN OilSupplierCert c ON p.SupplierCertId = c.Id " + "WHERE "+ where + " Order By " + order + asc + " Limit " + strconv.Itoa(int(itemsPerPage)) +" OFFSET " + strconv.Itoa((int(pageIndex)-1)*int(itemsPerPage)) resultsSlice, err = s.DBE.Query(sqlconunt) err = s.DBE.SQL(sql).Find(entitiesPtr) LogError(err) if len(resultsSlice) > 0 { results := resultsSlice[0] for _, value := range results { total, err = strconv.ParseInt(string(value), 10, 64) LogError(err) break } } return total } func (s *PaymentService) GetPaymentinfoById(Id string, entitiesPtr interface{}) (err error) { sql := "SELECT c.SupplierTypeCode,c.SupplierTypeName,s.SupplierName,p.* " + "FROM OilPaymentInfo p " + "LEFT JOIN OilSupplier s ON p.SupplierId = s.Id " + "LEFT JOIN OilSupplierCert c ON p.SupplierCertId = c.Id " + "WHERE p.Id="+ Id err = s.DBE.SQL(sql).Find(entitiesPtr) LogError(err) return err } // Amount 缴费金额 PayType 缴费类型 1 准入缴费 2 年审缴费 func (s *PaymentService) AddPaymentinfo(SupplierId int, SupplierCertId int, Amount float64, PayType string)(err error){ //var err error sql := "INSERT INTO OilPaymentInfo (SupplierId, SupplierCertId, Amount, PayType) VALUES" + "(? ,? , ?, ?)" _,err = s.DBE.Exec(sql, SupplierId, SupplierCertId, Amount, PayType) return err }