2
3

paymentinfoService.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package paymentinfo
  2. import (
  3. . "dashoo.cn/utils/db"
  4. "github.com/go-xorm/xorm"
  5. "strconv"
  6. )
  7. type PaymentService struct {
  8. ServiceBase
  9. }
  10. func GetPaymentService(xormEngine *xorm.Engine) *PaymentService {
  11. s := new(PaymentService)
  12. s.DBE = xormEngine
  13. return s
  14. }
  15. func (s *PaymentService) GetPaymentinfoList(pageIndex, itemsPerPage int64, order string, asc string, entitiesPtr interface{}, where string) (total int64) {
  16. var err error
  17. var resultsSlice []map[string][]byte
  18. sqlconunt := "SELECT COUNT(Id) FROM OilPaymentInfo WHERE IsPay = '1' "
  19. sql := "SELECT c.SupplierTypeCode,c.SupplierTypeName,s.SupplierName,p.* " +
  20. "FROM OilPaymentInfo p " +
  21. "LEFT JOIN OilSupplier s ON p.SupplierId = s.Id " +
  22. "LEFT JOIN OilSupplierCert c ON p.SupplierCertId = c.Id " +
  23. "WHERE "+ where +
  24. " Order By " + order + asc + " Limit " + strconv.Itoa(int(itemsPerPage)) +" OFFSET " + strconv.Itoa((int(pageIndex)-1)*int(itemsPerPage))
  25. resultsSlice, err = s.DBE.Query(sqlconunt)
  26. err = s.DBE.SQL(sql).Find(entitiesPtr)
  27. LogError(err)
  28. if len(resultsSlice) > 0 {
  29. results := resultsSlice[0]
  30. for _, value := range results {
  31. total, err = strconv.ParseInt(string(value), 10, 64)
  32. LogError(err)
  33. break
  34. }
  35. }
  36. return total
  37. }
  38. func (s *PaymentService) GetPaymentinfoById(Id string, entitiesPtr interface{}) (err error) {
  39. sql := "SELECT c.SupplierTypeCode,c.SupplierTypeName,s.SupplierName,p.* " +
  40. "FROM OilPaymentInfo p " +
  41. "LEFT JOIN OilSupplier s ON p.SupplierId = s.Id " +
  42. "LEFT JOIN OilSupplierCert c ON p.SupplierCertId = c.Id " +
  43. "WHERE p.Id="+ Id
  44. err = s.DBE.SQL(sql).Find(entitiesPtr)
  45. LogError(err)
  46. return err
  47. }
  48. // Amount 缴费金额 PayType 缴费类型 1 准入缴费 2 年审缴费
  49. func (s *PaymentService) AddPaymentinfo(SupplierId int, SupplierCertId int, Amount float64, PayType string)(err error){
  50. //var err error
  51. sql := "INSERT INTO OilPaymentInfo (SupplierId, SupplierCertId, Amount, PayType) VALUES" +
  52. "(? ,? , ?, ?)"
  53. _,err = s.DBE.Exec(sql, SupplierId, SupplierCertId, Amount, PayType)
  54. return err
  55. }