|
|
@@ -109,51 +109,66 @@ func (self *PayController) payExchange(oId, payWay, returnUrl, source, remark st
|
|
|
if product == nil {
|
|
|
self.ReturnError(403, []string{apps.ProductNotExist[0], fmt.Sprintf("%s产品不存在", product.Name)}, "", nil)
|
|
|
}
|
|
|
- //商品下架
|
|
|
- if product.Status == product_model.PRODUCT_STATUS_DOWN {
|
|
|
- self.ReturnError(403, []string{apps.ProductOffSale[0], fmt.Sprintf("%s产品已经下架", product.Name)}, "", nil)
|
|
|
- }
|
|
|
+ //非赠品计入价格
|
|
|
+ if !item.Send {
|
|
|
+ //商品下架
|
|
|
+ if product.Status == product_model.PRODUCT_STATUS_DOWN {
|
|
|
+ self.ReturnError(403, []string{apps.ProductOffSale[0], fmt.Sprintf("%s产品已经下架", product.Name)}, "", nil)
|
|
|
+ }
|
|
|
|
|
|
- //秒杀逻辑: 判断是否处于秒杀时间段内
|
|
|
- if product.SeckilShowPrice > 0 {
|
|
|
- now := time.Now()
|
|
|
- if now.Unix() < product.SeckillStart.Unix() {
|
|
|
- self.ReturnError(403, []string{apps.SeckillNotStart[0], fmt.Sprintf("%s秒杀活动尚未开始", product.Name)}, "", nil)
|
|
|
- } else if now.Unix() > product.SeckillEnd.Unix() {
|
|
|
- self.ReturnError(403, []string{apps.SeckillIsEnd[0], fmt.Sprintf("%s秒杀活动已经结束", product.Name)}, "", nil)
|
|
|
+ //秒杀逻辑: 判断是否处于秒杀时间段内
|
|
|
+ if product.SeckilShowPrice > 0 {
|
|
|
+ now := time.Now()
|
|
|
+ if now.Unix() < product.SeckillStart.Unix() {
|
|
|
+ self.ReturnError(403, []string{apps.SeckillNotStart[0], fmt.Sprintf("%s秒杀活动尚未开始", product.Name)}, "", nil)
|
|
|
+ } else if now.Unix() > product.SeckillEnd.Unix() {
|
|
|
+ self.ReturnError(403, []string{apps.SeckillIsEnd[0], fmt.Sprintf("%s秒杀活动已经结束", product.Name)}, "", nil)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //限购逻辑
|
|
|
- if product.PurchaseLimitCount > 0 {
|
|
|
- if product.PurchaseLimitCount < item.Count {
|
|
|
- self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
- } else {
|
|
|
- purchaseTotalCount := order_model.GetOrderCountByPIdAndWxUId(product.Id, wxUId)
|
|
|
- //历史已经买够到限购数量了
|
|
|
- if product.PurchaseLimitCount <= purchaseTotalCount {
|
|
|
- self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ //限购逻辑
|
|
|
+ if product.PurchaseLimitCount > 0 {
|
|
|
+ if product.PurchaseLimitCount < item.Count {
|
|
|
+ self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ } else {
|
|
|
+ purchaseTotalCount := order_model.GetOrderCountByPIdAndWxUId(product.Id, wxUId)
|
|
|
+ //历史已经买够到限购数量了
|
|
|
+ if product.PurchaseLimitCount <= purchaseTotalCount {
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ }
|
|
|
+ //历史没买够数量,但是历史总数+想购买的数量 超过限购数量
|
|
|
+ if product.PurchaseLimitCount < (purchaseTotalCount + item.Count) {
|
|
|
+ canBuyCount := product.PurchaseLimitCount - purchaseTotalCount
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s您还可以购买%d件", product.Name, canBuyCount)}, "", nil)
|
|
|
+ }
|
|
|
}
|
|
|
- //历史没买够数量,但是历史总数+想购买的数量 超过限购数量
|
|
|
- if product.PurchaseLimitCount < (purchaseTotalCount + item.Count) {
|
|
|
- canBuyCount := product.PurchaseLimitCount - purchaseTotalCount
|
|
|
- self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s您还可以购买%d件", product.Name, canBuyCount)}, "", nil)
|
|
|
+ }
|
|
|
+ //仅发货地区省,市判断
|
|
|
+ if len(product.OnlyDeliveryArea) > 0 {
|
|
|
+ if product_model.GetProductByIdAndProvince(product.Id, allowPro, true) == nil && helper.NewStr(product.OnlyDeliveryArea).Strpos(allowAddr, 0) < 0 {
|
|
|
+ self.ReturnError(403, []string{apps.OnlyDeliveryArea[0], fmt.Sprintf("%s产品不在限售区域内", product.Name)}, "", nil)
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //仅发货地区省,市判断
|
|
|
- if len(product.OnlyDeliveryArea) > 0 {
|
|
|
- if product_model.GetProductByIdAndProvince(product.Id, allowPro, true) == nil && helper.NewStr(product.OnlyDeliveryArea).Strpos(allowAddr, 0) < 0 {
|
|
|
- self.ReturnError(403, []string{apps.OnlyDeliveryArea[0], fmt.Sprintf("%s产品不在限售区域内", product.Name)}, "", nil)
|
|
|
+
|
|
|
+ //微信支付金额统计
|
|
|
+ if product.Pv >= product.Price || specialPromotion {
|
|
|
+ total_quan += product.Price * item.Count
|
|
|
}
|
|
|
+ total_price += product.Price * item.Count
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //微信支付金额统计
|
|
|
- if product.Pv >= product.Price || specialPromotion {
|
|
|
- total_quan += product.Price * item.Count
|
|
|
+ if _, ok := SaleNumsMap[product.Id]; ok {
|
|
|
+ SaleNumsMap[product.Id] = item.Count + SaleNumsMap[product.Id]
|
|
|
+ } else {
|
|
|
+ SaleNumsMap[product.Id] = item.Count
|
|
|
}
|
|
|
- total_price += product.Price * item.Count
|
|
|
- SaleNumsMap[product.Id] = item.Count
|
|
|
- storeMap[product.Id] = item.Count
|
|
|
+
|
|
|
+ if _, ok := storeMap[product.Id]; ok {
|
|
|
+ storeMap[product.Id] = item.Count + storeMap[product.Id]
|
|
|
+ } else {
|
|
|
+ storeMap[product.Id] = item.Count
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
//beego.BeeLogger.Error("SaleNumsMap1 %v", SaleNumsMap)
|
|
|
|
|
|
@@ -238,7 +253,7 @@ func (self *PayController) payExchange(oId, payWay, returnUrl, source, remark st
|
|
|
order.Source = source
|
|
|
order.Save()
|
|
|
//发放赠品
|
|
|
- go helpers.SetOrderPromotionPro(order.OrderId, wxUser.Id)
|
|
|
+ //go helpers.SetOrderPromotionPro(order.OrderId, wxUser.Id)
|
|
|
//已支付订单移除未支付队列
|
|
|
cancelKey := lib_redis.GetOrderCancelList()
|
|
|
lib_redis.ThrowOutRedisList(cancelKey, order.OrderId)
|
|
|
@@ -268,7 +283,7 @@ func (self *PayController) payExchange(oId, payWay, returnUrl, source, remark st
|
|
|
//获取paycode
|
|
|
payCode := sys_config.GetPayConfigByDepart(wxUser.Depart, false)
|
|
|
|
|
|
- beego.BeeLogger.Warn("payCode--%s", payCode)
|
|
|
+ //beego.BeeLogger.Warn("payCode--%s", payCode)
|
|
|
payData := wx_mp.GetPayData(wxUser.Openid, order.OrderId, order.PaiedPrice, body, notifyUrl, self.Ctx.Input.IP(), payCode)
|
|
|
|
|
|
//返回数据
|