diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php
index 7732bb26..950366b9 100644
--- a/api/controllers/plan/Order.php
+++ b/api/controllers/plan/Order.php
@@ -573,10 +573,11 @@ class Order extends CI_Controller{
echo "
";
}
- $cost = $srv_json_cost = array();
+ $cost = $srv_json_cost = $cost_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);
+ $cost_json_cost = $cost['cost_json'] ? json_decode($cost['cost_json'], true) : array();
echo "get cost:
";
echo $this->items_cost_model->db->last_query()."
";
if($debug){
@@ -631,6 +632,50 @@ class Order extends CI_Controller{
//精品
$srv_json['price_fine_select'] = $money_json['price_fine_select'] ? $money_json['price_fine_select'] : 0;
+ $fines = $item['fines'] ? json_decode($item['fines'], true) : array();
+ $fine_ids = array();
+ foreach ($fines as $fine){
+ if ($fine['id'] && $fine['id'] > 0){
+ $fine_ids[] = $fine['id'];
+ }
+ }
+ $cost_json = array();
+ $recost && $cost_json = $cost_json_cost;
+ $cost_select_price = 0; // 根据cost.fines 计算成本
+ $this->load->model('receiver/receiver_fine_model');
+ if ($fine_ids){
+ //$where = ['status' => 1];
+ $where['biz_id'] = $item['biz_id'];
+ $ids = implode(',',$fine_ids);
+ $where = ["id in ($ids)" => null];
+ $sum = $this->receiver_fine_model->sum('price', $where);
+ $cost_select_price = $sum['price'] ? $sum['price'] : 0;
+ }
+ if ($cost_select_price){
+ // $recost下,如$cost_json['select_price'] && $cost_select_price 要recost
+ if ($recost){
+ if (!$cost_json['select_price']){
+ $cost_json['select_price'] = $cost_select_price;
+ }
+ }
+ else{
+ $cost_json['select_price'] = $cost_select_price;
+ }
+ }
+ $cost_json && $add_data['cost_json'] = json_encode($cost_json,JSON_UNESCAPED_UNICODE);
+ if ($recost || $debug){
+ if ($fine_ids){
+ echo $this->receiver_fine_model->db->last_query()."
";
+ }
+ echo "get cost_json origin: {$cost_json}
";var_dump($cost_json);echo("
");
+ echo "get fines: {$fines}
";var_dump($fines);echo("
");
+ echo "get fine_ids: {$fine_ids}
";var_dump($fine_ids);echo("
");
+ echo "get cost_select_price: {$cost_select_price}
";
+ echo "get cost_json new: {$cost_json}
";var_dump($cost_json);
+ if($debug){
+ echo("
");
+ }
+ }
//获取创建订单时商务政策
$where = [