Ver código fonte

erp权限校区,erp活动,修改二维码信息

icole 4 anos atrás
pai
commit
f8d0f6f3ec

+ 2 - 2
etc/i2bill-api.yaml

@@ -1,5 +1,5 @@
 Name: i2bill-api
-Host: 0.0.0.0
+Host: 172.16.11.5
 Port: 8888
 DataSource: root:gSRGZqb121TlYIbJy0@tcp(47.103.202.94:3306)/i2bill?charset=utf8&loc=Local&parseTime=true
 Table:
@@ -10,7 +10,7 @@ Transform:
   Etcd:
     Hosts:
       - 47.103.219.158:30019
-    Key: transform.rpc
+    Key: icole.rpc
 Weixin:
   Appid: wxb8a763ab9e81d0cb
   Secret: 95dc14b89d32fe91709bba8916f30f74

+ 0 - 11
go.mod

@@ -7,22 +7,11 @@ go 1.16
 require (
 	git.i2edu.net/i2/go-zero v1.0.1-0.20210616091154-7fac117e009f
 	git.i2edu.net/i2/i2-bill-erp v0.0.0
-	github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 // indirect
-	github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
-	github.com/CloudyKit/jet v2.1.2+incompatible // indirect
-	github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect
-	github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect
-	github.com/bndr/gotabulate v1.1.2 // indirect
 	github.com/clbanning/mxj v1.8.4 // indirect
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
-	github.com/fatih/structs v1.1.0 // indirect
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/satori/go.uuid v1.2.0
-	github.com/syndtr/goleveldb v1.0.0 // indirect
-	github.com/tealeg/xlsx v1.0.5 // indirect
-	github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect
 	github.com/xormplus/xorm v0.0.0-20210512135344-8123d584d5f5
-	gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect
 	gopkg.in/yaml.v2 v2.4.0
 )
 

+ 3 - 0
go.sum

@@ -147,6 +147,8 @@ github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplb
 github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
+github.com/iancoleman/strcase v0.1.3 h1:dJBk1m2/qjL1twPLf68JND55vvivMupZ4wIzE8CTdBw=
+github.com/iancoleman/strcase v0.1.3/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
 github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
@@ -255,6 +257,7 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
 github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
 github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
+github.com/tal-tech/go-zero v1.1.7 h1:rs78kI5ZiBx1RIl562qDzkBV8P7CdnbCiljknyC4mXg=
 github.com/tal-tech/go-zero v1.1.7/go.mod h1:BEylLQnv5moldpMT1lH3kUoMEcdaIp+r9Lgp+41dXxg=
 github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
 github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=

+ 49 - 12
i2bill.api

