lisenzhou 2 years ago
parent
commit
cd3cca4e99
1 changed files with 68 additions and 34 deletions
  1. 68
    34
      src/subpackages/pages/marketing/changeVisit/index.jsx

+ 68
- 34
src/subpackages/pages/marketing/changeVisit/index.jsx View File

@@ -39,7 +39,7 @@ export default withLayout((props) => {
39 39
     price: "",
40 40
     successDate: "",
41 41
     totalCommission: "", //佣金总额
42
-    currentCommission: 0, //本次结佣
42
+    currentCommission: "", //本次结佣
43 43
   });
44 44
 
45 45
   const [FormData, setFormData] = useState({ ...RenChouData });
@@ -181,9 +181,10 @@ export default withLayout((props) => {
181 181
   // 进入页面带入当前客户的节点状态
182 182
   useEffect(() => {
183 183
     if (channelCustomerInfo?.status && isFirst.current === 1) {
184
-      isFirst.current++
185
-      CutStatus(StatusList.filter((x) => x.id === channelCustomerInfo.status)[0])();
186
-      
184
+      isFirst.current++;
185
+      CutStatus(
186
+        StatusList.filter((x) => x.id === channelCustomerInfo.status)[0]
187
+      )();
187 188
     }
188 189
   }, [channelCustomerInfo]);
189 190
 
@@ -250,6 +251,26 @@ export default withLayout((props) => {
250 251
   };
251 252
 
252 253
   const ToSubmit = () => {
254
+    // let params = {};
255
+    // for (let key in FormData) {
256
+    //   if (key !== "dividendsName" && key !== "dividendsPer") {
257
+    //     params[key] = { ...FormData }[key];
258
+    //     // console.log(
259
+    //     //   "🚀 ~ file: index.jsx ~ line 202 ~ ToSubmit ~ FormData",
260
+    //     //   FormData
261
+    //     // );
262
+    //   }
263
+    // }
264
+
265
+    // console.log(
266
+    //   params,
267
+    //   params.currentCommission,
268
+    //   Number(params.totalCommission || 0) -
269
+    //     Number(channelCustomerInfo?.channelCustomer?.settledCommission || 0) >=
270
+    //     Number(params.currentCommission || 0),
271
+    //   "params"
272
+    // );
273
+    // return;
253 274
     if (CurrentStatusId === 3) {
254 275
       fetch({
255 276
         url: API_SURE_CHIP,
@@ -282,20 +303,19 @@ export default withLayout((props) => {
282 303
       }
283 304
       params.dividendsName = `${FormData.dividendsName}|${FormData.dividendsPer}%`;
284 305
 
285
-      console.log(
286
-        {
287
-          customerId: id,
288
-          customerSignatory: {
289
-            ...params,
290
-            channelId:
291
-              channelId === "null" || channelId === null ? "" : channelId,
292
-            channelCustomerId,
293
-          },
294
-          totalCommission: Number(params.totalCommission) * 100,
295
-          currentCommission: Number(params.currentCommission) * 100,
296
-        },
297
-        "]]]]"
298
-      );
306
+      if (
307
+        Number(params.totalCommission || 0) -
308
+          Number(channelCustomerInfo?.channelCustomer?.settledCommission || 0) <
309
+        Number(params.currentCommission || 0)
310
+      ) {
311
+        Taro.showToast({
312
+          title: "本次结佣金额不能大于剩余未结佣金额",
313
+          icon: "none",
314
+          duration: 3000,
315
+        });
316
+        return;
317
+      }
318
+
299 319
       fetch({
300 320
         url: API_SURE_SIGN,
301 321
         method: "put",
@@ -308,7 +328,7 @@ export default withLayout((props) => {
308 328
             channelCustomerId,
309 329
           },
310 330
           totalCommission: Number(params.totalCommission) * 100,
311
-          currentCommission: Number(params.currentCommission) * 100,
331
+          currentCommission: Number(params.currentCommission || 0) * 100,
312 332
         },
313 333
       }).then(() => {
314 334
         Taro.showToast({ title: "修改成功", icon: "none", duration: 2000 });
@@ -324,6 +344,18 @@ export default withLayout((props) => {
324 344
         }
325 345
       }
326 346
       params.dividendsName = `${FormData.dividendsName}|${FormData.dividendsPer}%`;
347
+      if (
348
+        Number(params.totalCommission || 0) -
349
+          Number(channelCustomerInfo?.channelCustomer?.settledCommission || 0) <
350
+        Number(params.currentCommission || 0)
351
+      ) {
352
+        Taro.showToast({
353
+          title: "本次结佣金额不能大于剩余未结佣金额",
354
+          icon: "none",
355
+          duration: 3000,
356
+        });
357
+        return;
358
+      }
327 359
       fetch({
328 360
         url: API_SURE_BUY,
329 361
         method: "put",
@@ -335,6 +367,9 @@ export default withLayout((props) => {
335 367
               channelId === "null" || channelId === null ? "" : channelId,
336 368
             channelCustomerId,
337 369
           },
370
+
371
+          totalCommission: Number(params.totalCommission) * 100,
372
+          currentCommission: Number(params.currentCommission || 0) * 100,
338 373
         },
339 374
       }).then(() => {
340 375
         Taro.showToast({ title: "修改成功", icon: "none", duration: 2000 });
@@ -354,21 +389,19 @@ export default withLayout((props) => {
354 389
         }
355 390
       }
356 391
       params.dividendsName = `${FormData.dividendsName}|${FormData.dividendsPer}%`;
392
+      if (
393
+        Number(params.totalCommission || 0) -
394
+          Number(channelCustomerInfo?.channelCustomer?.settledCommission || 0) <
395
+        Number(params.currentCommission || 0)
396
+      ) {
397
+        Taro.showToast({
398
+          title: "本次结佣金额不能大于剩余未结佣金额",
399
+          icon: "none",
400
+          duration: 3000,
401
+        });
402
+        return;
403
+      }
357 404
 
358
-      console.log(
359
-        {
360
-          customerId: id,
361
-          customerSignatory: {
362
-            ...params,
363
-            channelId:
364
-              channelId === "null" || channelId === null ? "" : channelId,
365
-            channelCustomerId,
366
-          },
367
-          totalCommission: Number(params.totalCommission) * 100,
368
-          currentCommission: Number(params.currentCommission) * 100,
369
-        },
370
-        "]]]]"
371
-      );
372 405
       fetch({
373 406
         url: API_SURE_ALLPAYMENT,
374 407
         method: "put",
@@ -381,7 +414,7 @@ export default withLayout((props) => {
381 414
             channelCustomerId,
382 415
           },
383 416
           totalCommission: Number(params.totalCommission) * 100,
384
-          currentCommission: Number(params.currentCommission) * 100,
417
+          currentCommission: Number(params.currentCommission || 0) * 100,
385 418
         },
386 419
       }).then(() => {
387 420
         Taro.showToast({ title: "修改成功", icon: "none", duration: 2000 });
@@ -600,6 +633,7 @@ export default withLayout((props) => {
600 633
                   <Input
601 634
                     type="number"
602 635
                     placeholder="请输入金额"
636
+                    disabled={Number(channelCustomerInfo?.channelCustomer?.settledCommission||0) >0}
603 637
                     value={FormData.totalCommission}
604 638
                     onInput={InputChange.bind(this, "totalCommission")}
605 639
                   ></Input>