|
|
@@ -514,12 +514,12 @@ class Auth extends BaseController
|
|
514
|
514
|
}
|
|
515
|
515
|
}
|
|
516
|
516
|
// Log::info($data);
|
|
517
|
|
- $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,$data['spread']);
|
|
|
517
|
+ $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,0);
|
|
518
|
518
|
// $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
|
|
519
|
519
|
$repository->addagent($user);
|
|
520
|
520
|
$user = $repository->mainUser($user);
|
|
521
|
521
|
|
|
522
|
|
- $repository->bindSpread($user, intval($data['spread']));
|
|
|
522
|
+// $repository->bindSpread($user, intval($data['spread']));
|
|
523
|
523
|
// $repository->spread_log($user, intval($data['spread']));
|
|
524
|
524
|
$tokenInfo = $repository->createToken($user);
|
|
525
|
525
|
$repository->loginAfter($user);
|
|
|
@@ -538,26 +538,66 @@ class Auth extends BaseController
|
|
538
|
538
|
// }
|
|
539
|
539
|
// }
|
|
540
|
540
|
// }
|
|
541
|
|
- if ($type == "marketing"){
|
|
542
|
|
- $spread = Db::name("User") -> alias("u") -> leftjoin("MarketingUser mu","u.uid = mu.uid") -> where("u.uid",$data['spread']) -> field("u.uid,mu.spread_list") -> find();
|
|
543
|
|
- $spread_list = explode(',',$spread['spread_list']);
|
|
544
|
|
- if (!empty($spread_list)){
|
|
545
|
|
- $spread_list[] = "[" . $spread['uid'] . "]";
|
|
546
|
|
- }else{
|
|
547
|
|
- array_push($spread_list,"[".$spread['uid']."]");
|
|
548
|
|
- }
|
|
549
|
|
- $spread_list = array_filter($spread_list);
|
|
550
|
|
- $data = [
|
|
551
|
|
- "uid" => $user->uid,
|
|
552
|
|
- "spread_uid" => $spread['uid'],
|
|
553
|
|
- "spread_list" => implode(",",$spread_list)
|
|
554
|
|
- ];
|
|
555
|
|
- Db::name("MarketingUser") -> insert($data);
|
|
|
541
|
+// if ($type == "marketing"){
|
|
|
542
|
+// $spread = Db::name("User") -> alias("u") -> leftjoin("MarketingUser mu","u.uid = mu.uid") -> where("u.uid",$data['spread']) -> field("u.uid,mu.spread_list") -> find();
|
|
|
543
|
+// $spread_list = explode(',',$spread['spread_list']);
|
|
|
544
|
+// if (!empty($spread_list)){
|
|
|
545
|
+// $spread_list[] = "[" . $spread['uid'] . "]";
|
|
|
546
|
+// }else{
|
|
|
547
|
+// array_push($spread_list,"[".$spread['uid']."]");
|
|
|
548
|
+// }
|
|
|
549
|
+// $spread_list = array_filter($spread_list);
|
|
|
550
|
+// $data = [
|
|
|
551
|
+// "uid" => $user->uid,
|
|
|
552
|
+// "spread_uid" => $spread['uid'],
|
|
|
553
|
+// "spread_list" => implode(",",$spread_list)
|
|
|
554
|
+// ];
|
|
|
555
|
+// Db::name("MarketingUser") -> insert($data);
|
|
|
556
|
+// }
|
|
|
557
|
+
|
|
|
558
|
+ $result = $repository->returnToken($user, $tokenInfo);
|
|
|
559
|
+ $result['uid'] = $user->uid;
|
|
|
560
|
+
|
|
|
561
|
+ return app('json')->success($result);
|
|
|
562
|
+
|
|
|
563
|
+ }
|
|
|
564
|
+
|
|
|
565
|
+ /**
|
|
|
566
|
+ * 用户注册后绑定邀请人
|
|
|
567
|
+ */
|
|
|
568
|
+ public function registerBindSpread(UserRepository $repository)
|
|
|
569
|
+ {
|
|
|
570
|
+ $data = $this->request->params(['uid', 'spread_phone']);
|
|
|
571
|
+ $user = Db::name('user')->where('uid', $data['uid'])->field('uid,spread_uid')->find();
|
|
|
572
|
+ if (!$user) {
|
|
|
573
|
+ return app('json')->fail('注册失败,用户不存在');
|
|
|
574
|
+ }
|
|
|
575
|
+ if (empty($data['spread_phone'])) {
|
|
|
576
|
+ return app('json')->fail('推荐人手机号不能为空');
|
|
|
577
|
+ }
|
|
|
578
|
+ $spread_user = Db::name('user')->where('phone', $data['spread_phone'])->field('uid')->find();
|
|
|
579
|
+ if (!$spread_user) {
|
|
|
580
|
+ return app('json')->fail('推荐人手机号不存在');
|
|
|
581
|
+ }
|
|
|
582
|
+ if(empty($data['uid'])==$user['uid']){
|
|
|
583
|
+ return app('json')->fail('不能绑定自己为推荐人');
|
|
556
|
584
|
}
|
|
557
|
585
|
|
|
558
|
|
- return app('json')->success($repository->returnToken($user, $tokenInfo));
|
|
|
586
|
+ $spreadUid = $spread_user['uid'];//绑定推荐人
|
|
|
587
|
+ Db::name('user')->where('uid', $user['uid'])->update(['spread_uid' => $spreadUid, 'spread_time' => date('Y-m-d H:i:s')]);
|
|
|
588
|
+
|
|
|
589
|
+ //给推荐人下级+1
|
|
|
590
|
+ Db::name('user')->where('uid', $spreadUid)->update(['spread_count' => Db::raw('spread_count + 1')]);
|
|
|
591
|
+ //积分表更新
|
|
|
592
|
+ $this->sign_add($spreadUid, 30,1,'邀请好友注册奖励积分','','', '', 1, '', 2);
|
|
|
593
|
+
|
|
|
594
|
+ Cache::zincrby('s_top_' . date('Y-m'), 1, $spreadUid);
|
|
|
595
|
+ Cache::zincrby('s_top_' . monday(), 1, $spreadUid);
|
|
|
596
|
+ return app('json')->success('绑定成功');
|
|
|
597
|
+
|
|
559
|
598
|
}
|
|
560
|
599
|
|
|
|
600
|
+
|
|
561
|
601
|
/**
|
|
562
|
602
|
* 手机号找回密码
|
|
563
|
603
|
* @param UserRepository $repository
|
|
|
@@ -1364,22 +1404,42 @@ class Auth extends BaseController
|
|
1364
|
1404
|
$data = $this->request->params(['phone', 'code', 'key',"type", 'areaCode']);
|
|
1365
|
1405
|
$validate->sceneVerify()->check($data);
|
|
1366
|
1406
|
log::info("发送短信方法");
|
|
|
1407
|
+ if ($data['type']=="login"){
|
|
|
1408
|
+ $count=Db::name("user")->where("phone", $data["phone"])->count();
|
|
|
1409
|
+ if (!$count){
|
|
|
1410
|
+ return app('json')->make(405, '该手机号未注册,请去注册');
|
|
|
1411
|
+ }
|
|
|
1412
|
+ $sms_num_key = 'api.auth.num.' . $data['phone'];
|
|
|
1413
|
+ $num = Cache::get($sms_num_key) ?: 0;
|
|
|
1414
|
+ log::info("num{$num}");
|
|
|
1415
|
+
|
|
|
1416
|
+ if ($num > 9) {
|
|
|
1417
|
+ if (!$data['code'])
|
|
|
1418
|
+ return app('json')->make(402, '操作过于频繁,请稍后重试~');
|
|
|
1419
|
+ if (!$this->smslogin($data['phone'], $data['code'])) {
|
|
|
1420
|
+ return app('json')->fail('登录验证码输入有误');
|
|
|
1421
|
+ }
|
|
|
1422
|
+ }
|
|
|
1423
|
+ }
|
|
|
1424
|
+
|
|
1367
|
1425
|
if ($data['type']=="register"){
|
|
1368
|
1426
|
$count=Db::name("user")->where("phone", $data["phone"])->count();
|
|
1369
|
1427
|
if ($count){
|
|
1370
|
|
- return app('json')->make(405, '该手机号已注册');
|
|
|
1428
|
+ return app('json')->make(405, '该手机号已注册,请直接登录');
|
|
|
1429
|
+ }
|
|
|
1430
|
+ $sms_num_key = 'api.auth.num.' . $data['phone'];
|
|
|
1431
|
+ $num = Cache::get($sms_num_key) ?: 0;
|
|
|
1432
|
+ log::info("num{$num}");
|
|
|
1433
|
+
|
|
|
1434
|
+ if ($num > 9) {
|
|
|
1435
|
+ if (!$data['code'])
|
|
|
1436
|
+ return app('json')->make(402, '操作过于频繁,请稍后重试~');
|
|
|
1437
|
+ if (!$this->registersmscode($data['phone'], $data['code'])) {
|
|
|
1438
|
+ return app('json')->fail('注册验证码输入有误');
|
|
|
1439
|
+ }
|
|
1371
|
1440
|
}
|
|
1372
|
1441
|
}
|
|
1373
|
|
- $sms_num_key = 'api.auth.num.' . $data['phone'];
|
|
1374
|
1442
|
$sms_key = 'api.auth.sms.' . $data['phone'];
|
|
1375
|
|
- $num = Cache::get($sms_num_key) ? Cache::get($sms_num_key) : 0;
|
|
1376
|
|
- log::info("num{$num}" );
|
|
1377
|
|
- if ($num > 9) {
|
|
1378
|
|
- if (!$data['code'])
|
|
1379
|
|
- return app('json')->make(402, '操作过于频繁,请稍后重试~');
|
|
1380
|
|
- if (!$this->checkCaptcha($data['key'], $data['code']))
|
|
1381
|
|
- return app('json')->fail('验证码输入有误');
|
|
1382
|
|
- }
|
|
1383
|
1443
|
$sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
|
|
1384
|
1444
|
$sms_time = systemConfig('sms_time') ? systemConfig('sms_time') : 30 ;
|
|
1385
|
1445
|
$res = app()->make(AliYunSmsService::class)->send(($data['areaCode'] ?? '') . $data['phone'], $sms_code);
|
|
|
@@ -1533,14 +1593,8 @@ class Auth extends BaseController
|
|
1533
|
1593
|
|
|
1534
|
1594
|
$user = $repository->accountByUser($data['phone']);
|
|
1535
|
1595
|
if (!$user){
|
|
1536
|
|
- $data['spread_uid'] = 0;
|
|
1537
|
|
- if (intval($data['share_id'])) {
|
|
1538
|
|
- $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
|
|
1539
|
|
- $data['spread_uid'] = $spread_uid;
|
|
1540
|
|
- }
|
|
1541
|
|
- $user = $repository->registr($data['phone'], null, 'h5', '','',1, $data['spread_uid']);
|
|
|
1596
|
+ return app('json')->fail('手机号未注册,请先注册');
|
|
1542
|
1597
|
}
|
|
1543
|
|
- $user = $repository->mainUser($user);
|
|
1544
|
1598
|
|
|
1545
|
1599
|
// if($this->source=='yhc' && $this->merId){
|
|
1546
|
1600
|
// $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
|
|
|
@@ -1569,6 +1623,27 @@ class Auth extends BaseController
|
|
1569
|
1623
|
return app('json')->success($repository->returnToken($user, $tokenInfo));
|
|
1570
|
1624
|
}
|
|
1571
|
1625
|
|
|
|
1626
|
+ public function registerSmscode(UserAuthValidate $validate, UserRepository $repository)
|
|
|
1627
|
+ {
|
|
|
1628
|
+ $data = $this->request->params(['phone', 'sms_code', 'spread_uid']);
|
|
|
1629
|
+ $validate->sceneSmslogin()->check($data);
|
|
|
1630
|
+
|
|
|
1631
|
+ $count = Db::name('user')->where('phone', $data['phone'])->count();
|
|
|
1632
|
+ if ($count > 0) {
|
|
|
1633
|
+ return app('json')->fail('手机号已注册,请直接登录');
|
|
|
1634
|
+ }
|
|
|
1635
|
+
|
|
|
1636
|
+ if (!$this->checkSmsCode($data['phone'], $data['sms_code'])) {
|
|
|
1637
|
+ return app('json')->fail('验证码不正确');
|
|
|
1638
|
+ }
|
|
|
1639
|
+ return app('json')->success([
|
|
|
1640
|
+ 'msg' => '验证码验证通过,请填写推荐人手机号完成注册',
|
|
|
1641
|
+ 'phone' => $data['phone']
|
|
|
1642
|
+ ]);
|
|
|
1643
|
+
|
|
|
1644
|
+ }
|
|
|
1645
|
+
|
|
|
1646
|
+
|
|
1572
|
1647
|
public function merJavaRegister(UserRepository $repository){
|
|
1573
|
1648
|
$data = $this->request->params(['phone', 'spread','token','sign']);
|
|
1574
|
1649
|
Log::channel("gong")->info("供应链取消商品数据:" . json_encode($data));
|
|
|
@@ -1902,7 +1977,7 @@ class Auth extends BaseController
|
|
1902
|
1977
|
$ins_data['addtime'] = time();
|
|
1903
|
1978
|
$ins_data['status'] = $status;
|
|
1904
|
1979
|
$ins_data['mark'] = $mark;
|
|
1905
|
|
- $ins_data['type'] = $type;
|
|
|
1980
|
+ $ins_data['source_type'] = $type;
|
|
1906
|
1981
|
$ins_data['settlement_time'] = $settlement_time;// 结算时间 真正到了结算时间会结算
|
|
1907
|
1982
|
$ins_data['order_id'] = $order_id;
|
|
1908
|
1983
|
$ins_data['pm'] = $pm;
|