edit-admin-order

This commit is contained in:
lccsw
2022-04-13 14:02:26 +08:00
parent 485baac16f
commit 3cef15bd00
5 changed files with 144 additions and 33 deletions
@@ -71,7 +71,11 @@ class Orders extends HD_Controller
$where_s["{$t2}.status in ({$key2},{$up_key})"] = null;
}
$where_s = array_merge($where,$where_s);
$count2 = $this->receiver_orders_v2_model->selectOrders($where_s,'','', '', 1);
$having = 'total = 1';
if($key==0 && $key2==1){ //已付款
$having = 'total >= 1';
}
$count2 = $this->receiver_orders_v2_model->selectOrders($where_s,'','', '', 1,'',$having);
}else{
$where_s = [
"id not in (select o_id from lc_receiver_order_status where pid_status={$value['pid_status']} and status=1)" => null
@@ -721,6 +725,9 @@ class Orders extends HD_Controller
$url = http_host_com('api').'/pdfapi/add_pdf?oid='.$row['id'];
$pdf_res = file_get_contents($url);
}
if($row['order_time'] == '0000-00-00 00:00:00'){ //更新下定时间
$this->receiver_orders_v2_model->update(['order_time' => date('Y-m-d H:i:s',strtotime($pay_time))], ['id' => $row['id']]);
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
@@ -765,7 +772,7 @@ class Orders extends HD_Controller
}
$re_data = $this->receiver_order_datas_model->get(['o_id'=>$id]);
if(!$re_data){
$re_data_id = $this->eceiver_order_datas_model->add(['c_time'=>time(),'o_id'=>$id]);
$re_data_id = $this->receiver_order_datas_model->add(['c_time'=>time(),'o_id'=>$id]);
}else{
$re_data_id = $re_data['id'];
}
+47 -11
View File
@@ -122,6 +122,16 @@ class Ordersv2List
$where["{$this->t1}.c_time <="] = strtotime($c_time[1] . ' 23:59:59');
}
}
//下定时间
if ($params['order_time']) {
$order_time = explode(' ~ ', $params['order_time']);
if ($order_time[0]) {
$where["{$this->t1}.order_time >="] = strtotime($order_time[0] . ' 00:00:00');
}
if ($order_time[1]) {
$where["{$this->t1}.order_time <="] = strtotime($order_time[1] . ' 23:59:59');
}
}
//开票时间
if ($params['bill_time']) {
$bill_time = explode(' ~ ', $params['bill_time']);
@@ -191,7 +201,8 @@ class Ordersv2List
}
$fileds = "{$this->t1}.id,{$this->t1}.name,{$this->t1}.mobile,{$this->t1}.brand_id,{$this->t1}.s_id,{$this->t1}.v_id,
{$this->t1}.cor_id,{$this->t1}.incor_id,{$this->t1}.money_json,{$this->t1}.payway,{$this->t1}.status,{$this->t1}.c_time,
{$this->t1}.biz_id,{$this->t1}.bill_time,{$this->t1}.customer_id,{$this->t1}.owner_name,{$this->t1}.owner_mobile,{$this->t1}.main_type,{$this->t1}.info_json";
{$this->t1}.biz_id,{$this->t1}.bill_time,{$this->t1}.customer_id,{$this->t1}.owner_name,{$this->t1}.owner_mobile,{$this->t1}.main_type,{$this->t1}.info_json,
{$this->t1}.order_time,{$this->t1}.bill_time";
if($params['status_pid']==3){
$where["{$this->t1}.id in (select o_id from lc_receiver_order_status where pid_status=0 and status=2)"] = null;
}
@@ -202,8 +213,12 @@ class Ordersv2List
$where["{$this->t2}.pid_status"] = $params['status_pid'];
$up_key = $params['status']+1;
$where["{$this->t2}.status in ({$params['status']},{$up_key})"] = null;
$count = $this->ci->mdOrders->selectOrders($where,'', '', '', 1);
$rows = $this->ci->mdOrders->selectOrders($where, "c_time desc", $page, $size, '',$fileds);
$having = "total = 1";
if($params['status_pid']==0 && $params['status']==1){
$having = "total >= 1";
}
$count = $this->ci->mdOrders->selectOrders($where,'', '', '', 1,'',$having);
$rows = $this->ci->mdOrders->selectOrders($where, "c_time desc", $page, $size, '',$fileds,$having);
}else{
if(strlen($params['status'])){
$where["id not in (select o_id from lc_receiver_order_status where pid_status={$params['status_pid']} and status=1)"] = null;
@@ -282,8 +297,13 @@ class Ordersv2List
$fields['biz_name'] = $bizs[$val['biz_id']];
$fields['c_time'] = date('Y-m-d H:i:s', $val['c_time']);
$fields['cf_title'] = $customers[$val['customer_id']][0]['cf_title'];
$fields['cf_clues'] = $customers[$val['customer_id']][0]['cf_clues'];
$fields['cf_name'] = $cfroms[$customers[$val['customer_id']][0]['cf_id']][0]['title'];
$cf_name = $cfroms[$customers[$val['customer_id']][0]['cf_id']][0]['title'];
$cf_clues = $customers[$val['customer_id']][0]['cf_clues'];
$fields['cf_name'] = '';
$cf_name && $fields['cf_name'] = $cf_name.'(线上)<br>';
$cf_clues && $fields['cf_name'] .= $cf_clues.'(线下)';
$fields['order_time'] = $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '';
$fields['bill_time'] = $val['bill_time'] != '0000-00-00 00:00:00' ? $val['bill_time'] : '';
$lists[] = $fields;
}
}
@@ -311,12 +331,28 @@ class Ordersv2List
} else {
$fields1['name'] = ['title' => '客户', 'width' => '14%'];
}
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
if(strlen($status_pid) && $status_pid==0){
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'order_time' => ['title' => '下定时间', 'width' => '9%']];
}elseif($status_pid==3){
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'bill_time' => ['title' => '开票时间', 'width' => '9%']];
}else{
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
}
$fields = array_merge($fields1, $fields2);
return $fields;
}
+41 -18
View File
@@ -218,6 +218,29 @@
<input name="vin" type="text" value="<?= $params['vin'] ?>"/>
</div>
</div>
<?if(strlen($params['status_pid']) && $params['status_pid']==0){?>
<div class="am-form-group fl">
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<label class="am-para-label w100">下定时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="order-time" name="order_time" type="text" value="<?= $params['order_time'] ?>"
placeholder="下定时间范围" autocomplete="off"/>
</div>
</div>
</div>
<?}?>
<?if($params['status_pid']==3 && $params['status']==1){?>
<div class="am-form-group fl">
<label class="am-para-label w100">开票时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-bill-time" name="bill_time" type="text" value="<?= $params['bill_time'] ?>"
placeholder="订单时间范围" autocomplete="off"/>
</div>
</div>
</div>
<?}?>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml10">
@@ -247,6 +270,10 @@
<table class="am-table am-table-bordered">
<thead>
<tr>
<? foreach ($fieldAry as $v) { ?>
<th width="<?= $v['width'] ?>"><span><?= $v['title'] ?></span></th>
<? } ?>
<!--
<th width="14%"><span>客户</span></th>
<th width="24%"><span>车辆</span></th>
<th width="11%"><span>门店</span></th>
@@ -256,27 +283,17 @@
<th width="10%"><span>来源</span></th>
<th width="8%"><span>状态</span></th>
<th width="12%"><span>订单时间</span></th>
-->
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['name'] ?></td>
<td><?= $v['car_name'] ?></td>
<td><?= $v['biz_name'] ?></td>
<td><?= $v['price'] ?></td>
<td><?= $v['payway_name'] ?></td>
<td><?= $v['cf_title'] ?></td>
<td>
<?if($v['cf_name']){?><?= $v['cf_name'] ?>(线上)<br><?}?>
<?if($v['cf_clues']){?><?= $v['cf_clues'] ?>(线下)<?}?>
</td>
<td><?= $v['status_name'] ?></td>
<td><?= $v['c_time'] ?></td>
</tr>
<?php }
} ?>
<? foreach ($lists as $v) { ?>
<tr>
<? foreach ($fieldAry as $key => $val) { ?>
<td><?= $v[$key] ?></td>
<? } ?>
</tr>
<? } ?>
</tbody>
</table>
</div>
@@ -293,6 +310,12 @@
laydate.render({
elem: '#id-create-time', range: '~'
});
laydate.render({
elem: '#order-time', range: '~'
});
laydate.render({
elem: '#id-bill-time', range: '~'
});
$('.id-day-btn').click(function () {
var type = $(this).data('date'), date = '', d_obj = new Date();
switch (type) {
+45
View File
@@ -169,4 +169,49 @@ class Order extends CI_Controller{
echo "no data";
}
}
public function up_order_time(){
$size = $this->input->get('size');
!$size && $size = 20;
$t1 = 'lc_receiver_order_status';
$t2 = 'lc_receiver_orders_v2';
$fields = "$t2.*";
$where = [
"$t1.pid_status" => 0,
"$t1.status" => 1,
"$t2.id>=" => 10000,
"$t2.order_time" => '0000-00-00 00:00:00',
];
$this->db->from("$t1");
$this->db->join("$t2", "$t2.id=$t1.o_id",'left');
$this->db->select($fields);
$this->db->where($where);
$this->db->order_by("$t1.id asc");
$this->db->limit($size);
$rows = $this->db->get()->result_array();
if($rows){
foreach($rows as $key=>$val){
$where = [
'o_id'=>$val['id'],
'status'=>1,
"pay_time <>" => '0000-00-00 00:00:00',
];
$pay_row = $this->app_liche_orders_model->select($where,'pay_time asc',1,1);
if($pay_row){
$order_time = $pay_row[0]['pay_time'];
$res = $this->receiver_orders_v2_model->update(['order_time'=>$order_time],['id'=>$val['id']]);
echo "订单id:{$val['id']},更新{$res}<br>";
}else{
echo "订单id:{$val['id']},未找到支付订单<br>";
}
}
}else{
echo "no data";
}
}
}
@@ -24,7 +24,7 @@ class Receiver_orders_v2_model extends HD_Model
return $this->status_arr;
}
public function selectOrders($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0,$fileds="lc_receiver_orders_v2.*")
public function selectOrders($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0,$fileds="lc_receiver_orders_v2.*",$having="total=1")
{
$this->db->select($fileds.",count(lc_receiver_order_status.status) as total");
$this->db->from('lc_receiver_orders_v2');
@@ -33,7 +33,7 @@ class Receiver_orders_v2_model extends HD_Model
$this->db->where($where);
}
$this->db->group_by('lc_receiver_order_status.o_id');
$this->db->having('total = 1');
$this->db->having("$having");
if ($count) {
$res = $this->db->count_all_results();
return $res ? $res : 0;