diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index fc0df385..c79d475d 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -2437,11 +2437,20 @@ class StoreOrderRepository extends BaseRepository } return $query->select(); } + + /**导入库存 + * @param array $arrary + * @param $merId + * @return void + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ public function setProduct(array $arrary, $merId) { //读取excel $data = SpreadsheetExcelService::instance()->_import($arrary['path'], $arrary['sql'], $arrary['where'], 1); - if (!$data) return; + if (!$data) return false; unset($data[0]); $mer_cate_id=Db::name('store_category')->where('mer_id',$merId)->where('cate_name','默认分类')->value('store_category_id'); if (!$mer_cate_id ||$mer_cate_id==0){ @@ -2453,6 +2462,11 @@ class StoreOrderRepository extends BaseRepository $mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); } $make = app()->make(ProductRepository::class); + $type=Db::name('merchant')->where('mer_id',$merId)->value('type_id'); + $product_type=0; + if ($type==12){ + $product_type=98;//供应链 + } foreach ($data as $datum) { $find=Db::name('store_product')->where('mer_id', $merId)->where('bar_code', $datum['where']['bar_code'])->find(); if ($find){ @@ -2520,60 +2534,10 @@ class StoreOrderRepository extends BaseRepository "mer_status" => 1, "rate" => 3, ]; - $make->create($datas,98); + $make->create($datas,$product_type); } } - halt(22); - $import_id = $arrary['import_id']; - Db::transaction(function () use ($data, $merId, $import_id) { - $result = []; - $num = 0; - $count = 0; - $status = 0; - foreach ($data as $datum) { - $value = []; - $ret = []; - if ($datum['where']) { - $count = $count + 1; - if (empty($datum['value']['delivery_id'])) { - $mark = '发货单号为空'; - } else { - $ret = $this->getSearch([]) - ->where('status', 0) - ->where('paid', 1) - ->where('order_type', 0) - ->where('mer_id', $merId) - ->where($datum['where']) - ->find(); - $mark = '数据有误或已发货'; - } - if ($ret) { - try { - $value = array_merge($datum['value'], ['status' => 1]); - $value['delivery_type'] = 1; - $this->delivery($ret['order_id'], $merId, $value); - - $status = 1; - $mark = ''; - - $num = $num + 1; - } catch (\Exception $exception) { - $mark = $exception->getMessage(); - } - } - $datum['where']['mark'] = $mark; - $datum['where']['mer_id'] = $merId; - $datum['where']['status'] = $status; - $datum['where']['import_id'] = $import_id; - $result[] = array_merge($datum['where'], $datum['value']); - } - } - // 记录入库操作 - if (!empty($result)) app()->make(StoreImportDeliveryRepository::class)->insertAll($result); - $_status = ($count == $num) ? 1 : (($num < 1) ? -1 : 10); - app()->make(StoreImportRepository::class)->update($import_id, ['count' => $count, 'success' => $num, 'status' => $_status]); - }); - if (file_exists($arrary['path'])) unlink($arrary['path']); + return true; } } diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 81922ddc..1b209939 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -230,7 +230,7 @@ class ProductRepository extends BaseRepository $settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id); if ($productType ==0 ) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [],$data['mer_id']); $this->save($result->product_id, $settleParams, $content,$product,$productType); - if (in_array($productType, [0, 1])) { + if (in_array($productType, [0, 1,98])) { if ($productType == 1) { //秒杀商品 $dat = $this->setSeckillProduct($data); $dat['product_id'] = $result->product_id; @@ -785,7 +785,7 @@ class ProductRepository extends BaseRepository $where['product_type'] = $productType; if (!$merId) $where['is_gift_bag'] = 0; } - if ($productType == 1) { + if ($productType == 1||$productType==98) { $where['product_type'] = $productType; } if ($productType == 10) { diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index 918f9f4c..4be464e6 100644 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -156,6 +156,8 @@ class MerchantIntentionRepository extends BaseRepository if ($create) { $merchant = app()->make(MerchantRepository::class)->createMerchant($merData); $data['mer_id'] = $merchant->mer_id; + $data['uid'] = $intention['uid']; + $data['reg_admin_id'] = $merchant['merchant_admin']['merchant_admin_id']; // 写入商户客服表 $store_service_data['mer_id'] = $merchant->mer_id; $store_service_data['uid'] = $intention['uid']; diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 103dfa68..602ec6f5 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -252,7 +252,7 @@ class MerchantRepository extends BaseRepository unset($data['mer_account'], $data['mer_password']); $merchant = $this->dao->create($data); - $make->createMerchantAccount($merchant, $account, $password); + $merchant['merchant_admin']=$make->createMerchantAccount($merchant, $account, $password); $address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['street_id'],'area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); if($data['area_id'] && $data['village_id']){ Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index e935fa0a..9b76ff4a 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -189,7 +189,7 @@ class Merchant extends BaseController */ public function checkParam(MerchantValidate $validate, $isUpdate = false) { - $data = $this->request->params([['geo_street',0],['category_id', 0], ['type_id', 0], 'mer_name', 'commission_rate', 'real_name', 'mer_phone', 'mer_keyword', 'mer_address', 'mark', ['sort', 0], ['status', 0], ['is_audit', 0], ['is_best', 0], ['is_bro_goods', 0], ['is_bro_room', 0], ['is_trader', 0],'sub_mchid']); + $data = $this->request->params([['area_id',0],['street_id',0],['village_id',0],['geo_street',0],['category_id', 0], ['type_id', 0], 'mer_name', 'commission_rate', 'real_name', 'mer_phone', 'mer_keyword', 'mer_address', 'mark', ['sort', 0], ['status', 0], ['is_audit', 0], ['is_best', 0], ['is_bro_goods', 0], ['is_bro_room', 0], ['is_trader', 0],'sub_mchid']); if (!$isUpdate) { $data += $this->request->params(['mer_account', 'mer_password']); }else { diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 28e8fb17..9911f07c 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -15,7 +15,10 @@ namespace app\controller\api\store\merchant; use app\common\repositories\store\MerchantTakeRepository; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\system\config\ConfigValueRepository; +use app\common\repositories\system\financial\FinancialRepository; +use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\user\UserMerchantRepository; +use app\validate\merchant\MerchantFinancialAccountValidate; use app\validate\merchant\MerchantTakeValidate; use app\validate\merchant\MerchantUpdateValidate; use crmeb\jobs\ChangeMerchantStatusJob; @@ -231,4 +234,84 @@ class Merchant extends BaseController return app('json')->success($data); } + 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 ($this->userInfo['uid'] != $merchant->uid){ + return app('json')->fail('你不是管理员无法进行提现操作'); + } + $extract_minimum_line = systemConfig('extract_minimum_line') ?: 0; + $extract_minimum_num = systemConfig('extract_minimum_num'); + $_line = bcsub($merchant->mer_money,$extract_minimum_line,2); + $_extract = ($_line < 0) ? 0 : $_line; + $data = [ + 'mer_id' => $merchant->mer_id,//商户id + 'mer_name' => $merchant->mer_name,//商户名称 + 'mer_money' => $merchant->mer_money,//商户余额 + '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_type' => $merchant->financial_type,//提现方式 + ]; + return app('json')->success($data); + } + public function createApply($merId) + { + $data = $this->request->param(['extract_money','financial_type']); + $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 ($this->userInfo['uid'] != $merchant->uid){ + return app('json')->fail('你不是管理员无法进行提现操作'); + } + $data['mer_admin_id'] = $merchant['reg_admin_id']; + app()->make(FinancialRepository::class)->saveApply($merId,$data); + return app('json')->success('申请成功'); + } + + public function listApply($merId) + { + $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 ($this->userInfo['uid'] != $merchant->uid){ + return app('json')->fail('你不是管理员无法进行提现操作'); + } + [$page, $limit] = $this->getPage(); + $where['mer_id'] = $merId; + $data = app()->make(FinancialRepository::class)->getAdminList($where,$page,$limit); + return app('json')->success($data); + + } + + public function account($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 ($this->userInfo['uid'] != $merchant->uid){ + return app('json')->fail('你不是管理员无法进行提现操作'); + } + $data = [ + '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']); + 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 ($this->userInfo['uid'] != $merchant->uid){ + return app('json')->fail('你不是管理员无法进行提现操作'); + } + $update = [ + 'name' => $data['name'], + 'bank' => $data['bank'], + 'bank_code' => $data['bank_code'], + ]; + app()->make(MerchantRepository::class)->update($merId,['financial_bank' => json_encode($update),'financial_type' => 1]); + return app('json')->success('提交成功'); + } } diff --git a/app/controller/merchant/store/StoreImport.php b/app/controller/merchant/store/StoreImport.php index 1eb86cbc..8b83d112 100644 --- a/app/controller/merchant/store/StoreImport.php +++ b/app/controller/merchant/store/StoreImport.php @@ -89,7 +89,7 @@ class StoreImport extends BaseController $path = rtrim(public_path(),'/').$res['dir']; $data = []; switch ($type){ - case 'delivery': + case 'product': $check =[ 'A1'=>'商品名称', 'B1'=>'商品简介', @@ -111,9 +111,9 @@ class StoreImport extends BaseController ] ]; app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id']); - + return app('json')->success('开始导入数据,请稍后在列表中查看!'); break; - case 'product' : + case 'delivery' : SpreadsheetExcelService::instance()->checkImport($path,['E3' => '物流单号']); $data = [ 'mer_id' => $this->request->merId(), @@ -131,9 +131,7 @@ class StoreImport extends BaseController if(!empty($data)){ $res = $this->repository->create($this->request->merId(),'delivery'); $data['data']['import_id'] = $res->import_id; - -// app()->make(StoreOrderRepository::class)->setWhereDeliveryStatus($data['data'],$data['mer_id']); - + app()->make(StoreOrderRepository::class)->setWhereDeliveryStatus($data['data'],$data['mer_id']); Queue::push(ImportSpreadsheetExcelJob::class,$data); return app('json')->success('开始导入数据,请稍后在批量发货记录中查看!'); } diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index efa05be0..d7a6e834 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -49,6 +49,10 @@ class Product extends BaseController [$page, $limit] = $this->getPage(); $where = $this->request->params(['temp_id','cate_id','keyword',['type',1],'mer_cate_id','is_gift_bag','status','us_status','product_id','mer_labels',['order','sort'],'is_ficti','svip_price_type']); $where = array_merge($where,$this->repository->switchType($where['type'],$this->request->merId(),0)); + $type=$this->request->merchant()['type_id']; + if ($type==12){ + $where['product_type']=98;//供应链 + } return app('json')->success($this->repository->getList($this->request->merId(),$where, $page, $limit)); } @@ -147,7 +151,12 @@ class Product extends BaseController */ public function getStatusFilter() { - return app('json')->success($this->repository->getFilter($this->request->merId(),'商品',0)); + $type=$this->request->merchant()['type_id']; + $product_type=0; + if ($type==12){ + $product_type=98;//供应链 + } + return app('json')->success($this->repository->getFilter($this->request->merId(),'商品',$product_type)); } /** diff --git a/route/api.php b/route/api.php index ef867c5c..92947ada 100644 --- a/route/api.php +++ b/route/api.php @@ -321,6 +321,13 @@ Route::group('api/', function () { })->prefix('api.server.StoreOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class,0); + //管理员申请转账 + Route::get('admin/:merId/apply', 'api.store.merchant.Merchant/apply'); + Route::post('admin/:merId/create_apply', 'api.store.merchant.Merchant/createApply'); + Route::get('admin/:merId/lis_apply', 'api.store.merchant.Merchant/listApply'); + Route::get('admin/:merId/account_apply', 'api.store.merchant.Merchant/account'); + Route::post('admin/:merId/account_apply', 'api.store.merchant.Merchant/account_info'); + //管理员退款单 Route::group('server/:merId/refund', function () { //退款单