Exemplo n.º 1
0
func (this *shoppingService) HandleOrder(partnerId int, orderNo string) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		b := order.IsOver()
		if b {
			return errors.New("订单已经完成!")
		}

		status := order.GetValue().Status
		switch status + 1 {
		case enum.ORDER_CONFIRMED:
			err = order.Confirm()
		case enum.ORDER_PROCESSING:
			err = order.Process()
		case enum.ORDER_SENDING:
			err = order.Deliver()
		case enum.ORDER_RECEIVED:
			err = order.SignReceived()
		case enum.ORDER_COMPLETED:
			err = order.Complete()
		}
	}
	return err
}
Exemplo n.º 2
0
func (this *shoppingService) CancelOrder(partnerId int, orderNo string, reason string) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		err = order.Cancel(reason)
	}
	return err
}
Exemplo n.º 3
0
func (this *shoppingService) PayForOrder(partnerId int, orderNo string) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		err = order.SignPaid()
	}
	return err
}
Exemplo n.º 4
0
// 确认付款
func (this *shoppingService) PayForOrderOnlineTrade(partnerId int, orderNo string, spName string, tradeNo string) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		err = order.PaymentOnlineTrade(spName, tradeNo)
	}
	return err
}
Exemplo n.º 5
0
// 人工付款
func (this *shoppingService) PayForOrderByManager(partnerId int, orderNo string) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		err = order.CmPaymentWithBalance()
	}
	return err
}
Exemplo n.º 6
0
func (this *shoppingService) GetOrderByNo(partnerId int,
	orderNo string) *shopping.ValueOrder {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err != nil {
		Context.Log().PrintErr(err)
		return nil
	}
	v := order.GetValue()
	return &v
}
Exemplo n.º 7
0
func (this *shoppingService) SetDeliverShop(partnerId int, orderNo string,
	shopId int) error {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, err := sp.GetOrderByNo(orderNo)
	if err == nil {
		if err = order.SetShop(shopId); err == nil {
			_, err = order.Save()
		}
	}
	return err
}
Exemplo n.º 8
0
func (this *shoppingService) BuildOrder(partnerId int, memberId int,
	cartKey string, couponCode string) (map[string]interface{}, error) {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	order, _, err := sp.BuildOrder(memberId, couponCode)
	if err != nil {
		return nil, err
	}

	v := order.GetValue()
	buf := bytes.NewBufferString("")

	for _, v := range order.GetCoupons() {
		buf.WriteString(v.GetDescribe())
		buf.WriteString("\n")
	}

	var data map[string]interface{}
	data = make(map[string]interface{})
	if couponCode != "" {
		if v.CouponFee == 0 {
			data["result"] = v.CouponFee != 0
			data["message"] = "优惠券无效"
		} else {
			// 成功应用优惠券
			data["totalFee"] = v.TotalFee
			data["fee"] = v.Fee
			data["payFee"] = v.PayFee
			data["discountFee"] = v.DiscountFee
			data["couponFee"] = v.CouponFee
			data["couponDescribe"] = buf.String()
		}
	} else {
		// 取消优惠券
		data["totalFee"] = v.TotalFee
		data["fee"] = v.Fee
		data["payFee"] = v.PayFee
		data["discountFee"] = v.DiscountFee
	}
	return data, err
}
Exemplo n.º 9
0
func (this *shoppingService) SubmitOrder(partnerId, memberId int, couponCode string) (
	orderNo string, err error) {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	return sp.SubmitOrder(memberId, couponCode)
}
Exemplo n.º 10
0
func (this *shoppingService) BuildOrder(partnerId int, memberId int,
	cartKey string, couponCode string) (shopping.IOrder, shopping.ICart, error) {
	var sp shopping.IShopping = this._rep.GetShopping(partnerId)
	return sp.BuildOrder(memberId, couponCode)
}