Просмотр исходного кода

Merge branch 'develop' into feature/app_dev

* develop:
  增加商品混合支付
abiao лет назад: 4
Родитель
Сommit
707db39fe8

+ 9 - 7
go/gopath/src/fohow.com/apps/controllers/order_controller/cart_controller.go

@@ -9,7 +9,6 @@ import (
 	"github.com/astaxie/beego"
 	"strconv"
 	"strings"
-	"time"
 )
 
 //加入购物车
@@ -42,12 +41,12 @@ func (self *OrderController) CreateCart() {
 		}
 	}
 	//秒杀商品不允许加入购物车
-	if product.SeckilShowPrice > 0 {
-		now := time.Now()
-		if now.Unix() >= product.SeckillStart.Unix() && now.Unix() <= product.SeckillEnd.Unix() {
-			self.ReturnError(403, apps.SeckillNotAllow, "", nil)
-		}
-	}
+	//if product.SeckilShowPrice > 0 {
+	//	now := time.Now()
+	//	if now.Unix() >= product.SeckillStart.Unix() && now.Unix() <= product.SeckillEnd.Unix() {
+	//		self.ReturnError(403, apps.SeckillNotAllow, "", nil)
+	//	}
+	//}
 
 	//限购逻辑
 	if product.PurchaseLimitCount > 0 {
@@ -303,6 +302,9 @@ func (self *OrderController) GetCartBuyList() {
 		item.Cover = product_model.GetCoverByPId(item.ProductId, cache)
 		item.OriginalPrice = product.Price
 		item.ProductName = product.Name
+		item.SeckillStartAt = product.SeckillStart.Unix()
+		item.SeckillEndAt = product.SeckillEnd.Unix()
+		item.SeckilShowPrice = product.SeckilShowPrice
 		total += item.Count * product.Price
 	}
 

+ 16 - 11
go/gopath/src/fohow.com/apps/controllers/pay_controller/pay_exchange_controller.go

@@ -91,18 +91,15 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
 	storeMap := make(map[int64]int64)
 
 	//支付方式判断
-	if (order.OrderType == order_model.ORDER_TYPE_SEKILL || order.OrderType == order_model.ORDER_TYPE_SHOP) && payWay == pay_model.PAYWAY_BALANCE {
-		self.ReturnError(403, apps.NotRightPayWay, "", nil)
-	}
-
-	//普通订单总价大于pv只支持微信支付
-	if order.OrderType == order_model.ORDER_TYPE_NORMAL && useCoupon && order.Pv < order.TotalPrice {
+	if order.OrderType == order_model.ORDER_TYPE_SHOP && payWay == pay_model.PAYWAY_BALANCE {
 		self.ReturnError(403, apps.NotRightPayWay, "", nil)
 	}
 
 	//获取购物商品明细
 	buy_price_total := int64(0)
 	total_price := int64(0)
+	total_quan := int64(0)
+	total_weixin := int64(0)
 	list := order_model.GetAllDetailsOrderId(order.OrderId, false)
 	for _, item := range list {
 		//商品状态
@@ -140,6 +137,10 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
 				}
 			}
 		}
+		//微信支付金额统计
+		if product.Pv >= product.Price {
+			total_quan += product.Price * item.Count
+		}
 		buy_price_total += product.BuyPrice * item.Count
 		total_price += product.Price * item.Count
 		SaleNumsMap[product.Id] = item.Count
@@ -183,14 +184,18 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
 			freight = int64(0)
 		}
 		tp += freight
-		if order.OrderType != order_model.ORDER_TYPE_SEKILL && useCoupon {
-			if userLeftBalanceCount < tp {
+		total_quan += freight
+		if useCoupon {
+			if userLeftBalanceCount < total_quan {
 				totalCoupon = userLeftBalanceCount
 			} else {
-				needWx = false
-				totalCoupon = tp
+				totalCoupon = total_quan
 			}
 		}
+		total_weixin = tp - totalCoupon
+		if total_weixin > 0 {
+			needWx = true
+		}
 		order.Freight = freight
 		order.PickDept = pick_dept_id
 		order.PickWay = pick_way
@@ -231,7 +236,7 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
 			order.Contact = concat
 			order.Tel = tel
 			order.Address = addr
-			order.PaiedPrice = tp - totalCoupon
+			order.PaiedPrice = total_weixin
 			order.Source = source
 			order.Save()
 			if source == order_model.SOURCE_XCX { //小程序微信支付

+ 18 - 15
go/gopath/src/fohow.com/apps/models/order_model/cart.go

@@ -18,21 +18,24 @@ const (
 )
 
 type Cart struct {
-	Id            int64          `orm:"column(id);pk"                                       json:"id"`         // int(11)
-	ProductId     int64          `orm:"column(product_id)"                                  json:"product_id"` // int(11)
-	UserId        int64          `orm:"column(user_id)"                            json:"user_id"`             // varchar(64)
-	WxUserId      int64          `orm:"column(wx_user_id)"                                  json:"wx_user_id"`
-	CreatedAt     time.Time      `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"`    // datetime
-	Count         int64          `orm:"column(nums)"                                       json:"count"` // int(11)
-	IsBuy         bool           `orm:"column(is_buy)" json:"is_under_seckill"`
-	ProductName   string         `orm:"-"     json:"product_name"`   // decimal(10,2)
-	SizeName      string         `orm:"-"     json:"size_name"`      //   varchar(64)
-	ColorName     string         `orm:"-"     json:"color_name"`     //  varchar(64)
-	Cover         string         `orm:"-"     json:"cover"`          // decimal(10,2)
-	OriginalPrice int64          `orm:"-"     json:"original_price"` // decimal(10,2)
-	Attrs         string         `orm:"-"     json:"attrs"`          // decimal(10,2)
-	Package       bool           `orm:"-"     json:"package"`
-	PackageList   []*ProductItem `orm:"-"     json:"package_list"` // varchar(255)
+	Id              int64          `orm:"column(id);pk"                                       json:"id"`         // int(11)
+	ProductId       int64          `orm:"column(product_id)"                                  json:"product_id"` // int(11)
+	UserId          int64          `orm:"column(user_id)"                            json:"user_id"`             // varchar(64)
+	WxUserId        int64          `orm:"column(wx_user_id)"                                  json:"wx_user_id"`
+	CreatedAt       time.Time      `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"`    // datetime
+	Count           int64          `orm:"column(nums)"                                       json:"count"` // int(11)
+	IsBuy           bool           `orm:"column(is_buy)" json:"is_under_seckill"`
+	ProductName     string         `orm:"-"     json:"product_name"`       // decimal(10,2)
+	SizeName        string         `orm:"-"     json:"size_name"`          //   varchar(64)
+	ColorName       string         `orm:"-"     json:"color_name"`         //  varchar(64)
+	Cover           string         `orm:"-"     json:"cover"`              // decimal(10,2)
+	OriginalPrice   int64          `orm:"-"     json:"original_price"`     // decimal(10,2)
+	Attrs           string         `orm:"-"     json:"attrs"`              // decimal(10,2)
+	SeckillStartAt  int64          `orm:"-"     json:"seckill_start"`      // datetime
+	SeckillEndAt    int64          `orm:"-"     json:"seckill_end"`        // datetime
+	SeckilShowPrice int64          `orm:"-"     json:"seckill_show_price"` // datetime
+	Package         bool           `orm:"-"     json:"package"`
+	PackageList     []*ProductItem `orm:"-"     json:"package_list"` // varchar(255)
 
 }