def delete_file(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno", "file_type"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) if args["file_type"] in ["sb", "jd", "bzwj", "jdfj"]: if args["file_type"] == "sb": file_type = "申报单" elif args["file_type"] == "jd": file_type = "鉴定文件" elif args["file_type"] == "bzwj": file_type = "包装明细" elif args["file_type"] == "jdfj": file_type = "鉴定附件" else: file_type = "未知文件" id = get_model_return_dict( self.sgoods.get_dgdid_by_url(data["photourl"])) dgd_upload = get_model_return_dict( self.sgoods.get_dgd_by_id(id["id"])) print(dgd_upload) add_model( "AIR_HWYS_DGD_UPLOAD_BAK", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": file_type, "file_url": data["photourl"], "upload_create_time": dgd_upload["create_time"], "uploade_create_user": dgd_upload["create_user"], "delet_time": datetime.datetime.now(), "delet_user": user["username"], "file_name": data["file_name"] }) delete_photo = self.sgoods.delete_dgd_by_id(id["id"]) if not delete_photo: return { "status": 405, "status_code": 405989, "message": "删除失败" } if args["file_type"] in ["out", "weight", "by", "in"]: id = get_model_return_dict( self.sgoods.get_photosid_by_url(data["photourl"])) delete_photo = self.sgoods.delete_photos_by_id(id["id"]) if not delete_photo: return { "status": 405, "status_code": 405989, "message": "删除失败" } return {"status": 200, "message": "删除成功"}
def save_royalty(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) accounts = get_model_return_dict( self.sgoods.get_accounts_by_jcno(args["jcno"])) make_log("accounts", accounts) user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) if args["login_name"] == accounts: return import_status("ERROR_NONE_PERMISSION", "FANSTI_ERROR", "ERROR_NONE_PERMISSION") user_type_location = get_model_return_dict( self.susers.get_user_type(args["login_name"])) if user_type_location["user_type"] not in ["0", "3", "4"]: return {"status": 405, "status_code": 405999, "message": "无权限"} packer_leader = data["packer_leader"] for row in data["packer_list"]: add_model( "AIR_HWYS_PACK_ROYALTY", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "packer_leader": packer_leader, "packer": row["packer"], "royalty_rate": None, "create_date": datetime.datetime.now(), "create_user": user["username"] }) return {"status": 200, "message": "保存成功"}
def update_qrd(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno", "qrd_type"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) accounts = get_model_return_dict( self.sgoods.get_accounts_by_jcno(args["jcno"])) make_log("accounts", accounts) user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) if args["login_name"] == accounts: return import_status("ERROR_NONE_PERMISSION", "FANSTI_ERROR", "ERROR_NONE_PERMISSION") if args["qrd_type"] == "add": add_model( "AIR_HWYS_QRD", **{ "id": str(uuid.uuid1()), "ydno": wts["ydno"], "jcno": args["jcno"], "doc": data["charge_cname"], "curr": data["curr"], "amount": data["amount"], "fkdw": data["company"], "createtime": datetime.datetime.now(), "byzd1": "1", "byzd2": args["login_name"], "rate": "1", "currcode": "CNY" }) if args["qrd_type"] == "update": update_qrd = self.sgoods.update_qrd_by_id( data["id"], { "ydno": wts["ydno"], "jcno": args["jcno"], "doc": data["charge_cname"], "curr": data["curr"], "amount": data["amount"], "fkdw": data["company"], "createtime": datetime.datetime.now(), "byzd1": "1", "byzd2": args["login_name"] }) if not update_qrd: return SYSTEM_ERROR if args["qrd_type"] == "delete": delete = self.sgoods.delete_qrd_by_id(data["id"]) if not delete: return SYSTEM_ERROR return {"status": 200, "message": "编辑成功"}
def add_invate(self): args = request.args.to_dict() make_log("args", args) data = json.loads(request.data) make_log("data", data) true_args = ["openid"] true_data = ["openid"] if judge_keys(true_args, args.keys()) != 200: return judge_keys(true_args, args.keys()) if judge_keys(true_data, data.keys()) != 200: return judge_keys(true_data, data.keys()) wechat_login = get_model_return_dict( self.susers.get_wechat_login_by_openid(data["openid"])) user_invate = get_model_return_dict( self.susers.get_id_by_openid(data["openid"])) if user_invate: return import_status("ERROR_MESSAGE_CLICK", "FANSTI_ERROR", "ERROR_HAVE_INVATED") if wechat_login: return import_status("ERROR_HAVE_INVATED", "FANSTI_ERROR", "ERROR_HAVE_INVATED") new_user_invate = add_model( "USER_INVATE", **{ "id": str(uuid.uuid4()), "args_openid": args["openid"], "invate_openid": data["openid"] }) if not new_user_invate: return SYSTEM_ERROR return import_status("SUCCESS_NEW_INVATE", "OK")
def retrue_outhc(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) accounts = get_model_return_dict( self.sgoods.get_accounts_by_jcno(args["jcno"])) make_log("accounts", accounts) if args["login_name"] == accounts: return import_status("ERROR_NONE_PERMISSION", "FANSTI_ERROR", "ERROR_NONE_PERMISSION") if "retrue_type" not in data.keys(): return {"status": 405, "status_code": 405001, "message": "参数缺失"} user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) print(user) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) if data["retrue_type"] == "out": add_model( "AIR_HWYS_OUTWAREHOUSE", **{ "id": str(uuid.uuid1()), "ydno": wts["ydno"], "submitter": user["username"], "submit_time": datetime.datetime.now(), "create_time": datetime.datetime.now() }) if data["retrue_type"] == "hc": add_model( "AIR_HWYS_INGOODYARD", **{ "id": str(uuid.uuid1()), "ydno": wts["ydno"], "submitter": user["username"], "submit_time": datetime.datetime.now(), "create_time": datetime.datetime.now() }) return {"status": 200, "message": "确认成功"}
def new_news(self): data = json.loads(request.data) make_log("data", data) true_args = ["news_title", "news_all", "news_picture", "news_from"] if judge_keys(true_args, data.keys()) != 200: return judge_keys(true_args, data.keys()) new_news = add_model( "WECHAT_NEWS", **{ "id": str(uuid.uuid4()), "news_title": data["news_title"], "news_all": data["news_all"], "news_picture": data["news_picture"], "news_from": data["news_from"], "news_status": "1", "news_time": datetime.datetime.now() }) if not new_news: return SYSTEM_ERROR return import_status("SUCCESS_NEW_NEWS", "OK")
def make_user_message(self): args = request.args.to_dict() make_log("args", args) data = json.loads(request.data) make_log("data", data) true_args_params = ["openid"] true_data_params = ["message"] if judge_keys(true_args_params, args.keys()) != 200: return judge_keys(true_args_params, args.keys()) if judge_keys(true_data_params, data.keys()) != 200: return judge_keys(true_data_params, data.keys()) phone = get_model_return_dict( self.susers.get_wechat_login(args["openid"]))["phone"] new_message = add_model( "USER_MESSAGE", **{ "id": str(uuid.uuid4()), "phone": phone, "message": data["message"] }) if not new_message: return SYSTEM_ERROR return import_status("SUCCESS_MAKE_MESSAGE", "OK")
def make_sb(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) for row in data["jd_list"]: add_model( "AIR_HWYS_DGD_UPLOAD", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": "鉴定文件", "file_url": row["url"], "create_time": datetime.datetime.now(), "create_user": user["username"], "file_name": row["file_name"] }) for row in data["sb_list"]: add_model( "AIR_HWYS_DGD_UPLOAD", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": "申报单", "file_url": row["url"], "create_time": datetime.datetime.now(), "create_user": user["username"], "file_name": row["file_name"] }) for row in data["bzmx_list"]: add_model( "AIR_HWYS_DGD_UPLOAD", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": "包装明细", "file_url": row["url"], "create_time": datetime.datetime.now(), "create_user": user["username"], "file_name": row["file_name"] }) for row in data["jdfj_list"]: add_model( "AIR_HWYS_DGD_UPLOAD", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": "鉴定附件", "file_url": row["url"], "create_time": datetime.datetime.now(), "create_user": user["username"], "file_name": row["file_name"] }) return {"status": 200, "message": "上传完毕"}
def add_in(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) make_log("data", data) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) # wts中获取jcno/czr/hwpm user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) ckmxd = get_model_return_dict(self.sgoods.get_ckmxd_abo(args["jcno"])) if ckmxd: photo_head = ckmxd["photo_head"] print(photo_head) else: photo_head = None if photo_head: if photo_head == "6": photo_head = int(photo_head) else: photo_head = int(photo_head) + 1 else: photo_head = 1 add_model( "AIR_HWYS_CKMXD", **{ "list_id": str(uuid.uuid1()), "jcno": args["jcno"], "salesman": wts["czr"], "hwpm": data["hwpm"], "warehouse_address": data["warehouse_address"], "enter_time": datetime.datetime.strptime(data["enter_time"], "%Y-%m-%d %H:%M:%S"), "create_time": datetime.datetime.now(), "goods_quantity": data["goods_quantity"], "delivery_unit": data["delivery_unit"], "goods_weight": data["goods_weight"], "cargo_size": data["cargo_size"], "client_name": data["client_name"], "remark": data["remark"], "photo_head": str(photo_head) }) photoheadid = str(uuid.uuid1()) add_model( "AIR_HWYS_PHOTO_HEAD", **{ "id": photoheadid, "photohead": str(photo_head), "jcno": args["jcno"], "type": "in", "createtime": datetime.datetime.now(), "czr": user["username"], "photocount": len(data["pic_list"]) }) for row in data["pic_list"]: add_model( "AIR_HWYS_PHOTOS", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "phototype": "in", "photourl": row["url"], "createtime": datetime.datetime.now(), "czr": user["username"], "filename": row["filename"], "photoheadid": photoheadid }) return {"status": 200, "message": "提交成功"}
def add_new_file(self): args = request.args.to_dict() make_log("args", args) not_null_params = ['login_name', "jcno", "file_type"] if judge_keys(not_null_params, args.keys()) != 200: return judge_keys(not_null_params, args.keys()) data = json.loads(request.data) user = get_model_return_dict( self.susers.get_user_name(args["login_name"])) wts = get_model_return_dict(self.sgoods.get_control_goods( args["jcno"])) if args["file_type"] in ["sb", "jd", "bzwj", "jdfj"]: if args["file_type"] == "sb": file_type = "申报单" elif args["file_type"] == "jd": file_type = "鉴定文件" elif args["file_type"] == "bzwj": file_type = "包装明细" elif args["file_type"] == "jdfj": file_type = "鉴定附件" else: file_type = "未知文件" add_model( "AIR_HWYS_DGD_UPLOAD", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "ydno": wts["ydno"], "file_type": file_type, "file_url": data["url"], "create_time": datetime.datetime.now(), "create_user": user["username"], "file_name": data["file_name"] }) if args["file_type"] in ["out", "weight", "by"]: add_model( "AIR_HWYS_PHOTOS", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "phototype": args["file_type"], "photourl": data["url"], "createtime": datetime.datetime.now(), "czr": user["username"], "filename": data["file_name"] }) if args["file_type"] == "in": print(">>>>>>>>>>>>>>>>>") head = data["head"] print(head) heads = get_model_return_dict( self.sgoods.get_photoheadid_by_head_jcno( args["jcno"], str(head))) print(heads) if not heads: return { "status": 405, "status_code": 405992, "message": "未找到对应批次" } else: headid = heads["id"] add_model( "AIR_HWYS_PHOTOS", **{ "id": str(uuid.uuid1()), "jcno": args["jcno"], "phototype": args["file_type"], "photourl": data["url"], "createtime": datetime.datetime.now(), "czr": user["username"], "filename": data["file_name"], "photoheadid": headid }) return {"status": 200, "message": "保存成功"}
def retrue_goods(self): args = request.args.to_dict() make_log("args", args) data = json.loads(request.data) make_log("data", data) true_args = ["login_name", "jcno"] true_data = ["retrue_name"] if judge_keys(true_args, args.keys()) != 200: return judge_keys(true_args, args.keys()) if judge_keys(true_data, data.keys()) != 200: return judge_keys(true_data, data.keys()) jcno = args["jcno"] goods_retrue = get_model_return_list( self.sgoods.get_in_out_weight_by_jcno(jcno)) if not goods_retrue: in_pic = "0" out_pic = "0" weight_pic = "0" if data["retrue_name"] == "in": in_pic = "1" if data["retrue_name"] == "out": out_pic = "1" import datetime air_hwys_wts = get_model_return_dict( self.sgoods.get_AIR_HWYS_WTS_by_jcno(jcno)) if air_hwys_wts and air_hwys_wts.get( "jd_time") is None and air_hwys_wts.get( "jd_date") is None: # if not(air_hwys_wts and air_hwys_wts.get('jd_time') and air_hwys_wts.get('jd_date')): new_reds = add_model( "GET_RED_COIN", **{ "id": str(uuid.uuid1()), "login_name": args["login_name"], "createtime": datetime.datetime.now(), "red_id": 2, "status": 1 }) if not new_reds: return SYSTEM_ERROR if data["retrue_name"] == "weight": weight_pic = "1" new_goods_retrue = add_model( "GOODS_RETRUE", **{ "id": str(uuid.uuid4()), "login_name": args["login_name"], "in_pic": in_pic, "out_pic": out_pic, "weight_pic": weight_pic, "jcno": args["jcno"] }) if not new_goods_retrue: return SYSTEM_ERROR else: if data["retrue_name"] == "in": id = get_model_return_dict( self.sgoods.get_retrue_by_jcno_in(args["jcno"])) if id: return import_status("ERROR_FAIL_RETRUE", "FANSTI_ERROR", "ERROR_FAIL_RETRUE") else: id_name = get_model_return_dict( self.sgoods.get_retrue_by_jcno_loginname( args["jcno"], args["login_name"])) if not id_name: new_goods_retrue = add_model( "GOODS", **{ "id": str(uuid.uuid4()), "login_name": args["login_name"], "in_pic": "1", "out_pic": "0", "weight_pic": "0", "jcno": args["jcno"] }) if not new_goods_retrue: return SYSTEM_ERROR else: update_goods_retrue = self.sgoods.update_goods_retrue_by_id( id_name["id"], {"in_pic": "1"}) if not update_goods_retrue: return SYSTEM_ERROR elif data["retrue_name"] == "out": id = get_model_return_dict( self.sgoods.get_retrue_by_jcno_out(args["jcno"])) if id: return import_status("ERROR_FAIL_RETRUE", "FANSTI_ERROR", "ERROR_FAIL_RETRUE") else: id_name = get_model_return_dict( self.sgoods.get_retrue_by_jcno_loginname( args["jcno"], args["login_name"])) if not id_name: new_goods_retrue = add_model( "GOODS", **{ "id": str(uuid.uuid4()), "login_name": args["login_name"], "in_pic": "0", "out_pic": "1", "weight_pic": "0", "jcno": args["jcno"] }) if not new_goods_retrue: return SYSTEM_ERROR else: update_goods_retrue = self.sgoods.update_goods_retrue_by_id( id_name["id"], {"out_pic": "1"}) if not update_goods_retrue: return SYSTEM_ERROR import datetime air_hwys_wts = get_model_return_dict( self.sgoods.get_AIR_HWYS_WTS_by_jcno(jcno)) if air_hwys_wts and air_hwys_wts.get( "jd_time") is None and air_hwys_wts.get( "jd_date") is None: # if not(air_hwys_wts and air_hwys_wts.get('jd_time') and air_hwys_wts.get('jd_date')): new_reds = add_model( "GET_RED_COIN", **{ "id": str(uuid.uuid1()), "login_name": args["login_name"], "createtime": datetime.datetime.now(), "red_id": 2, "status": 1 }) if not new_reds: return SYSTEM_ERROR elif data["retrue_name"] == "weight": id = get_model_return_dict( self.sgoods.get_retrue_by_jcno_weight(args["jcno"])) if id: return import_status("ERROR_FAIL_RETRUE", "FANSTI_ERROR", "ERROR_FAIL_RETRUE") else: id_name = get_model_return_dict( self.sgoods.get_retrue_by_jcno_loginname( args["jcno"], args["login_name"])) if not id_name: new_goods_retrue = add_model( "GOODS", **{ "id": str(uuid.uuid4()), "login_name": args["login_name"], "in_pic": "0", "out_pic": "0", "weight_pic": "1", "jcno": args["jcno"] }) if not new_goods_retrue: return SYSTEM_ERROR else: update_goods_retrue = self.sgoods.update_goods_retrue_by_id( id_name["id"], {"weight_pic": "1"}) if not update_goods_retrue: return SYSTEM_ERROR else: return import_status("ERROR_WRONG_VALUE", "FANSTI_ERROR", "ERROR_WRONG_VALUE") # TODO 如果存在红包未领取,则修改红包状态 return import_status("SUCCESS_RETRUE_GOODS", "OK")
def user_binding(self): data = json.loads(request.data) make_log("data", data) true_data = ["phone", "openid"] null_data = [ "login_name", "login_password", "name", "usex", "city", "province" ] wl_key = [ 'status', 'openid', 'province', 'name', 'user_introduction', 'city', 'work_goodat', 'qq', 'login_name', 'work_year', 'phone', 'email', 'wechat', 'user_name', 'id', 'usex' ] wl = {k: data.get(k) for k in wl_key if k in data} import configparser from Fansti.config.Inforcode import FANSTICONFIG cfg = configparser.ConfigParser() cfg.read(FANSTICONFIG) usertype = -111 phone_list = eval(cfg.get("phone", "whitelist")) data["name"] = None if str(data.get("phone")) in phone_list: wechat_login_tmp = get_model_return_dict( self.susers.get_wechat_login_by_phone(data.get("phone"))) if not wechat_login_tmp: if "login_name" in data and "login_password" in data: check_result = self.check_name_password( data.get("login_name"), data.get("login_password")) if check_result: return check_result self.susers.add_model( "WECHAT_LOGIN", **{ "id": str(uuid.uuid1()), "openid": data.get("openid", ""), "login_name": data.get("login_name", ""), "name": data.get("name", ""), "phone": data.get("phone"), "status": data.get("status", "1"), "usex": data.get("usex", ""), "city": data.get("city", ""), "province": data.get("province", "") }) else: if "login_name" in data and "login_password" in data: check_result = self.check_name_password( data.get("login_name"), data.get("login_password")) if check_result: return check_result usertype = get_model_return_dict( self.susers.get_user_type( data.get("login_name"))).get("user_type") update_result = self.susers.update_wechat_login_by_phone( data.get("phone"), wl) if not update_result: return import_status("ERROR_UPDATE_DATA", "FANSTI_ERROR", "ERROR_UPDATE_DATA") response = import_status("SUCCESS_USER_BINDING", "OK") response['data'] = usertype return response if judge_keys(true_data, data.keys(), null_data) != 200: return judge_keys(true_data, data.keys(), null_data) # if self.get_wechat_phone(data["phone"]) != 200: # return self.get_wechat_phone(data["phone"] wl_tmp = get_model_return_dict( self.susers.get_wechat_login_by_phone(data["phone"])) if "login_name" in data and "login_password" in data: check_result = self.check_name_password(data.get("login_name"), data.get("login_password")) if check_result: return check_result usertype = get_model_return_dict( self.susers.get_user_type( data.get("login_name"))).get("user_type") if "login_name" not in data: data["login_name"] = None if "name" not in data: data["name"] = None if "usex" not in data: data["usex"] = None if "city" not in data: data["city"] = None if "province" not in data: data["province"] = None if "id" in wl_tmp: self.susers.update_wechat_login_by_phone(data['phone'], wl) else: add_wechat_login = add_model( "WECHAT_LOGIN", **{ "id": str(uuid.uuid1()), "login_name": data["login_name"], "openid": data["openid"], "status": "1", "phone": data["phone"], "name": data["name"], "usex": data["usex"], "city": data["city"], "province": data["province"] }) make_log("add_wechat_login", add_wechat_login) if not add_wechat_login: return SYSTEM_ERROR # else: # add_wechat_login = add_model("WECHAT_LOGIN", # **{ # "id": str(uuid.uuid1()), # "openid": data["openid"], # "status": "1", # "phone": data["phone"], # "name": data["name"], # "usex": data["usex"], # "city": data["city"], # "province": data["province"] # }) # make_log("add_wechat_login", add_wechat_login) # if not add_wechat_login: # return SYSTEM_ERROR response = import_status("SUCCESS_USER_BINDING", "OK") from Fansti.config.Inforcode import FANSTICONFIG import configparser cf = configparser.ConfigParser() cf.read(FANSTICONFIG) phone_list = cf.get("enquiry", "whitelist") if str(phone_list) == "[]": phone_list = str(phone_list).replace("[", "").replace("]", "") phone_list = list(phone_list) else: phone_list = str(phone_list).replace("[", "").replace("]", "").replace("\"", "") \ .replace("\'", "").replace("\\", "").replace(" ", "").replace("u", "").split(",") print(phone_list) response["data"] = {} response['data']["user_type"] = usertype if data["login_name"] not in phone_list: response["data"]["is_show"] = 0 else: response["data"]["is_show"] = 1 return response