コード例 #1
0
def test_push_mama_coupon_audit():
    from flashsale.coupon.models.transfer_coupon import CouponTransferRecord

    coupon_record = CouponTransferRecord.objects.first()
    print coupon_record.id
    push = WeixinPush()
    push.push_mama_coupon_audit(coupon_record)
コード例 #2
0
def test_push_pintuan():
    from flashsale.pay.models.teambuy import TeamBuy

    customer = Customer.objects.filter(mobile='15716692522').first()
    push = WeixinPush()
    teambuy = TeamBuy.objects.filter(id=1).first()
    push.push_pintuan_need_more_people(teambuy, customer)
コード例 #3
0
def task_push_new_mama_task(xlmm, current_task, params=None):
    """
    通知完成某新手任务,同时提醒下一个任务
    """
    return  # 暂时关闭新手任务推送

    from shopapp.weixin.apis import WeixinPush
    from flashsale.xiaolumm.models.new_mama_task import NewMamaTask

    next_task = xlmm.get_next_new_mama_task()

    header = NewMamaTask.get_push_msg(current_task, params=params)[0]

    if next_task:
        footer = NewMamaTask.get_push_msg(next_task, params=params)[1]
        to_url = NewMamaTask.get_push_msg(next_task, params=params)[2]
    else:
        footer = u'\n恭喜你,完成所有新手任务。'
        to_url = ''

    if not params:
        params = {'task_name': NewMamaTask.get_task_desc(current_task)}
    else:
        params['task_name'] = NewMamaTask.get_task_desc(current_task)

    wxpush = WeixinPush()
    wxpush.push_new_mama_task(xlmm.id,
                              header=header,
                              footer=footer,
                              to_url=to_url,
                              params=params)
コード例 #4
0
def task_weixin_push_update_app(app_visit):
    device_type = app_visit.device_type
    device = ''

    if device_type == app_visit.DEVICE_MOZILLA:
        # dont send push message if user visit via browser
        return
    elif device_type == app_visit.DEVICE_ANDROID:
        device = 'Android'
    elif device_type == app_visit.DEVICE_IOS:
        device = 'IOS'

    user_version = app_visit.get_user_version()
    latest_version = app_visit.get_latest_version()

    if user_version == latest_version:
        # already latest, no need to push udpate reminder
        return

    from shopapp.weixin.apis import WeixinPush
    wp = WeixinPush()

    mama_id = app_visit.mama_id
    to_url = "http://m.xiaolumeimei.com/sale/promotion/appdownload/"

    wp.push_mama_update_app(mama_id,
                            user_version,
                            latest_version,
                            to_url,
                            device=device)
コード例 #5
0
def send_weixin_push(sender, instance, created, **kwargs):
    if not created:
        return

    from shopapp.weixin.apis import WeixinPush
    wxpush = WeixinPush()
    wxpush.push_event(instance)
コード例 #6
0
ファイル: refund.py プロジェクト: xiaolusys/xiaolusys
    def send_refund_agree_weixin_message(self):
        # type : () -> None
        from flashsale.xiaolumm.models import WeixinPushEvent
        from shopapp.weixin.apis import WeixinPush

        push = WeixinPush()
        push.push_refund_notify(
            self, WeixinPushEvent.SALE_REFUND_AGREE)  # 推送同意退款微信消息
コード例 #7
0
def task_weixin_push_mama_coupon_audit(coupon_record):
    """
    精品券审核申请推送
    """
    from shopapp.weixin.apis import WeixinPush

    push = WeixinPush()
    push.push_mama_coupon_audit(coupon_record)
コード例 #8
0
def task_weixin_push_mama_invite_award(mama,
                                       buy_customer,
                                       amount,
                                       level_1_customer=None):
    wp = WeixinPush()
    wp.push_mama_invite_award(mama,
                              buy_customer,
                              amount,
                              level_1_customer=level_1_customer)
コード例 #9
0
def task_weixin_push_invite_trial(potential_mama):
    from flashsale.xiaolumm.models import PotentialMama, ReferalRelationship, AwardCarry

    referal_mama_id, potential_mama_id = potential_mama.referal_mama, potential_mama.potential_mama

    res = PotentialMama.objects.filter(
        referal_mama=referal_mama_id,
        created__lt=potential_mama.created).values('is_full_member').annotate(
            n=Count('is_full_member'))
    trial_num, convert_num = 0, 0
    for entry in res:
        if entry['is_full_member'] == True:
            convert_num = entry['n']
        if entry['is_full_member'] == False:
            trial_num = entry['n']

    trial_num += 1
    invite_num = trial_num + convert_num

    if invite_num < 2:
        target_num = 2
        award_num = 5
    elif invite_num < 5:
        target_num = 5
        award_num = 10
    elif invite_num < 10:
        target_num = 10
        award_num = 15
    else:
        target_num = (invite_num / 5 + 1) * 5
        award_num = 10

    # 距离下一步推荐1元妈妈奖金人数
    diff_num = target_num - invite_num

    # 一元邀请奖金+推荐完成新手任务奖金
    ac = AwardCarry.objects.filter(
        mama_id=referal_mama_id, carry_type__gte=6,
        carry_type__lte=7).aggregate(n=Sum('carry_num'))
    award_sum = ac['n'] or 0
    award_sum = award_sum * 0.01

    # 当前妈妈目前推荐正式妈妈可获奖金
    from flashsale.xiaolumm import utils
    rr_cnt = ReferalRelationship.objects.filter(
        referal_from_mama_id=referal_mama_id).count()
    rr_cnt += 1
    carry_num = utils.get_award_carry_num(rr_cnt, XiaoluMama.FULL)
    carry_num = carry_num * 0.01

    from shopapp.weixin.apis import WeixinPush
    wp = WeixinPush()

    wp.push_mama_invite_trial(referal_mama_id, potential_mama_id, diff_num,
                              award_num, invite_num, award_sum, trial_num,
                              carry_num)
