package services import ( "encoding/json" "errors" "fmt" "hongze/hongze_mfyx/models" "hongze/hongze_mfyx/models/order" "hongze/hongze_mfyx/utils" "time" ) // 获取日卡、月卡商品配置信息 func GetUserGoodsCardList() (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 condition string var pars []interface{} condition = ` AND goods_id IN (1,2) ` goodsList, e := order.GetCygxGoodsList(condition, pars) if e != nil { err = errors.New("GetCygxGoodsList, Err: " + e.Error()) return } 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("获取单场活动关联的商品配置信息 GetGoodsInfoByActivity, err:", err.Error()), 2) } }() if item.IsResearchPoints { //获取活动对用户要扣的点 userPointsNum, e := models.GetCygxActivityPointsSetUserNum(item.ActivityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } if userPointsNum > 0 { item.IsResearchPointsByUser = true } } 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) ` } else if item.ActivityTypeId == 1 && item.IsResearchPoints { //专家电话会,不限制人数,研选扣点(1299元) condition = ` AND goods_id IN (8) ` } goodsList, e := order.GetCygxGoodsList(condition, pars) if e != nil { err = errors.New("GetCygxGoodsList, Err: " + e.Error()) return } //如果活动有自定义的价格就优先按照自定义的价格来 if item.ActivityPrice > 0 { for k, _ := range goodsList { goodsList[k].CurrentPrice = fmt.Sprint(item.ActivityPrice) goodsList[k].Price = fmt.Sprint(item.ActivityOriginalPrice) goodsList[k].PopupPriceMsg = fmt.Sprint("¥", item.ActivityOriginalPrice) } } goodsListResp = goodsList return } // 获取单场活动音视频关联的商品配置信息 func GetGoodsInfoByActivityVivo(item *models.ActivityDetail) (goodsListResp []*order.CygxGoodsResp) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2) } }() activityId := item.ActivityId total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } if total == 0 { goodsListResp = make([]*order.CygxGoodsResp, 0) return } vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error()) return } var condition string var pars []interface{} condition = ` AND goods_id IN (9) ` goodsList, e := order.GetCygxGoodsList(condition, pars) if e != nil { err = errors.New("GetCygxGoodsList, Err: " + e.Error()) return } for k, _ := range goodsList { goodsList[k].CurrentPrice = fmt.Sprint(vivoPointsSetDetail.GoodsMoney) goodsList[k].Price = fmt.Sprint(vivoPointsSetDetail.GoodsMoney) goodsList[k].PopupPriceMsg = fmt.Sprint("¥", vivoPointsSetDetail.GoodsMoney) } goodsListResp = goodsList return } func GetActivityVivoPoints(item *models.ActivityDetail, wxUser *models.WxUserItem, havePower bool) (vivoPointsResp models.VivoPointsResp) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2) } }() activityId := item.ActivityId total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } if total == 0 { //如果没有设置就直接播放 vivoPointsResp.HavePoint = true return } totalMySuccess, e := models.GetActivitySignupCount(wxUser.UserId, activityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } totalPayVivo, e := order.GetCygxOrderVirtualAssetdCountByVivo(activityId, wxUser.UserId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } totalPointRecord, e := models.GetCygxActivityVivoPointRecordCount(activityId, wxUser.UserId) if e != nil { err = errors.New("GetCygxActivityVivoPointRecordCount, Err: " + e.Error()) return } //如果报了名,或者付费了,或者单独扣点了;就直接观看 if totalMySuccess > 0 || totalPayVivo > 0 || totalPointRecord > 0 { vivoPointsResp.HavePoint = true } vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error()) return } vivoPointsResp.ActivityPoints = fmt.Sprint(vivoPointsSetDetail.PointsNum) // 获取用户所在公司剩余的点 companyPointsNum, e := models.GetCompanyPoints(wxUser.CompanyId) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCompanyPoints, Err: " + e.Error()) return } vivoPointsResp.CompanyPoints = fmt.Sprint(companyPointsNum) havePowerYx, e := GetArticleDetailUserPower(wxUser) if e != nil { err = errors.New("GetArticleDetailUserPower, Err: " + e.Error()) return } if havePower || havePowerYx { if vivoPointsSetDetail.PointsNum == 0 { //有权限情况下,点数为零的时候直接播放 vivoPointsResp.HavePoint = true } if companyPointsNum > 0 { if companyPointsNum >= vivoPointsSetDetail.PointsNum { vivoPointsResp.PointPermission = 1 } else { vivoPointsResp.PointPermission = 2 } } else { //客户剩余点数为0的情况下,直接支付 vivoPointsResp.PointPermission = 3 } } else { if vivoPointsSetDetail.GoodsMoney > 0 { vivoPointsResp.PointPermission = 3 } } return } // 获取用户十分钟之内是否有相同的订单信息 func GetHaverEquallyOrderByUser10Min(userId, goodsId int) (orderCode string) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的订单信息失败 GetHaverEquallyOrderByUser10Min, err:", err.Error()), 2) } }() var condition string var pars []interface{} endTime := time.Now().Add(-10 * time.Minute) condition = ` AND order_status = 1 AND user_id = ? AND goods_id = ? AND create_time > ? AND register_platform = ? ORDER BY order_id DESC ` pars = append(pars, userId, goodsId, endTime, utils.REGISTER_PLATFORM) orderList, e := order.GetCygxOrderList(condition, pars, 0, 1) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxOrderList, Err: " + e.Error()) return } if len(orderList) == 0 { return } else { for _, v := range orderList { orderCode = v.OrderCode } } return } // 获取用户十分钟之内是否有相同的订单信息 func GetHaverEquallyOrderByUser10MinByActivty(userId, sourceId int) (orderCode string, seconds int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的订单信息失败 GetHaverEquallyOrderByUser10Min, err:", err.Error()), 2) } }() var condition string var pars []interface{} endTime := time.Now().Add(-10 * time.Minute) condition = ` AND order_status = 1 AND source = 'activity' AND user_id = ? AND source_id = ? AND create_time > ? AND register_platform = ? ORDER BY order_id DESC ` pars = append(pars, userId, sourceId, endTime, utils.REGISTER_PLATFORM) orderList, e := order.GetCygxOrderList(condition, pars, 0, 1) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxOrderList, Err: " + e.Error()) return } if len(orderList) == 0 { return } else { for _, v := range orderList { orderCode = v.OrderCode duration := time.Now().Sub(v.CreateTime) // 将时间差转换为秒数 seconds = 600 - int(duration.Seconds()) } } return } // 处理支付订单回调 func HandleOrderByWechatPay(itemCallback *WechatPayCallback) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("处理订单回调信息失败 HandleOrderByWechatPay, err:", err.Error()), 2) } }() outTradeNo := itemCallback.OutTradeNo orderDetail, e := order.GetCygxOrderDetailByOutTradeNo(outTradeNo) if e != nil { err = errors.New("GetCygxOrderDetailByOrderCode, Err: " + e.Error()) return } //修改过状态的不再二次处理 if orderDetail.OrderStatus == 2 { return } tradeState, _, _ := GetQueryOrderByOutTradeNo(outTradeNo) //主动查询微信支付信息 if tradeState != "SUCCESS" { return } go AddCygxOrderPayment(itemCallback) // 记录支付交易信息 if itemCallback.TradeState != "SUCCESS" { // 回调显示支付不成功,模版消息推送 if e != nil { err = errors.New("支付失败, OutTradeNo: " + outTradeNo) return } } itemOrder := new(order.CygxOrder) itemOrder.OrderCode = orderDetail.OrderCode itemOrder.PayTime = itemCallback.SuccessTime itemOrder.PayMoney = float64(float64(itemCallback.Amount.PayerTotal) / 100) // 金额分转换处理 itemOrder.OrderStatus = 2 itemOrder.OutTradeCode = itemCallback.TransactionID itemOrder.TradeType = itemCallback.TradeType //文章处理逻辑 OrderType int `comment:"订单类型,1:畅读卡订单,2:单场付费订单"` if orderDetail.OrderType == 1 { itemUserCard := new(order.CygxOrderUserCard) itemUserCard.OrderCode = orderDetail.OrderCode itemUserCard.UserId = orderDetail.UserId itemUserCard.Mobile = orderDetail.Mobile itemUserCard.Email = orderDetail.Email itemUserCard.CompanyId = orderDetail.CompanyId itemUserCard.CompanyName = orderDetail.CompanyName itemUserCard.RealName = orderDetail.RealName itemUserCard.SellerName = orderDetail.SellerName itemUserCard.CreateTime = time.Now() itemUserCard.ModifyTime = time.Now() itemUserCard.RegisterPlatform = orderDetail.RegisterPlatform if orderDetail.GoodsId == 1 { itemUserCard.StartDate = itemOrder.PayTime itemUserCard.EndDate = itemOrder.PayTime.AddDate(0, 0, 1) itemUserCard.CardType = "日卡" } else { now := time.Now() itemUserCard.StartDate = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) itemUserCard.EndDate = itemUserCard.StartDate.AddDate(0, 1, 0) itemUserCard.CardType = "月卡" } e = order.AddCygxOrderUserCard(itemUserCard, itemOrder) if e != nil { err = errors.New("AddCygxOrderUserCard, Err: " + e.Error()) return } } else if orderDetail.OrderType == 2 || orderDetail.OrderType == 3 { //如果是活动,把单场付费信息的活动写入 用户虚拟资产表 itemOrderVirtualAsset := new(order.CygxOrderVirtualAsset) itemOrderVirtualAsset.OrderCode = orderDetail.OrderCode itemOrderVirtualAsset.UserId = orderDetail.UserId itemOrderVirtualAsset.Mobile = orderDetail.Mobile itemOrderVirtualAsset.Email = orderDetail.Email itemOrderVirtualAsset.CompanyId = orderDetail.CompanyId itemOrderVirtualAsset.CompanyName = orderDetail.CompanyName itemOrderVirtualAsset.RealName = orderDetail.RealName itemOrderVirtualAsset.SellerName = orderDetail.SellerName itemOrderVirtualAsset.Source = orderDetail.Source itemOrderVirtualAsset.SourceId = orderDetail.SourceId itemOrderVirtualAsset.CreateTime = time.Now() itemOrderVirtualAsset.ModifyTime = time.Now() e = order.AddCygxOrderVirtualAsset(itemOrderVirtualAsset, itemOrder) if e != nil { err = errors.New("AddCygxOrderVirtualAsset, Err: " + e.Error()) return } } if orderDetail.Source == utils.CYGX_OBJ_ACTIVITY { go AddActivitySignupByWechatPay(orderDetail.SourceId, orderDetail.UserId) //微信付款成功自动添加报名 } go CancelOtherOrder(orderDetail) //付款成功之后自动取消其他相同的订单 go SendWxCategoryMsgWxPay(orderDetail) //有人支付成功时,模板消息发送给王芳、沈涛和推荐人(没有推荐人时给销售) return } func AddCygxOrderPayment(itemCallback *WechatPayCallback) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("处理订单回调信息失败 HandleOrderHandle, err:", err.Error()), 2) } }() itemPay := new(order.CygxOrderPayment) itemPay.OrderCode = itemCallback.OutTradeNo itemPay.OutTradeCode = itemCallback.TransactionID itemPay.PayBody = itemCallback.TradeStateDesc jsonData, _ := json.Marshal(itemCallback) itemPay.PayDetail = string(jsonData) itemPay.PayMoney = float64(float64(itemCallback.Amount.PayerTotal) / 100) // 金额分转换处理 itemPay.PayStatus = itemCallback.TradeState itemPay.CreateTime = time.Now() itemPay.PaymentType = 1 e := order.AddCygxOrderPayment(itemPay) if e != nil { err = errors.New("AddCygxOrderPayment, Err: " + e.Error()) return } return } // 获取用户十分钟之内是否有相同的订单信息 func GetHaverEquallyOrderByUser10MinByActivtyVivo(userId, sourceId int) (orderCode string, seconds int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的订单信息失败 GetHaverEquallyOrderByUser10MinByActivty, err:", err.Error()), 2) } }() var condition string var pars []interface{} endTime := time.Now().Add(-10 * time.Minute) condition = ` AND order_status = 1 AND source IN ( 'activityvideo', 'activityvoice') AND user_id = ? AND source_id = ? AND create_time > ? AND register_platform = ? ORDER BY order_id DESC ` pars = append(pars, userId, sourceId, endTime, utils.REGISTER_PLATFORM) orderList, e := order.GetCygxOrderList(condition, pars, 0, 1) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxOrderList, Err: " + e.Error()) return } if len(orderList) == 0 { return } else { for _, v := range orderList { orderCode = v.OrderCode duration := time.Now().Sub(v.CreateTime) // 将时间差转换为秒数 seconds = 600 - int(duration.Seconds()) } } return } // 处理退款订单回调 func HandleOrderRefundByWechatPay(itemCallback *WechatPayCallback) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("处理退款订单回调信息失败 HandleOrderRefundByWechatPay, err:", err.Error()), 2) } }() outTradeNo := itemCallback.OutTradeNo orderDetail, e := order.GetCygxOrderDetailByOutTradeNo(outTradeNo) if e != nil { err = errors.New("GetCygxOrderDetailByOrderCode, Err: " + e.Error()) return } //go AddCygxOrderPayment(itemCallback) // 记录支付交易信息 //修改过状态的不再二次处理 if orderDetail.OrderStatus == 3 { return } itemOrder := new(order.CygxOrder) itemOrder.OrderCode = orderDetail.OrderCode itemOrder.RefundTime = itemCallback.SuccessTime itemOrder.RefundMoney = float64(float64(itemCallback.Amount.PayerTotal) / 100) // 金额分转换处理 itemOrder.OrderStatus = 3 //文章处理逻辑 OrderType int `comment:"订单类型,1:畅读卡订单,2:单场付费订单"` if orderDetail.OrderType == 1 { itemUserCard := new(order.CygxOrderUserCard) itemUserCard.OrderCode = orderDetail.OrderCode itemUserCard.UserId = orderDetail.UserId itemUserCard.Mobile = orderDetail.Mobile itemUserCard.Email = orderDetail.Email itemUserCard.CompanyId = orderDetail.CompanyId itemUserCard.CompanyName = orderDetail.CompanyName itemUserCard.RealName = orderDetail.RealName itemUserCard.SellerName = orderDetail.SellerName itemUserCard.CreateTime = time.Now() itemUserCard.ModifyTime = time.Now() itemUserCard.RegisterPlatform = orderDetail.RegisterPlatform if orderDetail.GoodsId == 1 { itemUserCard.CardType = "日卡" } else { itemUserCard.CardType = "月卡" } e = order.RemoveCygxOrderUserCard(itemUserCard, itemOrder) // 移除用户 if e != nil { err = errors.New("RemoveCygxOrderUserCard, Err: " + e.Error()) return } } else if orderDetail.OrderType == 2 || orderDetail.OrderType == 3 { //如果是活动,把单场付费信息的活动写入 用户虚拟资产表 itemOrderVirtualAsset := new(order.CygxOrderVirtualAsset) itemOrderVirtualAsset.OrderCode = orderDetail.OrderCode itemOrderVirtualAsset.UserId = orderDetail.UserId itemOrderVirtualAsset.Mobile = orderDetail.Mobile itemOrderVirtualAsset.Email = orderDetail.Email itemOrderVirtualAsset.CompanyId = orderDetail.CompanyId itemOrderVirtualAsset.CompanyName = orderDetail.CompanyName itemOrderVirtualAsset.RealName = orderDetail.RealName itemOrderVirtualAsset.SellerName = orderDetail.SellerName itemOrderVirtualAsset.Source = orderDetail.Source itemOrderVirtualAsset.SourceId = orderDetail.SourceId itemOrderVirtualAsset.CreateTime = time.Now() itemOrderVirtualAsset.ModifyTime = time.Now() e = order.RemoveCygxOrderVirtualAsset(itemOrderVirtualAsset, itemOrder) if e != nil { err = errors.New("AddCygxOrderVirtualAsset, Err: " + e.Error()) return } } //if orderDetail.Source == utils.CYGX_OBJ_ACTIVITY { // go CancelActivitySignupByWechatPay(orderDetail.SourceId, orderDetail.UserId) //微信退款成功自动取消报名 //} return } // 微信付款成功自动添加报名 func AddActivitySignupByWechatPay(activityId, userId int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("微信付款成功自动添加报名失败 AddActivitySignupByWechatPay, err:", err.Error(), "activityId:", activityId, "userId:", userId), 2) } }() activityInfo, e := models.GetAddActivityInfoById(activityId) if e != nil { err = errors.New("GetAddActivityInfoById, Err: " + e.Error()) return } var userPointsNum float64 if activityInfo.IsResearchPoints { //获取活动对用户要扣的点 userPointsNum, e = models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } } //专家线下沙龙与买方线下交流、扣点的公司调研电话会自动报名 if activityInfo.ActivityTypeId != 5 && activityInfo.ActivityTypeId != 8 && userPointsNum == 0 { return } user, e := models.GetWxUserItemByUserId(userId) if e != nil { err = errors.New("GetWxUserItemByUserId, Err: " + e.Error()) return } var sellerName string sellerName, e = models.GetCompanySellerName(user.CompanyId) if e != nil { err = errors.New("GetCompanySellerName, Err: " + e.Error()) return } item := new(models.CygxActivitySignup) totalMySuccess, e := models.GetActivitySignupCount(userId, activityId) if e != nil { err = errors.New("AddActivitySignup, Err: " + e.Error()) return } if totalMySuccess > 0 { //已报名这个活动 return } item.UserId = userId item.RealName = user.RealName item.SellerName = sellerName item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.SignupType = 3 item.FailType = 0 item.DoFailType = 0 item.OutboundMobile = user.Mobile if user.OutboundMobile != "" { item.OutboundMobile = user.OutboundMobile if user.OutboundCountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.OutboundCountryCode } } else { item.OutboundMobile = user.Mobile if user.CountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.CountryCode } } _, e = models.AddActivitySignup(item) if e != nil { err = errors.New("AddActivitySignup, Err: " + e.Error()) return } fmt.Println("报名成功") go ActivityUserRemind(user, activityInfo, 4) return } // 微信退款成功自动取消报名 func CancelActivitySignupByWechatPay(activityId, userId int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("微信退款成功自动取消报名失败 CancelActivitySignupByWechatPay, err:", err.Error(), "activityId:", activityId, "userId:", userId), 2) } }() activityInfo, e := models.GetAddActivityInfoById(activityId) if e != nil { err = errors.New("GetAddActivityInfoById, Err: " + e.Error()) return } user, e := models.GetWxUserItemByUserId(userId) if e != nil { err = errors.New("GetWxUserItemByUserId, Err: " + e.Error()) return } item := new(models.CygxActivitySignup) item.UserId = userId item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName resp := new(models.SignupStatus) resp.ActivityId = activityId _, e = models.CancelActivitySignup(item) if e != nil { err = errors.New("CancelActivitySignup, Err: " + e.Error()) return } // 如果是买方研选下的专家沙龙,同时推给内容组四人 if activityInfo.ActivityTypeId == 5 { go SendActivitieCancelSignTemplateMsg(user, activityInfo) } go SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息 return } // 获取支付之后活动相关的弹窗信息 func GetActivityWechatPayMsg(activityId int) (isPublicActivitie, isSignUp bool) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("获取支付之后活动相关的弹窗信息失败 GetActivityWechatPayMsg, err:", err.Error(), "activityId:", activityId), 2) } }() activityInfo, e := models.GetAddActivityInfoById(activityId) if e != nil { err = errors.New("GetAddActivityInfoById, Err: " + e.Error()) return } if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)是公开活动 isPublicActivitie = true //日卡月卡商品信息 } var userPointsNum float64 if activityInfo.IsResearchPoints { //获取活动对用户要扣的点 userPointsNum, e = models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId) if e != nil { err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error()) return } } //专家线下沙龙与买方线下交流、扣点的公司调研电话会自动报名 if activityInfo.ActivityTypeId != 5 && activityInfo.ActivityTypeId != 8 && userPointsNum == 0 { return } else { isSignUp = true } return } // 付款成功之后自动取消其他相同的订单 func CancelOtherOrder(item *order.CygxOrder) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("付款成功之后自动取消其他相同的订单失败 CancelOtherOrder, err:", err.Error(), "order_id:", item.OrderId), 2) } }() var condition string var pars []interface{} userId := item.UserId //判断是日卡月卡还是单场付费活动 if item.GoodsId == 1 || item.GoodsId == 2 { condition += ` AND user_id = ? AND goods_id IN (1,2) AND order_id != ? AND order_status = 1 ` pars = append(pars, userId, item.OrderId) } else { condition += ` AND user_id = ? AND source_id = ? AND source = ? AND order_id != ? AND order_status = 1 ` pars = append(pars, userId, item.SourceId, item.Source, item.OrderId) } listOrder, e := order.GetCygxOrderDetailList(condition, pars) // 这里就一条数据 if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxOrderDetailList, Err: " + e.Error()) return } if len(listOrder) == 0 { err = nil return } for _, v := range listOrder { e = order.CancelCygxOrder(v) if e != nil { return } } return }