async def customer_product_config_approve_send(ns={}): """ 线下充值冲账审核提交 orgid – 机构 id user_id – 内部用户id business_id – 业务id form_component – 表单参数 result_org – 被执行机构 19013902201256182163 190139022024060493 284535551524374520 供应商: $provider, 产品: $product, 折扣: $discount, 客户: $customer 客户产品配置(运营配置折扣底价 销售对某个客户某个产品 配置折扣底价) :param ns: :return: """ db = DBPools() async with db.sqlorContext('kboss') as sor: try: # 获取供应商别名 provider_alias_name = (await sor.R('provider', {'orgid': ns.get('providerid')}))[0]['name'] # 如果是批量customerid 获取userid if ns.get('customerid'): ns['userid'] = (await sor.R('users', {'orgid': ns.get('customerid')}))[0]['id'] # 获取客户名称 如何没有 bid_orgid 就是配置统一所有客户 if not ns.get('offer_orgid'): ns['customer'] = '所有客户' else: # 查找客户名称 customer_name = (await sor.R('organization', {'id': ns.get('bid_orgid')}))[0]['orgname'] ns['customer'] = customer_name if not ns.get('productname'): return { 'status': False, 'msg': '没有传递字段 productname' } # 获取配置项(折扣/底价) if ns.get('discount'): project = '折扣' origin_res = ns.get('shangji_discount') content_res = ns.get('productname') + '配置的折扣是: ' + ns.get('discount') # 对比折扣 # if origin_res != '回佣产品': # if float(origin_res) >= float(content_res): # return { # 'status': False, # 'msg': '折扣不能低于供应商提供的折扣' # } else: project = '底价' origin_res = ns.get('floorprice') content_res = ns.get('productname') + '配置的低价是: ' + ns.get('price') # if float(origin_res) >= float(content_res): # return { # 'status': False, # 'msg': '售价不能低于供应商提供的底价' # } # 添加回调flag if ns['customer'] == '所有客户': ns['callback_flag'] = 'uniform_discount' if ns.get('discount') else 'uniform_price' business_id = (await sor.R('apv_business', {'business_name': '分销商产品配置', 'del_flg': '0'}))[0]['id'] else: ns['callback_flag'] = 'single_discount' if ns.get('discount') else 'single_price' business_id = (await sor.R('apv_business', {'business_name': '客户产品配置', 'del_flg': '0'}))[0]['id'] user_li = await sor.R('users',{'id':ns['userid']}) issue_approvecode = await issue_approve(phone=user_li[0]['mobile'], orgid=user_li[0]['orgid'], user_id=ns['userid'], business_id=business_id, form_component={"title": {"": ""}, 'detail': {'customer': ns['customer'], 'project': project, 'origin': provider_alias_name, 'content': content_res}}, apv_json=json.dumps(ns)) if issue_approvecode['status'] == True: return {'status': True, 'msg': '提交成功,请等待审核'} else: print('审批提交失败: %s' % issue_approvecode.get('msg')) return {'status': False, 'msg': '提交失败', 'error': issue_approvecode.get('msg')} except Exception as e: raise e return {'status': False, 'msg': '提交失败'} ret = await customer_product_config_approve_send(params_kw) return ret