@@ -8,11 +8,11 @@ info(
 )
 
 type PageResult {
-	Page          int         `json:"page"`
-	Rows          int         `json:"rows"`
-	TotalSize     int64       `json:"totalSize"`
-	TotalPageSize int64       `json:"totalPageSize"`
-	Content       interface{} `json:"content"`
+	Page          int                      `json:"page"`
+	Rows          int                      `json:"rows"`
+	TotalSize     int64                    `json:"totalSize"`
+	TotalPageSize int64                    `json:"totalPageSize"`
+	Content       []map[string]interface{} `json:"content"`
 }
 
 type WXLoginResponse {
@@ -56,13 +56,16 @@ type loginByWeixinRequest {
 }
 
 type AuthUserInfo {
-	ID       int64  `json:"id"`
-	Mobile   string `json:"mobile"`
-	UserName string `json:"username"`
-	NickName string `json:"nickname"`
-	Gender   int64  `json:"gender"`
-	Avatar   string `json:"avatar"`
-	Birthday int64  `json:"birthday"`
+	ID          int64  `json:"id"`
+	Mobile      string `json:"mobile"`
+	UserName    string `json:"username"`
+	NickName    string `json:"nickname"`
+	Gender      int64  `json:"gender"`
+	Avatar      string `json:"avatar"`
+	Birthday    int64  `json:"birthday"`
+	ErpRoleType int64  `json:"erp_role_type"`
+	ErpRole     string `json:"erp_role"`
+	MkId        string `json:"mk_id"`
 }
 
 type loginByWeixinResponse {
@@ -227,6 +230,20 @@ service i2bill-api {
 	post  /api/v1/acquirer_student/add(enrollAddReq) returns(Response)
 }
 
+//收单二维码
+@server(
+	jwt: JwtAuth
+	group: acquirer_mkt_qr
+)
+
+service i2bill-api {
+	@handler AcquirerMktQrUpdate
+	post  /api/v1/acquirer_mkt_qr/update returns(Response)
+	
+	@handler AcquirerMktQrGet
+	post  /api/v1/acquirer_mkt_qr/get returns(Response)
+}
+
 // 城市树
 @server(
 	jwt: JwtAuth
@@ -257,4 +274,24 @@ service i2bill-api{
 service i2bill-api{
 	@handler GetErpMktNetworkDetail
 	get /api/v1/mkt_network_detail/get_erp_mkt_network_detail returns(Response)
+}
+
+//erp 收单资源校区
+@server(
+	jwt: JwtAuth
+	group: base_organ_school
+)
+service i2bill-api{
+	@handler GetErpSchPerm
+	get /api/v1/base_organ_school/get_erp_sch_perm returns(Response)
+}
+
+//erp 校区活动
+@server(
+	jwt: JwtAuth
+	group: mkt_active
+)
+service i2bill-api{
+	@handler GetErpMktActive
+	get /api/v1/mkt_active/get_erp_mkt_active returns(Response)
 }

+ 22 - 0
internal/handler/acquirer_mkt_qr/acquirer_mkt_qr_get_handler.go

@@ -0,0 +1,22 @@
+package acquirer_mkt_qr
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/acquirer_mkt_qr"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func AcquirerMktQrGetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := acquirer_mkt_qr.NewAcquirerMktQrGetLogic(r.Context(), ctx)
+		resp, err := l.AcquirerMktQrGet(r)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 22 - 0
internal/handler/acquirer_mkt_qr/acquirer_mkt_qr_update_handler.go

@@ -0,0 +1,22 @@
+package acquirer_mkt_qr
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/acquirer_mkt_qr"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func AcquirerMktQrUpdateHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := acquirer_mkt_qr.NewAcquirerMktQrUpdateLogic(r.Context(), ctx)
+		resp, err := l.AcquirerMktQrUpdate(r)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 22 - 0
internal/handler/base_organ_school/get_erp_sch_perm_handler.go

@@ -0,0 +1,22 @@
+package handler
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/base_organ_school"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func GetErpSchPermHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := logic.NewGetErpSchPermLogic(r.Context(), ctx)
+		resp, err := l.GetErpSchPerm()
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 22 - 0
internal/handler/mkt_active/get_erp_mkt_active_handler.go

@@ -0,0 +1,22 @@
+package mkt_active
+
+import (
+	"net/http"
+
+	"git.i2edu.net/i2/go-zero/rest/httpx"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/mkt_active"
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+)
+
+func GetErpMktActiveHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+
+		l := mkt_active.NewGetErpMktActiveLogic(r.Context(), ctx)
+		resp, err := l.GetErpMktActive(r)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 41 - 0
internal/handler/routes.go

@@ -5,9 +5,12 @@ import (
 	"net/http"
 
 	acquirer "git.i2edu.net/i2/i2-bill-api/internal/handler/acquirer"
+	acquirer_mkt_qr "git.i2edu.net/i2/i2-bill-api/internal/handler/acquirer_mkt_qr"
 	acquirer_student "git.i2edu.net/i2/i2-bill-api/internal/handler/acquirer_student"
 	auth "git.i2edu.net/i2/i2-bill-api/internal/handler/auth"
 	base_organ "git.i2edu.net/i2/i2-bill-api/internal/handler/base_organ"
+	base_organ_school "git.i2edu.net/i2/i2-bill-api/internal/handler/base_organ_school"
+	mkt_active "git.i2edu.net/i2/i2-bill-api/internal/handler/mkt_active"
 	mkt_network_detail "git.i2edu.net/i2/i2-bill-api/internal/handler/mkt_network_detail"
 	mkt_part_time_user "git.i2edu.net/i2/i2-bill-api/internal/handler/mkt_part_time_user"
 	sys_optionset "git.i2edu.net/i2/i2-bill-api/internal/handler/sys_optionset"
@@ -127,6 +130,22 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 		},
 	)
 
+	engine.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodPost,
+				Path:    "/api/v1/acquirer_mkt_qr/update",
+				Handler: acquirer_mkt_qr.AcquirerMktQrUpdateHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/api/v1/acquirer_mkt_qr/get",
+				Handler: acquirer_mkt_qr.AcquirerMktQrGetHandler(serverCtx),
+			},
+		},
+		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
+	)
+
 	engine.AddRoutes(
 		[]rest.Route{
 			{
@@ -159,4 +178,26 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 		},
 		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
 	)
+
+	engine.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/v1/base_organ_school/get_erp_sch_perm",
+				Handler: base_organ_school.GetErpSchPermHandler(serverCtx),
+			},
+		},
+		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
+	)
+
+	engine.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/v1/mkt_active/get_erp_mkt_active",
+				Handler: mkt_active.GetErpMktActiveHandler(serverCtx),
+			},
+		},
+		rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
+	)
 }

