Bläddra i källkod

Merge remote-tracking branch 'origin/debug' into debug

zwxi 10 månader sedan
förälder
incheckning
db4e4d33a4

+ 1 - 2
controllers/activity.go

@@ -572,8 +572,7 @@ func (this *ActivityCoAntroller) Detail() {
 			if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
 				resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
 			} else {
-				resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
-				fmt.Println("activityId", activityId)
+				resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo)                                             //单场活动信息
 				resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
 			}
 			for _, v := range resp.GoodsList {

+ 8 - 6
controllers/order.go

@@ -2,7 +2,6 @@ package controllers
 
 import (
 	"encoding/json"
-	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/models/order"
@@ -182,7 +181,11 @@ func (this *OrderController) AddByActivity() {
 	if activityDetail.ActivityTypeName == "公司调研电话会" {
 		item.GoodsName = "买方交流"
 	}
-	fmt.Println("item.GoodsName", item.GoodsName)
+	//如果活动有自定义的价格就优先按照自定义的价格来
+	if activityDetail.ActivityPrice > 0 {
+		goodsDetail.CurrentPrice = activityDetail.ActivityPrice
+	}
+
 	//return
 	item.GoodsId = goodsId
 	item.GoodsMoney = goodsDetail.Price
@@ -374,10 +377,9 @@ func (this *OrderController) OrderDetail() {
 	br.Msg = "获取成功"
 }
 
-// @Title 通过活动创建订单
-// @Description 通过活动创建订单接口
-// @Param	request	body models.ActivitySingnupRep true "type json string"
-// @Success Ret=200 {object} models.SignupStatus
+// @Title 取消订单
+// @Description 取消订单接口
+// @Param	request	body models.CygxOrderCancelReq true "type json string"
 // @router /cancel [post]
 func (this *OrderController) Cancel() {
 	br := new(models.BaseResponse).Init()

+ 0 - 2
controllers/report.go

@@ -47,13 +47,11 @@ func (this *ReportController) IsShow() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-
 	if total > 0 {
 		resp.IsYanxuanSpecialAuthor = true
 	}
 	//resp.IsShowMobileAndEmailButton = true
 	resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否调取微信支付
-
 	resp.IsShow = true
 	br.Ret = 200
 	br.Success = true

+ 1 - 0
models/activity.go

@@ -240,6 +240,7 @@ type ActivityDetail struct {
 	LabelKeyword              string                     `description:"标签关键词"`
 	LabelKeywordImgLink       string                     `description:"标签关键词ico"`
 	MomentsImg                string                     `description:"分享到朋友圈的封面图片"`
+	ActivityPrice             float64                    `description:"单场活动价格"`
 }
 type ListArticleActivity struct {
 	Title   string `description:"文章标题"`

+ 1 - 0
models/order/order.go

@@ -38,6 +38,7 @@ type CygxOrder struct {
 	OrderCode        string    `comment:"订单编号"`
 	OutTradeCode     string    `comment:"外部交易号"`
 	PaymentType      int       `comment:"支付类型。取值范围:1微信支付,2支付宝支付。"`
+	TradeType        string    `comment:"交易类型,枚举值:JSAPI:公众号支付 、 NATIVE:扫码支付 、 App:App支付 、 MICROPAY:付款码支付 、 MWEB:H5支付 、 FACEPAY:刷脸支付"`
 	GoodsName        string    `comment:"商品名称"`
 	GoodsId          int       `comment:"商品ID"`
 	BuyerInvoice     string    `comment:"买家发票信息"`

+ 17 - 1
models/order/order_user_card.go

@@ -63,7 +63,21 @@ func AddCygxOrderUserCard(item *CygxOrderUserCard, itemOrder *CygxOrder) (err er
 
 	itemOrderAction := new(CygxOrderAction)
 
-	itemOrderAction.Action = "微信小程序已支付"
+	switch itemOrder.TradeType {
+	case "JSAPI":
+		itemOrderAction.Action = "公众号支付"
+	case "NATIVE":
+		itemOrderAction.Action = "扫码支付"
+	case "App":
+		itemOrderAction.Action = "App支付"
+	case "MICROPAY":
+		itemOrderAction.Action = "付款码支付"
+	case "MWEB":
+		itemOrderAction.Action = "H5支付"
+	case "FACEPAY":
+		itemOrderAction.Action = "刷脸支付"
+	}
+
 	itemOrderAction.OrderStatus = 2
 	itemOrderAction.OrderStatusText = "已支付"
 	itemOrderAction.OrderCode = item.OrderCode
@@ -87,6 +101,7 @@ func AddCygxOrderUserCard(item *CygxOrderUserCard, itemOrder *CygxOrder) (err er
 	updateParams["StartDate"] = item.StartDate
 	updateParams["EndDate"] = item.EndDate
 	updateParams["PaymentType"] = 1
+	updateParams["TradeType"] = itemOrder.TradeType
 	ptrStructOrTableName := "cygx_order"
 	whereParam := map[string]interface{}{"order_code": itemOrder.OrderCode}
 	qs := o.QueryTable(ptrStructOrTableName)
@@ -94,6 +109,7 @@ func AddCygxOrderUserCard(item *CygxOrderUserCard, itemOrder *CygxOrder) (err er
 		qs = qs.Filter(expr, exprV)
 	}
 	_, err = qs.Update(updateParams) // 修改订单状态
+	fmt.Println("err", err)
 	if err != nil {
 		return
 	}

+ 15 - 1
models/order/order_virtual_asset.go

@@ -41,8 +41,21 @@ func AddCygxOrderVirtualAsset(item *CygxOrderVirtualAsset, itemOrder *CygxOrder)
 	}()
 
 	itemOrderAction := new(CygxOrderAction)
+	switch itemOrder.TradeType {
+	case "JSAPI":
+		itemOrderAction.Action = "公众号支付"
+	case "NATIVE":
+		itemOrderAction.Action = "扫码支付"
+	case "App":
+		itemOrderAction.Action = "App支付"
+	case "MICROPAY":
+		itemOrderAction.Action = "付款码支付"
+	case "MWEB":
+		itemOrderAction.Action = "H5支付"
+	case "FACEPAY":
+		itemOrderAction.Action = "刷脸支付"
+	}
 
-	itemOrderAction.Action = "微信小程序已支付"
 	itemOrderAction.OrderStatus = 2
 	itemOrderAction.OrderStatusText = "已支付"
 	itemOrderAction.OrderCode = item.OrderCode
@@ -64,6 +77,7 @@ func AddCygxOrderVirtualAsset(item *CygxOrderVirtualAsset, itemOrder *CygxOrder)
 	updateParams["OutTradeCode"] = itemOrder.OutTradeCode
 	updateParams["ModifyTime"] = item.ModifyTime
 	updateParams["PaymentType"] = 1
+	updateParams["TradeType"] = itemOrder.TradeType
 	ptrStructOrTableName := "cygx_order"
 	whereParam := map[string]interface{}{"order_code": itemOrder.OrderCode}
 	qs := o.QueryTable(ptrStructOrTableName)

+ 16 - 9
services/order.go

@@ -63,6 +63,12 @@ func GetGoodsInfoByActivity(item *models.ActivityDetail) (goodsListResp []*order
 		err = errors.New("GetCygxGoodsList, Err: " + e.Error())
 		return
 	}
+	//如果活动有自定义的价格就优先按照自定义的价格来
+	if item.ActivityPrice > 0 {
+		for k, _ := range goodsList {
+			goodsList[k].CurrentPrice = fmt.Sprint(item.ActivityPrice)
+		}
+	}
 	goodsListResp = goodsList
 	return
 }
@@ -79,8 +85,8 @@ func GetHaverEquallyOrderByUser10Min(userId, goodsId int) (orderCode string) {
 	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 > ?  ORDER BY order_id DESC  `
-	pars = append(pars, userId, goodsId, endTime)
+	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())
@@ -108,8 +114,8 @@ func GetHaverEquallyOrderByUser10MinByActivty(userId, sourceId int) (orderCode s
 	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 > ?  ORDER BY order_id DESC  `
-	pars = append(pars, userId, sourceId, endTime)
+	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())
@@ -144,6 +150,11 @@ func HandleOrderHandle(itemCallback *WechatPayCallback) {
 		return
 	}
 
+	//修改过状态的不再二次处理
+	if orderDetail.OrderStatus == 2 {
+		return
+	}
+
 	go AddCygxOrderPayment(itemCallback) // 记录支付交易信息
 
 	if itemCallback.TradeState != "SUCCESS" { // 回调显示支付不成功,模版消息推送
@@ -152,10 +163,6 @@ func HandleOrderHandle(itemCallback *WechatPayCallback) {
 			return
 		}
 	}
-	//修改过状态的不再二次处理
-	if orderDetail.OrderStatus == 2 {
-		return
-	}
 
 	itemOrder := new(order.CygxOrder)
 	itemOrder.OrderCode = itemCallback.OutTradeNo
@@ -163,6 +170,7 @@ func HandleOrderHandle(itemCallback *WechatPayCallback) {
 	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 {
@@ -215,7 +223,6 @@ func HandleOrderHandle(itemCallback *WechatPayCallback) {
 			return
 		}
 	}
-	fmt.Println(orderDetail.Source)
 	return
 }