Пример #1
0
    def initial_data(self):
        self.team_owner = User.create(name='test_activity')
        self.team = Team.create(name='club_test_activity',
                                owner_id=self.team_owner.id)
        self.user = self.creator = User.create(name='activity_creator')
        self.activity = Activity.create(team=self.team,
                                        creator=self.creator,
                                        price='10', vip_price='8',
                                        leader=self.creator,
                                        title='just a test',
                                        description='description',
                                        start_time='3000-01-01 00:00:01',
                                        end_time='3000-12-31 23:59:59')

        self.order = OrderService.new_order(10, self.team, self.user,
                                            TeamOrder.OrderType.ACTIVITY,
                                            TeamOrder.OrderPaymentMethod.WXPAY,
                                            self.activity.id,
                                            title="UserOrderTest"
                                            )

        self.activity.add_member(self.user.id,
                                 users_count=1,
                                 price=10,
                                 free_times=0,
                                 total_fee=10,
                                 order_id=self.order.id,
                                 order_no=self.order.order_no,
                                 payment_method=TeamOrder.OrderPaymentMethod.WXPAY,
                                 payment_state=TeamOrder.OrderState.TRADE_BUYER_PAID,
                                 state=TeamMember.TeamMemberState.normal)
Пример #2
0
    def post(self, *args, **kwargs):

        # 检查创建数量是否超限
        self.check_create_throttle()

        form = self.validated_arguments
        team = Team.create(owner_id=self.current_user.id, **form)

        self.set_status(201)
        self.write(TeamSerializer(instance=team).data)
Пример #3
0
 def initial_data(self):
     self.team_owner = User.create(name='test_activity')
     self.team = Team.create(name='club_test_activity',
                             owner_id=self.team_owner.id)
     self.user = self.creator = User.create(name='activity_creator')
     self.activity = Activity.create(team=self.team,
                                     creator=self.creator,
                                     price='10',
                                     vip_price='8',
                                     leader=self.creator,
                                     title='just a test',
                                     description='description')
 def initial_data(self):
     self.team_owner = User.create(name='test_activity')
     self.team = Team.create(name='club_test_activity',
                             owner_id=self.team_owner.id)
     self.user = self.creator = User.create(name='activity_creator')
     self.activity = Activity.create(team=self.team,
                                     creator=self.creator,
                                     price='10',
                                     vip_price='8',
                                     leader=self.creator,
                                     title='just a test',
                                     description='description',
                                     need_nickname=True,
                                     join_end="3000-12-30 22:59:59",
                                     max_members=10,
                                     start_time='3000-01-01 00:00:01',
                                     end_time='3000-12-31 23:59:59')
     self.activity_2 = Activity.create(team=self.team,
                                       creator=self.creator,
                                       price='10',
                                       vip_price='8',
                                       leader=self.creator,
                                       title='just a test',
                                       description='description',
                                       need_nickname=True,
                                       join_end="3000-12-30 22:59:59",
                                       max_members=10,
                                       start_time='3000-01-01 00:00:01',
                                       end_time='3000-12-31 23:59:59')
     self.activity_member = ActivityMember.create(
         activity=self.activity,
         user=self.user,
         total_fee='0.01',
         nickname="leave activities",
         payment_method=TeamOrder.OrderPaymentMethod.WXPAY.value,
         payment_state=TeamOrder.OrderState.TRADE_BUYER_PAID,
     )
     TeamMemberService.new_order(team=self.team,
                                 activity_id=self.activity.id,
                                 user=self.user,
                                 order_type=TeamOrder.OrderType.ACTIVITY,
                                 payment_method='wxpay',
                                 total_fee=self.activity.price,
                                 payment_fee=self.activity.price,
                                 title='TestLeave')
     TeamOrder.update(state=TeamOrder.OrderState.TRADE_BUYER_PAID)\
         .where(TeamOrder.activity_id == self.activity.id,
                TeamOrder.user == self.user)\
         .execute()
 def initial_data(self):
     self.team_owner = User.create(name='test_activity')
     self.team = Team.create(name='club_test_activity',
                             owner_id=self.team_owner.id)
     self.user = self.creator = User.create(name='activity_creator')
     self.activity = Activity.create(team=self.team,
                                     creator=self.creator,
                                     price='10',
                                     vip_price='8',
                                     leader=self.creator,
                                     title='just a test',
                                     description='description',
                                     start_time='3000-01-01 00:00:01',
                                     end_time='3000-12-31 23:59:59',
                                     max_members=10)