+ 31 - 0
internal/logic/acquirer_mkt_qr/acquirer_mkt_qr_get_logic.go

@@ -0,0 +1,31 @@
+package acquirer_mkt_qr
+
+import (
+	"context"
+	"net/http"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/core/logx"
+)
+
+type AcquirerMktQrGetLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAcquirerMktQrGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) AcquirerMktQrGetLogic {
+	return AcquirerMktQrGetLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AcquirerMktQrGetLogic) AcquirerMktQrGet(r *http.Request) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+
+	return &types.Response{}, nil
+}

+ 91 - 0
internal/logic/acquirer_mkt_qr/acquirer_mkt_qr_update_logic.go

@@ -0,0 +1,91 @@
+package acquirer_mkt_qr
+
+import (
+	"context"
+	"encoding/json"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/user"
+	"git.i2edu.net/i2/i2-bill-api/model"
+	"io/ioutil"
+	"net/http"
+	"time"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/core/logx"
+)
+
+type AcquirerMktQrUpdateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAcquirerMktQrUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) AcquirerMktQrUpdateLogic {
+	return AcquirerMktQrUpdateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AcquirerMktQrUpdateLogic) AcquirerMktQrUpdate(r *http.Request) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	userId := l.svcCtx.GetUserIdByJwt(l.ctx)
+	body, err := ioutil.ReadAll(r.Body)
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	bean := new(model.I2billAcquirerMktQrXorm)
+	err = json.Unmarshal(body, bean)
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	erpId, err := user.GetAcquirePerm(userId, l.svcCtx.Transformer, l.svcCtx.DB)
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	if erpId == "" {
+		return &types.Response{500, "请先申请兼职", nil}, nil
+	}
+	sql := `
+			select  
+				qr.qudao_id,activity_id,school_id 
+			from 
+				i2bill_acquirer_mkt_qr qr 
+			inner join 
+				i2bill_mkt_part_time_user part
+			on 
+				qr.user_id = part_user.id
+			where 
+				part.mk_id = ? and qr.del_flag = 0  and part.del_flag = 0`
+	acquirers, err := l.svcCtx.DB.SQL(sql, erpId).Query().List()
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	if len(acquirers) == 0 {
+		return &types.Response{500, "请选择渠道", nil}, nil
+	}
+	if bean.Id != 0 {
+		bean.QudaoId, _ = acquirers[0]["qudao_id"].(int64)
+		bean.ActivityId, _ = acquirers[0]["activity_id"].(int64)
+		bean.SchoolId, _ = acquirers[0]["school_id"].(int64)
+	}
+
+	bean.QudaoId, _ = acquirers[0]["qudao_id"].(int64)
+	bean.ActivityId, _ = acquirers[0]["activity_id"].(int64)
+	bean.SchoolId, _ = acquirers[0]["school_id"].(int64)
+	bean.UserId = userId
+	bean.CreateTime = time.Now()
+	bean.LastUpdateTime = bean.CreateTime
+	bean.CreateBy = bean.UserId
+	bean.LastUpdateBy = bean.CreateBy
+	bean.DelFlag = 0
+	bean.Qr = "test.jpg"
+	//生成二维码
+	_, err = l.svcCtx.DB.Insert(bean)
+	if err != nil {
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	return &types.Response{200, "", nil}, nil
+}

+ 19 - 0
internal/logic/acquirer_student/acquirer_student_page_logic.go

