1、合作商余额查询

2、分油账户司机可用额度
This commit is contained in:
2026-10-20 23:21:10 +08:00
parent 45452c1799
commit fafd3e2c16
134 changed files with 2344 additions and 352 deletions
+70
View File
@@ -16,6 +16,7 @@ use app\common\enum\user\balanceLog\Scene as SceneEnum;
use app\common\library\helper;
use app\store\model\user\BalanceLog as BalanceLogModel;
use think\facade\Cache;
use think\facade\Db;
use app\api\service\User as UserService;
use app\api\model\UserOauth as UserOauthModel;
use app\common\model\User as UserModel;
@@ -112,6 +113,75 @@ class User extends UserModel
return $userInfo->save($data);
}
/**
* 保存实名信息(姓名 / 身份证号 / 车牌号)
*
* 分油是实名制的:上游在分油前会做「姓名 + 身份证号」二要素认证,
* 所以这三项必须在下单前补全。车牌号只在本地留存与后台展示,不上送上游。
*
* @param array $form
* @return bool
* @throws BaseException
*/
public function realname(array $form): bool
{
$realName = trim((string)($form['realName'] ?? ''));
$idCard = strtoupper(trim((string)($form['idCard'] ?? '')));
$plateNo = strtoupper(trim((string)($form['plateNo'] ?? '')));
if ($realName === '') {
$this->error = '请填写真实姓名';
return false;
}
// 中文姓名 2~20 字,允许少数民族姓名里的间隔号
if (!preg_match('/^[\x{4e00}-\x{9fa5}][\x{4e00}-\x{9fa5}·]{1,19}$/u', $realName)) {
$this->error = '姓名格式不正确,请填写身份证上的中文姓名';
return false;
}
if (!preg_match('/^\d{17}[\dX]$/', $idCard)) {
$this->error = '身份证号格式不正确(18位)';
return false;
}
// 省份简称 + 城市字母(不含 I/O,避免与 1/0 混淆) + 5~7 位序号(含新能源 8 位车牌)
if (!preg_match('/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,6}$/u', $plateNo)) {
$this->error = '车牌号格式不正确';
return false;
}
// 当前登录的用户信息
$userInfo = UserService::getCurrentLoginUser(true);
// 身份证号一旦用于分油就不允许再改:上游按身份证号累计司机额度,
// 改了会导致历史订单的额度与司机对不上。姓名/车牌可以改。
if ((string)$userInfo['id_card'] !== '' && (string)$userInfo['id_card'] !== $idCard) {
$used = Db::name('partners_order')
->where('user_id', '=', (int)$userInfo['user_id'])
->where('source', '=', 'mall')
->count();
if ($used > 0) {
$this->error = '身份证号已用于分油,不能修改,请联系客服';
return false;
}
}
return $userInfo->save([
'real_name' => $realName,
'id_card' => $idCard,
'plate_no' => $plateNo,
]) !== false;
}
/**
* 实名信息是否已补全(下单前的必要条件)
* @param array|static $user
* @return bool
*/
public static function isRealnameReady($user): bool
{
return trim((string)($user['real_name'] ?? '')) !== ''
&& trim((string)($user['id_card'] ?? '')) !== ''
&& trim((string)($user['plate_no'] ?? '')) !== '';
}
/**
* 验证绑定的手机号
* @param array $data