コード例 #10
0
ファイル: refund.py プロジェクト: xiaolusys/xiaolusys
    def send_refund_success_weixin_message(self):
        # type : () -> None
        """发送退款成功微信推送
        """
        from flashsale.xiaolumm.models import WeixinPushEvent
        from shopapp.weixin.apis import WeixinPush

        push = WeixinPush()
        push.push_refund_notify(
            self, WeixinPushEvent.SALE_REFUND_GOODS_SUCCESS)  # 推送退款成功微信消息
コード例 #11
0
    def send_goods_backed_message(self):
        """
        功能: 发送 用户的退货 已经到达仓库的 消息给用户
        """
        from shopapp.weixin.apis import WeixinPush
        from flashsale.xiaolumm.models import WeixinPushEvent

        salerefund = self.get_sale_refund()
        if not salerefund:
            return
        push = WeixinPush()
        push.push_refund_notify(salerefund, WeixinPushEvent.SALE_REFUND_ARRIVE)
        return
コード例 #12
0
def task_weixin_push_awardcarry(awardcarry):
    from shopapp.weixin.apis import WeixinPush
    wp = WeixinPush()

    from flashsale.xiaolumm import util_description
    courage_remarks = util_description.get_awardcarry_courage_remarks(
        awardcarry.carry_type)

    to_url = 'http://m.xiaolumeimei.com'
    if awardcarry.carry_type == 1 or awardcarry.carry_type == 2:
        to_url = 'http://m.xiaolumeimei.com/rest/v2/mama/redirect_stats_link?link_id=1'

    wp.push_mama_award(awardcarry, courage_remarks, to_url)
コード例 #13
0
def test_main():
    ordercarry = OrderCarry.objects.get(id=10)
    push = WeixinPush()
    remarks = u'来自好友%s,快打开App看看她买了啥~' % ordercarry.contributor_nick
    to_url = 'http://m.xiaolumeimei.com/sale/promotion/appdownload/'
    # push.push_mama_ordercarry(ordercarry, remarks, to_url)
    mama_id = 1
    user_version = '1.1'
    latest_version = '1.2'
    # push.push_mama_update_app(mama_id, user_version, latest_version, remarks, to_url)
    # saletrade = SaleTrade.objects.get(id=1)
    # push.push_trade_pay_notify(saletrade)
    # push.push_deliver_notify(saletrade)
    # salerefund = SaleRefund.objects.get(id=11)
    # push.push_refund_notify(salerefund)
    awardcarry = AwardCarry.objects.get(id=1)
    courage_remarks = 'remark'
    to_url = ''
    push.push_mama_award(awardcarry, courage_remarks, to_url)
コード例 #14
0
def task_weixin_push_clickcarry(clickcarry, fake=False):
    wp = WeixinPush()
    wp.push_mama_clickcarry(clickcarry, fake=fake)
コード例 #15
0
def test_push_clickcarry():
    from flashsale.xiaolumm.models.models_fortune import ClickCarry

    push = WeixinPush()
    clickcarry = ClickCarry.objects.filter().order_by('-created').first()
    push.push_mama_clickcarry(clickcarry)
コード例 #16
0
def test_push_salerefund():
    from flashsale.pay.models import SaleRefund
    salerefund = SaleRefund.objects.get(id=54103)
    push = WeixinPush()
    push.push_refund_notify(salerefund, 9)