@@ -6,6 +6,7 @@ import (
 	"git.i2edu.net/i2/i2-bill-api/internal/svc"
 	"git.i2edu.net/i2/i2-bill-api/internal/types"
 	"git.i2edu.net/i2/i2-bill-api/internal/utils"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
 	"net/http"
 	"strconv"
 	"time"
@@ -59,8 +60,26 @@ func (l *AcquirerStudentPageLogic) AcquirerStudentPage(r *http.Request) (*types.
 	}
 	res, err := utils.PageSearch(l.svcCtx.DB, "i2bill_acquirer_student", "page", "i2bill_acquirer_student", paramMap_i_t)
 	if err != nil {
+		logx.Error(err.Error())
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	erpRes, err := l.svcCtx.Transformer.GetErpSchool(l.ctx, &transform.Empty{})
+	if err != nil {
+		logx.Error(err.Error())
 		return &types.Response{500, err.Error(), res}, nil
 	}
+	if res.Content != nil {
+		for index, r := range res.Content {
+			for _, sch := range erpRes.School {
+				if sch.Id == r["sch_id"].(int64) {
+					r["sch_name"] = sch.Name
+					res.Content[index] = r
+					break
+				}
+			}
+
+		}
+	}
 	return &types.Response{200, "", res}, nil
 
 }

+ 43 - 0
internal/logic/base_organ_school/get_erp_sch_perm_logic.go

@@ -0,0 +1,43 @@
+package logic
+
+import (
+	"context"
+	"git.i2edu.net/i2/i2-bill-api/internal/logic/user"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/core/logx"
+)
+
+type GetErpSchPermLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetErpSchPermLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetErpSchPermLogic {
+	return GetErpSchPermLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetErpSchPermLogic) GetErpSchPerm() (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	erpUserId, err := user.GetAcquirePerm(l.svcCtx.GetUserIdByJwt(l.ctx), l.svcCtx.Transformer, l.svcCtx.DB)
+	if err != nil {
+		logx.Error(err.Error())
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	if erpUserId == "" {
+		return &types.Response{}, nil
+	}
+	school, err := user.GetUserSchoolPerm(erpUserId, l.svcCtx.Transformer, l.svcCtx.DB)
+	if err != nil {
+		logx.Error(err.Error())
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	return &types.Response{200, "", school}, nil
+}

+ 44 - 0
internal/logic/mkt_active/get_erp_mkt_active_logic.go

@@ -0,0 +1,44 @@
+package mkt_active
+
+import (
+	"context"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
+	"net/http"
+	"strconv"
+
+	"git.i2edu.net/i2/i2-bill-api/internal/svc"
+	"git.i2edu.net/i2/i2-bill-api/internal/types"
+
+	"git.i2edu.net/i2/go-zero/core/logx"
+)
+
+type GetErpMktActiveLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetErpMktActiveLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetErpMktActiveLogic {
+	return GetErpMktActiveLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GetErpMktActiveLogic) GetErpMktActive(r *http.Request) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	r.ParseForm()
+	schIdStr := r.Form.Get("sch_id")
+	schId, err := strconv.ParseUint(schIdStr, 10, 64)
+	if err != nil {
+		logx.Error(err.Error())
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	resp, err := l.svcCtx.Transformer.GetErpActive(l.ctx, &transform.GetErpActiveReq{SchId: schId})
+	if err != nil {
+		logx.Error(err.Error())
+		return &types.Response{500, err.Error(), nil}, nil
+	}
+	return &types.Response{200, "", resp}, nil
+}

+ 0 - 2
internal/logic/mkt_part_time_user/mkt_part_time_user_add_logic.go

@@ -50,7 +50,6 @@ func (l *PartTimeUserAddLogic) PartTimeUserAdd(req types.PartTimeUserAddRequest)
 		LastUpdateTime: time.Now(),
 		DelFlag:        0,
 		MkId:           req.MkId,
-		CreateBy:       1,
 		CheckState:     54,
 		CheckDesc:      "",
 		CityId:         req.CityId,
@@ -58,7 +57,6 @@ func (l *PartTimeUserAddLogic) PartTimeUserAdd(req types.PartTimeUserAddRequest)
 		Sex:            req.Sex,
 		Target:         0,
 		UserId:         userId,
-		LastUpdateBy:   0,
 		Name:           req.Name,
 	}
 	res, err := model.NewI2billMktPartTimeUserModel(l.svcCtx.SqlConn).Insert(*bean)

+ 1 - 5
internal/logic/mkt_part_time_user/mkt_part_time_user_update_logic.go

@@ -2,11 +2,9 @@ package mkt_part_time_user
 
 import (
 	"context"
-	"git.i2edu.net/i2/i2-bill-api/model"
-	"time"
-
 	"git.i2edu.net/i2/i2-bill-api/internal/svc"
 	"git.i2edu.net/i2/i2-bill-api/internal/types"
+	"git.i2edu.net/i2/i2-bill-api/model"
 
 	"git.i2edu.net/i2/go-zero/core/logx"
 )
@@ -45,7 +43,6 @@ func (l *PartTimeUserUpdateLogic) PartTimeUserUpdate(req types.PartTimeUserAddRe
 			return &types.Response{Code: 500, Msg: "你已经是兼职人员:", Data: nil}, nil
 		}
 	}
-	bean.LastUpdateTime = time.Now()
 	bean.CheckState = 54
 	bean.CheckDesc = ""
 	bean.CityId = req.CityId
@@ -53,7 +50,6 @@ func (l *PartTimeUserUpdateLogic) PartTimeUserUpdate(req types.PartTimeUserAddRe
 	bean.Name = req.Name
 	bean.MkId = req.MkId
 	bean.IponeNumber = req.IponeNumber
-	bean.LastUpdateBy = userId
 	_, err = l.svcCtx.DB.ID(bean.Id).AllCols().Update(*bean)
 	if err != nil {
 		return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil

+ 12 - 1
internal/logic/user/get_user_logic.go

@@ -34,13 +34,24 @@ func (l *GetUserLogic) GetUser() (*types.InfoResponse, error) {
 		logx.Error(err)
 		return nil, err
 	}
-	// 每次都去查找, 暂时没有绑定
+	// 每次都去查找, 暂时没有绑定 erp mk
 	// resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Id: user.ErpId, Phone: user.Mobile})
 	resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Phone: user.Mobile})
 	if err != nil {
 		logx.Error(err)
 		return nil, err
 	}
+	if resp.ErpRoleType != 1 {
+		//是不是 兼职
+		res, err := l.svcCtx.DB.SQL("select * from i2bill_mkt_part_time_user where del_flag = 0 and user_id = ? and check_state = ?", l.UserId, 57).Query().List()
+		if err != nil {
+			logx.Error(err)
+			return nil, err
+		}
+		if len(res) > 0 {
+			resp.ErpRoleType = 2
+		}
+	}
 	info := &types.InfoResponse{}
 	info.ID = user.Id
 	info.Avatar = user.Avatar

+ 2 - 2
internal/logic/user/punch_clock_page_logic.go

@@ -31,8 +31,8 @@ func NewPunchClockPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) Pun
 func (l *PunchClockPageLogic) PunchClockPage(r *http.Request) (*types.Response, error) {
 	// todo: add your logic here and delete this line
 	r.ParseForm()
-	create_time_sta := r.Form.Get("create_time_sta")
-	create_time_end := r.Form.Get("create_time_end")
+	create_time_sta := r.Form.Get("date_sta")
+	create_time_end := r.Form.Get("date_end")
 	page, _ := strconv.Atoi(r.Form.Get("page"))
 	rows, _ := strconv.Atoi(r.Form.Get("rows"))
 	sort := r.Form.Get("__sort__")

+ 63 - 0
internal/logic/user/user_erp_info.go

@@ -0,0 +1,63 @@
+package user
+
+import (
+	"context"
+	"errors"
+	"git.i2edu.net/i2/go-zero/core/logx"
+	"git.i2edu.net/i2/i2-bill-api/model"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
+	"git.i2edu.net/i2/i2-bill-erp/transformclient"
+	"github.com/xormplus/xorm"
+	"strings"
+)
+
+func GetAcquirePerm(userId int64, rpcClient transformclient.Transform, engine *xorm.Engine) (string, error) {
+	//获取兼职
+	partUser := new(model.I2billMktPartTimeUser)
+	_, err := engine.SQL("select * from i2bill_mkt_part_time_user where del_flag = 0 and check_state = 57 and user_id = ?", userId).Get(partUser)
+	if err != nil {
+		return "", err
+	}
+	if partUser.Id != 0 {
+		return partUser.MkId, nil
+	}
+	//获取erp用户
+	user := new(model.User)
+	_, err = engine.SQL("select * from i2bill_user where del_flag = 0 and user_id = ?", userId).Get(user)
+	if err != nil {
+		return "", err
+	}
+	if user.Id == 0 {
+		logx.Error("用户不存在")
+		return "", errors.New("用户不存在")
+	}
+	ctx := context.Background()
+	in := new(transform.GetErpRoleReq)
+	in.Mobile = user.Mobile
+	erpRoles, err := rpcClient.GetErpRole(ctx, in)
+	if err != nil {
+		return "", err
+	}
+	//判定是不是 mk 还是 兼职
+	if erpRoles.UserId != "" {
+		roles := strings.Split(erpRoles.Role, ",")
+		for _, r := range roles {
+			if r == "LAMK" || r == "LAMKM" || r == "student/readingStudent" {
+				return erpRoles.UserId, nil
+			}
+		}
+
+	}
+	return "", nil
+}
+
+//获取校区权限
+func GetUserSchoolPerm(erpUserId string, rpcClient transformclient.Transform, engine *xorm.Engine) ([]*transform.OrganSchool, error) {
+	ctx := context.Background()
+	in := erpUserId
+	result, err := rpcClient.GetErpOrganSchPerByUserId(ctx, &transform.GetErpOrganSchPerByUserIdReq{UserId: in})
+	if err != nil {
+		return nil, err
+	}
+	return result.School, nil
+}

+ 15 - 12
internal/types/types.go

@@ -2,11 +2,11 @@
 package types
 
 type PageResult struct {
-	Page          int         `json:"page"`
-	Rows          int         `json:"rows"`
-	TotalSize     int64       `json:"totalSize"`
-	TotalPageSize int64       `json:"totalPageSize"`
-	Content       interface{} `json:"content"`
+	Page          int                      `json:"page"`
+	Rows          int                      `json:"rows"`
+	TotalSize     int64                    `json:"totalSize"`
+	TotalPageSize int64                    `json:"totalPageSize"`
+	Content       []map[string]interface{} `json:"content"`
 }
 
 type WXLoginResponse struct {
@@ -49,13 +49,16 @@ type LoginByWeixinRequest struct {
 }
 
 type AuthUserInfo struct {
-	ID       int64  `json:"id"`
-	Mobile   string `json:"mobile"`
-	UserName string `json:"username"`
-	NickName string `json:"nickname"`
-	Gender   int64  `json:"gender"`
-	Avatar   string `json:"avatar"`
-	Birthday int64  `json:"birthday"`
+	ID          int64  `json:"id"`
+	Mobile      string `json:"mobile"`
+	UserName    string `json:"username"`
+	NickName    string `json:"nickname"`
+	Gender      int64  `json:"gender"`
+	Avatar      string `json:"avatar"`
+	Birthday    int64  `json:"birthday"`
+	ErpRoleType int64  `json:"erp_role_type"`
+	ErpRole     string `json:"erp_role"`
+	MkId        string `json:"mk_id"`
 }
 
 type LoginByWeixinResponse struct {

+ 2 - 1
internal/utils/page_utils.go

@@ -17,6 +17,7 @@ func PageSearch(db *xorm.Engine, controllername string, apiname string, tableNam
 	}
 	if rows == 0 {
 		rows = 10
+		params["rows"] = rows
 	}
 	offset := (page - 1) * rows
 	params["offset"] = offset
@@ -38,7 +39,7 @@ func PageSearch(db *xorm.Engine, controllername string, apiname string, tableNam
 
 	if result == nil {
 		presult := types.PageResult{}
-		content := []interface{}{}
+		content := []map[string]interface{}{}
 		presult.Page = (page)
 		presult.Rows = (rows)
 		presult.Content = content

+ 2 - 1
internal/utils/utils.go

@@ -2,8 +2,8 @@ package utils
 
 import (
 	"database/sql"
-	"reflect"
 	"hash/crc32"
+	"reflect"
 	"strconv"
 	"time"
 
@@ -49,6 +49,7 @@ func GetTimeYmd() time.Time {
 	return time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
 }
 
+//剔除sqlx.NullTime等model数据结构
 func UnmarshalMysqlRows(row interface{}) []map[string]interface{} {
 	tyR := reflect.TypeOf(row)
 	if tyR.Kind() != reflect.Slice {

+ 6 - 5
model/i2bill_acquirer_mkt_qr.sql

@@ -3,13 +3,14 @@ DROP TABLE IF EXISTS `i2bill_acquirer_mkt_qr`;
 CREATE TABLE `i2bill_acquirer_mkt_qr`  (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
   `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id',
-  `qudao_id` varchar(300) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '渠道id',
-  `activity_id` varchar(300) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '活动id',
+  `qudao_id` int(11)  NULL DEFAULT NULL COMMENT '渠道id',
+  `activity_id` int(11)  NULL DEFAULT NULL COMMENT '活动id',
+  `school_id`   int(11) NULL DEFAULT NULL COMMENT '校区id',
   `qr` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '二维码url',
-  `del_flag` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
+  `del_flag` int(11)  NULL DEFAULT NULL,
   `create_time` datetime(0) NULL DEFAULT NULL,
-  `create_by` varchar(36) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
+  `create_by` int(11)  NULL DEFAULT NULL,
   `last_update_time` datetime(0) NULL DEFAULT NULL,
-  `last_update_by` varchar(36) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
+  `last_update_by` int(11) NULL DEFAULT NULL,
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

+ 30 - 15
model/i2bill_acquirer_mkt_qr_model.go

@@ -4,6 +4,7 @@ import (
 	"database/sql"
 	"fmt"
 	"strings"
+	"time"
 
 	"git.i2edu.net/i2/go-zero/core/stores/sqlc"
 	"git.i2edu.net/i2/go-zero/core/stores/sqlx"
@@ -32,23 +33,33 @@ type (
 	}
 
 	I2billAcquirerMktQr struct {
-		DelFlag        sql.NullString `db:"del_flag" json:"del_flag"`
+		SchoolId       sql.NullInt64  `db:"school_id" json:"school_id"` // 校区id
+		Qr             sql.NullString `db:"qr" json:"qr"`               // 二维码url
+		LastUpdateBy   sql.NullInt64  `db:"last_update_by" json:"last_update_by"`
+		Id             int64          `db:"id" json:"id"`                   // 主键
 		UserId         sql.NullInt64  `db:"user_id" json:"user_id"`         // 用户id
-		Qr             sql.NullString `db:"qr" json:"qr"`                   // 二维码url
-		ActivityId     sql.NullString `db:"activity_id" json:"activity_id"` // 活动id
-		CreateTime     sql.NullTime   `db:"create_time" json:"create_time"`
-		CreateBy       sql.NullString `db:"create_by" json:"create_by"`
+		ActivityId     sql.NullInt64  `db:"activity_id" json:"activity_id"` // 活动id
+		CreateBy       sql.NullInt64  `db:"create_by" json:"create_by"`
 		LastUpdateTime sql.NullTime   `db:"last_update_time" json:"last_update_time"`
-		LastUpdateBy   sql.NullString `db:"last_update_by" json:"last_update_by"`
-		Id             int64          `db:"id" json:"id"`             // 主键
-		QudaoId        sql.NullString `db:"qudao_id" json:"qudao_id"` // 渠道id
+		QudaoId        sql.NullInt64  `db:"qudao_id" json:"qudao_id"` // 渠道id
+		DelFlag        sql.NullInt64  `db:"del_flag" json:"del_flag"`
+		CreateTime     sql.NullTime   `db:"create_time" json:"create_time"`
+	}
+	I2billAcquirerMktQrXorm struct {
+		SchoolId       int64     `json:"school_id"`
+		Qr             string    `json:"qr"`
+		LastUpdateBy   int64     `json:"last_update_by"`
+		Id             int64     `json:"id"`
+		UserId         int64     `json:"user_id"`
+		ActivityId     int64     `json:"activity_id"`
+		CreateBy       int64     `json:"create_by"`
+		LastUpdateTime time.Time `json:"last_update_time"`
+		QudaoId        int64     `json:"qudao_id"`
+		DelFlag        int64     `json:"del_flag"`
+		CreateTime     time.Time `json:"create_time"`
 	}
 )
 
-func (t *I2billAcquirerMktQr) TableName() string {
-	return "i2bill_acquirer_mkt_qr"
-}
-
 func NewI2billAcquirerMktQrModel(conn sqlx.SqlConn) I2billAcquirerMktQrModel {
 	return &defaultI2billAcquirerMktQrModel{
 		conn:  conn,
@@ -57,8 +68,8 @@ func NewI2billAcquirerMktQrModel(conn sqlx.SqlConn) I2billAcquirerMktQrModel {
 }
 
 func (m *defaultI2billAcquirerMktQrModel) Insert(data I2billAcquirerMktQr) (sql.Result, error) {
-	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, i2billAcquirerMktQrRowsExpectAutoSet)
-	ret, err := m.conn.Exec(query, data.DelFlag, data.UserId, data.Qr, data.ActivityId, data.CreateBy, data.LastUpdateTime, data.LastUpdateBy, data.QudaoId)
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, i2billAcquirerMktQrRowsExpectAutoSet)
+	ret, err := m.conn.Exec(query, data.SchoolId, data.Qr, data.LastUpdateBy, data.UserId, data.ActivityId, data.CreateBy, data.LastUpdateTime, data.QudaoId, data.DelFlag)
 	return ret, err
 }
 
@@ -78,7 +89,7 @@ func (m *defaultI2billAcquirerMktQrModel) FindOne(id int64) (*I2billAcquirerMktQ
 
 func (m *defaultI2billAcquirerMktQrModel) Update(data I2billAcquirerMktQr) error {
 	query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, i2billAcquirerMktQrRowsWithPlaceHolder)
-	_, err := m.conn.Exec(query, data.DelFlag, data.UserId, data.Qr, data.ActivityId, data.CreateBy, data.LastUpdateTime, data.LastUpdateBy, data.QudaoId, data.Id)
+	_, err := m.conn.Exec(query, data.SchoolId, data.Qr, data.LastUpdateBy, data.UserId, data.ActivityId, data.CreateBy, data.LastUpdateTime, data.QudaoId, data.DelFlag, data.Id)
 	return err
 }
 
@@ -87,3 +98,7 @@ func (m *defaultI2billAcquirerMktQrModel) Delete(id int64) error {
 	_, err := m.conn.Exec(query, id)
 	return err
 }
+
+func (t *I2billAcquirerMktQrXorm) TableName() string {
+	return "i2bill_acquirer_mkt_qr"
+}

+ 2 - 2
model/i2bill_mkt_part_time_user.sql

@@ -10,9 +10,9 @@ CREATE TABLE `i2bill_mkt_part_time_user`  (
   `city_id` int(0) NOT NULL DEFAULT 0  COMMENT '城市',
   `check_state` int(0) NOT NULL DEFAULT 54 COMMENT '审核状态',
   `check_desc` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '审核失败描述',
-  `create_by`  int(0)  NOT NULL DEFAULT 0,
+  `create_by`  varchar(36)   NULL DEFAULT null,
   `create_time` datetime(0)  NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  `last_update_by`  int(0)  NOT NULL DEFAULT 0,
+  `last_update_by`  varchar(36)   NULL DEFAULT NULL,
   `last_update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `del_flag` int(0) NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`) USING BTREE,

+ 2 - 2
model/i2bill_mkt_part_time_user_model.go

@@ -41,13 +41,13 @@ type (
 		CheckState     int64     `db:"check_state" json:"check_state"` // 审核状态
 		CreateTime     time.Time `db:"create_time" json:"create_time"`
 		LastUpdateTime time.Time `db:"last_update_time" json:"last_update_time"`
-		LastUpdateBy   int64     `db:"last_update_by" json:"last_update_by"`
+		LastUpdateBy   string    `db:"last_update_by" json:"last_update_by"`
 		Id             int64     `db:"id" json:"id"`
 		IponeNumber    string    `db:"ipone_number" json:"ipone_number"`
 		Target         int64     `db:"target" json:"target"`   // 目标人数
 		MkId           string    `db:"mk_id" json:"mk_id"`     // 所属erp mk id
 		CityId         int64     `db:"city_id" json:"city_id"` // 城市
-		CreateBy       int64     `db:"create_by" json:"create_by"`
+		CreateBy       string    `db:"create_by" json:"create_by"`
 	}
 )