Browse Source

报备单审核时,改变服务费,采购价或销售价随之改变

wufeng 2 years ago
parent
commit
900251b92a
1 changed files with 10 additions and 5 deletions
  1. 10 5
      app/abutment/logic/Filing.php

+ 10 - 5
app/abutment/logic/Filing.php

@@ -128,7 +128,7 @@ class Filing
     {
 
         $rs = Db::name('filing')
-            ->field('id,status')
+            ->field('id,status,is_determine_price,price,cgd_charge')
             ->where(['is_del' => 0, 'id' => $data['id']])
             ->whereIn('status', [0, 2])
             ->findOrEmpty();
@@ -145,13 +145,18 @@ class Filing
             ->findOrEmpty();
         if (empty($tmp)) return json_show(1005, '该平台不存在');
 
+        $update = array_merge($data, [
+            'companyName' => $companyName,
+            'updatetime' => date('Y-m-d H:i:s'),
+        ]);
+
+        if ($rs['is_determine_price'] == 1) $update['cgd_charge'] = round(bcsub($rs['price'], $data['service_charge'], 3), 2);//确定售价时,采购价=售价-服务费
+        else $update['price'] = round(bcadd($rs['cgd_charge'], $data['service_charge'], 3), 2);//不确定售价时,售价=采购价+服务费
+
         $res = Db::name('filing')
             ->where(['is_del' => 0, 'id' => $data['id']])
             ->whereIn('status', [0, 2])
-            ->update(array_merge($data, [
-                'companyName' => $companyName,
-                'updatetime' => date('Y-m-d H:i:s')
-            ]));
+            ->update($update);
         return $res ? json_show(0, '操作成功') : json_show(1004, '操作失败');