Browse Source

结账单

shish 4 years ago
parent
commit
e5f32ca65e
1 changed files with 22 additions and 6 deletions
  1. 22 6
      console/controllers/InitController.php

+ 22 - 6
console/controllers/InitController.php

@@ -735,12 +735,28 @@ class InitController extends Controller
             $ghsInfo = GhsClass::getByIds($batchGhsId, null, 'id');
             foreach ($clearBatch as $clear) {
                 $id = $clear['id'];
-                $customId = $clear['customId'] ?? 0;
-                $ghsId = $clear['ghsId'] ?? 0;
-                $customShopId = $customInfo[$customId]['shopId'] ?? 0;
-                $ghsShopId = $ghsInfo[$ghsId]['shopId'] ?? 0;
-                $params = ['customShopId' => $customShopId, 'ghsShopId' => $ghsShopId];
-                ClearClass::updateById($id, $params);
+                $clearStyle = $clear['clearStyle'] ?? 1;
+                if ($clearStyle != dict::getDict('clearStyle', 'gys2KmGys')) {
+                    $customId = $clear['customId'] ?? 0;
+                    $ghsId = $clear['ghsId'] ?? 0;
+                    $customShopId = $customInfo[$customId]['shopId'] ?? 0;
+                    $ghsShopId = $ghsInfo[$ghsId]['shopId'] ?? 0;
+                    $params = ['customShopId' => $customShopId, 'ghsShopId' => $ghsShopId];
+                    ClearClass::updateById($id, $params);
+                } else {
+                    $currentGhsId = $clear['ghsId'] ?? 0;
+                    if (empty($currentGhsId)) {
+                        echo "出现空的ghsId clearId:{$id} \n";
+                        continue;
+                    }
+                    $currentGhs = GhsClass::getById($currentGhsId, true);
+                    $currentCustomId = $currentGhs->customId ?? 0;
+                    $currentCustom = CustomClass::getById($currentCustomId, true);
+                    $customShopId = $currentCustom->shopId ?? 0;
+                    $ghsShopId = $currentGhs->shopId ?? 0;
+                    $params = ['customShopId' => $customShopId, 'customId' => $currentCustomId, 'ghsShopId' => $ghsShopId];
+                    ClearClass::updateById($id, $params);
+                }
             }
         }
     }