def add_coupon(self, type):
     coupon = Coupon()
     if type == 'collation':
         coupon.set_authorization('collation')
         self.liste_coupons_collation.append(coupon)
     elif type == 'repas':
         coupon.set_authorization('repas')
         self.liste_coupons_repas.append(coupon)
Beispiel #2
0
    def setUp(self):
        self.food = Category('food')
        self.home = Category('home')
        self.apple = Product('apple', 100.0, self.food)
        self.almond = Product('almond', 50.0, self.food)
        self.chair = Product('chair', 100.0, self.home)

        self.cart = ShoppingCart()
        self.cart.addItem(self.apple, 3)
        self.cart.addItem(self.almond, 1)
        self.cart.addItem(self.chair, 2)

        self.campaign1 = Campaign(self.food, 25.0, 1, DiscountType.Rate)
        self.campaign2 = Campaign(self.home, 50.0, 3, DiscountType.Rate)
        self.campaign3 = Campaign(self.food, 12, 1, DiscountType.Amount)
        self.campaign4 = Campaign(self.home, 10, 3, DiscountType.Amount)

        self.coupon1 = Coupon(100.0, 10.0, DiscountType.Rate)
        self.coupon2 = Coupon(1000.0, 10.0, DiscountType.Rate)
        self.coupon3 = Coupon(100.0, 100.0, DiscountType.Amount)
        self.coupon4 = Coupon(1000.0, 100.0, DiscountType.Amount)
Beispiel #3
0
from Coupon import Coupon

coupon = Coupon()

farm_data = coupon.get_farm()
# print(farm_data)

efun_data = coupon.get_efun()
# print(efun_data)

don_data = coupon.get_don()
# print(don_data)

hakka_data = coupon.get_hakka()
# print(hakka_data)
Beispiel #4
0
if int(choice) == 1:
	# Input Params
	coupon_num = int(input("Number of Coupons: "))
	coupon_val = float(input("Coupon Value: "))
	coupon_use = int(input("Number of Uses: "))

	# Warning String
	chk_str = "Are you sure you want to create coupon(s) with the following "
	chk_str += "parameters(y/n):\n (Coupons: {0} / Value: {1} / Uses: {2}) \n"
	chk_str = chk_str.format(coupon_num, coupon_val, coupon_use)

	# Create Coupons
	if str(input(chk_str)) == 'y':
		# Connect to Database
		conn = sqlite3.connect(app.config['DATABASE_FILE'])
		mc = Coupon(conn)
		coupon_list = []

		# Create Coupons
		for i in range(coupon_num):
			new_coup = mc.new(coupon_val, coupon_use)
			coupon_list.append(new_coup)

		# Output Coupon Codes:
		print("Coupon Codes:\n")
		for i in coupon_list: print(i)
		print("Done...")
		conn.close()	

# Clear Expired Coupons
elif int(choice) == 2:
Beispiel #5
0
from Coupon import Coupon
from Login import Login
from Book import Book

if __name__ == '__main__':
    config = open('config', 'r+')
    thor = config.readline()
    if not thor or thor == '':
        #登录获取thor(扫码登录)
        loginObj = Login()
        loginObj.login()
        thor = loginObj.get()
        config.write(thor)
    config.close()
    #根据商品的id快速下单
    b = Book(thor)
    b.book('27752137726', 1)

    #根据券的id领取优惠券
    c = Coupon(thor)
    c.getCoupon(
        'a89a85ebee8296dc65bd776f4a1d414e4e224464bb14bd65f5e822c44ff2854868dffebfbaa256891583cb0c75b53605'
    )