本文整理汇总了Python中core.models.User.pharmacy方法的典型用法代码示例。如果您正苦于以下问题:Python User.pharmacy方法的具体用法?Python User.pharmacy怎么用?Python User.pharmacy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.User
的用法示例。
在下文中一共展示了User.pharmacy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getdmuser
# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import pharmacy [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()