|
@@ -1,606 +1,606 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
- . "app.yhyue.com/moapp/jybase/api"
|
|
|
- qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
- . "app.yhyue.com/moapp/jybase/date"
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
- "encoding/base64"
|
|
|
- "encoding/json"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "github.com/SKatiyar/qr"
|
|
|
- "go.mongodb.org/mongo-driver/bson"
|
|
|
- "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/entity"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
- "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
- "log"
|
|
|
- "net/url"
|
|
|
- "strconv"
|
|
|
- "time"
|
|
|
+ . "app.yhyue.com/moapp/jybase/api"
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "encoding/base64"
|
|
|
+ "encoding/json"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "github.com/SKatiyar/qr"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/entity"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/pay"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/util"
|
|
|
+ "log"
|
|
|
+ "net/url"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type SalesCreateOrder struct {
|
|
|
- *xweb.Action
|
|
|
- createBySeller xweb.Mapper `xweb:"/free/seller/createOrder"` //销售代用户下单-创建订单
|
|
|
- wxPaymentPage xweb.Mapper `xweb:"/free/seller/wxPaymentPage"` //销售代用户下单-无身份微信订单页面
|
|
|
- getOrderPayAllMsg xweb.Mapper `xweb:"/free/seller/getOrderPayAllMsg"` //销售代用户下单-获取订单详情
|
|
|
- getCommonPayParam xweb.Mapper `xweb:"/free/seller/getCommonPayParam"` //销售代用户下单-获取支付参数
|
|
|
- isPaySuccess xweb.Mapper `xweb:"/free/seller/isPaySuccess"` //销售代用户下单-是否支付成功
|
|
|
- getSubBuyMsg xweb.Mapper `xweb:"/free/seller/svip/getSubBuyMsg"` //超级订阅-获取已购买信息
|
|
|
- getPrice xweb.Mapper `xweb:"/free/seller/svip/getPrice"` //超级订阅-获取超级订阅价格
|
|
|
- getSelectPrice xweb.Mapper `xweb:"/free/seller/svip/getSelectPrice"` //超级订阅-获取选择价格
|
|
|
- getValuationList xweb.Mapper `xweb:"/free/seller/svip/getValuationList"` //超级订阅-计价清单
|
|
|
+ *xweb.Action
|
|
|
+ createBySeller xweb.Mapper `xweb:"/free/seller/createOrder"` //销售代用户下单-创建订单
|
|
|
+ wxPaymentPage xweb.Mapper `xweb:"/free/seller/wxPaymentPage"` //销售代用户下单-无身份微信订单页面
|
|
|
+ getOrderPayAllMsg xweb.Mapper `xweb:"/free/seller/getOrderPayAllMsg"` //销售代用户下单-获取订单详情
|
|
|
+ getCommonPayParam xweb.Mapper `xweb:"/free/seller/getCommonPayParam"` //销售代用户下单-获取支付参数
|
|
|
+ isPaySuccess xweb.Mapper `xweb:"/free/seller/isPaySuccess"` //销售代用户下单-是否支付成功
|
|
|
+ getSubBuyMsg xweb.Mapper `xweb:"/free/seller/svip/getSubBuyMsg"` //超级订阅-获取已购买信息
|
|
|
+ getPrice xweb.Mapper `xweb:"/free/seller/svip/getPrice"` //超级订阅-获取超级订阅价格
|
|
|
+ getSelectPrice xweb.Mapper `xweb:"/free/seller/svip/getSelectPrice"` //超级订阅-获取选择价格
|
|
|
+ getValuationList xweb.Mapper `xweb:"/free/seller/svip/getValuationList"` //超级订阅-计价清单
|
|
|
|
|
|
- //tokenShow xweb.Mapper `xweb:"/free/seller/tokenShow"` //超级订阅-获取选择价格
|
|
|
+ //tokenShow xweb.Mapper `xweb:"/free/seller/tokenShow"` //超级订阅-获取选择价格
|
|
|
}
|
|
|
|
|
|
func (this *SalesCreateOrder) TokenShow() {
|
|
|
- vmap := map[string]interface{}{}
|
|
|
- for key := range this.Request.Form {
|
|
|
- value := this.Request.Form.Get(key)
|
|
|
- if key != "token" {
|
|
|
- vmap[key] = value
|
|
|
- } else {
|
|
|
- userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(value)
|
|
|
- if err != nil {
|
|
|
- vmap[key] = err.Error()
|
|
|
- continue
|
|
|
- }
|
|
|
- vmap[key] = map[string]interface{}{
|
|
|
- "userid": userid,
|
|
|
- "sellPName": sellPName,
|
|
|
- "sellPid": sellPid,
|
|
|
- "sellData": sellData,
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- this.ServeJson(vmap)
|
|
|
+ vmap := map[string]interface{}{}
|
|
|
+ for key := range this.Request.Form {
|
|
|
+ value := this.Request.Form.Get(key)
|
|
|
+ if key != "token" {
|
|
|
+ vmap[key] = value
|
|
|
+ } else {
|
|
|
+ userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(value)
|
|
|
+ if err != nil {
|
|
|
+ vmap[key] = err.Error()
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ vmap[key] = map[string]interface{}{
|
|
|
+ "userid": userid,
|
|
|
+ "sellPName": sellPName,
|
|
|
+ "sellPid": sellPid,
|
|
|
+ "sellData": sellData,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.ServeJson(vmap)
|
|
|
}
|
|
|
|
|
|
// CreateBySeller 销售为用户创建订单
|
|
|
// 逻辑和Createorder 一致
|
|
|
// 无用户身份,额外赠送
|
|
|
func (this *SalesCreateOrder) CreateBySeller() {
|
|
|
- var userid string
|
|
|
- rData, errMsg := func() (interface{}, error) {
|
|
|
- //参数接收
|
|
|
- infoMap := map[string]interface{}{}
|
|
|
- body := xweb.FilterXSS(string(this.Body()))
|
|
|
- //接收参数
|
|
|
- _ = json.Unmarshal([]byte(body), &infoMap)
|
|
|
- if len(infoMap) == 0 {
|
|
|
- return nil, fmt.Errorf("无效参数")
|
|
|
- }
|
|
|
- //解密请求参数
|
|
|
- userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(qutil.ObjToString(infoMap["token"]))
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- //产品类型
|
|
|
- product, _ := infoMap["product"].(string)
|
|
|
- if product != "VIP订阅" { //目前仅超级订阅
|
|
|
- return nil, fmt.Errorf("请求产品类型有误")
|
|
|
- }
|
|
|
- productId := strconv.Itoa(qutil.IntAll(infoMap["productId"]))
|
|
|
+ var userid string
|
|
|
+ rData, errMsg := func() (interface{}, error) {
|
|
|
+ //参数接收
|
|
|
+ infoMap := map[string]interface{}{}
|
|
|
+ body := xweb.FilterXSS(string(this.Body()))
|
|
|
+ //接收参数
|
|
|
+ _ = json.Unmarshal([]byte(body), &infoMap)
|
|
|
+ if len(infoMap) == 0 {
|
|
|
+ return nil, fmt.Errorf("无效参数")
|
|
|
+ }
|
|
|
+ //解密请求参数
|
|
|
+ userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(qutil.ObjToString(infoMap["token"]))
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ //产品类型
|
|
|
+ product, _ := infoMap["product"].(string)
|
|
|
+ if product != "VIP订阅" { //目前仅超级订阅
|
|
|
+ return nil, fmt.Errorf("请求产品类型有误")
|
|
|
+ }
|
|
|
+ productId := strconv.Itoa(qutil.IntAll(infoMap["productId"]))
|
|
|
|
|
|
- //
|
|
|
- data, _ := infoMap["data"].(map[string]interface{})
|
|
|
- if len(data) <= 0 {
|
|
|
- return nil, fmt.Errorf("无效参数")
|
|
|
- }
|
|
|
+ //
|
|
|
+ data, _ := infoMap["data"].(map[string]interface{})
|
|
|
+ if len(data) <= 0 {
|
|
|
+ return nil, fmt.Errorf("无效参数")
|
|
|
+ }
|
|
|
|
|
|
- //获取卡券相关
|
|
|
- lotteryId := qutil.ObjToString(data["lotteryId"]) //卡卷信息的id
|
|
|
- i_discountId := qutil.IntAll(data["discountId"]) //赠品相关
|
|
|
- discountId := strconv.Itoa(i_discountId)
|
|
|
- inserMap, msg := entity.JyCommonOrderStruct.InserMap(product, productId, userid, lotteryId, discountId, data, this.Session())
|
|
|
- //错误信息
|
|
|
- if msg != "" {
|
|
|
- return nil, fmt.Errorf(msg)
|
|
|
- }
|
|
|
- //销售额外赠送
|
|
|
- if product == "VIP订阅" && len(sellData) > 0 {
|
|
|
- tt := qutil.IntAll(sellData["tt"])
|
|
|
- tn := qutil.IntAll(sellData["tn"])
|
|
|
- if inserMap.VipEndTime != "" {
|
|
|
- endTime, _ := time.ParseInLocation(Date_Full_Layout, inserMap.VipEndTime, time.Local)
|
|
|
- if tt == 1 {
|
|
|
- endTime = endTime.AddDate(0, 0, tn)
|
|
|
- } else if tt == 2 {
|
|
|
- endTime = endTime.AddDate(0, tn, 0)
|
|
|
- }
|
|
|
- inserMap.VipEndTime = endTime.Format(Date_Full_Layout)
|
|
|
- }
|
|
|
+ //获取卡券相关
|
|
|
+ lotteryId := qutil.ObjToString(data["lotteryId"]) //卡卷信息的id
|
|
|
+ i_discountId := qutil.IntAll(data["discountId"]) //赠品相关
|
|
|
+ discountId := strconv.Itoa(i_discountId)
|
|
|
+ inserMap, msg := entity.JyCommonOrderStruct.InserMap(product, productId, userid, lotteryId, discountId, data, this.Session())
|
|
|
+ //错误信息
|
|
|
+ if msg != "" {
|
|
|
+ return nil, fmt.Errorf(msg)
|
|
|
+ }
|
|
|
+ //销售额外赠送
|
|
|
+ if product == "VIP订阅" && len(sellData) > 0 {
|
|
|
+ tt := qutil.IntAll(sellData["tt"])
|
|
|
+ tn := qutil.IntAll(sellData["tn"])
|
|
|
+ if inserMap.VipEndTime != "" {
|
|
|
+ endTime, _ := time.ParseInLocation(Date_Full_Layout, inserMap.VipEndTime, time.Local)
|
|
|
+ if tt == 1 {
|
|
|
+ endTime = endTime.AddDate(0, 0, tn)
|
|
|
+ } else if tt == 2 {
|
|
|
+ endTime = endTime.AddDate(0, tn, 0)
|
|
|
+ }
|
|
|
+ inserMap.VipEndTime = endTime.Format(Date_Full_Layout)
|
|
|
+ }
|
|
|
|
|
|
- filterMap := map[string]interface{}{}
|
|
|
- if err := json.Unmarshal([]byte(inserMap.Filter), &filterMap); err != nil {
|
|
|
- return nil, fmt.Errorf("创建订单异常Unmarshal")
|
|
|
- }
|
|
|
+ filterMap := map[string]interface{}{}
|
|
|
+ if err := json.Unmarshal([]byte(inserMap.Filter), &filterMap); err != nil {
|
|
|
+ return nil, fmt.Errorf("创建订单异常Unmarshal")
|
|
|
+ }
|
|
|
|
|
|
- if inserMap.VipType != 2 {
|
|
|
- filterMap["seller_give_type"] = tt
|
|
|
- filterMap["seller_give_cycle"] = tn
|
|
|
- }
|
|
|
+ if inserMap.VipType != 2 {
|
|
|
+ filterMap["seller_give_type"] = tt
|
|
|
+ filterMap["seller_give_cycle"] = tn
|
|
|
+ }
|
|
|
|
|
|
- bb, err := json.Marshal(filterMap)
|
|
|
- if err != nil {
|
|
|
- return nil, fmt.Errorf("创建订单异常-Marshal")
|
|
|
- }
|
|
|
- inserMap.Filter = string(bb)
|
|
|
- }
|
|
|
- now := time.Now()
|
|
|
- _, userErr := primitive.ObjectIDFromHex(userid)
|
|
|
- buy_subject := 1
|
|
|
- entId := 0
|
|
|
- if userErr != nil {
|
|
|
- //雇员标识
|
|
|
- positionData := util.InfoMysql.FindOne("base_position", map[string]interface{}{"id": userid}, "ent_id", "")
|
|
|
- if positionData != nil {
|
|
|
- entId = qutil.IntAll((*positionData)["ent_id"])
|
|
|
- }
|
|
|
- }
|
|
|
- insertM := map[string]interface{}{
|
|
|
- "order_money": inserMap.OrderMoney,
|
|
|
- "order_status": inserMap.OrderStatus,
|
|
|
- "service_status": inserMap.ServiceStatus,
|
|
|
- "user_phone": inserMap.UserPhone,
|
|
|
- "order_code": inserMap.OrderCode,
|
|
|
- "product_type": product,
|
|
|
- "create_time": FormatDate(&now, Date_Full_Layout),
|
|
|
- "original_price": inserMap.OriginalPrice,
|
|
|
- "user_id": userid,
|
|
|
- "filter": inserMap.Filter,
|
|
|
- "discount_price": inserMap.DiscountPrice,
|
|
|
- "d_relation_id": inserMap.DrelationId,
|
|
|
- "data_spec": inserMap.DataSpec,
|
|
|
- "user_mail": inserMap.UserMail,
|
|
|
- "data_count": inserMap.DataCount,
|
|
|
- "filter_publishtime": inserMap.FilterPublishtime,
|
|
|
- "is_backstage_order": 0,
|
|
|
- "filter_keys": inserMap.FilterKeys,
|
|
|
- "download_url": inserMap.DownloadUrl,
|
|
|
- "dis_word": inserMap.DisWord,
|
|
|
- "distribution_channel": "x020",
|
|
|
- "order_channel": "xdqd04", //下单渠道-启明星后台销售创建
|
|
|
- "salesperson": sellPName, //销售人员
|
|
|
- "salesperson_id": sellPid, //销售人员id
|
|
|
- "audit_status": 3, //默认审核通过
|
|
|
- "buy_subject": buy_subject,
|
|
|
- "ent_id": entId,
|
|
|
- }
|
|
|
+ bb, err := json.Marshal(filterMap)
|
|
|
+ if err != nil {
|
|
|
+ return nil, fmt.Errorf("创建订单异常-Marshal")
|
|
|
+ }
|
|
|
+ inserMap.Filter = string(bb)
|
|
|
+ }
|
|
|
+ now := time.Now()
|
|
|
+ _, userErr := primitive.ObjectIDFromHex(userid)
|
|
|
+ buy_subject := 1
|
|
|
+ entId := 0
|
|
|
+ if userErr != nil {
|
|
|
+ //雇员标识
|
|
|
+ positionData := util.InfoMysql.FindOne("base_position", map[string]interface{}{"id": userid}, "ent_id", "")
|
|
|
+ if positionData != nil {
|
|
|
+ entId = qutil.IntAll((*positionData)["ent_id"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insertM := map[string]interface{}{
|
|
|
+ "order_money": inserMap.OrderMoney,
|
|
|
+ "order_status": inserMap.OrderStatus,
|
|
|
+ "service_status": inserMap.ServiceStatus,
|
|
|
+ "user_phone": inserMap.UserPhone,
|
|
|
+ "order_code": inserMap.OrderCode,
|
|
|
+ "product_type": product,
|
|
|
+ "create_time": FormatDate(&now, Date_Full_Layout),
|
|
|
+ "original_price": inserMap.OriginalPrice,
|
|
|
+ "user_id": userid,
|
|
|
+ "filter": inserMap.Filter,
|
|
|
+ "discount_price": inserMap.DiscountPrice,
|
|
|
+ "d_relation_id": inserMap.DrelationId,
|
|
|
+ "data_spec": inserMap.DataSpec,
|
|
|
+ "user_mail": inserMap.UserMail,
|
|
|
+ "data_count": inserMap.DataCount,
|
|
|
+ "filter_publishtime": inserMap.FilterPublishtime,
|
|
|
+ "is_backstage_order": 0,
|
|
|
+ "filter_keys": inserMap.FilterKeys,
|
|
|
+ "download_url": inserMap.DownloadUrl,
|
|
|
+ "dis_word": inserMap.DisWord,
|
|
|
+ "distribution_channel": "x020",
|
|
|
+ "order_channel": "xdqd04", //下单渠道-启明星后台销售创建
|
|
|
+ "salesperson": sellPName, //销售人员
|
|
|
+ "salesperson_id": sellPid, //销售人员id
|
|
|
+ "audit_status": 3, //默认审核通过
|
|
|
+ "buy_subject": buy_subject,
|
|
|
+ "ent_id": entId,
|
|
|
+ }
|
|
|
|
|
|
- if inserMap.VipStartTime != "" && inserMap.VipEndTime != "" {
|
|
|
- insertM["vip_starttime"] = inserMap.VipStartTime
|
|
|
- insertM["vip_endtime"] = inserMap.VipEndTime
|
|
|
- }
|
|
|
- if inserMap.PrepayTime != "" {
|
|
|
- insertM["prepay_time"] = inserMap.PrepayTime
|
|
|
- }
|
|
|
- if inserMap.PayWay != "" {
|
|
|
- insertM["pay_way"] = inserMap.PayWay
|
|
|
- }
|
|
|
- if inserMap.PrepayId != "" {
|
|
|
- insertM["prepay_id"] = inserMap.PrepayId
|
|
|
- }
|
|
|
- if inserMap.FilterId != "" {
|
|
|
- insertM["filter_id"] = inserMap.FilterId
|
|
|
- }
|
|
|
- if inserMap.VipType != 0 {
|
|
|
- insertM["vip_type"] = inserMap.VipType
|
|
|
- }
|
|
|
+ if inserMap.VipStartTime != "" && inserMap.VipEndTime != "" {
|
|
|
+ insertM["vip_starttime"] = inserMap.VipStartTime
|
|
|
+ insertM["vip_endtime"] = inserMap.VipEndTime
|
|
|
+ }
|
|
|
+ if inserMap.PrepayTime != "" {
|
|
|
+ insertM["prepay_time"] = inserMap.PrepayTime
|
|
|
+ }
|
|
|
+ if inserMap.PayWay != "" {
|
|
|
+ insertM["pay_way"] = inserMap.PayWay
|
|
|
+ }
|
|
|
+ if inserMap.PrepayId != "" {
|
|
|
+ insertM["prepay_id"] = inserMap.PrepayId
|
|
|
+ }
|
|
|
+ if inserMap.FilterId != "" {
|
|
|
+ insertM["filter_id"] = inserMap.FilterId
|
|
|
+ }
|
|
|
+ if inserMap.VipType != 0 {
|
|
|
+ insertM["vip_type"] = inserMap.VipType
|
|
|
+ }
|
|
|
|
|
|
- orderid := util.Mysql.Insert("dataexport_order", insertM)
|
|
|
- if orderid <= 0 {
|
|
|
- return nil, fmt.Errorf("创建订单异常")
|
|
|
- }
|
|
|
- //发送站内信
|
|
|
- pcUrl := fmt.Sprintf(config.Config.WebSiteParameter.Link, inserMap.OrderCode)
|
|
|
- appUrl := fmt.Sprintf(config.Config.WebSiteParameter.AndroidUrl, inserMap.OrderCode)
|
|
|
- wxUrl := fmt.Sprintf(config.Config.WebSiteParameter.WeChatUrl, inserMap.OrderCode)
|
|
|
- go util.SendStationMessages(config.Config.WebSiteParameter.Addr, userid, config.Config.WebSiteParameter.Action,
|
|
|
- "1", config.Config.WebSiteParameter.Title, config.Config.WebSiteParameter.Content,
|
|
|
- pcUrl, appUrl, appUrl, wxUrl, qutil.InterfaceToStr(orderid))
|
|
|
+ orderid := util.Mysql.Insert("dataexport_order", insertM)
|
|
|
+ if orderid <= 0 {
|
|
|
+ return nil, fmt.Errorf("创建订单异常")
|
|
|
+ }
|
|
|
+ //发送站内信
|
|
|
+ pcUrl := fmt.Sprintf(config.Config.WebSiteParameter.Link, inserMap.OrderCode)
|
|
|
+ appUrl := fmt.Sprintf(config.Config.WebSiteParameter.AndroidUrl, inserMap.OrderCode)
|
|
|
+ wxUrl := fmt.Sprintf(config.Config.WebSiteParameter.WeChatUrl, inserMap.OrderCode)
|
|
|
+ go util.SendStationMessages(config.Config.WebSiteParameter.Addr, userid, config.Config.WebSiteParameter.Action,
|
|
|
+ "1", config.Config.WebSiteParameter.Title, config.Config.WebSiteParameter.Content,
|
|
|
+ pcUrl, appUrl, appUrl, wxUrl, qutil.InterfaceToStr(orderid))
|
|
|
|
|
|
- if i_discountId > 0 {
|
|
|
- go util.FindUserLotteryId(userid, orderid, i_discountId)
|
|
|
- }
|
|
|
- rdata := map[string]interface{}{"order_code": inserMap.OrderCode, "needPay": !inserMap.UnNeedPay}
|
|
|
- return rdata, nil
|
|
|
- }()
|
|
|
- if errMsg != nil {
|
|
|
- log.Printf("%s CreateBySeller 异常:%s\n", userid, errMsg.Error())
|
|
|
- }
|
|
|
- //创建完订单后更新卡券信息
|
|
|
- this.ServeJson(NewResult(rData, errMsg))
|
|
|
+ if i_discountId > 0 {
|
|
|
+ go util.FindUserLotteryId(userid, orderid, i_discountId)
|
|
|
+ }
|
|
|
+ rdata := map[string]interface{}{"order_code": inserMap.OrderCode, "needPay": !inserMap.UnNeedPay}
|
|
|
+ return rdata, nil
|
|
|
+ }()
|
|
|
+ if errMsg != nil {
|
|
|
+ log.Printf("%s CreateBySeller 异常:%s\n", userid, errMsg.Error())
|
|
|
+ }
|
|
|
+ //创建完订单后更新卡券信息
|
|
|
+ this.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
// WxPaymentPage
|
|
|
// 微信支付将openid添加至token
|
|
|
// 并重定向至指定url
|
|
|
func (this *SalesCreateOrder) WxPaymentPage() error {
|
|
|
- stateKey := this.GetString("state")
|
|
|
- if (this.GetString("href") == "" || this.GetString("token") == "") &&
|
|
|
- stateKey == "" {
|
|
|
- return this.WriteBytes([]byte("请求异常"))
|
|
|
- }
|
|
|
- param := this.Request.Form
|
|
|
- if stateKey == "" { //公众号回调
|
|
|
- stateKey = func() string {
|
|
|
- return fmt.Sprintf("%s_%s", time.Now().Format("20060102150405"), qutil.GetLetterRandom(5))
|
|
|
- }()
|
|
|
- redis.Put("other", stateKey, param, 60*5) //存储信息
|
|
|
- return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
|
|
|
- }
|
|
|
- //获取wx跳转前参数
|
|
|
- if redisValue := redis.Get("other", stateKey); redisValue != nil {
|
|
|
- if t, ok := redisValue.(url.Values); ok {
|
|
|
- param = t
|
|
|
- }
|
|
|
- }
|
|
|
- //获取用户openid
|
|
|
- openid := util.Getopenid(this.GetString("code"))
|
|
|
- if openid == "" {
|
|
|
- return this.WriteBytes([]byte("获取用户身份异常"))
|
|
|
- }
|
|
|
- userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(param.Get("token"))
|
|
|
- if err != nil {
|
|
|
- return this.WriteBytes([]byte(err.Error()))
|
|
|
- }
|
|
|
- sellData["openid"] = openid
|
|
|
- toHref := param.Get("href")
|
|
|
- param.Set("token", util.GetSellerToken(userid, sellPName, sellPid, sellData)) //更新token
|
|
|
- for _, key := range []string{"state", "code", "href"} {
|
|
|
- param.Del(key)
|
|
|
- }
|
|
|
- return this.Redirect(toHref+"?"+param.Encode(), 302)
|
|
|
+ stateKey := this.GetString("state")
|
|
|
+ if (this.GetString("href") == "" || this.GetString("token") == "") &&
|
|
|
+ stateKey == "" {
|
|
|
+ return this.WriteBytes([]byte("请求异常"))
|
|
|
+ }
|
|
|
+ param := this.Request.Form
|
|
|
+ if stateKey == "" { //公众号回调
|
|
|
+ stateKey = func() string {
|
|
|
+ return fmt.Sprintf("%s_%s", time.Now().Format("20060102150405"), qutil.GetLetterRandom(5))
|
|
|
+ }()
|
|
|
+ redis.Put("other", stateKey, param, 60*5) //存储信息
|
|
|
+ return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
|
|
|
+ }
|
|
|
+ //获取wx跳转前参数
|
|
|
+ if redisValue := redis.Get("other", stateKey); redisValue != nil {
|
|
|
+ if t, ok := redisValue.(url.Values); ok {
|
|
|
+ param = t
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取用户openid
|
|
|
+ openid := util.Getopenid(this.GetString("code"))
|
|
|
+ if openid == "" {
|
|
|
+ return this.WriteBytes([]byte("获取用户身份异常"))
|
|
|
+ }
|
|
|
+ userid, sellPName, sellPid, sellData, err := util.SellerTokenDecrypt(param.Get("token"))
|
|
|
+ if err != nil {
|
|
|
+ return this.WriteBytes([]byte(err.Error()))
|
|
|
+ }
|
|
|
+ sellData["openid"] = openid
|
|
|
+ toHref := param.Get("href")
|
|
|
+ param.Set("token", util.GetSellerToken(userid, sellPName, sellPid, sellData)) //更新token
|
|
|
+ for _, key := range []string{"state", "code", "href"} {
|
|
|
+ param.Del(key)
|
|
|
+ }
|
|
|
+ return this.Redirect(toHref+"?"+param.Encode(), 302)
|
|
|
}
|
|
|
|
|
|
// GetCommonPayParam 销售为用户创建订单
|
|
|
// 逻辑和commonAction.go GetCommonPayParam 一致
|
|
|
func (this *SalesCreateOrder) GetCommonPayParam() {
|
|
|
- orderCode := this.GetString("orderCode")
|
|
|
- //userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
- payway_req := this.GetString("payway")
|
|
|
- var userId string
|
|
|
- r := func() *entity.FuncResult {
|
|
|
- //解密请求参数
|
|
|
- userId, _, _, desc, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- if err != nil {
|
|
|
- return &entity.FuncResult{false, err, nil}
|
|
|
- }
|
|
|
- query := map[string]interface{}{
|
|
|
- "user_id": userId,
|
|
|
- "order_code": orderCode,
|
|
|
- "order_channel": "xdqd04", //仅查询销售创建订单
|
|
|
- "order_status": 0,
|
|
|
- }
|
|
|
- oData := util.Mysql.FindOne("dataexport_order", query, "id,code_url,prepay_time,pay_way,order_money,product_type,out_trade_no,course_status", "")
|
|
|
- if oData == nil || len(*oData) == 0 {
|
|
|
- return &entity.FuncResult{false, errors.New("未知订单"), nil}
|
|
|
- }
|
|
|
- //对公转账审核中
|
|
|
- if qutil.IntAll((*oData)["course_status"]) == 2 || qutil.IntAll((*oData)["course_status"]) == 4 {
|
|
|
- return &entity.FuncResult{false, errors.New("转账审核中,请勿重复支付"), nil}
|
|
|
- }
|
|
|
- payParam := qutil.ObjToString((*oData)["code_url"])
|
|
|
- payway := qutil.ObjToString((*oData)["pay_way"])
|
|
|
- totalfee := qutil.IntAll((*oData)["order_money"])
|
|
|
- //上次订单支付串是否可用
|
|
|
- if prepayTime, err := time.ParseInLocation(Date_Full_Layout, qutil.ObjToString((*oData)["prepay_time"]), time.Local); err == nil && payParam != "" && payway != "wx_js" { //微信公众号支付需要openid,不通账户支付不能通用
|
|
|
- if time.Now().Before(prepayTime.Add(time.Hour * 2)) { //支付串未过期
|
|
|
- if payway == payway_req {
|
|
|
- if payParam != "" {
|
|
|
- return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
- "orderCode": orderCode,
|
|
|
- "res": payParam,
|
|
|
- "price": totalfee,
|
|
|
- "timeout": prepayTime.Unix() + 2*60*60 - time.Now().Unix(),
|
|
|
- "payWay": payway}}
|
|
|
- }
|
|
|
- } else {
|
|
|
- //关闭之前支付串(防止重复支付)
|
|
|
- if !pay.CloseOrder(qutil.ObjToString((*oData)["out_trade_no"]), payway) {
|
|
|
- log.Printf("SalesCreateOrder GetCommonPayParam 关闭订单%s出错\n", orderCode)
|
|
|
- return &entity.FuncResult{false, errors.New("支付方式切换异常"), nil}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- openid := ""
|
|
|
- if payway_req == "wx_js" {
|
|
|
- if openid, _ = desc["openid"].(string); openid == "" {
|
|
|
- return &entity.FuncResult{false, fmt.Errorf("微信支付缺少参数"), nil}
|
|
|
- }
|
|
|
- } //重新生成支付串
|
|
|
- productFlag, ok := pay.PayWayAndSign[qutil.ObjToString((*oData)["product_type"])][payway_req]
|
|
|
- if !ok {
|
|
|
- return &entity.FuncResult{false, errors.New("未知支付类型:" + payway_req), nil}
|
|
|
- }
|
|
|
- tradeno, prepayid, payParam, err := pay.CreateOrderPay(totalfee, productFlag, this.IP(), openid, payway_req, orderCode)
|
|
|
- if err != nil {
|
|
|
- return &entity.FuncResult{false, errors.New(fmt.Sprintf("创建支付失败[%v]", err)), nil}
|
|
|
- }
|
|
|
- //更新订单表
|
|
|
- now := time.Now()
|
|
|
- ok = util.Mysql.Update("dataexport_order", query, map[string]interface{}{
|
|
|
- "code_url": payParam,
|
|
|
- "prepay_time": FormatDate(&now, Date_Full_Layout),
|
|
|
- "out_trade_no": tradeno,
|
|
|
- "prepay_id": prepayid,
|
|
|
- "pay_way": payway_req,
|
|
|
- })
|
|
|
- if !ok {
|
|
|
- return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
|
|
|
- }
|
|
|
- return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
- "orderCode": orderCode,
|
|
|
- "res": payParam,
|
|
|
- "price": totalfee,
|
|
|
- "timeout": 2 * 60 * 60,
|
|
|
- "payWay": payway_req}}
|
|
|
- }()
|
|
|
- if r.Err != nil {
|
|
|
- log.Printf("%s SalesCreateOrder GetCommonPayParam err:%v\n", userId, r.Err.Error())
|
|
|
- }
|
|
|
- if payway_req == "wx_pc" && r.Data["res"] != nil {
|
|
|
- rEncode, _ := qr.Encode(qutil.ObjToString(r.Data["res"]), qr.M)
|
|
|
- pngdat := rEncode.PNG()
|
|
|
- r.Data["res"] = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
- }
|
|
|
- this.ServeJson(r.Format())
|
|
|
+ orderCode := this.GetString("orderCode")
|
|
|
+ //userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
+ payway_req := this.GetString("payway")
|
|
|
+ var userId string
|
|
|
+ r := func() *entity.FuncResult {
|
|
|
+ //解密请求参数
|
|
|
+ userId, _, _, desc, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, err, nil}
|
|
|
+ }
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "user_id": userId,
|
|
|
+ "order_code": orderCode,
|
|
|
+ "order_channel": "xdqd04", //仅查询销售创建订单
|
|
|
+ "order_status": 0,
|
|
|
+ }
|
|
|
+ oData := util.Mysql.FindOne("dataexport_order", query, "id,code_url,prepay_time,pay_way,order_money,product_type,out_trade_no,course_status", "")
|
|
|
+ if oData == nil || len(*oData) == 0 {
|
|
|
+ return &entity.FuncResult{false, errors.New("未知订单"), nil}
|
|
|
+ }
|
|
|
+ //对公转账审核中
|
|
|
+ if qutil.IntAll((*oData)["course_status"]) == 2 || qutil.IntAll((*oData)["course_status"]) == 4 {
|
|
|
+ return &entity.FuncResult{false, errors.New("转账审核中,请勿重复支付"), nil}
|
|
|
+ }
|
|
|
+ payParam := qutil.ObjToString((*oData)["code_url"])
|
|
|
+ payway := qutil.ObjToString((*oData)["pay_way"])
|
|
|
+ totalfee := qutil.IntAll((*oData)["order_money"])
|
|
|
+ //上次订单支付串是否可用
|
|
|
+ if prepayTime, err := time.ParseInLocation(Date_Full_Layout, qutil.ObjToString((*oData)["prepay_time"]), time.Local); err == nil && payParam != "" && payway != "wx_js" { //微信公众号支付需要openid,不通账户支付不能通用
|
|
|
+ if time.Now().Before(prepayTime.Add(time.Hour * 2)) { //支付串未过期
|
|
|
+ if payway == payway_req {
|
|
|
+ if payParam != "" {
|
|
|
+ return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
+ "orderCode": orderCode,
|
|
|
+ "res": payParam,
|
|
|
+ "price": totalfee,
|
|
|
+ "timeout": prepayTime.Unix() + 2*60*60 - time.Now().Unix(),
|
|
|
+ "payWay": payway}}
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //关闭之前支付串(防止重复支付)
|
|
|
+ if !pay.CloseOrder(qutil.ObjToString((*oData)["out_trade_no"]), payway) {
|
|
|
+ log.Printf("SalesCreateOrder GetCommonPayParam 关闭订单%s出错\n", orderCode)
|
|
|
+ return &entity.FuncResult{false, errors.New("支付方式切换异常"), nil}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ openid := ""
|
|
|
+ if payway_req == "wx_js" {
|
|
|
+ if openid, _ = desc["openid"].(string); openid == "" {
|
|
|
+ return &entity.FuncResult{false, fmt.Errorf("微信支付缺少参数"), nil}
|
|
|
+ }
|
|
|
+ } //重新生成支付串
|
|
|
+ productFlag, ok := pay.PayWayAndSign[qutil.ObjToString((*oData)["product_type"])][payway_req]
|
|
|
+ if !ok {
|
|
|
+ return &entity.FuncResult{false, errors.New("未知支付类型:" + payway_req), nil}
|
|
|
+ }
|
|
|
+ tradeno, prepayid, payParam, err := pay.CreateOrderPay(totalfee, productFlag, this.IP(), openid, payway_req, orderCode)
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, errors.New(fmt.Sprintf("创建支付失败[%v]", err)), nil}
|
|
|
+ }
|
|
|
+ //更新订单表
|
|
|
+ now := time.Now()
|
|
|
+ ok = util.Mysql.Update("dataexport_order", query, map[string]interface{}{
|
|
|
+ "code_url": payParam,
|
|
|
+ "prepay_time": FormatDate(&now, Date_Full_Layout),
|
|
|
+ "out_trade_no": tradeno,
|
|
|
+ "prepay_id": prepayid,
|
|
|
+ "pay_way": payway_req,
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
|
|
|
+ }
|
|
|
+ return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
+ "orderCode": orderCode,
|
|
|
+ "res": payParam,
|
|
|
+ "price": totalfee,
|
|
|
+ "timeout": 2 * 60 * 60,
|
|
|
+ "payWay": payway_req}}
|
|
|
+ }()
|
|
|
+ if r.Err != nil {
|
|
|
+ log.Printf("%s SalesCreateOrder GetCommonPayParam err:%v\n", userId, r.Err.Error())
|
|
|
+ }
|
|
|
+ if payway_req == "wx_pc" && r.Data["res"] != nil {
|
|
|
+ rEncode, _ := qr.Encode(qutil.ObjToString(r.Data["res"]), qr.M)
|
|
|
+ pngdat := rEncode.PNG()
|
|
|
+ r.Data["res"] = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
+ }
|
|
|
+ this.ServeJson(r.Format())
|
|
|
}
|
|
|
|
|
|
func (this *SalesCreateOrder) IsPaySuccess() {
|
|
|
- defer qutil.Catch()
|
|
|
- var userId string
|
|
|
- rMap, err := func() (rData map[string]interface{}, err error) {
|
|
|
- code := this.GetString("code")
|
|
|
- userId, _, _, _, err = util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- if code != "" && userId != "" {
|
|
|
- data := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
- "order_code": code,
|
|
|
- "user_id": userId,
|
|
|
- "order_channel": "xdqd04",
|
|
|
- }, "order_status,pay_time,user_mail,pay_way,pay_money,filter", "")
|
|
|
- if data != nil && qutil.IntAll((*data)["order_status"]) == 1 {
|
|
|
- t, _ := time.ParseInLocation(Date_Full_Layout, qutil.ObjToString((*data)["pay_time"]), time.Local)
|
|
|
- return map[string]interface{}{
|
|
|
- "success": true,
|
|
|
- "email": qutil.ObjToString((*data)["user_mail"]),
|
|
|
- "payTime": t.Unix(),
|
|
|
- "pay_way": (*data)["pay_way"],
|
|
|
- "price": (*data)["pay_money"],
|
|
|
- "filter": (*data)["filter"],
|
|
|
- "orderCode": code,
|
|
|
- }, nil
|
|
|
- }
|
|
|
- }
|
|
|
- rData["success"] = false
|
|
|
- return
|
|
|
- }()
|
|
|
- if err != nil {
|
|
|
- log.Printf("%s SalesCreateOrder IsPaySuccess err:%v\n", userId, err.Error())
|
|
|
- }
|
|
|
- this.ServeJson(rMap)
|
|
|
+ defer qutil.Catch()
|
|
|
+ var userId string
|
|
|
+ rMap, err := func() (rData map[string]interface{}, err error) {
|
|
|
+ code := this.GetString("code")
|
|
|
+ userId, _, _, _, err = util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if code != "" && userId != "" {
|
|
|
+ data := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
+ "order_code": code,
|
|
|
+ "user_id": userId,
|
|
|
+ "order_channel": "xdqd04",
|
|
|
+ }, "order_status,pay_time,user_mail,pay_way,pay_money,filter", "")
|
|
|
+ if data != nil && qutil.IntAll((*data)["order_status"]) == 1 {
|
|
|
+ t, _ := time.ParseInLocation(Date_Full_Layout, qutil.ObjToString((*data)["pay_time"]), time.Local)
|
|
|
+ return map[string]interface{}{
|
|
|
+ "success": true,
|
|
|
+ "email": qutil.ObjToString((*data)["user_mail"]),
|
|
|
+ "payTime": t.Unix(),
|
|
|
+ "pay_way": (*data)["pay_way"],
|
|
|
+ "price": (*data)["pay_money"],
|
|
|
+ "filter": (*data)["filter"],
|
|
|
+ "orderCode": code,
|
|
|
+ }, nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rData["success"] = false
|
|
|
+ return
|
|
|
+ }()
|
|
|
+ if err != nil {
|
|
|
+ log.Printf("%s SalesCreateOrder IsPaySuccess err:%v\n", userId, err.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(rMap)
|
|
|
}
|
|
|
|
|
|
// GetSubBuyMsg 获取购买订阅相关信息
|
|
|
// 逻辑和vipSubscribeChange.go getSubBuyMsg 一致
|
|
|
func (this *SalesCreateOrder) GetSubBuyMsg() {
|
|
|
- var userId string
|
|
|
- r := func() *entity.FuncResult {
|
|
|
- userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- ent_id := qutil.IntAll(this.GetSession("entId"))
|
|
|
- entUserId := qutil.IntAll(this.GetSession("entUserId"))
|
|
|
- if err != nil {
|
|
|
- return &entity.FuncResult{false, err, nil}
|
|
|
- }
|
|
|
- rData, buyset, vip := entity.JyVipSubStruct.GetVipDetail(userId)
|
|
|
- if rData == nil || len(*rData) == 0 {
|
|
|
- return &entity.FuncResult{false, errors.New("获取信息失败"), nil}
|
|
|
- }
|
|
|
- var isread = false
|
|
|
- if (*rData)["isread"] != nil {
|
|
|
- isread = (*rData)["isread"].(bool)
|
|
|
- }
|
|
|
- o_vipjy := &map[string]interface{}{}
|
|
|
- //判断版本是企业的还是个人的
|
|
|
- infoCount := util.Mysql.CountBySql("select count(id) from entniche_wait_empower where ent_id=? and end_time>NOW() and product_type like '%VIP订阅%' ", ent_id)
|
|
|
- if infoCount > 0 {
|
|
|
- query := map[string]interface{}{
|
|
|
- "i_userid": entUserId,
|
|
|
- "i_entid": ent_id,
|
|
|
- "i_type": 1,
|
|
|
- }
|
|
|
- res, _ := util.MQFW.FindOne("entniche_rule", query)
|
|
|
- if res != nil && len(*res) > 0 {
|
|
|
- o_vipjy = qutil.ObjToMap((*res)["o_entniche"])
|
|
|
- }
|
|
|
- } else {
|
|
|
- o_vipjy = qutil.ObjToMap((*rData)["o_vipjy"])
|
|
|
- }
|
|
|
- vipStatus := qutil.IntAll((*rData)["i_vip_status"])
|
|
|
- var renewList *[]map[string]interface{}
|
|
|
- if vipStatus == 2 { //查询是否有未执行的续费订单
|
|
|
- renewList, _ = util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":1}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
|
|
|
- for i := 0; i < len(*renewList); i++ {
|
|
|
- delete((*renewList)[i], "_id")
|
|
|
- }
|
|
|
- }
|
|
|
- bigPower := jy.GetBigVipUserBaseMsg("10000", this.Session(), config.Config.Etcd.Hosts, config.Config.Etcd.Key)
|
|
|
- return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
- "isTrial": vipStatus == 1,
|
|
|
- "area": (*o_vipjy)["o_area"],
|
|
|
- "industry": (*o_vipjy)["a_buyerclass"],
|
|
|
- "buyset": buyset,
|
|
|
- "renewList": renewList,
|
|
|
- "infotype": (*o_vipjy)["a_infotype"],
|
|
|
- "items": (*o_vipjy)["a_items"],
|
|
|
- "projectmatch": (*o_vipjy)["i_projectmatch"],
|
|
|
- "ratemode": (*o_vipjy)["i_ratemode"],
|
|
|
- "matchway": (*o_vipjy)["i_matchway"],
|
|
|
- "startTime": (*rData)["l_vip_starttime"],
|
|
|
- "endTime": (*rData)["l_vip_endtime"],
|
|
|
- "otherbuyerclass": (*o_vipjy)["i_matchbuyerclass_other"],
|
|
|
- "isread": isread,
|
|
|
- "isvip": vip,
|
|
|
- "isnew": NewUserByVIP(userId, this.Session()), //免费订阅区分新老用户
|
|
|
- "isUpgrade": bigPower.IsUpgrade,
|
|
|
- }}
|
|
|
- }()
|
|
|
- if r.Err != nil {
|
|
|
- log.Printf("%s SalesCreateOrder GetSubBuyMsg err:%v\n", userId, r.Err.Error())
|
|
|
- }
|
|
|
- this.ServeJson(r.Format())
|
|
|
+ var userId string
|
|
|
+ r := func() *entity.FuncResult {
|
|
|
+ userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ ent_id := qutil.IntAll(this.GetSession("entId"))
|
|
|
+ entUserId := qutil.IntAll(this.GetSession("entUserId"))
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, err, nil}
|
|
|
+ }
|
|
|
+ rData, buyset, vip := entity.JyVipSubStruct.GetVipDetail(userId)
|
|
|
+ if rData == nil || len(*rData) == 0 {
|
|
|
+ return &entity.FuncResult{false, errors.New("获取信息失败"), nil}
|
|
|
+ }
|
|
|
+ var isread = false
|
|
|
+ if (*rData)["isread"] != nil {
|
|
|
+ isread = (*rData)["isread"].(bool)
|
|
|
+ }
|
|
|
+ o_vipjy := &map[string]interface{}{}
|
|
|
+ //判断版本是企业的还是个人的
|
|
|
+ infoCount := util.Mysql.CountBySql("select count(id) from entniche_wait_empower where ent_id=? and end_time>NOW() and product_type like '%VIP订阅%' ", ent_id)
|
|
|
+ if infoCount > 0 {
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "i_userid": entUserId,
|
|
|
+ "i_entid": ent_id,
|
|
|
+ "i_type": 1,
|
|
|
+ }
|
|
|
+ res, _ := util.MQFW.FindOne("entniche_rule", query)
|
|
|
+ if res != nil && len(*res) > 0 {
|
|
|
+ o_vipjy = qutil.ObjToMap((*res)["o_entniche"])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ o_vipjy = qutil.ObjToMap((*rData)["o_vipjy"])
|
|
|
+ }
|
|
|
+ vipStatus := qutil.IntAll((*rData)["i_vip_status"])
|
|
|
+ var renewList *[]map[string]interface{}
|
|
|
+ if vipStatus == 2 { //查询是否有未执行的续费订单
|
|
|
+ renewList, _ = util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":1}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
|
|
|
+ for i := 0; i < len(*renewList); i++ {
|
|
|
+ delete((*renewList)[i], "_id")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bigPower := jy.GetBigVipUserBaseMsg(this.Session(), *config.Middleground)
|
|
|
+ return &entity.FuncResult{true, nil, map[string]interface{}{
|
|
|
+ "isTrial": vipStatus == 1,
|
|
|
+ "area": (*o_vipjy)["o_area"],
|
|
|
+ "industry": (*o_vipjy)["a_buyerclass"],
|
|
|
+ "buyset": buyset,
|
|
|
+ "renewList": renewList,
|
|
|
+ "infotype": (*o_vipjy)["a_infotype"],
|
|
|
+ "items": (*o_vipjy)["a_items"],
|
|
|
+ "projectmatch": (*o_vipjy)["i_projectmatch"],
|
|
|
+ "ratemode": (*o_vipjy)["i_ratemode"],
|
|
|
+ "matchway": (*o_vipjy)["i_matchway"],
|
|
|
+ "startTime": (*rData)["l_vip_starttime"],
|
|
|
+ "endTime": (*rData)["l_vip_endtime"],
|
|
|
+ "otherbuyerclass": (*o_vipjy)["i_matchbuyerclass_other"],
|
|
|
+ "isread": isread,
|
|
|
+ "isvip": vip,
|
|
|
+ "isnew": NewUserByVIP(userId, this.Session()), //免费订阅区分新老用户
|
|
|
+ "isUpgrade": bigPower.IsUpgrade,
|
|
|
+ }}
|
|
|
+ }()
|
|
|
+ if r.Err != nil {
|
|
|
+ log.Printf("%s SalesCreateOrder GetSubBuyMsg err:%v\n", userId, r.Err.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(r.Format())
|
|
|
}
|
|
|
|
|
|
// GetSelectPrice 计算价格
|
|
|
// 复制 vipSubscribePay.go getSelectPrice
|
|
|
func (this *SalesCreateOrder) GetSelectPrice() {
|
|
|
- var userId string
|
|
|
- r := func() *entity.FuncResult {
|
|
|
- userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- if err != nil {
|
|
|
- return &entity.FuncResult{false, err, nil}
|
|
|
- }
|
|
|
- area := qutil.ObjToMap(this.GetString("area")) //地区
|
|
|
- timeRenew := this.GetString("time") //周期
|
|
|
- orderType, _ := this.GetInteger("orderType") //1 购买;2 续费;3 升级
|
|
|
- //卡卷信息的id
|
|
|
- lotteryId := this.GetString("lotteryId")
|
|
|
- useProduct, _ := this.GetInteger("useProduct")
|
|
|
- return CommonBilling(area, timeRenew, userId, lotteryId, orderType, useProduct, this.Session())
|
|
|
- }()
|
|
|
- if r.Err != nil {
|
|
|
- log.Printf("%s 价格计算 err:%v\n", userId, r.Err.Error())
|
|
|
- }
|
|
|
- this.ServeJson(r.Format())
|
|
|
+ var userId string
|
|
|
+ r := func() *entity.FuncResult {
|
|
|
+ userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, err, nil}
|
|
|
+ }
|
|
|
+ area := qutil.ObjToMap(this.GetString("area")) //地区
|
|
|
+ timeRenew := this.GetString("time") //周期
|
|
|
+ orderType, _ := this.GetInteger("orderType") //1 购买;2 续费;3 升级
|
|
|
+ //卡卷信息的id
|
|
|
+ lotteryId := this.GetString("lotteryId")
|
|
|
+ useProduct, _ := this.GetInteger("useProduct")
|
|
|
+ return CommonBilling(area, timeRenew, userId, lotteryId, orderType, useProduct, this.Session())
|
|
|
+ }()
|
|
|
+ if r.Err != nil {
|
|
|
+ log.Printf("%s 价格计算 err:%v\n", userId, r.Err.Error())
|
|
|
+ }
|
|
|
+ this.ServeJson(r.Format())
|
|
|
}
|
|
|
|
|
|
// GetValuationList 订单详情-计价清单
|
|
|
// 逻辑与 orderListDetails.go GetValuationList保持一致
|
|
|
func (this *SalesCreateOrder) GetValuationList() {
|
|
|
- var userId string
|
|
|
- r, err := func() (map[string]interface{}, error) {
|
|
|
- userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- order_code := this.GetString("order_code")
|
|
|
- upgradeSubtotail := []map[string]interface{}{}
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "order_code": order_code,
|
|
|
- "user_Id": userId,
|
|
|
- }
|
|
|
- filter := util.Mysql.FindOne(tableName_order, queryMap, "filter,order_money", "")
|
|
|
- if filter == nil {
|
|
|
- return nil, fmt.Errorf("未知订单")
|
|
|
- }
|
|
|
- res := qutil.ObjToMap((*filter)["filter"])
|
|
|
- upgradeSubtotail = qutil.ObjArrToMapArr((*res)["upgradeSubtotail"].([]interface{}))
|
|
|
- if len(upgradeSubtotail) > 0 {
|
|
|
- for _, v := range upgradeSubtotail {
|
|
|
- //续费 没有oldBuyset
|
|
|
- if v["oldBuyset"] == nil {
|
|
|
- v["oldBuyset"] = (*res)["newBuyset"]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return map[string]interface{}{
|
|
|
- "list": upgradeSubtotail,
|
|
|
- "order_money": (*filter)["order_money"],
|
|
|
- }, nil
|
|
|
- }()
|
|
|
- if err != nil {
|
|
|
- log.Printf("%s 价格计算 err:%v\n", userId, r)
|
|
|
- }
|
|
|
- this.ServeJson(r)
|
|
|
+ var userId string
|
|
|
+ r, err := func() (map[string]interface{}, error) {
|
|
|
+ userId, _, _, _, err := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ order_code := this.GetString("order_code")
|
|
|
+ upgradeSubtotail := []map[string]interface{}{}
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
+ "order_code": order_code,
|
|
|
+ "user_Id": userId,
|
|
|
+ }
|
|
|
+ filter := util.Mysql.FindOne(tableName_order, queryMap, "filter,order_money", "")
|
|
|
+ if filter == nil {
|
|
|
+ return nil, fmt.Errorf("未知订单")
|
|
|
+ }
|
|
|
+ res := qutil.ObjToMap((*filter)["filter"])
|
|
|
+ upgradeSubtotail = qutil.ObjArrToMapArr((*res)["upgradeSubtotail"].([]interface{}))
|
|
|
+ if len(upgradeSubtotail) > 0 {
|
|
|
+ for _, v := range upgradeSubtotail {
|
|
|
+ //续费 没有oldBuyset
|
|
|
+ if v["oldBuyset"] == nil {
|
|
|
+ v["oldBuyset"] = (*res)["newBuyset"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map[string]interface{}{
|
|
|
+ "list": upgradeSubtotail,
|
|
|
+ "order_money": (*filter)["order_money"],
|
|
|
+ }, nil
|
|
|
+ }()
|
|
|
+ if err != nil {
|
|
|
+ log.Printf("%s 价格计算 err:%v\n", userId, r)
|
|
|
+ }
|
|
|
+ this.ServeJson(r)
|
|
|
}
|
|
|
|
|
|
// GetPrice 销售代下单 支付价格
|
|
|
// 逻辑和vipSubscribeChange.go GetPrice 一致
|
|
|
func (this *SalesCreateOrder) GetPrice() {
|
|
|
- res := map[string]interface{}{
|
|
|
- "isActiving": true,
|
|
|
- "isWritten": 0,
|
|
|
- }
|
|
|
- j, _ := json.Marshal(&entity.SubVipPrice)
|
|
|
- _ = json.Unmarshal(j, &res)
|
|
|
- userId, _, _, _, _ := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
- if userId != "" {
|
|
|
- data, ok := util.MQFW.FindById("user", userId, nil)
|
|
|
- if ok && data != nil && *data != nil {
|
|
|
- //已录入信息 已激活大会员赠送
|
|
|
- if (*data)["i_member_give"] != nil {
|
|
|
- res["isWritten"] = qutil.IntAll((*data)["i_member_give"])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- this.ServeJson(res)
|
|
|
+ res := map[string]interface{}{
|
|
|
+ "isActiving": true,
|
|
|
+ "isWritten": 0,
|
|
|
+ }
|
|
|
+ j, _ := json.Marshal(&entity.SubVipPrice)
|
|
|
+ _ = json.Unmarshal(j, &res)
|
|
|
+ userId, _, _, _, _ := util.SellerTokenDecrypt(this.GetString("token"))
|
|
|
+ if userId != "" {
|
|
|
+ data, ok := util.MQFW.FindById("user", userId, nil)
|
|
|
+ if ok && data != nil && *data != nil {
|
|
|
+ //已录入信息 已激活大会员赠送
|
|
|
+ if (*data)["i_member_give"] != nil {
|
|
|
+ res["isWritten"] = qutil.IntAll((*data)["i_member_give"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.ServeJson(res)
|
|
|
}
|
|
|
|
|
|
// GetOrderPayAllMsg 代付订单详情页
|
|
|
func (o *SalesCreateOrder) GetOrderPayAllMsg() {
|
|
|
- order_code := o.GetString("orderCode")
|
|
|
- token := o.GetString("token")
|
|
|
+ order_code := o.GetString("orderCode")
|
|
|
+ token := o.GetString("token")
|
|
|
|
|
|
- data := map[string]interface{}{}
|
|
|
- var (
|
|
|
- r entity.FuncResult
|
|
|
- transactionId string
|
|
|
- )
|
|
|
- t := make(map[string]interface{})
|
|
|
- if order_code != "" && token != "" {
|
|
|
- fields := "order_code,user_id"
|
|
|
- info := map[string]interface{}{}
|
|
|
- userId, _, _, _, err := util.SellerTokenDecrypt(token)
|
|
|
- if err != nil {
|
|
|
- r.Err = errors.New("获取订单信息失败")
|
|
|
- goto env
|
|
|
- }
|
|
|
- info["order_code"] = order_code
|
|
|
- info["user_id"] = userId
|
|
|
- info["order_channel"] = "xdqd04"
|
|
|
- dataMap := util.Mysql.FindOne(tableName_order, info, fields, "")
|
|
|
- if dataMap != nil && len(*dataMap) > 0 {
|
|
|
- data = *dataMap
|
|
|
- //查询userid
|
|
|
- //userId := qutil.InterfaceToStr(data["user_id"])
|
|
|
- //if userId == "" {
|
|
|
- // r.Err = errors.New("获取订单信息失败")
|
|
|
- // goto env
|
|
|
- //}
|
|
|
- field := "id,order_code,del_status,prepay_time,create_time,pay_time,pay_way,user_phone,original_price,order_money,pay_money,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company,vip_starttime,vip_endtime,vip_type,discount_price,d_relation_id,billingMode,return_status,is_backstage_order,vip_starttime,vip_endtime"
|
|
|
- data, t, transactionId = CommonDetail(4, field, userId, order_code, o.Session())
|
|
|
- //如果手机号号为空查找通过userid查找手机号
|
|
|
- //if qutil.InterfaceToStr(data["user_phone"]) == "" {
|
|
|
- dataPhone, _ := util.MQFW.FindById("user", userId, "s_phone,s_m_phone")
|
|
|
- sPhone := qutil.InterfaceToStr((*dataPhone)["s_phone"])
|
|
|
- data["user_phone"] = qutil.If(sPhone == "", qutil.InterfaceToStr((*dataPhone)["s_m_phone"]), sPhone)
|
|
|
- dataMapSta := make(map[string]interface{})
|
|
|
- if qutil.IntAll(data["del_status"]) == 1 || qutil.IntAll(data["order_status"]) == -1 {
|
|
|
- dataMapSta["del_status"] = qutil.IntAll(data["del_status"])
|
|
|
- dataMapSta["order_status"] = qutil.IntAll(data["order_status"])
|
|
|
- } else {
|
|
|
- dataMapSta = data
|
|
|
- }
|
|
|
- //}
|
|
|
- r.Success = true
|
|
|
- r.Data = map[string]interface{}{
|
|
|
- "order": dataMapSta,
|
|
|
- "time": t,
|
|
|
- "transaction_id": transactionId,
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ data := map[string]interface{}{}
|
|
|
+ var (
|
|
|
+ r entity.FuncResult
|
|
|
+ transactionId string
|
|
|
+ )
|
|
|
+ t := make(map[string]interface{})
|
|
|
+ if order_code != "" && token != "" {
|
|
|
+ fields := "order_code,user_id"
|
|
|
+ info := map[string]interface{}{}
|
|
|
+ userId, _, _, _, err := util.SellerTokenDecrypt(token)
|
|
|
+ if err != nil {
|
|
|
+ r.Err = errors.New("获取订单信息失败")
|
|
|
+ goto env
|
|
|
+ }
|
|
|
+ info["order_code"] = order_code
|
|
|
+ info["user_id"] = userId
|
|
|
+ info["order_channel"] = "xdqd04"
|
|
|
+ dataMap := util.Mysql.FindOne(tableName_order, info, fields, "")
|
|
|
+ if dataMap != nil && len(*dataMap) > 0 {
|
|
|
+ data = *dataMap
|
|
|
+ //查询userid
|
|
|
+ //userId := qutil.InterfaceToStr(data["user_id"])
|
|
|
+ //if userId == "" {
|
|
|
+ // r.Err = errors.New("获取订单信息失败")
|
|
|
+ // goto env
|
|
|
+ //}
|
|
|
+ field := "id,order_code,del_status,prepay_time,create_time,pay_time,pay_way,user_phone,original_price,order_money,pay_money,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company,vip_starttime,vip_endtime,vip_type,discount_price,d_relation_id,billingMode,return_status,is_backstage_order,vip_starttime,vip_endtime"
|
|
|
+ data, t, transactionId = CommonDetail(4, field, userId, order_code, o.Session())
|
|
|
+ //如果手机号号为空查找通过userid查找手机号
|
|
|
+ //if qutil.InterfaceToStr(data["user_phone"]) == "" {
|
|
|
+ dataPhone, _ := util.MQFW.FindById("user", userId, "s_phone,s_m_phone")
|
|
|
+ sPhone := qutil.InterfaceToStr((*dataPhone)["s_phone"])
|
|
|
+ data["user_phone"] = qutil.If(sPhone == "", qutil.InterfaceToStr((*dataPhone)["s_m_phone"]), sPhone)
|
|
|
+ dataMapSta := make(map[string]interface{})
|
|
|
+ if qutil.IntAll(data["del_status"]) == 1 || qutil.IntAll(data["order_status"]) == -1 {
|
|
|
+ dataMapSta["del_status"] = qutil.IntAll(data["del_status"])
|
|
|
+ dataMapSta["order_status"] = qutil.IntAll(data["order_status"])
|
|
|
+ } else {
|
|
|
+ dataMapSta = data
|
|
|
+ }
|
|
|
+ //}
|
|
|
+ r.Success = true
|
|
|
+ r.Data = map[string]interface{}{
|
|
|
+ "order": dataMapSta,
|
|
|
+ "time": t,
|
|
|
+ "transaction_id": transactionId,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
env:
|
|
|
- o.ServeJson(r.Format())
|
|
|
+ o.ServeJson(r.Format())
|
|
|
}
|