base_resource_use.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. package entity
  2. import (
  3. "errors"
  4. . "app.yhyue.com/moapp/jybase/common"
  5. . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/db"
  6. )
  7. var Base_resource_use = base_resource_use{}
  8. //资源充值/消耗表
  9. type base_resource_use struct {
  10. Id int
  11. Appid string
  12. Ent_id int64 //企业id
  13. User_id int64 //用户id
  14. Function_code string //功能代码
  15. Add_count int //新增数量
  16. Surplus_count int //剩余数量
  17. Deduction_count int //扣除数量
  18. }
  19. //查找最新一条的权益使用记录
  20. func (b *base_resource_use) FindLastOneByEntId(appid, function_code string, ent_id int64) (*base_resource_use, error) {
  21. list := Mysql_BaseService.SelectBySql(`select * from base_resource_use where appid=? and function_code=? and ent_id=? limit 1`, appid, function_code, ent_id)
  22. if list == nil {
  23. return nil, errors.New("find error")
  24. }
  25. if list != nil && len(*list) == 1 {
  26. return JsonUnmarshal((*list)[0], &base_resource_use{}).(*base_resource_use), nil
  27. }
  28. return nil, nil
  29. }