|
@@ -423,6 +423,18 @@ class UserInfo extends BaseController
|
|
|
if ($user != false) {
|
|
|
$acount = new AccountCompany();
|
|
|
if (!empty($post['companyArr'])) {
|
|
|
+
|
|
|
+
|
|
|
+ //判断关联条件是否都是供应商
|
|
|
+ $all_companyNo = array_column($post['companyArr'], 'companyCode');
|
|
|
+
|
|
|
+ $tmp = Db::name('headquarters')
|
|
|
+ ->where(['is_del' => 0, 'status' => 1])
|
|
|
+ ->whereFindInSet('type', '1')
|
|
|
+ ->column('code');
|
|
|
+ $temp = array_diff($all_companyNo, $tmp);
|
|
|
+ if (!empty($temp)) throw new Exception(implode(',', $temp) . '不是业务公司');
|
|
|
+
|
|
|
$company_insert = [];
|
|
|
foreach ($post['companyArr'] as $company) {
|
|
|
$company_insert[] = [
|
|
@@ -558,6 +570,92 @@ class UserInfo extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //添加供应商账号
|
|
|
+ public function addSupplierAccount()
|
|
|
+ {
|
|
|
+
|
|
|
+ $post = $this->request->filter('trim')->post();
|
|
|
+
|
|
|
+ $tmp = Db::table("sys_account")
|
|
|
+ ->field('id')
|
|
|
+ ->where(["mobile" => $post['mobile'], 'is_del' => 0])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if ($tmp) return json_show(1002, "手机号已注册");
|
|
|
+
|
|
|
+ try {
|
|
|
+ $date = date("Y-m-d H:i:s");
|
|
|
+ $salt = makeSalt();
|
|
|
+ $password = sha1("dingding123" . $salt);
|
|
|
+ $da = [
|
|
|
+ 'username' => $post['mobile'],
|
|
|
+ "password" => $password,
|
|
|
+ "salt" => $salt,
|
|
|
+ "mobile" => $post['mobile'],
|
|
|
+ "source" => "paltadd",
|
|
|
+ "status" => 1,
|
|
|
+ "level" => 3,//供应商端账号
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $reuslt = Db::table('sys_account')->insert($da, true);
|
|
|
+ if ($reuslt) {
|
|
|
+ $data = [
|
|
|
+ "nickname" => $post['nickname'],
|
|
|
+ "mobile" => $post['mobile'],
|
|
|
+ "email" => $post['email'],
|
|
|
+ "portrait" => "",
|
|
|
+ "sex" => 1,
|
|
|
+ "post" => "",
|
|
|
+ "department" => "",
|
|
|
+ "account_id" => $reuslt,
|
|
|
+ "status" => 1,
|
|
|
+ "addtime" => $date,
|
|
|
+ "updatetime" => $date
|
|
|
+ ];
|
|
|
+ $user = Db::table("sys_user")->insert($data);
|
|
|
+ if ($user != false) {
|
|
|
+
|
|
|
+ //判断关联条件是否都是供应商
|
|
|
+ $all_companyNo = array_column($post['companyArr'], 'companyCode');
|
|
|
+
|
|
|
+ $tmp = Db::name('headquarters')
|
|
|
+ ->where(['is_del' => 0, 'status' => 1])
|
|
|
+ ->whereFindInSet('type', '3')
|
|
|
+ ->column('code');
|
|
|
+ $temp = array_diff($all_companyNo, $tmp);
|
|
|
+ if (!empty($temp)) throw new Exception(implode(',', $temp) . '不是供应商');
|
|
|
+
|
|
|
+ $company_insert = [];
|
|
|
+ foreach ($post['companyArr'] as $company) {
|
|
|
+ $company_insert[] = [
|
|
|
+ "account_id" => $reuslt,
|
|
|
+ "companyCode" => $company['companyCode'],
|
|
|
+ "companyName" => $company['companyName'],
|
|
|
+ "company_type" => $company['company_type'],
|
|
|
+ "is_main" => $company['is_main'],
|
|
|
+ "status" => 1,
|
|
|
+ "is_del" => 0,
|
|
|
+ "addtime" => $date,
|
|
|
+ "updatetime" => $date,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($company_insert) Db::name('account_company')->insertAll($company_insert);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ return json_show(0, "注册成功", ["userid" => $reuslt, "nickname" => $post['nickname']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1002, "注册失败");
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1002, "注册失败," . $e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//修改密码通过旧密码
|
|
|
public function passSetByPassword()
|
|
|
{
|