diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index 76e8760a..06a8790f 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -2,6 +2,7 @@ namespace app\controller\api\dataview; +use app\common\model\Company; use app\common\repositories\BaseRepository; use crmeb\basic\BaseController; use think\App; @@ -25,12 +26,30 @@ class Logistics extends BaseController // 三轮车列表 从供销系统获取 public function vehicleList() { - // 请求供销,供销查区域下的公司,在通过公司查三轮车列表 - $client = new \GuzzleHttp\Client(); - $getUrl = env('TASK_WORKER_HOST_URL') . '/api/index/vehicleCarList?areaCode='.$this->areaCode.'&streetCode='.$this->streetCode; - $response = $client->request('GET', $getUrl); - $result = json_decode($response->getBody(), true); - $list = $result['data']; + // 镇区域码为空,查区县的公司 + if (empty($this->streetCode)) { + $companyList = Db::connect('work_task')->name('company')->where('area', $this->areaCode)->select()->toArray(); + } else { + $companyList = Db::connect('work_task')->name('company')->where('street', $this->streetCode)->select()->toArray(); + } + $companyIds = array_column($companyList, 'id'); + // 查镇车辆列表 + $list = Db::connect('work_task')->name('vehicle_rent') + ->field('company_id, car_id as id, car_license as license') + ->append(['area_code','street_code']) + ->whereIn('company_id', $companyIds) + ->where('status','in','0,1,2') + ->withAttr('area_code', function ($value, $data){ + $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find(); + return $company['area']; + }) + ->withAttr('street_code', function ($value, $data){ + $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find(); + return $company['street']; + }) + ->group('company_id') + ->select()->toArray(); + $count = count($list); return app('json')->success(compact('count', 'list')); } @@ -50,6 +69,9 @@ class Logistics extends BaseController ->where('og.street_code', $this->streetCode) ->order('o.order_id', 'desc') ->find(); + if (empty($detail)) { + return app('json')->success([]); + } // 拼接商户的详细地址 area_id street_id village_id $area = Db::name('geo_area')->where('area_code', $detail['area_id'])->find(); $city = Db::name('geo_city')->where('city_code', $area['city_code'])->find(); diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index 73b4d416..6100d33a 100755 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -95,10 +95,8 @@ class Order extends BaseController $currOrderList = $currOrderCountQuery->page($page, $limit)->select()->toArray(); foreach ($currOrderList as $k => $order) { - $getUrl = env('LOGISTICS_HOST_URL') . '/api/courierData?order_sn=' . $order['order_sn']; - $response = $client->request('GET', $getUrl); - $courierData = json_decode($response->getBody(), true); - $currOrderList[$k]['courier'] = $courierData['data']['courier_name']; + $courierName = Db::connect('logistics')->name('logistics')->where(['order_sn'=>$order['order_sn']])->value('courier_name'); + $currOrderList[$k]['courier'] = $courierName; $currOrderList[$k]['status'] = $this->getStatusDesc($order['status']); } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index f0ceb9cf..559e979d 100755 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -47,7 +47,7 @@ class Merchant extends BaseController { parent::__construct($app); $this->repository = $repository; - $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null; + $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null; } /** @@ -58,21 +58,21 @@ class Merchant extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $where = $this->request->params(['store_category_id','keyword', 'order', 'is_best', 'location', 'category_id', 'type_id', 'type_code', 'is_trader', 'street_id', 'credit_buy']); + $where = $this->request->params(['merchant_category_id', 'keyword', 'order', 'is_best', 'location', 'category_id', 'type_id', 'type_code', 'is_trader', 'street_id', 'credit_buy']); if (empty($where['type_id'])) { - $where['type_id'] =[10,17]; + $where['type_id'] = [10, 17]; + } + if ($where['merchant_category_id'] > 0) { + // $arr= Db::name('store_category')->where(['pid'=>$where['store_category_id'],'mer_id'=>0,'level'=>1,'is_show'=>1])->column('cate_name'); + // if($arr){ + // $category_id=Db::name('merchant_category')->whereIn('category_name',$arr)->column('merchant_category_id'); + // if($category_id){ + // $where['category_id']=implode(',',$category_id); + // } + // } + $where['category_id'] = $where['merchant_category_id']; + unset($where['merchant_category_id']); } - // if($where['store_category_id']>0){ - // $arr= Db::name('store_category')->where(['pid'=>$where['store_category_id'],'mer_id'=>0,'level'=>1,'is_show'=>1])->column('cate_name'); - // if($arr){ - // $category_id=Db::name('merchant_category')->whereIn('category_name',$arr)->column('merchant_category_id'); - // if($category_id){ - // $where['category_id']=implode(',',$category_id); - // } - // } - // unset($where['store_category_id']); - // } - $where['category_id']=$where['store_category_id']??''; return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo)); } @@ -96,7 +96,7 @@ class Merchant extends BaseController public function systemDetail() { - $config = systemConfig(['site_logo', 'site_name','login_logo']); + $config = systemConfig(['site_logo', 'site_name', 'login_logo']); return app('json')->success([ 'mer_avatar' => $config['login_logo'], 'mer_name' => $config['site_name'], @@ -115,9 +115,9 @@ class Merchant extends BaseController public function productList($id) { [$page, $limit] = $this->getPage(); - $where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']); - if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊'); - return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo)); + $where = $this->request->params(['keyword', 'order', 'mer_cate_id', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']); + if (!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊'); + return app('json')->success($this->repository->productList($id, $where, $page, $limit, $this->userInfo)); } /** @@ -128,35 +128,34 @@ class Merchant extends BaseController */ public function categoryList($id) { - if(!$this->repository->merExists((int)$id)) + if (!$this->repository->merExists((int)$id)) return app('json')->fail('店铺已打烊'); return app('json')->success($this->repository->categoryList($id)); } public function qrcode($id) { - if(!$this->repository->merExists($id)) + if (!$this->repository->merExists($id)) return app('json')->fail('店铺已打烊'); - if ($this->request->param('type') == 'routine') { - $url= $this->repository->routineQrcode(intval($id)); - }elseif($this->request->param('type') == 'app'){ + if ($this->request->param('type') == 'routine') { + $url = $this->repository->routineQrcode(intval($id)); + } elseif ($this->request->param('type') == 'app') { $attachmentRepository = app()->make(AttachmentRepository::class); - $name='merchant_code_'.$id.'.png'; + $name = 'merchant_code_' . $id . '.png'; $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); - if($imageInfo){ - $url=$imageInfo['attachment_src']; - }else{ - $info = app()->make(QrcodeService::class)->getQRCodePath(systemConfig('site_url').'pages/store/home/index?id=' . $id, $name); + if ($imageInfo) { + $url = $imageInfo['attachment_src']; + } else { + $info = app()->make(QrcodeService::class)->getQRCodePath(systemConfig('site_url') . 'pages/store/home/index?id=' . $id, $name); $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $id, [ 'attachment_category_id' => 0, 'attachment_name' => $info['name'], 'attachment_src' => $info['dir'] ]); - $url=$info['dir']; + $url = $info['dir']; } - } - else{ - $url= $this->repository->wxQrcode(intval($id)); + } else { + $url = $this->repository->wxQrcode(intval($id)); } return app('json')->success(compact('url')); } @@ -177,13 +176,13 @@ class Merchant extends BaseController public function update(MerchantUpdateValidate $validate, MerchantTakeValidate $takeValidate, MerchantTakeRepository $repository) { - $type = $this->request->param('type',1); + $type = $this->request->param('type', 1); $id = $this->request->param('id'); - if(empty($id)){ + if (empty($id)) { return app('json')->fail('参数错误'); } - $merchant = Db::name('merchant')->where('mer_id',$id)->find(); + $merchant = Db::name('merchant')->where('mer_id', $id)->find(); if ($type == 2) { $data = $this->request->params([ 'mer_info', @@ -197,17 +196,17 @@ class Merchant extends BaseController 'mer_address', 'long', 'lat', - ['delivery_way',[2]], + ['delivery_way', [2]], 'credit_buy', 'settle_cycle', 'interest_rate', ]); - if(empty($data['service_phone'])) { + if (empty($data['service_phone'])) { return app('json')->fail('客户电话不能为空'); } // 如果手机号不存在,则使用入驻时的手机号 - $data['service_phone'] = empty($data['service_phone'])?$merchant['mer_phone']:$data['service_phone']; + $data['service_phone'] = empty($data['service_phone']) ? $merchant['mer_phone'] : $data['service_phone']; $validate->check($data); $sys_bases_status = systemConfig('sys_bases_status') === '0' ? 0 : 1; @@ -216,7 +215,7 @@ class Merchant extends BaseController $merCertificate = merchantConfig($id, 'mer_certificate'); if (!is_array($merCertificate)) { - $merCertificate = explode( ',', $merCertificate); + $merCertificate = explode(',', $merCertificate); } $merCertificate[0] = $data['mer_certificate']; app()->make(ConfigValueRepository::class)->setFormData([ @@ -235,15 +234,14 @@ class Merchant extends BaseController break; } } - $delivery_way = implode(',',$data['delivery_way']); + $delivery_way = implode(',', $data['delivery_way']); if (count($data['delivery_way']) == 1 && $data['delivery_way'] != $merchant['delivery_way']) { app()->make(ProductRepository::class)->getSearch([]) - ->where('mer_id',$merchant['mer_id']) + ->where('mer_id', $merchant['mer_id']) ->update(['delivery_way' => $delivery_way]); } $data['delivery_way'] = $delivery_way; - } else { $data = $this->request->params(['mer_state']); @@ -253,7 +251,7 @@ class Merchant extends BaseController if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine')) return app('json')->fail('开启店铺前请先完成微信子商户入驻'); } - Db::name('merchant')->where('mer_id',$id)->update($data); + Db::name('merchant')->where('mer_id', $id)->update($data); Queue::push(ChangeMerchantStatusJob::class, $id); return app('json')->success('修改成功'); @@ -267,11 +265,11 @@ class Merchant extends BaseController public function info(MerchantTakeRepository $repository) { $id = $this->request->param('id'); - if(empty($id)){ + if (empty($id)) { return app('json')->fail('参数错误'); } - $data = Db::name('merchant')->where('mer_id',$id)->find(); + $data = Db::name('merchant')->where('mer_id', $id)->find(); $data['mer_certificate'] = merchantConfig($id, 'mer_certificate'); $data['mer_certificate'] = $data['mer_certificate'][0] ?? ''; // $append = ['merchantCategory', 'merchantType', 'mer_certificate']; @@ -280,7 +278,7 @@ class Merchant extends BaseController // $data = $merchant->append($append)->hidden(['mark', 'reg_admin_id', 'sort'])->toArray(); $delivery = $repository->get($id) + systemConfig(['tx_map_key']); - $data = array_merge($data,$delivery); + $data = array_merge($data, $delivery); $data['sys_bases_status'] = systemConfig('sys_bases_status') === '0' ? 0 : 1; $data['type_code'] = Db::name('MerchantType')->where('mer_type_id', $data['type_id'])->value('type_code'); return app('json')->success($data); @@ -294,46 +292,47 @@ class Merchant extends BaseController public function marginInfo(MerchantTakeRepository $repository) { $id = $this->request->param('id'); - if(empty($id)){ + if (empty($id)) { return app('json')->fail('参数不能为空'); } - $merchantInfo = Db::name('merchant')->where('mer_id',$id)->field('uid,mer_id,type_id,mer_name,margin,paid_margin,is_margin')->find(); - if(empty($merchantInfo)){ + $merchantInfo = Db::name('merchant')->where('mer_id', $id)->field('uid,mer_id,type_id,mer_name,margin,paid_margin,is_margin')->find(); + if (empty($merchantInfo)) { return app('json')->fail('参数错误'); } $margin = Db::name('MerchantType')->where('mer_type_id', $merchantInfo['type_id'])->value('margin'); - $merchantInfo['unpaid_margin'] = bcsub($margin,$merchantInfo['paid_margin'],2); - if($merchantInfo['margin']==0){ - $merchantInfo['margin']=$merchantInfo['unpaid_margin']; + $merchantInfo['unpaid_margin'] = bcsub($margin, $merchantInfo['paid_margin'], 2); + if ($merchantInfo['margin'] == 0) { + $merchantInfo['margin'] = $merchantInfo['unpaid_margin']; } return app('json')->success($merchantInfo); } - public function apply($merId){ + public function apply($merId) + { $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } $extract_minimum_line = systemConfig('extract_minimum_line') ?: 0; $extract_minimum_num = systemConfig('extract_minimum_num'); - $_line = bcsub($merchant->mer_money,$extract_minimum_line,2); + $_line = bcsub($merchant->mer_money, $extract_minimum_line, 2); $_extract = ($_line < 0) ? 0 : $_line; $merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($merId); $data = [ - 'mer_id' => $merchant->mer_id,//商户id - 'mer_name' => $merchant->mer_name,//商户名称 - 'mer_money' => $merchant->mer_money,//商户余额 - 'lock_money' => $merLockMoney,//冻结金额 - 'lock_time' => systemConfig('mer_lock_time'),//冻结金额 - 'extract_minimum_line' => $extract_minimum_line,//提现最低额度 - 'extract_minimum_num' => $extract_minimum_num,//提现最低次数 - 'extract_money' => $_extract,//可提现金额 - 'financial_bank_name' => $merchant->financial_bank->name ?? '',//银行卡信息 - 'financial_bank_bank' => $merchant->financial_bank->bank ?? '',//银行卡信息 - 'financial_bank_code' => $merchant->financial_bank->bank_code ?? '',//银行卡信息 - 'financial_bank_branch' => $merchant->financial_bank->bank_branch ?? '',//开户行 - 'financial_type' => $merchant->financial_type,//提现方式 + 'mer_id' => $merchant->mer_id, //商户id + 'mer_name' => $merchant->mer_name, //商户名称 + 'mer_money' => $merchant->mer_money, //商户余额 + 'lock_money' => $merLockMoney, //冻结金额 + 'lock_time' => systemConfig('mer_lock_time'), //冻结金额 + 'extract_minimum_line' => $extract_minimum_line, //提现最低额度 + 'extract_minimum_num' => $extract_minimum_num, //提现最低次数 + 'extract_money' => $_extract, //可提现金额 + 'financial_bank_name' => $merchant->financial_bank->name ?? '', //银行卡信息 + 'financial_bank_bank' => $merchant->financial_bank->bank ?? '', //银行卡信息 + 'financial_bank_code' => $merchant->financial_bank->bank_code ?? '', //银行卡信息 + 'financial_bank_branch' => $merchant->financial_bank->bank_branch ?? '', //开户行 + 'financial_type' => $merchant->financial_type, //提现方式 ]; return app('json')->success($data); } @@ -346,7 +345,7 @@ class Merchant extends BaseController */ public function createApply($merId) { - $data = $this->request->param(['extract_money','financial_type', 'financial_bank_name', 'financial_bank_bank', 'financial_bank_code', 'financial_bank_branch']); + $data = $this->request->param(['extract_money', 'financial_type', 'financial_bank_name', 'financial_bank_bank', 'financial_bank_code', 'financial_bank_branch']); $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('reg_admin_id,uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); @@ -360,7 +359,7 @@ class Merchant extends BaseController $merchant->update(['financial_bank' => json_encode($bankInfo, JSON_UNESCAPED_UNICODE)], ['mer_id' => $merId]); $data['mer_admin_id'] = $merchant['reg_admin_id']; unset($data['financial_bank_name'], $data['financial_bank_bank'], $data['financial_bank_code'], $data['financial_bank_branch']); - app()->make(FinancialRepository::class)->saveApply($merId,$data); + app()->make(FinancialRepository::class)->saveApply($merId, $data); return app('json')->success('申请成功'); } @@ -372,9 +371,8 @@ class Merchant extends BaseController } [$page, $limit] = $this->getPage(); $where['mer_id'] = $merId; - $data = app()->make(FinancialRepository::class)->getAdminList($where,$page,$limit); + $data = app()->make(FinancialRepository::class)->getAdminList($where, $page, $limit); return app('json')->success($data); - } public function account($merId) @@ -384,17 +382,17 @@ class Merchant extends BaseController return app('json')->fail($msg); } $data = [ - 'financial_bank' => $merchant->financial_bank,//银行卡信息 - 'financial_wechat' => $merchant->financial_wechat,//微信信息 - 'financial_alipay' => $merchant->financial_alipay,//支付宝信息 - 'financial_type' => $merchant->financial_type,//提现方式 + 'financial_bank' => $merchant->financial_bank, //银行卡信息 + 'financial_wechat' => $merchant->financial_wechat, //微信信息 + 'financial_alipay' => $merchant->financial_alipay, //支付宝信息 + 'financial_type' => $merchant->financial_type, //提现方式 ]; return app('json')->success($data); } public function account_info($merId) { - $data = $this->request->param(['name','bank','bank_code','financial_type']); + $data = $this->request->param(['name', 'bank', 'bank_code', 'financial_type']); app()->make(MerchantFinancialAccountValidate::class)->check($data); $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { @@ -405,7 +403,7 @@ class Merchant extends BaseController 'bank' => $data['bank'], 'bank_code' => $data['bank_code'], ]; - app()->make(MerchantRepository::class)->update($merId,['financial_bank' => json_encode($update),'financial_type' => 1]); + app()->make(MerchantRepository::class)->update($merId, ['financial_bank' => json_encode($update), 'financial_type' => 1]); return app('json')->success('提交成功'); } diff --git a/config/database.php b/config/database.php index 6b4e9823..6732ec70 100644 --- a/config/database.php +++ b/config/database.php @@ -90,6 +90,47 @@ return [ // 数据库表前缀 'prefix' => env('database2.prefix', ''), + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => true, + // 监听SQL + 'trigger_sql' => env('app_debug', true), + // 开启字段缓存 + 'fields_cache' => false, + // 字段缓存路径 + 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, + ], + // 供销系统 + 'work_task' => [ + // 数据库类型 + 'type' => env('database3.type', 'mysql'), + // 服务器地址 + 'hostname' => env('database3.hostname', '127.0.0.1'), + // 数据库名 + 'database' => env('database3.database', ''), + // 用户名 + 'username' => env('database3.username', 'root'), + // 密码 + 'password' => env('database3.password', ''), + // 端口 + 'hostport' => env('database3.hostport', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 +// 'charset' => env('database.charset', 'utf8'), + 'charset' => 'utf8mb4', + // 数据库表前缀 + 'prefix' => env('database3.prefix', ''), + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 'deploy' => 0, // 数据库读写是否分离 主从式有效