init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Sellapi\Controller;
|
||||
use Think\Controller;
|
||||
|
||||
//[1.5.26]
|
||||
|
||||
/**
|
||||
* 合伙人代理版本设置
|
||||
* Class AgentController
|
||||
* @package Sellapi\Controller
|
||||
*/
|
||||
class AgentController extends Controller
|
||||
{
|
||||
/**
|
||||
* 修改代理级别
|
||||
*/
|
||||
public function editagent()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$juris = I('post.juris');
|
||||
$phone = I('post.phone');
|
||||
$all_data['juris'] = $juris;
|
||||
$art = M('retail_admin')->where(array('phone' => $phone))->save($all_data);
|
||||
if ($art != false) {
|
||||
$re['type'] = 1;
|
||||
$re['msg'] = '成功';
|
||||
} else {
|
||||
$re['type'] = 2;
|
||||
$re['msg'] = '失败';
|
||||
}
|
||||
}
|
||||
$this->ajaxReturn($re);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商家数量
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function checkMerchant()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$phone = I('post.phone');
|
||||
$appid = I('post.appid');
|
||||
$where['status'] = 1;
|
||||
$where['end_time'] = array('gt', time());
|
||||
$art = M('retail_admin')->where(array('phone' => $phone, 'appid' => $appid))->find();
|
||||
if ($art) {
|
||||
$count = M('retail_merchant')->where($where)->count();
|
||||
if ($count) {
|
||||
$re['type'] = 0;
|
||||
$re['msg'] = $count;
|
||||
$re['phone'] = $art['phone'];
|
||||
$re['appid'] = $art['appid'];
|
||||
} else {
|
||||
$re['type'] = 1;
|
||||
$re['msg'] = '数据为空';
|
||||
}
|
||||
} else {
|
||||
$re['type'] = 2;
|
||||
$re['msg'] = '合伙人信息查询为空';
|
||||
}
|
||||
$this->ajaxReturn($re);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Sellapi\Controller;
|
||||
//[1.3.64]
|
||||
use Think\Controller;
|
||||
|
||||
class CallController extends Controller
|
||||
{
|
||||
//获取子级元素
|
||||
public function getChildClass()
|
||||
{
|
||||
$id = I('post.id');
|
||||
$type = I('post.type');
|
||||
if ($type == 2) {
|
||||
$class = M('retail_goods_class as c1')
|
||||
->join('ls_retail_goods_class as c2 on c1.id=c2.pid')
|
||||
->where(array('c1.id' => $id, 'c2.status' => 0))
|
||||
->field('c2.id,c2.class_name')
|
||||
->order('c2.code asc')
|
||||
->select();
|
||||
} else {
|
||||
$class = M('retail_goods_class as c2')
|
||||
->join('ls_retail_goods_class as c3 on c2.id=c3.pid')
|
||||
->where(array('c2.id' => $id, 'c3.status' => 0))
|
||||
->field('c3.id,c3.class_name')
|
||||
->order('c3.code asc')
|
||||
->select();
|
||||
}
|
||||
if (!empty($class)) {
|
||||
$result['status'] = 1;
|
||||
$result['data'] = $class;
|
||||
$result['msg'] = '查询成功';
|
||||
} else {
|
||||
$result['status'] = 0;
|
||||
$result['msg'] = '暂无分类';
|
||||
}
|
||||
$this->ajaxReturn($result);
|
||||
}
|
||||
|
||||
//获取这个门店所有的分类
|
||||
public function getCate()
|
||||
{
|
||||
$merchantid = I("post.merchantid");
|
||||
//array('merchantid' => , 'status' => 0, 'type' => 1);
|
||||
$where["merchantid"] = $merchantid;
|
||||
$where["status"] = 0;
|
||||
$where["type"] = 1;
|
||||
$class_name = M('retail_goods_class')->where($where)->order('code asc')->select();
|
||||
if (!empty($class_name)) {
|
||||
$data["status"] = 1;
|
||||
$data["data"] = $class_name;
|
||||
} else {
|
||||
$data["status"] = 0;
|
||||
$data["data"] = "无分类" . $merchantid;
|
||||
}
|
||||
$this->ajaxReturn($data);
|
||||
}
|
||||
|
||||
//获取所有称重的商品
|
||||
public function getShop()
|
||||
{
|
||||
$storeid = I("post.storeid");
|
||||
if (!$storeid) {
|
||||
$data["status"] = 1;
|
||||
$data["msg"] = "参数错误,请检查";
|
||||
} else {
|
||||
$where['store_id'] = $storeid;
|
||||
$where["pricing_method"] = 2;
|
||||
$where['status'] = array('in', array(0, 1));
|
||||
//根据条件获取商品信息
|
||||
$goods_number = I('post.good_number');
|
||||
if (!empty($goods_number)) {
|
||||
$keyword = trim($goods_number, ' ');
|
||||
if (is_numeric($keyword)) {
|
||||
//纯数字直接走查询货号
|
||||
$where['goods_number|goods_code'] = $keyword;
|
||||
} else {
|
||||
$where['goods_name'] = array('like', '%' . $keyword . '%');
|
||||
}
|
||||
}
|
||||
$person1 = I('post.person1');
|
||||
$person2 = I('post.person2');
|
||||
$person3 = I('post.person3');
|
||||
//查询文件
|
||||
if (!empty($person3)) {
|
||||
$where['goods_class_id'] = $person3;
|
||||
} else if (!empty($person1)) {
|
||||
$class = M('retail_goods_class as c1')
|
||||
->join('ls_retail_goods_class as c2 on c1.id=c2.pid')
|
||||
->join('ls_retail_goods_class as c3 on c2.id=c3.pid AND c3.status=0', 'LEFT')
|
||||
->where(array('c1.id' => $person1, 'c2.status' => 0))
|
||||
->field('c2.id,c3.id as c3_id')->select();
|
||||
$flag = 1;
|
||||
}
|
||||
if (!empty($class)) {
|
||||
$arr = array();
|
||||
foreach ($class as &$val) {
|
||||
if (!in_array($val['id'], $arr)) {
|
||||
$arr[] = $val['id'];
|
||||
}
|
||||
if (!empty($val['c3_id'])) {
|
||||
if (!in_array($val['c3_id'], $arr)) {
|
||||
$arr[] = $val['c3_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$str = implode(',', $arr);
|
||||
$where['goods_class_id'] = array('in', $str . ',' . ($person2 ? $person2 : $person1));
|
||||
} else if ($flag == 1) {
|
||||
$where['goods_class_id'] = $person2 ? $person2 : $person1;
|
||||
}
|
||||
//只获取称重商品
|
||||
$goods = M('retail_goods')
|
||||
->field("plu_code,id,goods_number as good_number,goods_name,goods_code,retail_price,goods_class_id,shelf_life")
|
||||
->where($where)
|
||||
->order('goods_number desc')
|
||||
->select();
|
||||
$number = M('retail_goods')->where($where)->order('plu_code desc')->getField('plu_code');
|
||||
$number = $number ? $number : 1;
|
||||
foreach ($goods as $key => &$value) {
|
||||
$value['cate_name'] = M('retail_goods_class')->where(array('id' => $value['goods_class_id']))->getField('class_name');
|
||||
$value['goods_number'] = $value['good_number'];
|
||||
if ($value["plu_code"]) {
|
||||
$value["good_plu"] = $value["plu_code"];
|
||||
} else {
|
||||
$value["good_plu"] = $number++;
|
||||
}
|
||||
if (empty($value['shelf_life'])) {
|
||||
$value['shelf_life'] = '000';
|
||||
} else {
|
||||
$time = round(($value['shelf_life'] - time()) / 86400);
|
||||
if ($time > 999) {
|
||||
$time = '999';
|
||||
} else if ($time < 1) {
|
||||
$time = '000';
|
||||
} else {
|
||||
$time = str_pad($time, '3', '0', STR_PAD_LEFT);
|
||||
}
|
||||
$value['shelf_life'] = strval($time);
|
||||
}
|
||||
}
|
||||
//获取商品的所有数量
|
||||
$goods_count = M('retail_goods')
|
||||
->where($where)
|
||||
->count();
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '';
|
||||
$data['count'] = $goods_count;
|
||||
$data['data'] = $goods;
|
||||
}
|
||||
$this->ajaxReturn($data);
|
||||
}
|
||||
|
||||
//可以修改价钱和商品名称 或者plu值
|
||||
public function changeData()
|
||||
{
|
||||
$id = I("post.id");
|
||||
$data = I("post.");
|
||||
$map["id"] = $id;
|
||||
$data["plu_code"] = $data["good_plu"];
|
||||
unset($data['shelf_life']);
|
||||
unset($data['good_number']);
|
||||
$cache = M("retail_goods")->where($map)->save($data);
|
||||
if ($cache) {
|
||||
$datas["status"] = 1;
|
||||
$datas["msg"] = "修改成功,后台已同步";
|
||||
} else {
|
||||
$datas["status"] = 0;
|
||||
$datas["msg"] = "修改失败,请检查";
|
||||
}
|
||||
$this->ajaxReturn($datas);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Sellapi\Controller;
|
||||
|
||||
use Think\Controller;
|
||||
|
||||
//[1.4.88]
|
||||
|
||||
/**
|
||||
* Class GetVipInfoController
|
||||
* @package Sellapi\Controller 收银机结算页面获取会员信息
|
||||
*/
|
||||
class GetVipInfoController extends Controller
|
||||
{
|
||||
//+=======================================================================
|
||||
//- 2018-09-03 微信会员卡绑定实体会员卡
|
||||
//+=======================================================================
|
||||
public function bindCard()
|
||||
{
|
||||
if ($_POST) {
|
||||
$vipid = I("post.id");//会员id
|
||||
$guideid = I("post.guideid");//会员id
|
||||
$cardNum = I("post.cardnum");//会员卡号 PS:默认手机号,
|
||||
$cardKey = I("post.card_key");//实体会员卡EXTRA_ID,用来给现有会员绑定实体卡
|
||||
// $primaryid = I("post.primaryid");//会员卡主店id
|
||||
$merchantid = I("post.merchantid");//商户id
|
||||
if ($vipid == '' || $cardKey == '' || $merchantid == '' || $guideid == '') {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '参数错误,请重新登陆';
|
||||
} else {
|
||||
//需要先检查实体会员EXTRA_ID是否已被使用
|
||||
$find = M("retail_vip")->where(array('card_key' => $cardKey))->find();
|
||||
if (!empty($find)) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '抱歉,该会员卡已被绑定,无法再次绑定';
|
||||
} else {
|
||||
//还需要检查会员是否已绑定实体卡
|
||||
$map['id'] = $vipid;
|
||||
//$map['mobile_phone'] = $cardNum;
|
||||
$map['merchantid'] = $merchantid;
|
||||
$vip = M("retail_vip")->where($map)->find();
|
||||
if (empty($vip)) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '未查询到会员信息';
|
||||
} else {
|
||||
if (!empty($vip['card_key'])) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '抱歉,该用户已绑定实体卡';
|
||||
} else {
|
||||
//绑定实体卡
|
||||
$data['guideid'] = $guideid;
|
||||
$data['card_key'] = $cardKey;
|
||||
$bind = M("retail_vip")->where($map)->save($data);
|
||||
if ($bind) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '绑定成功';
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '绑定失败';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
|
||||
//+=======================================================================
|
||||
//- 2018-09-05 解绑会员卡
|
||||
//+=======================================================================
|
||||
public function untieCard()
|
||||
{
|
||||
if ($_POST) {
|
||||
$uid = I("post.id");//用户id
|
||||
$merchantid = I("post.merchantid");//商户id
|
||||
$pwd = I("post.pwd");//会员卡支付密码
|
||||
|
||||
if ($uid == '' || $merchantid == '' || $pwd == '') {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '参数错误,请重新登录';
|
||||
} else {
|
||||
//先查看会员是否绑定会员卡
|
||||
$find = M("retail_vip")->where(array('id' => $uid, 'merchantid' => $merchantid))->find();
|
||||
if ($find['card_key'] == '0') {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '该会员暂未绑定实体会员卡';
|
||||
} else {
|
||||
//解绑操作需验证用户支付密码
|
||||
$CryptrModel = new \Addons\Api\Crypto ();//加解密
|
||||
$orignPwd = $CryptrModel->encrypt($pwd, date('YmdHis', $find['addtime']));
|
||||
if ($orignPwd != $find['password']) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '密码有误,请重新输入';
|
||||
} else {
|
||||
//进行解绑操作 card_key字段为字符串0
|
||||
$data['card_key'] = '0';
|
||||
$untie = M("retail_vip")->where(array('id' => $uid, 'merchantid' => $merchantid))->save($data);
|
||||
if ($untie) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '解绑成功';
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '解绑失败';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户