order cost add fines about

This commit is contained in:
qianhy
2023-05-31 11:50:58 +08:00
parent 2d93a54596
commit 5929fb9694
+46 -1
View File
@@ -573,10 +573,11 @@ class Order extends CI_Controller{
echo "<br><br>";
}
$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: <br>";
echo $this->items_cost_model->db->last_query()."<br>";
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()."<br>";
}
echo "get cost_json origin: {$cost_json}<br>";var_dump($cost_json);echo("<br>");
echo "get fines: {$fines}<br>";var_dump($fines);echo("<br>");
echo "get fine_ids: {$fine_ids}<br>";var_dump($fine_ids);echo("<br>");
echo "get cost_select_price: {$cost_select_price}<br>";
echo "get cost_json new: {$cost_json}<br>";var_dump($cost_json);
if($debug){
echo("<br><br>");
}
}
//获取创建订单时商务政策
$where = [