瀏覽代碼

no message

xingzai 1 年之前
父節點
當前提交
0ed6c0e272
共有 8 個文件被更改,包括 146 次插入28 次删除
  1. 12 1
      controllers/activity.go
  2. 11 5
      controllers/order.go
  3. 16 10
      models/activity.go
  4. 2 0
      models/db.go
  5. 5 4
      models/order/goods.go
  6. 64 7
      models/order/order.go
  7. 35 0
      services/order.go
  8. 1 1
      services/user_permission.go

+ 12 - 1
controllers/activity.go

@@ -562,8 +562,19 @@ func (this *ActivityCoAntroller) Detail() {
 			resp.HasPermission = hasPermission
 			resp.SellerName = sellerName
 			resp.SellerMobile = sellerMobile
-		}
 
+			if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
+				resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
+			} else {
+				resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
+			}
+			for _, v := range resp.GoodsList {
+				resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
+			}
+			resp.IsShowWxPay = utils.IS_SHOW_WX_PAY                                                      //是否展示微信支付按钮
+			resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId)         //获取客户是否有过历史申请记录
+			resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
+		}
 	}
 
 	collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)

+ 11 - 5
controllers/order.go

@@ -77,16 +77,16 @@ func (this *OrderController) Add() {
 	item := new(order.CygxOrder)
 	item.OrderCode = utils.GetOrdernum()
 	item.GoodsName = goodsDetail.GoodsName
-	item.GoodsID = goodsId
-	item.GoodsMoney = goodsDetail.CurrentPrice
+	item.GoodsId = goodsId
+	item.GoodsMoney = goodsDetail.Price
 	item.OrderMoney = goodsDetail.CurrentPrice
-	item.SourceID = sourceId
+	item.SourceId = sourceId
 	item.Source = source
 	item.SourceTitle = title
-	item.UserID = user.UserId
+	item.UserId = user.UserId
 	item.Mobile = user.Mobile
 	item.Email = user.Email
-	item.CompanyID = user.CompanyId
+	item.CompanyId = user.CompanyId
 	item.CompanyName = user.CompanyName
 	item.RealName = user.RealName
 	item.SellerName = services.GetSellerName(user) // 销售姓名
@@ -94,6 +94,12 @@ func (this *OrderController) Add() {
 	item.ModifyTime = time.Now()
 	item.RegisterPlatform = utils.REGISTER_PLATFORM
 
+	err = order.AddCygxOrder(item)
+	if err != nil {
+		br.Msg = "创建订单信息失败"
+		br.ErrMsg = "创建订单信息失败,Err:" + err.Error()
+		return
+	}
 	fmt.Println(item)
 	fmt.Println(title)
 	fmt.Println(uid)

+ 16 - 10
models/activity.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mfyx/models/order"
 	"strings"
 	"time"
 )
@@ -240,16 +241,21 @@ type ListArticleActivity struct {
 }
 
 type CygxActivityResp struct {
-	HaqveJurisdiction bool   `description:"是否有权限"`
-	OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
-	HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
-	PopupMsg          string `description:"权限弹窗信息"`
-	MsgType           string `description:"Type : 类型 , Industry : 行业"`
-	SellerMobile      string `description:"销售电话"`
-	SellerName        string `description:"销售姓名"`
-	IsResearch        bool   `description:"是否属于研选"`
-	IsResearchSpecial bool   `description:"是否属于特殊的研选"`
-	Detail            *ActivityDetail
+	HaqveJurisdiction  bool   `description:"是否有权限"`
+	OperationMode      string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
+	HasPermission      int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
+	PopupMsg           string `description:"权限弹窗信息"`
+	MsgType            string `description:"Type : 类型 , Industry : 行业"`
+	SellerMobile       string `description:"销售电话"`
+	SellerName         string `description:"销售姓名"`
+	IsResearch         bool   `description:"是否属于研选"`
+	IsResearchSpecial  bool   `description:"是否属于特殊的研选"`
+	Detail             *ActivityDetail
+	PopupPriceMsg      string                 `description:"价格弹窗信息"`
+	IsShowWxPay        bool                   `description:"是否展示微信支付"`
+	IsCompanyApply     bool                   `description:"机构是否申请过试用"`
+	IsNeedBusinessCard bool                   `description:"是否需要上传名片"`
+	GoodsList          []*order.CygxGoodsResp `description:"商品信息"`
 }
 
 // 通过纪要ID获取活动详情

+ 2 - 0
models/db.go

@@ -192,5 +192,7 @@ func init() {
 func initOrder() {
 	orm.RegisterModel(
 		new(order.CygxUserBusinessCard), //用户上传名片
+		new(order.CygxOrder),            //订单表
+		new(order.CygxOrderAction),      //订单操表
 	)
 }

+ 5 - 4
models/order/goods.go

@@ -13,10 +13,11 @@ type CygxGoods struct {
 }
 
 type CygxGoodsResp struct {
-	GoodsId      int    `description:"商品ID"`
-	GoodsName    string `description:"商品名称"`
-	Price        string `description:"商品原价格"`
-	CurrentPrice string `description:"商品现价(当时出售的价格)"`
+	GoodsId       int    `description:"商品ID"`
+	GoodsName     string `description:"商品名称"`
+	Price         string `description:"商品原价格"`
+	CurrentPrice  string `description:"商品现价(当时出售的价格)"`
+	PopupPriceMsg string `description:"价格弹窗信息"`
 }
 
 func GetCygxGoodsList(condition string, pars []interface{}) (item []*CygxGoodsResp, err error) {

+ 64 - 7
models/order/order.go

@@ -1,6 +1,7 @@
 package order
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
@@ -12,12 +13,12 @@ type CygxOrderAddReq struct {
 }
 
 type CygxOrder struct {
-	OrderID          int       `orm:"column(order_id);pk";comment:"订单id"`
+	OrderId          int       `orm:"column(order_id);pk";comment:"订单id"`
 	OrderCode        string    `comment:"订单编号"`
 	OutTradeCode     string    `comment:"外部交易号"`
 	PaymentType      int       `comment:"支付类型。取值范围:1微信支付,2支付宝支付。"`
 	GoodsName        string    `comment:"商品名称"`
-	GoodsID          int       `comment:"商品ID"`
+	GoodsId          int       `comment:"商品ID"`
 	BuyerInvoice     string    `comment:"买家发票信息"`
 	GoodsMoney       float64   `comment:"商品总价"`
 	OrderMoney       float64   `comment:"订单总价"`
@@ -27,13 +28,13 @@ type CygxOrder struct {
 	RefundMoney      float64   `comment:"订单退款金额"`
 	OrderStatus      int       `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:已退款"`
 	PayTime          time.Time `comment:"订单付款时间"`
-	SourceID         int       `comment:"来源ID"`
+	SourceId         int       `comment:"来源ID"`
 	Source           string    `comment:"来源\n报告 :article\n活动 :activity"`
 	SourceTitle      string    `comment:"来源名称,活动或者报告标题"`
-	UserID           int       `comment:"用户ID"`
+	UserId           int       `comment:"用户ID"`
 	Mobile           string    `comment:"手机号"`
 	Email            string    `comment:"邮箱"`
-	CompanyID        int       `comment:"公司ID"`
+	CompanyId        int       `comment:"公司ID"`
 	CompanyName      string    `comment:"公司名称"`
 	RealName         string    `comment:"用户实际名称"`
 	SellerName       string    `comment:"所属销售"`
@@ -42,9 +43,65 @@ type CygxOrder struct {
 	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`
 }
 
+type CygxOrderAction struct {
+	ActionId         int64     `orm:"column(action_id);pk"` // 动作id
+	Action           string    // 动作内容
+	OrderStatus      int       // 订单状态,0:已取消、1:待支付、2:已支付、3:已退款
+	OrderStatusText  string    // 订单状态名称
+	OrderCode        string    // 订单编号
+	UserId           int       // 用户ID
+	Mobile           string    // 手机号
+	Email            string    // 邮箱
+	CompanyId        int       // 公司ID
+	CompanyName      string    // 公司名称
+	RealName         string    // 用户实际名称
+	SellerName       string    // 所属销售
+	CreateTime       time.Time // 创建时间
+	ModifyTime       time.Time // 修改时间
+	RegisterPlatform int       // 来源 1小程序,2:网页
+	AdminId          int       // 管理员ID
+	AdminName        string    // 管理员姓名
+}
+
 // 添加
 func AddCygxOrder(item *CygxOrder) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Insert(item)
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	itemOrderAction := new(CygxOrderAction)
+
+	itemOrderAction.Action = "创建订单"
+	itemOrderAction.OrderStatus = 1
+	itemOrderAction.OrderStatusText = "待支付"
+	itemOrderAction.OrderCode = item.OrderCode
+	itemOrderAction.UserId = item.UserId
+	itemOrderAction.Mobile = item.Mobile
+	itemOrderAction.Email = item.Email
+	itemOrderAction.CompanyId = item.CompanyId
+	itemOrderAction.CompanyName = item.CompanyName
+	itemOrderAction.RealName = item.RealName
+	itemOrderAction.SellerName = item.SellerName
+	itemOrderAction.CreateTime = time.Now()
+	itemOrderAction.ModifyTime = time.Now()
+	itemOrderAction.RegisterPlatform = item.RegisterPlatform
+
+	_, err = o.Insert(item) //写入订单信息
+	if err != nil {
+		return
+	}
+
+	_, err = o.Insert(itemOrderAction) // 写入订单操作信息
+	if err != nil {
+		return
+	}
 	return
 }

+ 35 - 0
services/order.go

@@ -3,6 +3,7 @@ package services
 import (
 	"errors"
 	"fmt"
+	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/models/order"
 	"hongze/hongze_mfyx/utils"
 )
@@ -27,3 +28,37 @@ func GetUserGoodsCardList() (goodsListResp []*order.CygxGoodsResp) {
 	goodsListResp = goodsList
 	return
 }
+
+// 获取单场活动关联的商品配置信息
+func GetGoodsInfoByActivity(item *models.ActivityDetail) (goodsListResp []*order.CygxGoodsResp) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("判断用户是否开通了个人研选权限失败 GetCygxGoodsList, err:", err.Error()), 2)
+		}
+	}()
+	//var goodsList []*order.CygxGoodsResp
+	//var e error
+	var condition string
+	var pars []interface{}
+
+	if item.ActivityTypeId == 1 && item.IsLimitPeople == 1 { //专家电话会。限制人数,
+		condition = ` AND  goods_id IN  (3) `
+	} else if (item.ActivityTypeId == 5 || item.ActivityTypeId == 8) && item.IsResearchPoints { //买方线下交流/专家线下沙龙。参会人扣点,
+		condition = ` AND  goods_id IN  (4) `
+	} else if (item.ActivityTypeId == 5 || item.ActivityTypeId == 8) && !item.IsResearchPoints { //买方线下交流/专家线下沙龙。参会人扣点,
+		condition = ` AND  goods_id IN  (5) `
+	} else if item.ActivityTypeId == 3 && item.IsResearchPoints { //非易董。公司调研电话会参会人扣点
+		condition = ` AND  goods_id IN  (6) `
+	} else if item.ActivityTypeId == 3 && !item.IsResearchPoints { //非易董。公司调研电话会参会人扣点
+		condition = ` AND  goods_id IN  (7) `
+	}
+	goodsList, e := order.GetCygxGoodsList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxGoodsList, Err: " + e.Error())
+		return
+	}
+	goodsListResp = goodsList
+	return
+}

+ 1 - 1
services/user_permission.go

@@ -223,7 +223,7 @@ func GetSellerName(user *models.WxUserItem) (sellerName string) {
 		err = errors.New("GetRaiSellerByCompanyId, Err: " + e.Error())
 		return
 	}
-	sellerName = sealldetail.RoleName
+	sellerName = sealldetail.RealName
 	return
 
 }