Commit a322fafb by 朱继来

调整DB

parent 8834f8e9
...@@ -8,6 +8,10 @@ use Illuminate\Foundation\Inspiring; ...@@ -8,6 +8,10 @@ use Illuminate\Foundation\Inspiring;
use DB; use DB;
use Log; use Log;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use App\Model\RegionModel;
use App\Model\OrderModel;
use App\Model\OrderAddressModel;
class JingDiaoOrderAddress extends Command class JingDiaoOrderAddress extends Command
{ {
/** /**
...@@ -38,7 +42,7 @@ class JingDiaoOrderAddress extends Command ...@@ -38,7 +42,7 @@ class JingDiaoOrderAddress extends Command
protected function getregion($parent_id = 0){ protected function getregion($parent_id = 0){
$str = ""; $str = "";
if($parent_id != 1){ if($parent_id != 1){
$region = DB::Connection("order")->table("lie_region")->where(["region_id"=>$parent_id])->first(); $region = RegionModel::where(["region_id"=>$parent_id])->first();
$str = $region->region_name." ".$str; $str = $region->region_name." ".$str;
if($region && $region->parent_id != 1){ if($region && $region->parent_id != 1){
$str = $this->getregion($region->parent_id)." ".$str; $str = $this->getregion($region->parent_id)." ".$str;
...@@ -80,7 +84,7 @@ class JingDiaoOrderAddress extends Command ...@@ -80,7 +84,7 @@ class JingDiaoOrderAddress extends Command
// } // }
//return; //return;
DB::Connection("order")->table("lie_order")->where(["is_type"=>1])->orderBy("order_id","desc")->chunk(100,function($orders){ OrderModel::where(["is_type"=>1])->orderBy("order_id","desc")->chunk(100,function($orders){
foreach($orders as $order){ foreach($orders as $order){
try{ try{
...@@ -103,7 +107,7 @@ class JingDiaoOrderAddress extends Command ...@@ -103,7 +107,7 @@ class JingDiaoOrderAddress extends Command
$str = mb_substr($orderRemark,0,2); $str = mb_substr($orderRemark,0,2);
$region = DB::Connection("order")->table("lie_region")->whereRaw("region_name like '{$str}%'")->first(); $region = RegionModel::whereRaw("region_name like '{$str}%'")->first();
if(!$region){ if(!$region){
...@@ -140,7 +144,7 @@ class JingDiaoOrderAddress extends Command ...@@ -140,7 +144,7 @@ class JingDiaoOrderAddress extends Command
//生成随机地址 //生成随机地址
protected function getRandomAddress(){ protected function getRandomAddress(){
$random = rand(1,367456); $random = rand(1,367456);
$address = DB::Connection("order")->table("lie_order_address")->where(["order_address_id"=>$random])->first(); $address = OrderAddressModel::where(["order_address_id"=>$random])->first();
if($address){ if($address){
return $address; return $address;
}else{ }else{
......
...@@ -124,27 +124,27 @@ class JingDiaoUser extends Command ...@@ -124,27 +124,27 @@ class JingDiaoUser extends Command
*/ */
public function handle(){ public function handle(){
$userids = $this->userids(); $userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id"); $users = DB::Connection("web")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{ try{
DB::Connection("order")->beginTransaction(); DB::Connection("web")->beginTransaction();
foreach($users as $user_id){ foreach($users as $user_id){
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user_id])->update([ DB::Connection("web")->table("lie_user_main")->where(["user_id"=>$user_id])->update([
"is_type"=>0, "is_type"=>0,
]); ]);
continue; continue;
$zjf_z = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",1)->sum("flow_point"); $zjf_z = DB::Connection("web")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",1)->sum("flow_point");
$zjf_f = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",2)->sum("flow_point"); $zjf_f = DB::Connection("web")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",2)->sum("flow_point");
$jifen = intval($zjf_z - $zjf_f); $jifen = intval($zjf_z - $zjf_f);
dump(sprintf("userid:%s 的积分为:%s",$user_id,$jifen)); dump(sprintf("userid:%s 的积分为:%s",$user_id,$jifen));
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first(); $userInfo = DB::Connection("web")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
$bk = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([ $bk = DB::Connection("web")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$jifen, "cur_user_point"=>$jifen,
"cur_total_point"=>$jifen, "cur_total_point"=>$jifen,
]); ]);
...@@ -153,10 +153,10 @@ class JingDiaoUser extends Command ...@@ -153,10 +153,10 @@ class JingDiaoUser extends Command
} }
DB::Connection("order")->commit(); DB::Connection("web")->commit();
}catch(\Exception $e){ }catch(\Exception $e){
dump($e->getMessage()); dump($e->getMessage());
DB::Connection("order")->rollBack(); DB::Connection("web")->rollBack();
} }
} }
...@@ -169,11 +169,11 @@ class JingDiaoUser extends Command ...@@ -169,11 +169,11 @@ class JingDiaoUser extends Command
{ {
$userids = $this->userids(); $userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id"); $users = DB::Connection("web")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{ try{
DB::Connection("order")->beginTransaction(); DB::Connection("web")->beginTransaction();
...@@ -187,7 +187,7 @@ class JingDiaoUser extends Command ...@@ -187,7 +187,7 @@ class JingDiaoUser extends Command
->select("order_amount","order_goods_type","is_type","order_pay_type","integral","status","order_id","create_time")->get(); ->select("order_amount","order_goods_type","is_type","order_pay_type","integral","status","order_id","create_time")->get();
// dump($orders); // dump($orders);
$zong_jifen = 0; $zong_jifen = 0;
$userMobile = DB::Connection("order")->table("lie_user_main")->where("user_id",$user_id)->select("mobile")->first(); $userMobile = DB::Connection("web")->table("lie_user_main")->where("user_id",$user_id)->select("mobile")->first();
foreach($orders as $k=>$order){ foreach($orders as $k=>$order){
$jifen = 0; $jifen = 0;
if($order->order_pay_type == 3){ if($order->order_pay_type == 3){
...@@ -220,7 +220,7 @@ class JingDiaoUser extends Command ...@@ -220,7 +220,7 @@ class JingDiaoUser extends Command
]; ];
// dump($jifenData); // dump($jifenData);
$bk = DB::Connection("order")->table("lie_point_log")->insert($jifenData); $bk = DB::Connection("web")->table("lie_point_log")->insert($jifenData);
if(!$bk){ if(!$bk){
throw new \Exception("添加数据失败"); throw new \Exception("添加数据失败");
} }
...@@ -228,16 +228,16 @@ class JingDiaoUser extends Command ...@@ -228,16 +228,16 @@ class JingDiaoUser extends Command
$zong_jifen += $jifen; $zong_jifen += $jifen;
} }
$zong_jifen = intval($zong_jifen); $zong_jifen = intval($zong_jifen);
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first(); $userInfo = DB::Connection("web")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
if(!$userInfo){ if(!$userInfo){
$userInfo = DB::Connection("order")->table("lie_user_info")->insert([ $userInfo = DB::Connection("web")->table("lie_user_info")->insert([
"user_id"=>$user_id, "user_id"=>$user_id,
"cur_user_point"=>$zong_jifen, "cur_user_point"=>$zong_jifen,
"cur_total_point"=>$zong_jifen, "cur_total_point"=>$zong_jifen,
]); ]);
} }
DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([ DB::Connection("web")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$userInfo->cur_user_point, "cur_user_point"=>$userInfo->cur_user_point,
"cur_total_point"=>$userInfo->cur_total_point, "cur_total_point"=>$userInfo->cur_total_point,
]); ]);
...@@ -249,11 +249,11 @@ class JingDiaoUser extends Command ...@@ -249,11 +249,11 @@ class JingDiaoUser extends Command
} }
DB::Connection("order")->commit(); DB::Connection("web")->commit();
}catch(\Exception $e){ }catch(\Exception $e){
dump($e->getMessage()); dump($e->getMessage());
DB::Connection("order")->rollBack(); DB::Connection("web")->rollBack();
} }
...@@ -360,7 +360,7 @@ class JingDiaoUser extends Command ...@@ -360,7 +360,7 @@ class JingDiaoUser extends Command
} }
$count = DB::connection('order') $count = DB::connection('web')
->table('lie_user_main') ->table('lie_user_main')
...@@ -384,13 +384,13 @@ class JingDiaoUser extends Command ...@@ -384,13 +384,13 @@ class JingDiaoUser extends Command
$countN=0; $countN=0;
$userJD = []; $userJD = [];
DB::Connection("order")->table("lie_user_main")->select("user_id","mobile","is_type")->OrderBy("user_id","desc")->whereRaw(" is_type = 1 and mobile != '' ") DB::Connection("web")->table("lie_user_main")->select("user_id","mobile","is_type")->OrderBy("user_id","desc")->whereRaw(" is_type = 1 and mobile != '' ")
->chunk(100, function($users) use(&$countN,&$userJD) { ->chunk(100, function($users) use(&$countN,&$userJD) {
foreach ($users as $user) { foreach ($users as $user) {
$user_id = $user->user_id; $user_id = $user->user_id;
$logs = null; $logs = null;
$orders = null; $orders = null;
$logs = DB::Connection("order")->table("lie_user_login")->where(["user_id"=>$user_id])->count("id"); $logs = DB::Connection("web")->table("lie_user_login")->where(["user_id"=>$user_id])->count("id");
$orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])->count("order_id"); $orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])->count("order_id");
if(!$logs && !$orders){ if(!$logs && !$orders){
dump($user->user_id); dump($user->user_id);
...@@ -417,7 +417,7 @@ class JingDiaoUser extends Command ...@@ -417,7 +417,7 @@ class JingDiaoUser extends Command
$redis->hset("api_email",$email,$user->user_id); $redis->hset("api_email",$email,$user->user_id);
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user->user_id])->update([ DB::Connection("web")->table("lie_user_main")->where(["user_id"=>$user->user_id])->update([
"mobile"=>"", "mobile"=>"",
"email"=>$email "email"=>$email
]); ]);
......
...@@ -11,7 +11,17 @@ use App\Http\Page; ...@@ -11,7 +11,17 @@ use App\Http\Page;
use App\Http\Controllers\PermController; use App\Http\Controllers\PermController;
use App\Http\Error; use App\Http\Error;
use App\Model\UserMainModel; use App\Model\UserMainModel;
use App\Model\UserAddressModel;
use App\Model\TaxInfoModel;
use App\Model\InvoiceCompanyModel;
use App\Model\RegionModel;
use App\Model\ShoppingCartModel;
use App\Model\OrderModel; use App\Model\OrderModel;
use App\Model\OrderExtendModel;
use App\Model\OrderPriceModel;
use App\Model\ShoppingCartModel;
use App\Model\PayLogModel;
use App\Model\OrderActionLogModel;
use App\Model\CrmModel; use App\Model\CrmModel;
use App\Model\CmsModel; use App\Model\CmsModel;
use Excel; use Excel;
...@@ -206,7 +216,7 @@ Class AddOrderController extends Controller ...@@ -206,7 +216,7 @@ Class AddOrderController extends Controller
} }
} }
$address = DB::connection('order')->table('lie_user_address')->where('user_id', $user->user_id)->select('address_id', 'consignee')->get(); // 收货地址 $address = UserAddressModel::where('user_id', $user->user_id)->select('address_id', 'consignee')->get(); // 收货地址
// $invoice = DB::connection('order')->table('lie_taxinfo')->where('user_id', $user->user_id)->select('tax_id', 'tax_title')->get(); // 发票信息 // $invoice = DB::connection('order')->table('lie_taxinfo')->where('user_id', $user->user_id)->select('tax_id', 'tax_title')->get(); // 发票信息
$info['user'] = $user; $info['user'] = $user;
...@@ -237,7 +247,7 @@ Class AddOrderController extends Controller ...@@ -237,7 +247,7 @@ Class AddOrderController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$address_id = $request->input('address_id'); $address_id = $request->input('address_id');
$address = DB::connection('order')->table('lie_user_address')->where('address_id', $address_id)->first(); $address = UserAddressModel::where('address_id', $address_id)->first();
$address->province_val = $this->getAddress($address->province); $address->province_val = $this->getAddress($address->province);
$address->city_val = $this->getAddress($address->city); $address->city_val = $this->getAddress($address->city);
...@@ -253,7 +263,7 @@ Class AddOrderController extends Controller ...@@ -253,7 +263,7 @@ Class AddOrderController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$tax_id = $request->input('tax_id'); $tax_id = $request->input('tax_id');
$invoice = DB::connection('order')->table('lie_taxinfo')->where('tax_id', $tax_id)->first(); $invoice = TaxInfoModel::where('tax_id', $tax_id)->first();
$invoice->province_val = $invoice->consignee_province ? $this->getAddress($invoice->consignee_province) : ''; $invoice->province_val = $invoice->consignee_province ? $this->getAddress($invoice->consignee_province) : '';
$invoice->city_val = $invoice->consignee_city ? $this->getAddress($invoice->consignee_city) : ''; $invoice->city_val = $invoice->consignee_city ? $this->getAddress($invoice->consignee_city) : '';
...@@ -261,7 +271,7 @@ Class AddOrderController extends Controller ...@@ -261,7 +271,7 @@ Class AddOrderController extends Controller
// 发票公司信息 // 发票公司信息
if (in_array($invoice->inv_type, [3, 4])) { if (in_array($invoice->inv_type, [3, 4])) {
$company_info = DB::connection('order')->table('lie_invoice_company')->where('com_name', $invoice->tax_title)->first(); $company_info = InvoiceCompanyModel::where('com_name', $invoice->tax_title)->first();
if ($company_info) { if ($company_info) {
$invoice->customer_en = $company_info->customer_en; $invoice->customer_en = $company_info->customer_en;
...@@ -283,7 +293,7 @@ Class AddOrderController extends Controller ...@@ -283,7 +293,7 @@ Class AddOrderController extends Controller
$user_id = $request->input('user_id'); $user_id = $request->input('user_id');
$inv_type = $request->input('inv_type'); $inv_type = $request->input('inv_type');
$invoice = DB::connection('order')->table('lie_taxinfo')->where(['user_id'=>$user_id, 'inv_type'=>$inv_type])->select('tax_id', 'tax_title')->get(); $invoice = TaxInfoModel::where(['user_id'=>$user_id, 'inv_type'=>$inv_type])->select('tax_id', 'tax_title')->get();
return ['errcode' => 0, 'errmsg' => '', 'data' => $invoice]; return ['errcode' => 0, 'errmsg' => '', 'data' => $invoice];
} }
...@@ -315,7 +325,7 @@ Class AddOrderController extends Controller ...@@ -315,7 +325,7 @@ Class AddOrderController extends Controller
// 查询省市区 // 查询省市区
public function getAddress($id) public function getAddress($id)
{ {
$addr = DB::connection('order')->table('lie_region')->where('region_id', $id)->select('region_name')->first(); $addr = RegionModel::where('region_id', $id)->select('region_name')->first();
return $addr ? $addr->region_name : '未匹配到ID:'.$id; return $addr ? $addr->region_name : '未匹配到ID:'.$id;
} }
...@@ -328,11 +338,11 @@ Class AddOrderController extends Controller ...@@ -328,11 +338,11 @@ Class AddOrderController extends Controller
$info['title'] = '新增自营线下订单'; $info['title'] = '新增自营线下订单';
// 默认内部账号ID // 默认内部账号ID
$internal = DB::connection('order')->table('lie_user_main')->where('mobile', Config('website.internal-account'))->select('user_id')->first(); $internal = UserMainModel::where('mobile', Config('website.internal-account'))->select('user_id')->first();
$info['internal_uid'] = $internal->user_id; $info['internal_uid'] = $internal->user_id;
// 默认内部账号收货地址 // 默认内部账号收货地址
$address = DB::connection('order')->table('lie_user_address')->where(['user_id' => $info['internal_uid'], 'is_default' => 1])->first(); $address = UserAddressModel::where(['user_id' => $info['internal_uid'], 'is_default' => 1])->first();
$address->province_val = $this->getAddress($address->province); $address->province_val = $this->getAddress($address->province);
$address->city_val = $this->getAddress($address->city); $address->city_val = $this->getAddress($address->city);
...@@ -350,7 +360,7 @@ Class AddOrderController extends Controller ...@@ -350,7 +360,7 @@ Class AddOrderController extends Controller
$intracode = DB::table('lie_intracode')->where('admin_id', $sale_id)->select('user_id')->first(); $intracode = DB::table('lie_intracode')->where('admin_id', $sale_id)->select('user_id')->first();
if (!empty($intracode)) { if (!empty($intracode)) {
$user = DB::connection('order')->table('lie_user_main')->where('user_id', $intracode->user_id)->select('mobile')->first(); $user = UserMainModel::where('user_id', $intracode->user_id)->select('mobile')->first();
$info['mobile'] = $user ? $user->mobile : ''; $info['mobile'] = $user ? $user->mobile : '';
} else { } else {
...@@ -551,7 +561,7 @@ Class AddOrderController extends Controller ...@@ -551,7 +561,7 @@ Class AddOrderController extends Controller
$data['buyer_id'] = $CmsModel->getSaleId($buyer); $data['buyer_id'] = $CmsModel->getSaleId($buyer);
} }
} else { // 修改交期 } else { // 修改交期
$goods_data = DB::connection('order')->table('lie_shopping_cart')->where('cart_id', $cart_id)->value('goods_data'); $goods_data = ShoppingCartModel::where('cart_id', $cart_id)->value('goods_data');
if (!$goods_data) { if (!$goods_data) {
$goods_data['delivery_time'] = $delivery_time; $goods_data['delivery_time'] = $delivery_time;
...@@ -563,7 +573,7 @@ Class AddOrderController extends Controller ...@@ -563,7 +573,7 @@ Class AddOrderController extends Controller
$data['goods_data'] = json_encode($goods_data); $data['goods_data'] = json_encode($goods_data);
} }
$res = DB::connection('order')->table('lie_shopping_cart')->where('cart_id', $cart_id)->update($data); $res = ShoppingCartModel::where('cart_id', $cart_id)->update($data);
if ($res === false) return ['errcode' => -1, 'errmsg' => '修改失败']; if ($res === false) return ['errcode' => -1, 'errmsg' => '修改失败'];
...@@ -773,10 +783,10 @@ Class AddOrderController extends Controller ...@@ -773,10 +783,10 @@ Class AddOrderController extends Controller
$info['type'] = $type; $info['type'] = $type;
$info['is_quiry'] = $request->input('is_quiry', ''); $info['is_quiry'] = $request->input('is_quiry', '');
$order = DB::connection('order')->table('lie_order')->where('order_id', $order_id)->first(); $order = OrderModel::where('order_id', $order_id)->first();
if ($type != 3) { if ($type != 3) {
$user = DB::connection('order')->table('lie_user_main')->where('user_id', $order->user_id)->select('mobile')->first(); $user = UserMainModel::where('user_id', $order->user_id)->select('mobile')->first();
$info['user_info'] = $user; $info['user_info'] = $user;
} }
...@@ -803,7 +813,7 @@ Class AddOrderController extends Controller ...@@ -803,7 +813,7 @@ Class AddOrderController extends Controller
$response = json_decode(curlApi($url, $data), true); $response = json_decode(curlApi($url, $data), true);
if ($response['err_code'] == 0) { if ($response['err_code'] == 0) {
$orderInfo = DB::connection('order')->table('lie_order')->where('order_id', $order_id)->first(); $orderInfo = OrderModel::where('order_id', $order_id)->first();
DB::beginTransaction(); DB::beginTransaction();
try { try {
...@@ -814,7 +824,7 @@ Class AddOrderController extends Controller ...@@ -814,7 +824,7 @@ Class AddOrderController extends Controller
$price['price'] = '-'.$orderInfo->order_amount; $price['price'] = '-'.$orderInfo->order_amount;
$price['create_time'] = time(); $price['create_time'] = time();
$priceAdd = DB::connection('order')->table('lie_order_price')->insert($price); $priceAdd = OrderPriceModel::insert($price);
// 添加付款记录 // 添加付款记录
$pay['user_id'] = $orderInfo->user_id; $pay['user_id'] = $orderInfo->user_id;
...@@ -828,10 +838,10 @@ Class AddOrderController extends Controller ...@@ -828,10 +838,10 @@ Class AddOrderController extends Controller
$pay['create_time'] = time(); $pay['create_time'] = time();
$pay['pay_time'] = time(); $pay['pay_time'] = time();
$payLog = DB::connection('order')->table('lie_pay_log')->insert($pay); $payLog = PayLogModel::insert($pay);
// 待发货状态 // 待发货状态
$update = DB::connection('order')->table('lie_order')->where('order_id', $order_id)->update(['status' => $status, 'pay_time' => time(), 'wms_syn' => 1]); $update = OrderModel::where('order_id', $order_id)->update(['status' => $status, 'pay_time' => time(), 'wms_syn' => 1]);
if ($update && $priceAdd && $payLog) { if ($update && $priceAdd && $payLog) {
DB::commit(); DB::commit();
...@@ -868,7 +878,8 @@ Class AddOrderController extends Controller ...@@ -868,7 +878,8 @@ Class AddOrderController extends Controller
$log['event'] = $event; $log['event'] = $event;
$log['ip'] = get_client_ip(); $log['ip'] = get_client_ip();
$log['create_time'] = time(); $log['create_time'] = time();
$actionLog = DB::connection('order')->table('lie_order_action_log')->insert($log);
$actionLog = OrderActionLogModel::insert($log);
if (!$actionLog){ if (!$actionLog){
errorLog(Error::E_ADD_FAILED, '添加操作记录失败'); errorLog(Error::E_ADD_FAILED, '添加操作记录失败');
...@@ -1093,7 +1104,7 @@ Class AddOrderController extends Controller ...@@ -1093,7 +1104,7 @@ Class AddOrderController extends Controller
$data['operator_id'] = $request->user->userId; $data['operator_id'] = $request->user->userId;
if ($goods_type == 1 && !$add_type) { if ($goods_type == 1 && !$add_type) {
$temp_save_info = DB::connection('order')->table('lie_order_extend')->where('order_id', $data['order_id'])->value('temp_save_info'); $temp_save_info = OrderExtendModel::where('order_id', $data['order_id'])->value('temp_save_info');
// 获取临时保存信息 // 获取临时保存信息
if ($temp_save_info) { if ($temp_save_info) {
......
...@@ -5,7 +5,8 @@ use App\Http\Controllers\Controller; ...@@ -5,7 +5,8 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Error; use App\Http\Error;
use DB; use DB;
use App\Http\Model\UserActionLogModel; use App\Model\RegionModel;
use App\Model\UserAddressModel;
class AddressController extends Controller class AddressController extends Controller
{ {
...@@ -58,7 +59,7 @@ class AddressController extends Controller ...@@ -58,7 +59,7 @@ class AddressController extends Controller
// 地址 // 地址
public function getRegion($region_id) public function getRegion($region_id)
{ {
$region = DB::connection('order')->table('lie_region')->where('region_id', $region_id)->select('region_name')->first(); $region = RegionModel::where('region_id', $region_id)->select('region_name')->first();
return $region ? $region->region_name : ''; return $region ? $region->region_name : '';
} }
...@@ -69,7 +70,7 @@ class AddressController extends Controller ...@@ -69,7 +70,7 @@ class AddressController extends Controller
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$address_id = $request->input('address_id'); $address_id = $request->input('address_id');
$info = DB::connection('order')->table('lie_user_address')->where('address_id', $address_id)->first(); $info = UserAddressModel::where('address_id', $address_id)->first();
if (empty($info)) return ['errcode' => Error::E_NOT_EXISTS, 'errmsg' => '未找到']; if (empty($info)) return ['errcode' => Error::E_NOT_EXISTS, 'errmsg' => '未找到'];
...@@ -160,15 +161,13 @@ class AddressController extends Controller ...@@ -160,15 +161,13 @@ class AddressController extends Controller
} }
if ($map['user_id'] && isset($map['address_type'])) { if ($map['user_id'] && isset($map['address_type'])) {
$addressList = DB::connection('order')->table('lie_user_address')->where($map)->get(); $addressList = UserAddressModel::where($map)->get();
} }
if(!empty($addressList) && is_array($addressList)) { if(!empty($addressList) && is_array($addressList)) {
$region = array(); $region = array();
foreach ($addressList as &$val) { foreach ($addressList as &$val) {
$region = DB::connection('order') $region = RegionModel::whereIn('region_id', [$val->province, $val->city, $val->district])
->table('lie_region')
->whereIn('region_id', [$val->province, $val->city, $val->district])
->select('region_id', 'region_name') ->select('region_id', 'region_name')
->get(); ->get();
......
...@@ -18,20 +18,23 @@ use App\Model\OrderExtendModel; ...@@ -18,20 +18,23 @@ use App\Model\OrderExtendModel;
use App\Model\OrderItemsModel; use App\Model\OrderItemsModel;
use App\Model\OrderItemsTrackModel; use App\Model\OrderItemsTrackModel;
use App\Model\OrderItemsTrackingModel; use App\Model\OrderItemsTrackingModel;
use App\Model\UserSampleApplyModel;
use App\Model\OrderActionLogModel; use App\Model\OrderActionLogModel;
use App\Model\UserSampleInviteModel;
use App\Model\UserGroupModel;
use App\Model\UserMainModel;
use App\Model\BrandBlackListModel;
use App\Model\PayExtendModel;
use Illuminate\Support\Facades\Redis;
use App\Model\ShoppingCartModel; use App\Model\ShoppingCartModel;
use App\Model\OrderServiceModel; use App\Model\OrderServiceModel;
use App\Model\OrderServiceItemsModel; use App\Model\OrderServiceItemsModel;
use App\Model\OrderServiceLogModel; use App\Model\OrderServiceLogModel;
use App\Model\OrderRefundModel; use App\Model\OrderRefundModel;
use App\Model\OrderRefundLogModel; use App\Model\OrderRefundLogModel;
use App\Model\BrandBlackListModel;
use App\Model\PayExtendModel;
use App\Model\UserMainModel;
use App\Model\UserAddressModel;
use App\Model\TaxInfoModel;
use App\Model\RegionModel;
use App\Model\UserGroupModel;
use App\Model\UserSampleApplyModel;
use App\Model\UserSampleInviteModel;
use Illuminate\Support\Facades\Redis;
use DB; use DB;
use App\Model\Frq\InquiryItemsReportModel; use App\Model\Frq\InquiryItemsReportModel;
...@@ -524,7 +527,7 @@ class ApiController extends Controller ...@@ -524,7 +527,7 @@ class ApiController extends Controller
if ($account) { if ($account) {
$field = preg_match('/@/', $account) ? 'email' : 'mobile'; $field = preg_match('/@/', $account) ? 'email' : 'mobile';
$user_id = DB::connection('order')->table('lie_user_main')->where($field, $account)->value('user_id'); $user_id = UserMainModel::where($field, $account)->value('user_id');
} }
// 公司和联系方式都存在 // 公司和联系方式都存在
...@@ -599,7 +602,7 @@ class ApiController extends Controller ...@@ -599,7 +602,7 @@ class ApiController extends Controller
$where['user_id'] = $user_id; $where['user_id'] = $user_id;
$where['inv_type'] = 2; $where['inv_type'] = 2;
$tax_info = DB::connection('order')->table('lie_taxinfo')->where($where)->select('tax_title', 'tax_id')->get(); $tax_info = TaxInfoModel::where($where)->select('tax_title', 'tax_id')->get();
$this->Export(0, '', $tax_info); $this->Export(0, '', $tax_info);
} }
...@@ -613,7 +616,7 @@ class ApiController extends Controller ...@@ -613,7 +616,7 @@ class ApiController extends Controller
$map['tax_title'] = $com_info->com_name; $map['tax_title'] = $com_info->com_name;
$map['user_id'] = $user_id; $map['user_id'] = $user_id;
$map['inv_type'] = $invoice_type; $map['inv_type'] = $invoice_type;
$invoice = DB::connection('order')->table('lie_taxinfo')->where($map)->first(); $invoice = TaxInfoModel::where($map)->first();
if (!$invoice) $this->Export(-1, '未找到发票信息'); if (!$invoice) $this->Export(-1, '未找到发票信息');
$tax_info['tax_id'] = isset($invoice) ? $invoice->tax_id : 0; $tax_info['tax_id'] = isset($invoice) ? $invoice->tax_id : 0;
...@@ -644,7 +647,7 @@ class ApiController extends Controller ...@@ -644,7 +647,7 @@ class ApiController extends Controller
$map['user_id'] = $user_id; $map['user_id'] = $user_id;
$map['address_type'] = 0; $map['address_type'] = 0;
$address = DB::connection('order')->table('lie_user_address')->where($map)->get(); $address = UserAddressModel::where($map)->get();
if (empty($address)) $this->Export(-1, '未获取到用户收货地址'); if (empty($address)) $this->Export(-1, '未获取到用户收货地址');
foreach ($address as &$v) { foreach ($address as &$v) {
...@@ -661,7 +664,7 @@ class ApiController extends Controller ...@@ -661,7 +664,7 @@ class ApiController extends Controller
// 查询省市区 // 查询省市区
public function getAddress($id) public function getAddress($id)
{ {
return DB::connection('order')->table('lie_region')->where('region_id', $id)->value('region_name'); return RegionModel::where('region_id', $id)->value('region_name');
} }
// 导入销售报价物料 // 导入销售报价物料
......
...@@ -4,13 +4,14 @@ namespace App\Http\Controllers; ...@@ -4,13 +4,14 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests; use App\Http\Requests;
use App\Http\Page;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\UserMainModel;
use App\Model\OrderModel; use App\Model\OrderModel;
use App\Model\PayLogModel;
use App\Model\OrderRefundModel; use App\Model\OrderRefundModel;
use App\Model\OrderRefundItemsModel; use App\Model\OrderRefundItemsModel;
use DB; use DB;
use App\Http\Page;
use App\Model\UserMainModel;
// 获取会员账号 // 获取会员账号
function getAccountName($user_id) function getAccountName($user_id)
...@@ -43,21 +44,15 @@ function getOrderAmount($order_id) ...@@ -43,21 +44,15 @@ function getOrderAmount($order_id)
// 获取支付名称 // 获取支付名称
function getPayName($order_id) function getPayName($order_id)
{ {
$payLog = DB::connection('order') $payLog = PayLogModel::where(['order_id' => $order_id])->select('pay_name')->get();
->table('lie_pay_log')
->where(['order_id' => $order_id]) if ($payLog->isEmpty()) return false;
->select('pay_name')
->get();
if (!empty($payLog)) {
foreach ($payLog as $v) { foreach ($payLog as $v) {
$payName[] = $v->pay_name; $payName[] = $v->pay_name;
} }
return implode(',', $payName); return implode(',', $payName);
}
return false;
} }
class RefundController extends Controller class RefundController extends Controller
...@@ -225,7 +220,7 @@ class RefundController extends Controller ...@@ -225,7 +220,7 @@ class RefundController extends Controller
{ {
$refund_id = $request->input('refund_id'); $refund_id = $request->input('refund_id');
$update = DB::connection('order')->table('lie_order_refund')->where('refund_id', $refund_id)->update(['status' => -1]); $update = OrderRefundModel::where('refund_id', $refund_id)->update(['status' => -1]);
if (!$update) return ['errcode' => 1, 'errmsg' => '取消申请失败']; if (!$update) return ['errcode' => 1, 'errmsg' => '取消申请失败'];
......
...@@ -11,7 +11,7 @@ class RegionController extends Controller ...@@ -11,7 +11,7 @@ class RegionController extends Controller
public function getAll() public function getAll()
{ {
$provinces = array(); $citys = array(); $towns = array(); $provinces = array(); $citys = array(); $towns = array();
$list = DB::connection('order')->table('lie_region')->orderBy('region_id', 'asc')->get(); $list = RegionModel::orderBy('region_id', 'asc')->get();
foreach (@$list as $val) { foreach (@$list as $val) {
if (!$val->parent_id) continue; if (!$val->parent_id) continue;
...@@ -45,7 +45,7 @@ class RegionController extends Controller ...@@ -45,7 +45,7 @@ class RegionController extends Controller
if (empty($region_id)){ if (empty($region_id)){
return ""; return "";
} }
$list = DB::connection('order')->table('lie_region')->select("region_name")->where("region_id",$region_id)->get(); $list = RegionModel::select("region_name")->where("region_id",$region_id)->get();
return !$list ? "" : current(objectToArray($list))['region_name']; return !$list ? "" : current(objectToArray($list))['region_name'];
} }
......
...@@ -3,34 +3,30 @@ ...@@ -3,34 +3,30 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use App\Http\Requests; use App\Http\Requests;
use App\Http\Page;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Model\OrderModel; use App\Model\OrderModel;
use App\Model\OrderReturnModel; use App\Model\OrderReturnModel;
use App\Model\OrderReturnItemsModel; use App\Model\OrderReturnItemsModel;
use DB; use App\Model\PayLogModel;
use App\Http\Page;
use App\Model\UserMainModel; use App\Model\UserMainModel;
use Illuminate\Support\Facades\Redis; use App\Model\ShippingModel;
use DB;
// 获取支付名称 // 获取支付名称
function getPayName($order_id) function getPayName($order_id)
{ {
$payLog = DB::connection('order') $payLog = PayLogModel::where(['order_id' => $order_id])->select('pay_name')->get();
->table('lie_pay_log')
->where(['order_id' => $order_id]) if ($payLog->isEmpty()) return false;
->select('pay_name')
->get();
if (!empty($payLog)) {
foreach ($payLog as $v) { foreach ($payLog as $v) {
$payName[] = $v->pay_name; $payName[] = $v->pay_name;
} }
return implode(',', $payName); return implode(',', $payName);
}
return false;
} }
// 获取交易员名称 // 获取交易员名称
...@@ -46,7 +42,7 @@ function getSalesName($sale_id) ...@@ -46,7 +42,7 @@ function getSalesName($sale_id)
// 获取物流名称 // 获取物流名称
function getShippingName($shipping_id) function getShippingName($shipping_id)
{ {
$shipping = DB::connection('order')->table('lie_shipping')->where('shipping_id', $shipping_id)->select('shipping_name')->first(); $shipping = ShippingModel::where('shipping_id', $shipping_id)->select('shipping_name')->first();
return $shipping ? $shipping->shipping_name : ''; return $shipping ? $shipping->shipping_name : '';
} }
...@@ -152,7 +148,7 @@ class ReturnController extends Controller ...@@ -152,7 +148,7 @@ class ReturnController extends Controller
$show = $page->show(); $show = $page->show();
// 获取配送方式 // 获取配送方式
$shippings = DB::connection('order')->table('lie_shipping')->get(); $shippings = ShippingModel::get();
$ship_type = []; $ship_type = [];
foreach ($shippings as $k => $v) { foreach ($shippings as $k => $v) {
......
...@@ -40,14 +40,14 @@ class SpecialController extends Controller ...@@ -40,14 +40,14 @@ class SpecialController extends Controller
DB::connection('order')->beginTransaction(); DB::connection('order')->beginTransaction();
$order = DB::connection('order')->table('lie_order_price')->where('order_id', $order_id)->where('price_type', 3)->first(); $order = OrderPriceModel::where('order_id', $order_id)->where('price_type', 3)->first();
if (!$order) { if (!$order) {
echo '运费不存在';die; echo '运费不存在';die;
} }
$data['price'] = 0; $data['price'] = 0;
$update = DB::connection('order')->table('lie_order_price')->where('order_id', $order_id)->where('price_type', 3)->update($data); $update = OrderPriceModel::where('order_id', $order_id)->where('price_type', 3)->update($data);
if (!$update) { if (!$update) {
DB::connection('order')->rollback(); DB::connection('order')->rollback();
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Page; use App\Http\Page;
use App\Map\PcbOrderInvoiceMap; use App\Map\PcbOrderInvoiceMap;
use App\Map\PcbOrderMap; use App\Map\PcbOrderMap;
...@@ -15,12 +17,9 @@ use App\Model\PaymentDaysModel; ...@@ -15,12 +17,9 @@ use App\Model\PaymentDaysModel;
use App\Model\Pcb\PcbOrderModel; use App\Model\Pcb\PcbOrderModel;
use App\Model\Pcb\PcbPublicModel; use App\Model\Pcb\PcbPublicModel;
use App\Model\Pcb\PcbPurchaseModel; use App\Model\Pcb\PcbPurchaseModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\PermController; use App\Http\Controllers\PermController;
use DB;
use App\Model\UserMainModel; use App\Model\UserMainModel;
use App\Model\UserInfoModel; use App\Model\UserInfoModel;
use App\Model\UserCompanyModel; use App\Model\UserCompanyModel;
...@@ -31,6 +30,8 @@ use App\Model\OrderServiceLogModel; ...@@ -31,6 +30,8 @@ use App\Model\OrderServiceLogModel;
use App\Model\OrderExtendModel; use App\Model\OrderExtendModel;
use App\Model\PayLogModel; use App\Model\PayLogModel;
use App\Model\OrderInvoiceModel; use App\Model\OrderInvoiceModel;
use App\Model\ShippingModel;
use DB;
class WebController extends Controller class WebController extends Controller
{ {
...@@ -97,7 +98,7 @@ class WebController extends Controller ...@@ -97,7 +98,7 @@ class WebController extends Controller
$data['title']='PCB交易列表'; $data['title']='PCB交易列表';
$data['order_type'] = PcbOrderMap::$order_type; $data['order_type'] = PcbOrderMap::$order_type;
$data['status'] = PcbOrderMap::$status; $data['status'] = PcbOrderMap::$status;
$data['shipping'] = objectToArray(DB::connection("order")->table("lie_shipping")->get()); $data['shipping'] = objectToArray(ShippingModel::get());
//分页 //分页
$response = (new PcbOrderModel())->getList(); $response = (new PcbOrderModel())->getList();
$page = new Page($response[3], 10); $page = new Page($response[3], 10);
...@@ -164,7 +165,7 @@ class WebController extends Controller ...@@ -164,7 +165,7 @@ class WebController extends Controller
$orderBase['create_time'] = $orderBase['create_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['create_time']) : ""; $orderBase['create_time'] = $orderBase['create_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['create_time']) : "";
$orderBase['finish_time'] = $orderBase['finish_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['finish_time']) : ""; $orderBase['finish_time'] = $orderBase['finish_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['finish_time']) : "";
$orderBase['pay_time'] = $orderBase['pay_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['pay_time']) : ""; $orderBase['pay_time'] = $orderBase['pay_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['pay_time']) : "";
$userCompany = DB::connection('order')->table("lie_user_company")->where("user_id",$orderBase['user_id'])->first(); $userCompany = UserCompanyModel::where("user_id",$orderBase['user_id'])->first();
$orderBase['company_name'] = $userCompany ? $userCompany->com_name : "" ; $orderBase['company_name'] = $userCompany ? $userCompany->com_name : "" ;
//拼接收货信息 //拼接收货信息
$RegionController = new RegionController(); $RegionController = new RegionController();
...@@ -250,7 +251,7 @@ class WebController extends Controller ...@@ -250,7 +251,7 @@ class WebController extends Controller
$orderBase['create_time'] = $orderBase['create_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['create_time']) : ""; $orderBase['create_time'] = $orderBase['create_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['create_time']) : "";
$orderBase['finish_time'] = $orderBase['finish_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['finish_time']) : ""; $orderBase['finish_time'] = $orderBase['finish_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['finish_time']) : "";
$orderBase['pay_time'] = $orderBase['pay_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['pay_time']) : ""; $orderBase['pay_time'] = $orderBase['pay_time'] > 0 ? date('Y-m-d H:i:s',$orderBase['pay_time']) : "";
$userCompany = DB::connection('order')->table("lie_user_company")->where("user_id",$orderBase['user_id'])->first(); $userCompany = UserCompanyModel::where("user_id",$orderBase['user_id'])->first();
$orderBase['company_name'] = $userCompany ? $userCompany->com_name : "" ; $orderBase['company_name'] = $userCompany ? $userCompany->com_name : "" ;
//拼接采购信息 //拼接采购信息
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class InvoiceCompanyModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_invoice_company';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class RemovalItemsModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_removal_items';
protected $primaryKey = 'removal_items_id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class ShippingModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_shipping';
protected $primaryKey = 'shipping_id';
public $timestamps = false;
}
\ No newline at end of file
...@@ -6,7 +6,7 @@ use Request; ...@@ -6,7 +6,7 @@ use Request;
class ShoppingCartModel extends Model class ShoppingCartModel extends Model
{ {
protected $connection = 'order'; protected $connection = 'web';
protected $table = 'lie_shopping_cart'; protected $table = 'lie_shopping_cart';
protected $primaryKey = 'cart_id'; protected $primaryKey = 'cart_id';
public $timestamps = false; public $timestamps = false;
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class TaxInfoModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_taxinfo';
protected $primaryKey = 'tax_id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserAddressModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_address';
protected $primaryKey = 'address_id';
public $timestamps = false;
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ use App\Model\RegionModel; ...@@ -9,7 +9,7 @@ use App\Model\RegionModel;
class UserCompanyModel extends Model class UserCompanyModel extends Model
{ {
protected $connection = 'order'; protected $connection = 'web';
protected $table = 'lie_user_company'; protected $table = 'lie_user_company';
protected $primaryKey = 'com_id'; protected $primaryKey = 'com_id';
public $timestamps = false; public $timestamps = false;
......
...@@ -8,7 +8,7 @@ use DB; ...@@ -8,7 +8,7 @@ use DB;
class UserMainModel extends Model class UserMainModel extends Model
{ {
protected $connection = 'order'; protected $connection = 'web';
protected $table = 'lie_user_main'; protected $table = 'lie_user_main';
protected $primaryKey = 'user_id'; protected $primaryKey = 'user_id';
public $timestamps = false; public $timestamps = false;
......
...@@ -71,16 +71,29 @@ return [ ...@@ -71,16 +71,29 @@ return [
'strict' => false, 'strict' => false,
], ],
'order' => [ 'web' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => env('DB_HOST', ''), 'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE_WEB', ''),
'username' => env('DB_USERNAME_WEB', ''),
'password' => env('DB_PASSWORD_WEB', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'order' => [
'driver' => 'mysql',
'host' => env('DB_HOST_ORDER', ''),
'database' => env('DB_DATABASE_ORDER', ''), 'database' => env('DB_DATABASE_ORDER', ''),
'username' => env('DB_USERNAME_ORDER', ''), 'username' => env('DB_USERNAME_ORDER', ''),
'password' => env('DB_PASSWORD_ORDER', ''), 'password' => env('DB_PASSWORD_ORDER', ''),
'port' => env('DB_PORT', 3306), 'port' => env('DB_PORT', 3306),
'charset' => 'utf8', 'charset' => 'utf8',
'collation' => 'utf8_unicode_ci', 'collation' => 'utf8_unicode_ci',
'prefix' => '', 'prefix' => env('DB_PREFIX_ORDER', ''),
'strict' => false, 'strict' => false,
], ],
......
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