def second_payagent_ratio(ip, province_id, city_id, area_id): ''' :param order: 省市区平台 :return: 二级分佣比例 ''' zong_id = [province_id, city_id, area_id] user_id = tuple(quchong(zong_id, None)) # 使用execute()执行SQL语句 if len(user_id) == 3: select = "SELECT agent_id,sales_ratio,tco_ratio,free_sales_ratio FROM `ecloud_orders`.`second_payagent_ratio` WHERE `agent_id` IN {0} order by field(agent_id ,{1},{2},{3});".format( user_id, user_id[0], user_id[1], user_id[2]) elif len(user_id) == 2: select = "SELECT agent_id,sales_ratio,tco_ratio,free_sales_ratio FROM `ecloud_orders`.`second_payagent_ratio` WHERE `agent_id` IN {0} order by field(agent_id ,{1},{2});".format( user_id, user_id[0], user_id[1]) else: select = "SELECT agent_id,sales_ratio,tco_ratio,free_sales_ratio FROM `ecloud_orders`.`second_payagent_ratio` WHERE `agent_id` = {0};".format( user_id[0]) data = SQL(ip).do_mysql_dict(select) data = xunzhao(data) return data
def ratio(ip, province_id, city_id, area_id, personal_id): zong_id = [province_id, city_id, area_id, personal_id] user_id = tuple(quchong(zong_id, None)) if user_id == (): data = None else: # 查上级分佣比例 if len(user_id) == 1: user_id = user_id[0] select = "SELECT user_id,ratio,type FROM ecloud_orders.user_agent_ratio WHERE user_id = {0};".format( user_id) elif user_id != (): select = "SELECT user_id,ratio,type FROM ecloud_orders.user_agent_ratio WHERE user_id in {0};".format( user_id) data = SQL(ip).do_mysql_dict(select) return data
def paixu(province_proportion, city_proportion, area_proportion): ''' :param province_proportion: 省分佣比例 :param city_proportion: 市分佣比例 :param area_proportion: 区分佣比例 :return: 最小的分佣比例 ''' if province_proportion == None: province_proportion = 0 if city_proportion == None: city_proportion = 0 if area_proportion == None: area_proportion = 0 proportion = [province_proportion, city_proportion, area_proportion] proportion = quchong(proportion, 0) min_proportion = min(proportion) return min_proportion
def ratio(self, province_id, city_id, area_id, personal_id): zong_id = [province_id, city_id, area_id, personal_id] user_id = tuple(quchong(zong_id, None)) # 打开数据库连接 db = pymysql.connect(host=self.ip, port=3306, user='******', passwd='iloveyou2016,./', db='ecloud_orders') # 使用cursor()方法创建一个游标对象cur (可以理解为激活数据库) cursor = db.cursor(pymysql.cursors.DictCursor) # 使用execute()执行SQL语句 if user_id == (): data = None else: # 查上级分佣比例 if len(user_id) == 1: user_id = user_id[0] select = "SELECT user_id,ratio,type FROM ecloud_orders.user_agent_ratio WHERE user_id = {0};".format( user_id) elif user_id != (): select = "SELECT user_id,ratio,type FROM ecloud_orders.user_agent_ratio WHERE user_id in {0};".format( user_id) # print("select", select) # 返回 cursor.execute(select) # 使用fetchall()方法获取查询结果 (接收全部的返回结果) data = cursor.fetchall() # print(data) db.close() return data
def userid(self, data, superior): global d, i, j, k, l, h if self.payment_method in ['抵工资', '家人购']: d = data['出钱方'] e = superior['支付服务费分佣'][0]['个人焕商'] f = superior['支付服务费分佣'][1]['区代理商'] g = superior['支付服务费分佣'][1]['市代理商'] h = superior['支付服务费分佣'][1]['省代理商'] i = superior['储备池分佣'][0]['个人焕商'] j = superior['储备池分佣'][1]['区代理商'] k = superior['储备池分佣'][1]['市代理商'] l = superior['储备池分佣'][1]['省代理商'] elif self.payment_method in ['现金', '微信', '支付宝']: # 现金服务费给卖家上级,储备池分佣给买家上级 e = superior['支付服务费分佣'][0]['个人焕商'] f = superior['支付服务费分佣'][1]['区代理商'] g = superior['支付服务费分佣'][1]['市代理商'] h = superior['支付服务费分佣'][1]['省代理商'] i = superior['储备池分佣'][0]['个人焕商'] j = superior['储备池分佣'][1]['区代理商'] k = superior['储备池分佣'][1]['市代理商'] l = superior['储备池分佣'][1]['省代理商'] else: # 易贝、易贝券 d = superior[0]['个人焕商'] e = superior[1]['区代理商'] f = superior[1]['市代理商'] g = superior[1]['省代理商'] a = data['买家'] b = data['卖家'] c = data['平台'] if self.payment_method == '易贝': if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): userid = [ a, a, a, c, c, c, c, b, a, d, e, f, g, c, c, d, e, f, g, c ] elif self.buyer_identity == "公海用户": userid = [a, a, a, c, c, c, c, b, c, e, f, g, c] else: # 非公海用户 个人焕商不可能为空 userid = [a, a, a, c, c, c, c, b, a, d, e, f, g, c] elif self.payment_method == '易贝券': if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): userid = [a, c, c, b, a, d, e, f, g, c] else: userid = [a, c, c, b] elif self.payment_method in ['抵工资', '家人购']: # 抵工资和家人购跟买家身份关系不大 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or ( self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): # 这里应该理解为企业/家人是公海用户,卖家是个人焕商 userid = [ d, d, d, c, c, c, c, b, a, i, j, k, l, c, c, e, f, g, h, c ] # 企业/家人上级个人、省市区、平台id else: userid = [d, d, d, c, c, c, c, b, c, e, f, g, h, c] # 企业上级个人、省市区、平台id else: # 现金账户、微信、支付宝 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): userid = [ a, c, c, c, b, b, a, i, j, k, l, c, # 储备池买家上级个人、省市区、平台id c, e, f, g, h, c ] # 卖家上级个人、省市区、平台id else: userid = [a, c, c, c, b, b, c, e, f, g, h, c] # 卖家上级个人、省市区、平台id userid = quchong(userid, None) # 去掉为None的列表 return userid
def expected_changes(self, ip, calculation, reserve_fund=None): # 预期变化值 ''' :param charge_amount:未消耗充值金额 :param reserve_fund:储备池金额 :return:变化的金额 ''' global iii sql_data = SQL(ip).wallet_detail(self.order) # 支付数据 if self.payment_method in ['易贝', '抵工资', '家人购']: a = (sql_data[0])[3] # 读取的商品价格 b = (calculation[0])[1] # 买家应出易贝服务费 c = (calculation[0])[2] # 买家应出现金服务费 if self.payment_method == "易贝": d = (calculation[1])[0] # 储备池买家上级个人焕商分佣 e = (calculation[1])[1] # 储备池买家上级区代理商分佣 f = (calculation[1])[2] # 储备池买家上级市代理商分佣 g = (calculation[1])[3] # 储备池买家上级省代理商分佣 h = (calculation[1])[4] # 储备池平台分佣 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): i = (calculation[2])[0] # 易贝服务费买家上级个人焕商分佣 j = (calculation[2])[1] # 易贝服务费买家上级区代理商分佣 k = (calculation[2])[2] # 易贝服务费买家上级市代理商分佣 l = (calculation[2])[3] # 易贝服务费买家上级省代理商分佣 m = (calculation[2])[4] # 易贝服务费平台分佣 iii = [ a, b * -1, c * -1, a * -1, b, c, a, a * -1, reserve_fund * -1, d, e, f, g, h, b * -1, i, j, k, l, m ] elif self.buyer_identity == "公海用户": # i = (calculation[1])[0] # 易贝服务费买家上级个人焕商分佣 j = (calculation[1])[1] # 易贝服务费买家上级区代理商分佣 k = (calculation[1])[2] # 易贝服务费买家上级市代理商分佣 l = (calculation[1])[3] # 易贝服务费买家上级省代理商分佣 m = (calculation[1])[4] # 易贝服务费平台分佣 iii = [ a, b * -1, c * -1, a * -1, b, c, a, a * -1, b * -1, j, k, l, m ] else: i = (calculation[1])[0] # 易贝服务费买家上级个人焕商分佣 j = (calculation[1])[1] # 易贝服务费买家上级区代理商分佣 k = (calculation[1])[2] # 易贝服务费买家上级市代理商分佣 l = (calculation[1])[3] # 易贝服务费买家上级省代理商分佣 m = (calculation[1])[4] # 易贝服务费平台分佣 iii = [ a, b * -1, c * -1, a * -1, b, c, a, a * -1, b * -1, i, j, k, l, m ] else: # 抵工资、家人购 d = (calculation[1])[0] # 储备池买家上级个人焕商分佣 e = (calculation[1])[1] # 储备池买家上级区代理商分佣 f = (calculation[1])[2] # 储备池买家上级市代理商分佣 g = (calculation[1])[3] # 储备池买家上级省代理商分佣 h = (calculation[1])[4] # 储备池平台分佣 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): i = (calculation[2])[0] # 易贝服务费买家上级个人焕商分佣 j = (calculation[2])[1] # 易贝服务费买家上级区代理商分佣 k = (calculation[2])[2] # 易贝服务费买家上级市代理商分佣 l = (calculation[2])[3] # 易贝服务费买家上级省代理商分佣 m = (calculation[2])[4] # 易贝服务费平台分佣 iii = [ a, b * -1, c * -1, a * -1, b, c, a, a * -1, reserve_fund * -1, d, e, f, g, h, b * -1, i, j, k, l, m ] # print("iii",iii) else: i = (calculation[1])[0] # 易贝服务费买家上级个人焕商分佣 j = (calculation[1])[1] # 易贝服务费买家上级区代理商分佣 k = (calculation[1])[2] # 易贝服务费买家上级市代理商分佣 l = (calculation[1])[3] # 易贝服务费买家上级省代理商分佣 m = (calculation[1])[4] # 易贝服务费平台分佣 iii = [ a, b * -1, c * -1, a * -1, b, c, a, a * -1, b * -1, i, j, k, l, m ] elif self.payment_method == '易贝券': a = (sql_data[0])[3] # 读取的商品价格 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): b = calculation[0] # 计算用的商品价格 d = (calculation[1])[0] # 储备池买家上级个人焕商分佣 e = (calculation[1])[1] # 储备池买家上级区代理商分佣 f = (calculation[1])[2] # 储备池买家上级市代理商分佣 g = (calculation[1])[3] # 储备池买家上级省代理商分佣 h = (calculation[1])[4] # 储备池平台分佣 iii = [a, b, b * -1, b, reserve_fund * -1, d, e, f, g, h] # print("易贝券") else: b = calculation # 计算用的商品价格 iii = [a, b, b * -1, b] else: # 现金 a = (sql_data[0])[3] # 读取的商品价格 b = (calculation[0])[0] # 计算得到的商品价格 c = (calculation[0])[1] # 卖家需要支付的现金服务费 o = b - c # 卖家实际应收到的金额 if (self.buyer_identity == "公海用户" and self.seller_identity == "个人焕商") or (self.buyer_identity == "公海用户" and self.seller_identity == "非焕商且已绑定个人焕商"): d = (calculation[1])[0] # 储备池买家上级个人焕商分佣 e = (calculation[1])[1] # 储备池买家上级区代理商分佣 f = (calculation[1])[2] # 储备池买家上级市代理商分佣 g = (calculation[1])[3] # 储备池买家上级省代理商分佣 h = (calculation[1])[4] # 储备池平台分佣 i = (calculation[2])[0] # 现金服务费卖家上级个人焕商分佣 j = (calculation[2])[1] # 现金服务费卖家上级区代理商分佣 k = (calculation[2])[2] # 现金服务费卖家上级市代理商分佣 l = (calculation[2])[3] # 现金服务费卖家上级省代理商分佣 m = (calculation[2])[4] # 现金服务费平台分佣 iii = [ a, o, c, o * -1, b, c * -1, reserve_fund * -1, d, e, f, g, h, c * -1, i, j, k, l, m ] else: i = (calculation[1])[0] # 现金服务费卖家上级个人焕商分佣 j = (calculation[1])[1] # 现金服务费卖家上级区代理商分佣 k = (calculation[1])[2] # 现金服务费卖家上级市代理商分佣 l = (calculation[1])[3] # 现金服务费卖家上级省代理商分佣 m = (calculation[1])[4] # 现金服务费平台分佣 iii = [a, o, c, o * -1, b, c * -1, c * -1, i, j, k, l, m] # 精华 我把分佣等于0的值去掉 就意味不分佣给这些人 iii = quchong(iii, 0) return iii