Explorar o código

[20250514]财务结算bug登录

lin-jim-leon hai 2 días
pai
achega
b50d4e2147
Modificáronse 41 ficheiros con 724 adicións e 470 borrados
  1. 31 11
      db/finance.go
  2. 11 0
      db/job.go
  3. 13 0
      db/subaccount.go
  4. 1 1
      db/user.go
  5. 58 57
      handler/confirmInvoice.go
  6. 1 0
      handler/confirmsupplierInvoice.go
  7. 1 0
      handler/confirmwithdraw.go
  8. 57 56
      handler/getBankInfo.go
  9. 2 0
      handler/getInvoicevalue.go
  10. 64 60
      handler/get_userInfo.go
  11. 57 0
      handler/getallwithdrawvalue.go
  12. 1 0
      handler/getbilllist.go
  13. 2 0
      handler/getinvoiceinfo.go
  14. 1 0
      handler/getinvoicelist.go
  15. 1 0
      handler/getsupplierinvoicelist.go
  16. 2 0
      handler/getsupplierinvoicevalue.go
  17. 1 0
      handler/getsupplierwithdrawlist.go
  18. 2 2
      handler/getwithdrawvalue.go
  19. 57 56
      handler/login.go
  20. 1 1
      handler/refusecharge.go
  21. 2 1
      handler/refusesupplierInvoice.go
  22. 1 0
      handler/refusewithdraw.go
  23. 1 0
      handler/setinvoiceinfo.go
  24. 3 2
      handler/supplierwithdrawprevalue.go
  25. 3 2
      handler/talentwithdrawprevalue.go
  26. 20 0
      model/http_model/GetAllwithdrawValueRequest.go
  27. 1 1
      model/http_model/SubAccountDetail.go
  28. 30 21
      model/http_model/code_login.go
  29. 10 10
      model/http_model/common_response.go
  30. 1 0
      model/http_model/create_sub_account.go
  31. 1 1
      model/http_model/getinvoicelistrequest.go
  32. 1 1
      model/http_model/getksauthorization.go
  33. 1 1
      model/http_model/getprerechargelistrequest.go
  34. 1 1
      model/http_model/getsupplierinvoicerequest.go
  35. 4 6
      model/http_model/getsupplierwithdrawlistrequest.go
  36. 1 1
      model/http_model/gettalentwithdrawlsitrequest.go
  37. 1 1
      model/http_model/job_detail.go
  38. 1 0
      model/http_model/jobshow.go
  39. 30 21
      model/http_model/userInfo.go
  40. 9 8
      route/init.go
  41. 238 148
      service/login_auth.go

+ 31 - 11
db/finance.go

