{"record":{"id":"2a76698619d3328e","repo":"JeffreySu/WeiXinMPSDK","slug":"tenpayv3profitshareingrequestdata","errorCode":null,"errorMessage":"必须指定待分账的接收方列表","messagePattern":"必须指定待分账的接收方列表","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/V3/Universal/Entities/Request/TenpayV3ProfitShareingRequestData.cs","lineNumber":167,"sourceCode":"        /// <param name=\"receivers\">分账接收方列表,此对象通过Json格式传输</param>\n        public TenpayV3ProtfitSharingRequestData(\n            string appId, string mchId, string subappid, string submchid, string key, string nonceStr,\n            string transactionId,\n            string outOrderNo,\n            TenpayV3ProfitShareingRequestData_ReceiverInfo[] receivers\n        )\n        {\n            AppId = appId;\n            MchId = mchId;\n            NonceStr = nonceStr;\n            Key = key;\n            SubAppId = subappid;\n            SubMchId = submchid;\n            Receivers = receivers;\n\n            if (Receivers == null || Receivers.Length == 0)\n            {\n                throw new ArgumentNullException(\"必须指定待分账的接收方列表\");\n            }\n            TransactionId = transactionId;\n            OutOrderNo = outOrderNo;\n\n\n            #region 设置RequestHandler\n\n            //创建支付应答对象\n            PackageRequestHandler = new RequestHandler(null);\n            //初始化\n            PackageRequestHandler.Init();\n\n            //设置package订单参数\n            //以下设置顺序按照官方文档排序，方便维护：https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1\n            PackageRequestHandler.SetParameter(\"appid\", this.AppId);                       //公众账号ID\n            PackageRequestHandler.SetParameter(\"mch_id\", this.MchId);                      //商户号\n            PackageRequestHandler.SetParameterWhenNotNull(\"sub_appid\", this.SubAppId);     //子商户公众账号ID\n            PackageRequestHandler.SetParameterWhenNotNull(\"sub_mch_id\", this.SubMchId);    //子商户号","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/V3/Universal/Entities/Request/TenpayV3ProfitShareingRequestData.cs#L149-L185","documentation":"The TenpayV3ProtfitSharingRequestData constructor requires a non-empty receivers array (the list of profit-sharing receivers for a WeChat Pay v3 分账 request). If receivers is null or an empty array, an ArgumentNullException with this message is thrown — note the message is passed as paramName, which is unconventional but the check itself is intentional.","triggerScenarios":"Creating a profit-sharing request via new TenpayV3ProtfitSharingRequestData(...) and passing null or new Receiver[0] for the receivers parameter.","commonSituations":"Order had no receivers configured in the merchant system, or the receivers list was filtered to empty before construction, or a copy/paste left the array argument empty in sample-driven code.","solutions":["Build at least one receiver entry (type, account, amount/description) and pass it to the constructor.","Guard at the call site: skip or reject profit-sharing calls when the receiver list is empty.","Fix upstream logic that produces an empty receivers array (e.g. filtering by ratio > 0 removing all entries)."],"exampleFix":"// before\nvar data = new TenpayV3ProtfitSharingRequestData(appid, mchid, null, transactionId, outOrderNo, ...);\n// after\nvar receivers = new[] { new Receiver { Type = \"MERCHANT_ID\", Account = \"190001001\", Amount = 100, Description = \"分账\" } };\nvar data = new TenpayV3ProtfitSharingRequestData(appid, mchid, receivers, transactionId, outOrderNo, ...);","handlingStrategy":"validation","validationCode":"// C#\nif (receivers is null || receivers.Length == 0)\n    throw new InvalidOperationException(\"Profit-sharing needs at least one receiver\");","typeGuard":"bool HasReceivers(Receiver[] r) => r is { Length: > 0 };","tryCatchPattern":"try { var data = new TenpayV3ProtfitSharingRequestData(..., receivers, ...); }\ncatch (ArgumentNullException ex) when (ex.Message.Contains(\"接收方列表\")) { log.LogWarning(\"No receivers configured for order {OrderNo}\", outOrderNo); }","preventionTips":["Decide upfront whether an order participates in profit-sharing; skip the API when not","Validate receivers list before the constructor call","Guard against filters that silently empty the receivers array"],"tags":["null-argument","profit-sharing","weixin-tenpay"],"backgroundTag":"null-argument","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}