| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276 |
- <?php
- /**
- * @package merchant
- *
- * @author Qinii
- * @day 2020-07-18
- *
- *
- */
- namespace app\controller\admin\system\merchant;
- use AdaPaySdk\AdapayTools;
- use app\common\model\merchant\MerchantQrcode;
- use app\common\repositories\merchant\apply\MerchantHaikeApplyRepository;
- use app\common\repositories\merchant\apply\MerchantLakalaApplyRepository;
- use app\common\repositories\system\attachment\AttachmentRepository;
- use app\controller\Rsa;
- use app\model\Offline\HuifuMemberEnterprise;
- use crmeb\services\QrcodeService;
- use think\App;
- use crmeb\basic\BaseController;
- use app\common\repositories\system\merchant\MerchantIntentionRepository;
- use think\db\Where;
- use think\Exception;
- use think\exception\ValidateException;
- use think\facade\Db;
- use Lakala\src\LakalaBoss;
- use think\facade\Log;
- class MerchantIntention extends BaseController
- {
- /**
- * @var MerchantIntentionRepository
- */
- protected $repository;
- /**
- * MerchantIntention constructor.
- * @param App $app
- * @param MerchantIntentionRepository $repository
- */
- public function __construct(App $app, MerchantIntentionRepository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- public function lst()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['keyword', 'status', 'date', 'account']);
- return app('json')->success($this->repository->getList($where, $page, $limit));
- }
- public function form($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->markForm($id)));
- }
- public function statusForm($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->statusForm($id)));
- }
- public function mark($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $data = $this->request->params([
- 'type','logo','mer_name','mer_short_name','addr','open_account','acc_type',
- 'bank_account','bank_deposit','bank_branch',
- 'name','phone','email','spread_account',
- 'card_positive_person','card_back_person','identification_valid_date_start','identification_valid_date_end','idcard_no','business_premises2','business_premises3','business_premises4','doorhead','business_license','business_addr','house_number','credit_code','haike_wx_type','haike_ali_type','haike_wx_appid','agent_apply_no'
- ]);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- $this->repository->update($id, $data);
- return app('json')->success('修改成功');
- }
- public function switchStatus($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $status = $this->request->param('status', 0) == 1 ? 1 : 2;
- $check_result = $this->request->param('check_result', '');
- $mer_id = 0;
- if ($status == 1){
- $activation_code=Db::name('merchant_intention')->where('mer_intention_id',$id)->value('activation_code');
- Db::name('activation_code')->where('code',$activation_code)->update(['status'=>3,'utime'=>time()]);
- //审核通过 创建商户
- $result = $this->repository->createMer($id);
- if ($result['code'] != 200) {
- return app('json')->fail($result['msg']);
- }
- $mer_id = $result['data'];
- /*首信易入网*/
- // $this -> sxyApply($id);
- /*首信易end*/
- /*汇付入网*/
- // $this->huihupay($id);
- /*汇付入网end*/
- }else{
- $activation_code=Db::name('merchant_intention')->where('mer_intention_id',$id)->value('activation_code');
- $mer_id=Db::name('merchant_intention')->where('mer_intention_id',$id)->value('mer_id');
- Db::name('activation_code')->where('code',$activation_code)->update(['status'=>3,'utime'=>time()]);
- }
- $res = $this->repository->update($id, ['status' => 3,'check_result' => $check_result, "mer_id"=>$mer_id]);
- if($res['code'] == 400){
- return app('json')->fail($res['msg']);
- }
- return app('json')->success('修改成功');
- }
- public function UpgradeToMerchant($id,$type)
- {
- try {
- $data=Db::name('merchant_intention')->where('mer_id',$id)->find();
- if($type=='wx'){
- $name='0001';
- }else{
- // $data['phone']='17724847560';
- $name='config';
- }
- // $jinjian_data=$this->jinjian_data($data);
- // $res=$this->repository ->UpgradeToMerchants($jinjian_data,$name);//1642668206737383
- $res=[
- 'request_id'=>'1643271204838377'//ID
- ];
- $jinjian_query=$this->repository ->incoming_select(['request_id'=>$res['request_id']],$name);//进件查询
- // Db::name('log')->insert(['data'=>'进件查询']);
- // if(!empty($jinjian_query['error_type']))
- // return app('json')->fail('进件失败请重新尝试--可能的原因:'.$data['error_msg']);
- // if($type=='wx'){
- // Db::name('merchant_intention')->where('mer_id',$id)->update(['hf_api_key_wx'=>$jinjian_query['live_api_key'],'app_id_wx'=>$jinjian_query['app_id_list']['0']['app_id']]);
- // }else{
- // Db::name('merchant_intention')->where('mer_id',$id)->update(['hf_api_key'=>$jinjian_query['live_api_key'],'app_id'=>$jinjian_query['app_id_list']['0']['app_id']]);
- // }
- $ruzhu_data=$this->ruzhu_data($jinjian_query,$data);
- //
- // $ruzhu=$this->repository->ruzhu($ruzhu_data,$name);
- // dump($ruzhu);
- //// $ruzhu_data['request_id']='1646545572847297';
- // $ruzhu=$this->repository->ruzhu_query(['request_id'=>$ruzhu_data['request_id']],$name);
- // dump($ruzhu);
- $pic=Db::name('merchant_intention')->where('mer_id',$id)->find();
- //
- //
- // $shenhe_data=$this->shenhe_data($pic,$name);
- // $shenhe_commit=$this->shenhe_commit($shenhe_data,'api_live_2d788178-808b-4d73-bd9f-17c0d09cec44');
- // $commit_res=$this->repository->commit_res($shenhe_commit,$name);
- // $commit_res=$this->repository->commit_res_query(['subApiKey'=>'api_live_2d788178-808b-4d73-bd9f-17c0d09cec44']);
- // dump($commit_res);
- // $mer_id='276';
- $mer_id = $id;
- $this -> repository -> huifu_create($id,1,'api_live_b3a56559-bb1a-42d0-89e2-b1d85e04a655','app_f3cba57b-15f3-4135-afda-ebe9fe3416ce',$mer_id);
- $this -> repository -> huifu_create($id,2,'api_live_68c25d10-2808-4042-8659-900e7b98ed1f','app_bd63b366-dbf1-4c66-97ef-a1438e9c935e',$mer_id);
- // $this -> repository -> huifu_create($id,1,'api_live_e266401e-24d2-456a-b0b2-9810b357590a','app_64c0ff62-75e7-470f-b45e-8758cef009ee',$mer_id);
- // $this -> repository -> huifu_create($id,2,'api_live_2d788178-808b-4d73-bd9f-17c0d09cec44','app_fbcc4676-42d4-44d2-af97-05c85e2deef6',$mer_id);
- }catch (Exception $exception){
- Db::name('log')->insert(['data'=>'入驻失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);
- }
- }
- public function delete($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $this->repository->update($id, ['is_del' => 1]);
- return app('json')->success('删除成功');
- }
- /**
- * 发起海科入网
- * @return mixed
- * @author php迷途小书童
- * @created 2021/2/3 15:55
- */
- public function apply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $intention = $this->repository->getDetail(['mer_intention_id'=>$id]);
- $applyData = [];
- try {
- $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $haikeApply = $haikeRepository->getWhere(['apply_id' => $intention['mer_intention_id'],'apply_type' => 1]);
- if (!$intention['merch_no']) {
- $applyData = ['mer_intention_id' => $id,'is_again' => 0];
- } else if (in_array($haikeApply->status, [1,5,6])){
- $applyData = ['mer_intention_id' => $id,'is_again' => 1,'merch_no' => $intention['merch_no']];
- } else if (in_array($haikeApply->status, [3,4,7])){
- $applyData = ['mer_intention_id' => $id,'is_again' => 2,'merch_no' => $intention['merch_no']];
- }
- if (empty($applyData))
- return app('json')->fail('当前无修改信息的条件');
- $return = $haikeRepository->createOrder($applyData);
- if ($return['code'] != 200) {
- return app('json')->fail($return['msg']);
- }
- } catch (\Throwable $e) {
- return app('json')->fail($e->getMessage());
- }
- return app('json')->success('发起申请成功');
- }
- /**
- * 海科入网微信业务申请
- * @return mixed
- * @author php迷途小书童
- * @created 2021/2/3 15:55
- */
- public function wxApply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- try {
- $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $return = $haikeRepository->haikeWxApply(['mer_intention_id' => $id]);
- if ($return['return_code'] != 200) {
- return app('json')->fail($return['return_msg']);
- }
- } catch (\Throwable $e) {
- return app('json')->fail($e->getMessage());
- }
- return app('json')->success('发起申请成功');
- }
- /**
- * 海科入网微信业务申请-二次认证
- * @return mixed
- * @author php迷途小书童
- * @created 2021/2/3 15:55
- */
- public function wxAuthApply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- try {
- $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $return = $haikeRepository->haikeWxAuthApply(['mer_intention_id' => $id]);
- if ($return['code'] != 200) {
- return app('json')->fail($return['msg']);
- }
- //配置微信公众号
- $return = $haikeRepository->haikeWxAppidConfAdd(['mer_intention_id' => $id]);
- if ($return['return_code'] != 200) {
- return app('json')->fail($return['return_msg']);
- }
- } catch (\Throwable $e) {
- return app('json')->fail($e->getMessage());
- }
- return app('json')->success('发起申请成功');
- }
- /**
- * 海科入网支付宝业务申请
- * @return mixed
- * @author php迷途小书童
- * @created 2021/2/3 15:55
- */
- public function aliApply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- try {
- $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $return = $haikeRepository->haikeAliApply(['mer_intention_id' => $id]);
- if ($return['return_code'] != 200) {
- return app('json')->fail($return['return_msg']);
- }
- } catch (\Throwable $e) {
- return app('json')->fail($e->getMessage());
- }
- return app('json')->success('发起申请成功');
- }
- /*详情*/
- public function detail($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id]))
- return app('json')->fail('数据不存在');
- $data = $this->repository->getDetail(['mer_intention_id'=>$id]);
- return app("json")->success("获取成功",$data);
- }
- /**
- * 首信易入网all
- * */
- public function sxyApplyAll(){
- set_time_limit(0);
- // $intention=Db::name("merchant_intention")
- // //审核通过//海科入网通过//未在首信易入网
- // -> where("status = 1 and sxy_declare_id = 0 and merch_no != ''")
- // -> field("mer_intention_id")
- // ->select();
- $intention = Db::name("declare_log") -> where("`declare` = 2") -> field("m_id") -> select();
- if($intention){
- $intention = $intention -> toArray();
- foreach ($intention as $key => $value){
- // $this -> repository -> createSXY($value['mer_intention_id']);
- $this -> repository -> createSXY($value['m_id']);
- sleep(10);
- }
- }
- }
- /**
- * 首信易入网
- * */
- public function sxyApply($id){
- $merchant=Db::name('merchant_intention')->alias('mi')->leftJoin('merchant m','m.mer_id=mi.mer_id')->where('mi.mer_intention_id',$id)->field('m.*')->find();
- if(!$merchant){
- return app('json')->fail('该入驻申请还未开店');
- }
- $result = $this -> repository -> sxyStatus($id);
- if($result['code']==1){
- return app('json')->fail('首信易正在审核');
- }
- Db::name('log')->insert(['data'=>'自动审核通过接着执行_首信易']);
- Db::name('log')->insert(['data'=>'商户自动审核通通过首信易入网1=='.$id,'time'=>date('Y-m-d H:i:s',time())]);
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return false;
- Db::name('log')->insert(['data'=>'商户自动审核通通过首信易入网2=='.$id,'time'=>date('Y-m-d H:i:s',time())]);
- $res = $this -> repository -> createSXY($id);
- return app('json')->success('申请已提交');
- }
- /**
- * @param $id
- * #@return int
- */
- public function huihupay($id)
- {
- $merchant=Db::name('merchant_intention')->alias('mi')->leftJoin('merchant m','m.mer_id=mi.mer_id')->where('mi.mer_intention_id',$id)->field('m.*')->find();
- if(!$merchant){
- return app('json')->fail('该入驻申请还未开店');
- }
- $merchant=Db::name('merchant_intention')->where('mer_intention_id',$id)->find();
- if($merchant['hf_status']==1){
- return app('json')->fail('汇付正在审核');
- }elseif ($merchant['hf_status']==2){
- return app('json')->fail('汇付审核已通过');
- }
- $user_group = Db::name('user')->where('uid', $merchant['uid'])->value('user_group');
- if ($user_group != 1) {
- return app('json')->fail('非消费者身份,不可调整成创客身份');
- }
- Db::name('log')->insert(['data'=>'自动审核通过接着执行_汇付']);
- Db::name('log')->insert(['data'=>'商户自动审核通过汇付入网1=='.$id,'time'=>date('Y-m-d H:i:s',time())]);
- // if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- // return false;
- Db::name('log')->insert(['data'=>'商户自动审核通过汇付入网2=='.$id,'time'=>date('Y-m-d H:i:s',time())]);
- //微信支付
- //支付宝和微信信息不在同一个账户上所以需要进行两次创建用户
- $res=$this -> repository -> huifu_create($id,1);// 支付宝 创建用户
- $res=$this -> repository -> huifu_create($id,2);// 微信 创建用户
- // return $id.'-----汇付创建完成';
- // sleep(5);
- // //支付宝支付
- // $this -> repository -> huifu_create($id,'1');
- return app('json')->success('申请已提交');
- }
- /**
- * 发起拉卡拉入网
- * @return mixed
- * @created 2021/2/5 15:55
- */
- public function lakalaApply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $intention = $this->repository->getDetail(['mer_intention_id'=>$id]);
- // try {
- // $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- if (!$intention['merch_no']) {
- $applyData = ['mer_intention_id' => $id,'is_again' => false];
- } else {
- $applyData = ['mer_intention_id' => $id,'is_again' => 1,'merch_no' => $intention['merch_no']];
- }
- // $return = $this->lakalaru($applyData,$id);
- // return app('json')->fail($applyData);
- $return = $lakalaRepository->createOrderlakala($applyData);
- return app('json')->fail($return);
- if ($return['code'] != 200) {
- return app('json')->fail($return);
- }
- // } catch (\Throwable $e) {
- // return app('json')->fail($e->getMessage());
- // }
- return app('json')->success("申请成功");
- }
- /**
- * 发起拉卡拉商户入驻
- * @return mixed
- * @created 2021/2/5 15:55
- */
- public function lakalaMerApply($id)
- {
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
- return app('json')->fail('数据不存在');
- $intention = $this->repository->getDetail(['mer_intention_id'=>$id]);
- // try {
- // $haikeRepository = app()->make(MerchantHaikeApplyRepository::class);
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- if (!$intention['merch_no']) {
- $applyData = ['mer_intention_id' => $id,'is_again' => false];
- } else {
- $applyData = ['mer_intention_id' => $id,'is_again' => 1,'merch_no' => $intention['merch_no']];
- }
- // $return = $this->lakalaru($applyData,$id);
- // return app('json')->fail($applyData);
- $return = $lakalaRepository->createOrderlakala($applyData);
- return app('json')->success($return);
- // if ($return['code'] != 200) {
- // return app('json')->fail($return);
- // }
- // } catch (\Throwable $e) {
- // return app('json')->fail($e->getMessage());
- // }
- // return app('json')->success("申请成功");
- }
- /**
- * 手机号绑定
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function lakalacheck($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- // $intention = $this->repository->getDetail(['mer_intention_id'=>$id]);
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->createMobileMember($params);
- return app('json')->success($return);
- }
- /**
- * 企业信息认证
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function createCompanyVerify($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- // MerchantIntentionApplyRepository
- // $intentionRepository = app()->make(MerchantIntentionRepository::class);
- // $intention = $intentionRepository->getOne(['mer_intention_id' => $params['apply_id']]);
- $intention=Db::name("merchant_intention")->where(['mer_intention_id' => $params['apply_id']])->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->createCompanyVerify($params,$intention);
- return app('json')->success($return);
- }
- /**
- * 首笔支付认证确认_对公卡
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function memberBankBind($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- // MerchantIntentionApplyRepository
- // $intentionRepository = app()->make(MerchantIntentionRepository::class);
- // $intention = $intentionRepository->getOne(['mer_intention_id' => $params['apply_id']]);
- $intention=Db::name("merchant_intention")->where(['mer_intention_id' => $params['apply_id']])->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->memberBankBind($params,$intention);
- return app('json')->success($return);
- }
- /**
- * 开通商户
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function createMerchant($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- // MerchantIntentionApplyRepository
- // $intentionRepository = app()->make(MerchantIntentionRepository::class);
- // $intention = $intentionRepository->getOne(['mer_intention_id' => $params['apply_id']]);
- $intention=Db::name("merchant_intention")->where(['mer_intention_id' => $params['apply_id']])->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->createMerchant($params,$intention);
- return app('json')->success($return);
- }
- /**
- * 商户绑定
- */
- public function memberMerchantBind($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- $intention=Db::name("merchant_intention")->where(['mer_intention_id' => $params['apply_id']])->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->memberMerchantBind($params);
- return app('json')->success($return);
- }
- /**
- * 开通支付账户(URL)
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function payAccount($id){
- if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])){
- return app('json')->fail('数据不存在');
- }
- $params=Db::name("merchant_lakala_apply")->where("apply_id",$id)->find();
- $lakalaRepository = app()->make(MerchantLakalaApplyRepository::class);
- $return = $lakalaRepository->payAccount($params);
- return app('json')->success($return);
- }
- // public function lakalacheck($id){
- //// $ids = Db::name("store")->where(['id'=>$ids])->find();
- // $ids = $this->repository->getDetail(['mer_intention_id'=>$id]);
- // if($ids['mer_intention_id']){
- // //查询拉卡拉进件
- // $lakalaBoss = LakalaBoss::getInstance();
- // $result = $lakalaBoss->selectStore($ids['mer_intention_id'],$ids['request_id']);
- // if($result['code'] == 0){
- // if($result['data']['status'] == 'S'){
- // return app('json')->success('开户成功!');
- // }elseif($result['data']['status'] == 'F'){
- // return app('json')->fail("开户失败!");
- // }elseif($result['data']['status'] == 'P'){
- // return app('json')->fail("开户处理中!");
- // }
- // }else{
- // return app('json')->fail($result['message']);
- // }
- // }
- // return app('json')->fail("非法操作!");
- // }
- public function getQrcodeList(){
- [$page, $limit] = $this->getPage();
- $params = $this->request->params(['status', 'account']);
- if(isset($params['account']) && $params['account'] != ''){
- $list = Db::name("MerchantQrcode")
- -> alias("qr")
- -> join("Merchant mer","qr.mer_id = mer.mer_id")
- -> where("mer.mer_phone",$params['account'])
- -> field("qr.*")
- -> find();
- if(!$list) return app('json')->fail('查无结果');
- $list = [$list];
- $count = 1;
- }else{
- switch ($params['status']){
- case "3"://未绑定二维码
- $list = Db::name('MerchantQrcode') -> where("uid",0) -> where("mer_id",0) -> page($page,$limit) -> select();
- $count = Db::name('MerchantQrcode') -> where("uid",0) -> where("mer_id",0) -> count();
- break;
- case "2"://申请中商户二维码
- $list = Db::name('MerchantQrcode') -> where("uid","<>",0) -> where("mer_id",0) -> page($page,$limit) -> select();
- $count = Db::name('MerchantQrcode') -> where("uid","<>",0) -> where("mer_id",0) -> count();
- break;
- case "1"://已绑定二维码
- $list = Db::name('MerchantQrcode') -> where("uid","<>",0) -> where("mer_id","<>",0) -> page($page,$limit) -> select();
- $count = Db::name('MerchantQrcode') -> where("uid","<>",0) -> where("mer_id","<>",0) -> count();
- break;
- default:
- $list = Db::name('MerchantQrcode') -> page($page,$limit) -> select();
- $count = Db::name('MerchantQrcode') -> count();
- break;
- }
- if($list){
- $list = $list -> toArray();
- }
- }
- if(!$list) return app('json')->fail('查无结果');
- foreach ($list as $key => $value){
- $list[$key]['status'] = 0;
- $list[$key]['mer_name'] = '';
- if($value['uid'] != 0 && $value['mer_id'] != 0){
- $list[$key]['status'] = 1;//审核通过
- $list[$key]['mer_name'] = Db::name("merchant")->where(['mer_id' => $value['mer_id']])->value('mer_name');
- }
- if($value['uid'] != 0 && $value['mer_id'] == 0){
- $list[$key]['status'] = 2;//申请中
- $list[$key]['mer_name'] = Db::name("merchant_intention")->where(['uid' => $value['uid']])->value('mer_name');
- }
- }
- $return['count'] = $count;
- $return['list'] = $list;
- return app('json')->success($return);
- }
- /**
- * @remarks 检索渠道商手机号是否存在 返回 uid
- * @author Tang
- * @created 2021/8/30 11:32
- */
- public function search_Channel()
- {
- $phone = $this->request->params(['phone']);
- if(!$phone){
- return app('json')->fail('请输入要检索手机号码');
- }
- $uid=Db::name('user')
- ->alias('u')
- ->where('u.phone',$phone['phone'])
- ->where('u_a.identity',6)
- ->rightJoin('user_agent u_a','u.uid = u_a.user_id')
- ->field('u_a.id,u.uid')
- ->find();
- if($uid){
- return app('json')->success($uid['uid']);
- }else{
- return app('json')->fail('查无结果');
- }
- }
- public function createQrcode(){
- $num = $this->request->params(['num']);
- $phone = $this->request->params(['phone']);
- // $uid = $this->request->params(['uid']);
- // if(!$uid){
- // return app('json')->fail('请检查参数');
- // }
- $uid = 0;
- if(!empty($phone['phone'])){
- $qudao=Db::name('user')
- ->alias('u')
- ->where('u.phone',$phone['phone'])
- ->where('u_a.identity',6)
- ->rightJoin('user_agent u_a','u.uid = u_a.user_id')
- ->field('u_a.id,u.uid')
- ->find();
- if(!$qudao) {
- return app('json')->fail('此运营商不存在');
- }
- $uid = $qudao['uid'];
- }
- $max = $num['num'] <= 100 ? $num['num'] : 100;
- $siteUrl = systemConfig('site_url');
- $attachmentRepository = app()->make(AttachmentRepository::class);
- $urlCode = [];
- $codeInsert = [];
- $show_src_array = [];
- for($i = 0;$i < $max;$i++){
- $id = $this -> getNewQrcodeId();
- $name = "offlinepay_".$id.".jpg";
- $codeUrl = set_http_type(rtrim($siteUrl, '/') .'/offlinepay/index.html?id=' . $id, request()->isSsl() ? 0 : 1);//二维码链接
- $imageInfo = app()->make(QrcodeService::class)->getQRCodePath($codeUrl, $name);
- if (!is_string($imageInfo)){
- $imageInfo['dir'] = path_to_url($imageInfo['dir']);
- if (strpos($imageInfo['dir'], 'http') === false) $imageInfo['dir'] = request()->domain() . $imageInfo['dir'];
- $attachmentRepository->create(systemConfig('upload_type') ?: 1, 0, 0, [
- 'attachment_category_id' => 0,
- 'attachment_name' => $imageInfo['name'],
- 'attachment_src' => $imageInfo['dir']
- ]);
- $show_src = $this -> show_src($imageInfo['dir'],$id);
- if(!empty($show_src)){
- $codeInsert[] = [
- 'uid'=>0,
- 'mer_id' =>0,
- 'code_id'=>$id,
- 'qrcode_src' => $imageInfo['dir'],
- 'show_src' => $show_src,
- 'user_id'=>$uid
- ];
- $urlCode[] = $imageInfo['dir'];
- $show_src_array[]=$show_src;
- }
- }
- unset($imageInfo);
- }
- Db::name('MerchantQrcode') -> insertAll($codeInsert);
- $zip = $this->addzip($show_src_array,$phone['phone']);
- return app('json') -> success(
- [
- 'num'=>count($urlCode),
- 'zip'=>$zip
- ]
- );
- }
- /**
- * 获取唯一id号
- */
- public function getNewQrcodeId()
- {
- list($msec, $sec) = explode(' ', microtime());
- $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
- $id = $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
- return $id;
- }
- /**
- * 二维码美化
- * */
- public function show_src($qrcode,$id)
- {
- $siteUrl = systemConfig('site_url');
- $uploadType = (int)systemConfig('upload_type') ?: 1;
- $resWap = true;
- $spreadBanner = systemConfig('show_qrcode');
- $attachmentRepository = app()->make(AttachmentRepository::class);
- //检测远程文件是否存在
- if (isset($qrcode) && strstr($qrcode, 'http') !== false && curl_file_exist($qrcode) === false) {
- $qrcode = null;
- }
- if (!$qrcode) {
- return false;
- } else $urlCode = $qrcode;
- $siteUrl = set_http_type($siteUrl, request()->isSsl() ? 0 : 1);
- $filelink = [
- 'Bold' => 'public/font/Alibaba-PuHuiTi-Regular.otf',
- 'Normal' => 'public/font/Alibaba-PuHuiTi-Regular.otf',
- ];
- if (!file_exists($filelink['Bold'])) throw new ValidateException('缺少字体文件Bold');
- if (!file_exists($filelink['Normal'])) throw new ValidateException('缺少字体文件Normal');
- $posterInfo = '收款码生成失败:(';
- $config = array(
- 'image' => array(
- array(
- 'url' => $urlCode, //二维码资源
- 'stream' => 0,
- 'left' => 182,
- 'top' => 505,
- 'right' => 0,
- 'bottom' => 0,
- 'width' => 581,
- 'height' => 581,
- 'opacity' => 100
- )
- ),
- 'text' => array(
- array(
- 'text' => $id,
- 'left' => 250,
- 'top' => 1200,
- 'fontPath' => $filelink['Bold'], //字体文件
- 'fontSize' => 32, //字号
- 'fontColor' => '40,40,40', //字体颜色
- 'angle' => 0,
- )
- ),
- 'background' => $spreadBanner
- );
- $resWap = $resWap && $posterInfo = setSharePoster($config, 'wap/spread/poster');
- if (!is_array($posterInfo)) throw new ValidateException('收款码生成失败');
- $posterInfo['dir'] = path_to_url($posterInfo['dir']);
- if (strpos($posterInfo['dir'], 'http') === false) $posterInfo['dir'] = request()->domain() . $posterInfo['dir'];
- $attachmentRepository->create($uploadType, 0, 0, [
- 'attachment_category_id' => 0,
- 'attachment_name' => $posterInfo['name'],
- 'attachment_src' => $posterInfo['dir']
- ]);
- if ($resWap) {
- if ($posterInfo['image_type'] == 1)
- $wap_poster = rtrim($siteUrl, '/') . $posterInfo['thumb_path'];
- else
- $wap_poster = set_http_type($posterInfo['thumb_path'], 1);
- }
- return $wap_poster ?? '';
- }
- //二维码打包start
- /**
- * 将优化后的二维码添加到压缩包
- */
- public function addzip($show_src,$phone)
- {
- $tmpDir = './public/zip/'; //
- if (!file_exists($tmpDir)) {
- //创建文件夹
- mkdir($tmpDir, 0777, true);
- }
- // $phone=Db::name('user_agent')
- // ->where('u_a.user_id',$uid)
- // ->alias('u_a')
- // ->leftJoin('user u','u_a.user_id=u.uid')
- // ->field('u.phone')
- // ->find();
- $zipName = date('YmdHis') . mt_rand(1000, 9999) . '.zip'; // 压缩包文件名
- if($phone > 0){
- $rend=md5(mt_rand(100000000, 999999999));
- $zipName = $phone . '_' . $rend . '.zip'; // 压缩包文件名
- }
- $zipNameUrl = $tmpDir . $zipName; // 文件路径
- //生成文件
- $zip = new \ZipArchive();
- if ($zip->open($zipNameUrl, \ZipArchive::OVERWRITE) !== true) {
- //OVERWRITE 参数会覆写压缩包的文件 文件必须已经存在
- if ($zip->open($zipNameUrl, \ZipArchive::CREATE) !== true) {
- // 文件不存在则生成一个新的文件 用CREATE打开文件会追加内容至zip
- return '下载失败,文件夹不存在';
- }
- }
- foreach ($show_src as $file) {
- //判断图片是否存在
- $isFile = $this->checkFileExists($file);
- if (!$isFile) {
- continue;
- }
- //抓取图片内容
- $fileContent = file_get_contents($file);
- //添加图片
- $zip->addFromString(basename($file), $fileContent);
- }
- // 关闭
- $zip->close();
- $qrcodeData=[
- 'url'=>'http://app.bjtdba.com/zip/'.$zipName,
- 'ctime'=>time()
- ];
- Db::name('qrcode_zip') -> insert($qrcodeData);
- return $qrcodeData['url'];
- }
- /**
- * 判断文件是否存在,支持本地及远程文件
- * @param String $file 文件路径
- * @return Boolean
- */
- private function checkFileExists($file)
- {
- // 远程文件
- if (strtolower(substr($file, 0, 5)) == 'https') {
- // 远程文件
- $header = get_headers($file, true);
- return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
- } elseif (strtolower(substr($file, 0, 4)) == 'http') {
- // 远程文件
- $header = get_headers($file, true);
- return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
- } else {
- // 本地文件
- return file_exists($file);
- }
- }
- //二维码打包 end
- public function notify($type)
- {
- $post=$this->request->param();
- Db::name("log")->insert(array('data'=>'【异步接受到的参数】'.json_encode($post),));//日志记录
- $post_data_str = isset($post['data']) ? $post['data']: '';
- $post_sign_str = isset($post['sign']) ? $post['sign']: '';
- # 先校验签名和返回的数据的签名的数据是否一致
- $adapay_tools=new AdapayTools();
- if ($post['appId'] == 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0'){
- AdapayTools::setRsaPrivateKey('MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKvkKGN19wxH9Uusx8gXnt89oYbgvIRkzO2pD0nzSF/MS65m2j5DgKMG5lryL6bfco2p9syoxKI7IE9pLFtFTyI477cNoUsvWiIYikx5uKz0CDdBcR8AAapfrs5XKgJMcogulqDm4/7QUDuQJoATdvEpA6yfiaW2EqSnMpvZKsdFAgMBAAECgYAgmVOjkUK6HIeDw4/b/cbOlbSljMeT4D4RMIfKwY3PRUJxH+Zx+oFR6cQUKWwqHKRwA3Tf2X35OndlOBAGez2Hc1M08brGSlCB/Ze654mOP5H+bImKfmWQxJiVbbY4ef6msgNAp+FicWLvo6WDuymmP7gvoQbC5E90tRKDCvyawQJBANy/GaYU209Dikbd6E2rWKaS9dgx9f/wZOqmUMUzsDicMO4nK1qojyEm8inkoSRyzv0vLXqD/j/buhE4FjO/YbECQQDHV66K4NKNvuKAbI0NNXothxe2PS6lJrBU5QWgt4Q6CsQ8v+WyFq9AUjEahN11Evm2DCnEBddZKmSctZTgry/VAkAgCEMKjKA+Ykige/cHvkOA+HZgRu+xkgqy2iuCUjvSGygmhtyNrUQHxYUCe0C+70IGD2CEFL9COPpJIWBnZfAhAkATbV0qVbzPaaIDaBDbD7Ini7no3c+U8s9Ohr9kqV3uliwHy5/kGkfcGeaFMhuvFDlX35mWbAdPvkzt5NhsiUY9AkBNdE3yUz+f7A92oZr4bHX7r5gyUTumRiBYyiJ8dgMl6lT8OpQZpBxdswyWg2nkmPoCjoASZx8LoCBhsK4SBcfz');
- }else{
- AdapayTools::setRsaPrivateKey('MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALFOkwRKx2HKMpAL7LUb755cIS7mleort++Rkl25tJMJCf9Ezeyg4xwLBN6RQsLERTAzRKc/EUtxm4/9rzDzvNZ4BegEI8mXWBUrgpn7e1ar8Ek8IRPdXLrozuld9cv56R3yB/Yta0R+kmgCfn2C5V+xtM6njimkOStvdK5cNwqFAgMBAAECgYA5pn+87IeJr1Hjbk0n0g6GYhRUCJuECXUEC0QY/3HMQSsj+f4uy10s2BRcPcUESQbqFjFjY+k+q5DWL7kP5KBoXGnFyflAyRhWGTkSC3VhGixh6ro3EcUJSrFDjGaThGaPrc8Zfcp5JhL5Thi0GaBXSnRH1Cmn4h8gkAEJxIM7PQJBAOq2+oVPtqkj99YRs0eewkZAM7bKRzSwI7OFU6YWsCYVkqNE7Lr3KKGekehuWwkOvrCBR+NEGQfAb557g2CHmzMCQQDBYtgQ5wvl9fD8BWAVKuPoxoleH+9wUQ65Rnt/Ebkx+g8kP37JRun81duLDULTKr/3ak42goE00TfnfeXl0gNnAkA0wuUVypF4/AjeKiRu2RU6zXvSfy36fg3IcRQYpcj7BqZr5TaB4MVVb1vFL+lu482hx63tPIWT5IIy0fj6XgFZAkBinlKLRBgIPISZMPCPuuCg22ZADs8fGucEStI9ub8Uom3IUW0JndVDb5fW8HtMjrd4p8ic+a6ETdFRhx2PNqsvAkAzDvlve56sZnLYx9t/MPkJTK3ZhgVETS0H2FUyJGVOSfjv68bNsUshyPfzJrdbCeLzjMLq8TpyOmiIUAeQ5YCX');
- }
- $sign_flag = $adapay_tools->verifySign($post_data_str, $post_sign_str);
- $post_data_str=json_decode($post_data_str,true);
- if ($sign_flag){
- switch ($type){
- case "pay":
- try {
- Db::name("log")->insert(array('data'=>'【验签通过-支付】:时间:'.date('Y-m-d H:i:s',time()),));//日志记录
- }catch (Exception $exception){
- return app('json')->fail('错误2');
- }
- break;
- case "crate_merber_enterprise":
- Db::name("log")->insert(array('data'=>'【汇付创建企业用户】: 验签通过:时间'.date('Y-m-d H:i:s',time())));//日志记录
- try {
- if($post_data_str['audit_state']=='D'|| $post_data_str['audit_state']=='E'){
- Db::name("log")->insert(array('data'=>'状态判断完了'));//日志记录
- $id=Db::name("hf_user_order")->where('order_no',$post_data_str['order_no'])->value('mer_intention_id');
- $mer_id=Db::name("hf_user_order")->alias('huo')->leftJoin('merchant_intention mi','huo.mer_intention_id=mi.mer_intention_id')->where('order_no',$post_data_str['order_no'])->value('mi.mer_id');
- $checkMerchat=Db::name('merchant')
- ->where('mer_id',$mer_id)
- ->find();
- $insert = [
- [
- 'mer_id' => $checkMerchat['mer_id'],
- 'type' => 1,
- 'member_id' => $checkMerchat['hf_member_id']
- ],
- [
- 'mer_id' => $checkMerchat['mer_id'],
- 'type' => 2,
- 'member_id' => $checkMerchat['hf_member_id_wx']
- ],
- [
- 'mer_id' => $checkMerchat['mer_id'],
- 'type' => 3,
- 'member_id' => $post_data_str['member_id']
- ],
- ];
- Db::name('merchant_member')->where('mer_id', $mer_id)->insertAll($insert);
- }else{
- $id=Db::name("hf_user_order")->where('order_no',$post_data_str['order_no'])->value('mer_intention_id');
- Db::name('merchant_intention')->where('mer_intention_id',$id)->update(['check_result'=>$post_data_str['audit_desc'],'status'=>3,'hf_status'=>3]);
- }
- }catch (Exception $e){
- Db::name("log")->insert(array('data'=>'执行错误————'.$e->getMessage()));
- }
- break;
- case "ruzhu":
- // Db::name('');
- }
- # 业务方自己的逻辑
- }
- }
- /**
- * 商户进件需要的数据
- */
- public function jinjian_data($data)
- {//license_code mer_start_valid_date mer_valid_date
- if($data['identification_valid_date_end']=='forever'){
- $data['identification_valid_date_end']='20991231';
- }
- if($data['acc_type']=='10A'){
- $bank_acct_type=1;
- }else if ($data['acc_type']=='10B'){
- $bank_acct_type=2;
- }
- $license_code='';
- $mer_start_valid_date='';
- $mer_valid_date='';
- if($data['type']==1||$data['type']==2){
- $type='1';
- $license_code=$data['credit_code'];
- $mer_start_valid_date=date('Ymd',strtotime($data['merc_start_time']));
- if($data['merc_end_time']=='forever'){
- $mer_valid_date='20991231';
- }else{
- $mer_valid_date=date('Ymd',strtotime($data['merc_end_time']));
- }
- }else{
- $type=2;
- }
- $bank_code=Db::name('hf_bank_code')->whereLike('name','%'.$data['bank_deposit'].'%')->value('code');
- if(!$bank_code){
- Db::name('merchant_intention')->where('mer_intention_id',$data['mer_intention_id'])->update(['status'=>2,'check_result'=>'银行卡开户行填写不正确']);
- return app('json')->fail('银行卡开户行填写不正确');
- }
- // $data['phone']='17354256998';
- $returndata=[
- 'request_id'=>time().rand(111111,999999),
- 'usr_phone'=>$data['phone'],
- 'cont_name'=>$data['name'],
- 'cont_phone'=>$data['phone'],
- 'customer_email'=>$data['email'],
- 'mer_name'=>$data['mer_name'],
- 'mer_short_name'=>$data['mer_short_name'],
- 'reg_addr'=>$data['addr'],
- 'cust_addr'=>$data['addr'],
- 'cust_tel'=>$data['phone'],
- 'legal_name'=>$data['name'],
- 'legal_type'=>0,
- 'legal_idno'=>$data['idcard_no'],
- 'legal_mp'=>$data['phone'],
- 'legal_start_cert_id_expires'=>date('Ymd',strtotime($data['identification_valid_date_start'])),
- 'legal_id_expires'=>date('Ymd',strtotime($data['identification_valid_date_end'])),
- 'card_id_mask'=>$data['bank_account'],
- 'card_name'=>$data['bank_deposit'],
- 'bank_acct_type'=>$bank_acct_type,
- 'bank_code'=>$bank_code,
- 'prov_code'=>$this->getHfAddress($data['province_id'],'province'),//省份编码 (省市编码),
- 'area_code'=>$this->getHfAddress($data['city_id'],'city'),//地区编码 (省市编码)
- 'license_code'=>$license_code,
- 'mer_valid_date'=>$mer_valid_date,
- 'mer_start_valid_date'=>$mer_start_valid_date,
- 'entry_mer_type'=>$type,
- 'rsa_public_key'=>'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTpMESsdhyjKQC+y1G++eXCEu5pXqK7fvkZJdubSTCQn/RM3soOMcCwTekULCxEUwM0SnPxFLcZuP/a8w87zWeAXoBCPJl1gVK4KZ+3tWq/BJPCET3Vy66M7pXfXL+ekd8gf2LWtEfpJoAn59guVfsbTOp44ppDkrb3SuXDcKhQIDAQAB'
- ];
- return $returndata;
- }
- public function ruzhu_data($data,$mer_data)
- {
- $config=[
- 'wx_lite'=> [
- 'appid'=> 'wx9082e5ac2fdb513f'
- ],
- 'wx_pub'=>[
- // 'appid'=>'wx66f5f8def2b755da',//天地博爱
- 'appid'=>'wx9909df446471d46b',//天地博爱网络
- 'path'=>'https://app.bjtdba.com/'
- ],
- 'wx_scan'=>'',
- 'alipay'=>'',
- 'alipay_wap'=>'',
- 'alipay_lite'=>'',
- 'alipay_qr'=>'',
- 'alipay_pub'=>'',
- 'alipay_scan'=>''
- ];
- if($mer_data['type']==1){
- $mer_type=3;
- }elseif ($mer_data['type']==2){
- $mer_type=5;
- }else{
- $mer_type=8;
- }
- $request_id=time().rand(111111,999999);
- $return_data=[
- 'sub_api_key'=>$data['live_api_key'],
- 'fee_type'=>'02',
- 'app_id'=>$data['app_id_list']['0']['app_id'],
- 'request_id'=>$request_id,
- 'wx_category'=>'756',
- 'alipay_category'=>'2015091000052157',
- 'cls_id'=>'5331',
- 'model_type'=>'1',
- 'mer_type'=>$mer_type,
- 'province_code'=>$this->getHfAddress_ruzhu($mer_data['province_id'],'province'),//省份编码 (省市编码),
- 'city_code'=>$this->getHfAddress_ruzhu($mer_data['city_id'],'city'),//省份编码 (省市编码),
- 'district_code'=>$this->getHfAddress_ruzhu($mer_data['province_id'],'area'),//省份编码 (省市编码),
- // 'add_value_list'=>'{"alipay":"","alipay_wap":"","alipay_lite":"","alipay_qr":"","alipay_scan":""}',
- 'add_value_list'=>json_encode($config),
- 'notify_url'=>env('APP_URL').'/sys/HuiPay/notify_url/'.'ruzhu'
- ];
- return $return_data;
- }
- public function getHfAddress($id,$type){
- if($type == 'province'){
- $res = Db::name("user_province")
- ->where(['province_id' => $id])
- ->field('province_code,short_name')
- ->find();
- $code = $res['province_code'];
- $check = Db::name("hf_business_address") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address") -> where("province like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- if($type == 'city'){
- $res = Db::name("user_city")
- ->where(['city_id' => $id])
- ->field('city_code,short_name')
- ->find();
- $code = $res['city_code'];
- $check = Db::name("hf_business_address") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address") -> where("city like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- if($type == 'area'){
- $res = Db::name("user_area")
- ->where(['area_id' => $id])
- ->field('area_code,short_name')
- ->find();
- $code = $res['area_code'];
- $check = Db::name("hf_business_address") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address") -> where("area like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- return '';
- }
- public function getHfAddress_ruzhu($id,$type){
- if($type == 'province'){
- $res = Db::name("user_province")
- ->where(['province_id' => $id])
- ->field('province_code,short_name')
- ->find();
- $code = $res['province_code'];
- $check = Db::name("hf_business_address_ruzhu") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address_ruzhu") -> where("province like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- if($type == 'city'){
- $res = Db::name("user_city")
- ->where(['city_id' => $id])
- ->field('city_code,short_name')
- ->find();
- $code = $res['city_code'];
- $check = Db::name("hf_business_address_ruzhu") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address_ruzhu") -> where("city like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- if($type == 'area'){
- $res = Db::name("user_area")
- ->where(['area_id' => $id])
- ->field('area_code,short_name')
- ->find();
- $code = $res['area_code'];
- $check = Db::name("hf_business_address_ruzhu") -> where('code',$code) -> find();
- if(!$check){
- $code = Db::name("hf_business_address_ruzhu") -> where("area like '%".$res['short_name']."%'") -> value('code');
- }
- return $code;
- }
- return '';
- }
- //图片类型,01:三证合一码,02:法人/小微负责人身份证正面,03:法人/小微负责人身份证反面,04:门店,05:开户许可证/小微负责人银行卡正面照,06:股东身份证正面,07:股东身份证反面,08:结算账号开户证明,09:网站截图,10:行业资质文件,11:icp备案许可证明或者许可证编码,12:租赁合同,13:交易测试记录,14:业务场景证明材料
- public function shenhe_data($data,$name)
- {
- $return_data=[];
- if($name=='0001'){
- $hf_api_key=$data['hf_api_key_wx'];
- }else{
- $hf_api_key=$data['hf_api_key'];
- }
- if($data['type']==3){
- }else{
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- 'file'=>$this->imgToBaes64($data['business_license']),
- 'fileType'=>'01'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- 'file'=>$this->imgToBaes64($data['card_positive_person']),
- 'fileType'=>'02'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- 'file'=>$this->imgToBaes64($data['card_back_person']),
- 'fileType'=>'03'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- 'file'=>$this->imgToBaes64('https://88yx.xyz/qqh/uploads/20220314142841969.jpg'),
- // 'file'=>$this->($data['business_license']),
- 'fileType'=>'04'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- // 'file'=>$data['business_license'],
- 'file'=>$this->imgToBaes64('http://88yx.xyz/qqh/uploads/20220127154252626.jpg'),
- 'fileType'=>'04'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- $shenhedata=[
- 'subApiKey'=>$hf_api_key,
- 'file'=>$this->imgToBaes64($data['open_account']),
- 'fileType'=>'05'
- ];
- $return_data[]=$this->repository->merProfilePictures($shenhedata,$name);
- }
- return $return_data;
- }
- function imgToBaes64($url)
- {
- $imgInfo = getimagesize($url);
- return 'data:'.$imgInfo['mime'].';base64,'.base64_encode(file_get_contents($url));
- }
- public function shenhe_commit($data,$api_key)
- {
- $return_data=[
- 'socialCreditCodeId'=>$data['0']['pic_id'],
- 'legalCertIdFrontId'=>$data['1']['pic_id'],
- 'legalCertIdBackId'=>$data['2']['pic_id'],
- 'storeId'=>$data['3']['pic_id'].'|'.$data['4']['pic_id'],
- 'accountOpeningPermitId'=>$data['5']['pic_id'],
- 'subApiKey'=>$api_key
- ];
- return $return_data;
- }
- public function huiFuSettleIn()
- {
- $mer_id = $this->request->param('mer_id', 0);
- $merchant=Db::name('merchant_intention')
- ->alias('mi')
- ->Join('merchant m','m.mer_id=mi.mer_id')
- ->where('mi.hf_status',0)
- ->when($mer_id != 0,function ($query) use ($mer_id){
- $query -> where('m.mer_id',$mer_id);
- })
- ->field('mi.mer_intention_id,m.mer_id,mi.hf_status,mi.idcard_no,mi.bank_account')
- // ->limit(5)
- -> select()
- ->toArray();
- foreach ($merchant as $row){
- if($row['idcard_no'] == '') continue;
- if($row['bank_account'] == '') continue;
- $res = $this -> repository -> huifu_create($row['mer_intention_id'],3,'','',$row['mer_id']);// 微信 创建用户
- log::info($res);
- }
- return app('json')->success("运行结束");
- }
- }
|