package service import ( "errors" . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity" ) /* * 资源充值 * @param appid * @param function_code 功能代码 * @param account_id 账户id * @param ent_account_id 企业账户id * @param entId 企业id * @param count 充值数量 * @param ids 业务id * @return 状态 0:失败 1:成功 -1:不在有效期内 -2:数量不足 -3:没有授权 -4:超额 */ func Recharge(appid, function_code string, account_id, ent_account_id int64, count int64, ids []string) (int64, error) { if appid == "" { return 0, errors.New("无效的参数appid") } else if function_code == "" { return 0, errors.New("无效的参数function_code") } else if count <= 0 { return 0, errors.New("无效的参数count") } else if account_id == 0 && ent_account_id == 0 { return 0, errors.New("无效的参数account_id、ent_account_id") } function := Base_function.FindByCode(appid, function_code) if function == nil { return 0, errors.New("功能原始表中没有找到该功能") } myPowers := Base_power.FindMyPowersByFc(appid, function_code, account_id, ent_account_id) if myPowers == nil || len(*myPowers) == 0 { return -1, errors.New("功能权益表中没有找到权益记录") } status := Base_resource_use.Recharge(appid, function_code, (*myPowers)[0].Id, account_id, count, ids) if status == 1 { return 1, nil } else if status == -1 { return -4, nil } return 0, nil }