Commit a322fafb by 朱继来

调整DB

parent 8834f8e9
......@@ -8,6 +8,10 @@ use Illuminate\Foundation\Inspiring;
use DB;
use Log;
use Illuminate\Support\Facades\Redis;
use App\Model\RegionModel;
use App\Model\OrderModel;
use App\Model\OrderAddressModel;
class JingDiaoOrderAddress extends Command
{
/**
......@@ -38,7 +42,7 @@ class JingDiaoOrderAddress extends Command
protected function getregion($parent_id = 0){
$str = "";
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;
if($region && $region->parent_id != 1){
$str = $this->getregion($region->parent_id)." ".$str;
......@@ -80,7 +84,7 @@ class JingDiaoOrderAddress extends Command
// }
//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){
try{
......@@ -103,7 +107,7 @@ class JingDiaoOrderAddress extends Command
$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){
......@@ -140,7 +144,7 @@ class JingDiaoOrderAddress extends Command
//生成随机地址
protected function getRandomAddress(){
$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){
return $address;
}else{
......
......@@ -124,27 +124,27 @@ class JingDiaoUser extends Command
*/
public function handle(){
$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{
DB::Connection("order")->beginTransaction();
DB::Connection("web")->beginTransaction();
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,
]);
continue;
$zjf_z = DB::Connection("order")->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_z = DB::Connection("web")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",1)->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);
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_total_point"=>$jifen,
]);
......@@ -153,10 +153,10 @@ class JingDiaoUser extends Command
}
DB::Connection("order")->commit();
DB::Connection("web")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
DB::Connection("web")->rollBack();
}
}
......@@ -169,11 +169,11 @@ class JingDiaoUser extends Command
{
$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{
DB::Connection("order")->beginTransaction();
DB::Connection("web")->beginTransaction();
......@@ -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();
// dump($orders);
$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){
$jifen = 0;
if($order->order_pay_type == 3){
......@@ -220,7 +220,7 @@ class JingDiaoUser extends Command
];
// dump($jifenData);
$bk = DB::Connection("order")->table("lie_point_log")->insert($jifenData);
$bk = DB::Connection("web")->table("lie_point_log")->insert($jifenData);
if(!$bk){
throw new \Exception("添加数据失败");
}
......@@ -228,16 +228,16 @@ class JingDiaoUser extends Command
$zong_jifen += $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){
$userInfo = DB::Connection("order")->table("lie_user_info")->insert([
$userInfo = DB::Connection("web")->table("lie_user_info")->insert([
"user_id"=>$user_id,
"cur_user_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_total_point"=>$userInfo->cur_total_point,
]);
......@@ -249,11 +249,11 @@ class JingDiaoUser extends Command
}
DB::Connection("order")->commit();
DB::Connection("web")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
DB::Connection("web")->rollBack();
}
......@@ -360,7 +360,7 @@ class JingDiaoUser extends Command
}
$count = DB::connection('order')
$count = DB::connection('web')
->table('lie_user_main')
......@@ -384,13 +384,13 @@ class JingDiaoUser extends Command
$countN=0;
$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) {
foreach ($users as $user) {
$user_id = $user->user_id;
$logs = 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");
if(!$logs && !$orders){
dump($user->user_id);
......@@ -417,7 +417,7 @@ class JingDiaoUser extends Command
$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"=>"",
"email"=>$email
]);
......
......@@ -11,7 +11,17 @@ use App\Http\Page;
use App\Http\Controllers\PermController;
use App\Http\Error;
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\OrderExtendModel;
use App\Model\OrderPriceModel;
use App\Model\ShoppingCartModel;
use App\Model\PayLogModel;
use App\Model\OrderActionLogModel;
use App\Model\CrmModel;
use App\Model\CmsModel;
use Excel;
......@@ -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(); // 发票信息
$info['user'] = $user;
......@@ -237,7 +247,7 @@ Class AddOrderController extends Controller
if ($request->isMethod('post')) {
$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->city_val = $this->getAddress($address->city);
......@@ -253,7 +263,7 @@ Class AddOrderController extends Controller
if ($request->isMethod('post')) {
$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->city_val = $invoice->consignee_city ? $this->getAddress($invoice->consignee_city) : '';
......@@ -261,7 +271,7 @@ Class AddOrderController extends Controller
// 发票公司信息
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) {
$invoice->customer_en = $company_info->customer_en;
......@@ -283,7 +293,7 @@ Class AddOrderController extends Controller
$user_id = $request->input('user_id');
$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];
}
......@@ -315,7 +325,7 @@ Class AddOrderController extends Controller
// 查询省市区
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;
}
......@@ -328,11 +338,11 @@ Class AddOrderController extends Controller
$info['title'] = '新增自营线下订单';
// 默认内部账号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;
// 默认内部账号收货地址
$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->city_val = $this->getAddress($address->city);
......@@ -350,7 +360,7 @@ Class AddOrderController extends Controller
$intracode = DB::table('lie_intracode')->where('admin_id', $sale_id)->select('user_id')->first();
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 : '';
} else {
......@@ -551,7 +561,7 @@ Class AddOrderController extends Controller
$data['buyer_id'] = $CmsModel->getSaleId($buyer);
}
} 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) {
$goods_data['delivery_time'] = $delivery_time;
......@@ -563,7 +573,7 @@ Class AddOrderController extends Controller
$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' => '修改失败'];
......@@ -773,10 +783,10 @@ Class AddOrderController extends Controller
$info['type'] = $type;
$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) {
$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;
}
......@@ -803,7 +813,7 @@ Class AddOrderController extends Controller
$response = json_decode(curlApi($url, $data), true);
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();
try {
......@@ -814,7 +824,7 @@ Class AddOrderController extends Controller
$price['price'] = '-'.$orderInfo->order_amount;
$price['create_time'] = time();
$priceAdd = DB::connection('order')->table('lie_order_price')->insert($price);
$priceAdd = OrderPriceModel::insert($price);
// 添加付款记录
$pay['user_id'] = $orderInfo->user_id;
......@@ -828,10 +838,10 @@ Class AddOrderController extends Controller
$pay['create_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) {
DB::commit();
......@@ -862,13 +872,14 @@ Class AddOrderController extends Controller
}
// 操作记录
$log['order_id'] = $order_id;
$log['operator_id'] = $request->user->userId;
$log['order_id'] = $order_id;
$log['operator_id'] = $request->user->userId;
$log['operator_type'] = 2;
$log['event'] = $event;
$log['ip'] = get_client_ip();
$log['create_time'] = time();
$actionLog = DB::connection('order')->table('lie_order_action_log')->insert($log);
$log['event'] = $event;
$log['ip'] = get_client_ip();
$log['create_time'] = time();
$actionLog = OrderActionLogModel::insert($log);
if (!$actionLog){
errorLog(Error::E_ADD_FAILED, '添加操作记录失败');
......@@ -1093,7 +1104,7 @@ Class AddOrderController extends Controller
$data['operator_id'] = $request->user->userId;
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) {
......
......@@ -5,7 +5,8 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Error;
use DB;
use App\Http\Model\UserActionLogModel;
use App\Model\RegionModel;
use App\Model\UserAddressModel;
class AddressController extends Controller
{
......@@ -58,7 +59,7 @@ class AddressController extends Controller
// 地址
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 : '';
}
......@@ -69,7 +70,7 @@ class AddressController extends Controller
if ($request->isMethod('post')) {
$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' => '未找到'];
......@@ -160,15 +161,13 @@ class AddressController extends Controller
}
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)) {
$region = array();
foreach ($addressList as &$val) {
$region = DB::connection('order')
->table('lie_region')
->whereIn('region_id', [$val->province, $val->city, $val->district])
$region = RegionModel::whereIn('region_id', [$val->province, $val->city, $val->district])
->select('region_id', 'region_name')
->get();
......
......@@ -18,20 +18,23 @@ use App\Model\OrderExtendModel;
use App\Model\OrderItemsModel;
use App\Model\OrderItemsTrackModel;
use App\Model\OrderItemsTrackingModel;
use App\Model\UserSampleApplyModel;
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\OrderServiceModel;
use App\Model\OrderServiceItemsModel;
use App\Model\OrderServiceLogModel;
use App\Model\OrderRefundModel;
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 App\Model\Frq\InquiryItemsReportModel;
......@@ -524,7 +527,7 @@ class ApiController extends Controller
if ($account) {
$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
$where['user_id'] = $user_id;
$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);
}
......@@ -613,7 +616,7 @@ class ApiController extends Controller
$map['tax_title'] = $com_info->com_name;
$map['user_id'] = $user_id;
$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, '未找到发票信息');
$tax_info['tax_id'] = isset($invoice) ? $invoice->tax_id : 0;
......@@ -644,7 +647,7 @@ class ApiController extends Controller
$map['user_id'] = $user_id;
$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, '未获取到用户收货地址');
foreach ($address as &$v) {
......@@ -661,7 +664,7 @@ class ApiController extends Controller
// 查询省市区
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');
}
// 导入销售报价物料
......
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use DB;
use Illuminate\Support\Facades\Redis as Redis;
use App\Model\RegionModel;
class RegionController extends Controller
{
public function getAll()
{
$provinces = array(); $citys = array(); $towns = array();
$list = DB::connection('order')->table('lie_region')->orderBy('region_id', 'asc')->get();
foreach (@$list as $val) {
if (!$val->parent_id) continue;
switch ($val->region_type) {
case 1:
$provinces[$val->parent_id]['parent_id'] = $val->parent_id;
$provinces[$val->parent_id]['children'][] = $val;
break;
case 2:
$citys[$val->parent_id]['parent_id'] = $val->parent_id;
$citys[$val->parent_id]['children'][] = $val;
break;
case 3:
$towns[$val->parent_id]['parent_id'] = $val->parent_id;
$towns[$val->parent_id]['children'][] = $val;
break;
}
}
return array(
'errcode'=>0,
'errmsg'=>'success',
'provinces'=> $provinces,
'citys'=> $citys,
'towns'=> $towns
);
}
//获取省市县名称
public function getRegionName($region_id)
{
if (empty($region_id)){
return "";
}
$list = DB::connection('order')->table('lie_region')->select("region_name")->where("region_id",$region_id)->get();
return !$list ? "" : current(objectToArray($list))['region_name'];
}
// 初始化地址缓存
public function cache()
{
$RegionModel = new RegionModel();
$province = $RegionModel->getRegion(1); // 获取省
S_str('oms:province', json_encode($province));
$city = $RegionModel->getRegion(2); // 获取城市
foreach($city as $c) {
S_hash('oms:city:'.$c['parent_id'], $c['region_id'], json_encode($c));
}
$district = $RegionModel->getRegion(3); // 获取区
foreach($district as $d) {
S_hash('oms:district:'.$d['parent_id'], $d['region_id'], json_encode($d));
}
echo '设置地址缓存成功';
}
// 清除缓存
public function clear()
{
Redis::del('oms:province');
Redis::del(Redis::keys('oms:city:*'));
Redis::del(Redis::keys('oms:district:*'));
echo '清除地址缓存成功';
}
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use DB;
use Illuminate\Support\Facades\Redis as Redis;
use App\Model\RegionModel;
class RegionController extends Controller
{
public function getAll()
{
$provinces = array(); $citys = array(); $towns = array();
$list = RegionModel::orderBy('region_id', 'asc')->get();
foreach (@$list as $val) {
if (!$val->parent_id) continue;
switch ($val->region_type) {
case 1:
$provinces[$val->parent_id]['parent_id'] = $val->parent_id;
$provinces[$val->parent_id]['children'][] = $val;
break;
case 2:
$citys[$val->parent_id]['parent_id'] = $val->parent_id;
$citys[$val->parent_id]['children'][] = $val;
break;
case 3:
$towns[$val->parent_id]['parent_id'] = $val->parent_id;
$towns[$val->parent_id]['children'][] = $val;
break;
}
}
return array(
'errcode'=>0,
'errmsg'=>'success',
'provinces'=> $provinces,
'citys'=> $citys,
'towns'=> $towns
);
}
//获取省市县名称
public function getRegionName($region_id)
{
if (empty($region_id)){
return "";
}
$list = RegionModel::select("region_name")->where("region_id",$region_id)->get();
return !$list ? "" : current(objectToArray($list))['region_name'];
}
// 初始化地址缓存
public function cache()
{
$RegionModel = new RegionModel();
$province = $RegionModel->getRegion(1); // 获取省
S_str('oms:province', json_encode($province));
$city = $RegionModel->getRegion(2); // 获取城市
foreach($city as $c) {
S_hash('oms:city:'.$c['parent_id'], $c['region_id'], json_encode($c));
}
$district = $RegionModel->getRegion(3); // 获取区
foreach($district as $d) {
S_hash('oms:district:'.$d['parent_id'], $d['region_id'], json_encode($d));
}
echo '设置地址缓存成功';
}
// 清除缓存
public function clear()
{
Redis::del('oms:province');
Redis::del(Redis::keys('oms:city:*'));
Redis::del(Redis::keys('oms:district:*'));
echo '清除地址缓存成功';
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Page;
use App\Map\PcbOrderInvoiceMap;
use App\Map\PcbOrderMap;
......@@ -15,12 +17,9 @@ use App\Model\PaymentDaysModel;
use App\Model\Pcb\PcbOrderModel;
use App\Model\Pcb\PcbPublicModel;
use App\Model\Pcb\PcbPurchaseModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Controllers\PermController;
use DB;
use App\Model\UserMainModel;
use App\Model\UserInfoModel;
use App\Model\UserCompanyModel;
......@@ -31,6 +30,8 @@ use App\Model\OrderServiceLogModel;
use App\Model\OrderExtendModel;
use App\Model\PayLogModel;
use App\Model\OrderInvoiceModel;
use App\Model\ShippingModel;
use DB;
class WebController extends Controller
{
......@@ -97,7 +98,7 @@ class WebController extends Controller
$data['title']='PCB交易列表';
$data['order_type'] = PcbOrderMap::$order_type;
$data['status'] = PcbOrderMap::$status;
$data['shipping'] = objectToArray(DB::connection("order")->table("lie_shipping")->get());
$data['shipping'] = objectToArray(ShippingModel::get());
//分页
$response = (new PcbOrderModel())->getList();
$page = new Page($response[3], 10);
......@@ -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['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']) : "";
$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 : "" ;
//拼接收货信息
$RegionController = new RegionController();
......@@ -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['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']) : "";
$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 : "" ;
//拼接采购信息
......
<?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 OrderReturnItemsModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_return_items';
protected $primaryKey = 'return_items_id';
public $timestamps = false;
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderReturnItemsModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_return_items';
protected $primaryKey = 'return_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 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
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class ShoppingCartModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_shopping_cart';
protected $primaryKey = 'cart_id';
public $timestamps = false;
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class ShoppingCartModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_shopping_cart';
protected $primaryKey = 'cart_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 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;
class UserCompanyModel extends Model
{
protected $connection = 'order';
protected $connection = 'web';
protected $table = 'lie_user_company';
protected $primaryKey = 'com_id';
public $timestamps = false;
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserMainModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_main';
protected $primaryKey = 'user_id';
public $timestamps = false;
// 测试帐号
public function testMobile()
{
$testId = array();
$user = $this->where(['is_test' => 1])->select('user_id')->get()->toArray();
foreach ($user as $k => $v) {
$testId[$k] = $v['user_id'];
}
return $testId;
}
// 获取用户账号
public function getUserAccount($user_id)
{
return $this->where('user_id', $user_id)->select('user_id', 'mobile', 'email')->first();
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserMainModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_main';
protected $primaryKey = 'user_id';
public $timestamps = false;
// 测试帐号
public function testMobile()
{
$testId = array();
$user = $this->where(['is_test' => 1])->select('user_id')->get()->toArray();
foreach ($user as $k => $v) {
$testId[$k] = $v['user_id'];
}
return $testId;
}
// 获取用户账号
public function getUserAccount($user_id)
{
return $this->where('user_id', $user_id)->select('user_id', 'mobile', 'email')->first();
}
}
\ No newline at end of file
......@@ -71,16 +71,29 @@ return [
'strict' => false,
],
'order' => [
'web' => [
'driver' => 'mysql',
'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', ''),
'username' => env('DB_USERNAME_ORDER', ''),
'password' => env('DB_PASSWORD_ORDER', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'prefix' => env('DB_PREFIX_ORDER', ''),
'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