Commit 8ff42998 by 朱继来

调整导入

parent 264c3d40
......@@ -4,9 +4,10 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\OrderModel;
use App\Model\UserMainModel;
use App\Model\UserCompanyModel;
use App\Model\OrderModel;
use App\Model\OrderInvoiceModel;
use App\Model\OrderActionLogModel;
use App\Model\PayLogModel;
use DB;
......@@ -152,12 +153,14 @@ class SpecialController extends Controller
if (!$v[0] || !$v[1]) continue;
// 1. 根据手机或邮箱查找客户最近的订单
$order_id = $this->getLastOrderId(trim($v[0]));
$res = $this->getLastOrderId(trim($v[0]));
if ($order_id === false) {
Log::info('客户账号:'.$v[0].',客服邮箱:'.$v[1].',客户无订单');
if ($res['err_code'] != 0) {
Log::info('客户账号:'.$v[0].','.$res['err_msg']);
continue;
}
}
$order_id = $res['data'];
// 2. 根据企业邮箱查找sale_id
$sale_id = $this->getSaleId(trim(strtolower($v[1])));
......@@ -182,28 +185,34 @@ class SpecialController extends Controller
// 获取客户最近的订单
public function getLastOrderId($account)
{
$UserMainModel = new UserMainModel();
$UserCompanyModel = new UserCompanyModel();
$OrderModel = new OrderModel();
$UserMainModel = new UserMainModel();
$UserCompanyModel = new UserCompanyModel();
$OrderModel = new OrderModel();
$OrderInvoiceModel = new OrderInvoiceModel();
if (strpos($account, '@') !== false) { // 邮箱
$where['email'] = strtolower($account);
$user_info = $UserMainModel->where($where)->select('user_id')->first();
$user_info = $UserMainModel->where($where)->select('user_id')->orderBy('user_id', 'desc')->first();
} else if (preg_match('/\d{11}/', $account)) { // 手机号码
$where['mobile'] = $account;
$user_info = $UserMainModel->where($where)->select('user_id')->first();
$user_info = $UserMainModel->where($where)->select('user_id')->orderBy('user_id', 'desc')->first();
} else { // 公司名称
$user_info = $UserCompanyModel->where('com_name', $account)->select('user_id')->first();
// 发票抬头
$order_invoice = $OrderInvoiceModel->where('tax_title', $account)->select('order_id')->orderBy('order_id', 'desc')->first();
if ($order_invoice) return ['err_code' => 0, 'err_msg' => '', 'data' => $order_invoice['order_id']];
$user_info = $UserCompanyModel->where('com_name', $account)->select('user_id')->orderBy('com_id', 'desc')->first();
}
if (!$user_info) return false;
if (!$user_info) return ['err_code' => 1, 'err_msg' => '未找到客户'];
// 查找最近的订单
$order = $OrderModel->where('user_id', $user_info['user_id'])->where('is_type', 0)->select('order_id')->orderBy('order_id', 'desc')->first();
if (!$order) return false;
if (!$order) return ['err_code' => 2, 'err_msg' => '未找到客户订单'];
return $order['order_id'];
return ['err_code' => 0, 'err_msg' => '', 'data' => $order['order_id']];
}
// 获取后台业务ID
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderInvoiceModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_invoice';
protected $primaryKey = 'order_inv_id';
public $timestamps = false;
}
\ No newline at end of file
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