|
|
@@ -267,30 +267,25 @@ func (self *OrderController) MultCentCreate() {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
}
|
|
|
totalPrice := int64(0)
|
|
|
- //创建订单
|
|
|
- order := new(order_model.Order).CreateNew(wxUId, uId,
|
|
|
- totalPrice, int64(0), order_model.ORDER_TYPE_CENT, wxUser.Depart, order_model.SOURCE_XCX)
|
|
|
- if order == nil {
|
|
|
- self.ReturnError(403, apps.CreateOrderFail, "", nil)
|
|
|
- }
|
|
|
+ //计算订单总额
|
|
|
c_arr := strings.Split(ids, ",")
|
|
|
c_nums := strings.Split(nums, ",")
|
|
|
for key, s_item := range c_arr {
|
|
|
pId, _ := strconv.ParseInt(s_item, 10, 64)
|
|
|
cNums := int64(1)
|
|
|
cNums, _ = strconv.ParseInt(c_nums[key], 10, 64)
|
|
|
- product := product_model.GetProductById(pId, false)
|
|
|
+ product := product_model.GetProductById(pId, true)
|
|
|
if product == nil {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
}
|
|
|
if product.Ptype != product_model.CENT_SALE {
|
|
|
self.ReturnError(403, apps.NoShopSale, "", nil)
|
|
|
}
|
|
|
-
|
|
|
- //创建订单明细
|
|
|
+ //计算订单总额
|
|
|
totalPrice += product.Price * cNums
|
|
|
- CreateOrderDetails(product, order, cNums)
|
|
|
}
|
|
|
+
|
|
|
+ //订单合法性判断
|
|
|
freight := base_config.GetFreight()
|
|
|
if totalPrice < base_config.GetOrderLimit() {
|
|
|
self.ReturnError(403, []string{apps.OrderNotEnough[0], fmt.Sprintf("订单金额不能低于%d积分", base_config.GetOrderLimit()/int64(100))}, "", nil)
|
|
|
@@ -302,6 +297,24 @@ func (self *OrderController) MultCentCreate() {
|
|
|
if userLeftCent < totalPrice {
|
|
|
self.ReturnError(403, apps.CentNotEnough, "", nil)
|
|
|
}
|
|
|
+
|
|
|
+ //创建订单
|
|
|
+ order := new(order_model.Order).CreateNew(wxUId, uId,
|
|
|
+ totalPrice, int64(0), order_model.ORDER_TYPE_CENT, wxUser.Depart, order_model.SOURCE_XCX)
|
|
|
+ if order == nil {
|
|
|
+ self.ReturnError(403, apps.CreateOrderFail, "", nil)
|
|
|
+ }
|
|
|
+ //创建订单明细
|
|
|
+ for key, s_item := range c_arr {
|
|
|
+ pId, _ := strconv.ParseInt(s_item, 10, 64)
|
|
|
+ cNums := int64(1)
|
|
|
+ cNums, _ = strconv.ParseInt(c_nums[key], 10, 64)
|
|
|
+ product := product_model.GetProductById(pId, true)
|
|
|
+ if product == nil {
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
+ }
|
|
|
+ CreateOrderDetails(product, order, cNums)
|
|
|
+ }
|
|
|
order.TotalPrice = totalPrice
|
|
|
order.Freight = freight
|
|
|
order.Save()
|