예제 #1
0
    def test_paid(self):
        YixinAccount.bind(self.local_account.id, 'p2p_account', 'p2p_token')
        YixinAccount.bind(self.another_local_account.id, 'p2p_account_1',
                          'p2p_token_1')

        order_a = HoardOrder.add(self.yixin_service.uuid.hex,
                                 self.local_account.id,
                                 decimal.Decimal('12000.0'), self.fin_order_id)
        order_b = HoardOrder.add(self.yixin_service.uuid.hex,
                                 self.another_local_account.id,
                                 decimal.Decimal('24000.12'),
                                 self.another_fin_order_id)

        assert not order_a.is_success
        assert not order_b.is_success

        order_a.mark_as_paid('102')
        assert order_a.is_success
        assert order_a.order_id == '102'
        assert not order_b.is_success

        order_a = HoardOrder.get(order_a.id_)
        order_b = HoardOrder.get(order_b.id_)
        assert order_a.is_success
        assert order_a.order_id == '102'
        assert not order_b.is_success

        order_b.mark_as_paid('101')
        assert order_b.is_success
        assert order_b.order_id == '101'
예제 #2
0
def genernate_report(filename, date):

    csv_file = open(filename, 'wb')
    writer = csv.writer(csv_file, delimiter=',')
    header = ['理财单号', '订单号', '宜人贷账号', '宜定盈名称', '订单状态', '订单金额', '创建时间']
    writer.writerow(header)
    year, month = date.split('-')

    sql = 'select id from hoard_order where status="C" \
            and year(creation_time)=%s and month(creation_time)=%s'

    params = (year, month)
    rs = db.execute(sql, params)
    orders = [HoardOrder.get(r[0]) for r in rs]

    if orders is not None:
        for order in orders:
            if order.order_id is None:
                continue
            profile = HoardProfile.get(order.user_id)
            yixin_account = YixinAccount.get_by_local(
                profile.account_id) if profile else ''
            p2p_account = yixin_account.p2p_account if yixin_account else ''
            p2p_service_name = (order.service.p2pservice_name
                                if order.service else '')

            if order.status == OrderStatus.paid:
                order_status = '已支付'
            elif order.status == OrderStatus.unpaid:
                order_status = '未支付'
            elif order.status == OrderStatus.confirmed:
                order_status = '已确认'
            elif order.status == OrderStatus.failure:
                order_status = '失败'
            else:
                order_status = '未知'

            line = [
                str(order.fin_order_id),
                str(order.order_id),
                str(p2p_account),
                str(p2p_service_name), order_status,
                int(order.order_amount),
                order.creation_time.strftime('%Y-%m-%d %H:%M')
            ]

            writer.writerow(line)

        csv_file.close()
예제 #3
0
파일: rebate.py 프로젝트: c1xfr2e/soledad
 def order(self):
     return HoardOrder.get(self.order_pk)