diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php
index 27cc12e2..966a661c 100644
--- a/api/controllers/plan/Order.php
+++ b/api/controllers/plan/Order.php
@@ -508,21 +508,16 @@ class Order extends CI_Controller{
foreach ($rows as $item) {
$if_usedcar = $item['if_usedcar'];
- $biz = $this->biz_model->get(['id'=>$item['biz_id']]);
- $cost = $srv_json_cost = array();
- if ($recost || $debug){
- $cost = $this->items_cost_model->get(array('o_id'=>$item['id']));
- $srv_json_cost = json_decode($cost['srv_json'], true);
- echo $this->items_cost_model->db->last_query()."
";
- }
-
if ($debug){
echo "finance_id: {$item['finance_id']}"."
";
echo "biz_id: {$item['biz_id']}"."
";
echo "status: {$item['status']}"."
";
echo "if_usedcar: {$if_usedcar}"."
";
echo "
";
+ }
+ $biz = $this->biz_model->get(['id'=>$item['biz_id']]);
+ if ($debug){
echo "get biz:
";
echo $this->biz_model->db->last_query()."
";
var_dump($biz);
@@ -530,6 +525,16 @@ class Order extends CI_Controller{
echo "biz_type: {$biz['type']}"."
";
echo "
";
}
+
+ $cost = $srv_json_cost = array();
+ if ($recost || $debug){
+ $cost = $this->items_cost_model->get(array('o_id'=>$item['id']));
+ $srv_json_cost = json_decode($cost['srv_json'], true);
+ echo "get cost:
";
+ echo $this->items_cost_model->db->last_query()."
";
+ echo "
";
+ }
+
$money_json = json_decode($item['money_json'],true);
$info_json = json_decode($item['info_json'],true);
$bill_time_month = date('Y-m-d',strtotime($item['bill_time']));
@@ -934,7 +939,7 @@ class Order extends CI_Controller{
var_dump($add_data);
if ($cost){
- echo "
";
+ echo "
get cost data:
";
var_dump($cost);
echo "
";
echo "c_time: ".date("Y-m-d H:i:s",$cost['c_time'])."
";
@@ -948,6 +953,7 @@ class Order extends CI_Controller{
if ($recost){
unset($add_data['c_time']);
$id = $this->items_cost_model->update($add_data, array('o_id' => $item['id']));
+ $id && $id = $cost['id']; # 如有更新,强制为cost.id
}
else{
$id = $this->items_cost_model->add($add_data);