charge.go 1.07 KB
Newer Older
chenweijian's avatar
chenweijian committed
1 2 3
package charge_r

import (
chenweijian's avatar
chenweijian committed
4
	"git.hilo.cn/hilo-common/domain"
chenweijian's avatar
chenweijian committed
5 6
	"git.hilo.cn/hilo-common/mycontext"
	"github.com/gin-gonic/gin"
chenweijian's avatar
chenweijian committed
7 8 9
	"hilo-group/domain/cache/user_c"
	"hilo-group/domain/service/diamond_s"
	"hilo-group/req"
chenweijian's avatar
chenweijian committed
10 11 12 13 14
	"hilo-group/resp"
)

// @Tags 充值
// @Summary 是否可以分享充值链接
chenweijian's avatar
chenweijian committed
15
// @Param externalId query string true "分享对象的external id"
chenweijian's avatar
chenweijian committed
16 17 18 19
// @Success 200
// @Router /v1/charge/share [get]
func CanShareChargeLink(c *gin.Context) (*mycontext.MyContext, error) {
	myContext := mycontext.CreateMyContext(c.Keys)
chenweijian's avatar
chenweijian committed
20 21 22 23 24 25

	userId, lang, err := req.GetUserIdLang(c, myContext)
	if err != nil {
		return myContext, err
	}

chenweijian's avatar
chenweijian committed
26
	extId := c.Query("externalId")
chenweijian's avatar
chenweijian committed
27 28 29 30 31 32 33 34 35 36 37 38
	model := domain.CreateModelContext(myContext)
	toUser, err := user_c.GetUserByExternalId(model, extId)
	if err != nil {
		return myContext, err
	}

	// 家族限制检查
	if err = diamond_s.NewDiamondService(myContext).CheckDealerTransferFamilyLimit(userId, toUser.ID, lang); err != nil {
		myContext.Log.Errorf("CanShareChargeLink err:%v", err)
		return myContext, err
	}

chenweijian's avatar
chenweijian committed
39
	resp.ResponseOk(c, nil)
chenweijian's avatar
chenweijian committed
40 41
	return myContext, nil
}