@@ -125,7 +125,7 @@ func GetRechargeValue(ctx context.Context, request http_model.GetRechargeValueRe
 	var rechargeValue float64
 	db := GetReadDB(ctx)
 	var rechargelist []gorm_model.YounggeeRechargeRecord
-	err := db.Model(gorm_model.YounggeeRechargeRecord{}).Where("status = ?", request.Status).Find(rechargelist).Error
+	err := db.Model(gorm_model.YounggeeRechargeRecord{}).Where("status = ?", request.Status).Find(&rechargelist).Error
 	if err != nil {
 		return nil, err
 	}
@@ -141,7 +141,7 @@ func GetInvoiceValue(ctx context.Context, request http_model.GetInvoiceValueRequ
 	var invoicevalue float64
 	db := GetReadDB(ctx)
 	var invoicelist []gorm_model.YounggeeInvoiceRecord
-	err := db.Model(gorm_model.YounggeeInvoiceRecord{}).Where("status = ?", request.Status).Find(invoicelist).Error
+	err := db.Model(gorm_model.YounggeeInvoiceRecord{}).Where("status = ?", request.Status).Find(&invoicelist).Error
 	if err != nil {
 		return nil, err
 	}
@@ -153,7 +153,7 @@ func GetInvoiceValue(ctx context.Context, request http_model.GetInvoiceValueRequ
 	return InvoiceValue, err
 }
 
-func GetSupplierWithdrawPrevalue(ctx context.Context, request http_model.GetSupplierWithdrawPrevalueRequest) (*http_model.WithdrawValue, error) {
+func GetSupplierWithdrawPrevalue(ctx context.Context) (*http_model.WithdrawValue, error) {
 	var withdrawvalue float64
 	db := GetReadDB(ctx)
 	var withdrawlist []gorm_model.YounggeeSupplierWithdraw
@@ -170,12 +170,12 @@ func GetSupplierWithdrawPrevalue(ctx context.Context, request http_model.GetSupp
 	}, err
 }
 
-func GetTalentWithdrawPrevalue(ctx context.Context, request http_model.GetTalentWithdrawPrevalueRequest) (*http_model.TalentWithdrawValue, error) {
+func GetTalentWithdrawPrevalue(ctx context.Context) (*http_model.TalentWithdrawValue, error) {
 	var withdrawvalue float64
 	db := GetReadDB(ctx)
 	var withdrawlist []gorm_model.YounggeeWithdrawRecord
 	// 获取所有符合条件的发票
-	err := db.Model(gorm_model.YounggeeSupplierWithdraw{}).Where("withdraw_status =1").Find(&withdrawlist).Error
+	err := db.Model(gorm_model.YounggeeWithdrawRecord{}).Where("status =1").Find(&withdrawlist).Error
 	if err != nil {
 		return nil, err
 	}
@@ -203,12 +203,32 @@ func GetWithDrawInfo(ctx context.Context, request http_model.GetWithDrawInfoRequ
 	return res, nil
 }
 
-func GetWithdrawValue(ctx context.Context, request http_model.GetWithdrawValueRequest) (*http_model.ALlWithdrawValue, error) {
+func GetAllwithdrawValue(ctx context.Context) (*http_model.GetAllwithdrawValueData, error) {
+	allvalues, err := GetWithdrawValue(ctx)
+	if err != nil {
+		return nil, err
+	}
+	talentvalue, err := GetTalentWithdrawPrevalue(ctx)
+	if err != nil {
+		return nil, err
+	}
+	suppliervalue, err := GetSupplierWithdrawPrevalue(ctx)
+	if err != nil {
+		return nil, err
+	}
+	return &http_model.GetAllwithdrawValueData{
+		WithdrawValue:       suppliervalue.WithdrawValue,
+		TalentWithdrawvalue: talentvalue.TalentWithdrawValue,
+		AccumulateValue:     allvalues.AllWithdrawValue,
+	}, err
+}
+
+func GetWithdrawValue(ctx context.Context) (*http_model.ALlWithdrawValue, error) {
 	var withdrawvalue float64
 	db := GetReadDB(ctx)
 	var withdrawlist []gorm_model.YounggeeWithdrawRecord
 	// 获取所有符合条件的发票
-	err := db.Model(gorm_model.YounggeeSupplierWithdraw{}).Where("withdraw_status =2").Find(&withdrawlist).Error
+	err := db.Model(gorm_model.YounggeeWithdrawRecord{}).Where("status =2").Find(&withdrawlist).Error
 	if err != nil {
 		return nil, err
 	}
@@ -235,7 +255,7 @@ func GetSupplierInvoiceValue(ctx context.Context, request http_model.GetSupplier
 	var invoicelist []gorm_model.YounggeeSupplierInvoice
 
 	// 获取所有符合条件的发票
-	err := db.Model(gorm_model.YounggeeSupplierInvoice{}).Where("status = ?", request.Status).Find(&invoicelist).Error
+	err := db.Model(gorm_model.YounggeeSupplierInvoice{}).Where("invoice_status = ?", request.Status).Find(&invoicelist).Error
 	if err != nil {
 		return nil, err
 	}
@@ -1058,9 +1078,9 @@ func GetSupplierWithdrawList(ctx context.Context, req http_model.GetSupplierWith
 			SupplierName:   supplier.SupplierName,
 			Name:           name,
 			WithDrawinfo:   withdrawinfo,
-			SubmitAt:       withdraw.SupplyTime,
-			AggreeAt:       withdraw.AgreeTime,
-			ReajectAt:      withdraw.RejectTime,
+			SubmitAt:       withdraw.SupplyTime.Format("2006-01-02 15:04:05"),
+			AggreeAt:       withdraw.AgreeTime.Format("2006-01-02 15:04:05"),
+			ReajectAt:      withdraw.RejectTime.Format("2006-01-02 15:04:05"),
 			ReajectReason:  withdraw.FailReson,
 			Taskinfo:       &taskinfo,
 			SupplierId:     supplier.SupplierId,

+ 11 - 0
db/job.go

@@ -146,10 +146,21 @@ func GetJobdDetail(ctx context.Context, req *http_model.JobShowRequest) (*http_m
 		FinancialPermission:  jobdetail.FinancialPermission,
 		UsercenterPermission: jobdetail.UsercenterPermission,
 		OperatePermission:    jobdetail.OperatePermission,
+		AccountId:            jobdetail.AccountId,
 	}
 	return response, nil
 }
 
+func GetJob(ctx context.Context, id int) (*gorm_model.YounggeeJob, error) {
+	db := GetReadDB(ctx)
+	var jobdetail gorm_model.YounggeeJob
+	err := db.Model(gorm_model.YounggeeJob{}).Where("job_id = ?", id).Find(&jobdetail).Error
+	if err != nil {
+		return nil, err
+	}
+	return &jobdetail, nil
+}
+
 func GetJobList(ctx context.Context, req *http_model.JobListRequest) (*http_model.JobListResponse, error) {
 	db := GetReadDB(ctx)
 	var jobs []gorm_model.YounggeeJob

+ 13 - 0
db/subaccount.go

@@ -21,7 +21,9 @@ func CreateSubAccount(ctx context.Context, req *http_model.CreateSubAccountReque
 	fmt.Println("now:", now)
 	younggee_user := gorm_model.YounggeeUser{
 		Phone:         req.PhoneNumber,
+		Password:      req.Password,
 		User:          req.SubAccountName,
+		Username:      req.SubAccountName,
 		Role:          "5",
 		LastLoginTime: now,
 		UpdatedAt:     now,
@@ -236,3 +238,14 @@ func GetSubAccdDetail(ctx context.Context, req *http_model.SubAccShowRequest) (*
 	}
 	return response, nil
 }
+
+// FindSubAccountById 根据手机号码查询子账号
+func FindSubAccountById(ctx context.Context, id int64) (*gorm_model.YounggeeSubAccount, error) {
+	db := GetReadDB(ctx)
+	var subaccount gorm_model.YounggeeSubAccount
+	err := db.Model(gorm_model.YounggeeSubAccount{}).Where("user_id = ?", id).Find(&subaccount).Error
+	if err != nil {
+		return nil, err
+	}
+	return &subaccount, nil
+}

+ 1 - 1
db/user.go

@@ -21,7 +21,7 @@ import (
 func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
 	user := &gorm_model.YounggeeUser{}
-	err := db.Model(user).Where("user = ?", User).First(user).Error
+	err := db.Model(user).Where("user = ? ", User).First(user).Error
 	if err != nil {
 		if err == gorm.ErrRecordNotFound {
 			fmt.Println("record not found")

+ 58 - 57
handler/confirmInvoice.go

@@ -1,57 +1,58 @@
-package handler
-
-import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
-	"youngee_m_api/consts"
-	"youngee_m_api/db"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/util"
-)
-
-func WrapConfirmInvoiceHandler(ctx *gin.Context) {
-	handler := newConfirmInvoiceHandler(ctx)
-	BaseRun(handler)
-}
-
-type ConfirmInvoiceHandler struct {
-	ctx  *gin.Context
-	req  *http_model.ConfirmInvoiceRequest
-	resp *http_model.CommonResponse
-}
-
-func (c ConfirmInvoiceHandler) getContext() *gin.Context {
-	return c.ctx
-}
-
-func (c ConfirmInvoiceHandler) getResponse() interface{} {
-	return c.resp
-}
-
-func (c ConfirmInvoiceHandler) getRequest() interface{} {
-	return c.req
-}
-
-func (c ConfirmInvoiceHandler) run() {
-	err := db.ConfirmInvoice(c.ctx, c.req)
-	if err != nil {
-		// 数据库查询失败,返回5001
-		logrus.Errorf("[ConfirmInvoiceHandler] call ConfirmInvoice err:%+v\n", err)
-		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
-		logrus.Info("ConfirmInvoice fail,req:%+v", c.req)
-		return
-	}
-	c.resp.Message = "确认开票成功"
-}
-
-func (c ConfirmInvoiceHandler) checkParam() error {
-	return nil
-}
-
-func newConfirmInvoiceHandler(ctx *gin.Context) *ConfirmInvoiceHandler {
-	return &ConfirmInvoiceHandler{
-		ctx:  ctx,
-		req:  http_model.NewConfirmInvoiceRequest(),
-		resp: http_model.NewConfirmInvoiceResponse(),
-	}
-}
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapConfirmInvoiceHandler(ctx *gin.Context) {
+	handler := newConfirmInvoiceHandler(ctx)
+	BaseRun(handler)
+}
+
+type ConfirmInvoiceHandler struct {
+	ctx  *gin.Context
+	req  *http_model.ConfirmInvoiceRequest
+	resp *http_model.CommonResponse
+}
+
+func (c ConfirmInvoiceHandler) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c ConfirmInvoiceHandler) getResponse() interface{} {
+	return c.resp
+}
+
+func (c ConfirmInvoiceHandler) getRequest() interface{} {
+	return c.req
+}
+
+func (c ConfirmInvoiceHandler) run() {
+	err := db.ConfirmInvoice(c.ctx, c.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[ConfirmInvoiceHandler] call ConfirmInvoice err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("ConfirmInvoice fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "确认开票成功"
+	c.resp.Status = consts.ErrorSuccess
+}
+
+func (c ConfirmInvoiceHandler) checkParam() error {
+	return nil
+}
+
+func newConfirmInvoiceHandler(ctx *gin.Context) *ConfirmInvoiceHandler {
+	return &ConfirmInvoiceHandler{
+		ctx:  ctx,
+		req:  http_model.NewConfirmInvoiceRequest(),
+		resp: http_model.NewConfirmInvoiceResponse(),
+	}
+}

+ 1 - 0
handler/confirmsupplierInvoice.go

@@ -42,6 +42,7 @@ func (c ConfirmSupplierInvoiceHandler) run() {
 		return
 	}
 	c.resp.Message = "确认开票成功"
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c ConfirmSupplierInvoiceHandler) checkParam() error {

+ 1 - 0
handler/confirmwithdraw.go

@@ -42,6 +42,7 @@ func (c ConfirmWithdrawHandler) run() {
 		return
 	}
 	c.resp.Message = "确认提现成功"
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c ConfirmWithdrawHandler) checkParam() error {

+ 57 - 56
handler/getBankInfo.go

@@ -1,56 +1,57 @@
-package handler
-
-import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
-	"youngee_m_api/consts"
-	"youngee_m_api/db"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/util"
-)
-
-func WrapGetBankInfoHandler(ctx *gin.Context) {
-	handler := newGetBankInfoHandler(ctx)
-	BaseRun(handler)
-}
-
-type GetBankInfo struct {
-	ctx  *gin.Context
-	req  *http_model.GetBankInfoRequest
-	resp *http_model.CommonResponse
-}
-
-func (g GetBankInfo) getContext() *gin.Context {
-	return g.ctx
-}
-
-func (g GetBankInfo) getResponse() interface{} {
-	return g.resp
-}
-
-func (g GetBankInfo) getRequest() interface{} {
-	return g.req
-}
-
-func (g GetBankInfo) run() {
-	data, err := db.GetBankInfo(g.ctx, g.req)
-	if err != nil {
-		logrus.WithContext(g.ctx).Errorf("[GetBankInfoHandler] error GetBankInfo, err:%+v", err)
-		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
-		return
-	}
-	g.resp.Data = data
-
-}
-
-func (g GetBankInfo) checkParam() error {
-	return nil
-}
-
-func newGetBankInfoHandler(ctx *gin.Context) *GetBankInfo {
-	return &GetBankInfo{
-		ctx:  ctx,
-		req:  http_model.NewGetBankInfoRequest(),
-		resp: http_model.NewGetBankInfoResponse(),
-	}
-}
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetBankInfoHandler(ctx *gin.Context) {
+	handler := newGetBankInfoHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetBankInfo struct {
+	ctx  *gin.Context
+	req  *http_model.GetBankInfoRequest
+	resp *http_model.CommonResponse
+}
+
+func (g GetBankInfo) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetBankInfo) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetBankInfo) getRequest() interface{} {
+	return g.req
+}
+
+func (g GetBankInfo) run() {
+	data, err := db.GetBankInfo(g.ctx, g.req)
+	if err != nil {
+		logrus.WithContext(g.ctx).Errorf("[GetBankInfoHandler] error GetBankInfo, err:%+v", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	g.resp.Data = data
+	g.resp.Status = consts.ErrorSuccess
+
+}
+
+func (g GetBankInfo) checkParam() error {
+	return nil
+}
+
+func newGetBankInfoHandler(ctx *gin.Context) *GetBankInfo {
+	return &GetBankInfo{
+		ctx:  ctx,
+		req:  http_model.NewGetBankInfoRequest(),
+		resp: http_model.NewGetBankInfoResponse(),
+	}
+}

+ 2 - 0
handler/getInvoicevalue.go

@@ -41,6 +41,8 @@ func (g GetInvoiceValueHandler) run() {
 		return
 	}
 	g.resp.Data = data
+	g.resp.Status = consts.ErrorSuccess
+	g.resp.Message = "ok"
 }
 
 func (g GetInvoiceValueHandler) checkParam() error {

+ 64 - 60
handler/get_userInfo.go

@@ -1,60 +1,64 @@
-package handler
-
-import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
-	"youngee_m_api/consts"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/service"
-	"youngee_m_api/util"
-)
-
-func WrapGetUserInfoHandler(ctx *gin.Context) {
-	handler := newGetUserInfo(ctx)
-	BaseRun(handler)
-}
-
-func newGetUserInfo(ctx *gin.Context) *UserInfo {
-	return &UserInfo{
-		req:  http_model.NewUserInfoRequest(),
-		resp: http_model.NewUserInfoResponse(),
-		ctx:  ctx,
-	}
-}
-
-type UserInfo struct {
-	req  *http_model.UserInfoRequest
-	resp *http_model.CommonResponse
-	ctx  *gin.Context
-}
-
-func (u UserInfo) getContext() *gin.Context {
-	return u.ctx
-}
-
-func (u UserInfo) getResponse() interface{} {
-	return u.resp
-}
-
-func (u UserInfo) getRequest() interface{} {
-	return u.req
-}
-
-func (u UserInfo) run() {
-	userInfo, err := service.LoginAuth.AuthToken(u.ctx, u.req.Token)
-	if err != nil {
-		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
-		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, u.req.Token)
-		logrus.Info("login fail,req:%+v", u.req)
-		return
-	}
-	data := http_model.UserInfoResponse{}
-	data.User = userInfo.User
-	data.Username = userInfo.Username
-	data.Role = userInfo.Role
-	u.resp.Data = data
-}
-
-func (u UserInfo) checkParam() error {
-	return nil
-}
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapGetUserInfoHandler(ctx *gin.Context) {
+	handler := newGetUserInfo(ctx)
+	userToken := ctx.Request.Header.Get("Authorization")
+	handler.req.Token = userToken
+	BaseRun(handler)
+}
+
+func newGetUserInfo(ctx *gin.Context) *UserInfo {
+	return &UserInfo{
+		req:  http_model.NewUserInfoRequest(),
+		resp: http_model.NewUserInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UserInfo struct {
+	req  *http_model.UserInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (u UserInfo) getContext() *gin.Context {
+	return u.ctx
+}
+
+func (u UserInfo) getResponse() interface{} {
+	return u.resp
+}
+
+func (u UserInfo) getRequest() interface{} {
+	return u.req
+}
+
+func (u UserInfo) run() {
+	data, err := service.LoginAuth.AuthToken(u.ctx, u.req.Token)
+	if err != nil {
+		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
+		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, u.req.Token)
+		logrus.Info("login fail,req:%+v", u.req)
+		return
+	}
+	//data := http_model.UserInfoResponse{}
+	//data.User = userInfo.User
+	//data.Username = userInfo.Username
+	//data.Role = userInfo.Role
+	u.resp.Data = data
+	u.resp.Message = "ok"
+	u.resp.Status = consts.ErrorSuccess
+}
+
+func (u UserInfo) checkParam() error {
+	return nil
+}

+ 57 - 0
handler/getallwithdrawvalue.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetAllwithdrawValueHandler(ctx *gin.Context) {
+	handler := newGetAllwithdrawValueHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetAllwithdrawValueHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetAllwithdrawValueRequest
+	resp *http_model.CommonResponse
+}
+
+func (g GetAllwithdrawValueHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetAllwithdrawValueHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetAllwithdrawValueHandler) getRequest() interface{} {
+	return g.req
+}
+
+func (g GetAllwithdrawValueHandler) run() {
+	data, err := db.GetAllwithdrawValue(g.ctx)
+	if err != nil {
+		logrus.WithContext(g.ctx).Errorf("[GetAllwithdrawValueHandler] error GetAllwithdrawValue, err:%+v", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	g.resp.Data = data
+	g.resp.Message = "ok"
+	g.resp.Status = consts.ErrorSuccess
+}
+
+func (g GetAllwithdrawValueHandler) checkParam() error {
+	return nil
+}
+
+func newGetAllwithdrawValueHandler(ctx *gin.Context) *GetAllwithdrawValueHandler {
+	return &GetAllwithdrawValueHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetAllwithdrawValueRequest(),
+		resp: http_model.NewGetAllwithdrawValueResponse(),
+	}
+}

+ 1 - 0
handler/getbilllist.go

@@ -43,6 +43,7 @@ func (c GetBillTaskList) run() {
 	}
 	c.resp.Message = "成功查询开票列表"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c GetBillTaskList) checkParam() error {

+ 2 - 0
handler/getinvoiceinfo.go

@@ -41,6 +41,8 @@ func (g GetInvoiceInfoHandler) run() {
 		return
 	}
 	g.resp.Data = data
+	g.resp.Message = "OK"
+	g.resp.Status = consts.ErrorSuccess
 }
 
 func (g GetInvoiceInfoHandler) checkParam() error {

+ 1 - 0
handler/getinvoicelist.go

@@ -44,6 +44,7 @@ func (c GetInvoiceList) run() {
 	}
 	c.resp.Message = "成功查询开票列表"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c GetInvoiceList) checkParam() error {

+ 1 - 0
handler/getsupplierinvoicelist.go

@@ -43,6 +43,7 @@ func (c GetSupplierInvoiceList) run() {
 	}
 	c.resp.Message = "成功查询开票列表"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c GetSupplierInvoiceList) checkParam() error {

+ 2 - 0
handler/getsupplierinvoicevalue.go

@@ -41,6 +41,8 @@ func (g GetSupplierInvoiceValueHandler) run() {
 		return
 	}
 	g.resp.Data = data
+	g.resp.Status = consts.ErrorSuccess
+	g.resp.Message = "ok"
 }
 
 func (g GetSupplierInvoiceValueHandler) checkParam() error {

+ 1 - 0
handler/getsupplierwithdrawlist.go

@@ -43,6 +43,7 @@ func (c GetSupplierWithdrawList) run() {
 	}
 	c.resp.Message = "成功查询开票列表"
 	c.resp.Data = res
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c GetSupplierWithdrawList) checkParam() error {

+ 2 - 2
handler/getwithdrawvalue.go

@@ -33,8 +33,8 @@ func (g GetWithdrawValueHandler) getRequest() interface{} {
 }
 
 func (g GetWithdrawValueHandler) run() {
-	req := g.req
-	data, err := db.GetWithdrawValue(g.ctx, *req)
+	//req := g.req
+	data, err := db.GetWithdrawValue(g.ctx)
 	if err != nil {
 		logrus.WithContext(g.ctx).Errorf("[GetWithdrawValueHandler] error GetWithdrawValue, err:%+v", err)
 		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)

+ 57 - 56
handler/login.go

@@ -1,56 +1,57 @@
-package handler
-
-import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
-	"youngee_m_api/consts"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/service"
-	"youngee_m_api/util"
-)
-
-func WrapCodeLoginHandler(ctx *gin.Context) {
-	handler := newCodeLoginHandler(ctx)
-	BaseRun(handler)
-}
-
-func newCodeLoginHandler(ctx *gin.Context) *CodeLoginHandler {
-	return &CodeLoginHandler{
-		req:  http_model.NewCodeLoginRequest(),
-		resp: http_model.NewCodeLoginResponse(),
-		ctx:  ctx,
-	}
-}
-
-type CodeLoginHandler struct {
-	req  *http_model.CodeLoginRequest
-	resp *http_model.CommonResponse
-	ctx  *gin.Context
-}
-
-func (h *CodeLoginHandler) getRequest() interface{} {
-	return h.req
-}
-func (h *CodeLoginHandler) getContext() *gin.Context {
-	return h.ctx
-}
-func (h *CodeLoginHandler) getResponse() interface{} {
-	return h.resp
-}
-func (h *CodeLoginHandler) run() {
-	token, username, role, err := service.LoginAuth.AuthCode(h.ctx, h.req.User, h.req.Password)
-	if err != nil {
-		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
-		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, token)
-		logrus.Info("login fail,req:%+v", h.req)
-		return
-	}
-	data := http_model.CodeLoginData{}
-	data.Token = token
-	data.Username = username
-	data.Role = role
-	h.resp.Data = data
-}
-func (h *CodeLoginHandler) checkParam() error {
-	return nil
-}
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapCodeLoginHandler(ctx *gin.Context) {
+	handler := newCodeLoginHandler(ctx)
+	BaseRun(handler)
+}
+
+func newCodeLoginHandler(ctx *gin.Context) *CodeLoginHandler {
+	return &CodeLoginHandler{
+		req:  http_model.NewCodeLoginRequest(),
+		resp: http_model.NewCodeLoginResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CodeLoginHandler struct {
+	req  *http_model.CodeLoginRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *CodeLoginHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *CodeLoginHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *CodeLoginHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *CodeLoginHandler) run() {
+	err, resdata := service.LoginAuth.AuthCode(h.ctx, h.req.User, h.req.Password)
+	if err != nil {
+		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, resdata.Token)
+		logrus.Info("login fail,req:%+v", h.req)
+		return
+	}
+	//data := http_model.CodeLoginData{}
+	//data.Token = token
+	//data.Username = username
+	//data.Role = role
+	h.resp.Data = resdata
+	h.resp.Status = consts.ErrorSuccess
+}
+func (h *CodeLoginHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/refusecharge.go

@@ -49,7 +49,7 @@ func (h *RefuseRechargeHandler) run() {
 		log.Info("RefuseRecharge fail,req:%+v", h.req)
 		return
 	}
-	h.resp.Message = "成功同意充值"
+	h.resp.Message = "成功拒绝充值"
 	h.resp.Data = res
 	h.resp.Status = consts.ErrorSuccess
 }

+ 2 - 1
handler/refusesupplierInvoice.go

@@ -41,7 +41,8 @@ func (c RefuseSupplierInvoiceHandler) run() {
 		logrus.Info("RefuseSupplierInvoice fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "确认开票成功"
+	c.resp.Message = "拒绝开票成功"
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c RefuseSupplierInvoiceHandler) checkParam() error {

+ 1 - 0
handler/refusewithdraw.go

@@ -42,6 +42,7 @@ func (c RefuseWithdrawHandler) run() {
 		return
 	}
 	c.resp.Message = "拒绝成功"
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c RefuseWithdrawHandler) checkParam() error {

+ 1 - 0
handler/setinvoiceinfo.go

@@ -42,6 +42,7 @@ func (c SetInvoiceInfoHandler) run() {
 		return
 	}
 	c.resp.Message = "确认开票成功"
+	c.resp.Status = consts.ErrorSuccess
 }
 
 func (c SetInvoiceInfoHandler) checkParam() error {

+ 3 - 2
handler/supplierwithdrawprevalue.go

@@ -33,14 +33,15 @@ func (g GetSupplierWithdrawPrevalueHandler) getRequest() interface{} {
 }
 
 func (g GetSupplierWithdrawPrevalueHandler) run() {
-	req := g.req
-	data, err := db.GetSupplierWithdrawPrevalue(g.ctx, *req)
+	data, err := db.GetSupplierWithdrawPrevalue(g.ctx)
 	if err != nil {
 		logrus.WithContext(g.ctx).Errorf("[GetSupplierWithdrawPrevalueHandler] error GetSupplierWithdrawPrevalue, err:%+v", err)
 		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
 		return
 	}
 	g.resp.Data = data
+	g.resp.Status = consts.ErrorSuccess
+	g.resp.Message = "ok"
 }
 
 func (g GetSupplierWithdrawPrevalueHandler) checkParam() error {

+ 3 - 2
handler/talentwithdrawprevalue.go

@@ -33,14 +33,15 @@ func (g GetTalentWithdrawPrevalueHandler) getRequest() interface{} {
 }
 
 func (g GetTalentWithdrawPrevalueHandler) run() {
-	req := g.req
-	data, err := db.GetTalentWithdrawPrevalue(g.ctx, *req)
+	data, err := db.GetTalentWithdrawPrevalue(g.ctx)
 	if err != nil {
 		logrus.WithContext(g.ctx).Errorf("[GetTalentWithdrawPrevalueHandler] error GetTalentWithdrawPrevalue, err:%+v", err)
 		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
 		return
 	}
 	g.resp.Data = data
+	g.resp.Status = consts.ErrorSuccess
+	g.resp.Message = "ok"
 }
 
 func (g GetTalentWithdrawPrevalueHandler) checkParam() error {

+ 20 - 0
model/http_model/GetAllwithdrawValueRequest.go

@@ -0,0 +1,20 @@
+package http_model
+
+type GetAllwithdrawValueRequest struct {
+}
+
+type GetAllwithdrawValueData struct {
+	WithdrawValue       float64 `json:"withdraw_value"`
+	TalentWithdrawvalue float64 `json:"talent_withdraw_value"`
+	AccumulateValue     float64 `json:"accumulate_value"`
+}
+
+func NewGetAllwithdrawValueRequest() *GetAllwithdrawValueRequest {
+	return new(GetAllwithdrawValueRequest)
+}
+
+func NewGetAllwithdrawValueResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetAllwithdrawValueData)
+	return resp
+}

+ 1 - 1
model/http_model/SubAccountDetail.go

@@ -4,7 +4,7 @@ import "youngee_m_api/model/gorm_model"
 
 type SubAccountDetailRequest struct {
 	PageSize      int    `json:"page_size"`
-	PageNum       int    `json:"page_num"`
+	PageNum       int    `json:"page"`
 	JobId         *int   `json:"job_id,omitempty"`         // 可选的岗位类型
 	AccountStatus *int   `json:"account_status,omitempty"` // 可选的账号状态
 	Others        string `json:"others,omitempty"`         //手机号或账号名称

+ 30 - 21
model/http_model/code_login.go

@@ -1,21 +1,30 @@
-package http_model
-
-type CodeLoginRequest struct {
-	User     string `json:"user"`
-	Password string `json:"password"`
-}
-
-type CodeLoginData struct {
-	Token    string `json:"token"`
-	Username string `json:"username"`
-	Role     string `json:"role"`
-}
-
-func NewCodeLoginRequest() *CodeLoginRequest {
-	return new(CodeLoginRequest)
-}
-func NewCodeLoginResponse() *CommonResponse {
-	resp := new(CommonResponse)
-	resp.Data = new(CodeLoginData)
-	return resp
-}
+package http_model
+
+type CodeLoginRequest struct {
+	User     string `json:"user"`
+	Password string `json:"password"`
+}
+
+type CodeLoginData struct {
+	Token                string `json:"token"`
+	Username             string `json:"username"`
+	Role                 string `json:"role"`
+	JobName              string `json:"job_name"`
+	AccountId            int64  `json:"account_id"`
+	SubAccountId         int    `json:"sub_account_id"`
+	WorkspacePermission  string `json:"workspace_permission"`
+	TaskcenterPermission string `json:"taskcenter_permission"`
+	SectaskPermission    string `json:"sectask_permission"`
+	FinancialPermission  string `json:"financial_permission"`
+	UsercenterPermission string `json:"usercenter_permission"`
+	OperatePermission    string `json:"operate_permission"`
+}
+
+func NewCodeLoginRequest() *CodeLoginRequest {
+	return new(CodeLoginRequest)
+}
+func NewCodeLoginResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CodeLoginData)
+	return resp
+}

+ 10 - 10
model/http_model/common_response.go

@@ -1,10 +1,10 @@
-package http_model
-
-// CommonResponse 接口通用的返回结构体
-type CommonResponse struct {
-	Status  int32       `json:"status"`
-	Message string      `json:"message"`
-	Data    interface{} `json:"data"`
-}
-type CommonRequest interface {
-}
+package http_model
+
+// CommonResponse 接口通用的返回结构体
+type CommonResponse struct {
+	Status  int32       `json:"code"`
+	Message string      `json:"msg"`
+	Data    interface{} `json:"data"`
+}
+type CommonRequest interface {
+}

+ 1 - 0
model/http_model/create_sub_account.go

@@ -2,6 +2,7 @@ package http_model
 
 type CreateSubAccountRequest struct {
 	SubAccountName string `json:"sub_account_name"`
+	Password       string `json:"password"`
 	Job            int    `json:"job_id"`
 	PhoneNumber    string `json:"phone_number"`
 	Code           string `json:"code"`

+ 1 - 1
model/http_model/getinvoicelistrequest.go

@@ -4,7 +4,7 @@ import "time"
 
 type GetInvoiceListRequest struct {
 	PageSize int `json:"page_size"`
-	PageNum  int `json:"page_num"`
+	PageNum  int `json:"page"`
 	Status   int `json:"status"`
 }
 

+ 1 - 1
model/http_model/getksauthorization.go

@@ -2,7 +2,7 @@ package http_model
 
 type GetAuthorizationRequest struct {
 	PageSize int `json:"page_size"`
-	PageNum  int `json:"page_num"`
+	PageNum  int `json:"page"`
 }
 
 type GetAuthorizationResponse struct {

+ 1 - 1
model/http_model/getprerechargelistrequest.go

@@ -2,7 +2,7 @@ package http_model
 
 type GetPreRechargeListRequest struct {
 	PageSize int    `json:"page_size"`
-	PageNum  int    `json:"page_num"`
+	PageNum  int    `json:"page"`
 	Status   int    `json:"status"`
 	Others   string `json:"others,omitempty"`
 }

+ 1 - 1
model/http_model/getsupplierinvoicerequest.go

@@ -4,7 +4,7 @@ import "time"
 
 type GetSupplierInvoiceListRequest struct {
 	PageSize int `json:"page_size"`
-	PageNum  int `json:"page_num"`
+	PageNum  int `json:"page"`
 	Status   int `json:"status"`
 }
 

+ 4 - 6
model/http_model/getsupplierwithdrawlistrequest.go

@@ -1,10 +1,8 @@
 package http_model
 
-import "time"
-
 type GetSupplierWithdrawListRequest struct {
 	PageSize int `json:"page_size"`
-	PageNum  int `json:"page_num"`
+	PageNum  int `json:"page"`
 	Status   int `json:"status"`
 }
 
@@ -17,9 +15,9 @@ type SupplierWithdrawListResponse struct {
 	Name           string        `json:"name"`
 	Taskinfo       *[]Tasklist   `json:"taskinfo"`
 	WithDrawinfo   *Withdrawinfo `json:"withdraw_info"`
-	SubmitAt       time.Time     `json:"submit_at"`
-	AggreeAt       time.Time     `json:"aggree_at"`
-	ReajectAt      time.Time     `json:"reject_at"`
+	SubmitAt       string        `json:"submit_at"`
+	AggreeAt       string        `json:"aggree_at"`
+	ReajectAt      string        `json:"reject_at"`
 	ReajectReason  string        `json:"reject_reason"`
 	SupplierId     int           `json:"supplier_id"`
 	Avater         string        `json:"avater"`

+ 1 - 1
model/http_model/gettalentwithdrawlsitrequest.go

@@ -2,7 +2,7 @@ package http_model
 
 type GetTalentWithdrawListRequest struct {
 	PageSize int    `json:"page_size"`
-	PageNum  int    `json:"page_num"`
+	PageNum  int    `json:"page"`
 	Status   int    `json:"status"`
 	Others   string `json:"others,omitempty"`
 	During   string `json:"during,omitempty"`

+ 1 - 1
model/http_model/job_detail.go

@@ -4,7 +4,7 @@ import "youngee_m_api/model/gorm_model"
 
 type JobDetailRequest struct {
 	PageSize  int   `json:"page_size"`
-	PageNum   int   `json:"page_num"`
+	PageNum   int   `json:"page"`
 	AccountID int64 `json:"account_id"`
 }
 

+ 1 - 0
model/http_model/jobshow.go

@@ -14,6 +14,7 @@ type GetJobshowData struct {
 	FinancialPermission  string `json:"financial_permission"`  //财务结算权限
 	UsercenterPermission string `json:"usercenter_permission"` //用户中心权限
 	OperatePermission    string `json:"operate_permission"`    //运营中心权限
+	AccountId            int64  `json:"account_id"`
 }
 
 func NewJobShowRequest() *JobShowRequest {

+ 30 - 21
model/http_model/userInfo.go

@@ -1,21 +1,30 @@
-package http_model
-
-type UserInfoRequest struct {
-	Token string
-}
-
-type UserInfoResponse struct {
-	User     string
-	Username string
-	Role     string
-}
-
-func NewUserInfoRequest() *UserInfoRequest {
-	return new(UserInfoRequest)
-}
-
-func NewUserInfoResponse() *CommonResponse {
-	resp := new(CommonResponse)
-	resp.Data = new(UserInfoResponse)
-	return resp
-}
+package http_model
+
+type UserInfoRequest struct {
+	Token string
+}
+
+type UserInfoResponse struct {
+	User                 string
+	Username             string
+	Role                 string
+	JobName              string `json:"job_name"`
+	AccountId            int64  `json:"account_id"`
+	SubAccountId         int    `json:"sub_account_id"`
+	WorkspacePermission  string `json:"workspace_permission"`
+	TaskcenterPermission string `json:"taskcenter_permission"`
+	SectaskPermission    string `json:"sectask_permission"`
+	FinancialPermission  string `json:"financial_permission"`
+	UsercenterPermission string `json:"usercenter_permission"`
+	OperatePermission    string `json:"operate_permission"`
+}
+
+func NewUserInfoRequest() *UserInfoRequest {
+	return new(UserInfoRequest)
+}
+
+func NewUserInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UserInfoResponse)
+	return resp
+}

+ 9 - 8
route/init.go

@@ -13,7 +13,7 @@ func InitRoute(r *gin.Engine) {
 
 	r.POST("/youngee/m/login", handler.WrapCodeLoginHandler)
 	r.GET("/youngee/m/getLoginUser", handler.WrapGetLoginUserHandler)
-	r.POST("/userInfo", handler.WrapGetUserInfoHandler)
+	r.POST("/youngee/m/userInfo", handler.WrapGetUserInfoHandler)
 	r.GET("/test/ping", func(c *gin.Context) {
 		resp := http_model.CommonResponse{
 			Status:  0,
@@ -194,7 +194,7 @@ func InitRoute(r *gin.Engine) {
 	{
 		f.Use(middleware.LoginAuthMiddleware)
 
-		f.GET("/getRechargeValue", handler.WrapGetRechargeValueHandler)      //获取充值金额
+		f.POST("/getRechargeValue", handler.WrapGetRechargeValueHandler)     //获取充值金额
 		f.GET("/getrechargecount", handler.WrapGetRechargeCountHandler)      //列表角标
 		f.POST("/getPreRechargelist", handler.WrapGetPreRechargeListHandler) //充值待确认、确认、失败列表
 		f.POST("/getrechargeinfo", handler.WrapGetRechargeInfoHandler)       //充值确认信息
@@ -208,17 +208,18 @@ func InitRoute(r *gin.Engine) {
 		f.GET("/getInvoiceNums", handler.WrapGetInvoiceNumsHandler)   // 获取待开票的数量
 		f.GET("/getRechargeNums", handler.WrapGetRechargeNumsHandler) // 获取充值待确认的数量
 
-		f.GET("/getInvoiceValue", handler.WrapGetInvoiceValueHandler)                 //获取待开票,已开票金额
-		f.GET("/getSupplierInvoiceValue", handler.WrapGetSupplierInvoiceValueHandler) //获取回票待确认,已回票金额
-		f.POST("/getInvoicelist", handler.WrapGetInvoiceListHandler)                  //待/已开票列表
-		f.POST("/getSupplierInvoicelist", handler.WrapGetSupplierInvoiceListHandler)  //待/已回票列表
-		f.POST("/setInvoiceinfo", handler.WrapSetInvoiceInfoHandler)                  //平台回票信息
+		f.POST("/getInvoiceValue", handler.WrapGetInvoiceValueHandler)                 //获取待开票,已开票金额
+		f.POST("/getSupplierInvoiceValue", handler.WrapGetSupplierInvoiceValueHandler) //获取回票待确认,已回票金额
+		f.POST("/getInvoicelist", handler.WrapGetInvoiceListHandler)                   //待/已开票列表
+		f.POST("/getSupplierInvoicelist", handler.WrapGetSupplierInvoiceListHandler)   //待/已回票列表
+		f.POST("/setInvoiceinfo", handler.WrapSetInvoiceInfoHandler)                   //平台回票信息
 
 		f.POST("/supplierwithdraw", handler.WarpGetSupplierWithdrawPrevalueHandler)    //服务商提现待确认
 		f.POST("/getSupplierWithdrawlist", handler.WrapGetSupplierWithdrawListHandler) //服务商待/已提现、已驳回列表
 		f.POST("/confirmwithdraw", handler.WrapConfirmWithdrawHandler)                 // 确认服务商提现
 		f.POST("/refusewithdraw", handler.WrapRefuseWithdrawHandler)                   // 不同意服务商提现
 
+		f.GET("/getallwithdrawValue", handler.WrapGetAllwithdrawValueHandler)          //提现金额
 		f.GET("/gettalentwithdrawValue", handler.WarpGetTalentWithdrawPrevalueHandler) //达人提现待确认
 		f.GET("/withdrawvalue", handler.WarpGetWithdrawValueHandler)                   //累计提现金额
 		f.POST("/getTalentWithdrawlist", handler.WrapGetTalentWithdrawListHandler)     //达人待/已提现、已驳回列表
@@ -233,7 +234,7 @@ func InitRoute(r *gin.Engine) {
 		f.POST("/confirmsupplierInvoice", handler.WrapConfirmSupplierInvoiceHandler) // 确认回票
 		f.POST("/refusesupplierInvoice", handler.WrapRefuseSupplierInvoiceHandler)   // 不同意回票
 
-		f.POST("/ConfirmWithdrawal", handler.WrapConfirmWithdrawalHandler)     // 确认提现
+		f.POST("/ConfirmWithdrawal", handler.WrapConfirmWithdrawalHandler)     // 确认达人提现
 		f.POST("/RefuseWithdrawal", handler.WrapRefuseTalentWithdrawalHandler) // 提现驳回
 
 		f.POST("/getBankInfo", handler.WrapGetBankInfoHandler) // 获取银行开户地信息

+ 238 - 148
service/login_auth.go

@@ -1,148 +1,238 @@
-package service
-
-import (
-	"context"
-	"encoding/json"
-	"errors"
-	"fmt"
-	"github.com/sirupsen/logrus"
-	"strconv"
-	"strings"
-	"time"
-	"youngee_m_api/consts"
-	"youngee_m_api/db"
-	"youngee_m_api/model/redis_model"
-	"youngee_m_api/model/system_model"
-	"youngee_m_api/redis"
-	"youngee_m_api/util"
-)
-
-var LoginAuth *loginAuth
-
-func LoginAuthInit(config *system_model.Session) {
-	auth := new(loginAuth)
-	auth.sessionTTL = time.Duration(config.TTL) * time.Minute
-	LoginAuth = auth
-}
-
-type loginAuth struct {
-	sessionTTL time.Duration
-}
-
-func (l *loginAuth) AuthToken(ctx context.Context, token string) (*redis_model.Auth, error) {
-	user, err := l.parseToken(ctx, token)
-	if err != nil {
-		logrus.Debug("token格式错误:%+v", token)
-		return nil, err
-	}
-	auth, err := l.getSessionAuth(ctx, user)
-	if err != nil {
-		logrus.Debug("获取session redis错误: token:%+v,err:%+v", token, err)
-		return nil, err
-	}
-	if auth.Token != token {
-		logrus.Debug("获取session time过期错误: token:%+v", token)
-		return nil, errors.New("auth failed")
-	}
-	return auth, nil
-}
-
-func (l *loginAuth) AuthCode(ctx context.Context, User string, password string) (string, string, string, error) {
-	user, err := db.GetUser(ctx, User)
-	if err != nil {
-		return "", "", "", err
-	} else if user == nil {
-		// 账号不存在
-		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
-		return "账号不存在", "", "", errors.New("auth fail")
-	} else if string(user.Role) != consts.BRole && string(user.Role) != consts.BRole2 {
-		// 账号权限有误
-		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
-		return "权限错误,请登录管理账号", "", "", errors.New("auth fail")
-	} else if string(user.UserState) != "1" {
-		// 账号已经被禁用
-		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
-		return "账号已经被禁用", "", "", errors.New("auth fail")
-	}
-	var token string
-	if user.Password == password {
-		token = l.getToken(ctx, user.User)
-		auth := &redis_model.Auth{
-			Phone:    user.Phone,
-			ID:       user.ID,
-			User:     user.User,
-			Username: user.Username,
-			RealName: user.RealName,
-			Role:     user.Role,
-			Email:    user.Email,
-			Token:    token,
-		}
-		if err := l.setSession(ctx, user.User, auth); err != nil {
-			fmt.Printf("setSession error\n")
-			return "", "", "", err
-		}
-	}
-	return token, user.Username, user.Role, nil
-}
-
-func (l *loginAuth) setSession(ctx context.Context, user string, auth *redis_model.Auth) error {
-	if authJson, err := json.Marshal(auth); err == nil {
-		err = redis.Set(ctx, l.getRedisKey(user), string(authJson), l.sessionTTL)
-		if err == nil {
-			return err
-		}
-	}
-	return nil
-}
-
-//func (l *loginAuth) getSessionCode(ctx context.Context, phone string) (*string, error) {
-//	value, err := redis.Get(ctx, l.getRedisKey(phone))
-//	if err != nil {
-//		if err == consts.RedisNil {
-//			return nil, fmt.Errorf("not found in redis,phone:%+v", phone)
-//		}
-//		return nil, err
-//	}
-//	return &value, nil
-//}
-
-func (l *loginAuth) getSessionAuth(ctx context.Context, user string) (*redis_model.Auth, error) {
-	value, err := redis.Get(ctx, l.getRedisKey(user))
-	if err != nil {
-		if err == consts.RedisNil {
-			return nil, fmt.Errorf("not found in redis,user:%+v", user)
-		}
-		return nil, err
-	}
-	auth := new(redis_model.Auth)
-	if err = json.Unmarshal([]byte(value), auth); err != nil {
-		return nil, err
-	}
-	return auth, nil
-}
-
-func (l *loginAuth) getToken(ctx context.Context, user string) string {
-	timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
-	token := user + "." + timeSeed + "." + util.MD5(user, timeSeed, consts.AuthSalt)
-	return token
-}
-
-func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
-	parts := strings.Split(token, ".")
-	if len(parts) == 3 {
-		user := parts[0]
-		timeSeed := parts[1]
-		if parts[2] == util.MD5(user, timeSeed, consts.AuthSalt) {
-			return user, nil
-		}
-	}
-	return "", errors.New("token invalid")
-}
-
-func (l *loginAuth) encryptPassword(password string) string {
-	return util.MD5(password)
-}
-
-func (l *loginAuth) getRedisKey(key string) string {
-	return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
-}
+package service
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"github.com/sirupsen/logrus"
+	"strconv"
+	"strings"
+	"time"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/model/redis_model"
+	"youngee_m_api/model/system_model"
+	"youngee_m_api/redis"
+	"youngee_m_api/util"
+)
+
+var LoginAuth *loginAuth
+
+func LoginAuthInit(config *system_model.Session) {
+	auth := new(loginAuth)
+	auth.sessionTTL = time.Duration(config.TTL) * time.Minute
+	LoginAuth = auth
+}
+
+type loginAuth struct {
+	sessionTTL time.Duration
+}
+
+func (l *loginAuth) AuthToken(ctx context.Context, token string) (*http_model.UserInfoResponse, error) {
+	user, err := l.parseToken(ctx, token)
+	if err != nil {
+		logrus.Debug("token格式错误:%+v", token)
+		return nil, err
+	}
+	auth, err := l.getSessionAuth(ctx, user)
+	if err != nil {
+		logrus.Debug("获取session redis错误: token:%+v,err:%+v", token, err)
+		return nil, err
+	}
+	if auth.Token != token {
+		logrus.Debug("获取session time过期错误: token:%+v", token)
+		return nil, errors.New("auth failed")
+	}
+	var loginUser http_model.UserInfoResponse
+	if auth.Role == "1" {
+		//主账号
+		loginUser = http_model.UserInfoResponse{
+			User:                 auth.User,
+			Username:             auth.Username,
+			Role:                 auth.Role,
+			JobName:              "主账号无岗位",
+			AccountId:            auth.ID,
+			SubAccountId:         0,
+			WorkspacePermission:  "1",
+			TaskcenterPermission: "1",
+			SectaskPermission:    "1",
+			FinancialPermission:  "1",
+			OperatePermission:    "1",
+			UsercenterPermission: "1",
+		}
+	} else {
+		subaccount, err := db.FindSubAccountById(ctx, auth.ID)
+		if err != nil {
+			return nil, err
+		}
+
+		jobinfo, err := db.GetJob(ctx, subaccount.JobId)
+		if err != nil {
+			return nil, err
+		}
+		loginUser = http_model.UserInfoResponse{
+
+			User:                 auth.User,
+			Username:             auth.Username,
+			Role:                 auth.Role,
+			JobName:              jobinfo.JobName,
+			AccountId:            auth.ID,
+			SubAccountId:         subaccount.SubAccountId,
+			WorkspacePermission:  jobinfo.WorkshopPermission,
+			TaskcenterPermission: jobinfo.TaskcenterPermission,
+			SectaskPermission:    jobinfo.SectaskPermisson,
+			FinancialPermission:  jobinfo.FinancialPermission,
+			OperatePermission:    jobinfo.OperatePermission,
+			UsercenterPermission: jobinfo.UsercenterPermission,
+		}
+	}
+	return &loginUser, nil
+}
+
+func (l *loginAuth) AuthCode(ctx context.Context, User string, password string) (error, *http_model.CodeLoginData) {
+	user, err := db.GetUser(ctx, User)
+	var loginuserdata http_model.CodeLoginData
+	if err != nil {
+		return err, nil
+	} else if user == nil {
+		// 账号不存在
+		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
+		loginuserdata.Token = "账号不存在"
+		return errors.New("auth fail"), &loginuserdata
+	} else if string(user.Role) != consts.BRole && string(user.Role) != consts.BRole2 {
+		// 账号权限有误
+		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
+		loginuserdata.Token = "权限错误,请登录管理账号"
+		return errors.New("auth fail"), &loginuserdata
+	} else if string(user.UserState) != "1" {
+		// 账号已经被禁用
+		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
+		loginuserdata.Token = "账号已经被禁用"
+		return errors.New("auth fail"), &loginuserdata
+	}
+	var token string
+	if user.Password == password {
+		token = l.getToken(ctx, user.User)
+		auth := &redis_model.Auth{
+			Phone:    user.Phone,
+			ID:       user.ID,
+			User:     user.User,
+			Username: user.Username,
+			RealName: user.RealName,
+			Role:     user.Role,
+			Email:    user.Email,
+			Token:    token,
+		}
+		if err := l.setSession(ctx, user.User, auth); err != nil {
+			fmt.Printf("setSession error\n")
+			return err, nil
+		}
+	}
+
+	if user.Role == "1" {
+		//主账号
+		loginuserdata = http_model.CodeLoginData{
+			Token:                token,
+			Username:             user.Username,
+			Role:                 user.Role,
+			JobName:              "主账号无岗位",
+			AccountId:            user.ID,
+			SubAccountId:         0,
+			WorkspacePermission:  "1",
+			TaskcenterPermission: "1",
+			SectaskPermission:    "1",
+			FinancialPermission:  "1",
+			OperatePermission:    "1",
+			UsercenterPermission: "1",
+		}
+	} else {
+		subaccount, err := db.FindSubAccountById(ctx, user.ID)
+		if err != nil {
+			return err, nil
+		}
+
+		jobinfo, err := db.GetJob(ctx, subaccount.JobId)
+		if err != nil {
+			return err, nil
+		}
+		loginuserdata = http_model.CodeLoginData{
+			Token:                token,
+			Username:             user.Username,
+			Role:                 user.Role,
+			JobName:              jobinfo.JobName,
+			AccountId:            user.ID,
+			SubAccountId:         subaccount.SubAccountId,
+			WorkspacePermission:  jobinfo.WorkshopPermission,
+			TaskcenterPermission: jobinfo.TaskcenterPermission,
+			SectaskPermission:    jobinfo.SectaskPermisson,
+			FinancialPermission:  jobinfo.FinancialPermission,
+			OperatePermission:    jobinfo.OperatePermission,
+			UsercenterPermission: jobinfo.UsercenterPermission,
+		}
+	}
+	return nil, &loginuserdata
+}
+
+func (l *loginAuth) setSession(ctx context.Context, user string, auth *redis_model.Auth) error {
+	if authJson, err := json.Marshal(auth); err == nil {
+		err = redis.Set(ctx, l.getRedisKey(user), string(authJson), l.sessionTTL)
+		if err == nil {
+			return err
+		}
+	}
+	return nil
+}
+
+//func (l *loginAuth) getSessionCode(ctx context.Context, phone string) (*string, error) {
+//	value, err := redis.Get(ctx, l.getRedisKey(phone))
+//	if err != nil {
+//		if err == consts.RedisNil {
+//			return nil, fmt.Errorf("not found in redis,phone:%+v", phone)
+//		}
+//		return nil, err
+//	}
+//	return &value, nil
+//}
+
+func (l *loginAuth) getSessionAuth(ctx context.Context, user string) (*redis_model.Auth, error) {
+	value, err := redis.Get(ctx, l.getRedisKey(user))
+	if err != nil {
+		if err == consts.RedisNil {
+			return nil, fmt.Errorf("not found in redis,user:%+v", user)
+		}
+		return nil, err
+	}
+	auth := new(redis_model.Auth)
+	if err = json.Unmarshal([]byte(value), auth); err != nil {
+		return nil, err
+	}
+	return auth, nil
+}
+
+func (l *loginAuth) getToken(ctx context.Context, user string) string {
+	timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
+	token := user + "." + timeSeed + "." + util.MD5(user, timeSeed, consts.AuthSalt)
+	return token
+}
+
+func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
+	parts := strings.Split(token, ".")
+	if len(parts) == 3 {
+		user := parts[0]
+		timeSeed := parts[1]
+		if parts[2] == util.MD5(user, timeSeed, consts.AuthSalt) {
+			return user, nil
+		}
+	}
+	return "", errors.New("token invalid")
+}
+
+func (l *loginAuth) encryptPassword(password string) string {
+	return util.MD5(password)
+}
+
+func (l *loginAuth) getRedisKey(key string) string {
+	return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
+}