Ver Fonte

Merge branch 'dev4.6.2.4' of http://192.168.3.207:8080/qmx/jy into dev4.6.2.4

wangshan há 3 anos atrás
pai
commit
41301df101

+ 10 - 0
src/jfw/modules/publicapply/src/attachmentdow/init.go

@@ -0,0 +1,10 @@
+package attachmentdow
+
+import (
+	"attachmentdow/service"
+	"github.com/go-xweb/xweb"
+)
+
+func init() {
+	xweb.AddAction(&service.Dow{})
+}

+ 74 - 0
src/jfw/modules/publicapply/src/attachmentdow/service/service.go

@@ -0,0 +1,74 @@
+package service
+
+import (
+	. "api"
+	"config"
+	"db"
+	"fmt"
+	"github.com/go-xweb/xweb"
+	"log"
+	qu "qfw/util"
+	"qfw/util/jy"
+	"qfw/util/redis"
+	"time"
+	"util"
+)
+
+type Dow struct {
+	*xweb.Action
+	subdow xweb.Mapper `xweb:"/attachment/get"` //超级订阅附件下载
+}
+
+//超级订阅 附件下载
+func (u *Dow) Subdow() {
+	if !R.CheckReqParam(u.ResponseWriter, u.Request, "infoId") {
+		return
+	}
+	r := func() Result {
+		userid := qu.ObjToString(u.GetSession("userId"))
+		if userid == "" {
+			return Result{Data: nil, Error_msg: "未登录"}
+		}
+
+		BaseMsg := jy.GetBigVipUserBaseMsg(userid, db.Mysql, db.Mgo)
+		status := BaseMsg.VipStatus
+		if status <= 0 {
+			return Result{Data: nil, Error_msg: "非超级订阅用户,无下载权限"}
+		}
+		mon := fmt.Sprintf(jy.VipFileUploadNumKey, userid, fmt.Sprint(time.Now().Month()))
+		ss := redis.GetInt(jy.PowerCacheDb, mon)
+		if config.Config.File_number <= ss {
+			return Result{Data: nil, Error_msg: "您本月查看机会已经消耗完毕,如需要更多服务,请前往联系客服。"}
+		}
+
+		//前端传的是加密的id 需要解密
+		infoId := util.DecodeId(u.GetString("infoId")) //"5ddf222ce9d1f601e469e00c  5f50c37dc0145440737556d0"
+		// 调用rpc
+		req := util.JyMemberRequest{infoId}
+		rep, err := util.Attachment(&req)
+		if err != nil {
+			return Result{Data: nil, Error_msg: "rpc调用失败"}
+		}
+		if rep.Rep == nil {
+			rep.Rep = []map[string]interface{}{}
+		}
+		//下载后自增一次
+		redis.Incr(jy.VipFileUploadNumKey, mon)
+
+		m := rep.Rep
+		data := make(map[string]interface{})
+		data["p_userid"] = userid
+		data["p_infoId"] = infoId
+		data["p_create_time"] = time.Now().Unix()
+		data["p_rep"] = rep
+		data["p_type"] = "超级订阅用户附件下载"
+		//存库记录
+		db.Mgo.Save("filehistroy", data)
+		log.Printf("超级订阅用户%s,%s月第%d次下载附件", userid, mon, ss)
+		return Result{Data: map[string]interface{}{
+			"attachment": m,
+			"len":        len(rep.Rep),
+		}}
+	}()
+	u.ServeJson(r)
+}

+ 4 - 1
src/jfw/modules/publicapply/src/config.json

@@ -14,6 +14,8 @@
             "user": "public03@topnet.net.cn"
         }
     ],
+    "attachmentRPC":"192.168.3.128:10082",
+    "followPushRpc": "127.0.0.1:8759",
     "industry": "分类综合测试",
     "defaultEntList": [
         "744fb1d7cc3561e11c639fcc2ad955c0",
@@ -39,5 +41,6 @@
         "3613232bc702d011232ed57f0027af1c"
 
     ],
-    "bidSearchOldUserLimit": 1626105600
+    "bidSearchOldUserLimit": 1626105600,
+    "file_number": 10
 }