Пример #6
0
 def initial_data(self):
     faker = Faker()
     sport = Sport.create(name=faker.pystr(), description="测试")
     self.team_owner = User.create(name='test_match')
     self.team = Team.create(name='club_test_match',
                             owner_id=self.team_owner.id,
                             sport=sport)
     self.user = self.creator = User.create(name='match_creator')
     self.match = Match.create(
         team_id=self.team.id,
         user_id=self.user.id,
         sport_id=sport.id,
         price=10,
         title='just a test',
         description='description',
         start_time='3000-01-01 00:00:01',
         end_time='3000-12-31 23:59:59',
         join_start="2016-01-01 00:00:01",
         join_end="2999-12-31 23:59:59",
         state=Match.MatchState.opening.value,
     )
    def initial_data(self):
        self.leader = User.create(name="imleader")
        self.team = Team.create(name="test_finish_activity",
                                owner_id=self.leader.id)
        self.activity = Activity.create(
            team=self.team,
            creator=self.leader,
            leader=self.leader,
            title="test_finish_activity",
            description="test_stoped_activity",
            price=Decimal(15),
            max_members=30,
            start_time=datetime.datetime.now() - datetime.timedelta(hours=2),
            end_time=datetime.datetime.now() - datetime.timedelta(hours=1),
            payment_type=0,
            repeat_type="weekly",
            state=Activity.ActivityState.opening)

        self.online_paid_amount = 0

        for i in range(0, 5):
            user = User.create(name="test_%s" % i)
            order = TeamOrder.create(
                team=self.team,
                user=user,
                order_type=0,
                activity_id=self.activity.id,
                title="test_finish",
                order_no=TeamOrder.get_new_order_no(),
                credit_fee=0,
                total_fee=self.activity.price,
                payment_fee=self.activity.price,
                payment_method="wxpay",
                state=TeamOrder.OrderState.TRADE_BUYER_PAID,
                paid=self.activity.start_time,
                created=self.activity.start_time,
                finished=self.activity.start_time)
            ActivityMember.create(
                team=self.team,
                activity=self.activity,
                user=user,
                price=self.activity.price,
                users_count=1,
                total_fee=self.activity.price,
                payment_state=order.state,
                payment_method="wxpay",
                order_id=order.id,
                order_no=order.order_no,
                state=ActivityMember.ActivityMemberState.confirmed,
                free_times=0,
            )

            self.online_paid_amount += self.activity.price

        for i in range(0, 3):
            user = User.create(name="test2_%s" % i)
            order = TeamOrder.create(team=self.team,
                                     user=user,
                                     order_type=0,
                                     activity_id=self.activity.id,
                                     title="test_finish",
                                     order_no=TeamOrder.get_new_order_no(),
                                     credit_fee=0,
                                     total_fee=self.activity.price,
                                     payment_fee=self.activity.price,
                                     payment_method="wxpay",
                                     state=TeamOrder.OrderState.WAIT_BUYER_PAY,
                                     created=self.activity.start_time,
                                     finished=self.activity.start_time)
            ActivityMember.create(
                team=self.team,
                activity=self.activity,
                user=user,
                price=self.activity.price,
                users_count=1,
                total_fee=self.activity.price,
                payment_state=order.state,
                payment_method="wxpay",
                order_id=order.id,
                order_no=order.order_no,
                state=ActivityMember.ActivityMemberState.wait_confirm,
                free_times=0,
            )