コード例 #17
0
def task_push_mission_state_msg_to_weixin_user(mission_record_id, state):
    """state: staging,任务未完成状态通知; finished,任务完成奖励通知; confirm,任务奖励确认通知; cancel,任务奖励取消通知;"""
    try:
        from shopapp.weixin.apis import WeixinPush
        mama_mission = MamaMissionRecord.objects.filter(
            id=mission_record_id).first()
        if not settings.MAMA_MISSION_PUSH_SWITCH and mama_mission.mama_id > 135:
            return

        base_mission = mama_mission.mission
        if not base_mission.is_push_msg:
            return

        mama_grade = MamaSaleGrade.objects.filter(
            mama_id=mama_mission.mama_id).first()
        wxpush = WeixinPush()
        if state == MamaMissionRecord.STAGING:
            week_end_time = datetime.datetime.strptime(
                '%s-0' % mama_mission.year_week, '%Y-%W-%w')
            mission_kpi_unit = base_mission.kpi_type == MamaMission.KPI_COUNT and u'个' or u'元'

            head_title = u'女王,您本周还有一个任务未完成,点击查看奖励规则!'
            if mama_grade and base_mission.cat_type == MamaMission.CAT_SALE_MAMA:
                mama_grade_params = {
                    'grade': mama_grade.get_grade_display(),
                    'combo': mama_grade.combo_count
                }
                head_title = u'女王,您本周销售任务奖励等级为{grade}级,连续达标{combo}次,点击查看奖励规则!'.format(
                    **mama_grade_params)

            params = {
                'header':
                head_title,
                'footer':
                u'小鹿妈妈在截止日期前完成任务可获取额外奖励 (本周业绩越好,下周可获取额外奖励越高,点击查看奖励规则).',
                'task_name':
                mama_mission.get_mission_name(),
                'award_amount':
                u'¥%.2f' % mama_mission.get_award_amount(),
                'deadline':
                u'%s' % week_end_time.strftime('%Y-%m-%d'),
                'target_state':
                u'已完成 %s %s/(目标数 %s %s)' %
                (mama_mission.get_finish_value(), mission_kpi_unit,
                 mama_mission.get_target_value(), mission_kpi_unit),
                'description':
                base_mission.desc,
            }

            wxpush.push_mission_state_task(
                mama_mission.mama_id,
                header=params.get('header'),
                footer=params.get('footer'),
                to_url=constants.WEEKLY_AWARD_RULES_URL,
                params=params)

        elif state == MamaMissionRecord.FINISHED:
            params = {
                'header':
                u'女王,本周有一任务已完成,奖励已生成,请到小鹿美美app任务列表查看吧!',
                'footer':
                u'小鹿妈妈在截止日期前完成任务可获取额外奖励 (妈妈销售奖励预计收益,需7天后变成确认收益,退款会影响收益到账哦).',
                'task_name':
                u'%s, 赏¥%.2f元' % (mama_mission.get_mission_name(),
                                  mama_mission.get_award_amount()),
                'task_type':
                base_mission.get_cat_type_display(),
                'finish_time':
                mama_mission.finish_time
            }
            wxpush.push_new_mama_task(mama_mission.mama_id,
                                      header=params.get('header'),
                                      footer=params.get('footer'),
                                      to_url=constants.WEEKLY_AWARD_RULES_URL,
                                      params=params)

        elif state == MamaMissionRecord.CONFIRM:
            params = {
                'header':
                u'女王,(%s)周任务奖励已到账,请到小鹿美美app任务列表查看吧!' % mama_mission.year_week,
                'footer':
                u'小鹿妈妈在截止日期前完成任务可获取额外奖励 (本周业绩越好,下周可获取额外奖励越高,点击查看奖励规则).',
                'task_name':
                u'%s, 赏¥%.2f元' % (mama_mission.get_mission_name(),
                                  mama_mission.get_award_amount()),
                'task_type':
                base_mission.get_cat_type_display(),
                'finish_time':
                mama_mission.finish_time
            }
            wxpush.push_new_mama_task(mama_mission.mama_id,
                                      header=params.get('header'),
                                      footer=params.get('footer'),
                                      to_url=constants.WEEKLY_AWARD_RULES_URL,
                                      params=params)

        elif state == MamaMissionRecord.CANCEL:
            week_end_time = datetime.datetime.strptime(
                '%s-0' % mama_mission.year_week, '%Y-%W-%w')
            mission_kpi_unit = base_mission.kpi_type == MamaMission.KPI_COUNT and u'个' or u'元'
            params = {
                'header':
                u'女王,您有笔交易退款,导致(%s)周销售任务未达预期奖励取消,请到小鹿美美app任务列表查看吧!' %
                mama_mission.year_week,
                'footer':
                u'妈妈销售奖励预计收益,需7天后变成确认收益,退款会影响收益到账哦( 如有疑问请咨询客服热线: 400-823-5355,点击查看奖励规则)',
                'task_name':
                mama_mission.get_mission_name(),
                'award_amount':
                u'¥%.2f' % mama_mission.get_award_amount(),
                'deadline':
                u'%s' % week_end_time.strftime('%Y-%m-%d'),
                'target_state':
                u'已完成 %s %s/(目标数 %s %s)' %
                (mama_mission.get_finish_value(), mission_kpi_unit,
                 mama_mission.get_target_value(), mission_kpi_unit),
                'description':
                base_mission.desc,
            }
            wxpush.push_mission_state_task(
                mama_mission.mama_id,
                header=params.get('header'),
                footer=params.get('footer'),
                to_url=constants.WEEKLY_AWARD_RULES_URL,
                params=params)

    except Exception, exc:
        raise task_push_mission_state_msg_to_weixin_user.retry(exc=exc)
コード例 #18
0
ファイル: tasks.py プロジェクト: xiaolusys/xiaolusys
def task_push_trade_pay_notify(saletrade):
    weixin_push = WeixinPush()
    weixin_push.push_trade_pay_notify(saletrade)