+ 3 - 0
src/jfw/modules/publicapply/src/config/config.go

@@ -15,6 +15,9 @@ type config struct {
 	Industry              string
 	DefaultEntList        []string //企业查询默认展示企业
 	BidSearchOldUserLimit int64
+	File_number           int
+	AttachmentRPC		  string
+	FollowPushRpc         string
 }
 type BidColl struct {
 	PayUserCollLimit      int    //付费用户收藏数量最大限制

+ 106 - 0
src/jfw/modules/publicapply/src/util/rpc.go

@@ -0,0 +1,106 @@
+package util
+
+import (
+	"config"
+	"encoding/json"
+	"log"
+	"net/rpc"
+	"qfw/util"
+	qrpc "qfw/util/rpc"
+)
+
+//项目更新推送
+func FollowPush(p *qrpc.FollowPush) (repls []*map[string]interface{}, err error) {
+	util.Try(func() {
+		client, e := rpc.DialHTTP("tcp", config.Config.FollowPushRpc)
+		defer client.Close()
+		if e != nil {
+			err = e
+			log.Println(err.Error())
+			return
+		}
+		var repl []byte
+		err = client.Call("FollowPushRpc.FollowPush", p, &repl)
+		if err == nil && repl != nil && len(repl) > 0 {
+			var mp []*map[string]interface{}
+			json.Unmarshal(repl, &mp)
+			repls = mp
+		}
+		if err != nil {
+			log.Println(err.Error())
+		}
+	}, func(e interface{}) {})
+	return
+}
+
+type JyMemberRequest struct {
+	InfoId string
+}
+
+type JyMemberResponse struct {
+	Rep []map[string]interface{}
+}
+
+//附件下载
+func Attachment(am *JyMemberRequest) (rep *JyMemberResponse, err error) {
+	util.Try(func() {
+		client, e := rpc.DialHTTP("tcp", config.Config.AttachmentRPC)
+		defer client.Close()
+		if e != nil {
+			err = e
+			log.Println(err.Error())
+			return
+		}
+		err = client.Call("JyService.Download", am, &rep)
+		if err == nil && rep != nil {
+			return
+		}
+		if err != nil {
+			log.Println(err.Error())
+		}
+	}, func(e interface{}) {})
+	return
+}
+
+//JyService.Forecast  中标预测分析rpc接口
+
+type ForecastS struct {
+	Pname        string   `json:"pname"`        //项目名称
+	Id           string   `json:"id"`           //项目id
+	Infoid       string   `json:"infoid"`       //项目第一个listid
+	BuyerContent []string `json:"buyerContent"` //采购内容
+	Buyer        string   `json:"buyer"`        //采购单位
+	Budget       float64  `json:"budget"`       //预算
+	Area         string   `json:"area"`         //地区
+	City         string   `json:"city"`         //城市
+	RedisFKey    string   `json:"redisFKey"`    //保存数据rediskey值
+	Agency       string   `json:"agency"`       //招标代理机构
+	Buyertel     string   `json:"buyertel"`     //采购联系方式
+	Buyerperson  string   `json:"buyerperson"`  //采购联系人
+	Type         string   `json:"type"`         //是否需要传参数
+	ServiceId    int      `json:"serviceId"`    //服务id
+	MobileModel  string   `json:"mobileModel"`  //手机型号
+	AppVersion   string   `json:"appVersion"`   //app版本号
+}
+
+type repBool struct {
+	Rep bool
+}
+
+func JyForecastByRpc(getRes *ForecastS) bool {
+	// log.Println("-------:", getRes)
+	var ok repBool
+	util.Try(func() {
+		client, err := rpc.DialHTTP("tcp", config.Config.AttachmentRPC)
+		if err != nil {
+			log.Println("Forecast-1-err:", err)
+		}
+		defer client.Close()
+		err = client.Call("JyService.Forecast", getRes, &ok)
+		if err != nil {
+			log.Println("Forecast-2-err:", err)
+		}
+	}, func(e interface{}) {})
+	log.Println(ok.Rep)
+	return ok.Rep
+}