cost add repair loan_product
This commit is contained in:
@@ -324,6 +324,7 @@ class Order extends CI_Controller{
|
||||
$this->load->model('biz/biz_settle_srv_model');
|
||||
$this->load->model('auto/auto_business_model');
|
||||
$this->load->model('items/items_cost_model');
|
||||
$this->load->model('sys/sys_finance_model');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
$id = $this->input->get('id');
|
||||
@@ -469,7 +470,11 @@ class Order extends CI_Controller{
|
||||
$srv_json['loan_price'] = $money_json['price_loan'];
|
||||
$loan_row = $this->order_loans_model->get(['o_id'=>$item['id']]);
|
||||
$finance_id = $item['finance_id'];
|
||||
$srv_json['loan_product'] = $loan_row['title'];
|
||||
$srv_json['loan_product'] = ''; # $loan_row['title'];
|
||||
if ($finance_id){
|
||||
$finance_row = $this->sys_finance_model->get(array('id'=>$finance_id),'title');
|
||||
$srv_json['loan_product'] = $finance_row ? $finance_row['title'] : '';
|
||||
}
|
||||
$srv_json['loan_num'] = $finance_num = $loan_row['num'] ? $loan_row['num'] : 0;
|
||||
$where = [
|
||||
'biz_id' => $item['biz_id'],
|
||||
@@ -590,4 +595,38 @@ class Order extends CI_Controller{
|
||||
}
|
||||
echo "repair ".count($rows)." rows ok!";
|
||||
}
|
||||
|
||||
public function cost_repair_loan_product(){
|
||||
$this->load->model('items/items_cost_model');
|
||||
$sql = "
|
||||
select c.id, c.o_id, c.srv_json, JSON_UNQUOTE(JSON_EXTRACT(c.srv_json,'$.loan_product')) as loan_product, o.payway, o.finance_id, f.title
|
||||
from lc_items_cost c
|
||||
left join lc_receiver_orders_v2 o on c.o_id = o.id
|
||||
left join lc_sys_finance f on f.id = o.finance_id
|
||||
where o.finance_id > 0
|
||||
and JSON_UNQUOTE(JSON_EXTRACT(c.srv_json,'$.loan_product')) <> f.title
|
||||
";
|
||||
$rows = $this->items_cost_model->db->query($sql)->result_array();
|
||||
if (!$rows){
|
||||
echo "数据不存在";exit();
|
||||
}
|
||||
|
||||
foreach ($rows as $row){
|
||||
$id = $row['id'];
|
||||
$o_id = $row['o_id'];
|
||||
$loan_product = $row['title'];
|
||||
if (!$loan_product){
|
||||
echo "{$id}, o_id: {$o_id}, title not found <br>";
|
||||
continue;
|
||||
}
|
||||
|
||||
$srv_json = json_decode($row['srv_json'],true);
|
||||
$srv_json['loan_product'] = $loan_product;
|
||||
$upd_data['srv_json'] = json_encode($srv_json,JSON_UNESCAPED_UNICODE);
|
||||
$res = $this->items_cost_model->update($upd_data, array('id'=>$id));
|
||||
echo "{$id}, o_id: {$o_id}, update: {$res}<br>";
|
||||
}
|
||||
|
||||
echo "repair ".count($rows)." rows ok!";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user