def add_addsecond(self, afid): asidlist = [] asnamelist = [] addsecond = [ ["滨盛创业园", "潮锦创业园", "江拓创业园"], ["创巢创业园", "下沙网", "浙江省海外留学人员创业园"], ["科技创业中心"], ["创意园区", "嘉得威创业园", "网络文学创业园"], ["江虹国际创业园", "万恒创业园", "京安创业园"], ["打铁关", "西兴", "龙翔桥", "江陵路"], ["白洋", "三墩", "文新", "沈塘桥"], ["新风", "市民中心", "南星桥", "复兴路"], ] for index, data in enumerate(afid): for asname in addsecond[index]: asid = str(uuid.uuid4()) add_model("AddressSecond", **{ "ASid": asid, "AFid": data, "ASname": asname }) asidlist.append(asid) asnamelist.append(asname) return asidlist, asnamelist
def add_product(self, pid): try: add_model( "Products", **{ "PRid": pid[0], "PRname": "测试套餐1", "PRprice": 28.88, "PRstatus": 1, "PRimage": "http://120.79.182.43:7444/imgs/hello.jpg", "PRinfo": "测试数据", "PRsalesvolume": 100, "PRscore": 4.2 }) add_model( "Products", **{ "PRid": pid[1], "PRname": "测试套餐2", "PRprice": 18.88, "PRstatus": 1, "PRimage": "http://120.79.182.43:7444/imgs/hello.jpg", "PRinfo": "测试数据", "PRsalesvolume": 300, "PRscore": 3.2 }) add_model( "Products", **{ "PRid": pid[2], "PRname": "测试套餐3", "PRprice": 9.88, "PRstatus": 1, "PRimage": "http://120.79.182.43:7444/imgs/hello.jpg", "PRinfo": "测试数据", "PRsalesvolume": 120, "PRscore": 3.5 }) add_model( "Products", **{ "PRid": pid[3], "PRname": "测试套餐4", "PRprice": 15.88, "PRstatus": 1, "PRimage": "http://120.79.182.43:7444/imgs/hello.jpg", "PRinfo": "测试数据", "PRsalesvolume": 1001, "PRscore": 2.1 }) add_model( "Products", **{ "PRid": pid[4], "PRname": "测试套餐5", "PRprice": 13.88, "PRstatus": 1, "PRimage": "http://120.79.182.43:7444/imgs/hello.jpg", "PRinfo": "测试数据", "PRsalesvolume": 5, "PRscore": 1.6 }) except Exception as e: print e.message
def add_machinery(self, pridlist, aaidlist): for aaid in aaidlist: for prid in pridlist: add_model("Machinery", **{ "MAid": str(uuid.uuid1()), "AAid": aaid, "PRid": prid })
def add_addabo(self, asidlist, asnamelist): aaid_list = [] for index, i in enumerate(asidlist): aaid = str(uuid.uuid4()) add_model( "AddressAbo", **{ "AAid": aaid, "ASid": i, "AAmessage": asnamelist[index] + "A区拐角机器", "AAimage": "图片地址", }) aaid_list.append(aaid) return aaid_list
def add_coupons(self, coid): try: for row in coid: add_model( "Coupons", **{ "COid": row, "COfilter": 20, "COdiscount": 1, "COamount": None, "COstart": None, "COend": None }) except Exception as e: print e.message
def add_user(self, uid): try: add_model( "Users", **{ "USid": uid, "UStelphone": "17706441101", "USpassword": "******", "USname": "测试账号", "USsex": 101, "UScoin": 100.1, "USinvatecode": "ETECH007" }) except Exception as e: print e.message
def add_or_update_cart(self): args = request.args.to_dict() print(self.title.format("args")) print(args) print(self.title.format("args")) data = json.loads(request.data) print(self.title.format("data")) print(data) print(self.title.format("data")) if "token" not in args: return PARAMS_MISS token = args.get("token") uid = token_to_usid(token) pid = data.get("PRid") CAnumber = data.get("CAnumber") if CAnumber <= 0: PBnumber = self.scart.get_pbnumber_by_pbid_and_usid(pid, uid) pnum = int(CAnumber) + int(PBnumber) if pnum <= 0: return self.del_cart(uid, pid) try: if not self.sproduct.get_pro_info_by_pid(pid): return import_status("ERROR_MESSAGE_NONE_PRODUCT", "SHARPGOODS_ERROR", "ERROR_NONE_PRODUCT") cart = self.scart.get_cart_by_uid_pid(uid, pid) print(self.title.format("cart")) print(cart) print(self.title.format("cart")) if cart: PBnumber = self.scart.get_pbnumber_by_pbid_and_usid(pid, uid) pnum = int(CAnumber) + int(PBnumber) self.scart.update_num_cart(pnum, cart.CAid) else: add_model( "Cart", **{ "CAid": str(uuid.uuid1()), "CAnumber": CAnumber, "USid": uid, "CAstatus": 1, "PRid": pid }) except dberror: return SYSTEM_ERROR except Exception as e: print(e.message) return SYSTEM_ERROR return import_status("SUCCESS_MESSAGE_UPDATE_CART", "OK")
def add_addfirst(self, acid): afidlist = [] addfirst = [ { "name": "萧山区", "aftype": 1 }, { "name": "下沙区", "aftype": 1 }, { "name": "上城区", "aftype": 1 }, { "name": "下城区", "aftype": 1 }, { "name": "滨江区", "aftype": 1 }, { "name": "地铁1号线", "aftype": 0 }, { "name": "地铁2号线", "aftype": 0 }, { "name": "地铁4号线", "aftype": 0 }, ] for data in addfirst: afid = str(uuid.uuid4()) add_model( "AddressFirst", **{ "AFid": afid, "ACid": acid, "AFtype": data["aftype"], "AFname": data["name"], }) afidlist.append(afid) return afidlist
def add_cardpackage(self, coid, uid): try: add_model( "Cardpackage", **{ "CAid": str(uuid.uuid4()), "USid": uid, "COid": coid[0], "CAstatus": 1, "CAstart": "20180423000000", "CAend": "20180429000000" }) add_model( "Cardpackage", **{ "CAid": str(uuid.uuid4()), "USid": uid, "COid": coid[1], "CAstatus": 2, "CAstart": "20180429000000", "CAend": "20180522000000" }) add_model( "Cardpackage", **{ "CAid": str(uuid.uuid4()), "USid": uid, "COid": coid[2], "CAstatus": 2, "CAstart": "20180329000000", "CAend": "20180419000000" }) except Exception as e: print e.message
def create_review(self): args = request.args.to_dict() print(self.title.format("args")) print(args) print(self.title.format("args")) if "token" not in args.keys() or "OMid" not in args.keys(): return PARAMS_MISS token = args.get("token") USid = token_to_usid(token) OMid = get_str(args, "OMid") OMstatus = self.service_order.get_omstatus_by_omid(OMid) if OMstatus >= 49: return import_status("ERROR_MESSAGE_WRONG_OMSTATUS", "LOVEBREAKFAST_ERROR", "ERROR_CODE_WRONG_OMSTATUS") data = request.data data = json.loads(data) print(self.title.format("data")) print(data) print(self.title.format("data")) for row in data: print(self.title.format("data_item")) print(row) print(self.title.format("data_item")) if "PRid" not in row or "REscore" not in row: return PARAMS_MISS if "REcontent" in row: REcontent = row["REcontent"] else: REcontent = None PRid = row["PRid"] REscore = row["REscore"] print(self.title.format("REscore")) print(REscore) print(self.title.format("REscore")) try: add_model( "Review", **{ "REid": str(uuid.uuid1()), "OMid": OMid, "PRid": PRid, "USid": USid, "REscore": REscore, "REcontent": REcontent, "REstatus": 1 }) except Exception as e: print(self.title.format("add_review")) print(e.message) print(self.title.format("add_review")) return SYSTEM_ERROR product_volue = self.service_product.get_product_volume_by_prid( PRid) product_score = self.service_product.get_product_score_by_prid( PRid) score = (product_score * product_volue + REscore) / product_volue product = {"PRscore": score} update_product = self.service_product.update_product_by_prid( PRid, product) print(self.title.format("update_product")) print(update_product) print(self.title.format("update_product")) if not update_product: return SYSTEM_ERROR order = {"OMstatus": 49} update_order = self.service_order.update_ordermain_by_omid( OMid, order) print(self.title.format("update_order")) print(update_order) print(self.title.format("update_order")) if not update_order: return SYSTEM_ERROR back_response = import_status("SUCCESS_MESSAGE_ADD_REVIEW", "OK") return back_response
def add_city(self, acid): add_model("AddCity", **{"ACid": acid, "ACname": "杭州市"})