Commit 7efb6fb3 by 朱继来

Merge branch 'zjl_erp_20190923' into development

parents 9d503e30 8ff42998
...@@ -4,9 +4,10 @@ namespace App\Http\Controllers; ...@@ -4,9 +4,10 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\OrderModel;
use App\Model\UserMainModel; use App\Model\UserMainModel;
use App\Model\UserCompanyModel; use App\Model\UserCompanyModel;
use App\Model\OrderModel;
use App\Model\OrderInvoiceModel;
use App\Model\OrderActionLogModel; use App\Model\OrderActionLogModel;
use App\Model\PayLogModel; use App\Model\PayLogModel;
use DB; use DB;
...@@ -152,12 +153,14 @@ class SpecialController extends Controller ...@@ -152,12 +153,14 @@ class SpecialController extends Controller
if (!$v[0] || !$v[1]) continue; if (!$v[0] || !$v[1]) continue;
// 1. 根据手机或邮箱查找客户最近的订单 // 1. 根据手机或邮箱查找客户最近的订单
$order_id = $this->getLastOrderId(trim($v[0])); $res = $this->getLastOrderId(trim($v[0]));
if ($order_id === false) { if ($res['err_code'] != 0) {
Log::info('客户账号:'.$v[0].',客服邮箱:'.$v[1].',客户无订单'); Log::info('客户账号:'.$v[0].','.$res['err_msg']);
continue; continue;
} }
$order_id = $res['data'];
// 2. 根据企业邮箱查找sale_id // 2. 根据企业邮箱查找sale_id
$sale_id = $this->getSaleId(trim(strtolower($v[1]))); $sale_id = $this->getSaleId(trim(strtolower($v[1])));
...@@ -182,28 +185,34 @@ class SpecialController extends Controller ...@@ -182,28 +185,34 @@ class SpecialController extends Controller
// 获取客户最近的订单 // 获取客户最近的订单
public function getLastOrderId($account) public function getLastOrderId($account)
{ {
$UserMainModel = new UserMainModel(); $UserMainModel = new UserMainModel();
$UserCompanyModel = new UserCompanyModel(); $UserCompanyModel = new UserCompanyModel();
$OrderModel = new OrderModel(); $OrderModel = new OrderModel();
$OrderInvoiceModel = new OrderInvoiceModel();
if (strpos($account, '@') !== false) { // 邮箱 if (strpos($account, '@') !== false) { // 邮箱
$where['email'] = strtolower($account); $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)) { // 手机号码 } else if (preg_match('/\d{11}/', $account)) { // 手机号码
$where['mobile'] = $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 { // 公司名称 } 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(); $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 // 获取后台业务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