Commit 3720f440 by 宁成龙

完善客户编码等问题

parent c6e8af7f
...@@ -27,7 +27,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable ...@@ -27,7 +27,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$form->disableCreatingCheck(); $form->disableCreatingCheck();
$form->row(function (Form\Row $form) { $form->row(function (Form\Row $form) {
$form->width(4)->text('company_name')->required(); $form->width(4)->text('company_name')->required();
$form->width(4)->text('user_sn'); $form->width(4)->text('user_sn')->disable();
}); });
$form->row(function (Form\Row $form) { $form->row(function (Form\Row $form) {
$form->width(4)->text('first_name')->required(); $form->width(4)->text('first_name')->required();
......
...@@ -114,6 +114,8 @@ class UserService ...@@ -114,6 +114,8 @@ class UserService
"update_time" => time(), "update_time" => time(),
]; ];
$userId = User::insertData($userData); $userId = User::insertData($userData);
$userSn = self::generateSn($userId);
User::updateById($userId, ["user_sn" => $userSn]);
foreach ($params['user_address_list'] as $address) { foreach ($params['user_address_list'] as $address) {
if ($address['_remove_']) { if ($address['_remove_']) {
...@@ -162,6 +164,12 @@ class UserService ...@@ -162,6 +164,12 @@ class UserService
} }
} }
public static function generateSn($userId)
{
$id = str_pad($userId, 6, 0, STR_PAD_LEFT);
return 'SU' . $id;
}
public static function transferUser($ids, $saleId) public static function transferUser($ids, $saleId)
{ {
try { try {
...@@ -178,6 +186,8 @@ class UserService ...@@ -178,6 +186,8 @@ class UserService
"sale_name" => $saleInfo["name"], "sale_name" => $saleInfo["name"],
]; ];
User::updateByIdArr($userIds, $update); User::updateByIdArr($userIds, $update);
InquiryService::batchUpdateSalesId($saleId, $userIds);
// OrderService::changeOrderSales($userIds,$saleId,$saleInfo["name"]);
DB::commit(); DB::commit();
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
......
<?php
namespace App\Models;
use App\Http\Services\PermService;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{ /*
* 权限
*/
public function scopeRule($query, $viewList,$adminUser="sale_id")
{
if (getAdminUserId() == 1000) {
return $query;
}
//查看所有
if (PermService::hasPerm($viewList[0])) {
return $query;
}
//查看下级
if (PermService::hasPerm($viewList[1])) { //查看下级的权限//获取用户部门下的所有用户
$userIds = PermService::getSubUserId(getAdminUserId());
if (!empty($userIds)) {
return $query->whereIn($adminUser, $userIds);
}
}
$query = $query->where($adminUser, getAdminUserId());
return $query;
}
}
...@@ -26,7 +26,7 @@ use Illuminate\Database\Eloquent\Model; ...@@ -26,7 +26,7 @@ use Illuminate\Database\Eloquent\Model;
* @property $created_time 创建时间 * @property $created_time 创建时间
* @property $update_time 更新时间 * @property $update_time 更新时间
*/ */
class User extends Model class User extends BaseModel
{ {
use HasDateTimeFormatter; use HasDateTimeFormatter;
protected $table = 'users'; protected $table = 'users';
...@@ -39,6 +39,13 @@ class User extends Model ...@@ -39,6 +39,13 @@ class User extends Model
const ACCOUNT_PROPERTIES_PERSONAL = 1; const ACCOUNT_PROPERTIES_PERSONAL = 1;
const ACCOUNT_PROPERTIES_ENTERPRISE = 2; const ACCOUNT_PROPERTIES_ENTERPRISE = 2;
//查看权限
public static $ruleViewList = [
self::SEM_USER_VIEW_ALL, //查看所有
self::SEM_USER_VIEW_SUB,//查看下级
];
const SEM_USER_VIEW_ALL = "sem_user_viewAllList";//查看所有
const SEM_USER_VIEW_SUB = "sem_user_viewSubList";//查看下级
public static function insertData($data) public static function insertData($data)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment