wangkaiyue 4 年之前
父節點
當前提交
3a32bc0b72
共有 1 個文件被更改,包括 17 次插入8 次删除
  1. 17 8
      src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

+ 17 - 8
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -67,6 +67,7 @@ func (this *SubVipPayOrder) CreateOrder() {
 		orderType, _ := this.GetInteger("orderType") //1 简单付费,5 升降级续费
 		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
 		disWord := this.GetString("disWord")
+		req_price, _ := this.GetInteger("price")     //前端展示金额
 		order_phone := this.GetString("order_phone") //p19.3用户信息采集 手机号
 
 		if disWord == "" {
@@ -122,17 +123,20 @@ func (this *SubVipPayOrder) CreateOrder() {
 		}
 		//计算价格
 		totalfee := entity.JyVipSubStruct.GetSubVipPrice(buyset, date_count, date_unit)
+		if req_price != totalfee {
+			log.Println(userId+" 前台计算", req_price, "后台计算", totalfee)
+			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", totalfee, req_price)), nil}
+		}
 		//原价
 		original_price := totalfee
 		log.Printf("最终选择 地区:%+v   行业:%v\n 价格%d", filter.Area, filter.Industry, totalfee)
 		ordercode := pay.GetOrderCode(userId)
-		//用户当前使用卡卷
-		userLotteryId := ""
-		full_price, reduce_price := 0, 0
+
 		//卡卷信息的id
 		lotteryId := this.GetString("lotteryId")
-		discount_price := 0
+		discount_price, userLotteryId := 0, ""
 		if lotteryId != "" {
+			full_price, reduce_price := 0, 0
 			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
 			if full_price <= totalfee {
 				totalfee = totalfee - reduce_price
@@ -209,6 +213,7 @@ func (this *SubVipPayOrder) Renew() {
 	r := func() *entity.FuncResult {
 		disWord := this.GetString("disWord")
 		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+		req_price, _ := this.GetInteger("price") //前端展示金额
 		if disWord == "" {
 			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
@@ -227,6 +232,10 @@ func (this *SubVipPayOrder) Renew() {
 			return &entity.FuncResult{false, errors.New("请求异常,非vip状态"), nil}
 		}
 		totalfee := entity.JyVipSubStruct.GetSubVipPriceByBuySet(buyset, date_count, date_unit, false)
+		if req_price != totalfee {
+			log.Println(userId+" 前台计算", req_price, "后台计算", totalfee)
+			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", totalfee, req_price)), nil}
+		}
 		filter := entity.VipSimpleMsg{
 			Area:       nil,
 			Industry:   nil,
@@ -242,13 +251,13 @@ func (this *SubVipPayOrder) Renew() {
 		}
 		//原价
 		original_price := totalfee
-		//用户当前使用卡卷
-		userLotteryId := ""
-		full_price, reduce_price := 0, 0
+
 		//卡卷信息的id
 		lotteryId := this.GetString("lotteryId")
-		discount_price := 0
+		userLotteryId, discount_price := "", 0
 		if lotteryId != "" {
+			//用户当前使用卡卷
+			full_price, reduce_price := 0, 0
 			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
 			if full_price <= totalfee {
 				totalfee = totalfee - reduce_price