|
|
@@ -114,6 +114,59 @@ func (self *ProductController) Get() {
|
|
|
self.ServeJSON()
|
|
|
}
|
|
|
|
|
|
+//商品详情
|
|
|
+func (self *ProductController) GetPdDetail() {
|
|
|
+ _id := self.Ctx.Input.Param(":id")
|
|
|
+ pId, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
+ _size_id := self.Ctx.Input.Param(":size_id")
|
|
|
+ sizeId, _ := strconv.ParseInt(_size_id, 10, 64)
|
|
|
+ _color_id := self.Ctx.Input.Param(":color_id")
|
|
|
+ colorId, _ := strconv.ParseInt(_color_id, 10, 64)
|
|
|
+ cache, _ := self.GetBool("cache", false)
|
|
|
+
|
|
|
+ pd := product_model.GetProductByIdAndSizeAndColor(pId, sizeId, colorId, cache)
|
|
|
+ if pd == nil {
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ pd.SoldCount = pd.SaleNums
|
|
|
+ if pd.Count > pd.SoldCount {
|
|
|
+ pd.LeftCount = pd.Count - pd.SoldCount
|
|
|
+ }
|
|
|
+ pd.SoldCount = pd.SoldCount + pd.VirtualSoldCount
|
|
|
+ pd.Cover = product_model.GetCoverByPId(pId, cache)
|
|
|
+ pd.Album = product_model.GetPicturesByPIdAndPType(pId, product_model.PIC_TYPE_ALBUM, cache)
|
|
|
+ pd.ShareImg = self.GetCdnFullImgUrl(pd.ShareImg)
|
|
|
+
|
|
|
+ if pd.SeckilShowPrice > 0 {
|
|
|
+ now := time.Now()
|
|
|
+ pd.SeckillStartAt = pd.SeckillStart.Unix()
|
|
|
+ pd.SeckillEndAt = pd.SeckillEnd.Unix()
|
|
|
+ if pd.SeckillStart.Unix() > now.Unix() {
|
|
|
+ pd.SeckillState = product_model.SECKILL_PREPARING_STATE
|
|
|
+ pd.SeckillStateCn = product_model.SECKILL_PREPARING_STATE_CN
|
|
|
+ pd.SoldCount = pd.SoldCount - pd.VirtualSoldCount //准备中不加虚拟量
|
|
|
+ } else if pd.SeckillStart.Unix() <= now.Unix() && now.Unix() < pd.SeckillEnd.Unix() {
|
|
|
+ pd.IsUnderSeckill = true
|
|
|
+ pd.SeckillState = product_model.SECKILL_UNDER_STATE
|
|
|
+ pd.SeckillStateCn = product_model.SECKILL_UNDER_STATE_CN
|
|
|
+ } else {
|
|
|
+ pd.SeckillState = product_model.SECKILL_END_STATE
|
|
|
+ pd.SeckillStateCn = product_model.SECKILL_END_STATE_CN
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pd.HaveSize = false
|
|
|
+ if product_model.GetProductAttrConfig(pd.Id) != nil {
|
|
|
+ pd.HaveSize = true
|
|
|
+ }
|
|
|
+
|
|
|
+ pd.DeliverStartTime = pd.DeliverStartAt.Unix()
|
|
|
+ pd.DeliverStopTime = pd.DeliverStopAt.Unix()
|
|
|
+ // ret.Product = pd
|
|
|
+ self.Data["json"] = pd
|
|
|
+ self.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
//商品分类
|
|
|
func (self *ProductController) Categories() {
|
|
|
ancestry := self.GetString("ancestry")
|