Commit 2c00c1f7 by 朱继来

调整导出

parent e512d37c
......@@ -6,6 +6,8 @@ use Illuminate\Support\Facades\Redis;
use Request;
use Excel;
use DB;
use App\Model\OrderPriceModel;
use App\Model\UserMainModel;
class OrderModel extends Model
{
......@@ -36,7 +38,7 @@ class OrderModel extends Model
// ->leftJoin('lie_order_shipping as s', function($join) {
// $join->on('o.order_id', '=', 's.order_id')->where('s.shipping_type', '=', 1);
// })
->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
// ->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
// ->leftJoin('lie_user_company as c', 'o.user_id', '=', 'c.user_id')
->where(function ($query) use ($map) {
// 查询类型
......@@ -46,11 +48,16 @@ class OrderModel extends Model
} else if($map['order_type'] == 4) { // 会员ID
$query->where('o.user_id', '=', $map['order_contain']);
} else { // 会员账号
$user_map = [];
if (preg_match('/@/', $map['order_contain'])) {
$query->where('u.email', '=', $map['order_contain']);
$user_map['email'] = $map['order_contain'];
} else {
$query->where('u.mobile', '=', $map['order_contain']);
$user_map['mobile'] = $map['order_contain'];
}
$user_id = UserMainModel::where($user_map)->value('user_id');
$query->where('o.user_id', '=', $user_id);
}
}
})
......@@ -235,12 +242,12 @@ class OrderModel extends Model
$query->where('i.inv_type', '=', $map['order_invoice_status']);
}
})
->where(function ($query) use ($map) {
// 是否为新用户
if ($map['is_new'] != '') {
$query->where('u.is_new', '=', $map['is_new']);
}
})
// ->where(function ($query) use ($map) {
// // 是否为新用户
// if ($map['is_new'] != '') {
// $query->where('u.is_new', '=', $map['is_new']);
// }
// })
->where(function ($query) use ($map) {
// 是否新订单
if ($map['is_new_order'] != '') {
......@@ -261,7 +268,7 @@ class OrderModel extends Model
})
->where('it.status', 1)
->where('o.order_goods_type', '=', $map['order_goods_type'])
->select('o.order_id', 'o.order_sn', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'it.extra_price', 'it.goods_discount_amount', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc')
->select('o.order_id', 'o.order_sn', 'o.user_id', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'it.extra_price', 'it.goods_discount_amount', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc')
->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC')
// ->get()
......@@ -272,6 +279,8 @@ class OrderModel extends Model
$list['data'] = $this->exportList($list['data']); // 订单数据处理
}
// 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test',
return $list;
// dump($list->getBindings());
// dump($list->toSql());
......@@ -366,6 +375,10 @@ class OrderModel extends Model
return strtoupper($item['order_id'].'.'.$item['price_type']);
})->toArray();
// 获取用户信息
$UserMainModel = new UserMainModel();
$user_info = $UserMainModel->whereIn('user_id', $all_user_id)->select('mobile', 'email', 'client_source', 'is_new', 'is_test', 'user_id')->get()->keyBy('user_id')->toArray();
// 获取用户公司名称
$UserCompanyModel = new UserCompanyModel();
$company_info = $UserCompanyModel->whereIn('user_id', $all_user_id)->lists('com_name', 'user_id')->toArray();
......@@ -379,6 +392,16 @@ class OrderModel extends Model
$order_shipping = $OrderShippingModel->where('shipping_type', 1)->whereIn('order_id', $all_order_id)->select('order_id', 'status')->get()->keyBy('order_id')->toArray();
for ($i = 0; $i < count($order); $i++) {
$user = isset($user_info[$order[$i]['user_id']]) ? $user_info[$order[$i]['user_id']] : '';
if (!$user) {
$user['mobile'] = '';
$user['email'] = '';
$user['client_source'] = '';
$user['is_new'] = '';
$user['is_test'] = '';
}
$current_com_name = isset($company_info[$order[$i]['user_id']]) ? $company_info[$order[$i]['user_id']] : ''; // 当前公司
$current_order_addr = isset($order_address[$order[$i]['order_id']]) ? $order_address[$order[$i]['order_id']] : ''; // 当前订单收货地址
$current_order_shipping = isset($order_shipping[$order[$i]['order_id']]) ? $order_shipping[$order[$i]['order_id']] : ''; // 当前订单物流
......@@ -387,7 +410,7 @@ class OrderModel extends Model
$tmp[$i]['order_sn'] = "\t".$order[$i]['order_sn']."\t";
$tmp[$i]['erp_sn'] = "\t".$order[$i]['erp_sn']."\t";
$tmp[$i]['jd_order_id'] = "\t".$order[$i]['jd_order_id']."\t";
$tmp[$i]['user_account'] = $order[$i]['mobile'] ? $order[$i]['mobile'] : $order[$i]['email'];
$tmp[$i]['user_account'] = isset($user['mobile']) ? $user['mobile'] : $user['email'];
// $tmp[$i]['is_new'] = $order[$i]['is_new'] == 1 ? '是' : '否'; // 是否为新用户
$tmp[$i]['consignee'] = isset($current_order_addr['consignee']) ? $current_order_addr['consignee']."\t" : '';
......@@ -463,12 +486,12 @@ class OrderModel extends Model
$tmp[$i]['send_remark'] = '';
} else {
$tmp[$i]['adtags'] = $order[$i]['order_source'];
$tmp[$i]['client_source'] = $order[$i]['client_source'];
$tmp[$i]['client_source'] = $user['client_source'];
$tmp[$i]['cancel_reason'] = $order[$i]['cancel_reason'];
$tmp[$i]['send_remark'] = $order[$i]['send_remark'];
}
$tmp[$i]['is_test'] = $order[$i]['is_test'] == 1 ? '是' : '否';
$tmp[$i]['is_test'] = $user['is_test'] == 1 ? '是' : '否';
if ($order[$i]['order_goods_type'] == 2) {
$tmp[$i]['sale_type'] = $order[$i]['sale_type'] == 1 ? '现卖' : '预售';
......@@ -559,9 +582,6 @@ class OrderModel extends Model
}
return $result[0]['region_name'].$suffix;
}
// 获取自营商品型号
......@@ -575,9 +595,9 @@ class OrderModel extends Model
// 订单金额展示
public function getOrderPrice($order_id, $type)
{
$price = DB::connection('order')->table('lie_order_price')->where('order_id', '=', $order_id)->where('price_type', '=', $type)->select('price')->first();
$price = OrderPriceModel::where('order_id', '=', $order_id)->where('price_type', '=', $type)->value('price');
return $price ? $price->price : 0;
return $price ? $price : 0;
}
// 获取订单来源
......
......@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Redis;
use Request;
use Excel;
use DB;
use App\Model\ShippingModel;
class OrderReturnModel extends Model
{
......@@ -161,9 +162,7 @@ class OrderReturnModel extends Model
// 获取物流名称
public function getShippingName($shipping_id)
{
$shipping = DB::connection('order')->table('lie_shipping')->where('shipping_id', $shipping_id)->select('shipping_name')->first();
return $shipping ? $shipping->shipping_name : '';
return ShippingModel::where('shipping_id', $shipping_id)->value('shipping_name');
}
// 审核
......
......@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
use App\Model\RegionModel;
class PaymentDaysModel extends Model
{
......@@ -60,7 +61,7 @@ class PaymentDaysModel extends Model
})
->select($Select)->first()->toArray();
if(!$info) return false;
$address=DB::connection('order')->table('lie_region')->whereIn('region_id',[$info['com_area_id'],$info['com_city_id'],$info['com_province_id']])->lists('region_name','region_id');
$address=RegionModel::whereIn('region_id',[$info['com_area_id'],$info['com_city_id'],$info['com_province_id']])->lists('region_name','region_id');
$info['address']=$address;
return $info;
}
......
......@@ -4,6 +4,7 @@ namespace App\Model\Pcb;
use App\Map\PcbOrderMap;
use App\Model\UserMainModel;
use App\Model\UserCompanyModel;
use Illuminate\Database\Eloquent\Model;
use Request;
use DB;
......@@ -107,7 +108,7 @@ class PcbOrderModel extends Model
$shipping = $con->table('shipping')->where(['relevance_id' => $v['order_id'],'shipping_type'=>1])->first();
$v['shipping_no'] = $shipping ? $shipping->shipping_no : "";
$v['shipping_name'] = $shipping ? $shipping->shipping_name : "";
$userCompany = DB::connection('order')->table("lie_user_company")->where("user_id",$v['user_id'])->first();
$userCompany = UserCompanyModel::where("user_id",$v['user_id'])->first();
$v['company_name'] = $userCompany ? $userCompany->com_name : "" ;
}
return $data;
......
......@@ -209,7 +209,7 @@
</dd>
</dl>
@endif
<dl>
<!-- <dl>
<dt>用户标签:</dt>
<dd>
<select id="is_new" name="is_new" class="form-control is_new selectpicker" title="全部">
......@@ -219,7 +219,7 @@
<option value="2">老客户</option>
</select>
</dd>
</dl>
</dl> -->
@endif
<dl>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment