| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models\common;
- use app\models\User;
- use app\modules\client\models\v1\BindForm;
- use yii\base\Model;
- class CommonOrder
- {
- /**
- * 持续更新...
- * 下单前的检测
- */
- public static function checkOrder($other = [])
- {
- $user = get_user();
- if ($user->blacklist) {
- return [
- 'code' => 1,
- 'msg' => '无法下单'
- ];
- }
- if (isset($other['mobile']) && $other['mobile']) {
- if (!preg_match("/^1\d{10}$/", $other['mobile'])) {
- return [
- 'code' => 1,
- 'msg' => '请输入正确的手机号111'
- ];
- }
- }
- }
- /**
- * 分销 保存上级的ID(用于先成为上下级,再成为分销商)
- * @param $parentId
- * @return static
- */
- public static function saveParentId($parentId)
- {
- if (!$parentId) {
- return;
- }
- // 父级用户不存在
- $parentUser = User::findOne($parentId);
- if (!$parentUser) {
- return;
- }
- $user = get_user();
- if ($user) {
- $form = new BindForm();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->parent_id = $parentId;
- $form->condition = 1;
- $form->save();
- // $user->parent_user_id = $parentId;
- // $user->save();
- }
- return $user;
- }
- }
|