|
@@ -132,16 +132,26 @@ func (self *OrderController) Create() {
|
|
|
order.Promotions = specialstr
|
|
order.Promotions = specialstr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- order.Save()
|
|
|
|
|
-
|
|
|
|
|
- //抵扣银豆
|
|
|
|
|
|
|
+ //实抵银豆
|
|
|
var math = helper.NewMath()
|
|
var math = helper.NewMath()
|
|
|
userLeftSilver := balance_model.GetUserTotalSilver(wxUId)
|
|
userLeftSilver := balance_model.GetUserTotalSilver(wxUId)
|
|
|
paiedSilver, _ := math.Min(float64(userLeftSilver), float64(product.Silver*count))
|
|
paiedSilver, _ := math.Min(float64(userLeftSilver), float64(product.Silver*count))
|
|
|
|
|
|
|
|
- //创建订单明细
|
|
|
|
|
- new(order_model.OrderDetail).Create(order.OrderId, order.Id, product.Id, product.RelateProductId, product.Price, int64(paiedSilver), product.Name, sizeName, colorName, count, wxUser.Depart)
|
|
|
|
|
|
|
+ //折扣
|
|
|
|
|
+ dis := (float64(product.Price*count) - paiedSilver) * float64(product.Pv) / float64(100)
|
|
|
|
|
+ disAmount := math.Round(dis)
|
|
|
|
|
+
|
|
|
|
|
+ //提货券
|
|
|
|
|
+ userLeftBalanceCount := balance_model.GetUserTotalBalance(wxUId)
|
|
|
|
|
+ if userLeftBalanceCount > int64(0) {
|
|
|
|
|
+ disAmount = float64(0)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ //创建订单明细
|
|
|
|
|
+ new(order_model.OrderDetail).Create(order.OrderId, order.Id, product.Id, product.RelateProductId, product.Price, int64(paiedSilver), int64(disAmount), product.Name, sizeName, colorName, count, wxUser.Depart)
|
|
|
|
|
+ order.DisAmount = int64(disAmount)
|
|
|
|
|
+ order.TotalSilver = product.Silver * count
|
|
|
|
|
+ order.Save()
|
|
|
//发放赠品
|
|
//发放赠品
|
|
|
helpers.SetOrderPromotionPro(order.OrderId, wxUser.Id)
|
|
helpers.SetOrderPromotionPro(order.OrderId, wxUser.Id)
|
|
|
|
|
|
|
@@ -191,6 +201,7 @@ func (self *OrderController) MultipleCreate() {
|
|
|
}
|
|
}
|
|
|
totalPrice := int64(0)
|
|
totalPrice := int64(0)
|
|
|
totalPv := int64(0)
|
|
totalPv := int64(0)
|
|
|
|
|
+ totalSilver := int64(0)
|
|
|
c_arr := strings.Split(ids, ",")
|
|
c_arr := strings.Split(ids, ",")
|
|
|
c_nums := strings.Split(nums, ",")
|
|
c_nums := strings.Split(nums, ",")
|
|
|
|
|
|
|
@@ -235,15 +246,25 @@ func (self *OrderController) MultipleCreate() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //统计总银豆
|
|
|
|
|
+ totalSilver += product.Silver * cNums
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //统计实抵银豆
|
|
|
|
|
+ var math = helper.NewMath()
|
|
|
|
|
+ userLeftSilver := balance_model.GetUserTotalSilver(wxUId)
|
|
|
|
|
+ paiedSilver, _ := math.Min(float64(userLeftSilver), float64(totalSilver))
|
|
|
|
|
+
|
|
|
|
|
+ //提货券
|
|
|
|
|
+ userLeftBalanceCount := balance_model.GetUserTotalBalance(wxUId)
|
|
|
|
|
+
|
|
|
//创建订单
|
|
//创建订单
|
|
|
order := new(order_model.Order).CreateNew(wxUId, wxUser.UserId,
|
|
order := new(order_model.Order).CreateNew(wxUId, wxUser.UserId,
|
|
|
totalPrice, int64(0), order_model.ORDER_TYPE_NORMAL, wxUser.Depart, order_model.SOURCE_XCX)
|
|
totalPrice, int64(0), order_model.ORDER_TYPE_NORMAL, wxUser.Depart, order_model.SOURCE_XCX)
|
|
|
if order == nil {
|
|
if order == nil {
|
|
|
self.ReturnError(403, apps.CreateOrderFail, "", nil)
|
|
self.ReturnError(403, apps.CreateOrderFail, "", nil)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ totalDisamout := int64(0)
|
|
|
for key, s_item := range c_arr {
|
|
for key, s_item := range c_arr {
|
|
|
cId, _ := strconv.ParseInt(s_item, 10, 64)
|
|
cId, _ := strconv.ParseInt(s_item, 10, 64)
|
|
|
cNums := int64(1)
|
|
cNums := int64(1)
|
|
@@ -263,8 +284,20 @@ func (self *OrderController) MultipleCreate() {
|
|
|
totalPrice += product.Price * cNums
|
|
totalPrice += product.Price * cNums
|
|
|
totalPv += product.Pv * cNums
|
|
totalPv += product.Pv * cNums
|
|
|
|
|
|
|
|
|
|
+ //统计单件
|
|
|
|
|
+ singleTSilver := (float64(product.Silver*cNums) / float64(totalSilver)) * paiedSilver
|
|
|
|
|
+ silver := int64(math.Round(singleTSilver))
|
|
|
|
|
+
|
|
|
|
|
+ dis := (float64(product.Price*cNums) - singleTSilver) * float64(product.Pv) / float64(100)
|
|
|
|
|
+ disAmount := int64(math.Round(dis))
|
|
|
|
|
+
|
|
|
|
|
+ if userLeftBalanceCount > int64(0) {
|
|
|
|
|
+ disAmount = int64(0)
|
|
|
|
|
+ }
|
|
|
|
|
+ totalDisamout += disAmount
|
|
|
|
|
+
|
|
|
//创建订单明细
|
|
//创建订单明细
|
|
|
- CreateOrderDetails(product, order, cNums, wxUser.Depart)
|
|
|
|
|
|
|
+ CreateOrderDetails(product, order, cNums, wxUser.Depart, silver, disAmount)
|
|
|
}
|
|
}
|
|
|
freight := sys_config.GetFreight()
|
|
freight := sys_config.GetFreight()
|
|
|
if totalPrice >= sys_config.GetOrderLimit() {
|
|
if totalPrice >= sys_config.GetOrderLimit() {
|
|
@@ -273,6 +306,8 @@ func (self *OrderController) MultipleCreate() {
|
|
|
order.Pv = totalPv
|
|
order.Pv = totalPv
|
|
|
order.TotalPrice = totalPrice
|
|
order.TotalPrice = totalPrice
|
|
|
order.Freight = freight
|
|
order.Freight = freight
|
|
|
|
|
+ order.DisAmount = totalDisamout
|
|
|
|
|
+ order.TotalSilver = totalSilver
|
|
|
specialPromotion, specialstr := sys_config.GetSpetialPromotion()
|
|
specialPromotion, specialstr := sys_config.GetSpetialPromotion()
|
|
|
if specialPromotion {
|
|
if specialPromotion {
|
|
|
order.Promotions = specialstr
|
|
order.Promotions = specialstr
|
|
@@ -358,7 +393,7 @@ func (self *OrderController) MultShopCreate() {
|
|
|
}
|
|
}
|
|
|
//创建订单明细
|
|
//创建订单明细
|
|
|
totalPrice += product.Price * cNums
|
|
totalPrice += product.Price * cNums
|
|
|
- CreateOrderDetails(product, order, cNums, wxUser.Depart)
|
|
|
|
|
|
|
+ CreateOrderDetails(product, order, cNums, wxUser.Depart, int64(0), int64(0))
|
|
|
}
|
|
}
|
|
|
freight := sys_config.GetFreight()
|
|
freight := sys_config.GetFreight()
|
|
|
if totalPrice >= sys_config.GetOrderLimit() {
|
|
if totalPrice >= sys_config.GetOrderLimit() {
|
|
@@ -466,7 +501,7 @@ func (self *OrderController) MultCentCreate() {
|
|
|
if product == nil {
|
|
if product == nil {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
}
|
|
}
|
|
|
- CreateOrderDetails(product, order, cNums, wxUser.Depart)
|
|
|
|
|
|
|
+ CreateOrderDetails(product, order, cNums, wxUser.Depart, int64(0), int64(0))
|
|
|
}
|
|
}
|
|
|
order.TotalPrice = totalPrice
|
|
order.TotalPrice = totalPrice
|
|
|
order.Freight = freight
|
|
order.Freight = freight
|
|
@@ -760,7 +795,7 @@ func (self *OrderController) Operate() {
|
|
|
self.ServeJSON()
|
|
self.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func CreateOrderDetails(product *product_model.Product, order *order_model.Order, cNums, depart int64) {
|
|
|
|
|
|
|
+func CreateOrderDetails(product *product_model.Product, order *order_model.Order, cNums, depart, silver, disAmount int64) {
|
|
|
//获取商品属性详情
|
|
//获取商品属性详情
|
|
|
sizeName := ""
|
|
sizeName := ""
|
|
|
colorName := ""
|
|
colorName := ""
|
|
@@ -776,7 +811,7 @@ func CreateOrderDetails(product *product_model.Product, order *order_model.Order
|
|
|
colorName = productColor.Name
|
|
colorName = productColor.Name
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- new(order_model.OrderDetail).Create(order.OrderId, order.Id, product.Id, product.RelateProductId, product.Price, product.RoboBalancePrice, product.Name, sizeName, colorName, cNums, depart)
|
|
|
|
|
|
|
+ new(order_model.OrderDetail).Create(order.OrderId, order.Id, product.Id, product.RelateProductId, product.Price, silver, disAmount, product.Name, sizeName, colorName, cNums, depart)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//用户评论订单明细
|
|
//用户评论订单明细
|