user_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package manage
  2. import (
  3. "log"
  4. sutil "sfbase/utils"
  5. "sfis/utils"
  6. "testing"
  7. "time"
  8. )
  9. /*var (
  10. product1 = &model.Product{
  11. BaseModel: model.BaseModel{ID: 1003},
  12. Name: "行业招标数据",
  13. Path: "/path1",
  14. UnitPrice: 50, //单价精确到分 5毛
  15. MinUnit: 1, //最小单位1,即 5毛/条
  16. ProductType: 1, //产品类型 0-按次 1-按条
  17. TestNum: 100,
  18. }
  19. product2 = &model.Product{
  20. Name: "中国移动招标数据",
  21. Path: "/path2",
  22. UnitPrice: 1500, //单价精确到分 15快
  23. MinUnit: 1, //最小单位1,即 15快/次
  24. ProductType: 0, //产品类型 0-按次 1-按条
  25. TestNum: 500,
  26. }
  27. )*/
  28. func init() {
  29. //todo init connection db operation
  30. }
  31. func Test_CreateUser(t *testing.T) {
  32. //log.Println("devUserCreate testing......")
  33. appID := utils.GetAppID(time.Now().Unix())
  34. secretKey := sutil.GetComplexRandom(8, 3, 5)
  35. log.Printf("create successful appID:[%s],secretKey:[%s]", appID, secretKey)
  36. //创建用户、给用户开通接口产品时候有以下几种情况
  37. //1.线上给账户充值10000块(user_account),不去实际购买产品,无购买记录,用户产品表无剩余量(left_num为0).此时又分两种情况
  38. //1.1 按次扣账户余额
  39. //1.2 按量扣账户余额
  40. //appID := ""
  41. //tradeMoney := 1 * 100 * 10000 //充值1万块钱
  42. }
  43. func chooseUserProduct(appID string, tradeMoney int) {
  44. }