文件
mashangyoujiu/Application/Sellapi/Controller/LoginController.class.php

110 行
5.2 KiB
PHP
可执行文件

<?php
namespace Sellapi\Controller;
use Think\Controller;
//[1.2.0]
class LoginController extends Controller
{
public function logindo()
{
if ($_POST) {
$userName = $_POST ['username'];
$pwd = $_POST ['password'];
$User = M("retail_cashier")->where(array("mobile" => $userName, "status" => 1))->find();
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$ret = 0;
if ($User == null) {
$data ['msg'] = '账号不存在';
} else {
$store = M("retail_store")->where(array("id" => $User['storeid']))->find();
//如果门店已被删除则不给予登录
if ($store['state'] == 1) {
//被删除
$data['status'] = 0;
$data['msg'] = '门店已被删除,无法登录';
} elseif ($store['state'] == 0) {
$CryptrModel = new \Addons\Api\Crypto ();
$orignPwd = $CryptrModel->encrypt($pwd, date('YmdHis', $User['addtime']));
if ($orignPwd == $User['password']) {
$partner = M("retail_merchant")->where(array("id" => $User['merchantid']))->getField("partnerid");
$find = M("retail_cashier_logo")->where("admin_id =" . $partner)->getField("pc_icon");
$find = $http_type . $_SERVER['HTTP_HOST'] . $find;
/* 添加商品权限 1. 开启 2. 关闭 */
/* 添加商品权限 1.开启 2.关闭 查看进价权限 1.开启 2.关闭 */
$jurisdiction = M('retail_store_jurisdiction')->field('showpurch_price,addgoods')->where(array('storeid' => $store['id']))->find();
if (!$jurisdiction['showpurch_price'] || $jurisdiction['showpurch_price'] == 2 || !$jurisdiction['addgoods'] || $jurisdiction['addgoods'] == 2 || !$User['cashier_add_goods'] || $User['cashier_add_goods'] == 2) {
$data['add_goods_jurisdiction'] = 2;
} else {
$data['add_goods_jurisdiction'] = 1;
}
/*************/
//获取门店名称
$ret = 1;
$data ['msg'] = '登陆成功';
$Users['uid'] = $User['id'];
$Users['name'] = $User['name'];
$Users['storeid'] = $User['storeid'];
$Users['merchantid'] = $User['merchantid'];
$Users['storename'] = $store['storetag'];
$Users['cash_model'] = $User['cash_model'];
$Users['print_time'] = $User['print_time'];
$Users['store_preferential'] = $store['preferential'];
$Users['preferential'] = $User['preferential'];
$Users['salesdiction'] = $User['salesdiction'];
$Users['pc_icon'] = $find ? $find : '';
$data ['data'] = $Users;
$w['storeid'] = $User['storeid'];
$w['cashierid'] = $User['id'];
$one = M('retail_record')->where($w)->order('start_time desc')->find();
if ($one) {
// 有记录
if (!$one['end_time']) {
// 未交班
$build = false;
} else {
// 已交班
$build = true;
}
} else {
// 无记录
$build = true;
}
if ($build) {
// 新生成上班jilu
$Ad['storeid'] = $User['storeid'];
$Ad['jobnum'] = $User['jobnum'];
$Ad['cashierid'] = $User['id'];
$Ad['start_time'] = time();
$ret2 = M('retail_record')->add($Ad);
if ($ret2) {
} else {
$ret = 0;
$data['msg'] = '系统错误,请重新登录';
}
} else {
$ret = 1;
$data['msg'] = '登录成功,上次未交班,请勿忘记交班';
}
} else {
$data ['msg'] = '密码错误';
}
}
}
$data ['status'] = $ret;
$this->ajaxReturn($data);
}
}
public function getSign()
{
$key = I('post.akey');
$post = I('post.');
unset($post['akey']);
$sign = createSign($post, $key);
echo $sign;
}
}