From 537fa7b7ea3facc3161d5baa99e18378933480c8 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Thu, 24 Jun 2021 15:27:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/misc/misc.go | 44 --- controllers/auth2_contoller.go | 340 ------------------ controllers/bill_controller.go | 28 -- controllers/cms.go | 160 --------- controllers/event_controller.go | 328 ------------------ controllers/job_controller.go | 567 ------------------------------- controllers/mtwm_callback.go | 32 -- controllers/order_controller.go | 207 ----------- controllers/tonglian_callback.go | 40 --- controllers/union_controller.go | 164 --------- controllers/user2_controller.go | 448 ------------------------ controllers/wxpay_callback.go | 42 --- globals/api/api.go | 154 --------- globals/api2/api2.go | 20 -- globals/beegodb/beegodb.go | 35 -- globals/globals.go | 122 ------- main.go | 128 +------ routers/router.go | 50 +-- 18 files changed, 10 insertions(+), 2899 deletions(-) delete mode 100644 controllers/auth2_contoller.go delete mode 100644 controllers/bill_controller.go delete mode 100644 controllers/cms.go delete mode 100644 controllers/event_controller.go delete mode 100644 controllers/job_controller.go delete mode 100644 controllers/mtwm_callback.go delete mode 100644 controllers/order_controller.go delete mode 100644 controllers/tonglian_callback.go delete mode 100644 controllers/union_controller.go delete mode 100644 controllers/user2_controller.go delete mode 100644 controllers/wxpay_callback.go delete mode 100644 globals/api2/api2.go diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 77c3e1e39..d709f8b49 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -1,59 +1,15 @@ package misc import ( - "git.rosy.net.cn/jx-callback/business/jxstore/partner/pdd" "time" - "git.rosy.net.cn/jx-callback/business/jxstore/event" - - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/globals" ) -var ( - dailyWorkTimeList = []string{ - "00:00:30", - } - stationTimeList = []string{ - "11:35:00", - } -) - func Init() { - if globals.IsProductEnv() { - //拼多多订单轮询 - ScheduleTimerFuncByInterval(func() { - pdd.GetUnionOrders() - }, 5*time.Second, 5*time.Minute) - - ScheduleTimerFunc("doDailyWork", doDailyWork, dailyWorkTimeList) - - ScheduleTimerFunc("InitStation", func() { - //同步油站信息 - cms.InitStation(jxcontext.AdminCtx) - }, stationTimeList) - } -} - -func doDailyWork() { - globals.SugarLogger.Debug("doDailyWork") - //刷新任务过期状态 - cms.RefreshJobStatus(jxcontext.AdminCtx) - //刷新任务标签状态 - cms.RefreshJobSpan(jxcontext.AdminCtx) - //刷新用户会员时间 - cms.RefreshUserMemberStatus(jxcontext.AdminCtx) - //删除聊天记录 - event.DeleteMessageRecord(jxcontext.AdminCtx) - //自动确认收货(刷新状态) - cms.RefreshDropShippingJob(jxcontext.AdminCtx) - //刷新京东快递 - cms.RefreshJdDelivery(jxcontext.AdminCtx) } // 按时间序列循环 diff --git a/controllers/auth2_contoller.go b/controllers/auth2_contoller.go deleted file mode 100644 index 9924daacf..000000000 --- a/controllers/auth2_contoller.go +++ /dev/null @@ -1,340 +0,0 @@ -package controllers - -import ( - "encoding/base64" - "fmt" - "net/http" - "strings" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/auth2" - "git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding" - _ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile" // 强制导入mobile认证方式 - "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password" - "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/globals" - beego "github.com/astaxie/beego/adapter" -) - -func GetComposedCode(c *beego.Controller, code string) (composedCode string) { - composedCode = code - referer := c.Ctx.Request.Referer() - globals.SugarLogger.Debugf("GetComposedCode referer:%s", referer) - index := strings.Index(referer, "//") - if index > 0 { - list := strings.Split(referer[index+2:], "/") - if len(list) >= 2 { - composedCode = weixin.ComposeJsCode(list[1], code) - } - } - return composedCode -} - -type Auth2Controller struct { - beego.Controller -} - -// @Title 生成captcha -// @Description 生成captcha -// @Param width formData int true "图片宽" -// @Param height formData int true "图片高" -// @Param captchaLen formData int false captcha码长度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateCaptcha [post] -func (c *Auth2Controller) CreateCaptcha() { - c.callCreateCaptcha(func(params *tAuth2CreateCaptchaParams) (retVal interface{}, errCode string, err error) { - retVal, err = auth2.CreateCaptcha(params.Width, params.Height, params.CaptchaLen) - return retVal, "", err - }) -} - -// @Title 发送验证码 -// @Description 发送验证码(captcha码与authToken二者必须至少有一个) -// @Param captchaID formData string false "captcha码ID" -// @Param captchaValue formData string false "captcha码值" -// @Param authToken formData string false "之前的认证信息" -// @Param authID formData string true "手机号或邮件" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendVerifyCode [post] -func (c *Auth2Controller) SendVerifyCode() { - c.callSendVerifyCode(func(params *tAuth2SendVerifyCodeParams) (retVal interface{}, errCode string, err error) { - _, _, err = auth2.SendVerifyCode(params.AuthToken, params.CaptchaID, params.CaptchaValue, params.AuthID) - // if err == nil && authInfo != nil { - // user, err2 := dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID()) - // if err2 == nil && user.Type&(model.UserTypeBoss|model.UserTypeOperator) != 0 { - // retVal = code - // } - // } - return retVal, "", err - }) -} - -// @Title 登录接口 -// @Description 登录接口(微信与公众号登录不能直接调用此接口) -// @Param authType formData string true "登录类型,当前支持[localpass:本地账号密码,mobile:手机短信,wxqrcode:微信登录,weixinsns:微信公众号,weixinmini;小程序,wxnative:微信APP,ddstaff:钉钉企业,ddqrcode:钉钉扫码,alipaycode:支付宝小程序]" -// @Param authSecret formData string true "不同登录类型的登录秘密,如果是localpass登录类型,是md5后的值(空串不要md5)" -// @Param authID formData string false "登录ID,登录类型为localpass时依赖于authIDType,其它为相应登录类型的id" -// @Param authIDType formData string false "只有在登录类型为localpass时,才有意义,分别为:userid2:用户名,email,mobile" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Login [post] -func (c *Auth2Controller) Login() { - c.callLogin(func(params *tAuth2LoginParams) (retVal interface{}, errCode string, err error) { - if params.AuthType == auth2.AuthTypeMobile { - params.AuthIDType = auth2.UserIDMobile - } else if params.AuthType == auth2.AuthTypeEmail { - params.AuthIDType = auth2.UserIDEmail - } - if params.AuthType == weixin.AuthTypeMini { - params.AuthSecret = GetComposedCode(&c.Controller, params.AuthSecret) - } - ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request) - authInfo, err := auth2.Login(ctx, params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret) - // TODO 兼容没有取到authid2的错误 - if err == nil && authInfo.AuthBindInfo != nil { - if authInfo.AuthBindInfo.AuthID2 == "" { - authInfo.AuthBindInfo.AuthID2 = authInfo.AuthBindInfo.AuthID - } - retVal = authInfo - } - return retVal, "", err - }) -} - -// @Title 得到自己登录token的信息 -// @Description 得到自己登录token的信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetTokenInfo [get] -func (c *Auth2Controller) GetTokenInfo() { - c.callGetTokenInfo(func(params *tAuth2GetTokenInfoParams) (retVal interface{}, errCode string, err error) { - if true { //auth2.IsV2Token(params.Token) { - retVal, err = auth2.GetTokenInfo(params.Token) - } else { - // retVal, err = auth.GetUserInfo(params.Token) - } - if err == model.ErrTokenIsInvalid { - errCode = model.ErrCodeTokenIsInvalid - } - return retVal, errCode, err - }) -} - -// @Title 微信扫码认证回调接口 -// @Description 微信扫码认证回调接口,自己不能直接调用 -// @Param code query string true "客户同意后得到的code" -// @Param block query string true "回调地址" -// @Param state query string false "微信回调的登录状态" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /WeixinOAuth2 [get] -func (c *Auth2Controller) WeixinOAuth2() { - var ( - redirectURL string - callResult *CallResult - ) - c.callWeixinOAuth2(func(params *tAuth2WeixinOAuth2Params) (retVal interface{}, errCode string, err error) { - ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request) - authInfo, err := auth2.Login(ctx, weixin.AuthTypeWeixin, params.State, "", params.Code) - if err == nil { - callResult = &CallResult{ - Code: model.ErrCodeSuccess, - Data: string(utils.MustMarshal(authInfo)), - } - } else { - callResult = &CallResult{ - Code: model.ErrCodeGeneralFailed, - Desc: err.Error(), - } - } - redirectURL = fmt.Sprintf("%s?info=%s", params.Block, base64.StdEncoding.EncodeToString(utils.MustMarshal(callResult))) - return retVal, model.ErrorCodeIgnore, err - }) - globals.SugarLogger.Debugf("WeixinOAuth2, callResult:%s, redirectURL:%s", utils.Format4Output(callResult, true), redirectURL) - c.Redirect(redirectURL, http.StatusTemporaryRedirect) -} - -// @Title 微信公众号认证回调接口 -// @Description 微信公众号认证回调接口,自己不能直接调用 -// @Param code query string true "客户同意后得到的code" -// @Param block query string true "回调地址" -// @Param state query string false "微信回调的登录状态" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /WeixinMPOAuth2 [get] -func (c *Auth2Controller) WeixinMPOAuth2() { - var ( - redirectURL string - callResult *CallResult - ) - c.callWeixinMPOAuth2(func(params *tAuth2WeixinMPOAuth2Params) (retVal interface{}, errCode string, err error) { - ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request) - authInfo, err := auth2.Login(ctx, weixin.AuthTypeMP, params.State, "", params.Code) - if err == nil { - callResult = &CallResult{ - Code: model.ErrCodeSuccess, - Data: string(utils.MustMarshal(authInfo)), - } - } else { - callResult = &CallResult{ - Code: model.ErrCodeGeneralFailed, - Desc: err.Error(), - } - } - redirectURL = fmt.Sprintf("%s?info=%s", params.Block, base64.StdEncoding.EncodeToString(utils.MustMarshal(callResult))) - return retVal, model.ErrorCodeIgnore, err - }) - globals.SugarLogger.Debugf("WeixinMPOAuth2, callResult:%s, redirectURL:%s", utils.Format4Output(callResult, true), redirectURL) - c.Redirect(redirectURL, http.StatusTemporaryRedirect) -} - -// @Title 钉钉认证回调接口 -// @Description 钉钉认证回调接口,自己不能直接调用 -// @Param code query string true "客户同意后得到的code" -// @Param block query string false "回调地址" -// @Param state query string false "微信回调的登录状态" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DingDingOAuth2 [get] -func (c *Auth2Controller) DingDingOAuth2() { - var ( - redirectURL string - callResult *CallResult - ) - c.callDingDingOAuth2(func(params *tAuth2DingDingOAuth2Params) (retVal interface{}, errCode string, err error) { - if params.Block == "" { - params.Block = params.State - params.State = "" - } - ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request) - authInfo, err := auth2.Login(ctx, dingding.AuthTypeQRCode, params.State, "", params.Code) - if err == nil { - callResult = &CallResult{ - Code: model.ErrCodeSuccess, - Data: string(utils.MustMarshal(authInfo)), - } - } else { - callResult = &CallResult{ - Code: model.ErrCodeGeneralFailed, - Desc: err.Error(), - } - } - if params.Block != "" { - redirectURL = fmt.Sprintf("%s?info=%s", params.Block, base64.StdEncoding.EncodeToString(utils.MustMarshal(callResult))) - } - return retVal, model.ErrorCodeIgnore, err - }) - globals.SugarLogger.Debugf("DingDingOAuth2, callResult:%s, redirectURL:%s", utils.Format4Output(callResult, true), redirectURL) - if redirectURL != "" { - c.Redirect(redirectURL, http.StatusTemporaryRedirect) - } -} - -// @Title 登出接口 -// @Description 登出接口(此接口兼容V1的TOKEN) -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Logout [delete] -func (c *Auth2Controller) Logout() { - c.callLogout(func(params *tAuth2LogoutParams) (retVal interface{}, errCode string, err error) { - if authInfo, ok := params.Ctx.GetLoginInfo().(*auth2.AuthInfo); ok { - err = auth2.Logout(authInfo) - } else { - // err = auth.Logout(params.Token) - } - return nil, "", err - }) -} - -// @Title 绑定认证方式 -// @Description 绑定认证方式 -// @Param token header string true "认证token" -// @Param authToken formData string true "之前通过login得到的新认证TOKEN" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddAuthBind [post] -func (c *Auth2Controller) AddAuthBind() { - c.callAddAuthBind(func(params *tAuth2AddAuthBindParams) (retVal interface{}, errCode string, err error) { - authInfo, err2 := params.Ctx.GetV2AuthInfo() - if err := err2; err == nil { - newAuthInfo, err2 := auth2.GetTokenInfo(params.AuthToken) - if err = err2; err == nil { - err = auth2.AddAuthBind(authInfo, newAuthInfo) - } - } - return retVal, "", err - }) -} - -// @Title 绑定认证方式 -// @Description 绑定认证方式 -// @Param token header string true "认证token" -// @Param authToken formData string true "之前通过login得到的新认证TOKEN" -// @Param mobile formData string true "之前通过getuserbyminiinfo得到的" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddAuthBindWithMobile [post] -func (c *Auth2Controller) AddAuthBindWithMobile() { - c.callAddAuthBindWithMobile(func(params *tAuth2AddAuthBindWithMobileParams) (retVal interface{}, errCode string, err error) { - newAuthInfo, err := auth2.GetTokenInfo(params.AuthToken) - err = auth2.AddAuthBindWithMobile(newAuthInfo, params.Mobile) - return retVal, "", err - }) -} - -// @Title 删除认证方式 -// @Description 删除认证方式 -// @Param token header string true "认证token" -// @Param authType query string true "登录类型,参见Login的描述" -// @Param authTypeID query string false "登录类型标识" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RemoveAuthBind [delete] -func (c *Auth2Controller) RemoveAuthBind() { - c.callRemoveAuthBind(func(params *tAuth2RemoveAuthBindParams) (retVal interface{}, errCode string, err error) { - authInfo, err2 := params.Ctx.GetV2AuthInfo() - if err = err2; err == nil { - err = auth2.UnbindAuth(authInfo.GetID(), params.AuthType, params.AuthTypeID, params.Ctx.GetUserName()) - } - return retVal, "", err - }) -} - -// @Title 修改(或初始化)密码 -// @Description 修改(或初始化)密码 -// @Param token header string true "认证token" -// @Param oldPwd query string false "原密码md5,如果是重置或新设,为空" -// @Param newPwd query string true "新密码md5" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ChangePassword [put] -func (c *Auth2Controller) ChangePassword() { - c.callChangePassword(func(params *tAuth2ChangePasswordParams) (retVal interface{}, errCode string, err error) { - authInfo, err := params.Ctx.GetV2AuthInfo() - if err == nil { - err = password.AutherObj.ChangePassword(authInfo.GetID(), params.Ctx.GetUserName(), params.OldPwd, params.NewPwd) - } - return retVal, "", err - }) -} - -// @Title 清除除参数token以外的这个人的token -// @Description 清除除参数token以外的这个人的token -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeletedTokenInfoWithoutParam [put] -func (c *Auth2Controller) DeletedTokenInfoWithoutParam() { - c.callDeletedTokenInfoWithoutParam(func(params *tAuth2DeletedTokenInfoWithoutParamParams) (retVal interface{}, errCode string, err error) { - newAuthInfo, err2 := auth2.GetTokenInfo(params.Token) - if err = err2; err == nil { - err = auth2.DeletedTokenInfoWithoutParam(newAuthInfo) - } - return retVal, "", err - }) -} diff --git a/controllers/bill_controller.go b/controllers/bill_controller.go deleted file mode 100644 index 1e5830089..000000000 --- a/controllers/bill_controller.go +++ /dev/null @@ -1,28 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/financial" - beego "github.com/astaxie/beego/adapter" -) - -type BillController struct { - beego.Controller -} - -// @Title 查看用户账户收支明细 -// @Description 查看用户账户收支明细 -// @Param token header string true "认证token" -// @Param userID query string true "用户ID" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param offset query int false "列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserBillDetail [get] -func (c *BillController) GetUserBillDetail() { - c.callGetUserBillDetail(func(params *tBillGetUserBillDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = financial.GetUserBillDetail(params.Ctx, params.UserID, params.FromTime, params.ToTime, params.PageSize, params.Offset) - return retVal, "", err - }) -} diff --git a/controllers/cms.go b/controllers/cms.go deleted file mode 100644 index c2f43996d..000000000 --- a/controllers/cms.go +++ /dev/null @@ -1,160 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/initdata" - "git.rosy.net.cn/jx-callback/business/jxutils/datares" - beego "github.com/astaxie/beego/adapter" -) - -type CmsController struct { - beego.Controller -} - -// @Title 新增配置 -// @Description 新增配置 -// @Param token header string true "认证token" -// @Param type formData string true "配置类型(当前只支持PricePack)" -// @Param key formData string true "配置名" -// @Param value formData string true "配置值" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /NewConfig [post] -func (c *CmsController) NewConfig() { - c.callNewConfig(func(params *tCmsNewConfigParams) (retVal interface{}, errCode string, err error) { - err = cms.AddConfig(params.Ctx, params.Key, params.Type, params.Value) - return retVal, "", err - }) -} - -// @Title 删除配置 -// @Description 删除配置 -// @Param token header string true "认证token" -// @Param type query string true "配置类型(当前只支持PricePack)" -// @Param key query string true "配置名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteConfig [delete] -func (c *CmsController) DeleteConfig() { - c.callDeleteConfig(func(params *tCmsDeleteConfigParams) (retVal interface{}, errCode string, err error) { - err = cms.DeleteConfig(params.Ctx, params.Key, params.Type) - return retVal, "", err - }) -} - -// @Title 修改配置 -// @Description 修改配置 -// @Param token header string true "认证token" -// @Param type formData string true "配置类型(当前只支持PricePack)" -// @Param key formData string true "配置名" -// @Param value formData string true "配置值" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateConfig [put] -func (c *CmsController) UpdateConfig() { - c.callUpdateConfig(func(params *tCmsUpdateConfigParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.UpdateConfig(params.Ctx, params.Key, params.Type, params.Value) - return retVal, "", err - }) -} - -// @Title 查询配置 -// @Description 查询配置 -// @Param token header string fasle "认证token" -// @Param type query string false "配置类型(当前只支持PricePack)" -// @Param key query string false "配置名" -// @Param keyword query string false "关键字" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryConfigs [get] -func (c *CmsController) QueryConfigs() { - c.callQueryConfigs(func(params *tCmsQueryConfigsParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.QueryConfigs(params.Key, params.Type, params.Keyword) - return retVal, "", err - }) -} - -// @Title 得到七牛上传服务临时token -// @Description 得到七牛上传服务临时token,当前设置为5分钟内有效。正常使用场景为每次上传资源前实时获取,而不是保存下来一直使用,如果hashCode有值,且本地有,可能直接返回URL -// @Param token header string true "认证token" -// @Param suffix query string true "前缀" -// @Param hashCode query string false "图片hash" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetQiniuUploadToken [get] -func (c *CmsController) GetQiniuUploadToken() { - c.callGetQiniuUploadToken(func(params *tCmsGetQiniuUploadTokenParams) (retVal interface{}, errCode string, err error) { - retVal, err = datares.GetQiniuUploadToken(params.Ctx, params.Suffix, params.HashCode) - return retVal, "", err - }) -} - -// @Title 得到服务相关的一些基础信息 -// @Description 得到服务相关的一些基础信息,包括版本,及一些元数据信息 -// @Param token header string false "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetServiceInfo [get] -func (c *CmsController) GetServiceInfo() { - c.callGetServiceInfo(func(params *tCmsGetServiceInfoParams) (retVal interface{}, errCode string, err error) { - retVal = cms.GetServiceInfo(params.Ctx) - return retVal, "", err - }) -} - -// @Title init place -// @Description init place -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InitPlace [post] -func (c *CmsController) InitPlace() { - c.callInitPlace(func(params *tCmsInitPlaceParams) (retVal interface{}, errCode string, err error) { - err = initdata.InitPlace(params.Ctx) - return retVal, "", err - }) -} - -// @Title 得到地点(省,城市,区)信息 -// @Description 得到地点(省,城市,区)信息。 -// @Param token header string false "认证token" -// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)" -// @Param parentCode query int false "上级地点code,这个指的是国家标准CODE(中国为:100000,北京为:110000,北京市为:110100),不是数据库中的ID" -// @Param level query int false "地点级别:省为1,市为2,区为3,注意直辖市也要分省与市级" -// @Param includeDisabled query bool false "是否包括禁用的城市(缺省不包括)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPlaces [get] -func (c *CmsController) GetPlaces() { - c.callGetPlaces(func(params *tCmsGetPlacesParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetPlaces(params.Ctx, params.Keyword, params.IncludeDisabled, params.MapData) - return retVal, "", err - }) -} - -// @Title 修改地点信息 -// @Description 只支持修改enabled, jd_code和mtps_price这三个属性 -// @Param token header string true "认证token" -// @Param code formData int true "地点编号,注意是code不是ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdatePlace [put] -func (c *CmsController) UpdatePlace() { - c.callUpdatePlace(func(params *tCmsUpdatePlaceParams) (retVal interface{}, errCode string, err error) { - - return retVal, "", err - }) -} - -// @Title init station -// @Description init station -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InitStation [post] -func (c *CmsController) InitStation() { - c.callInitStation(func(params *tCmsInitStationParams) (retVal interface{}, errCode string, err error) { - err = cms.InitStation(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/event_controller.go b/controllers/event_controller.go deleted file mode 100644 index eab29576e..000000000 --- a/controllers/event_controller.go +++ /dev/null @@ -1,328 +0,0 @@ -package controllers - -import ( - "fmt" - "io" - "log" - "net/http" - "os" - "path" - "time" - - "git.rosy.net.cn/jx-callback/business/jxstore/event" - "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - "git.rosy.net.cn/jx-callback/globals" - - "git.rosy.net.cn/jx-callback/business/jxutils" - - "git.rosy.net.cn/jx-callback/business/model/dao" - - "git.rosy.net.cn/jx-callback/business/model" - - "github.com/gorilla/websocket" - - "git.rosy.net.cn/baseapi/utils" - - beego "github.com/astaxie/beego/adapter" -) - -// 操作事件明细相关API -type EventController struct { - beego.Controller -} - -const ( - audioPath = "/jxdata/cthrgw/dist/audio/" -) - -// 配置升级程序(升级为websocket) -var upgrader = websocket.Upgrader{} - -// @Title 测试websocket -// @Description 测试websocket -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TestWebsocket [get] -func (c *EventController) TestWebsocket() { - // 解决跨域问题(微信小程序) - upgrader.CheckOrigin = func(r *http.Request) bool { - return true - } - //升级将HTTP服务器连接升级到WebSocket协议。 - //responseHeader包含在对客户端升级的响应中 - //请求。使用responseHeader指定Cookie(设置Cookie)和 - //应用程序协商的子目录(Sec WebSocket协议)。 - //如果升级失败,则升级将向客户端答复一个HTTP错误 - ws, err := upgrader.Upgrade(c.Ctx.ResponseWriter, c.Ctx.Request, nil) - if err != nil { - log.Fatal(err) - } - var ( - userID = c.GetString("userID") - ) - if userID == "" { - return - } - if globals.IsProductEnv() { - _, _, err = jxcontext.New(nil, c.GetString("token"), c.Ctx.ResponseWriter, c.Ctx.Request) - if err != nil { - msg := &CallResult{ - Code: model.ErrCodeGeneralFailed, - Desc: err.Error(), - } - ws.WriteJSON(&msg) - } - globals.SugarLogger.Debugf("TestWebsocket connection...") - } - c.EnableRender = false //Beego不启用渲染 - go event.ImMessage(userID, ws) -} - -// @Title 查询聊天记录 -// @Description 查询聊天记录 -// @Param token header string true "认证token" -// @Param groupID query int true "组ID" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetImMessageRecord [get] -func (c *EventController) GetImMessageRecord() { - c.callGetImMessageRecord(func(params *tEventGetImMessageRecordParams) (retVal interface{}, errCode string, err error) { - var db = dao.GetDB() - retVal, err = dao.GetImMessageRecord(db, params.GroupID, "", params.Ctx.GetUserID(), 0, -1, utils.Str2Time(params.FromTime), utils.Str2Time(params.ToTime), params.Offset, params.PageSize) - //清除此用户组所有的未读标记 - if messageGroupReads, err := dao.GetMessageGroupRead(db, params.Ctx.GetUserID(), params.GroupID); err == nil { - for _, v := range messageGroupReads { - v.UnReadCount = 0 - dao.UpdateEntity(db, v, "UnReadCount") - } - } - return retVal, "", err - }) -} - -// @Title 用户未读消息设置 -// @Description 用户未读消息设置,用户在退出登录,ws关闭,以及关闭小程序或app时调用 -// @Param token header string true "认证token" -// @Param payload query string true "messageGroupRead 格式[{"groupID":,"unReadCount":}]" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateUserMessageGroupRead [post] -func (c *EventController) UpdateUserMessageGroupRead() { - c.callUpdateUserMessageGroupRead(func(params *tEventUpdateUserMessageGroupReadParams) (retVal interface{}, errCode string, err error) { - var reads []*model.MessageGroupRead - if err = jxutils.Strings2Objs(params.Payload, &reads); err == nil { - err = event.UpdateUserMessageGroupRead(params.Ctx, reads) - } - return retVal, "", err - }) -} - -// @Title 发送聊天消息(限定系统消息) -// @Description 发送聊天消息(限定系统消息) -// @Param token header string true "认证token" -// @Param payload formData string true "immessageRecord 类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendSysMessage [post] -func (c *EventController) SendSysMessage() { - c.callSendSysMessage(func(params *tEventSendSysMessageParams) (retVal interface{}, errCode string, err error) { - var imMessageRecord *model.ImMessageRecord - if err = jxutils.Strings2Objs(params.Payload, &imMessageRecord); err == nil { - err = event.SendSysMessage(params.Ctx, imMessageRecord) - } - return retVal, "", err - }) -} - -// @Title 创建聊天组 -// @Description 创建聊天组 -// @Param token header string true "认证token" -// @Param userID formData string true "创建者id" -// @Param userID2 formData string false "被拉的id 如果userID2为空就默认为是创建的群聊" -// @Param name formData string false "如果是群聊,则要传入群名" -// @Param dividePercentage formData int false "如果是群聊,则要传入分成比例" -// @Param quitPrice formData int false "如果是群聊,则要传入退团金额" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateMessageGroup [post] -func (c *EventController) CreateMessageGroup() { - c.callCreateMessageGroup(func(params *tEventCreateMessageGroupParams) (retVal interface{}, errCode string, err error) { - retVal, err = event.CreateMessageGroup(params.Ctx, params.UserID, params.UserID2, params.Name, params.DividePercentage, params.QuitPrice) - return retVal, "", err - }) -} - -// @Title 查询某个用户所有聊天组 -// @Description 查询某个用户所有聊天组 -// @Param token header string true "认证token" -// @Param userID query string true "userid" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMessageGroupByUser [get] -func (c *EventController) GetMessageGroupByUser() { - c.callGetMessageGroupByUser(func(params *tEventGetMessageGroupByUserParams) (retVal interface{}, errCode string, err error) { - retVal, err = event.GetMessageGroupByUser(params.Ctx, params.UserID) - return retVal, "", err - }) -} - -// @Title 查询聊天组 -// @Description 查询聊天组 -// @Param token header string true "认证token" -// @Param groupID query int true "groupID" -// @Param isMember query bool true "是否查询组员" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMessageGroups [get] -func (c *EventController) GetMessageGroups() { - c.callGetMessageGroups(func(params *tEventGetMessageGroupsParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetMessageGroups(dao.GetDB(), "", params.GroupID, model.GroupTypeMulit, params.IsMember, "") - return retVal, "", err - }) -} - -// @Title 加入用户组 -// @Description 加入用户组 -// @Param token header string true "认证token" -// @Param groupID formData int true "组号" -// @Param userID formData string true "被邀请人ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddMessageGroup [post] -func (c *EventController) AddMessageGroup() { - c.callAddMessageGroup(func(params *tEventAddMessageGroupParams) (retVal interface{}, errCode string, err error) { - err = event.AddMessageGroup(params.Ctx, params.GroupID, params.UserID) - return retVal, "", err - }) -} - -// @Title 修改群组信息 -// @Description 修改群组信息 -// @Param token header string true "认证token" -// @Param groupID formData int true "组号" -// @Param payload formData string true "群组 payload" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateMessageGroup [put] -func (c *EventController) UpdateMessageGroup() { - c.callUpdateMessageGroup(func(params *tEventUpdateMessageGroupParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { - retVal, err = event.UpdateMessageGroup(params.Ctx, params.GroupID, payload) - } - return retVal, "", err - }) -} - -// @Title 退出用户组(踢人) -// @Description 退出用户组(踢人) -// @Param token header string true "认证token" -// @Param groupID formData int true "组号" -// @Param userID formData string true "userID" -// @Param flag formData bool false "是否是解散群" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteMessageGroup [post] -func (c *EventController) DeleteMessageGroup() { - c.callDeleteMessageGroup(func(params *tEventDeleteMessageGroupParams) (retVal interface{}, errCode string, err error) { - errCode, err = event.DeleteMessageGroup(params.Ctx, params.GroupID, params.UserID, params.Flag) - return retVal, errCode, err - }) -} - -// @Title 转让群主 -// @Description 转让群主 -// @Param token header string true "认证token" -// @Param groupID formData int true "组号" -// @Param userID formData string true "userID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TransferMessageGroupMaster [post] -func (c *EventController) TransferMessageGroupMaster() { - c.callTransferMessageGroupMaster(func(params *tEventTransferMessageGroupMasterParams) (retVal interface{}, errCode string, err error) { - err = event.TransferMessageGroupMaster(params.Ctx, params.GroupID, params.UserID) - return retVal, "", err - }) -} - -// @Title 上传图片 -// @Description 上传图片 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UploadImg [post] -func (c *EventController) UploadImg() { - c.callUploadImg(func(params *tEventUploadImgParams) (retVal interface{}, errCode string, err error) { - file, head, err := c.GetFile("rsmImg") - defer file.Close() - if head.Size > 1024*1024*5 { - err = fmt.Errorf("图片太大,请重新选择!") - } - if path.Ext(head.Filename) != ".jpg" && path.Ext(head.Filename) != ".png" { - err = fmt.Errorf("不支持的图片格式,请重新选择!") - } - if err != nil { - return retVal, "", err - } - fileName := utils.GetUUID() + "_" + time.Now().Format("20060102") + path.Ext(head.Filename) - c.SaveToFile("rsmImg", "/jxdata/cthrgw/dist/img/"+fileName) - return "https://www.jxcs.net/img/" + fileName, "", err - }) -} - -// @Title 上传音频 -// @Description 上传音频 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UploadAudio [post] -func (c *EventController) UploadAudio() { - c.callUploadAudio(func(params *tEventUploadAudioParams) (retVal interface{}, errCode string, err error) { - var ( - timeStr = time.Now().Format("20060102") - filePath = audioPath + timeStr - ) - files := c.Ctx.Request.MultipartForm.File["rsmAudio"] - head := files[0] - file, err := head.Open() - defer file.Close() - if path.Ext(head.Filename) != ".mp3" { - err = fmt.Errorf("不支持的音频格式,请重新选择!") - } - if err != nil { - return retVal, "", err - } - fileName := utils.GetUUID() + "_" + timeStr + path.Ext(head.Filename) - if _, err = os.Stat(filePath); os.IsNotExist(err) { - os.MkdirAll(filePath, os.ModePerm) - os.Chmod(filePath, os.ModePerm) - } - f, err := os.OpenFile(filePath+"/"+fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - return retVal, "", err - } - defer f.Close() - io.Copy(f, file) - - return &model.ImMessageRecord{ - Content: "https://www.jxcs.net/audio/" + timeStr + "/" + fileName, - }, "", err - }) -} - -// @Title 得到用户统计数据 -// @Description 得到用户统计数据 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserStatistics [get] -func (c *EventController) GetUserStatistics() { - c.callGetUserStatistics(func(params *tEventGetUserStatisticsParams) (retVal interface{}, errCode string, err error) { - retVal, err = event.GetUserStatistics(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/job_controller.go b/controllers/job_controller.go deleted file mode 100644 index 5c8cd9b7e..000000000 --- a/controllers/job_controller.go +++ /dev/null @@ -1,567 +0,0 @@ -package controllers - -import ( - "fmt" - - "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego/server/web" -) - -type JobController struct { - web.Controller -} - -// @Title 发布任务 -// @Description 发布任务 -// @Param token header string true "认证token" -// @Param payload formData string true "job+step+img 类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /PublishJob [post] -func (c *JobController) PublishJob() { - c.callPublishJob(func(params *tJobPublishJobParams) (retVal interface{}, errCode string, err error) { - var job *model.JobExt - if err = utils.UnmarshalUseNumber([]byte(params.Payload), &job); err == nil { - errCode, err = cms.PublishJob(params.Ctx, job) - } - return retVal, errCode, err - }) -} - -// @Title 修改任务 -// @Description 修改任务 -// @Param token header string true "认证token" -// @Param payload formData string true "job+step+img 类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateJob [post] -func (c *JobController) UpdateJob() { - c.callUpdateJob(func(params *tJobUpdateJobParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = jxutils.Strings2Objs(params.Payload, &payload); err == nil { - err = cms.UpdateJob(params.Ctx, payload) - } - return retVal, "", err - }) -} - -// @Title 用户取消发布的任务 -// @Description 用户取消发布的任务 -// @Param token header string true "认证token" -// @Param jobID formData int true "jobID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelPublishJob [post] -func (c *JobController) CancelPublishJob() { - c.callCancelPublishJob(func(params *tJobCancelPublishJobParams) (retVal interface{}, errCode string, err error) { - err = cms.CancelPublishJob(params.Ctx, params.JobID) - return retVal, "", err - }) -} - -// @Title 查看任务类型 -// @Description 查看任务类型 -// @Param token header string true "认证token" -// @Param name query string false "分类名" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJobCategories [get] -func (c *JobController) GetJobCategories() { - c.callGetJobCategories(func(params *tJobGetJobCategoriesParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetJobCategories(dao.GetDB(), params.Name) - return retVal, "", err - }) -} - -// @Title 查看任务列表 -// @Description 查看任务列表 -// @Param token header string false "认证token" -// @Param userIDs query string false "用户IDs" -// @Param categoryIDs query string false "分类IDs" -// @Param statuss query string false "状态s" -// @Param vendorIDs query string false "平台IDs" -// @Param cityCodes query string false "CityIDs" -// @Param includeStep query bool false "是否查询步骤,默认否" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param lng query float64 false "经度" -// @Param lat query float64 false "维度" -// @Param span query int false "标签,1为置顶,2为推荐" -// @Param keyword query string false "关键字" -// @Param sortType query int false "排序类型, 1距离,2新店优先,3今日热门,4奖励高低" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJobs [get] -func (c *JobController) GetJobs() { - c.callGetJobs(func(params *tJobGetJobsParams) (retVal interface{}, errCode string, err error) { - var ( - userIDs []string - categoryIDs, statuss, vendorIDs, cityCodes []int - ) - if err = jxutils.Strings2Objs(params.UserIDs, &userIDs, params.CategoryIDs, &categoryIDs, params.Statuss, &statuss, params.VendorIDs, &vendorIDs, params.CityCodes, &cityCodes); err == nil { - retVal, err = cms.GetJobs(params.Ctx, userIDs, categoryIDs, statuss, vendorIDs, cityCodes, params.IncludeStep, params.FromTime, params.ToTime, params.Lng, params.Lat, params.Span, params.Keyword, params.SortType, params.PageSize, params.Offset) - } - return retVal, "", err - }) -} - -// @Title 查看任务 -// @Description 查看任务 -// @Param token header string false "认证token" -// @Param jobID query int false "任务ID" -// @Param lng query float64 false "经度" -// @Param lat query float64 false "维度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJobDetail [get] -func (c *JobController) GetJobDetail() { - c.callGetJobDetail(func(params *tJobGetJobDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetJobDetail(params.Ctx, params.JobID, params.Lng, params.Lat) - return retVal, "", err - }) -} - -// @Title 接任务 -// @Description 接任务 -// @Param token header string true "认证token" -// @Param jobID formData int true "jobID" -// @Param dropShippingDeliveryID formData int false "一件代发地址id" -// @Param dropShippingCount formData int false "一件代发商品数量" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AcceptJob [post] -func (c *JobController) AcceptJob() { - c.callAcceptJob(func(params *tJobAcceptJobParams) (retVal interface{}, errCode string, err error) { - _, errCode, err = cms.AcceptJob(params.Ctx, params.JobID, params.DropShippingDeliveryID, params.DropShippingCount) - return retVal, errCode, err - }) -} - -// @Title 用户取消接受的任务 -// @Description 用户取消接受的任务 -// @Param token header string true "认证token" -// @Param jobID formData int true "jobID" -// @Param jobOrderID formData int true "jobOrderID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelAcceptJob [post] -func (c *JobController) CancelAcceptJob() { - c.callCancelAcceptJob(func(params *tJobCancelAcceptJobParams) (retVal interface{}, errCode string, err error) { - err = cms.CancelAcceptJob(params.Ctx, params.JobID, int64(params.JobOrderID)) - return retVal, "", err - }) -} - -// @Title 查看接受的任务列表 -// @Description 查看接受的任务列表 -// @Param token header string true "认证token" -// @Param userID query string false "用户ID" -// @Param jobUserID query string false "发起任务的用户ID" -// @Param jobOrderID query int false "任务订单ID" -// @Param categoryID query string false "分类ID" -// @Param statuss query string false "状态s" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJobOrders [get] -func (c *JobController) GetJobOrders() { - c.callGetJobOrders(func(params *tJobGetJobOrdersParams) (retVal interface{}, errCode string, err error) { - var ( - statuss []int - ) - if err = jxutils.Strings2Objs(params.Statuss, &statuss); err == nil { - retVal, err = dao.GetJobOrders(dao.GetDB(), 0, int64(params.JobOrderID), params.UserID, params.JobUserID, "", utils.Str2Time(params.FromTime), utils.Str2Time(params.ToTime), statuss, params.PageSize, params.Offset) - } - return retVal, "", err - }) -} - -// @Title 提交任务 -// @Description 提交任务 -// @Param token header string true "认证token" -// @Param payload formData string true "joborder type" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SubmitJob [post] -func (c *JobController) SubmitJob() { - c.callSubmitJob(func(params *tJobSubmitJobParams) (retVal interface{}, errCode string, err error) { - var jobOrder *model.JobOrder - if err = jxutils.Strings2Objs(params.Payload, &jobOrder); err == nil { - err = cms.SubmitJob(params.Ctx, jobOrder) - } - return retVal, "", err - }) -} - -// @Title 审核任务 -// @Description 审核任务 -// @Param token header string true "认证token" -// @Param jobOrderID formData int true "jobOrderID" -// @Param status formData int true "审核标志,15 是通过,20是不通过" -// @Param comment formData string false "审核理由" -// @Param vendorWaybillID formData string false "运单号(一件代发)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AuditJob [post] -func (c *JobController) AuditJob() { - c.callAuditJob(func(params *tJobAuditJobParams) (retVal interface{}, errCode string, err error) { - err = cms.AuditJob(params.Ctx, params.JobOrderID, params.Status, params.Comment, params.VendorWaybillID) - return retVal, "", err - }) -} - -// @Title 确认收货(一件代发) -// @Description 确认收货(一件代发) -// @Param token header string true "认证token" -// @Param jobOrderID formData int true "jobOrderID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ConfirmDropShippingJob [post] -func (c *JobController) ConfirmDropShippingJob() { - c.callConfirmDropShippingJob(func(params *tJobConfirmDropShippingJobParams) (retVal interface{}, errCode string, err error) { - err = cms.ConfirmDropShippingJob(params.Ctx, params.JobOrderID) - return retVal, "", err - }) -} - -// @Title 导入美团会员 -// @Description 导入美团会员 -// @Param token header string false "认证token" -// @Param payload formData string true "mtmembers struct" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ImprotMtMembers [post] -func (c *JobController) ImprotMtMembers() { - c.callImprotMtMembers(func(params *tJobImprotMtMembersParams) (retVal interface{}, errCode string, err error) { - var mtMembers []*model.MtMember - if err = jxutils.Strings2Objs(params.Payload, &mtMembers); err == nil { - err = cms.ImprotMtMembers(params.Ctx, mtMembers) - } - return retVal, "", err - }) -} - -// @Title 充值美团会员 -// @Description 充值美团会员 -// @Param token header string true "认证token" -// @Param phone formData int true "电话" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RechargeMtMembers [post] -func (c *JobController) RechargeMtMembers() { - c.callRechargeMtMembers(func(params *tJobRechargeMtMembersParams) (retVal interface{}, errCode string, err error) { - errCode, err = cms.RechargeMtMembers(params.Ctx, params.Phone) - return retVal, errCode, err - }) -} - -// @Title 查看美团会员 -// @Description 查看美团会员 -// @Param token header string false "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMtMembers [get] -func (c *JobController) GetMtMembers() { - c.callGetMtMembers(func(params *tJobGetMtMembersParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetMtMembers(dao.GetDB()) - return retVal, "", err - }) -} - -// @Title 发送京东快递 -// @Description 发送京东快递 -// @Param token header string true "认证token" -// @Param payload formData string true "delivery order 类型" -// @Param pickUpStartTime formData string false "预约取件开始时间" -// @Param pickUpEndTime formData string false "预约取件结束时间" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SendJdDelivery [post] -func (c *JobController) SendJdDelivery() { - c.callSendJdDelivery(func(params *tJobSendJdDeliveryParams) (retVal interface{}, errCode string, err error) { - var dOrder *model.DeliveryOrder - if err = jxutils.Strings2Objs(params.Payload, &dOrder); err == nil { - if params.PickUpStartTime != "" && params.PickUpEndTime != "" { - dOrder.PickUpStartTime = utils.Str2Time(params.PickUpStartTime) - dOrder.PickUpEndTime = utils.Str2Time(params.PickUpEndTime) - } - errCode, err = cms.SendJdDelivery(params.Ctx, dOrder) - } - return retVal, errCode, err - }) -} - -// @Title 取消京东快递 -// @Description 取消京东快递 -// @Param token header string true "认证token" -// @Param vendorWaybillID formData string true "运单号" -// @Param reason formData string true "取消原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CancelJdDelivery [post] -func (c *JobController) CancelJdDelivery() { - c.callCancelJdDelivery(func(params *tJobCancelJdDeliveryParams) (retVal interface{}, errCode string, err error) { - err = cms.CancelJdDelivery(params.Ctx, params.VendorWaybillID, params.Reason) - return retVal, "", err - }) -} - -// @Title 查询用户的京东快递 -// @Description 查询用户的京东快递 -// @Param token header string true "认证token" -// @Param status query int false "订单状态" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetJdDelivery [get] -func (c *JobController) GetJdDelivery() { - c.callGetJdDelivery(func(params *tJobGetJdDeliveryParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetJdDelivery(params.Ctx, params.Status, params.FromTime, params.ToTime, params.PageSize, params.Offset) - return retVal, "", err - }) -} - -// @Title 查询京东快递物流信息 -// @Description 查询京东快递物流信息 -// @Param token header string true "认证token" -// @Param vendorWaybillID query string false "运单号" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetDeliveryDetail [get] -func (c *JobController) GetDeliveryDetail() { - c.callGetDeliveryDetail(func(params *tJobGetDeliveryDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetDeliveryDetail(params.Ctx, params.VendorWaybillID) - return retVal, "", err - }) -} - -// @Title 地址识别 (txcloud购买) -// @Description 地址识别 -// @Param token header string true "认证token" -// @Param address query string false "完整地址" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddressDistinguish [post] -func (c *JobController) AddressDistinguish() { - c.callAddressDistinguish(func(params *tJobAddressDistinguishParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.AddressDistinguish(params.Ctx, params.Address) - return retVal, "", err - }) -} - -// @Title 查询所有快递物流信息 (txcloud购买) -// @Description 查询所有快递物流信息 -// @Param token header string true "认证token" -// @Param vendorWaybillID query string false "运单号" -// @Param comType query string false "快递公司编码" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetAllDeliveryDetail [get] -func (c *JobController) GetAllDeliveryDetail() { - c.callGetAllDeliveryDetail(func(params *tJobGetAllDeliveryDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetAllDeliveryDetail(params.Ctx, params.VendorWaybillID, params.ComType) - return retVal, "", err - }) -} - -// @Title 京东快递物流超重验证 -// @Description 京东快递物流超重验证 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CheckJdDeliveryWeight [post] -func (c *JobController) CheckJdDeliveryWeight() { - c.callCheckJdDeliveryWeight(func(params *tJobCheckJdDeliveryWeightParams) (retVal interface{}, errCode string, err error) { - err = cms.CheckJdDeliveryWeight(params.Ctx) - return retVal, "", err - }) -} - -// @Title 获取油站列表 -// @Description 获取油站列表 -// @Param token header string true "认证token" -// @Param stationName query string false "油站名" -// @Param cityCode query int false "城市ID" -// @Param lat query float64 false "用户坐标" -// @Param lng query float64 false "用户坐标" -// @Param oilCode query string false "油号" -// @Param sortType query int false "排序, 1为距离,2为评分,3为油价" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetStationList [get] -func (c *JobController) GetStationList() { - c.callGetStationList(func(params *tJobGetStationListParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetStationList(params.Ctx, params.StationName, params.CityCode, params.Lat, params.Lng, params.OilCode, params.SortType, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 查询用户个人订单易加油 -// @Description 查询用户个人订单 -// @Param token header string true "认证token" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetEjyOrders [get] -func (c *JobController) GetEjyOrders() { - c.callGetEjyOrders(func(params *tJobGetEjyOrdersParams) (retVal interface{}, errCode string, err error) { - mobile, _ := params.Ctx.GetMobileAndUserID() - if mobile == "" { - return nil, "", fmt.Errorf("未查询到用户手机号!请确认绑定了手机!") - } - retVal, err = api.EjyAPI.GetUserOrders(mobile, params.Offset) - return retVal, "", err - }) -} - -// @Title 用户申请退款,易加油 -// @Description 用户申请退款,易加油 -// @Param token header string true "认证token" -// @Param vendorOrderID query string true "易加油订单号" -// @Param reason query string true "退款原因" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UserRefundEjy [get] -func (c *JobController) UserRefundEjy() { - c.callUserRefundEjy(func(params *tJobUserRefundEjyParams) (retVal interface{}, errCode string, err error) { - mobile, _ := params.Ctx.GetMobileAndUserID() - if mobile == "" { - return nil, "", fmt.Errorf("未查询到用户手机号!请确认绑定了手机!") - } - retVal, err = api.EjyAPI.UserRefund(params.VendorOrderID, mobile, params.Reason) - return retVal, "", err - }) -} - -// @Title 刷新任务状态 -// @Description 刷新任务状态 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJobStatus [post] -func (c *JobController) RefreshJobStatus() { - c.callRefreshJobStatus(func(params *tJobRefreshJobStatusParams) (retVal interface{}, errCode string, err error) { - err = cms.RefreshJobStatus(params.Ctx) - return retVal, "", err - }) -} - -// @Title 设置任务标签 -// @Description 设置任务标签 -// @Param token header string true "认证token" -// @Param jobIDs formData string true "任务IDs" -// @Param endAt formData string true "截止日期" -// @Param span formData int true "标签,1为置顶,2为推荐" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateJobSpan [post] -func (c *JobController) CreateJobSpan() { - c.callCreateJobSpan(func(params *tJobCreateJobSpanParams) (retVal interface{}, errCode string, err error) { - var ( - jobIDs []int - ) - if err = jxutils.Strings2Objs(params.JobIDs, &jobIDs); err == nil { - err = cms.CreateJobSpan(params.Ctx, jobIDs, params.EndAt, params.Span) - } - return retVal, "", err - }) -} - -// @Title 置顶任务重排序 -// @Description 置顶任务重排序 -// @Param token header string true "认证token" -// @Param jobIDs formData string true "任务IDs(按顺序)" -// @Param span formData int true "标签,1为置顶,2为推荐" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ReloadJobSpan [post] -func (c *JobController) ReloadJobSpan() { - c.callReloadJobSpan(func(params *tJobReloadJobSpanParams) (retVal interface{}, errCode string, err error) { - var ( - jobIDs []int - ) - if err = jxutils.Strings2Objs(params.JobIDs, &jobIDs); err == nil { - err = cms.ReloadJobSpan(params.Ctx, jobIDs, params.Span) - } - return retVal, "", err - }) -} - -// @Title 根据地址查坐标 -// @Description 根据地址查坐标 -// @Param token header string true "认证token" -// @Param address formData string true "地址" -// @Param cityCode formData int true "cityCode" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetCoordinateFromAddress [get] -func (c *JobController) GetCoordinateFromAddress() { - c.callGetCoordinateFromAddress(func(params *tJobGetCoordinateFromAddressParams) (retVal interface{}, errCode string, err error) { - place := &struct { - Lng float64 `json:"lng"` - Lat float64 `json:"lat"` - }{} - lng, lat, err := api.AutonaviAPI.GetCoordinateFromAddressByPage(params.Address, params.CityCode) - place.Lng = lng - place.Lat = lat - return place, "", err - }) -} - -// @Title 手动刷新京东快递任务 -// @Description 手动刷新京东快递任务 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RefreshJdDelivery [post] -func (c *JobController) RefreshJdDelivery() { - c.callRefreshJdDelivery(func(params *tJobRefreshJdDeliveryParams) (retVal interface{}, errCode string, err error) { - err = cms.RefreshJdDelivery(jxcontext.AdminCtx) - return retVal, "", err - }) -} - -// @Title 测试接口 -// @Description 测试接口 -// @Param token header string false "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TempJob [post] -func (c *JobController) TempJob() { - c.callTempJob(func(params *tJobTempJobParams) (retVal interface{}, errCode string, err error) { - //cms.TempJob() - cms.TestTemp() - return retVal, "", err - }) -} - -// @Title 测试接口2 -// @Description 测试接口2 -// @Param token header string false "认证token" -// @Param data formData string false "data" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /TempJobTest [post] -func (c *JobController) TempJobTest() { - c.callTempJobTest(func(params *tJobTempJobTestParams) (retVal interface{}, errCode string, err error) { - cms.TestTemp2(params.Data) - return retVal, "", err - }) -} diff --git a/controllers/mtwm_callback.go b/controllers/mtwm_callback.go deleted file mode 100644 index 56aa30645..000000000 --- a/controllers/mtwm_callback.go +++ /dev/null @@ -1,32 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/platformapi/mtunionapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxstore/partner/mt" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego/server/web" - "net/http" -) - -type MTWMController struct { - web.Controller -} - -func (c *MTWMController) UnionMsg() { - if c.Ctx.Input.Method() == http.MethodPost { - call, err := api.MtUnionAPI.GetCallbackMsg(c.Ctx.Request) - globals.SugarLogger.Debugf("mtunion callback callbackResponse:%s", utils.Format4Output(call, true)) - if err == nil { - err = mt.OnCallback(call) - } - c.Data["json"] = &mtunionapi.CallBack{ - Errcode: "0", - Errmsg: "ok", - } - c.ServeJSON() - } else { - c.Abort("404") - } -} diff --git a/controllers/order_controller.go b/controllers/order_controller.go deleted file mode 100644 index 083a09402..000000000 --- a/controllers/order_controller.go +++ /dev/null @@ -1,207 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxstore/financial" - "git.rosy.net.cn/jx-callback/business/jxutils" - beego "github.com/astaxie/beego/adapter" -) - -type OrderController struct { - beego.Controller -} - -// @Title 支付 -// @Description 支付 -// @Param token header string true "认证token" -// @Param orderID formData string true "订单号" -// @Param payType formData int true "支付平台类型" -// @Param vendorPayType formData string true "平台支付类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Pay [post] -func (c *OrderController) Pay() { - c.callPay(func(params *tOrderPayParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.Pay(params.Ctx, params.OrderID, params.PayType, params.VendorPayType) - return retVal, "", err - }) -} - -// @Title 提现 -// @Description 提现 -// @Param token header string true "认证token" -// @Param orderID formData string true "订单号" -// @Param payType formData int true "支付平台类型" -// @Param vendorPayType formData string true "平台支付类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /Cash [post] -func (c *OrderController) Cash() { - c.callCash(func(params *tOrderCashParams) (retVal interface{}, errCode string, err error) { - errCode, err = cms.Cash(params.Ctx, params.OrderID, params.PayType, params.VendorPayType) - return retVal, errCode, err - }) -} - -// @Title 创建订单 -// @Description 创建订单 -// @Param token header string true "认证token" -// @Param type formData int true "支付类型/账单类型" -// @Param orderType formData int true "订单类型,1为发任务,2为冲会员,3为发快递" -// @Param way formData string true "认证方式" -// @Param price formData int true "支付金额" -// @Param lng formData float64 true "经纬度" -// @Param lat formData float64 true "经纬度" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /CreateOrder [post] -func (c *OrderController) CreateOrder() { - c.callCreateOrder(func(params *tOrderCreateOrderParams) (retVal interface{}, errCode string, err error) { - retVal, errCode, err = cms.CreateOrder(params.Ctx, params.Type, params.OrderType, params.Way, params.Price, params.Lng, params.Lat) - return retVal, errCode, err - }) -} - -// @Title 查询订单提现申请 -// @Description 查询订单提现申请 -// @Param token header string true "认证token" -// @Param orderID query string false "订单号" -// @Param userID query string false "用户ID" -// @Param orderType query int false "订单类型,1为支付,2为提现" -// @Param cityCodes query string false "城市code列表" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param keyword query string false "关键字" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetOrders [get] -func (c *OrderController) GetOrders() { - c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) { - var cityCodes []int - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes); err == nil { - retVal, err = cms.GetOrders(params.Ctx, params.OrderID, params.UserID, params.OrderType, cityCodes, params.FromTime, params.ToTime, params.Keyword, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 完成提现订单 -// @Description 完成提现订单 -// @Param token header string true "认证token" -// @Param orderIDs formData string true "订单号列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /FinishedCashOrders [post] -func (c *OrderController) FinishedCashOrders() { - c.callFinishedCashOrders(func(params *tOrderFinishedCashOrdersParams) (retVal interface{}, errCode string, err error) { - var orderIDs []string - if err = jxutils.Strings2Objs(params.OrderIDs, &orderIDs); err == nil { - err = cms.FinishedCashOrders(params.Ctx, orderIDs) - } - return retVal, "", err - }) -} - -// @Title 支付统计 -// @Description 支付统计 -// @Param token header string true "认证token" -// @Param userID query string false "用户id" -// @Param pop query int false "1为你邀请的,0为全部" -// @Param cityCodes query string false "城市id列表" -// @Param mobile query string false "用户手机,必须全匹配" -// @Param fromTime query string false "消费开始时间" -// @Param toTime query string false "消费结束时间" -// @Param orderTypes query string false "1为发任务,2为冲会员,3为发快递,4为一件代发支付" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPayStatistics [get] -func (c *OrderController) GetPayStatistics() { - c.callGetPayStatistics(func(params *tOrderGetPayStatisticsParams) (retVal interface{}, errCode string, err error) { - var cityCodes, orderTypes []int - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes, params.OrderTypes, &orderTypes); err == nil { - retVal, err = cms.GetPayStatistics(params.Ctx, params.UserID, params.Pop, cityCodes, params.Mobile, params.FromTime, params.ToTime, orderTypes) - } - return retVal, "", err - }) -} - -// @Title 经营分析图表 -// @Description 经营分析图表 -// @Param token header string true "认证token" -// @Param cityCodes query string false "城市id列表" -// @Param fromTime query string true "开始时间" -// @Param toTime query string true "结束时间" -// @Param jobIDs query string false "任务IDs" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetManageStatisticsImg [get] -func (c *OrderController) GetManageStatisticsImg() { - c.callGetManageStatisticsImg(func(params *tOrderGetManageStatisticsImgParams) (retVal interface{}, errCode string, err error) { - var cityCodes, jobIDs []int - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes, params.JobIDs, &jobIDs); err == nil { - retVal, err = cms.GetManageStatisticsImg(params.Ctx, cityCodes, params.FromTime, params.ToTime, jobIDs) - } - return retVal, "", err - }) -} - -// @Title 经营分析任务列表 -// @Description 经营分析任务列表 -// @Param token header string true "认证token" -// @Param cityCodes query string false "城市id列表" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param jobIDs query string false "任务IDs" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetManageStatisticsJob [get] -func (c *OrderController) GetManageStatisticsJob() { - c.callGetManageStatisticsJob(func(params *tOrderGetManageStatisticsJobParams) (retVal interface{}, errCode string, err error) { - var cityCodes, jobIDs []int - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes, params.JobIDs, &jobIDs); err == nil { - retVal, err = cms.GetManageStatisticsJob(params.Ctx, cityCodes, params.FromTime, params.ToTime, jobIDs, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 查询我的推广订单 -// @Description 查询我的推广订单 -// @Param token header string true "认证token" -// @Param statuss query string false "状态s" -// @Param vendorID query int false "-1 全部" -// @Param offset query int false "列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetMyUnionOrders [get] -func (c *OrderController) GetMyUnionOrders() { - c.callGetMyUnionOrders(func(params *tOrderGetMyUnionOrdersParams) (retVal interface{}, errCode string, err error) { - var statuss []int - if err = jxutils.Strings2Objs(params.Statuss, &statuss); err == nil { - retVal, err = cms.GetMyUnionOrders(params.Ctx, statuss, params.VendorID, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 联盟订单结算 -// @Description 联盟订单结算 -// @Param token header string true "认证token" -// @Param vendorIDs query string false "平台IDs" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SettleUnionOrders [post] -func (c *OrderController) SettleUnionOrders() { - c.callSettleUnionOrders(func(params *tOrderSettleUnionOrdersParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { - err = financial.SettleUnionOrders(params.Ctx, vendorIDs) - } - return retVal, "", err - }) -} diff --git a/controllers/tonglian_callback.go b/controllers/tonglian_callback.go deleted file mode 100644 index e9bfa2434..000000000 --- a/controllers/tonglian_callback.go +++ /dev/null @@ -1,40 +0,0 @@ -package controllers - -import ( - "bytes" - "io/ioutil" - "net/http" - - "git.rosy.net.cn/jx-callback/business/jxstore/financial" - - "git.rosy.net.cn/jx-callback/globals/api" - - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" - - beego "github.com/astaxie/beego/adapter" - "github.com/astaxie/beego/server/web/context" -) - -type TongLianController struct { - beego.Controller -} - -func (c *TongLianController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - call, err := api.TLpayAPI.GetCallbackMsg(getUsefulRequest2(c.Ctx)) - globals.SugarLogger.Debugf("tonglianapi callback callbackResponse:%s", utils.Format4Output(call, true)) - if err == nil { - err = financial.OnTLPayCallback(call) - } - c.Data["json"] = call - c.ServeJSON() - } else { - c.Abort("404") - } -} - -func getUsefulRequest2(ctx *context.Context) *http.Request { - ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody)) - return ctx.Request -} diff --git a/controllers/union_controller.go b/controllers/union_controller.go deleted file mode 100644 index 39eff4dca..000000000 --- a/controllers/union_controller.go +++ /dev/null @@ -1,164 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals/api" - "github.com/astaxie/beego/server/web" -) - -type UnionController struct { - web.Controller -} - -// @Title 查询联盟活动 -// @Description 查询联盟活动 -// @Param token header string true "认证token" -// @Param vendorID query int true "平台ID" -// @Param actType query int true "活动类型ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUnionActList [get] -func (c *UnionController) GetUnionActList() { - c.callGetUnionActList(func(params *tUnionGetUnionActListParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUnionActList(params.Ctx, params.VendorID, params.ActType) - return retVal, "", err - }) -} - -// @Title 分享联盟链接 -// @Description 分享联盟链接 -// @Param token header string true "认证token" -// @Param jobID formData int true "任务ID" -// @Param shareType formData int true "分享类型,1为当前用户分享给别人,2为当前用户自己领取" -// @Param resourceType formData int false "资源类型" -// @Param linkType formData int true "链接类型,1 h5链接 2 deeplink(唤起)链接 3 中间页唤起链接 4 微信小程序唤起路径, 5为小程序二维码" -// @Param goodsID formData string false "分享商品时的商品ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /ShareUnionLink [post] -func (c *UnionController) ShareUnionLink() { - c.callShareUnionLink(func(params *tUnionShareUnionLinkParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.ShareUnionLink(params.Ctx, params.JobID, params.ShareType, params.LinkType, params.ResourceType, params.GoodsID) - return retVal, "", err - }) -} - -// @Title 查看接取的联盟任务执行情况 -// @Description 查看接取的联盟任务执行情况 -// @Param token header string true "认证token" -// @Param jobOrderID query int true "接取任务ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUnionJobOrderInfo [get] -func (c *UnionController) GetUnionJobOrderInfo() { - c.callGetUnionJobOrderInfo(func(params *tUnionGetUnionJobOrderInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUnionJobOrderInfo(params.Ctx, params.JobOrderID) - return retVal, "", err - }) -} - -// @Title 查询平台物料分类 -// @Description 查询平台物料分类 -// @Param token header string false "认证token" -// @Param vendorID query int true "平台ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorMatterCategory [get] -func (c *UnionController) GetVendorMatterCategory() { - c.callGetVendorMatterCategory(func(params *tUnionGetVendorMatterCategoryParams) (retVal interface{}, errCode string, err error) { - retVal, err = dao.GetVendorMatterCategory(dao.GetDB(), params.VendorID) - return retVal, "", err - }) -} - -// @Title 查询平台物料 -// @Description 查询平台物料 -// @Param token header string false "认证token" -// @Param vendorID query int true "平台ID" -// @Param vendorCatID query string false "平台分类ID" -// @Param keyword query string false "关键字" -// @Param offset query int false "页码" -// @Param pageSize query int false "页大小" -// @Param listID query string false "分页用" -// @Param sortType query int false "排序类型" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorMatters [get] -func (c *UnionController) GetVendorMatters() { - c.callGetVendorMatters(func(params *tUnionGetVendorMattersParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorMatters(params.Ctx, params.VendorID, params.VendorCatID, params.Keyword, params.Offset, params.PageSize, params.SortType, params.ListID) - return retVal, "", err - }) -} - -// @Title 查询平台物料详情 -// @Description 查询平台物料详情 -// @Param token header string false "认证token" -// @Param vendorID query int true "平台ID" -// @Param goodsID query string true "平台商品ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorMatterDetail [get] -func (c *UnionController) GetVendorMatterDetail() { - c.callGetVendorMatterDetail(func(params *tUnionGetVendorMatterDetailParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorMatterDetail(params.Ctx, params.VendorID, params.GoodsID) - return retVal, "", err - }) -} - -// @Title 查询平台物料推荐 -// @Description 查询平台物料推荐 -// @Param token header string false "认证token" -// @Param vendorID query int true "平台ID" -// @Param goodsID query string true "平台商品ID" -// @Param rcmmdType query int true "推荐类型,1为今日销量榜,3为相似商品,5为实时热销榜" -// @Param offset query int false "页码" -// @Param pageSize query int false "页大小" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetVendorMatterRcmmd [get] -func (c *UnionController) GetVendorMatterRcmmd() { - c.callGetVendorMatterRcmmd(func(params *tUnionGetVendorMatterRcmmdParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetVendorMatterRcmmd(params.Ctx, params.VendorID, params.GoodsID, params.RcmmdType, params.Offset, params.PageSize) - return retVal, "", err - }) -} - -// @Title 查询拼多多分享前,推广位有没有绑定授权 -// @Description 查询拼多多分享前,推广位有没有绑定授权 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetPddBindInfo [get] -func (c *UnionController) GetPddBindInfo() { - c.callGetPddBindInfo(func(params *tUnionGetPddBindInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = api.PddAPI.MemberAuthorityQuery(params.Ctx.GetUserID()) - return retVal, "", err - }) -} - -// @Title 查询联盟订单 -// @Description 查询联盟订单 -// @Param token header string true "认证token" -// @Param vendorIDs query string false "平台IDs" -// @Param statuss query string false "订单状态s" -// @Param beginTime query string false "开始时间" -// @Param endTime query string false "结束时间" -// @Param keyword query string false "关键字" -// @Param offset query int false "页码" -// @Param pageSize query int false "页大小" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUnionOrders [get] -func (c *UnionController) GetUnionOrders() { - c.callGetUnionOrders(func(params *tUnionGetUnionOrdersParams) (retVal interface{}, errCode string, err error) { - var vendorIDs []int - var statuss []int - if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.Statuss, &statuss); err == nil { - retVal, err = cms.GetUnionOrders(params.Ctx, vendorIDs, statuss, params.BeginTime, params.EndTime, params.Keyword, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} diff --git a/controllers/user2_controller.go b/controllers/user2_controller.go deleted file mode 100644 index 21d1d7989..000000000 --- a/controllers/user2_controller.go +++ /dev/null @@ -1,448 +0,0 @@ -package controllers - -import ( - "git.rosy.net.cn/baseapi/platformapi/weixinapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/auth2" - "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" - "git.rosy.net.cn/jx-callback/business/jxstore/cms" - "git.rosy.net.cn/jx-callback/business/jxutils" - "git.rosy.net.cn/jx-callback/business/jxutils/jsonerr" - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - beego "github.com/astaxie/beego/adapter" - "strings" -) - -type User2Controller struct { - beego.Controller -} - -// @Title 用户注册 -// @Description 用户注册 -// @Param token header string false "管理员token" -// @Param payload formData string true "json数据,User对象(手机号必填)" -// @Param mobileVerifyCode formData string false "手机验证码(通过auth2.SendVerifyCode获得)(mobileVerifyCode与authToken不能同时为空)" -// @Param authToken formData string false "之前通过login得到的认证TOKEN(mobileVerifyCode与authToken不能同时为空)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /RegisterUser [post] -func (c *User2Controller) RegisterUser() { - c.callRegisterUser(func(params *tUser2RegisterUserParams) (retVal interface{}, errCode string, err error) { - var ( - user model.User - inAuthInfo, manTokenInfo *auth2.AuthInfo - ) - if params.AuthToken != "" { - inAuthInfo, err = auth2.GetTokenInfo(params.AuthToken) - } else if params.Token != "" { - manTokenInfo, err = auth2.GetTokenInfo(params.Token) - } - if err == nil { - if err = jxutils.Strings2Objs(params.Payload, &user); err == nil { - user.Type = 0 - retVal, err = cms.RegisterUserWithMobile(params.Ctx, &user, params.MobileVerifyCode, inAuthInfo, manTokenInfo) - } - } - return retVal, errCode, err - }) -} - -// @Title 得到用户已经成功绑定的认证信息 -// @Description 得到用户已经成功绑定的认证信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetBindAuthInfo [get] -func (c *User2Controller) GetBindAuthInfo() { - c.callGetBindAuthInfo(func(params *tUser2GetBindAuthInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUserBindAuthInfo(params.Ctx) - return retVal, "", err - }) -} - -// @Title 得到用户列表 -// @Description 得到用户列表 -// @Param token header string true "认证token" -// @Param keyword query string false "关键字,可以部分匹配" -// @Param userID query string false "用户id" -// @Param pop query int false "1为你邀请的,0为全部" -// @Param cityCodes query string false "城市id列表" -// @Param mobile query string false "用户手机,必须全匹配" -// @Param fromTime query string false "开始时间" -// @Param toTime query string false "结束时间" -// @Param timeType query int false "1为注册时间,2为消费时间" -// @Param consumeTypes query string false "1为发任务,2为冲会员,3为发快递" -// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" -// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUsers [get] -func (c *User2Controller) GetUsers() { - c.callGetUsers(func(params *tUser2GetUsersParams) (retVal interface{}, errCode string, err error) { - var ( - cityCodes, consumeTypes []int - ) - if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes, params.ConsumeTypes, &consumeTypes); err == nil { - retVal, err = cms.GetUsers(params.Ctx, params.Keyword, params.UserID, params.Pop, params.Mobile, params.FromTime, params.ToTime, params.TimeType, cityCodes, consumeTypes, params.Offset, params.PageSize) - } - return retVal, "", err - }) -} - -// @Title 得到用户 -// @Description 得到用户 -// @Param token header string true "认证token" -// @Param userID query string true "用户id" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUser [get] -func (c *User2Controller) GetUser() { - c.callGetUser(func(params *tUser2GetUserParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUser(params.Ctx, params.UserID) - return retVal, "", err - }) -} - -// @Title 用户自己增加配送地址 -// @Description 用户自己增加配送地址 -// @Param token header string true "认证token" -// @Param consigneeName formData string true "收货人" -// @Param consigneeMobile formData string true "收货人手机" -// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)" -// @Param detailAddress formData string false "门牌号" -// @Param lng formData float64 true "经度" -// @Param lat formData float64 true "纬度" -// @Param tag formData string false "标签" -// @Param remark formData string false "备注" -// @Param isDefault formData int false "是否是默认" -// @Param type formData int false "1为寄件人,2为取件人(收货人)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddMyDeliveryAddress [post] -func (c *User2Controller) AddMyDeliveryAddress() { - c.callAddMyDeliveryAddress(func(params *tUser2AddMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) { - // var address *model.UserDeliveryAddress - // if err = utils.Map2StructByJson(params.MapData, &address, true); err == nil { - // retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address) - // } - address := &model.UserDeliveryAddress{ - ConsigneeName: params.ConsigneeName, - ConsigneeMobile: params.ConsigneeMobile, - Address: params.Address, - DetailAddress: params.DetailAddress, - Lng: params.Lng, - Lat: params.Lat, - Tag: params.Tag, - Remark: params.Remark, - IsDefault: int8(params.IsDefault), - Type: params.Type, - } - retVal, err = cms.AddMyDeliveryAddress(params.Ctx, address) - return retVal, "", err - }) -} - -// @Title 用户自己删除配送地址 -// @Description 用户自己删除送地址 -// @Param token header string true "认证token" -// @Param id query int true "地址ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteMyDeliveryAddress [delete] -func (c *User2Controller) DeleteMyDeliveryAddress() { - c.callDeleteMyDeliveryAddress(func(params *tUser2DeleteMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) { - err = cms.DeleteMyDeliveryAddress(params.Ctx, params.Id) - return retVal, "", err - }) -} - -// @Title 用户自己修改配送地址 -// @Description 用户自己修改配送地址 -// @Param token header string true "认证token" -// @Param id formData int true "地址ID" -// @Param consigneeName formData string false "收货人" -// @Param consigneeMobile formData string false "收货人手机" -// @Param address formData string false "地址(区县以下,门牌号以上的地址信息)" -// @Param detailAddress formData string false "门牌号" -// @Param lng formData float64 false "经度" -// @Param lat formData float64 false "纬度" -// @Param tag formData string false "标签" -// @Param remark formData string false "备注" -// @Param isDefault formData int false "是否是默认(0:否,1:是)" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateMyDeliveryAddress [put] -func (c *User2Controller) UpdateMyDeliveryAddress() { - c.callUpdateMyDeliveryAddress(func(params *tUser2UpdateMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) { - err = cms.UpdateMyDeliveryAddress(params.Ctx, params.Id, params.MapData) - return retVal, "", err - }) -} - -// @Title 用户查询自己的配送地址 -// @Description 用户查询自己的配送地址 -// @Param token header string true "认证token" -// @Param type query int false "地址类型,1是寄件人,2是收货人" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /QueryMyDeliveryAddress [get] -func (c *User2Controller) QueryMyDeliveryAddress() { - c.callQueryMyDeliveryAddress(func(params *tUser2QueryMyDeliveryAddressParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.QueryMyDeliveryAddress(params.Ctx, params.Type) - return retVal, "", err - }) -} - -// @Title 得到用户指定门店的购物车信息 -// @Description 得到用户指定门店的购物车信息 -// @Param token header string true "认证token" -// @Param storeIDs query string true "门店ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /LoadMyCart [get] -func (c *User2Controller) LoadMyCart() { - c.callLoadMyCart(func(params *tUser2LoadMyCartParams) (retVal interface{}, errCode string, err error) { - _, userID := params.Ctx.GetMobileAndUserID() - var storeIDs []int - if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { - retVal, err = cms.LoadUserCart(params.Ctx, userID, storeIDs) - } - return retVal, "", err - }) -} - -// @Title 存储用户指定门店的购物车信息 -// @Description 存储用户指定门店的购物车信息 -// @Param token header string true "认证token" -// @Param storeID formData int true "门店ID" -// @Param payload formData string false "完整的购物车商品列表" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /SaveMyCart [post] -func (c *User2Controller) SaveMyCart() { - c.callSaveMyCart(func(params *tUser2SaveMyCartParams) (retVal interface{}, errCode string, err error) { - var cartItems []*model.UserCartItem - _, userID := params.Ctx.GetMobileAndUserID() - if err = jxutils.Strings2Objs(params.Payload, &cartItems); err == nil { - err = cms.SaveUserCart(params.Ctx, userID, params.StoreID, cartItems) - } - return retVal, "", err - }) -} - -// @Title 得到用户自己的信息 -// @Description 得到用户自己的信息 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetSelfInfo [get] -func (c *User2Controller) GetSelfInfo() { - c.callGetSelfInfo(func(params *tUser2GetSelfInfoParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetSelfInfo(params.Ctx) - return retVal, "", err - }) -} - -// @Title 根据小程序jsCode修改用户信息 -// @Description 根据小程序jsCode修改用户信息 -// @Param token header string true "认证token" -// @Param data formData string true "加密数据" -// @Param iv formData string true "iv" -// @Param jsCode formData string false "小程序jsCode" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateUserByMiniInfo [post] -func (c *User2Controller) UpdateUserByMiniInfo() { - c.callUpdateUserByMiniInfo(func(params *tUser2UpdateUserByMiniInfoParams) (retVal interface{}, errCode string, err error) { - authInfo, err := params.Ctx.GetV2AuthInfo() - if err == nil { - decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) - if err = err2; err == nil { - var userInfo *weixinapi.MiniUserInfo - if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { - retVal = userInfo - if user := params.Ctx.GetFullUser(); user != nil { - if userInfo.AvatarURL != "" { - user.Avatar = userInfo.AvatarURL - } - if userInfo.PurePhoneNumber != "" { - user.Mobile = utils.String2Pointer(userInfo.PurePhoneNumber) - } - if userInfo.NickName != "" { - user.Name = userInfo.NickName - } - globals.SugarLogger.Debugf("UpdateUserByMiniInfo", utils.Format4Output(userInfo, false)) - _, err = dao.UpdateEntity(dao.GetDB(), user) - if err != nil && dao.IsDuplicateError(err) { - if mobileAuth, err2 := auth2.LoginInternal(params.Ctx.Context, auth2.AuthTypeMobile, userInfo.PurePhoneNumber, auth2.UserIDMobile, auth2.InternalAuthSecret); err2 == nil { - err = jsonerr.New(mobileAuth, model.ErrCodeJsonUserAlreadyExist) - } - } else if err == nil && userInfo.PurePhoneNumber != "" { - if tokenInfo, err := auth2.GetTokenInfo(params.Token); err == nil { - tokenInfo.Mobile = userInfo.PurePhoneNumber - auth2.SetUserInfo(params.Token, tokenInfo, auth2.DefTokenDuration) - } - } - } - } - } - } - return retVal, "", err - }) -} - -type UserInfoWithWeixin struct { - Mobile string `json:"mobile"` - IsExist bool `json:"isExist"` -} - -// @Title 根据小程序jsCode查询用户信息 -// @Description 根据小程序jsCode查询用户信息 -// @Param token header string false "认证token" -// @Param data formData string true "加密数据" -// @Param iv formData string true "iv" -// @Param jsCode formData string false "小程序jsCode" -// @Param authType formData string false "authType" -// @Param appID formData string false "appID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserByMiniInfo [post] -func (c *User2Controller) GetUserByMiniInfo() { - c.callGetUserByMiniInfo(func(params *tUser2GetUserByMiniInfoParams) (retVal interface{}, errCode string, err error) { - authInfo := &auth2.AuthInfo{} - if params.JsCode == "" { - result := api.Cacher.Get(params.Token) - utils.Map2StructByJson(result.(map[string]interface{}), &authInfo, false) - } - str := []string{ - params.AppID, - params.JsCode, - } - jsCode := strings.Join(str, ",") - if err == nil { - decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, jsCode, params.Data, params.Iv) - if err = err2; err == nil { - var userInfo *weixinapi.MiniUserInfo - globals.SugarLogger.Debugf("GetUserByMiniInfo :%v", decryptedDataBase64) - if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { - result := &UserInfoWithWeixin{} - result.Mobile = userInfo.PhoneNumber - if userInfo.PhoneNumber != "" { - if user, err := dao.GetUserByID(dao.GetDB(), "mobile", userInfo.PhoneNumber); err == nil { - if user != nil { - result.IsExist = true - } else { - result.IsExist = false - } - } - } - retVal = result - } - } - } - return retVal, "", err - }) -} - -// @Title 会员充值 -// @Description 会员充值 -// @Param token header string true "认证token" -// @Param memberID formData int true "会员ID" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /InvestMember [post] -func (c *User2Controller) InvestMember() { - c.callInvestMember(func(params *tUser2InvestMemberParams) (retVal interface{}, errCode string, err error) { - errCode, err = cms.InvestMember(params.Ctx, params.MemberID, "", false) - return retVal, errCode, err - }) -} - -// @Title 修改用户信息 -// @Description 修改用户信息 -// @Param token header string true "认证token" -// @Param payload formData string true "user payload" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /UpdateUser [put] -func (c *User2Controller) UpdateUser() { - c.callUpdateUser(func(params *tUser2UpdateUserParams) (retVal interface{}, errCode string, err error) { - payload := make(map[string]interface{}) - if err = jxutils.Strings2Objs(params.Payload, &payload); err == nil { - err = cms.UpdateUser(params.Ctx, payload) - } - return retVal, "", err - }) -} - -// @Title 被邀请用户达到4人时同意或拒绝入群 -// @Description 被邀请用户达到4人时同意或拒绝入群 -// @Param token header string true "认证token" -// @Param flag formData int true "1为同意,0为拒绝" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AcceptAddGroup [post] -func (c *User2Controller) AcceptAddGroup() { - c.callAcceptAddGroup(func(params *tUser2AcceptAddGroupParams) (retVal interface{}, errCode string, err error) { - err = cms.AcceptAddGroup(params.Ctx, params.Flag) - return retVal, "", err - }) -} - -// @Title 获取用户管理城市 -// @Description 获取用户管理城市 -// @Param token header string true "认证token" -// @Param userID query string false "userID" -// @Param cityCode query int false "cityCode" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserCityManager [get] -func (c *User2Controller) GetUserCityManager() { - c.callGetUserCityManager(func(params *tUser2GetUserCityManagerParams) (retVal interface{}, errCode string, err error) { - return retVal, "", err - }) -} - -// @Title 增加用户管理城市 -// @Description 增加用户管理城市 -// @Param token header string true "认证token" -// @Param userID formData string true "userID" -// @Param cityCode formData int true "cityCode" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /AddUserCityManager [post] -func (c *User2Controller) AddUserCityManager() { - c.callAddUserCityManager(func(params *tUser2AddUserCityManagerParams) (retVal interface{}, errCode string, err error) { - return retVal, "", err - }) -} - -// @Title 删除用户管理城市 -// @Description 删除用户管理城市 -// @Param token header string true "认证token" -// @Param userID formData string true "userID" -// @Param cityCode formData int true "cityCode" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /DeleteUserCityManager [post] -func (c *User2Controller) DeleteUserCityManager() { - c.callDeleteUserCityManager(func(params *tUser2DeleteUserCityManagerParams) (retVal interface{}, errCode string, err error) { - return retVal, "", err - }) -} - -// @Title 得到搜索关键词 -// @Description 得到搜索关键词 -// @Param token header string true "认证token" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /GetUserSerachKeyword [get] -func (c *User2Controller) GetUserSerachKeyword() { - c.callGetUserSerachKeyword(func(params *tUser2GetUserSerachKeywordParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.GetUserSerachKeyword(params.Ctx) - return retVal, "", err - }) -} diff --git a/controllers/wxpay_callback.go b/controllers/wxpay_callback.go deleted file mode 100644 index 519c8d45e..000000000 --- a/controllers/wxpay_callback.go +++ /dev/null @@ -1,42 +0,0 @@ -package controllers - -import ( - "fmt" - "net/http" - - "git.rosy.net.cn/jx-callback/business/jxstore/financial" - - "git.rosy.net.cn/baseapi/platformapi/wxpayapi" - "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" - beego "github.com/astaxie/beego/adapter" -) - -type WXPayController struct { - beego.Controller -} - -func (c *WXPayController) Msg() { - if c.Ctx.Input.Method() == http.MethodPost { - msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request) - globals.SugarLogger.Debugf("wxpayapi callback msg:%s, callbackResponse:%s, %t", utils.Format4Output(msg, true), utils.Format4Output(callbackResponse, true), callbackResponse == nil) - var err error - if callbackResponse == nil { - if msg.MsgType == wxpayapi.MsgTypeUnkown { - err = fmt.Errorf("未知的微信支付回调类型:%d", msg.MsgType) - } else { - err = financial.OnWxPayCallback(msg) - } - } - if callbackResponse == nil { - callbackResponse = wxpayapi.SuccessResponse - } else if err != nil { - callbackResponse = wxpayapi.Err2CallbackResponse(err, "") - } - c.Data["xml"] = callbackResponse - c.ServeXML() - } else { - c.Abort("404") - } -} diff --git a/globals/api/api.go b/globals/api/api.go index df0b307ba..1549f4bc8 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -1,164 +1,10 @@ package api -import ( - "git.rosy.net.cn/baseapi/platformapi/jdunionapi" - "git.rosy.net.cn/baseapi/platformapi/pddapi" - "git.rosy.net.cn/baseapi/platformapi/tbunionapi" - "io/ioutil" - - "git.rosy.net.cn/baseapi/platformapi/mtunionapi" - - "git.rosy.net.cn/baseapi/platformapi/txcloudapi" - - "git.rosy.net.cn/baseapi/platformapi/ejyapi" - - "git.rosy.net.cn/baseapi/platformapi/mtmemberapi" - - "git.rosy.net.cn/baseapi/platformapi/unipushapi" - - "git.rosy.net.cn/baseapi/platformapi/jdshopapi" - - "git.rosy.net.cn/baseapi/platformapi/aliupcapi" - - "git.rosy.net.cn/baseapi/platformapi/jdeclpapi" - - "git.rosy.net.cn/baseapi/platformapi/tonglianpayapi" - - aliyunsmsclient "github.com/KenmyZhang/aliyun-communicate" - - "git.rosy.net.cn/baseapi/platformapi/alipayapi" - "git.rosy.net.cn/baseapi/platformapi/autonavi" - "git.rosy.net.cn/baseapi/platformapi/baidunavi" - "git.rosy.net.cn/baseapi/platformapi/dingdingapi" - "git.rosy.net.cn/baseapi/platformapi/ebaiapi" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" - "git.rosy.net.cn/baseapi/platformapi/showapi" - "git.rosy.net.cn/baseapi/platformapi/weimobapi" - "git.rosy.net.cn/baseapi/platformapi/weixinapi" - "git.rosy.net.cn/baseapi/platformapi/wxpayapi" - "git.rosy.net.cn/jx-callback/business/jxutils/cache" - "git.rosy.net.cn/jx-callback/business/jxutils/cache/redis" - "git.rosy.net.cn/jx-callback/globals" - - beego "github.com/astaxie/beego/adapter" - "github.com/qiniu/api.v7/auth/qbox" -) - -var ( - MtUnionAPI *mtunionapi.API - TbUnionAPI *tbunionapi.API - PddAPI *pddapi.API - JdUnionAPI *jdunionapi.API - - JdEclpAPI *jdeclpapi.API - JdShopAPI *jdshopapi.API - - EbaiAPI *ebaiapi.API - - MtwmAPI *mtwmapi.API - WeixinAPI *weixinapi.API // 微信公众号 - WeixinMiniAPI *weixinapi.API // 小程序 - WeixinApp *weixinapi.API // app微信登录 - WxpayAPI *wxpayapi.API // 微信支付AppAPI - WxpayAPI2 *wxpayapi.API // 微信支付小程序API - - TLpayAPI *tonglianpayapi.API //通联收银宝api - MtMemberAPI *mtmemberapi.API - - WeixinPageAPI *weixinapi.API // 用户微信扫码登录 - - AliPayAPI *alipayapi.API - TxAPI *txcloudapi.API - - AutonaviAPI *autonavi.API - BaiDuNaviAPI *baidunavi.API - QiniuAPI *qbox.Mac - ShowAPI *showapi.API - WeimobAPI *weimobapi.API - DingDingAPI *dingdingapi.API - DingDingQRCodeAPI *dingdingapi.API - AliUpcAPI *aliupcapi.API //阿里商品条码查询api - EjyAPI *ejyapi.API //易加油 - - PushAPI *unipushapi.API - - Cacher cache.ICacher - SMSClient *aliyunsmsclient.SmsClient -) - func init() { Init() // 这里必须要调用 } // 这样写的原因是在测试时,可以重新读取配置文件 func Init() { - MtUnionAPI = mtunionapi.New(beego.AppConfig.DefaultString("mtUnionAppKey", ""), beego.AppConfig.DefaultString("mtUnionAppSecret", "")) - TbUnionAPI = tbunionapi.New(beego.AppConfig.DefaultString("tbUnionAppKey", ""), beego.AppConfig.DefaultString("tbUnionAppSecret", "")) - PddAPI = pddapi.New(beego.AppConfig.DefaultString("pddAppKey", ""), beego.AppConfig.DefaultString("pddAppSecret", "")) - JdUnionAPI = jdunionapi.New(beego.AppConfig.DefaultString("jdUnionAppKey", ""), beego.AppConfig.DefaultString("jdUnionAppSecret", "")) - if !beego.AppConfig.DefaultBool("disableJdEclp", false) { - JdEclpAPI = jdeclpapi.New(beego.AppConfig.String("jdEclpAccessToken"), beego.AppConfig.String("jdEclpAppKey"), beego.AppConfig.String("jdEclpAppSecret")) - } else { - JdEclpAPI = nil - } - if !beego.AppConfig.DefaultBool("disableJdShop", false) { - JdShopAPI = jdshopapi.New(beego.AppConfig.String("jdShopAccessToken"), beego.AppConfig.String("jdShopAppKey"), beego.AppConfig.String("jdShopAppSecret")) - // if jdsCookie := beego.AppConfig.DefaultString("jdsCookie", ""); jdsCookie != "" { - // JdShopAPI.SetCookieWithStr(jdsCookie) - // } - } else { - JdShopAPI = nil - } - if !beego.AppConfig.DefaultBool("disableMtwm", false) { - MtwmAPI = mtwmapi.New(beego.AppConfig.String("mtwmAppID"), beego.AppConfig.String("mtwmSecret"), beego.AppConfig.String("mtwmCallbackURL"), "") - // if mtwmCookieStr := beego.AppConfig.DefaultString("mtwmCookieStr", ""); mtwmCookieStr != "" { - // MtwmAPI.SetCookieWithStr(mtwmCookieStr) - // } - } else { - MtwmAPI = nil - } - - if !beego.AppConfig.DefaultBool("disableWeixin", false) { - WeixinAPI = weixinapi.New(beego.AppConfig.String("weixinID"), beego.AppConfig.String("weixinSecret")) - // 这个主要是用于调试阶段使用,生产环境中用的是自动刷新那套 - if weixinToken := beego.AppConfig.DefaultString("weixinToken", ""); weixinToken != "" { - WeixinAPI.CBSetToken(weixinToken) - } - if weixinMsgToken := beego.AppConfig.DefaultString("weixinMsgToken", ""); weixinMsgToken != "" { - WeixinAPI.SetMsgTokenAndKey(weixinMsgToken, beego.AppConfig.DefaultString("weixinMsgKey", "")) - } - } else { - WeimobAPI = nil - } - WeixinMiniAPI = weixinapi.New(beego.AppConfig.String("weixinMiniAppID"), beego.AppConfig.String("weixinMiniSecret")) - WeixinApp = weixinapi.New(beego.AppConfig.String("weixinAppID"), beego.AppConfig.String("weixinAppSecret")) - - certPEMBlock, _ := ioutil.ReadFile("conf/apiclient_cert.pem") - keyPEMBlock, _ := ioutil.ReadFile("conf/apiclient_key.pem") - WxpayAPI = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID1"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"), - certPEMBlock, keyPEMBlock) - WxpayAPI2 = wxpayapi.NewWithCertificate(beego.AppConfig.String("wxpayAppID2"), beego.AppConfig.String("wxpayAppKey"), beego.AppConfig.String("wxpayAppMchID"), - certPEMBlock, keyPEMBlock) - - if globals.TLPayNotifyURL != "" { - TLpayAPI = tonglianpayapi.New(beego.AppConfig.String("tonglianPayAppID"), beego.AppConfig.String("tonglianPayKey"), beego.AppConfig.String("tonglianPayCusID")) - } - AutonaviAPI = autonavi.New(beego.AppConfig.String("autonaviKey")) - BaiDuNaviAPI = baidunavi.New(beego.AppConfig.String("baidunaviAK"), beego.AppConfig.String("baidunaviSK")) - QiniuAPI = qbox.NewMac(beego.AppConfig.String("qiniuAK"), beego.AppConfig.String("qiniuSK")) - ShowAPI = showapi.New(beego.AppConfig.DefaultInt("showAppID", 0), beego.AppConfig.DefaultString("showAppSecret", "")) - Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", "")) - AliUpcAPI = aliupcapi.New(beego.AppConfig.String("aliUpcAppCode")) - TxAPI = txcloudapi.New(beego.AppConfig.String("txCloudSecretID"), beego.AppConfig.String("txCloudSecretKey")) - DingDingAPI = dingdingapi.NewWithAgentID(beego.AppConfig.DefaultInt64("dingdingAgentID", 0), beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingAppKey", ""), beego.AppConfig.DefaultString("dingdingSecret", "")) - DingDingQRCodeAPI = dingdingapi.New(beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingQRCodeAppKey", ""), beego.AppConfig.DefaultString("dingdingQRCodeSecret", "")) - - if alipayAppID := beego.AppConfig.DefaultString("alipayAppID", ""); alipayAppID != "" { - AliPayAPI = alipayapi.New(alipayAppID, []byte(beego.AppConfig.String("alipayPrivateKey"))) - } - EjyAPI = ejyapi.New(beego.AppConfig.DefaultString("ejyPlatName", ""), beego.AppConfig.DefaultString("ejyBeforeKey", ""), beego.AppConfig.DefaultString("ejyAfterKey", "")) - PushAPI = unipushapi.New(beego.AppConfig.DefaultString("pushAppID", ""), beego.AppConfig.DefaultString("pushAppKey", ""), beego.AppConfig.DefaultString("pushAppSecret", ""), beego.AppConfig.DefaultString("pushMasterSecret", "")) - MtMemberAPI = mtmemberapi.New() - SMSClient = aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/") } diff --git a/globals/api2/api2.go b/globals/api2/api2.go deleted file mode 100644 index 25b901f0a..000000000 --- a/globals/api2/api2.go +++ /dev/null @@ -1,20 +0,0 @@ -package api2 - -import ( - "git.rosy.net.cn/jx-callback/business/authz" - "git.rosy.net.cn/jx-callback/business/authz/casbinauth" - "git.rosy.net.cn/jx-callback/globals" -) - -var ( - RoleMan authz.IAuthz -) - -func Init() { - RoleMan2, err := casbinauth.New("conf/rbac_model.conf") - if err != nil { - globals.SugarLogger.Error(err.Error()) - } else { - RoleMan = RoleMan2 - } -} diff --git a/globals/beegodb/beegodb.go b/globals/beegodb/beegodb.go index 165f00f72..e22f146dc 100644 --- a/globals/beegodb/beegodb.go +++ b/globals/beegodb/beegodb.go @@ -1,8 +1,6 @@ package beegodb import ( - "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/legacymodel" beego "github.com/astaxie/beego/adapter" "github.com/astaxie/beego/adapter/orm" ) @@ -12,39 +10,6 @@ func Init() { orm.RegisterDataBase("default", "mysql", beego.AppConfig.String("dbConnectStr"), 30) // orm.RegisterDataBase("c4", "mysql", "root:WebServer@1@tcp(gold1.jxc4.com:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true", 30) - //用户 - orm.RegisterModel(&model.AuthBind{}, &model.User{}) - orm.RegisterModel(&model.UserMember{}) - orm.RegisterModel(&model.UserDeliveryAddress{}) - orm.RegisterModel(&model.UserCityManager{}) - orm.RegisterModel(&model.UserSearch{}) - orm.RegisterModel(&model.UserUnionBind{}) //联盟相关绑定 - orm.RegisterModel(&model.UserUnionBindImg{}) //多个活动图片 - //账单 - orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{}) - //支付订单 - orm.RegisterModel(&model.Order{}) - orm.RegisterModel(&model.DeliveryOrder{}) - //联盟订单 - orm.RegisterModel(&model.UnionOrder{}) - orm.RegisterModel(&model.UnionOrderStatus{}) - orm.RegisterModel(&model.UnionOrderSettle{}) //订单结算 - //任务 - orm.RegisterModel(&model.Job{}, &model.JobCategory{}, &model.JobStep{}, &model.JobImg{}) - orm.RegisterModel(&model.JobOrder{}) - orm.RegisterModel(&model.JobTimer{}) - orm.RegisterModel(&model.JobSpan{}) - //聊天 - orm.RegisterModel(&model.ImMessageRecord{}, &model.MessageGroup{}, &model.MessageGroupMember{}) - orm.RegisterModel(&model.MessageGroupRead{}) - - orm.RegisterModel(&model.Place{}, &model.StationInfo{}) - orm.RegisterModel(&model.OperateEventDetail{}) - orm.RegisterModel(&model.MtMember{}) - orm.RegisterModel(&model.OperateEvent{}) - orm.RegisterModel(&model.NewConfig{}, &legacymodel.Config{}) - orm.RegisterModel(&model.AddressDistinguish{}) - orm.RegisterModel(&model.VendorMatterCategory{}) //平台物流分类(手动添的) // create table orm.RunSyncdb("default", false, true) } diff --git a/globals/globals.go b/globals/globals.go index 60273c8bd..a0e15f5eb 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -9,62 +9,7 @@ import ( ) var ( - ReallyCallPlatformAPI bool - ReallySendWeixinMsg bool - SugarLogger *zap.SugaredLogger - - AliKey string - AliSecret string - - EnableStoreWrite bool - EnableJdStoreWrite bool - EnableEbaiStoreWrite bool - EnableElmStoreWrite bool - EnableMtwmStoreWrite bool - EnableWscStoreWrite bool - EnablePendingChange bool - EnableYbStoreWrite bool - EnableJdShopWrite bool //京东商城 - - QiniuBucket string - WeimobCallbackURL string - WeimobStateSecret string - - BackstageHost string - WxBackstageHost string - - GetWeixinTokenURL string - GetWeixin2TokenURL string - GetWeixinTokenKey string - GetYLYTokenURL string - GetPushTokenURL string - GetWeimobTokenURL string - WxpayAppKey string - - StoreName string - StoreNameMtwm string - StoreNameEbai string - - SMSSignName string - SMSMobileVerifyTemplate string - SMSPopSuccessTemplate string - - EnableWXAuth2 bool - DisableWXAuth1 bool - - WxpayNotifyURL string - TLPayNotifyURL string - - JdOrgCode string - Jd2OrgCode string - Jd3OrgCode string - JdLoginName string - - IsStoreSkuAct bool - IsAddEvent bool - - OutputDebugMsgLevel int ) func init() { @@ -78,72 +23,5 @@ func init() { } func Init() { - if false { //!IsProductEnv() { - OutputDebugMsgLevel = 1 - } - SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode) - ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test") - ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv() - - AliKey = beego.AppConfig.DefaultString("aliKey", "") - AliSecret = beego.AppConfig.DefaultString("aliSecret", "") - - EnableStoreWrite = beego.AppConfig.DefaultBool("enableStoreWrite", false) - EnableJdStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableJdStoreWrite", false) - EnableEbaiStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableEbaiStoreWrite", false) - EnableElmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableElmStoreWrite", false) - EnableMtwmStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableMtwmStoreWrite", false) - EnableWscStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableWscStoreWrite", false) - // EnablePendingChange = beego.AppConfig.DefaultBool("enablePendingChange", false) - EnableYbStoreWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableYbStoreWrite", false) - EnableJdShopWrite = EnableStoreWrite && beego.AppConfig.DefaultBool("enableJdShopWrite", false) - - QiniuBucket = beego.AppConfig.String("qiniuBucket") - - WeimobCallbackURL = beego.AppConfig.DefaultString("weimobCallbackURL", "") - WeimobStateSecret = beego.AppConfig.DefaultString("weimobStateSecret", "") - - BackstageHost = beego.AppConfig.DefaultString("backstageHost", "") - WxBackstageHost = beego.AppConfig.DefaultString("wxBackstageHost", "") - - GetWeixinTokenURL = beego.AppConfig.DefaultString("getWeixinTokenURL", "") - GetWeixin2TokenURL = beego.AppConfig.DefaultString("getWeixin2TokenURL", "") - GetYLYTokenURL = beego.AppConfig.DefaultString("getYLYTokenURL", "") - GetWeimobTokenURL = beego.AppConfig.DefaultString("getWeimobTokenURL", "") - GetWeixinTokenKey = beego.AppConfig.DefaultString("getWeixinTokenKey", "") - GetPushTokenURL = beego.AppConfig.DefaultString("getPushTokenURL", "") - - StoreName = beego.AppConfig.String("storeName") - StoreNameMtwm = beego.AppConfig.String("storeNameMtwm") - StoreNameEbai = beego.AppConfig.String("storeNameEbai") - - SMSSignName = beego.AppConfig.String("smsSignName") - SMSMobileVerifyTemplate = beego.AppConfig.String("smsMobileVerifyTemplate") - SMSPopSuccessTemplate = beego.AppConfig.String("smsPopSuccessTemplate") - - EnableWXAuth2 = true // beego.BConfig.RunMode == "beta" - DisableWXAuth1 = true - - WxpayAppKey = beego.AppConfig.DefaultString("wxpayAppKey", "") - WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "") - TLPayNotifyURL = beego.AppConfig.DefaultString("tonglianPayNotifyURL", "") - JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "") - Jd2OrgCode = beego.AppConfig.DefaultString("jd2OrgCode", "") - Jd3OrgCode = beego.AppConfig.DefaultString("jd3OrgCode", "") - JdLoginName = beego.AppConfig.DefaultString("jdLoginName", "") - IsAddEvent = beego.AppConfig.DefaultBool("addEvent", false) - IsStoreSkuAct = !IsProductEnv() -} - -func IsCallbackAlwaysReturnSuccess() bool { - return beego.BConfig.RunMode == "beta" -} - -func IsMainProductEnv() bool { - return beego.BConfig.RunMode == "rsm" -} - -func IsProductEnv() bool { - return beego.BConfig.RunMode == "print" } diff --git a/main.go b/main.go index a89ef7199..c84379371 100644 --- a/main.go +++ b/main.go @@ -3,25 +3,16 @@ package main import ( "flag" "fmt" - "io" - "net" - "net/http" _ "net/http/pprof" "os" "time" - "git.rosy.net.cn/baseapi/platformapi/dingdingapi" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/jx-callback/business/jxutils/tasks" - beego "github.com/astaxie/beego/server/web" // 导入缺省订单调度器 - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/beegodb" _ "git.rosy.net.cn/jx-callback/business/auth2/authprovider/alipay" @@ -100,116 +91,11 @@ func checkCmdFlags() bool { } func main() { - if !checkCmdFlags() { - Init() - // if err := tasks.RefreshWeixinToken(); err != nil { - // globals.SugarLogger.Errorf("RefreshWeixinToken failed with error:%s", err) - // return - // } - // if err := tasks.RefreshWeixin2Token(); err != nil { - // globals.SugarLogger.Errorf("RefreshWeixin2Token failed with error:%s", err) - // return - // } - // if err := tasks.RefreshWeixin3Token(); err != nil { - // globals.SugarLogger.Errorf("RefreshWeixin3Token failed with error:%s", err) - // return - // } - // if err := tasks.RefreshPushToken(); err != nil { - // globals.SugarLogger.Errorf("RefreshPushToken failed with error:%s", err) - // return - // } - // 延时的原因是等回调准备好 - if globals.IsProductEnv() || beego.BConfig.RunMode == "beta" { - utils.AfterFuncWithRecover(2*time.Second, func() { - if err := tasks.RefreshDingDingToken(); err != nil { - globals.SugarLogger.Errorf("RefreshDingDingToken failed with error:%s", err) - return - } - if globals.IsProductEnv() { - api.DingDingAPI.DeleteCallback() - if err := api.DingDingAPI.RegisterCallback([]string{dingdingapi.CBTagUserAddOrg, dingdingapi.CBTagUserModifyOrg, dingdingapi.CBTagUserLeaveOrg}, beego.AppConfig.DefaultString("dingdingCallbackToken", ""), beego.AppConfig.DefaultString("dingdingCallbackAESKey", ""), beego.AppConfig.DefaultString("dingdingCallbackURL", "")); err != nil { - globals.SugarLogger.Warnf("dingding RegisterCallback failed with error:%v", err) - } - } - }) - } - cms.ResetJobTimers() - if beego.BConfig.RunMode != "prod" { - beego.BConfig.WebConfig.DirectoryIndex = true - beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" - } - go func() { - if globals.IsMainProductEnv() { - http.ListenAndServe("0.0.0.0:6061", nil) - } else { - http.ListenAndServe("0.0.0.0:6060", nil) - } - }() - if globals.IsProductEnv() { - l, err := net.Listen("tcp", ":8000") - if err != nil { - fmt.Println("listen error:", err) - return - } - for { - c, err := l.Accept() - if err != nil { - fmt.Println("accept error:", err) - break - } - go handleConn(c) - } - } - beego.Run() - } + Init() + //先打开swagger + //if beego.BConfig.RunMode != "prod" { + beego.BConfig.WebConfig.DirectoryIndex = true + beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" + //} + beego.Run() } - -func handleConn(c net.Conn) { - if c == nil { - fmt.Println("conn is nil") - return - } - defer c.Close() - //reader := bufio.NewReader(c) - buffer := make([]byte, 1024) - for { - n, err := c.Read(buffer) - //ReadString阻塞,直到读到\n - //msg, err := reader.ReadString('\n') - if err != nil { - if err == io.EOF { - fmt.Println("connection close 1") - } else { - fmt.Println("ReadString err", err) - } - return - } - fmt.Println("read data:", string(buffer[:n])) - b := []byte("ok") - c.Write(b) - } -} - -//func handleConn(c net.Conn) { -// if c == nil { -// fmt.Println("conn is nil") -// return -// } -// defer c.Close() -// //reader := bufio.NewReader(c) -// buffer := make([]byte, 1024) -// for { -// n, err := c.Read(buffer) -// if err != nil { -// if err == io.EOF { -// fmt.Println("connection close") -// } else { -// fmt.Println("ReadString err", err) -// } -// return -// } -// fmt.Println("read data:", buffer[:n]) -// b := []byte("ok") -// c.Write(b) -// } -//} diff --git a/routers/router.go b/routers/router.go index bf9abca53..f7c06b9b6 100644 --- a/routers/router.go +++ b/routers/router.go @@ -9,64 +9,20 @@ package routers import ( "git.rosy.net.cn/jx-callback/controllers" - "github.com/astaxie/beego/server/web" beecontext "github.com/astaxie/beego/server/web/context" ) func init() { ns := web.NewNamespace("/v2", - web.NSNamespace("/task", + web.NSNamespace("/openapi"), + web.NSNamespace("/print", web.NSInclude( - &controllers.TaskController{}, - ), - ), - web.NSNamespace("/auth2", - web.NSInclude( - &controllers.Auth2Controller{}, - ), - ), - web.NSNamespace("/user2", - web.NSInclude( - &controllers.User2Controller{}, - ), - ), - web.NSNamespace("/order", - web.NSInclude( - &controllers.OrderController{}, - ), - ), - web.NSNamespace("/job", - web.NSInclude( - &controllers.JobController{}, - ), - ), - web.NSNamespace("/event", - web.NSInclude( - &controllers.EventController{}, - ), - ), - web.NSNamespace("/bill", - web.NSInclude( - &controllers.BillController{}, - ), - ), - web.NSNamespace("/cms", - web.NSInclude( - &controllers.CmsController{}, - ), - ), - web.NSNamespace("/union", - web.NSInclude( - &controllers.UnionController{}, + &controllers.PrintController{}, ), ), ) web.AddNamespace(ns) - web.AutoRouter(&controllers.WXPayController{}) - web.AutoRouter(&controllers.TongLianController{}) - web.AutoRouter(&controllers.MTWMController{}) - web.AutoRouter(&controllers.PrintController{}) // 如下都是用于检测存活的空接口 web.Any("/", func(ctx *beecontext.Context) {