当前位置: 首页>>代码示例>>Python>>正文


Python User.pharmacystores方法代码示例

本文整理汇总了Python中core.models.User.pharmacystores方法的典型用法代码示例。如果您正苦于以下问题:Python User.pharmacystores方法的具体用法?Python User.pharmacystores怎么用?Python User.pharmacystores使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.models.User的用法示例。


在下文中一共展示了User.pharmacystores方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getdmuser

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import pharmacystores [as 别名]
def getdmuser():
    html = StringIO()
    url = r'%sgetuser'%DMURL
    print datetime.now()
    print url
    c = pycurl.Curl()
    c.setopt(pycurl.URL, url)
    c.setopt(pycurl.SSL_VERIFYHOST, False)
    c.setopt(pycurl.SSL_VERIFYPEER, False)
    c.setopt(pycurl.WRITEFUNCTION, html.write)
    c.setopt(pycurl.FOLLOWLOCATION, 1)
    c.perform()
    
    ll = str(html.getvalue())
    users = json.loads(ll)
    for u in users:
        user = User()
        p = User_Phone.query.filter(db.or_(User_Phone.phone == u['phone'],User_Phone.phone == u['phone2'])).first()
        purchases = u['name']+u'于'+u['gmdate']+u' 在 '+u['gmaddress']+u' 购买了大盒'+str(u['gmbigcount'])+u'盒,小盒'+str(u['gmsmallcount'])+u'盒,备注:'+u['remark']+u',电话:'+u['phone']+','+u['phone2']+u',年龄:'+str(u['ages'])+u',性别:'+u['gender']+u',区域:'+u['area']
        if p:
            pass#如果存在,不处理20141224
#            user = User.query.get_or_404(p.user_id)
#            user.operator_id = 1
#            user.origin = int(u['origin'])
#            user.user_type = 5#服务客户
#            #user.assign_operator_id = 1            
#            user.purchases = str(user.purchases)+purchases
#            user.qxhdm_user_id = u['id']
#            user.area = u['area']
#            user.pharmacy = u['pharmacy']
#            user.promoters = u['promoters']
#            user.pharmacystores = u['pharmacystores']
#
#            user.qxhdm_time = datetime.now().strftime('%Y-%m-%d')
#            db.session.add(user)
#            
#            #分配记录
#            assign_log = User_Assign_Log()
#            assign_log.user_id = user.user_id
#            assign_log.assign_operator_id = None
#            assign_log.operator_id = 1
#            assign_log.user_type = user.user_type
#            db.session.add(assign_log)


        else:            
            user.operator_id = 1
            user.origin = int(u['origin'])
            user.user_type = 5#服务客户
            #user.assign_operator_id = 1
            user.name = u['name']
            user.phone = u['phone']
            user.phone2 = u['phone2']
            user.gender = u['gender']
            user.ages = u['ages']
            user.is_new = u['is_new']
            user.disease = u['disease']
            user.fugou = u['fugou']
            user.remark = u['remark']
            user.area = u['area']
            user.pharmacy = u['pharmacy']
            user.promoters = u['promoters']
            user.pharmacystores = u['pharmacystores']
            user.purchases = purchases
            user.qxhdm_user_id = u['id']

            user.qxhdm_time = datetime.now().strftime('%Y-%m-%d')
            db.session.add(user)
            db.session.flush()

            #分配记录
            assign_log = User_Assign_Log()
            assign_log.user_id = user.user_id
            assign_log.assign_operator_id = None
            assign_log.operator_id = 1
            assign_log.user_type = user.user_type
            db.session.add(assign_log)

            db.session.add(User_Phone.add_phone(user.user_id,user.phone))
            if user.phone2:
                db.session.add(User_Phone.add_phone(user.user_id,user.phone2))

        url = r'%supdateuser?id=%s&user_id=%s'%(DMURL,u['id'],user.user_id)
        print url
        c = pycurl.Curl()
        c.setopt(pycurl.URL, url)
        c.setopt(pycurl.SSL_VERIFYHOST, False)
        c.setopt(pycurl.SSL_VERIFYPEER, False)
        c.setopt(pycurl.WRITEFUNCTION, html.write)
        c.setopt(pycurl.FOLLOWLOCATION, 1)
        c.perform()

        db.session.commit()
开发者ID:coco369,项目名称:qxh_ecp,代码行数:95,代码来源:dmmanage.py


注:本文中的core.models.User.pharmacystores方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。