添加网站文件
This commit is contained in:
558
application/api/controller/Account.php
Normal file
558
application/api/controller/Account.php
Normal file
@@ -0,0 +1,558 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\LoginLogic;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\api\server\UserServer;
|
||||
use app\api\cache\TokenCache;
|
||||
use think\facade\Config;
|
||||
use think\Db;
|
||||
|
||||
class Account extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['register','applogin', 'login', 'mnplogin', 'codeurl', 'oalogin', 'oplogin','logout','smslogin', 'uinAppLogin', 'silentLogin', 'authLogin','stafflogin'];
|
||||
|
||||
|
||||
/**
|
||||
* note 注册接口
|
||||
* create_time 2020/10/23 18:42
|
||||
*/
|
||||
public function register(){
|
||||
$post = $this->request->post();
|
||||
$post['check_code'] = ConfigServer::get('register_setting', 'open', 0);
|
||||
$result = $this->validate($post,'app\api\validate\Register');
|
||||
if($result ===true){
|
||||
$data = LoginLogic::register($post);
|
||||
if($data){
|
||||
$this->_success('注册成功',$data);
|
||||
}
|
||||
$this->_error('获取失败',$result,0);
|
||||
}$this->_error($result,'',0);
|
||||
}
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/账号
|
||||
* @title 手机号账号登录
|
||||
* @description 手机号账号登录
|
||||
* @method post
|
||||
* @url /account/login
|
||||
* @return {"code":1,"msg":"登录成功","data":["token":"3237676fa733d73333341",//登录令牌"nickname":"好象cms-小林",//昵称"avatar":"http://b2c.yixiangonline.com/uploads/user/avatar/3f102df244d5b40f21c4b25dc321c5ab.jpeg",//头像url"level":0,//等级],"show":0,"time":"0.775400"}
|
||||
* @param account 必填 string 账号或手机号
|
||||
* @param id 必填 int 1-密码登录-2-验证码登录
|
||||
* @param password 必填 string 密码
|
||||
* @param client 必填 int 客户端类型:2-h5,3-ios,4-android
|
||||
* @return_param token string 登录令牌
|
||||
* @return_param nickname string 昵称
|
||||
* @return_param avatar string 头像
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\Login.password');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$data = LoginLogic::login($post);
|
||||
$this->_success('登录成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function smsLogin(){
|
||||
$post = $this->request->post();
|
||||
$post['message_key'] = 'YZMDL';
|
||||
$check = $this->validate($post, 'app\api\validate\Login.code');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$data = LoginLogic::login($post);
|
||||
$this->_success('登录成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/账号
|
||||
* @title 小程序登录
|
||||
* @description 小程序登录
|
||||
* @method post
|
||||
* @url /account/mnpLogin
|
||||
* @return {"code":1,"msg":"登录成功","data":["token":"3237676fa733d73333341",//登录令牌"nickname":"好象cms-小林",//昵称"avatar":"http://b2c.yixiangonline.com/uploads/user/avatar/3f102df244d5b40f21c4b25dc321c5ab.jpeg",//头像url"level":0,//等级],"show":0,"time":"0.775400"}
|
||||
* @param code 必填 string code
|
||||
* @param iv 必填 string iv
|
||||
* @param encrypted_data 必填 string encrypted_data
|
||||
* @return_param token string 登录令牌
|
||||
* @return_param nickname string 昵称
|
||||
* @return_param avatar string 头像
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function mnpLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\MnpLogin');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$data = LoginLogic::mnpLogin($post);
|
||||
$this->_success($data['msg'], $data['data'], $data['code'], $data['show']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/账号
|
||||
* @title 获取获取向微信请求code的链接
|
||||
* @description
|
||||
* @method get
|
||||
* @url /account/codeurl
|
||||
* @param url 必填 varchar 前端当前url
|
||||
* @return_param url string codeurl
|
||||
* @remark 这里是备注信息
|
||||
* @number 0
|
||||
* @return {"code":1,"msg":"获取成功","data":{"url":'http://mp.weixin……'}}
|
||||
*/
|
||||
public function codeUrl()
|
||||
{
|
||||
$url = $this->request->get('url');
|
||||
$this->_success('获取成功', ['url' => LoginLogic::codeUrl($url)], 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/账号
|
||||
* @title 微信H5登录
|
||||
* @description 微信H5登录
|
||||
* @method post
|
||||
* @url /account/oalogin
|
||||
* @return {"code":1,"msg":"登录成功","data":["token":"3237676fa733d73333341",//登录令牌"nickname":"好象cms-小林",//昵称"avatar":"http://b2c.yixiangonline.com/uploads/user/avatar/3f102df244d5b40f21c4b25dc321c5ab.jpeg",//头像url"level":0,//等级],"show":0,"time":"0.775400"}
|
||||
* @param code 必填 string code
|
||||
* @return_param token string 登录令牌
|
||||
* @return_param nickname string 昵称
|
||||
* @return_param avatar string 头像
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function oaLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\OaLogin');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$data = LoginLogic::oaLogin($post);
|
||||
$this->_success($data['msg'], $data['data'], $data['code']);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/账号
|
||||
* @title 微信第三方app登录
|
||||
* @description 微信第三方app登录
|
||||
* @method post
|
||||
* @url /account/oplogin
|
||||
* @return {"code":1,"msg":"登录成功","data":["token":"3237676fa733d73333341",//登录令牌"nickname":"好象cms-小林",//昵称"avatar":"http://b2c.yixiangonline.com/uploads/user/avatar/3f102df244d5b40f21c4b25dc321c5ab.jpeg",//头像url"level":0,//等级],"show":0,"time":"0.775400"}
|
||||
* @param code 必填 string code
|
||||
* @param client 必填 int 客户端类型:3-ios,4-android
|
||||
* @return_param token string 登录令牌
|
||||
* @return_param nickname string 昵称
|
||||
* @return_param avatar string 头像
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function opLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\OpLogin');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$data = LoginLogic::opLogin($post);
|
||||
$this->_success($data['msg'], $data['data'], $data['code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
LoginLogic::logout($this->user_id, $this->client);
|
||||
//退出登录只有成功
|
||||
$this->_success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: uniapp微信登录
|
||||
* @author 段誉(2021/3/16 16:00)
|
||||
*/
|
||||
public function uinAppLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$data = LoginLogic::uinAppLogin($post);
|
||||
$this->_success($data['msg'], $data['data'], $data['code']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getrandstr($length = 10){
|
||||
$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$len = strlen($str)-1;
|
||||
$randstr = '';
|
||||
for ($i=0;$i<$length;$i++) {
|
||||
$num=mt_rand(0,$len);
|
||||
$randstr .= $str[$num];
|
||||
}
|
||||
return $randstr;
|
||||
}
|
||||
//2021-0419 小程序新版登录调整
|
||||
|
||||
/**
|
||||
* Notes: 小程序登录(旧系统用户,返回用户信息,否则返回空)
|
||||
* @author 段誉(2021/4/19 16:50)
|
||||
*/
|
||||
public function silentLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
|
||||
if(!empty($post['login_type']) && $post['login_type'] == 'toutiao'){
|
||||
|
||||
return $this->silentLogin_toutiao($post);
|
||||
}
|
||||
|
||||
if (empty($post['code'])) {
|
||||
$this->_error('参数缺失');
|
||||
}
|
||||
$data = LoginLogic::silentLogin($post);
|
||||
$this->_success($data['msg'], $data['data'], $data['code'], $data['show']);
|
||||
}
|
||||
public function silentLogin_toutiao($data){
|
||||
$url='https://developer.toutiao.com/api/apps/v2/jscode2session';
|
||||
$data=[
|
||||
'appid'=>'tt0523739e9a12236501',
|
||||
'secret'=>'58280e4f36d88e93d7a4be9f0e590b2302a462c5',
|
||||
'code'=>$data['code'],
|
||||
//'anonymous_code'=>$anonymousCode,
|
||||
];
|
||||
$res=$this->json_post($url,$data);
|
||||
// array(3) {
|
||||
// ["err_no"]=>
|
||||
// int(0)
|
||||
// ["err_tips"]=>
|
||||
// string(7) "success"
|
||||
// ["data"]=>
|
||||
// array(5) {
|
||||
// ["session_key"]=>
|
||||
// string(24) "xDIPf7whhzHFz+5ppTanFA=="
|
||||
// ["openid"]=>
|
||||
// string(36) "_000dypj-umBDuy6oz-nKqesccbK29flyIws"
|
||||
// ["anonymous_openid"]=>
|
||||
// string(0) ""
|
||||
// ["unionid"]=>
|
||||
// string(36) "eb8fbd8b-4124-595d-abf4-9fbca7ef3611"
|
||||
// ["dopenid"]=>
|
||||
// string(0) ""
|
||||
// }
|
||||
// }
|
||||
$res=json_decode($res,true);
|
||||
if(empty($res['data']['openid'])){
|
||||
$this->_error('登录失败:'.json_encode($res));
|
||||
}
|
||||
$openid = $res['data']['openid'];
|
||||
$unionid = $res['data']['unionid'];
|
||||
|
||||
$user_id =Db::name('user_auth')->where('openid',$openid)->find();
|
||||
|
||||
$response['headimgurl'] = $this->getrandstr();
|
||||
$response['headimgurl'] = 'https://web.dulmao.com/uploads/images/202404240124289ecef8304.png';
|
||||
$response['openid'] = $openid;
|
||||
$response['unionid'] = $unionid;
|
||||
|
||||
if (empty($user_id)) {
|
||||
$user_info = UserServer::createUser($response,8);
|
||||
} else {
|
||||
$user_info = UserServer::updateUser($response,8, $user_id);
|
||||
}
|
||||
|
||||
//验证用户信息
|
||||
$check_res = self::checkUserInfo($user_info);
|
||||
if (true !== $check_res) {
|
||||
return $this->_error($check_res);
|
||||
}
|
||||
|
||||
//创建会话
|
||||
$user_info['token'] = self::createSession($user_info['id'], 8);
|
||||
|
||||
unset($user_info['id'], $user_info['disable']);
|
||||
return $this->_success('登录成功', $user_info);
|
||||
}
|
||||
public static function createSession($user_id, $client)
|
||||
{
|
||||
|
||||
//清除之前缓存
|
||||
$token = Db::name('session')
|
||||
->where(['user_id' => $user_id, 'client' => $client])
|
||||
->value('token');
|
||||
if($token) {
|
||||
$token_cache = new TokenCache($token);
|
||||
$token_cache->del();
|
||||
}
|
||||
|
||||
$result = Db::name('session')
|
||||
->where(['user_id' => $user_id, 'client' => $client])
|
||||
->find();
|
||||
|
||||
$time = time();
|
||||
$expire_time = $time + Config::get('project.token_expire_time');
|
||||
$token = md5($user_id . $client . $time);
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'token' => $token,
|
||||
'client' => $client,
|
||||
'update_time' => $time,
|
||||
'expire_time' => $expire_time,
|
||||
];
|
||||
|
||||
if (empty($result)) {
|
||||
Db::name('session')->insert($data);
|
||||
} else {
|
||||
Db::name('session')
|
||||
->where(['user_id' => $user_id, 'client' => $client])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
//更新登录信息
|
||||
$login_ip = $ip = request()->ip();
|
||||
Db::name('user')
|
||||
->where(['id' => $user_id])
|
||||
->update(['login_time' => $time, 'login_ip' => $login_ip]);
|
||||
|
||||
//创建新的缓存
|
||||
(new TokenCache($token, ['token' => $token]))->set(300);
|
||||
return $token;
|
||||
}
|
||||
public static function checkUserInfo($user_info)
|
||||
{
|
||||
if (empty($user_info)) {
|
||||
return '登录失败:user';
|
||||
}
|
||||
|
||||
if ($user_info['disable']) {
|
||||
return '该用户被禁用';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public function json_post($url, $data = [])
|
||||
{
|
||||
//$data=http_build_query($data);
|
||||
//$data=json_encode($data);
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if(!$data){
|
||||
return 'data is null';
|
||||
}
|
||||
if(is_array($data))
|
||||
{
|
||||
$data = json_encode($data);
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER,array(
|
||||
'Content-Type: application/json; charset=utf-8',
|
||||
'Content-Length:' . strlen($data),
|
||||
'Cache-Control: no-cache',
|
||||
'Pragma: no-cache'
|
||||
));
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$res = curl_exec($curl);
|
||||
$errorno = curl_errno($curl);
|
||||
if ($errorno) {
|
||||
return $errorno;
|
||||
}
|
||||
curl_close($curl);
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 小程序登录(新用户登录->需要提交昵称和头像参数)
|
||||
* @author 段誉(2021/4/19 16:49)
|
||||
*/
|
||||
public function authLogin()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['nickname'] = $this->getrandstr();
|
||||
$post['headimgurl'] = 'https://web.dulmao.com/uploads/images/202404240124289ecef8304.png';
|
||||
|
||||
//|
|
||||
if (empty($post['code']) || empty($post['nickname']) || empty($post['phone_code'])) {
|
||||
$this->_error('参数缺失');
|
||||
}
|
||||
|
||||
$phone = $this->code_phone($post['phone_code']);
|
||||
|
||||
|
||||
$data = LoginLogic::authLogin($post,$phone);
|
||||
$this->_success($data['msg'], $data['data'], $data['code'], $data['show']);
|
||||
}
|
||||
|
||||
//获取手机号
|
||||
public function code_phone($code){
|
||||
$data['code'] = $code;
|
||||
$config = WeChatServer::getMnpConfig();
|
||||
$accessToken = '';
|
||||
|
||||
$cache = cache('wx_mini_token');
|
||||
if(!empty($cache) && !empty($cache['token']) && $cache['exp'] > time()){
|
||||
$accessToken = $cache['token'];
|
||||
}else{
|
||||
$token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$config['app_id']."&secret=".$config['secret']."";
|
||||
$_accessToken = file_get_contents($token_url);
|
||||
$_accessToken = json_decode($_accessToken);
|
||||
if(!empty($_accessToken)){
|
||||
$accessToken = $_accessToken->access_token;
|
||||
cache('wx_mini_token',['token'=>$accessToken,'exp'=>time()+6000]);
|
||||
}else{
|
||||
$this->_error('获取token失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=$accessToken";
|
||||
|
||||
$info = $this->http_request($url,json_encode($data),'json');
|
||||
// 一定要注意转json,否则汇报47001错误
|
||||
$tmpinfo = json_decode($info,true);
|
||||
if(empty($tmpinfo)){
|
||||
$this->_error('获取手机号失败');
|
||||
}
|
||||
|
||||
if(!empty($tmpinfo['errcode'])){
|
||||
$this->_error($tmpinfo['errmsg']);
|
||||
}
|
||||
|
||||
return $tmpinfo['phone_info']['phoneNumber'];
|
||||
}
|
||||
public function getAccessToken()
|
||||
{
|
||||
$appid = '填写自己的appID';
|
||||
$secret = '填写自己的秘钥';
|
||||
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret."";
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch,CURLOPT_URL,$url);
|
||||
curl_setopt($ch,CURLOPT_HEADER,0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $res;
|
||||
exit();
|
||||
}
|
||||
//图片合法性验证
|
||||
public function http_request($url, $data = null)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
|
||||
if (!empty($data)) {
|
||||
curl_setopt($curl, CURLOPT_POST, TRUE);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json'
|
||||
));
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
$output = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return $output;
|
||||
}
|
||||
// 获取手机号
|
||||
public function getPhoneNumber(){
|
||||
$tmp = $this->getAccessToken();
|
||||
$tmptoken = json_decode($tmp);
|
||||
$token = $tmptoken->access_token;
|
||||
$data['code'] = $_GET['code'];//前端获取code
|
||||
|
||||
$url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=$token";
|
||||
$info = $this->http_request($url,json_encode($data),'json');
|
||||
// 一定要注意转json,否则汇报47001错误
|
||||
$tmpinfo = json_decode($info);
|
||||
|
||||
$code = $tmpinfo->errcode;
|
||||
$phone_info = $tmpinfo->phone_info;
|
||||
//手机号
|
||||
$phoneNumber = $phone_info->phoneNumber;
|
||||
if($code == '0'){
|
||||
echo json_encode(['code'=>1,'msg'=>'请求成功','phoneNumber'=>$phoneNumber]);
|
||||
die();
|
||||
}else{
|
||||
echo json_encode(['code'=>2,'msg'=>'请求失败']);
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//员工端登入接口
|
||||
public function stafflogin(){
|
||||
$get = $this->request->get();
|
||||
//判断是不是员工
|
||||
$pass=md5(md5($get['password']));
|
||||
$phone=Db::name('staff')->where('mobile',$get['phone'])->where('password','like',$pass)->find();
|
||||
|
||||
|
||||
|
||||
if($phone){
|
||||
$this->_success('登入成功',$phone);
|
||||
}else{
|
||||
$this->_error('登入失败,请检查账号和密码');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
application/api/controller/ActivityArea.php
Normal file
33
application/api/controller/ActivityArea.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\ActivityAreaLogic;
|
||||
|
||||
class ActivityArea extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['activityGoodsList'];
|
||||
|
||||
public function activityGoodsList()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$list = ActivityAreaLogic::activityGoodsList($id, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $list);
|
||||
}
|
||||
}
|
||||
239
application/api/controller/Ad.php
Normal file
239
application/api/controller/Ad.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\AdLogic;
|
||||
|
||||
use think\Db;
|
||||
class Ad extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists','channel','label','add_comost','add_comost','list_comost','follow_comost','comost_add','label_edit','comost_info','notice','position','position_list','vode_type','video_list','video_info','user_wages','user_wages_add','user_leave','fine','recruit','last_leave','last_fine','notice_list','leave','auth'];
|
||||
public function lists()
|
||||
{
|
||||
$pid = $this->request->get('pid');
|
||||
$client = $this->request->get('client', 1);
|
||||
if ($pid) {
|
||||
$list = AdLogic::lists($pid, $client);
|
||||
} else {
|
||||
$list = [];
|
||||
}
|
||||
$this->_success('获取成功', $list);
|
||||
}
|
||||
|
||||
//获取客户的渠道
|
||||
public function channel(){
|
||||
$list=Db::name('staffchannel')->field('id,name')->select();
|
||||
$this->_success('获取成功', $list);
|
||||
|
||||
}
|
||||
|
||||
//获取客户的标签
|
||||
public function label(){
|
||||
$list=Db::name('user_label')->field('id,name')->select();
|
||||
$this->_success('获取成功', $list);
|
||||
}
|
||||
|
||||
//增加客户的档案
|
||||
public function add_comost(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$phone=Db::name('user_address')->where('telephone',$get['mobile'])->find();
|
||||
if($phone){
|
||||
$this->_error('电话号码已存在');
|
||||
}
|
||||
$staff=Db::name('staff')->where('id',$get['staff_id'])->field('mobile')->find();
|
||||
$admin=Db::name('admin')->where('phone',$staff['mobile'])->find();
|
||||
if($admin){
|
||||
$data=[
|
||||
'contact' => $get['consignee'],
|
||||
'telephone' => $get['mobile'],
|
||||
'sex' => $get['sex'],
|
||||
'address' => $get['adder'],
|
||||
'pet' => $get['pet'],
|
||||
'hbl' => $get['clas'],
|
||||
'wx' => $get['wx'],
|
||||
'brand_id' => $get['channels'],
|
||||
'label_id' => $get['labels'],
|
||||
'admin_id' => $admin['id'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
];
|
||||
$inser=Db::name('user_address')->data($data)->insert();
|
||||
$this->_success('增加客户数据成功');
|
||||
}else{
|
||||
$this->_error('增加数据失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//根据ID获取客户的归属
|
||||
public function list_comost(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::list_comost($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//根据订单id获取的跟进信息
|
||||
public function follow_comost(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::follow_comost($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//创建跟进的内容
|
||||
public function comost_add(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::comost_add($get);
|
||||
$this->_success('增加跟进内容成功');
|
||||
}
|
||||
|
||||
//修改客户的标签
|
||||
public function label_edit(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$update=Db::name('user_address')->where('id',$get['uid'])->update(['label_id'=>$get['value']]);
|
||||
$this->_success('修改渠道成功');
|
||||
}
|
||||
|
||||
public function comost_info(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$list=Db::name('user_address')->where('id',$get['id'])->find();
|
||||
if($list['sex']==0){
|
||||
$list['sex']="男";
|
||||
}else{ $list['sex']="女";}
|
||||
if($list['pet']=0){
|
||||
$list['pet']="无";
|
||||
}else{$list['pet']="有";}
|
||||
if($list['hbl']==0){
|
||||
$list['hbl']="无";
|
||||
}else{ $list['hbl']="有";}
|
||||
if($list['wx']==0){
|
||||
$list['wx']="无";
|
||||
}else{ $list['wx']="有";}
|
||||
$label=Db::name('user_label')->where('id',$list['label_id'])->field('name')->find();
|
||||
if($label){
|
||||
$list['label_name']= $label['name'];
|
||||
}else{
|
||||
$list['label_name']= '-';
|
||||
}
|
||||
$brand=Db::name('staffchannel')->where('id',$list['brand_id'])->field('name')->find();
|
||||
if($brand){
|
||||
$list['brand_name']= $brand['name'];
|
||||
}else{
|
||||
$list['brand_name']= '-';
|
||||
}
|
||||
$this->_success('获取数据成功',$list);
|
||||
}
|
||||
|
||||
//获取首页最新公告俩条
|
||||
public function notice(){
|
||||
$lists = AdLogic::notice();
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//获取招聘类型列表
|
||||
public function position(){
|
||||
$lists = AdLogic::position();
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
public function position_list(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::position_list($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//获取视频的类型
|
||||
public function vode_type(){
|
||||
$lists = AdLogic::vode_type();
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
public function video_list(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::video_list($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//根据id获取视频培训
|
||||
public function video_info(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::video_info($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//员工工资获取获取
|
||||
public function user_wages(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::user_wages($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
//员工增加员工的工资
|
||||
public function user_wages_add(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::user_wages_add($get);
|
||||
if($lists==-1){
|
||||
$this->_error('工资已经提交请勿重复提交');
|
||||
}
|
||||
$this->_success('提交成功');
|
||||
}
|
||||
//获取请假的列表
|
||||
public function user_leave(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::user_leave($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//删除上一个月请假列表
|
||||
public function last_leave(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::last_leave($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
//获取到员工的罚款记录
|
||||
public function fine(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::fine($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
//获取员工上一个月罚款记录
|
||||
public function last_fine(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::last_fine($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
//提交招聘的信息
|
||||
public function recruit(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::addrecruit($get);
|
||||
$this->_success('提交成功等待人事回电');
|
||||
}
|
||||
//获取公告的内容
|
||||
public function notice_list(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$lists = AdLogic::notice_list($get);
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
//员工提交请假申请
|
||||
public function leave(){
|
||||
$get = $this->request->get();//获取的到传递过来的参数
|
||||
$data=Db::name('leavesd')
|
||||
->where('staff_id',$get['staff_id'])
|
||||
->where('time',strtotime($get['time']))
|
||||
->where('addtime',$get['after'])
|
||||
->find();
|
||||
if($data){
|
||||
$this->_error('日期已经请假');
|
||||
}
|
||||
$lists = AdLogic::addleave($get);
|
||||
$this->_success('提交成功');
|
||||
}
|
||||
//获取员工权限
|
||||
public function auth(){
|
||||
$get = $this->request->get();
|
||||
|
||||
$lists = AdLogic::auth($get);
|
||||
|
||||
$this->_success('获取权限成功',$lists);
|
||||
}
|
||||
|
||||
}
|
||||
307
application/api/controller/Administration.php
Normal file
307
application/api/controller/Administration.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\StaffOrderLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
class Administration extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['Nuorder','uNuorder','order_sn','countOrder','allcustom','orderdeail','infoOrder','typePay','conle','edit_order','edit_order','overtime'];
|
||||
/**
|
||||
* note 获取全部总订单数据
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function Nuorder(){
|
||||
|
||||
$param = $this->request->get(); //接受传递过来的参数
|
||||
$where=[];
|
||||
|
||||
|
||||
if (!empty($param['search'])) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $param['search'])) {
|
||||
$where[] = ['mobile', '=', $param['search']];
|
||||
} else {
|
||||
$where[] = ['consignee', 'LIKE', '%' . $param['search'] . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
|
||||
$data=Db::name('order')
|
||||
->order('id', 'desc')
|
||||
->where($where)
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
|
||||
$filteredData = [];
|
||||
foreach ($data as &$item){
|
||||
$item['create_time'] = date('Y-m-d', $item['create_time']);
|
||||
$goods=StaffOrderLogic::goods($item['goods_id']); //订单的商品
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['image']=$goods['image'];
|
||||
$item['code']=$goods['code'];
|
||||
}
|
||||
$admin=StaffOrderLogic::admin($item['admin_id']);
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}
|
||||
$count=StaffOrderLogic::order_sn($item['order_sn']); //统计总的条数
|
||||
$item['order_wc']=$count; //统计完成次数
|
||||
$item['order_dsy']=$item['code']-$count;
|
||||
if (isset($param['currentTab'])) {
|
||||
if ($param['currentTab'] === '0' && $item['order_dsy']>0) {
|
||||
$filteredData[] = $item;
|
||||
} elseif ($param['currentTab'] === '1' && $item['order_dsy']<=0) {
|
||||
$filteredData[] = $item;
|
||||
} elseif ($param['currentTab'] === '2') {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
elseif (!isset($param['currentTab'])) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
} else {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->_success('获取数据成功',$filteredData);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取的我的订单
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function uNuorder(){
|
||||
$param = $this->request->get(); //接受传递过来的参数
|
||||
$where=[];
|
||||
if (!empty($param['search'])) {
|
||||
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $param['search'])) {
|
||||
$where[] = ['mobile', '=', $param['search']];
|
||||
} else {
|
||||
$where[] = ['consignee', 'LIKE', '%' . $param['search'] . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$admin_id=Db::name('admin')
|
||||
->alias('a')
|
||||
->join('staff s','s.mobile=a.phone')
|
||||
->where('s.id',$param['id'])
|
||||
->field('a.id')
|
||||
->find();
|
||||
if($admin_id){
|
||||
$data=Db::name('order')
|
||||
->order('id', 'desc')
|
||||
->where($where)
|
||||
->where('admin_id', $admin_id['id'])
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
|
||||
$filteredData = [];
|
||||
foreach ($data as &$item){
|
||||
$item['create_time'] = date('Y-m-d', $item['create_time']);
|
||||
$goods=StaffOrderLogic::goods($item['goods_id']); //订单的商品
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['image']=$goods['image'];
|
||||
$item['code']=$goods['code'];
|
||||
}
|
||||
$admin=StaffOrderLogic::admin($item['admin_id']);
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}
|
||||
$count=StaffOrderLogic::order_sn($item['order_sn']); //统计总的条数
|
||||
$item['order_wc']=$count; //统计完成次数
|
||||
$item['order_dsy']=$item['code']-$count;
|
||||
if (isset($param['currentTab'])) {
|
||||
if ($param['currentTab'] === '0' && $item['order_dsy']>0) {
|
||||
$filteredData[] = $item;
|
||||
} elseif ($param['currentTab'] === '1' && $item['order_dsy']<=0) {
|
||||
$filteredData[] = $item;
|
||||
} elseif ($param['currentTab'] === '2') {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
elseif (!isset($param['currentTab'])) {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
} else {
|
||||
$filteredData[] = $item;
|
||||
}
|
||||
}
|
||||
$this->_success('获取成功',$data);
|
||||
|
||||
}else{
|
||||
$this->_error("人员不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* note 根据订单编号查询订单
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function order_sn(){
|
||||
$param = $this->request->get(); //接受传递过来的参数
|
||||
$where=[];
|
||||
if (isset($param['staff_status']) && $param['staff_status'] !== '') {
|
||||
switch ($param['staff_status']) {
|
||||
case '4':
|
||||
$where[] = ['abnormal', '=', 1];
|
||||
break;
|
||||
default:
|
||||
$where[] = ['staff_status', '=', $param['staff_status']];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$data=Db::name('order_exe')->alias('o')
|
||||
->join('order s','s.order_sn=o.order_sn')
|
||||
->where('o.order_sn',$param['order_sn'])
|
||||
->where($where)
|
||||
->field('o.*, s.goods_id, s.order_sn as s_order_sn,s.admin_id,s.address,o.staff_id,o.remark')
|
||||
->order('o.id', 'desc')
|
||||
->select();
|
||||
foreach ($data as &$item){
|
||||
$item['autotime']=date('Y-m-d',$item['autotime']);
|
||||
$goods=StaffOrderLogic::goods($item['goods_id']); //订单的商品
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
}
|
||||
$staff=StaffOrderLogic::staff($item['staff_id']);
|
||||
if($staff){
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_phone']=$staff['mobile'];
|
||||
}
|
||||
}
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note 根据订单编号统计数据
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function countOrder(){
|
||||
$param = $this->request->get(); //接受传递过来的参数
|
||||
$data['toder']=Db::name('order_exe')->where('order_sn',$param['order_sn'])->where('staff_status',0)->count();
|
||||
$data['ardfs']=Db::name('order_exe')->where('order_sn',$param['order_sn'])->where('staff_status',1)->count();
|
||||
$data['fwz']=Db::name('order_exe')->where('order_sn',$param['order_sn'])->where('staff_status',2)->count();
|
||||
$data['fwywc']=Db::name('order_exe')->where('order_sn',$param['order_sn'])->where('staff_status',3)->count();
|
||||
$data['ycorder']=Db::name('order_exe')->where('order_sn',$param['order_sn'])->where('abnormal',1)->count();
|
||||
|
||||
$this->_success('获取成功',$data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取到全部客户
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function allcustom(){
|
||||
$param = $this->request->get();
|
||||
if (!empty($param['search'])) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $param['search'])) {
|
||||
$where[] = ['telephone', '=', $param['search']];
|
||||
} else {
|
||||
$where[] = ['contact', 'LIKE', '%' . $param['search'] . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$data=Db::name('user_address')
|
||||
->where($where)
|
||||
->page($param['page'], $param['limt'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($data as &$item){
|
||||
$admin=StaffOrderLogic::admin($item['admin_id']); //获取到绑定管理员信息
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}else{
|
||||
$item['admin_name']='-';
|
||||
}
|
||||
$conne=StaffOrderLogic::addqudao($item['brand_id']);
|
||||
if($conne){
|
||||
$item['channel_name']=$conne['name'];
|
||||
}else{
|
||||
$item['channel_name']='-';
|
||||
}
|
||||
$user=StaffOrderLogic::user($item['user_id']);
|
||||
if($user){
|
||||
$item['user_image']=UrlServer::getFileUrl($user['avatar']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 根据订单编号获取到订单信息
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function orderdeail(){
|
||||
$param = $this->request->get();
|
||||
$data=Db::name('order')->alias('o')
|
||||
->join('goods g','o.goods_id=g.id')
|
||||
->join('admin a','a.id=admin_id')
|
||||
->join('orderchannel c','o.channel_id=c.id')
|
||||
->where('o.id',$param['id'])
|
||||
->field(['o.id','o.goods_id','g.id','g.name as goods_name','o.order_sn','o.create_time','o.consignee','o.mobile','o.address','a.name as admin_name','c.name as clan_name','o.pay_zd','o.pay_way','o.order_amount','o.gord_id','o.order_remarks'])
|
||||
->find();
|
||||
$data['create_time']=date('Y-m-d H:i:s');
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 编辑订单功能
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function infoOrder(){
|
||||
$param = $this->request->get();
|
||||
$data=Db::name('order')
|
||||
->where('id',$param['id'])
|
||||
->find();
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note 获取所有的支付渠道
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function typePay(){
|
||||
$data=Db::name('collection')->select();
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note 获取是有的订单渠道
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function conle(){
|
||||
$data=Db::name('orderchannel')->select();
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note 编辑订单的数据
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function edit_order(){
|
||||
$param = $this->request->get();
|
||||
$data=StaffOrderLogic::edit_order($param); //统计总的条数
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note订单加时间的审批
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function overtime(){
|
||||
$param = $this->request->get();
|
||||
$admin_id=Db::name('admin')
|
||||
->alias('a')
|
||||
->join('staff s','s.mobile=a.phone')
|
||||
->where('s.id',$param['id'])
|
||||
->field('a.id')
|
||||
->find();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
113
application/api/controller/AfterSale.php
Normal file
113
application/api/controller/AfterSale.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
use think\Db;
|
||||
use app\api\logic\AfterSaleLogic;
|
||||
|
||||
/**
|
||||
* 售后
|
||||
* Class Order
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class AfterSale extends ApiBase
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
$type = $this->request->get('type', 'normal');
|
||||
$lists = AfterSaleLogic::lists($this->user_id, $type, $this->page_no, $this->page_size);
|
||||
$this->_success('',$lists);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$check = $this->validate($post, 'app\api\validate\AfterSale.add');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
return AfterSaleLogic::add($post, $this->user_id);
|
||||
}
|
||||
|
||||
|
||||
//售后商品信息
|
||||
public function goodsInfo()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$check = $this->validate($get, 'app\api\validate\AfterSale.info');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$this->_success('', AfterSaleLogic::info($get['item_id'], $get['order_id']));
|
||||
}
|
||||
|
||||
|
||||
public function express()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\AfterSale.express');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
return AfterSaleLogic::express($this->user_id, $post);
|
||||
}
|
||||
|
||||
|
||||
public function cancel()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\AfterSale.cancel');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
AfterSaleLogic::cancel($this->user_id, $post);
|
||||
$this->_success('撤销成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$this->_success('', AfterSaleLogic::detail($get));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function again()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$order=Db::name('order')->where('id',$post['id'])->find();
|
||||
if($order['refund_status']==2){
|
||||
$this->_error('退款申请之中');
|
||||
}
|
||||
if($order['pay_status']!=1){
|
||||
$this->_error('订单未支付,无法申请退款');
|
||||
}
|
||||
|
||||
if($order['code']==0){
|
||||
$this->_error('订单已完成,无法申请退款');
|
||||
}
|
||||
$ref=Db::name('order')->where('id',$post['id'])->update(['refund_status'=>2]);
|
||||
|
||||
$this->_success('申请成功');
|
||||
}
|
||||
}
|
||||
153
application/api/controller/ApiBase.php
Normal file
153
application/api/controller/ApiBase.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\App;
|
||||
use think\Controller;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\facade\Config;
|
||||
use think\facade\Debug;
|
||||
use think\Response;
|
||||
|
||||
class ApiBase extends Controller
|
||||
{
|
||||
public $user_info = [];
|
||||
public $user_id = null;
|
||||
public $client = null;
|
||||
|
||||
public $page_no = 1;
|
||||
public $page_size = 15;
|
||||
|
||||
public $like_not_need_login = [];
|
||||
|
||||
/**
|
||||
* 底层控制器初始化
|
||||
* ApiBase constructor.
|
||||
* @param App|null $app
|
||||
*/
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
parent::__construct($app);
|
||||
self::setValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc: 设置基础控制器属性值
|
||||
*/
|
||||
private function setValue()
|
||||
{
|
||||
|
||||
//用户信息
|
||||
$this->user_info = $this->request->user_info ?? [];
|
||||
$this->user_id = $this->request->user_info['id'] ?? null;
|
||||
$this->client = $this->request->user_info['client'] ?? null;
|
||||
|
||||
//分页参数
|
||||
$page_no = (int)$this->request->get('page_no');
|
||||
$this->page_no = $page_no && is_numeric($page_no) ? $page_no : $this->page_no;
|
||||
$page_size = (int)$this->request->get('page_size');
|
||||
$this->page_size = $page_size && is_numeric($page_size) ? $page_size : $this->page_size;
|
||||
$this->page_size = min($this->page_size, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc: 请求成功
|
||||
* @param string $msg
|
||||
* @param array $data
|
||||
* @param int $code
|
||||
* @param int $show
|
||||
* @param array $header
|
||||
*/
|
||||
protected function _success($msg = '', $data = [], $code = 1, $show = 0, array $header = [])
|
||||
{
|
||||
$type = $this->getResponseType();
|
||||
$time = Debug::getUseTime();
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
'show' => $show,
|
||||
'time' => $time,
|
||||
];
|
||||
|
||||
if (Config::get('app_trace')) {
|
||||
$result['debug'] = [
|
||||
'request' => [
|
||||
'get' => $this->request->get(),
|
||||
'post' => $this->request->post(),
|
||||
'header' => $this->request->header(),
|
||||
]
|
||||
];
|
||||
}
|
||||
$type = $this->getResponseType();
|
||||
// 把跳转模板的渲染下沉,这样在 response_send 行为里通过getData()获得的数据是一致性的格式
|
||||
if ('html' == strtolower($type)) {
|
||||
$type = 'jump';
|
||||
}
|
||||
|
||||
$response = Response::create($result, $type)->header($header)->options(['jump_template' => $this->app['config']->get('dispatch_success_tmpl')]);
|
||||
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 lr
|
||||
* Desc: 请求失败
|
||||
* @param string $msg
|
||||
* @param array $data
|
||||
* @param int $code
|
||||
* @param int $show
|
||||
* @param array $header
|
||||
*/
|
||||
protected function _error($msg = '', $data = [], $code = 0, $show = 1, array $header = [])
|
||||
{
|
||||
$type = $this->getResponseType();
|
||||
$time = Debug::getUseTime();
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
'show' => $show,
|
||||
'time' => $time,
|
||||
];
|
||||
|
||||
if (Config::get('app_trace')) {
|
||||
$result['debug'] = [
|
||||
'request' => [
|
||||
'get' => $this->request->get(),
|
||||
'post' => $this->request->post(),
|
||||
'header' => $this->request->header(),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if ('html' == strtolower($type)) {
|
||||
$type = 'jump';
|
||||
}
|
||||
|
||||
$response = Response::create($result, $type)->header($header)->options(['jump_template' => $this->app['config']->get('dispatch_error_tmpl')]);
|
||||
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
application/api/controller/Article.php
Normal file
56
application/api/controller/Article.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\ArticleLogic;
|
||||
|
||||
|
||||
class Article extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['lists', 'category', 'detail'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$article = ArticleLogic::lists($id, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $article);
|
||||
}
|
||||
|
||||
|
||||
public function category()
|
||||
{
|
||||
$article = ArticleLogic::CategoryLists();
|
||||
$this->_success('获取成功', $article);
|
||||
}
|
||||
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$client = $this->request->get('client',1);
|
||||
if (!$id) {
|
||||
$this->_error('参数缺失');
|
||||
}
|
||||
$article_detail = ArticleLogic::getArticleDetail($id,$client);
|
||||
$this->_success('获取成功', $article_detail);
|
||||
}
|
||||
}
|
||||
133
application/api/controller/Bargain.php
Normal file
133
application/api/controller/Bargain.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\BargainLogic;
|
||||
|
||||
class Bargain extends ApiBase{
|
||||
|
||||
public $like_not_need_login = ['barginNumber', 'lists','detail','closeBargain'];
|
||||
|
||||
/**
|
||||
* Notes:获取砍价成功人数
|
||||
* @author: 2021/2/23 16:11
|
||||
*/
|
||||
public function barginNumber(){
|
||||
$number = BargainLogic::barginNumber();
|
||||
$this->_success('获取成功',$number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 砍价列表
|
||||
* @author: 2021/2/23 15:54
|
||||
*/
|
||||
public function lists(){
|
||||
|
||||
$list = BargainLogic::lists($this->page_no, $this->page_size);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:砍价活动详情
|
||||
* @author: 2021/2/23 17:44
|
||||
*/
|
||||
public function detail(){
|
||||
$bargain_id = $this->request->get('bargain_id');
|
||||
$result = $this->validate(['bargain_id'=>$bargain_id],'app\api\validate\Bargain.detail');
|
||||
if(true === $result){
|
||||
$detail = BargainLogic::detail($bargain_id);
|
||||
$this->_success('获取成功',$detail);
|
||||
}
|
||||
$this->_error($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:发起砍价
|
||||
* @author: 2021/2/23 18:43
|
||||
*/
|
||||
public function sponsor(){
|
||||
$post_data = $this->request->post();
|
||||
$result = $this->validate($post_data,'app\api\validate\Bargain.sponsor');
|
||||
if(true === $result){
|
||||
$data = BargainLogic::sponsor($post_data,$this->user_id);
|
||||
$this->_success($data['msg'],$data['data'],$data['code'],$data['show']);
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:砍价助力
|
||||
* @author: 2021/2/25 18:21
|
||||
*/
|
||||
public function knife(){
|
||||
$id = $this->request->post('id');
|
||||
$result = $this->validate(['id'=>$id,'user_id'=>$this->user_id],'app\api\validate\Bargain.knife');
|
||||
if(true === $result){
|
||||
$data = BargainLogic::knife($id,$this->user_id);
|
||||
$this->_success($data['msg'],$data['data'],$data['code'],$data['show']);
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:砍价订单列表
|
||||
* @author: 2021/2/24 17:15
|
||||
*/
|
||||
public function orderList(){
|
||||
$type = $this->request->get('type','-1');
|
||||
$list = BargainLogic::orderList($type,$this->user_id,$this->page_no,$this->page_size);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:砍价详情
|
||||
* @author: 2021/2/24 15:36
|
||||
*/
|
||||
public function bargainDetail(){
|
||||
$id = $this->request->get('id');
|
||||
$result = $this->validate(['id'=>$id,'user_id'=>$this->user_id],'app\api\validate\Bargain.bargainDetail');
|
||||
if(true === $result){
|
||||
$detail = BargainLogic::bargainDetail($id,$this->user_id);
|
||||
$this->_success('获取成功',$detail);
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes:关闭砍价订单
|
||||
* @author: 2021/2/26 16:36
|
||||
*/
|
||||
public function closeBargain(){
|
||||
$id = $this->request->post('id');
|
||||
if($id){
|
||||
BargainLogic::closeBargain($id);
|
||||
}
|
||||
$this->_success('');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
98
application/api/controller/Cart.php
Normal file
98
application/api/controller/Cart.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\CartLogic;
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
* Class Cart
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Cart extends ApiBase
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$this->_success('', CartLogic::lists($this->user_id));
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\Cart.add');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$res = CartLogic::add($post['item_id'], $post['goods_num'], $this->user_id);
|
||||
if ($res === true) {
|
||||
$this->_success('加入成功');
|
||||
}
|
||||
$this->_error($res);
|
||||
}
|
||||
|
||||
|
||||
public function change()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\Cart.change');
|
||||
if ($check !== true) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$res = CartLogic::change($post['cart_id'], $post['goods_num']);
|
||||
if ($res === true) {
|
||||
$this->_success();
|
||||
}
|
||||
$this->_error($res);
|
||||
}
|
||||
|
||||
|
||||
public function del()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\Cart.del');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
if (CartLogic::del($post['cart_id'], $this->user_id)) {
|
||||
$this->_success('删除成功');
|
||||
}
|
||||
$this->_error('删除失败');
|
||||
}
|
||||
|
||||
|
||||
public function selected()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\Cart.selected');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
CartLogic::selected($post, $this->user_id);
|
||||
$this->_success();
|
||||
}
|
||||
|
||||
|
||||
public function num()
|
||||
{
|
||||
$this->_success('',CartLogic::cartNum($this->user_id));
|
||||
}
|
||||
}
|
||||
23
application/api/controller/Collect.php
Normal file
23
application/api/controller/Collect.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\CollectLogic;
|
||||
|
||||
class Collect extends ApiBase{
|
||||
/**
|
||||
* note 商品收藏列表
|
||||
* create_time 2020/10/29 10:17
|
||||
*/
|
||||
public function getCollectGoods(){
|
||||
$collect = CollectLogic::getCollectGoods($this->user_id,$this->page_no,$this->page_size);
|
||||
$this->_success('获取成功',$collect);
|
||||
}
|
||||
/**
|
||||
* note 商品收藏操作
|
||||
* create_time 2020/10/29 10:17
|
||||
*/
|
||||
public function handleCollectGoods(){
|
||||
$post = $this->request->post();
|
||||
$collect = CollectLogic::handleCollectGoods($post,$this->user_id);
|
||||
$this->_success('获取成功',$collect);
|
||||
}
|
||||
}
|
||||
89
application/api/controller/Coupon.php
Normal file
89
application/api/controller/Coupon.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\CouponLogic;
|
||||
|
||||
class Coupon extends ApiBase{
|
||||
public $like_not_need_login = ['couponlist','getgoodscoupon'];
|
||||
/**
|
||||
* note 领券中心
|
||||
* create_time 2020/10/22 12:06
|
||||
*/
|
||||
public function couponList(){
|
||||
$coupon_list = CouponLogic::getCouponList($this->user_id);
|
||||
$this->_success('获取成功',$coupon_list);
|
||||
}
|
||||
/**
|
||||
* note 商品详情获取优惠券
|
||||
* create_time 2020/10/22 18:14
|
||||
*/
|
||||
public function getGoodsCoupon(){
|
||||
$id = $this->request->get('id');
|
||||
$coupon_list = [];
|
||||
if($id){
|
||||
$coupon_list = CouponLogic::getGoodsCoupon($this->user_id,$id);
|
||||
}
|
||||
$this->_success('',$coupon_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 领取优惠券
|
||||
* create_time 2020/10/22 12:06
|
||||
*/
|
||||
public function getCoupon(){
|
||||
$coupon_id = $this->request->post('id');
|
||||
$result = $this->validate(['id'=>$coupon_id,'user_id'=>$this->user_id],'app\api\validate\GetCoupon');
|
||||
if($result === true){
|
||||
$result = CouponLogic::userGetCoupon($coupon_id,$this->user_id);
|
||||
if($result == true){
|
||||
$this->_success('领取成功','');
|
||||
}
|
||||
$result = '领取失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
/**
|
||||
* note 我的优惠券
|
||||
* create_time 2020/10/26 9:37
|
||||
*/
|
||||
public function myCoupon(){
|
||||
$type = $this->request->get('type',1);
|
||||
$coupon_list = CouponLogic::getMyCouponList($this->user_id,$type);
|
||||
$this->_success('获取成功',$coupon_list);
|
||||
|
||||
}
|
||||
/**
|
||||
* note 下单获取优惠券
|
||||
* create_time 2020/10/28 11:06
|
||||
*/
|
||||
public function orderCoupon(){
|
||||
$goods = $this->request->post('goods');
|
||||
$data = CouponLogic::orderCoupon($goods,$this->user_id);
|
||||
$this->_success('获取成功',$data);
|
||||
}
|
||||
/**
|
||||
* note 注册赠送优惠券
|
||||
* create_time 2020/12/4 10:29
|
||||
*/
|
||||
public function registerSendCoupon(){
|
||||
$list = CouponLogic::registerSendCoupon($this->user_id);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
}
|
||||
33
application/api/controller/Dispatch.php
Normal file
33
application/api/controller/Dispatch.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
class Dispatch extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['_error'];
|
||||
|
||||
public function dispatch_error($msg = '', $code = 0)
|
||||
{
|
||||
return $this->_error($msg, [], $code);
|
||||
}
|
||||
|
||||
}
|
||||
161
application/api/controller/Distribution.php
Normal file
161
application/api/controller/Distribution.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\DistributionLogic;
|
||||
use app\common\model\User;
|
||||
|
||||
class Distribution extends ApiBase
|
||||
{
|
||||
|
||||
/**
|
||||
* 填写邀请码
|
||||
*/
|
||||
public function code()
|
||||
{
|
||||
$code = $this->request->post('code');
|
||||
$data = [
|
||||
'user_id' => $this->user_id,
|
||||
'code' => $code,
|
||||
];
|
||||
$result = $this->validate($data, 'app\api\validate\DistributionCode');
|
||||
if ($result !== true) {
|
||||
$this->_error($result, [], 0, 0);
|
||||
}
|
||||
$result = DistributionLogic::code($code, $this->user_id);
|
||||
if ($result !== true) {
|
||||
$this->_error($result, [], 0, 0);
|
||||
}
|
||||
$this->_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销会员申请
|
||||
*/
|
||||
public function apple()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$result = $this->validate($post, 'app\api\validate\DistributionApply');
|
||||
if ($result !== true) {
|
||||
$this->_error($result);
|
||||
}
|
||||
$result = DistributionLogic::apple($post,$this->user_id);
|
||||
if ($result !== true) {
|
||||
$this->_error($result);
|
||||
}
|
||||
$this->_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 最新的分销会员申请详情
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function appleDetail()
|
||||
{
|
||||
$this->_success('',DistributionLogic::appleDetail($this->user_id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User: 意象信息科技 mjf
|
||||
* Desc: 我的分销上级
|
||||
*/
|
||||
public function myLeader()
|
||||
{
|
||||
$this->_success('', DistributionLogic::myLeader($this->user_id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销推广主页信息
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->_success('', DistributionLogic::index($this->user_id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 分销订单
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$this->_success('', DistributionLogic::order($this->user_id, $get, $page, $size));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 月度账单
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function monthBill()
|
||||
{
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$this->_success('', DistributionLogic::getMonthBill($this->user_id, $page, $size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 月度账单明细
|
||||
*/
|
||||
public function monthDetail()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$this->_success('', DistributionLogic::getMonth($get, $this->user_id, $page, $size));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 分销会员页面判断
|
||||
* @author 段誉(2021/2/1 18:45)
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$user = User::get($this->user_id);
|
||||
if ($user['freeze_distribution'] == 1) {
|
||||
$this->_error('您已被冻结');
|
||||
}
|
||||
|
||||
if ($user['is_distribution'] == 1) {
|
||||
$this->_success('', '', 10001);//已是分销会员
|
||||
} else {
|
||||
$this->_success('', '',20001);//未是分销会员
|
||||
}
|
||||
}
|
||||
}
|
||||
47
application/api/controller/File.php
Normal file
47
application/api/controller/File.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\common\server\FileServer;
|
||||
|
||||
class File extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['formImage','test'];
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/上传文件
|
||||
* @title form表单方式上传图片
|
||||
* @description 图片上传
|
||||
* @method post
|
||||
* @url /file/formimage
|
||||
* @return param name string 图片名称
|
||||
* @return param url string 文件地址
|
||||
* @remark
|
||||
* @number 1
|
||||
* @return {"code":1,"msg":"上传文件成功","data":{"url":"http:\/\/likeb2b2c.yixiangonline.com\/uploads\/images\/user\/20200810\/3cb866f6bb30b7239d91582f7d9822d6.png","name":"2.png"},"show":0,"time":"0.283254","debug":{"request":{"get":[],"post":[],"header":{"content-length":"103132","content-type":"multipart\/form-data; boundary=--------------------------206668736604428806173438","connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"1f8aa4dd-f53c-4d12-98b4-8d901ac847db","cache-control":"no-cache","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2"}}}}
|
||||
*/
|
||||
public function formImage()
|
||||
{
|
||||
$data = FileServer::userFormImage($this->user_id);
|
||||
$this->_success($data['msg'], $data['data'], $data['code']);
|
||||
}
|
||||
}
|
||||
18
application/api/controller/Footprint.php
Normal file
18
application/api/controller/Footprint.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\FootPrintLogic;
|
||||
|
||||
class Footprint extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$lists = FootPrintLogic::lists();
|
||||
$this->_success('获取成功', $lists);
|
||||
}
|
||||
}
|
||||
73
application/api/controller/Goods.php
Normal file
73
application/api/controller/Goods.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\GoodsLogic;
|
||||
class Goods extends ApiBase{
|
||||
|
||||
public $like_not_need_login = ['getgoodsdetail', 'getgoodslist','getbestlist','gethostlist','getsearchpage'];
|
||||
|
||||
/**
|
||||
* note 商品列表
|
||||
* create_time 2020/10/20 11:12
|
||||
*/
|
||||
public function getGoodsList(){
|
||||
$get = $this->request->get();
|
||||
$goods_list = GoodsLogic::getGoodsList($this->user_id, $get, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功',$goods_list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* note 商品详情
|
||||
* create_time 2020/10/20 11:12
|
||||
*/
|
||||
public function getGoodsDetail(){
|
||||
$id = $this->request->get('id');
|
||||
$goods = GoodsLogic::getGoodsDetail($this->user_id,$id);
|
||||
if($goods){
|
||||
$this->_success('获取成功',$goods);
|
||||
}
|
||||
$this->_error('商品不存在',[],0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 首页好物优选
|
||||
* create_time 2020/10/21 19:04
|
||||
*/
|
||||
public function getBestList() {
|
||||
$goods_list = GoodsLogic::getBestList($this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $goods_list);
|
||||
|
||||
}
|
||||
/**
|
||||
* note 热销商品
|
||||
* create_time 2020/11/17 9:52
|
||||
*/
|
||||
public function getHostList(){
|
||||
$goods_list = GoodsLogic::getHostList($this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $goods_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* note 获取搜索页数据
|
||||
* create_time 2020/10/22 16:01
|
||||
*/
|
||||
public function getSearchPage(){
|
||||
$limit = $this->request->get('limit ',10);
|
||||
$list = GoodsLogic::getSearchPage($this->user_id,$limit);
|
||||
$this->_success('',$list);
|
||||
}
|
||||
/**
|
||||
* note 清空搜索记录
|
||||
* create_time 2020/12/18 10:26
|
||||
*/
|
||||
public function clearSearch(){
|
||||
$result = GoodsLogic::clearSearch($this->user_id);
|
||||
if($result){
|
||||
$this->_success('清理成功','');
|
||||
}
|
||||
$this->_error('清理失败','');
|
||||
|
||||
}
|
||||
}
|
||||
21
application/api/controller/GoodsCategory.php
Normal file
21
application/api/controller/GoodsCategory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\GoodsCategoryLogic;
|
||||
class GoodsCategory extends ApiBase{
|
||||
public $like_not_need_login = ['lists'];
|
||||
|
||||
/**
|
||||
* Notes:获取商品分类
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @author: 2021/3/6 18:49
|
||||
*/
|
||||
public function lists(){
|
||||
$client = $this->request->get('client',1);
|
||||
$cateogry = GoodsCategoryLogic::categoryThirdTree($client);
|
||||
|
||||
$this->_success('获取成功',$cateogry);
|
||||
}
|
||||
}
|
||||
118
application/api/controller/GoodsComment.php
Normal file
118
application/api/controller/GoodsComment.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\GoodsCommentLogic;
|
||||
|
||||
class GoodsComment extends ApiBase{
|
||||
public $like_not_need_login = ['lists','category'];
|
||||
|
||||
/**
|
||||
* note 商品评论分类
|
||||
* create_time 2020/11/11 16:33
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$collect = GoodsCommentLogic::category($get);
|
||||
$this->_success('获取成功', $collect);
|
||||
}
|
||||
/**
|
||||
* note 商品评论列表
|
||||
* create_time 2020/11/11 16:34
|
||||
*/
|
||||
public function lists(){
|
||||
$get = $this->request->get();
|
||||
$collect = GoodsCommentLogic::lists($get, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $collect);
|
||||
|
||||
}
|
||||
/**
|
||||
* note 添加商品评论
|
||||
* create_time 2020/11/11 15:14
|
||||
*/
|
||||
public function addGoodsComment()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$result = $this->validate($post, 'app\api\validate\GoodsComment');
|
||||
if ($result === true) {
|
||||
$result = GoodsCommentLogic::addGoodsComment( $post,$this->user_id);
|
||||
if($result === true){
|
||||
$this->_success('评论成功');
|
||||
}
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
/**
|
||||
* note 服务子订单的pl
|
||||
* create_time 2020/11/11 15:14
|
||||
*/
|
||||
public function addOrderComment()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$result = GoodsCommentLogic::addOrderComment( $post,$this->user_id);
|
||||
|
||||
if($result === true){
|
||||
$this->_success('评论成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取到订单的详情
|
||||
* create_time 2020/11/11 15:14
|
||||
*/
|
||||
public function OrderInfo()
|
||||
{
|
||||
$post = $this->request->post('id');
|
||||
$result = GoodsCommentLogic::OrderInfo($post);
|
||||
|
||||
$this->_success('获取成功',$result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* note 获取未评论或已评论的订单商品列表
|
||||
* create_time 2020/11/12 11:11
|
||||
*/
|
||||
public function getOrderGoods(){
|
||||
$type = $this->request->get('type',1);
|
||||
$list = GoodsCommentLogic::getOrderGoods($type,$this->user_id, $this->page_no, $this->page_size);
|
||||
$this->_success('',$list);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取评论的商品信息
|
||||
* create_time 2020/11/13 14:45
|
||||
*/
|
||||
public function getGoods(){
|
||||
$id = $this->request->get('id');
|
||||
if($id){
|
||||
$goods = GoodsCommentLogic::getGoods($id);
|
||||
$this->_success('获取成功',$goods);
|
||||
}
|
||||
$this->_success('请选择评论的商品');
|
||||
}
|
||||
}
|
||||
52
application/api/controller/Help.php
Normal file
52
application/api/controller/Help.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\HelpLogic;
|
||||
|
||||
|
||||
class Help extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists', 'category', 'detail'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$article = HelpLogic::lists($id, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $article);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
$help = HelpLogic::CategoryLists();
|
||||
$this->_success('获取成功', $help);
|
||||
}
|
||||
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$client = $this->request->get('client',1);
|
||||
$help_detail = HelpLogic::getHelpDetail($id,$client);
|
||||
$this->_success('获取成功', $help_detail);
|
||||
}
|
||||
|
||||
}
|
||||
272
application/api/controller/Index.php
Normal file
272
application/api/controller/Index.php
Normal file
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:htp://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\model\Client_;
|
||||
use app\common\model\MessageScene_;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use think\facade\Hook;
|
||||
use think\Db;
|
||||
use app\common\model\{NoticeSetting, SmsLog, SmsConfig};
|
||||
use app\common\server\Alisms;
|
||||
class Index extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['test','sedx','lists','appInit', 'downLine', 'share', 'config','pcLists','goods_stay_time','send_sms','get_pege'];
|
||||
|
||||
//短信宝接口
|
||||
public function sedx(){
|
||||
$nowtime = time();
|
||||
$s = strtotime(date('Y-m-d',$nowtime+86400));
|
||||
$e = strtotime(date('Y-m-d',$s))+86399;
|
||||
$where = [
|
||||
['autotime','>=',$s],
|
||||
['autotime','<=',$e],
|
||||
];
|
||||
$phons = Db::name('order_exe')
|
||||
->where($where)
|
||||
->where('status','<>',3)
|
||||
->field('phone')
|
||||
->select();
|
||||
$apiUrl = "https://api.smsbao.com/sms?" . http_build_query([
|
||||
'u' => 'connoryz',
|
||||
'p' => '6ea341b75d96492396d98ac26a5b71e6',
|
||||
'm' => '18285169381',
|
||||
'c' => '测试短信内容', // 内容需要编码
|
||||
]);
|
||||
|
||||
$result = file_get_contents($apiUrl);
|
||||
if ($result === '0') {
|
||||
echo '短信发送成功';
|
||||
} else {
|
||||
echo '短信发送失败';
|
||||
}
|
||||
|
||||
dump($result);
|
||||
}
|
||||
|
||||
//阿里云短信接口
|
||||
public function send_sms(){
|
||||
$config = SmsConfig::get(['status' => 1]);
|
||||
if(!$config || !$config->app_key){
|
||||
echo '短信未开启';
|
||||
exit;
|
||||
}
|
||||
$config->sign ='哆啦猫家政';
|
||||
|
||||
$alisms = new Alisms($config);
|
||||
|
||||
|
||||
$nowtime = time();
|
||||
//明日起始时间
|
||||
$s = strtotime(date('Y-m-d',$nowtime+86400));
|
||||
$e = strtotime(date('Y-m-d',$s))+86399;
|
||||
|
||||
$where = [
|
||||
['autotime','>=',$s],
|
||||
['autotime','<=',$e],
|
||||
];
|
||||
$phons = Db::name('order_exe')
|
||||
->where($where)
|
||||
->where('status','<>',3)
|
||||
->field('phone')
|
||||
->select();
|
||||
if(empty($phons)){
|
||||
echo '暂无号码';
|
||||
exit;
|
||||
}
|
||||
foreach ($phons as $v){
|
||||
if(empty($v['phone'])) continue;
|
||||
$res = $alisms->setMobile($v['phone'])
|
||||
->setTemplateCode('SMS_492015079')
|
||||
->sendSms();
|
||||
}
|
||||
echo '执行完成';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* note 首页接口
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function lists(){
|
||||
$lists = IndexLogic::lists($this->user_id);
|
||||
return $this->_success('',$lists);
|
||||
}
|
||||
public function get_pege(){
|
||||
$id = $this->request->get('id');
|
||||
$date=Db::name('pageweb')->where('id',$id)->find();
|
||||
$this->_success('获取数据成功',$date);
|
||||
}
|
||||
public function goods_stay_time(){
|
||||
$input = input();
|
||||
if(empty($input['uid'])){
|
||||
$this->_error('uid empty');
|
||||
}
|
||||
if(empty($input['goods_id'])){
|
||||
$this->_error('goods_id empty');
|
||||
}
|
||||
if(empty($input['time'])){
|
||||
$this->_error('time empty');
|
||||
}
|
||||
|
||||
$uid = $input['uid'];
|
||||
$goods_id = $input['goods_id'];
|
||||
$time = $input['time'];
|
||||
$data = [
|
||||
'uid'=>$uid,
|
||||
'goods_id'=>$goods_id,
|
||||
'time'=>$time,
|
||||
'add_time'=>time()
|
||||
];
|
||||
Db::name('goods_stay_time')->insert($data);
|
||||
$this->_success('ok');
|
||||
}
|
||||
|
||||
/**
|
||||
* app下载链接 todo lr未完成
|
||||
*/
|
||||
public function downLine()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$check = $this->validate($get, 'app\api\validate\App');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
if(isset($get['client']) && $get['client'] == Client_::ios){
|
||||
$this->_success('', ['line' => ConfigServer::get('app', 'line_ios', '')]);
|
||||
}else{
|
||||
$this->_success('', ['line' => ConfigServer::get('app', 'line_android', '')]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* app初始化接口
|
||||
* 苹果不允许单独只有微信第三方登录
|
||||
*/
|
||||
public function appInit()
|
||||
{
|
||||
$data = [
|
||||
'wechat_login' => ConfigServer::get('app', 'wechat_login', '',0),//微信登录
|
||||
//弹出协议
|
||||
'agreement' => ConfigServer::get('app', 'agreement', '',1)
|
||||
];
|
||||
$this->_success('', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取分享信息
|
||||
* @author 张无忌(2021/1/20 17:04)
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function share()
|
||||
{
|
||||
$client = $this->request->get('client', Client_::mnp, 'intval');
|
||||
$config = [];
|
||||
switch ($client) {
|
||||
case Client_::mnp:
|
||||
$config = ConfigServer::get('share', 'mnp', [
|
||||
'mnp_share_title' => ''
|
||||
]);
|
||||
break;
|
||||
case Client_::oa:
|
||||
$config = ConfigServer::get('share', 'h5', [
|
||||
'h5_share_title' => '',
|
||||
'h5_share_intro' => '',
|
||||
'h5_share_image' => ''
|
||||
]);
|
||||
if (!empty($config['h5_share_image']) and $config['h5_share_image'] !== '') {
|
||||
$config['h5_share_image'] = UrlServer::getFileUrl($config['h5_share_image']);
|
||||
}
|
||||
break;
|
||||
case Client_::android:
|
||||
case Client_::ios:
|
||||
$config = ConfigServer::get('share', 'app', [
|
||||
'app_share_title' => '',
|
||||
'app_share_intro' => '',
|
||||
'app_share_image' => ''
|
||||
]);
|
||||
if (!empty($config['app_share_image']) and $config['app_share_image'] !== '') {
|
||||
$config['app_share_image'] = UrlServer::getFileUrl($config['app_share_image']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $this->_success('获取成功', $config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 设置
|
||||
* @author 段誉(2021/2/25 15:39)
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$navigation = Db::name('dev_navigation')
|
||||
->field('name,selected_icon,un_selected_icon')
|
||||
->where('del', 0)
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
foreach($navigation as &$item) {
|
||||
$item['selected_icon'] = empty($item['selected_icon']) ? '' : UrlServer::getFileUrl($item['selected_icon']);
|
||||
$item['un_selected_icon'] = empty($item['un_selected_icon']) ? '' : UrlServer::getFileUrl($item['un_selected_icon']);
|
||||
}
|
||||
$config = [
|
||||
'register_setting' => ConfigServer::get('register_setting', 'open', 0),//注册设置-是否开启短信验证注册
|
||||
'app_wechat_login' => ConfigServer::get('app', 'wechat_login', 0),//APP是否允许微信授权登录
|
||||
'shop_login_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'shop_login_logo')),//移动端登录页logo
|
||||
'web_favicon' => UrlServer::getFileUrl(ConfigServer::get('website', 'web_favicon')),//浏览器标签图标
|
||||
'name' => ConfigServer::get('website', 'name'),//商城名称
|
||||
'copyright_info' => ConfigServer::get('copyright', 'company_name'),//版权信息
|
||||
'icp_number' => ConfigServer::get('copyright', 'number'),//ICP备案号
|
||||
'icp_link' => ConfigServer::get('copyright', 'link'),//备案号链接
|
||||
'app_agreement' => ConfigServer::get('app', 'agreement', 0),//app弹出协议
|
||||
'ios_download' => ConfigServer::get('app', 'line_ios', ''),//ios_app下载链接
|
||||
'android_download' => ConfigServer::get('app', 'line_android', ''),//安卓下载链接
|
||||
'download_doc' => ConfigServer::get('app', 'download_doc', ''),//app下载文案
|
||||
'cate_style' => ConfigServer::get('decoration', 'layout_no', 1),//分类页面风格
|
||||
'index_setting' => [ // 首页设置
|
||||
// 热销榜单
|
||||
'logo' => ConfigServer::get('decoration', 'index_setting_logo', 1),
|
||||
// 热销榜单
|
||||
'hots' => ConfigServer::get('decoration', 'index_setting_hots', 1),
|
||||
// 新品推荐
|
||||
'news' => ConfigServer::get('decoration', 'index_setting_news', 1),
|
||||
// 顶部背景图
|
||||
'top_bg_image' => UrlServer::getFileUrl(ConfigServer::get('decoration', 'index_setting_top_bg_image', ''))
|
||||
],
|
||||
'center_setting' => [ // 个人中心设置
|
||||
// 顶部背景图
|
||||
'top_bg_image' => UrlServer::getFileUrl(ConfigServer::get('decoration', 'center_setting_top_bg_image', ''))
|
||||
],
|
||||
'navigation_setting' => [ // 底部导航设置
|
||||
// 未选中文字颜色
|
||||
'ust_color' => ConfigServer::get('decoration', 'navigation_setting_ust_color', '#000000'),
|
||||
// 选中文字颜色
|
||||
'st_color' => ConfigServer::get('decoration', 'navigation_setting_st_color', '#000000'),
|
||||
// 顶部背景图
|
||||
// 'top_bg_image' => UrlServer::getFileUrl(ConfigServer::get('decoration', 'navigation_setting_top_bg_image', ''))
|
||||
],
|
||||
// 首页底部导航菜单
|
||||
'navigation_menu' => $navigation
|
||||
];
|
||||
$this->_success('', $config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
122
application/api/controller/Leadership.php
Normal file
122
application/api/controller/Leadership.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\LeadershipLogic;
|
||||
use think\Db;
|
||||
|
||||
class Leadership extends ApiBase{
|
||||
public $like_not_need_login = ['index','material_list','material_examine','material_notpass','finance_list','finance_examine','finance_notpass','addorder_list','addorder_examine','addorder_notpass','staff_list'];
|
||||
/**
|
||||
* Notes: pc端首页接口
|
||||
* @author: 2021/3/5 12:00
|
||||
*/
|
||||
public function index(){
|
||||
$lists = PcLogic::pcLists();
|
||||
return $this->_success('',$lists);
|
||||
}
|
||||
|
||||
//获取等待审核物料的数据列表
|
||||
public function material_list(){
|
||||
$get = $this->request->get(); //获取前端传递过来的数据
|
||||
$list = LeadershipLogic::material_list($get);
|
||||
$this->_success('获取成功',$list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//点击审核通过
|
||||
public function material_examine(){
|
||||
$get = $this->request->get(); //获取前端传递过来的数据
|
||||
$update=Db::name('erp_staff')->where('id',$get['id'])->update(['status'=>2]);
|
||||
$this->_success('审核通过');
|
||||
|
||||
}
|
||||
|
||||
//点击审核不通过
|
||||
public function material_notpass(){
|
||||
$get = $this->request->get(); //获取前端传递过来的数据
|
||||
$update=Db::name('erp_staff')->where('id',$get['id'])->update(['status'=>3,'reason'=>$get['data']]);
|
||||
$this->_success('审核通过');
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取报销的列表
|
||||
public function finance_list(){
|
||||
$get = $this->request->get(); //获取前端传递过来的数据
|
||||
$list = LeadershipLogic::finance_list($get);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
//报销审核通过
|
||||
public function finance_examine(){
|
||||
$get= $this->request->get(); //获取前端传递过来的数据
|
||||
$info=Db::name('finance')->where('id',$get['id'])->find();
|
||||
$update=Db::name('finance')->where('id',$get['id'])->update(['status'=>2,'staff_id'=>$get['staff_id']]);
|
||||
$order=Db::name('order_exe')->where('id',$info['order_id'])->update(['account'=>$info['pay']]);
|
||||
$this->_success('审核通过');
|
||||
}
|
||||
//报销审核不通过的理由
|
||||
public function finance_notpass(){
|
||||
$get= $this->request->get(); //获取前端传递过来的数据
|
||||
$update=Db::name('finance')->where('id',$get['id'])->update(['status'=>3,'reason'=>$get['data']]);
|
||||
$this->_success('修改状态成功');
|
||||
}
|
||||
|
||||
//获取报销的列表
|
||||
public function addorder_list(){
|
||||
$get = $this->request->get(); //获取前端传递过来的数据
|
||||
$list = LeadershipLogic::addorder_list($get);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
//加时间通过代码
|
||||
public function addorder_examine(){
|
||||
$get= $this->request->get(); //获取前端传递过来的数据
|
||||
$info=Db::name('order_timeadd')->where('id',$get['id'])->find();
|
||||
$update=Db::name('order_timeadd')->where('id',$get['id'])->update(['status'=>2,'staff_id'=>$get['staff_id']]);
|
||||
$order=Db::name('order_exe')->where('id',$info['orderid'])->update(['add'=>$info['minute']]);
|
||||
$this->_success('审核通过');
|
||||
}
|
||||
//加时间审核不通过代码
|
||||
public function addorder_notpass(){
|
||||
$get= $this->request->get(); //获取前端传递过来的数据
|
||||
$update=Db::name('order_timeadd')->where('id',$get['id'])->update(['status'=>3,'reason'=>$get['data']]);
|
||||
$this->_success('修改状态成功');
|
||||
}
|
||||
|
||||
//获取站长员工下面的信息
|
||||
public function staff_list(){
|
||||
$get= $this->request->get(); //获取前端传递过来的数据
|
||||
$data=Db::name('leavesd')
|
||||
->where('staff_id',$get['staff_id'])
|
||||
->find();
|
||||
if($data){
|
||||
|
||||
}
|
||||
|
||||
$list = LeadershipLogic::staff_list($get);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
103
application/api/controller/LoginPassword.php
Normal file
103
application/api/controller/LoginPassword.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\LoginPasswordLogic;
|
||||
|
||||
|
||||
class LoginPassword extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['check', 'checkcode', 'forget'];
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/登录注册
|
||||
* @title 密码登录
|
||||
* @description 密码登录
|
||||
* @method post
|
||||
* @url /login_password/check
|
||||
* @param mobile 必填 int 手机号
|
||||
* @param password 必填 varchar 密码
|
||||
* @param client 选填 int 不填默认1小程序-2h5-3ios-4安卓
|
||||
* @return_param token varchar token
|
||||
* @remark
|
||||
* @number 1
|
||||
* @return {"code":1,"msg":"登录成功","data":{"token":"d2800867ac869c52a7a017b89209907d"},"show":0,"time":"0.125048","debug":{"request":{"get":[],"post":{"mobile":"13711515723","password":"123456czw"},"header":{"content-length":"288","content-type":"multipart\/form-data; boundary=--------------------------249270077524121393881040","connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"883b6917-66c2-4995-a882-fbc5625bad33","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2","token":"ff0c66fe0c89fe1e9be591d82d551521"}}}}
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\LoginPassword.add');
|
||||
if ($result === true) {
|
||||
$check = LoginPasswordLogic::check($post);
|
||||
if ($check) {
|
||||
|
||||
$this->_error($check['msg'], $check['data'], $check['code']);
|
||||
}
|
||||
$this->_error('获取失败', $result, 0);
|
||||
}
|
||||
$this->_error($result, '', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/登录注册
|
||||
* @title 验证码登录
|
||||
* @description 验证码登录
|
||||
* @method post
|
||||
* @url /login_password/checkCode
|
||||
* @param mobile 必填 int 手机号
|
||||
* @param code 必填 varchar 验证码
|
||||
* @param client 选填 int 不填默认1小程序-2h5-3ios-4安卓
|
||||
* @return_param token varchar token
|
||||
* @remark
|
||||
* @number 1
|
||||
* @return {"code":1,"msg":"登录成功","data":{"token":"c108d186a4e62bc3ac6004074930d43b"},"show":0,"time":"0.136925","debug":{"request":{"get":[],"post":{"mobile":"13711515723","code":"8888"},"header":{"content-length":"279","content-type":"multipart\/form-data; boundary=--------------------------405368968101365594543781","connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"cd4c0d70-e3b5-4576-9f8d-58bbdb6f0e5f","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2","token":"ff0c66fe0c89fe1e9be591d82d551521"}}}}
|
||||
*/
|
||||
public function checkCode()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['message_key'] = 'YZMDL';
|
||||
$result = $this->validate($post, 'app\api\validate\LoginPassword.code');
|
||||
if ($result === true) {
|
||||
$check = LoginPasswordLogic::checkCode($post);
|
||||
if ($check) {
|
||||
|
||||
$this->_error($check['msg'], $check['data'], $check['code']);
|
||||
}
|
||||
$this->_error('获取失败', $result, 0);
|
||||
}
|
||||
$this->_error($result, '', 0);
|
||||
}
|
||||
|
||||
|
||||
//忘记密码
|
||||
public function forget()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['message_key'] = 'ZHMM';
|
||||
$result = $this->validate($post, 'app\api\validate\LoginPassword');
|
||||
if ($result === true) {
|
||||
return LoginPasswordLogic::forget($post);
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
}
|
||||
43
application/api/controller/Luckdraw.php
Normal file
43
application/api/controller/Luckdraw.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\LuckdrawLogic;
|
||||
|
||||
class Luckdraw extends ApiBase
|
||||
{
|
||||
/**
|
||||
* Notes: 抽奖奖品
|
||||
* @author 张无忌(2021/1/26 16:07)
|
||||
*/
|
||||
public function prize()
|
||||
{
|
||||
$lists = LuckdrawLogic::getPrize($this->user_id);
|
||||
$this->_success('OK', $lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 用户抽奖记录
|
||||
* @author 张无忌(2021/1/26 16:14)
|
||||
*/
|
||||
public function record()
|
||||
{
|
||||
$lists = LuckdrawLogic::getUserRecord($this->user_id, $this->page_no, $this->page_size);
|
||||
$this->_success('OK', $lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 抽奖 start
|
||||
* @author 张无忌(2021/1/26 17:00)
|
||||
*/
|
||||
public function draw()
|
||||
{
|
||||
$result = LuckdrawLogic::draw($this->user_id);
|
||||
if ($result) {
|
||||
$this->_success('OK', $result);
|
||||
}
|
||||
$error = LuckdrawLogic::getError() ?: '抽奖失败';
|
||||
$this->_error($error);
|
||||
}
|
||||
}
|
||||
33
application/api/controller/Menu.php
Normal file
33
application/api/controller/Menu.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\MenuLogic;
|
||||
|
||||
class Menu extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$type = $this->request->get('type', 1);
|
||||
$list = MenuLogic::getMenu($type);
|
||||
return $this->_success('获取成功', $list);
|
||||
}
|
||||
}
|
||||
42
application/api/controller/Notice.php
Normal file
42
application/api/controller/Notice.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\common\logic\NoticeLogic;
|
||||
|
||||
class Notice extends ApiBase
|
||||
{
|
||||
//消息中心
|
||||
public function index()
|
||||
{
|
||||
$this->_success('获取成功', NoticeLogic::index($this->user_id));
|
||||
}
|
||||
|
||||
//列表
|
||||
public function lists()
|
||||
{
|
||||
$type = $this->request->get('type');
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$this->_success('获取成功', NoticeLogic::lists($this->user_id, $type, $page, $size));
|
||||
}
|
||||
|
||||
}
|
||||
917
application/api/controller/Order.php
Normal file
917
application/api/controller/Order.php
Normal file
@@ -0,0 +1,917 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\OrderLogic;
|
||||
use app\common\model\Client_;
|
||||
use think\Db;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\common\model\NoticeSetting;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* Class Order
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Order extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['wxmassin', 'lists', 'appInit', 'downLine', 'share', 'config','pcLists','getpege','ttorder'];
|
||||
|
||||
//抖音订单回调
|
||||
public function ttorder(){
|
||||
$ttPay = new ttPay();
|
||||
$res = $ttPay->run('notify');
|
||||
}
|
||||
|
||||
//订单列表
|
||||
public function lists()
|
||||
{
|
||||
$type = $this->request->get('type', 'all');
|
||||
$order_list = OrderLogic::getOrderList($this->user_id, $type, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}
|
||||
|
||||
public function stafflist()
|
||||
{
|
||||
$type = $this->request->get('type', 'all');
|
||||
$order_list = OrderLogic::stafflist($this->user_id, $type, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}
|
||||
|
||||
//员工订单详情页面
|
||||
public function numberlist()
|
||||
{
|
||||
$type = $this->request->get('type', 'all');
|
||||
$tiem= $this->request->get();
|
||||
if(isset($tiem['id'])){
|
||||
|
||||
|
||||
$order_list = OrderLogic::timelist($this->user_id, $type,$tiem,$this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}else{
|
||||
$order_list = OrderLogic::numberlist($this->user_id, $type, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}
|
||||
|
||||
}
|
||||
//员工服务订单列表
|
||||
|
||||
//下单接口
|
||||
public function buy()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
|
||||
$post['user_id'] = $this->user_id;
|
||||
$post['client'] = $this->client;
|
||||
|
||||
// $openid = 'oehgp4zzyK34d3TgnXD1ytpeNRjI';
|
||||
|
||||
// //发送下单成功通知
|
||||
// $template = [
|
||||
// 'touser'=>$openid,
|
||||
// 'template_id'=>'qTmpP2ZnGMpgAFgNsmcVMfTjCeSE7GXEQQaFTUERAuU',
|
||||
// 'page'=>'',//点击模板消息 打开小程序页面
|
||||
// 'data'=>[
|
||||
// 'thing2'=>['value'=>'擦玻璃服务'],
|
||||
// 'amount8'=>['value'=>'金额:2元'],
|
||||
// 'time10'=>['value'=>date('Y-m-d H:i',time())]
|
||||
// ]
|
||||
// ];
|
||||
// $r = send_mini_template($template);
|
||||
|
||||
$check = $this->validate($post, 'app\api\validate\Order.buy');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
|
||||
$action = $post['action'];
|
||||
|
||||
|
||||
$info = OrderLogic::info($post, $this->user_id);
|
||||
|
||||
|
||||
|
||||
if ($info['code'] == 0) {
|
||||
$this->_error($info['msg']);
|
||||
}
|
||||
|
||||
if ($action == 'info') {
|
||||
$this->_success('', $info['data']);
|
||||
}
|
||||
|
||||
if ($this->client != Client_::pc && empty($post['pay_way'])) {
|
||||
$this->_error('请联系管理员配置支付方式');
|
||||
}
|
||||
|
||||
|
||||
$order = OrderLogic::add($this->user_id, $info['data'], $post);
|
||||
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
//订单详情
|
||||
public function detail()
|
||||
{
|
||||
$order_id = $this->request->get('id');
|
||||
if (!$order_id){
|
||||
$this->_error('请选择订单');
|
||||
}
|
||||
$order_detail = OrderLogic::getOrderDetail($order_id, $this->user_id);
|
||||
if (!$order_detail) {
|
||||
$this->_error('订单不存在了!', '');
|
||||
}
|
||||
$this->_success('获取成功', $order_detail);
|
||||
}
|
||||
|
||||
//取消订单
|
||||
public function cancel()
|
||||
{
|
||||
$order_id = $this->request->post('id');
|
||||
if (empty($order_id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
return OrderLogic::cancel($order_id, $this->user_id);
|
||||
}
|
||||
|
||||
|
||||
//删除订单
|
||||
public function del()
|
||||
{
|
||||
$order_id = $this->request->post('id');
|
||||
if (empty($order_id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
return OrderLogic::del($order_id, $this->user_id);
|
||||
}
|
||||
|
||||
|
||||
//确认订单
|
||||
public function confirm()
|
||||
{
|
||||
$order_id = $this->request->post('id');
|
||||
if (empty($order_id)) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
return OrderLogic::confirm($order_id, $this->user_id);
|
||||
}
|
||||
|
||||
|
||||
public function orderTraces()
|
||||
{
|
||||
$order_id = $this->request->get('id');
|
||||
$tips = '参数错误';
|
||||
if ($order_id) {
|
||||
$traces = OrderLogic::orderTraces($order_id, $this->user_id);
|
||||
if ($traces) {
|
||||
$this->_success('获取成功', $traces);
|
||||
}
|
||||
$tips = '暂无物流信息';
|
||||
}
|
||||
$this->_error($tips);
|
||||
}
|
||||
|
||||
public function Get_Chinese_WeekDay($Join_Date)
|
||||
{
|
||||
$WeekDay = date('w', strtotime($Join_Date));
|
||||
$WeekList = array('日', '一', '二', '三', '四', '五', '六');
|
||||
return '星期' . $WeekList[$WeekDay];
|
||||
}
|
||||
|
||||
|
||||
public function get3day(){
|
||||
$goods_id = $this->request->post('id');
|
||||
$order=Db::name('order')->where('id',$goods_id)->find(); //获取到订单的信息
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find(); //获取到商品的信息
|
||||
|
||||
|
||||
// $staff=Db::name('staff')->where('goods_id',$goods['brand_id'])->select(); //查询到所有的保洁师傅
|
||||
// dump($staff);die;
|
||||
|
||||
$days = [];
|
||||
$current = date('Y-m-d');
|
||||
for($i = 1 ; $i <= 3 ;$i++){
|
||||
$current = date("Y-m-d", strtotime($current . "+1 day"));
|
||||
$days[] = $current;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
foreach ($days as $k=>$v){
|
||||
$start = strtotime($v); //开始时间
|
||||
$end = strtotime($v.' 23:59:59'); //结束时间
|
||||
|
||||
//统计这个时间请假的用户的数据
|
||||
$orders=Db::name('order_exe')->where('addtime',1)->where('autotime','>=',$start)->where('autotime','<=',$end)->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
$oneDimensionalArray = array_column($orders, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
|
||||
|
||||
$lent=Db::name('leave')->where('addtime',1)->where('time','>=',$start)->where('time','<=',$end)->whereNotNull('user_id')->field('user_id')->group('user_id')->select();
|
||||
$lentuser = array_column($lent,'user_id');
|
||||
|
||||
|
||||
//判断上午
|
||||
$numbersw=Db::name('staff')
|
||||
->where('onwork',1)
|
||||
->where('goods_id',$goods['brand_id'])
|
||||
->whereNotIn('id',$oneDimensionalArray) // $array为要比较的数组
|
||||
->whereNotIn('id',$lentuser) // $array为要比较的数组
|
||||
->count(); //获取到请假的人数
|
||||
$order_numbersw=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id',0)->where('addtime',1)->count();// 没有派单的保洁师
|
||||
|
||||
$numbersw=$numbersw-$order_numbersw;
|
||||
|
||||
|
||||
//统计这个时间请假的用户的数据
|
||||
$ordersxw=Db::name('order_exe')->where('addtime',2)->where('autotime','>=',$start)->where('autotime','<=',$end)->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
$oneDimensionalArrayxw= array_column($ordersxw, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
|
||||
|
||||
$lentxw=Db::name('leave')->where('addtime',2)->where('time','>=',$start)->where('time','<=',$end)->whereNotNull('user_id')->field('user_id')->group('user_id')->select();
|
||||
$lentuserxw = array_column($lentxw,'user_id');
|
||||
|
||||
|
||||
|
||||
//判断下午
|
||||
$numberxw=Db::name('staff')
|
||||
->where('onwork',1)
|
||||
->whereNotIn('id',$oneDimensionalArrayxw) // $array为要比较的数组
|
||||
->where('goods_id',$goods['brand_id'])
|
||||
->whereNotIn('id',$lentuserxw) // $array为要比较的数组
|
||||
->count(); //获取到请假的人数
|
||||
$order_numberxw=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id',0)->where('addtime',2)->count();// 没有派单的保洁师
|
||||
$numberxw=$numberxw-$order_numberxw;
|
||||
if($numbersw>0){
|
||||
$coied=false;
|
||||
} else{
|
||||
$coied=true;
|
||||
}
|
||||
if($numberxw>0){
|
||||
$coiedxw=false;
|
||||
} else{
|
||||
$coiedxw=true;
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'date'=>$v,
|
||||
'week'=>$this->Get_Chinese_WeekDay($v),
|
||||
'hourLists'=>[
|
||||
['hour'=>"上午",'select'=>false,'disabled'=>$coied,'selectDay'=>$v,'staffnumber'=>$numbersw],
|
||||
['hour'=>'下午','select'=>false,'disabled'=>$coiedxw,'selectDay'=>$v,'staffnumber'=>$numberxw],
|
||||
]
|
||||
];
|
||||
}
|
||||
$data[0]['select'] = true;
|
||||
$this->_success('获取成功', $data);
|
||||
|
||||
}
|
||||
|
||||
public function getday(){
|
||||
$post = $this->request->post();
|
||||
|
||||
$order=Db::name('order')->where('id',$post['data']['id'])->find(); //获取到订单的信息
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find(); //获取到商品的信息
|
||||
$day = $post['data']['day'];
|
||||
$start = strtotime($day);
|
||||
$end = strtotime($day.' 23:59:59');
|
||||
|
||||
|
||||
|
||||
//统计这个时间请假的用户的数据
|
||||
$orders=Db::name('order_exe')->where('addtime',1)->where('autotime','>=',$start)->where('autotime','<=',$end)->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
$oneDimensionalArray = array_column($orders, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
|
||||
|
||||
$lent=Db::name('leave')->where('addtime',1)->where('time','>=',$start)->where('time','<=',$end)->whereNotNull('user_id')->field('user_id')->group('user_id')->select();
|
||||
$lentuser = array_column($lent,'user_id');
|
||||
$numbersw=Db::name('staff')
|
||||
->where('onwork',1)
|
||||
->where('goods_id',$goods['brand_id'])
|
||||
->whereNotIn('id',$oneDimensionalArray) // $array为要比较的数组
|
||||
->whereNotIn('id',$lentuser) // $array为要比较的数组
|
||||
->count();
|
||||
|
||||
$order_numbersw=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id',0)->where('addtime',1)->count();// 没有派单的保洁师
|
||||
|
||||
$numbersw=$numbersw-$order_numbersw;
|
||||
|
||||
//统计这个时间请假的用户的数据
|
||||
$ordersxw=Db::name('order_exe')->where('addtime',2)->where('autotime','>=',$start)->where('autotime','<=',$end)->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
$oneDimensionalArrayxw= array_column($ordersxw, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
|
||||
|
||||
$lentxw=Db::name('leave')->where('addtime',2)->where('time','>=',$start)->where('time','<=',$end)->whereNotNull('user_id')->field('user_id')->group('user_id')->select();
|
||||
$lentuserxw = array_column($lentxw,'user_id');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//判断下午
|
||||
$numberxw=Db::name('staff')
|
||||
->where('onwork',1)
|
||||
->whereNotIn('id',$oneDimensionalArrayxw) // $array为要比较的数组
|
||||
->whereNotIn('id',$lentuserxw) // $array为要比较的数组
|
||||
->where('goods_id',$goods['brand_id'])
|
||||
->count(); //获取到请假的人数
|
||||
|
||||
$order_numberxw=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id',0)->where('addtime',2)->count();// 没有派单的保洁师
|
||||
$numberxw=$numberxw-$order_numberxw;
|
||||
|
||||
if($numbersw>0){
|
||||
$coied=false;
|
||||
}else{
|
||||
$coied=true;
|
||||
}
|
||||
if($numberxw>0){
|
||||
$coiedxw=false;
|
||||
}else{
|
||||
$coiedxw=true;
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'date'=>$day,
|
||||
'week'=>$this->Get_Chinese_WeekDay($day),
|
||||
'hourLists'=>[
|
||||
['hour'=>'上午','select'=>false,'disabled'=>$coied,'selectDay'=>$day,'staffnumber'=>$numbersw],
|
||||
['hour'=>'下午','select'=>false,'disabled'=>$coiedxw,'selectDay'=>$day,'staffnumber'=>$numberxw],
|
||||
]
|
||||
];
|
||||
$data[0]['select'] = true;
|
||||
$this->_success('获取成功', $data);
|
||||
}
|
||||
|
||||
public function sendgzhmsg($orderid = ''){
|
||||
$uid = $this->user_id;
|
||||
// $uid = 366;
|
||||
$openids=Db::name('user_auth')->where('user_id',$uid)->find(); //获取用户的ID
|
||||
$adder=Db::name('user_address')->where('user_id',$uid)->find();
|
||||
// $openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'MJBxsfAT18v9fQ8LYK2v1AF4iRkprNp1KPVm1ses64I', //模板id
|
||||
'data'=>[
|
||||
'time4'=>[
|
||||
'value'=>date('Y-m-d H:i',time())
|
||||
],
|
||||
'thing1'=>[
|
||||
'value'=>$adder['contact']
|
||||
]
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
|
||||
$r = $app->template_message->send($data);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function shensatff($id){
|
||||
dump($id);
|
||||
|
||||
}
|
||||
|
||||
public function putday(){
|
||||
$post = $this->request->post();
|
||||
$sw = $post['data']['hourLists'][0]['select'];
|
||||
$xw = $post['data']['hourLists'][1]['select'];
|
||||
$orderid=$post['data']['id']; //传递进来的订单id
|
||||
$day = $post['data']['date'];
|
||||
$order=Db::name('order')->where('id',$orderid)->find(); //获取到订单的基本信息
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find();
|
||||
if($order['code']<=0){
|
||||
$this->_error('订单次数已不足无法预约');
|
||||
}
|
||||
|
||||
if($sw && $xw){
|
||||
$code=Db::name('order')->where('id',$orderid)->find();
|
||||
if($code['code']<=2){
|
||||
return 20;
|
||||
}else{
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>1,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$datas=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>2,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($datas)->insert();
|
||||
$order=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-2]); //获取到订单的基本信息
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
}
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
|
||||
}
|
||||
}
|
||||
if($sw){
|
||||
if($order>0){
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>1,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$orderss=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-1]); //获取到订单的基本信息
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day.'.8:00-12:00'
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
}
|
||||
|
||||
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
}else{
|
||||
return 20;
|
||||
}
|
||||
|
||||
}
|
||||
if($xw){
|
||||
if($order>0){
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>2,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$order=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-1]); //获取到订单的基本信息
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day.'.14:00-16:00'
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
}
|
||||
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
}else{
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//保洁师开始接单
|
||||
public function take(){
|
||||
$order_id = $this->request->post('params');
|
||||
$order=Db::name('order_exe')->where('id',$order_id)->find();
|
||||
if($order['autotime']-time()>24*3600){
|
||||
$this->_error('无法接单,未到时间');
|
||||
}else{
|
||||
$toke=Db::name('order_exe')->where('id', $order_id )->update(['status'=>1]);
|
||||
$this->_success('接单成功');
|
||||
}
|
||||
}
|
||||
|
||||
//保洁师开始接单
|
||||
public function wego(){
|
||||
$order_id = $this->request->post('params');
|
||||
$toke=Db::name('order_exe')->where('id', $order_id )->update(['status'=>1,'timeadd'=>time(),'staff_status'=>1]);
|
||||
$this->_success('接单成功');
|
||||
}
|
||||
|
||||
//保洁师结束服务
|
||||
public function ends(){
|
||||
$order_id = $this->request->post('params');
|
||||
$toke=Db::name('order_exe')->where('id', $order_id )->update(['status'=>2,'timeout'=>time(),'staff_status'=>1]);
|
||||
$this->_success('接单成功');
|
||||
}
|
||||
|
||||
//订单的详情显示
|
||||
|
||||
public function orderinfo(){
|
||||
$type = $this->request->post('type', 'all');
|
||||
$post=$this->request->post();
|
||||
$order_sn=$post['id']['order_sn'];
|
||||
$order_list = OrderLogic::orderinfo($this->user_id, $type,$order_sn,$this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}
|
||||
|
||||
//微信的通知
|
||||
public function wxmassin(){
|
||||
|
||||
$start = strtotime(date("Y-m-d",strtotime("+1 day")));
|
||||
$end =$start+24*3600-1;
|
||||
$order=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id','<>',0)->select();
|
||||
foreach ($order as &$orders) {
|
||||
$custom=Db::name('order')->where('order_sn',$orders['order_sn'])->find();
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$user=Db::name('staff')->where('id',$orders['staff_id'])->find();
|
||||
|
||||
if($orders['addtime']=1){
|
||||
$timesw='上午';
|
||||
}else{
|
||||
$timesw='下午';
|
||||
}
|
||||
|
||||
// $uid = 366;
|
||||
$openids=Db::name('user_auth')->where('user_id',$user['user_id'])->find(); //获取用户的ID
|
||||
$time=date('Y-m-d',$orders['autotime']);
|
||||
// $openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'YYsFPwTCrPcxi0JA_zg0xnz6uFaVAlobfTGvhQVDglE', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=> $time.$timesw
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$custom['address']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$custom['consignee']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$custom['mobile']
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getpege(){
|
||||
$id = $this->request->get('id');
|
||||
$date=Db::name('pageweb')->where('id',$id)->find();
|
||||
$this->_success('获取数据成功',$date);
|
||||
// dump($id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Class ttPay{
|
||||
|
||||
private $api_url='https://developer.toutiao.com/api/apps/ecpay/v1/';
|
||||
private $app_id;
|
||||
private $token;
|
||||
private $salt;
|
||||
|
||||
public function __construct() {
|
||||
$this->app_id = 'tt0523739e9a12236501';
|
||||
$this->token='123qazqweeesdflomswwe';
|
||||
$this->salt='ejAuHvbI472euyhb34aVyLD92ll9tgZCqWnMi0tX';
|
||||
}
|
||||
|
||||
public function run($action,$order = null){
|
||||
$action=$action?$action:'order';
|
||||
if(!in_array($action,['order','query','refund','settle','notify','set'])){
|
||||
echo '非法请求';die;
|
||||
}
|
||||
return $this->$action($order);
|
||||
}
|
||||
|
||||
//下单
|
||||
private function order($order){
|
||||
$data=[
|
||||
'out_order_no'=>$order['order_sn'],
|
||||
'total_amount'=>1,
|
||||
'subject'=>'购买服务',
|
||||
'body'=>'购买商品',
|
||||
'valid_time'=>3600,
|
||||
];
|
||||
return $this->post('create_order',$data);
|
||||
|
||||
}
|
||||
|
||||
//查询订单
|
||||
private function query(){
|
||||
$data=[
|
||||
'out_order_no'=>'2021110117254573565'
|
||||
];
|
||||
$res=$this->post('query_order',$data,false);
|
||||
echo json_encode($res);die;
|
||||
}
|
||||
|
||||
//订单退款
|
||||
private function refund(){
|
||||
$data=[
|
||||
'out_order_no'=>'2021110118351347832',
|
||||
'out_refund_no'=>$this->order_number(),
|
||||
'reason'=>'退款原因',
|
||||
'refund_amount'=>1,
|
||||
];
|
||||
$res=$this->post('create_refund',$data);
|
||||
echo json_encode($res);die;
|
||||
}
|
||||
|
||||
//订单分账
|
||||
private function settle(){
|
||||
$data=[
|
||||
'out_order_no'=>'2021110118301265990',
|
||||
'out_settle_no'=>$this->order_number(),
|
||||
'settle_desc'=>'分账描述',
|
||||
'settle_params'=>json_encode([]),//分润方参数 如[['merchant_uid'=>'商户号','amount'=>'10']] 可以有多个分账商户
|
||||
];
|
||||
$res=$this->post('settle',$data);
|
||||
echo json_encode($res);die;
|
||||
}
|
||||
|
||||
//支付设置回调测试
|
||||
private function set(){
|
||||
$content=file_get_contents('php://input');
|
||||
$this->log('log.txt',$content);
|
||||
}
|
||||
|
||||
//回调
|
||||
private function notify(){
|
||||
$content=input();
|
||||
|
||||
if(empty($content)) return false;
|
||||
$this->log('notify.txt',json_encode($content));
|
||||
|
||||
if(is_array($content)){
|
||||
$content=$content;
|
||||
}else{
|
||||
$content=json_decode($content,true);
|
||||
}
|
||||
|
||||
$sign=$this->handler($content);
|
||||
if(!empty($content['msg_signature']) && $sign==$content['msg_signature']){
|
||||
|
||||
if(is_array($content['msg'])){
|
||||
$msg=$content['msg'];
|
||||
}else{
|
||||
$msg=json_decode($content['msg'],true);
|
||||
}
|
||||
|
||||
|
||||
if($content['type'] == 'payment'){
|
||||
$order_sn = $msg['payment_order_no'];
|
||||
Db::name('order')->where('order_sn',$order_sn)->update(['pay_status'=>1]);
|
||||
}
|
||||
|
||||
|
||||
//这里更新应用业务逻辑代码,使用$msg跟应用订单比对更新订单,可以用 $content['type']判断是支付回调还是退款回调,payment支付回调 refund退款回调。
|
||||
$res=['err_no'=>0,'err_tips'=>'success'];
|
||||
echo json_encode($res);
|
||||
exit;
|
||||
}else{
|
||||
echo '验签失败';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试订单号,实际应用根据自己应用实际生成
|
||||
* @return string
|
||||
*/
|
||||
private function order_number(){
|
||||
return date('YmdHis').rand(10000,99999);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求小程序平台服务端
|
||||
* @param string $url 接口地址
|
||||
* @param array $data 参数内容
|
||||
* @param boolean $notify 是否有回调
|
||||
* @return array
|
||||
*/
|
||||
private function post($method,$data,$notify=true){
|
||||
$data['app_id']=$this->app_id;
|
||||
|
||||
$data['sign']=$this->sign($data);
|
||||
$url=$this->api_url.$method;
|
||||
$res=$this->http('POST',$url,json_encode($data),['Content-Type: application/json'],true);
|
||||
return json_decode($res,true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回调验签
|
||||
* @param array $map 验签参数
|
||||
* @return stirng
|
||||
*/
|
||||
private function handler($map){
|
||||
$rList = array();
|
||||
array_push($rList, $this->token);
|
||||
foreach($map as $k =>$v) {
|
||||
if ( $k == "type" || $k=='msg_signature')
|
||||
continue;
|
||||
$value = trim(strval($v));
|
||||
if ($value == "" || $value == "null")
|
||||
continue;
|
||||
array_push($rList, $value);
|
||||
}
|
||||
sort($rList,2);
|
||||
return sha1(implode($rList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求签名
|
||||
* @param array $map 请求参数
|
||||
* @return stirng
|
||||
*/
|
||||
private function sign($map) {
|
||||
$rList = array();
|
||||
foreach($map as $k =>$v) {
|
||||
if ($k == "other_settle_params" || $k == "app_id" || $k == "sign" || $k == "thirdparty_id")
|
||||
continue;
|
||||
$value = trim(strval($v));
|
||||
$len = strlen($value);
|
||||
if ($len > 1 && substr($value, 0,1)=="\"" && substr($value,$len, $len-1)=="\"")
|
||||
$value = substr($value,1, $len-1);
|
||||
$value = trim($value);
|
||||
if ($value == "" || $value == "null")
|
||||
continue;
|
||||
array_push($rList, $value);
|
||||
}
|
||||
array_push($rList, $this->salt);
|
||||
sort($rList, 2);
|
||||
return md5(implode('&', $rList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 写日志
|
||||
* @param string $path 日志路径
|
||||
* @param string $content 内容
|
||||
*/
|
||||
private function log($path, $content){
|
||||
$file=fopen($path, "a");
|
||||
fwrite($file, date('Y-m-d H:i:s').'-----'.$content."\n");
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 网络请求
|
||||
* @param stirng $method 请求模式
|
||||
* @param stirng $url请求网关
|
||||
* @param array $params 请求参数
|
||||
* @param stirng $header 自定义头
|
||||
* @param boolean $multi 文件上传
|
||||
* @return array
|
||||
*/
|
||||
private function http( $method = 'GET', $url,$params,$header = array(), $multi = false){
|
||||
|
||||
$opts = array(
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_HTTPHEADER => $header
|
||||
);
|
||||
/* 根据请求类型设置特定参数 */
|
||||
switch(strtoupper($method)){
|
||||
case 'GET':
|
||||
$opts[CURLOPT_URL] = $url . '?' . http_build_query($params);
|
||||
break;
|
||||
case 'POST':
|
||||
//判断是否传输文件
|
||||
$params = $multi ? $params : http_build_query($params);
|
||||
$opts[CURLOPT_URL] = $url;
|
||||
$opts[CURLOPT_POST] = 1;
|
||||
$opts[CURLOPT_POSTFIELDS] = $params;
|
||||
break;
|
||||
default:
|
||||
throw new Exception('不支持的请求方式!');
|
||||
}
|
||||
|
||||
/* 初始化并执行curl请求 */
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, $opts);
|
||||
$data = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
if($error) throw new Exception('请求发生错误:' . $error);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
182
application/api/controller/Payment.php
Normal file
182
application/api/controller/Payment.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\model\Order;
|
||||
use app\common\model\Order as CommonOrder;
|
||||
use app\common\model\Client_;
|
||||
use app\common\server\AliPayServer;
|
||||
use app\common\server\WeChatPayServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\common\logic\PaymentLogic;
|
||||
use app\common\model\Pay;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 支付逻辑
|
||||
* Class Payment
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Payment extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['aliNotify', 'notifyMnp', 'notifyOa', 'notifyApp'];
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 预支付
|
||||
* @author 段誉(2021/2/23 14:33)
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function prepay()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
switch ($post['from']) {
|
||||
case 'order':
|
||||
$order = Order::get($post['order_id']);
|
||||
if ($order['order_status'] == CommonOrder::STATUS_CLOSE || $order['del'] == 1) {
|
||||
$this->_error('订单已关闭');
|
||||
}
|
||||
break;
|
||||
case 'recharge':
|
||||
$order = Db::name('recharge_order')->where(['id' => $post['order_id']])->find();
|
||||
break;
|
||||
}
|
||||
|
||||
//找不到订单
|
||||
if (empty($order)) {
|
||||
$this->_error('订单不存在');
|
||||
}
|
||||
|
||||
//已支付
|
||||
if ($order['pay_status'] == Pay::ISPAID || $order['order_amount'] == 0) {
|
||||
$this->_success('支付成功', ['order_id' => $order['id']], 10001);
|
||||
}
|
||||
|
||||
$result = PaymentLogic::pay($post['from'], $order, $post['order_source']);
|
||||
if (false === $result) {
|
||||
$this->_error(PaymentLogic::getError(), ['order_id' => $order['id']], PaymentLogic::getReturnCode());
|
||||
}
|
||||
|
||||
if (PaymentLogic::getReturnCode() != 0) {
|
||||
$this->_success('', $result, PaymentLogic::getReturnCode());
|
||||
}
|
||||
|
||||
$this->_success('', $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 小程序回调
|
||||
* @author 段誉(2021/2/23 14:34)
|
||||
*/
|
||||
public function notifyMnp()
|
||||
{
|
||||
$config = WeChatServer::getPayConfig(Client_::mnp);
|
||||
return WeChatPayServer::notify($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 公众号回调
|
||||
* @author 段誉(2021/2/23 14:34)
|
||||
*/
|
||||
public function notifyOa()
|
||||
{
|
||||
$config = WeChatServer::getPayConfig(Client_::oa);
|
||||
return WeChatPayServer::notify($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: APP回调
|
||||
* @author 段誉(2021/2/23 14:34)
|
||||
*/
|
||||
public function notifyApp()
|
||||
{
|
||||
$config = WeChatServer::getPayConfig(Client_::ios);
|
||||
return WeChatPayServer::notify($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 支付宝回调
|
||||
* @author 段誉(2021/3/23 11:37)
|
||||
*/
|
||||
public function aliNotify()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$result = (new AliPayServer())->verifyNotify($data);
|
||||
if (true === $result) {
|
||||
echo 'success';
|
||||
} else {
|
||||
echo 'fail';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @author 段誉(2021/3/23 11:36)
|
||||
* @return \think\Model[]
|
||||
*/
|
||||
public function payway()
|
||||
{
|
||||
$get= $this->request->get('client');
|
||||
$payModel = new Pay();
|
||||
$pay = $payModel->where(['status' => 1])->order('sort')->hidden(['config'])->select()->toArray();
|
||||
|
||||
$client = true;
|
||||
if($get) $client = false;
|
||||
foreach ($pay as $k => &$item) {
|
||||
if ($item['code'] == 'wechat') {
|
||||
$item['extra'] = '微信快捷支付';
|
||||
$item['pay_way'] = Pay::WECHAT_PAY;
|
||||
}
|
||||
|
||||
if ($item['code'] == 'balance') {
|
||||
$user_money = Db::name('user')->where(['id' => $this->user_id])->value('user_money');
|
||||
$item['extra'] = '可用余额:'.$user_money;
|
||||
$item['pay_way'] = Pay::BALANCE_PAY;
|
||||
}
|
||||
|
||||
if ($item['code'] == 'alipay' ) {
|
||||
$item['extra'] = '';
|
||||
$item['pay_way'] = Pay::ALI_PAY;
|
||||
}
|
||||
|
||||
if (in_array($this->client, [Client_::mnp, Client_::oa]) && $item['code'] == 'alipay') {
|
||||
unset($pay[$k]);
|
||||
}
|
||||
// if(!$client){
|
||||
// if($item['code'] == 'wechat' || $item['code'] == 'alipay'){
|
||||
// unset($pay[$k]);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
$this->_success('', array_values($pay));
|
||||
}
|
||||
|
||||
}
|
||||
70
application/api/controller/Pc.php
Normal file
70
application/api/controller/Pc.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\PcLogic;
|
||||
|
||||
class Pc extends ApiBase{
|
||||
public $like_not_need_login = ['index','commonData','goodsList'];
|
||||
/**
|
||||
* Notes: pc端首页接口
|
||||
* @author: 2021/3/5 12:00
|
||||
*/
|
||||
public function index(){
|
||||
$lists = PcLogic::pcLists();
|
||||
return $this->_success('',$lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:pc广告公告数据
|
||||
* @author: 2021/3/5 18:00
|
||||
*/
|
||||
public function commonData(){
|
||||
return $this->_success('',PcLogic::commonData($this->user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取商品列表
|
||||
* @author: 2021/3/5 17:19
|
||||
*/
|
||||
public function goodsList(){
|
||||
$type = $this->request->get('type',1);
|
||||
$sort_type = $this->request->get('sort_type','');
|
||||
$sort = $this->request->get('sort','');
|
||||
$name = $this->request->get('name','');
|
||||
$category_id = $this->request->get('category_id','');
|
||||
$list = PcLogic::goodsList($this->page_no,$this->page_size,$name,$category_id,$type,$sort_type,$sort);
|
||||
return $this->_success('',$list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:修改用户信息
|
||||
* @author: 2021/3/8 19:07
|
||||
*/
|
||||
public function changeUserInfo(){
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$result = $this->validate($post,'app\api\validate\ChangeUserInfo.pc');
|
||||
if(true === $result){
|
||||
PcLogic::changeUserInfo($post);
|
||||
return $this->_success('保存成功');
|
||||
}
|
||||
return $this->_error($result);
|
||||
}
|
||||
}
|
||||
53
application/api/controller/Points.php
Normal file
53
application/api/controller/Points.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\PointsLogic;
|
||||
use app\api\logic\UserLogic;
|
||||
|
||||
class Points extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['classify',''];
|
||||
|
||||
/**
|
||||
* 获取积分商品的分类
|
||||
* @return mixed
|
||||
*/
|
||||
public function classify()
|
||||
{
|
||||
$lists = PointsLogic::classify();
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
/**
|
||||
* 获取积分的商品内容
|
||||
* @return mixed
|
||||
*/
|
||||
public function goodslist(){
|
||||
$lists = PointsLogic::goodslist();
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function goodsIofo(){
|
||||
|
||||
$id = $this->request->get('id');
|
||||
$data = PointsLogic::goodsIofo($id);
|
||||
$this->_success('获取数据成功',$data);
|
||||
|
||||
}
|
||||
|
||||
public function goodsSub(){
|
||||
$data = $this->request->get();
|
||||
$data['user_id']= $this->user_id;
|
||||
$user_jf=UserLogic::getUserInfo($this->user_id);
|
||||
if($user_jf['user_integral']<$data['price']){
|
||||
$this->_error('积分不足');
|
||||
}else{
|
||||
$data = PointsLogic::goodsSub($data);
|
||||
$this->_success('兑换成功',$data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
53
application/api/controller/Policy.php
Normal file
53
application/api/controller/Policy.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\PolicyLogic;
|
||||
|
||||
class Policy extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['service', 'privacy', 'aftersale'];
|
||||
|
||||
/**
|
||||
* 服务协议
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
$this->_success('获取成功', PolicyLogic::service());
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐私政策
|
||||
*/
|
||||
public function privacy()
|
||||
{
|
||||
$this->_success('获取成功', PolicyLogic::privacy());
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后保障
|
||||
*/
|
||||
public function afterSale()
|
||||
{
|
||||
$this->_success('获取成功', PolicyLogic::afterSale());
|
||||
}
|
||||
|
||||
}
|
||||
64
application/api/controller/Recharge.php
Normal file
64
application/api/controller/Recharge.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\RechargeLogic;
|
||||
class Recharge extends ApiBase{
|
||||
public $like_not_need_login = ['rechargetemplate'];
|
||||
/**
|
||||
* note 充值模板
|
||||
* create_time 2020/10/24 15:56
|
||||
*/
|
||||
public function rechargeTemplate(){
|
||||
$list = RechargeLogic::getTemplate();
|
||||
$this->_success('',$list);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 充值
|
||||
* create_time 2020/10/24 15:56
|
||||
*/
|
||||
public function recharge(){
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post,'app\api\validate\Recharge');
|
||||
|
||||
if($result === true){
|
||||
$data = RechargeLogic::recharge($this->user_id,$this->client,$post);
|
||||
if($data){
|
||||
$this->_success('',$data);
|
||||
}
|
||||
$this->_error('信息获取错误');
|
||||
|
||||
}
|
||||
$this->_error($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值记录
|
||||
*/
|
||||
public function rechargeRecord()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['page_no'] = $get['page_no'] ?? $this->page_no;
|
||||
$get['page_size'] = $get['page_size'] ?? $this->page_size;
|
||||
$get['user_id'] = $this->user_id;
|
||||
$result = RechargeLogic::rechargeRecord($get);
|
||||
return $this->_success('',$result);
|
||||
}
|
||||
}
|
||||
124
application/api/controller/Recruit.php
Normal file
124
application/api/controller/Recruit.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\CartLogic;
|
||||
use app\api\logic\RegionLogic;
|
||||
use think\Db;
|
||||
class Recruit extends ApiBase{
|
||||
|
||||
public $like_not_need_login = ['recruit_type','recruit_order','recruit_orderinfo','staff_list','recruit_index','recruit_listorder','add_order'];
|
||||
|
||||
public function recruit_type(){
|
||||
|
||||
$recruit_type=Db::name('staff_group')->select(); //获取部门信息
|
||||
$recruitype=Db::name('recruitype')->select(); //获取招聘的类型
|
||||
$recrui_monney=Db::name('recrui_monney')->select();
|
||||
|
||||
$data=[
|
||||
'filterProject'=>$recruit_type,
|
||||
'filterSubject'=>$recruitype,
|
||||
'filterYear'=>$recrui_monney
|
||||
|
||||
];
|
||||
|
||||
return $this->_success('获取招聘类型成功',$data);
|
||||
|
||||
}
|
||||
|
||||
//站长端派单查询
|
||||
public function recruit_order(){
|
||||
$get = $this->request->get();//获取的电话查询
|
||||
|
||||
$data=RegionLogic::recruit_order($get);
|
||||
return $this->_success('获取订单的数据成功',$data);
|
||||
|
||||
}
|
||||
|
||||
//根据id获取订单的基本
|
||||
|
||||
public function recruit_orderinfo(){
|
||||
$get = $this->request->get();//获取订单的id
|
||||
$info=Db::name('order')->where('id',$get['order_id'])->find();
|
||||
return $this->_success('获取订单数据成功',$info);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取保洁师的基本
|
||||
public function staff_list(){
|
||||
$get = $this->request->get();//获取传递过来的时间
|
||||
$get['datatime']=date('Y-m-d',$get['time']/1000); //获取提交过来日期
|
||||
$timestamp = strtotime("today 14:00 am"); //上午的时间搓
|
||||
$timestampxw = strtotime("today 18:00 am"); //上午的时间搓
|
||||
//判断日期类型
|
||||
if(time()>strtotime($get['datatime'])){
|
||||
$this->_error('日期时间选择错误');
|
||||
}
|
||||
$data=RegionLogic::staff_list($get);
|
||||
return $this->_success('获取保洁师',$data);
|
||||
|
||||
}
|
||||
|
||||
//首页获取站长端口数据统计
|
||||
public function recruit_index(){
|
||||
$get = $this->request->get();//传递过来的数据
|
||||
$data=RegionLogic::recruit_index($get);
|
||||
return $this->_success('获取订单的数据成功',$data);
|
||||
}
|
||||
|
||||
//首页获取统计内容
|
||||
public function recruit_listorder(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$data=RegionLogic::recruit_listorder($get);
|
||||
return $this->_success('获取订单的数据成功',$data);
|
||||
|
||||
}
|
||||
|
||||
//站长创建子订单
|
||||
public function add_order(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$orderinfo=Db::name('order')->where('id',$get['order_id'])->find();
|
||||
$useradder=Db::name('user_address')->where('', $orderinfo['mobile'])->find();
|
||||
|
||||
//传递过来的时间转换
|
||||
$selectime=date("Y-m-d",$get['time']/1000);
|
||||
|
||||
// 使用date()函数获取星期几的数字表示(0-6,0 是星期天)
|
||||
$weekdayNum = date('N', strtotime($selectime));
|
||||
|
||||
// 使用数组映射星期几的名称
|
||||
$weekdays = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六','星期天'];
|
||||
|
||||
// 获取对应的星期名称
|
||||
$weekdayName = $weekdays[$weekdayNum - 1];
|
||||
|
||||
if($orderinfo && $useradder){
|
||||
$data=[
|
||||
'order_sn' => $orderinfo['order_sn'],
|
||||
'name' => $orderinfo['consignee'],
|
||||
'phone' => $orderinfo['mobile'],
|
||||
'admin' => $useradder['admin_id'],
|
||||
'goods_id' => $orderinfo['goods_id'],
|
||||
'channel_id' => $useradder['brand_id'],
|
||||
'type' => $orderinfo['type_id'],
|
||||
'autotime' => strtotime($selectime),
|
||||
'xq' => $weekdayName,
|
||||
'date' => $selectime,
|
||||
'addtime' => $get['addtime'],
|
||||
'staff_id' => $get['staff_id'],
|
||||
'create_time' => time(),
|
||||
'remark' => $get['remark'],
|
||||
|
||||
];
|
||||
$inser=Db::name('order_exe')->data($data)->insert();
|
||||
if($inser){
|
||||
$update=Db::name('order')->where('order_sn',$orderinfo['order_sn'])->update(['code'=>$orderinfo['code']-1]);
|
||||
return $this->_success('创建子订单成功');
|
||||
}
|
||||
}else{
|
||||
$this->_error('创建子订单失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
application/api/controller/Region.php
Normal file
35
application/api/controller/Region.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\RegionLogic;
|
||||
|
||||
class Region extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$lists = RegionLogic::lists();
|
||||
$this->_success('获取成功', $lists);
|
||||
}
|
||||
}
|
||||
79
application/api/controller/Seckill.php
Normal file
79
application/api/controller/Seckill.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\SeckillLogic;
|
||||
|
||||
|
||||
class Seckill extends ApiBase{
|
||||
|
||||
|
||||
public $like_not_need_login = ['seckilltime','seckillgoods'];
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/营销
|
||||
* @title 获取秒杀时间段
|
||||
* @description 获取秒杀时间段
|
||||
* @method get
|
||||
* @url /seckill/seckillTime
|
||||
* @return {"code":1,"msg":"获取成功","data":[{"id":"1","start_time":"08:00","end_time":"10:00","is_open":0,"tips":"已结束"},{"id":"2","start_time":"11:00","end_time":"14:00","is_open":1,"tips":"抢购中"},{"id":"3","start_time":"14:00","end_time":"18:00","is_open":0,"tips":"未开始"},{"id":"4","start_time":"20:00","end_time":"22:00","is_open":0,"tips":"未开始"}],"show":0,"time":"0.274701","debug":{"request":{"get":[],"post":[],"header":{"connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"bd852ce3-cbe9-4c66-bb91-7e34eb223716","cache-control":"no-cache","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.1","content-type":"","content-length":""}}}}
|
||||
* @return_param id int 活动id
|
||||
* @return_param start_time varchar 开始时间
|
||||
* @return_param end_time varchar 结束时间
|
||||
* @return_param status int 状态0-未开始,1-抢购中;2-已结束
|
||||
* @return_param tips string 提示
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function seckillTime(){
|
||||
$list = SeckillLogic::seckillTime();
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/营销
|
||||
* @title 获取秒杀商品
|
||||
* @description 获取秒杀商品
|
||||
* @method get
|
||||
* @url /seckill/seckillGoods
|
||||
* @return {"code":1,"msg":"获取成功","data":{"list":[{"name":"华为儿童手表3 pro智能电话中小学生天才男女孩防水可爱运动多功能视频拍照通话gps定位4g电信版官方旗舰店","id":"2","image":"http:\/\/www.likeb2b2c.com:20002\/uploads\/images\/20200709\/161c78cbefc68afbbb0e1856b1a9a596.png","min_price":"789.00","seckill_price":"720.00","sales_sum":"0"},{"name":"雀巢(Nestle)脆脆鲨 休闲零食 威化饼干巧克力味24*20g+8*20g","id":"7","image":"http:\/\/www.likeb2b2c.com:20002\/uploads\/images\/20200710\/cd7dfb551061f353ba53d21c2a2275c4.jpg","min_price":"42.99","seckill_price":"40.00","sales_sum":"0"}],"page":1,"size":15,"count":2,"more":0},"show":0,"time":"0.449604","debug":{"request":{"get":{"id":"2"},"post":[],"header":{"connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"91999655-047e-4144-8de2-bedf1e3fac90","cache-control":"no-cache","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.1","content-type":"","content-length":""}}}}
|
||||
* @param id 必填 int 活动id
|
||||
* @param page_no 选填 int 页码(默认第一页)
|
||||
* @param page_size 选填 int 每页数量(默认15)
|
||||
* @return_param name string 商品名称
|
||||
* @return_param id int 商品id
|
||||
* @return_param image array 商品图片
|
||||
* @return_param min_price float 商品最小价
|
||||
* @return_param sales_sum int 销量
|
||||
* @return_param seckill_price float 商品秒杀价
|
||||
* @return_param shop_id int 店铺id
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function seckillGoods(){
|
||||
$id = $this->request->get('id');
|
||||
if($id){
|
||||
$list = SeckillLogic::seckillGoods($id,$this->page_no,$this->page_size);
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
$this->_error('缺少参数');
|
||||
|
||||
}
|
||||
}
|
||||
28
application/api/controller/Service.php
Normal file
28
application/api/controller/Service.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\ServiceLogic;
|
||||
|
||||
class Service extends ApiBase {
|
||||
public $like_not_need_login = ['lists'];
|
||||
public function lists(){
|
||||
$list = ServiceLogic::getConfig();
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
}
|
||||
71
application/api/controller/Share.php
Normal file
71
application/api/controller/Share.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\ShareLogic;
|
||||
use app\common\model\BargainLaunch;
|
||||
|
||||
class Share extends ApiBase
|
||||
{
|
||||
public function shareGoods()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$url = $this->request->get('url');
|
||||
$client = $this->client;
|
||||
if ($id && $url) {
|
||||
$result = ShareLogic::shareGoods($this->user_id, $id, $url, $client);
|
||||
$this->_success($result['msg'], $result['data'], $result['code']);
|
||||
}
|
||||
$this->_error('缺少参数', '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 用户分销海报
|
||||
* @return array
|
||||
* @author 段誉(2021/3/18 10:28)
|
||||
*/
|
||||
public function userPoster()
|
||||
{
|
||||
$url = $this->request->get('url');
|
||||
$client = $this->client;
|
||||
if (empty($client)) {
|
||||
$this->_error('参数缺失');
|
||||
}
|
||||
$result = ShareLogic::getUserPoster($this->user_id, $url, $client);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:砍价分享
|
||||
* @author: 2021/2/25 11:22
|
||||
*/
|
||||
public function shareBargain()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$url = $this->request->get('url');
|
||||
$client = $this->client;
|
||||
$result = $this->validate(['id' => $id, 'url' => $url], 'app\api\validate\Bargain.share');
|
||||
if (true === $result) {
|
||||
$result = ShareLogic::shareBargain($this->user_id, $id, $url, $client);
|
||||
$this->_success($result['msg'], $result['data'], $result['code']);
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
}
|
||||
90
application/api/controller/Sign.php
Normal file
90
application/api/controller/Sign.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\SignLogic;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class sign extends ApiBase{
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/签到
|
||||
* @title 获取签到列表
|
||||
* @description 获取签到列表
|
||||
* @method get
|
||||
* @url /sign/lists
|
||||
* @return {"code":1,"msg":"获取成功","data":{"lists":[{"days":"1","sign_time":null,"status":"0","integral":"22","growth":"552"},{"days":"2","sign_time":null,"status":"0","integral":"22","growth":"552"},{"days":"3","sign_time":null,"status":"0","integral":63,"growth":563},{"days":"4","sign_time":null,"status":"0","integral":66,"growth":596},{"days":"5","sign_time":null,"status":"0","integral":"22","growth":"552"},{"days":"6","sign_time":null,"status":"0","integral":66,"growth":574}],"message":{"user_integral":"5041","days":"0"}},"show":0,"time":"0.126686","debug":{"request":{"get":[],"post":[],"header":{"connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"75a16271-edbd-4172-a238-a7d36ed07019","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2","token":"ff0c66fe0c89fe1e9be591d82d551521","content-type":"","content-length":""}}}}
|
||||
* @return_param days int 天数列表
|
||||
* @return_param sign_time int 签到时间
|
||||
* @return_param status int 签到状态
|
||||
* @return_param integral int 积分值
|
||||
* @return_param growth int 成长值
|
||||
* @return_param user_integral int 用户积分
|
||||
* @return_param user_growth int 用户成长值
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function lists(){
|
||||
$sign = SignLogic::lists($this->user_id);
|
||||
$this->_success('获取成功',$sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/签到
|
||||
* @title 签到
|
||||
* @description 签到
|
||||
* @method get
|
||||
* @url /sign/sign
|
||||
* @return {"code":1,"msg":"获取成功","data":{"integral":"22","growth":"552","day":1},"show":0,"time":"0.201775","debug":{"request":{"get":[],"post":[],"header":{"connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"1c4ef02d-b268-4ba7-a5df-c5b6a5f3d630","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2","token":"ff0c66fe0c89fe1e9be591d82d551521","content-type":"","content-length":""}}}}
|
||||
* @return_param integral int 获得积分值
|
||||
* @return_param growth int 获得成长值
|
||||
* @return_param days int 连续天数
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function sign(){
|
||||
$result = $this->validate(['user_id'=>$this->user_id],'app\api\validate\Sign');
|
||||
if($result === true){
|
||||
$sign = SignLogic::sign($this->user_id);
|
||||
$this->_success('签到成功',$sign);
|
||||
}
|
||||
$this->_error($result);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/签到
|
||||
* @title 获取签到规则
|
||||
* @description 获取签到规则
|
||||
* @method get
|
||||
* @url /sign/rule
|
||||
* @return {"code":1,"msg":"获取成功","data":"1.每天签到可以获得每天签到奖励;\n2.每日最多可签到1次,断签则会重新计算连签天数,达到连续天数后即可获得连续奖励;\n3.活动以及奖励最终解释权归商家所有。\n","show":0,"time":"0.173280","debug":{"request":{"get":[],"post":[],"header":{"connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"e8617112-b05d-4bea-a8d8-424a674f1c84","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.2","token":"ff0c66fe0c89fe1e9be591d82d551521","content-type":"","content-length":""}}}}
|
||||
* @return_param * text 规则
|
||||
* @remark
|
||||
* @number 1
|
||||
*/
|
||||
public function rule(){
|
||||
$rule = ConfigServer::get('sign_rule','instructions','');
|
||||
$this->_success('获取成功',$rule);
|
||||
}
|
||||
}
|
||||
52
application/api/controller/Sms.php
Normal file
52
application/api/controller/Sms.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\SmsLogic;
|
||||
class Sms extends ApiBase{
|
||||
|
||||
public $like_not_need_login = ['send'];
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口/短信
|
||||
* @title 发送短信
|
||||
* @description 发送短信
|
||||
* @method post
|
||||
* @url /sms/send
|
||||
* @return {"code":1,"msg":"发送成功","data":[],"show":0,"time":"0.612711","debug":{"request":{"get":[],"post":{"mobile":"13172565144","key":"ZCYZ"},"header":{"content-length":"278","content-type":"multipart\/form-data; boundary=--------------------------990456238154467810004652","connection":"keep-alive","accept-encoding":"gzip, deflate, br","host":"www.likeb2b2c.com:20002","postman-token":"d517ed7f-5a49-46e2-b975-8828e0475501","cache-control":"no-cache","accept":"*\/*","user-agent":"PostmanRuntime\/7.26.3"}}}}
|
||||
* @return_param id int 订单id
|
||||
* @param mobile 必填 int 手机号码
|
||||
* @param key 必填 int 事件:ZCYZ-注册验证;ZHMM-找回密码;YZMDL-验证码登录; BGSJHM-更换手机号;BDSJHM-绑定手机号码
|
||||
* @remark 这里是备注信息
|
||||
* @number 0
|
||||
*/
|
||||
public function send(){
|
||||
$mobile = $this->request->post('mobile');
|
||||
$key = $this->request->post('key','ZCYZ');
|
||||
$result = $this->validate(['mobile'=>$mobile,'key'=>$key],'app\api\validate\SmsSend');
|
||||
if($result !== true){
|
||||
$this->_error($result);
|
||||
}
|
||||
$send_result = SmsLogic::send($mobile,$key, $this->user_id);
|
||||
if($send_result !== true){
|
||||
$this->_error($send_result);
|
||||
}
|
||||
$this->_success('发送成功');
|
||||
}
|
||||
}
|
||||
822
application/api/controller/Staff.php
Normal file
822
application/api/controller/Staff.php
Normal file
@@ -0,0 +1,822 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\LoginLogic;
|
||||
use app\api\logic\StaffLogic;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\api\server\UserServer;
|
||||
use app\api\cache\TokenCache;
|
||||
use think\facade\Config;
|
||||
use app\api\model\{Coupon, Order, User,Orderexe};
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class Staff extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['staff_user','order_list','staff_taking','order_start','start_tim','order_progress','complete','complete_time','timeorder','index','sement','addsement','listsement','numberement','editsement','addtime','addtimeinfo','addtimenumber','editaddtime','orderinfo','orderlist','staff_qjia','gettoken','get_urlcheme','count','abnormal'];
|
||||
|
||||
function gettoken(){
|
||||
$appid = 'wxfa3cb402f088cbf8';
|
||||
$secret = '563284ab0358e3ee0ada351fc96f045e';
|
||||
$cache_token = cache("wx_1_token");
|
||||
if($cache_token && $cache_token['expires_in'] > time()){
|
||||
return $cache_token['access_token'];
|
||||
}
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
|
||||
$res = json_decode(file_get_contents($url),true);
|
||||
|
||||
$token = $res['access_token'];
|
||||
$res['expires_in'] = time()+ $res['expires_in'] - 100;
|
||||
cache('wx_1_token',$res);
|
||||
return $token;
|
||||
}
|
||||
|
||||
//获取链接
|
||||
function get_urlcheme(){
|
||||
$id = input('id');
|
||||
|
||||
$token = $this->gettoken();
|
||||
$url1 = 'https://api.weixin.qq.com/wxa/generatescheme?access_token='.$token;
|
||||
$ch = curl_init();
|
||||
$data1 = array("path"=>"/pages/eval/eval", "query"=>"id=".$id,"env_version"=>"release");
|
||||
$data = json_encode(array("expire_type"=>1,"expire_interval"=>5,"jump_wxa"=>$data1));
|
||||
curl_setopt($ch, CURLOPT_URL, $url1);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$p = (json_decode($output,true));
|
||||
|
||||
if(empty($p['openlink'])){
|
||||
echo '生成链接失败:'.(!empty($p['errmsg'])?$p['errmsg']:'');
|
||||
exit;
|
||||
}
|
||||
header("Location: {$p['openlink']}");
|
||||
}
|
||||
|
||||
|
||||
//员工的基本的信息
|
||||
public function staff_user(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$inof=Db::name('staff')->where('id',$get['staff_id'])->find();
|
||||
$inof['staff_img']=UrlServer::getFileUrl($inof['image']);
|
||||
if($inof){
|
||||
$inof['ordermonth']=
|
||||
Db::name('order_exe')
|
||||
->where('staff_id', $get['staff_id'])
|
||||
->whereTime('autotime', 'month')
|
||||
->where('staff_status',3)
|
||||
->count(); //拥挤当月完成订单
|
||||
|
||||
$inof['year']=Db::name('order_exe')
|
||||
->where('staff_id', $get['staff_id'])
|
||||
->whereTime('autotime', 'year')
|
||||
->where('staff_status',3)
|
||||
->count(); //拥挤本年完成订单
|
||||
$inof['addtime']=Db::name('order_exe')->where('staff_id', $get['staff_id'])->whereTime('autotime', 'month')->where('staff_status',3)->count(); //拥挤本年完成订单
|
||||
$inof['notfinish']=Db::name('order_exe')->where('staff_id', $inof['id'])->whereTime('autotime', 'month')->where('staff_status',3)->where('addtime',1)->sum('add')/60; //上午加时
|
||||
$inof['finish']=Db::name('order_exe')->where('staff_id', $inof['id'])->whereTime('autotime', 'month')->where('staff_status',3)->where('addtime',2)->sum('add')/60;
|
||||
$inof['amount']=Db::name('order_exe')->where('staff_id', $inof['id'])->whereTime('autotime', 'month')->where('staff_status',3)->sum('account');
|
||||
return $this->_success('获取数据成功',$inof);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//首页的数据统计
|
||||
|
||||
public function index(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
// 计算明天的日期
|
||||
|
||||
$tomorrow = date('Y-m-d', strtotime('+1 day'));
|
||||
|
||||
$start = strtotime($tomorrow); //开始时间
|
||||
$end = strtotime($tomorrow.' 23:59:59'); //结束时间
|
||||
|
||||
$tomorrows = date('Y-m-d', strtotime('+2 day'));
|
||||
|
||||
$starts = strtotime($tomorrows); //开始时间
|
||||
$ends = strtotime($tomorrows.' 23:59:59'); //结束时间
|
||||
|
||||
$tomorrows= date('Y-m-d', strtotime('+2 day'));
|
||||
$userinfo=Db::name('staff')->where('id',$get['uid'])->find();
|
||||
$userinfo['dataorder']=Db::name('order_exe')->whereTime('autotime', 'today')->where('staff_id',$get['uid'])->count(); //统计今天的订单
|
||||
|
||||
|
||||
$userinfo['tomorrow']=Db::name('order_exe')->where('autotime','>=',$start)->where('autotime','<=',$end)->where('staff_id',$get['uid'])->count(); //统计今天的订单
|
||||
|
||||
$userinfo['tomorrows']=Db::name('order_exe')->where('autotime','>=',$starts)->where('autotime','<=',$ends)->where('staff_id',$get['uid'])->count(); //统计今天的订单
|
||||
return $this->_success('获取数据成功',$userinfo);
|
||||
}
|
||||
|
||||
|
||||
//获取等待接单
|
||||
public function order_list(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$lists=StaffLogic::order_list($get);
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//获取等待接单
|
||||
public function order_start(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$order = new Orderexe();
|
||||
$lists = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',$get['staff_status'])
|
||||
->order('autotime desc')
|
||||
->select();
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
//查询其他用户
|
||||
$more_where = [
|
||||
['staff_id','<>',$get['staff_id']],
|
||||
['order_sn','=',$list['order_sn']],
|
||||
['autotime','=',$list['autotime']]
|
||||
];
|
||||
$more_users = $order->where($more_where)
|
||||
->order('autotime desc')
|
||||
->column('staff_id');
|
||||
if(!empty($more_users)){
|
||||
$list['users'] = Db::name('staff')->field('mobile,name,addr')->whereIn('id',$more_users)->select();
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//已经开始的服务的订单
|
||||
public function order_progress(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$order = new Orderexe();
|
||||
$lists = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',$get['staff_status'])
|
||||
->order('autotime desc')
|
||||
->select();
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
//查询其他用户
|
||||
$more_where = [
|
||||
['staff_id','<>',$get['staff_id']],
|
||||
['order_sn','=',$list['order_sn']],
|
||||
['autotime','=',$list['autotime']]
|
||||
];
|
||||
$more_users = $order->where($more_where)
|
||||
->order('autotime desc')
|
||||
->column('staff_id');
|
||||
if(!empty($more_users)){
|
||||
$list['users'] = Db::name('staff')->field('mobile,name,addr')->whereIn('id',$more_users)->select();
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//异常订单列表
|
||||
public function abnormal(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$order = new Orderexe();
|
||||
$lists = $order->where('staff_id',$get['staff_id'])
|
||||
->where('abnormal',$get['staff_status'])
|
||||
->order('autotime desc')
|
||||
->select();
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
//查询其他用户
|
||||
$more_where = [
|
||||
['staff_id','<>',$get['staff_id']],
|
||||
['order_sn','=',$list['order_sn']],
|
||||
['autotime','=',$list['autotime']]
|
||||
];
|
||||
$more_users = $order->where($more_where)
|
||||
->order('autotime desc')
|
||||
->column('staff_id');
|
||||
if(!empty($more_users)){
|
||||
$list['users'] = Db::name('staff')->field('mobile,name,addr')->whereIn('id',$more_users)->select();
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取当月的订单
|
||||
|
||||
public function complete(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$order = new Orderexe();
|
||||
$lists = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',3)
|
||||
->whereTime('autotime','month')
|
||||
->order('autotime desc')
|
||||
->select();
|
||||
|
||||
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
//查询其他用户
|
||||
$more_where = [
|
||||
['staff_id','<>',$get['staff_id']],
|
||||
['order_sn','=',$list['order_sn']],
|
||||
['autotime','=',$list['autotime']]
|
||||
];
|
||||
$more_users = $order->where($more_where)
|
||||
|
||||
->order('autotime desc')
|
||||
->column('staff_id');
|
||||
if(!empty($more_users)){
|
||||
$list['users'] = Db::name('staff')->field('mobile,name,addr')->whereIn('id',$more_users)->select();
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//保洁师开始接单
|
||||
public function staff_taking(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$taking=Db::name('order_exe')->where('id',$get['orderid'])->update(['staff_status'=>1]);
|
||||
$this->_success('获取数据成功',$taking);
|
||||
}
|
||||
//保洁师开始开始服务
|
||||
public function start_tim(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$orderlist=Db::name('order_exe')->where('id',$get['orderid'])->find(); //获取订单的基本信息
|
||||
if($orderlist['addtime']==1){ //派单上午订单
|
||||
$selectime=date("Y-m-d",$orderlist['autotime']); //获取上午的时间
|
||||
$timeStamp = strtotime($selectime . ' 07:30:00');
|
||||
|
||||
if($timeStamp<time()){
|
||||
$start=Db::name('order_exe')->where('id',$get['orderid'])->update(['staff_status'=>2,'start_time'=>time(),'status'=>0]);
|
||||
$this->_success('获取数据成功');
|
||||
}else{
|
||||
$this->_error('开始失败');
|
||||
}
|
||||
}else{
|
||||
$selectime=date("Y-m-d",$orderlist['autotime']); //获取上午的时间
|
||||
$timeStamp = strtotime($selectime . ' 13:30:00');
|
||||
if($timeStamp<time()){
|
||||
$start=Db::name('order_exe')->where('id',$get['orderid'])->update(['staff_status'=>2,'start_time'=>time(),'status'=>0]);
|
||||
$this->_success('获取数据成功');
|
||||
}else{
|
||||
$this->_error('开始失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//保洁师确定订单服务已经完成
|
||||
|
||||
public function complete_time(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$orderlist=Db::name('order_exe')->where('id',$get['orderid'])->find(); //获取订单的基本信息
|
||||
if($orderlist['addtime']==1){ //派单上午订单
|
||||
$selectime=date("Y-m-d",$orderlist['autotime']); //获取上午的时间
|
||||
$timeStamp = strtotime($selectime . ' 11:30:00');
|
||||
if($timeStamp<time()){
|
||||
$start=Db::name('order_exe')->where('id',$get['orderid'])->update(['staff_status'=>3,'timeout'=>time(),'status'=>1]);
|
||||
$this->_success('获取数据成功',$start);
|
||||
}else{
|
||||
$this->_error('开始失败');
|
||||
}
|
||||
}else{
|
||||
$selectime=date("Y-m-d",$orderlist['autotime']); //获取上午的时间
|
||||
$timeStamp = strtotime($selectime . ' 17:30:00');
|
||||
if($timeStamp<time()){
|
||||
$start=Db::name('order_exe')->where('id',$get['orderid'])->update(['staff_status'=>3,'start_time'=>time()]);
|
||||
$this->_success('获取数据成功');
|
||||
}else{
|
||||
$this->_error('开始失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//员工排期订单的查询
|
||||
|
||||
public function timeorder(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$order = new Orderexe();
|
||||
$start = strtotime($get['ordertime']); //开始时间
|
||||
$end = strtotime($get['ordertime'].'23:59:59'); //结束时间
|
||||
$lists = $order->where('staff_id',$get['uid'])
|
||||
->where('autotime','>=',$start)->where('autotime','<=',$end)
|
||||
->order('autotime asc')
|
||||
->select();
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
|
||||
//获取报销的类型
|
||||
|
||||
public function sement(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
|
||||
$lists=Db::name('finance_type')->select(); //获取报销的类型
|
||||
|
||||
$this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//增加保洁记录
|
||||
|
||||
public function addsement(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$orderinfo=Db::name('order_exe')->where('id',$get['orderid'])->find();
|
||||
$sement=Db::name('finance')->where('order_id',$get['orderid'])->find(); //查询报销订单重复
|
||||
$data=[
|
||||
'order_id'=>$get['orderid'],
|
||||
'staff_id'=>$orderinfo['staff_id'],
|
||||
'user_id'=>$orderinfo['staff_id'],
|
||||
'status'=>1,
|
||||
'pay'=>$get['money'],
|
||||
'brand_id'=>$get['type'],
|
||||
'remarks'=>$get['reak'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
if($sement){
|
||||
$this->_error('报销单据已经重复');
|
||||
}else{
|
||||
$inser=Db::name('finance')->data($data)->insert();
|
||||
if($inser){
|
||||
$this->_success('增加报销单成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//根据订单获取报销的列表
|
||||
public function listsement(){
|
||||
$get = $this->request->get();
|
||||
$where = [];
|
||||
$where[] = ['order_id', '=', $get['order_id']];
|
||||
if (isset($get['status']) && !empty($get['status'])) {
|
||||
$where[] = ['status', '=', $get['status']];
|
||||
}
|
||||
|
||||
$lists = Db::name('finance')->where($where)->select();
|
||||
|
||||
// 批量查询优化(避免N+1查询)
|
||||
$orderIds = array_column($lists, 'order_id');
|
||||
$brandIds = array_column($lists, 'brand_id');
|
||||
|
||||
// 批量获取订单信息
|
||||
$orderExes = [];
|
||||
if (!empty($orderIds)) {
|
||||
$orderExes = Db::name('order_exe')
|
||||
->where('id', 'in', $orderIds)
|
||||
->column('*', 'id');
|
||||
}
|
||||
|
||||
// 批量获取品牌信息
|
||||
$financeTypes = [];
|
||||
if (!empty($brandIds)) {
|
||||
$financeTypes = Db::name('finance_type')
|
||||
->where('id', 'in', $brandIds)
|
||||
->column('*', 'id');
|
||||
}
|
||||
|
||||
foreach ($lists as &$list){
|
||||
// 安全获取订单信息
|
||||
$order_exe = $orderExes[$list['order_id']] ?? [];
|
||||
$list['order_sn'] = $order_exe['order_sn'] ?? '';
|
||||
|
||||
// 修复逻辑错误:= 改为 ==
|
||||
if (isset($order_exe['addtime']) && $order_exe['addtime'] == 1) {
|
||||
$list['sw'] = "8:00-12:00";
|
||||
} else {
|
||||
$list['sw'] = "14:00-16:00";
|
||||
}
|
||||
|
||||
// 安全获取品牌信息
|
||||
$type = $financeTypes[$list['brand_id']] ?? [];
|
||||
$list['type_name'] = $type['name'] ?? '';
|
||||
}
|
||||
|
||||
$this->_success('获取报销单数据', $lists);
|
||||
}
|
||||
|
||||
//根据订单获取报销的列表
|
||||
public function numberement(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$lists=Db::name('finance')->where('order_id',$get['order_id'])->find();
|
||||
$this->_success('获取报销单数据',$lists);
|
||||
}
|
||||
|
||||
//员工修改报销的单据
|
||||
public function editsement(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$data=[
|
||||
'order_id'=>$get['orderid'],
|
||||
'status'=>1,
|
||||
'pay'=>$get['money'],
|
||||
'brand_id'=>$get['type'],
|
||||
'remarks'=>$get['reak'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
$lists=Db::name('finance')->where('order_id',$get['orderid'])->data($data)->update();
|
||||
$this->_success('修改报销单据成功',$lists);
|
||||
}
|
||||
|
||||
|
||||
//员工订单加时间
|
||||
|
||||
public function addtime(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$info=Db::name('order_timeadd')->where('orderid',$get['orderid'])->find();
|
||||
if($info){
|
||||
$this->_error('订单已经加时');
|
||||
}else{
|
||||
$data=[
|
||||
'orderid'=>$get['orderid'],
|
||||
'status'=>1,
|
||||
'minute'=>$get['minute'],
|
||||
'remarks'=>$get['reak'],
|
||||
'staff_id'=>$get['staff_id'],
|
||||
'user_id'=>$get['staff_id'],
|
||||
// 'pay_type'=>$get['type'],
|
||||
'pay'=>$get['pay'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
$inser=Db::name('order_timeadd')->data($data)->insert();
|
||||
if($inser){
|
||||
$this->_success('增加服务加时成功');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//根据订单显示加时的详细详细
|
||||
|
||||
public function addtimeinfo(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$result = StaffLogic::infoaddtim($get);
|
||||
$this->_success('获取报销单数据',$result);
|
||||
}
|
||||
|
||||
//更具订单显示详情
|
||||
|
||||
public function addtimenumber(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$inof=Db::name('order_timeadd')->where('orderid',$get['orderid'])->find();
|
||||
$this->_success('获取报销单数据',$inof);
|
||||
}
|
||||
|
||||
//员工端口修改加时间
|
||||
|
||||
public function editaddtime(){
|
||||
$get = $this->request->get();//获取子订单的iD
|
||||
$update=Db::name('order_timeadd')->where('orderid',$get['orderid'])->where('status',1)->update(['minute'=>$get['minute'],'remarks'=>$get['reak'],'pay'=>$get['pay']]);
|
||||
if($update){
|
||||
$this->_success('修改成功',$update);
|
||||
}else{
|
||||
$this->_error('审核已经通过无法修改');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//根据订单ID 获取订单的基本信息
|
||||
public function orderinfo(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
|
||||
// dump($get);
|
||||
// if (is_array($get['order_id'])) {
|
||||
// $data = $get['order_id'];
|
||||
// }else {
|
||||
// $data = json_decode($get['order_id'], true);
|
||||
// }
|
||||
$orders=Db::name('order_timeadd')->where('orderid',$get['order_id'])->find(); //查询加时表格
|
||||
$lists = Db::name('order_exe')->where('id',$get['order_id'])->find(); //查询子订单信息
|
||||
|
||||
if($lists){
|
||||
$lists['autotime']=date("Y-m-d",$lists['autotime']);
|
||||
if($lists['addtime']==1){
|
||||
$lists['sw']='上午';
|
||||
}else{
|
||||
$lists['sw']='下午';
|
||||
}
|
||||
|
||||
$goods= Db::name('order')->where('order_sn',$lists['order_sn'])->find(); //查询子订单信息
|
||||
if($goods){
|
||||
$lists['adder']= $goods['address'];
|
||||
$lists['lat']= $goods['lat'];
|
||||
$lists['lng']= $goods['lng'];
|
||||
}else{
|
||||
$lists['adder']= '-';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$goods=Db::name('goods')->where('id',$goods['goods_id'])->find();
|
||||
$lists['goods_name']= $goods['name'];
|
||||
|
||||
$admin=Db::name('admin')->where('id',$lists['admin'])->find();
|
||||
if($admin){
|
||||
$lists['admin_name']=$admin['name'];
|
||||
$lists['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$lists['admin_name']='-';
|
||||
$lists['admin_phone']='-';
|
||||
}
|
||||
if($orders){
|
||||
$lists['add']=$orders['minute'];
|
||||
}else{
|
||||
$lists['add']=0;
|
||||
}
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
|
||||
}
|
||||
//查询所有的订单接口
|
||||
|
||||
public function orderlist(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$order = new Orderexe();
|
||||
$where=[];
|
||||
if($get['type']==1){
|
||||
$date='year';
|
||||
}else{
|
||||
$date='month';
|
||||
}
|
||||
if($get['type']==3){
|
||||
$where[]=['add', '>', 0];
|
||||
$date='month';
|
||||
}
|
||||
if($get['type']==4){
|
||||
$where[]=['account', '>', 0];
|
||||
$date='month';
|
||||
}
|
||||
|
||||
$lists = $order->where('staff_id',$get['staff_id'])->where($where)
|
||||
->where('staff_status',3)
|
||||
->whereTime('autotime',$date)
|
||||
->order('autotime asc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function staff_qjia(){
|
||||
$get = $this->request->get();//获取提交的基本信息
|
||||
$order=Db::name('order_exe')->where('autotime','>=',$get['start_time'])->where('autotime','<=',$get['end_time'])->where('staff_id',$get['staff_id'])->select(); //统计今天的订单
|
||||
if($order){
|
||||
$this->_error('无法请假有订单',$order);
|
||||
}else{
|
||||
$lent=Db::name('leave')->where('user_id',$get['staff_id'])->where('time','>=',$get['start_time'])->where('time','<=',$get['end_time'])->select();
|
||||
if($lent){
|
||||
$this->_error('请假数据重复',$lent);
|
||||
}else{
|
||||
$this->_success('',StaffLogic::leaveadd($get));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function count(){
|
||||
$order = new Orderexe();
|
||||
$get = $this->request->get();//获取提交的基本信息
|
||||
|
||||
$today = date('Y-m-d');
|
||||
// 计算明天的日期
|
||||
$tomorrow = date('Y-m-d', strtotime($today . ' +1 day'));
|
||||
$tomorrows = date('Y-m-d', strtotime($today . ' +2 day'));
|
||||
$data['toder'] = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',0)
|
||||
->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"])
|
||||
->order('autotime desc')
|
||||
->count();
|
||||
$data['ardfs'] = $order->where('staff_id',$get['staff_id'])
|
||||
->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"])
|
||||
->where('staff_status',1)
|
||||
->order('autotime desc')
|
||||
->count();
|
||||
$data['fwz'] = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',2)
|
||||
->order('autotime desc')
|
||||
->count();
|
||||
$data['fwywc'] = $order->where('staff_id',$get['staff_id'])
|
||||
->where('staff_status',3)
|
||||
->whereTime('autotime','month')
|
||||
->count();
|
||||
$data['ycorder'] = $order->where('staff_id',$get['staff_id'])
|
||||
->where('abnormal',1)
|
||||
->whereTime('autotime','month')
|
||||
->count();
|
||||
$this->_success('获取数据成功',$data);
|
||||
}
|
||||
|
||||
}
|
||||
402
application/api/controller/Staffgoods.php
Normal file
402
application/api/controller/Staffgoods.php
Normal file
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\StaffgoodsLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use app\api\model\{Orderexe};
|
||||
use think\Db;
|
||||
|
||||
class Staffgoods extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['goods_type','godds_list','addgoods','usergoods','staff_del','user_leave','user_addorder','user_finance','order_images','up_imgs','get_imgs','sub_orderlist','counts','order_list','orderinfos','order_sever','goods_info','order_wages','orderinfo_wages'];
|
||||
|
||||
|
||||
//获取物料商品的分类
|
||||
public function goods_type()
|
||||
{
|
||||
$goods_type=Db::name('material_type')->select();
|
||||
return $this->_success('获取数据成功', $goods_type);
|
||||
|
||||
}
|
||||
|
||||
//获取物料的商品信息\
|
||||
public function godds_list(){
|
||||
$get = $this->request->get();//获取到员工的ID
|
||||
$lists=StaffgoodsLogic::godds_list($get);
|
||||
return $this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
public function goods_info(){
|
||||
$id = $this->request->get('id');//获取到员工的ID
|
||||
$lists=StaffgoodsLogic::goods_info($id);
|
||||
return $this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
//员工申请物料
|
||||
public function addgoods(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$lists=StaffgoodsLogic::addgoods($get);
|
||||
return $this->_success('申请成功等待审核');
|
||||
}
|
||||
|
||||
//我的物料申请记录
|
||||
public function usergoods(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$data=Db::name('erp_staff')
|
||||
->where('status',$get['status'])
|
||||
->where('staff_id',$get['staff_id'])
|
||||
->page($get['page'],$get['pageSize'])
|
||||
->select();
|
||||
foreach ($data as $key => $level){
|
||||
$goods=Db::name('epr')->where('id',$level['goods_id'])->find();
|
||||
$data[$key]['name']=$goods['name'];
|
||||
$data[$key]['images']=UrlServer::getFileUrl($goods['abs_avatar']);;
|
||||
$data[$key]['time']=date('Y-m-d H:i:s',$data[$key]['create_time']);
|
||||
|
||||
}
|
||||
return $this->_success('获取数据成功过',$data);
|
||||
}
|
||||
|
||||
//删除物料申请
|
||||
public function staff_del(){
|
||||
$get = $this->request->get();//接受传递过来的参数\
|
||||
$del=Db::name('erp_staff')->where('id',$get['id'])->delete();
|
||||
return $this->_success('删除成功');
|
||||
|
||||
}
|
||||
|
||||
//我的请假的数据
|
||||
public function user_leave(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$data=Db::name('leave')
|
||||
->where('status',0)
|
||||
->where('user_id',$get['staff_id'])
|
||||
->page($get['page'],$get['pageSize'])
|
||||
->select();
|
||||
foreach ($data as $key => $level){
|
||||
$data[$key]['time']=date('Y-m-d',$data[$key]['time']);
|
||||
if($data[$key]['addtime']==1){
|
||||
$data[$key]['sw']='上午';
|
||||
}else{
|
||||
$data[$key]['sw']='下午';
|
||||
}
|
||||
|
||||
}
|
||||
return $this->_success('获取数据成功过',$data);
|
||||
}
|
||||
|
||||
//我的加时订单显示列表
|
||||
public function user_addorder(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$lists=Db::name('order_timeadd')
|
||||
->where('status',$get['status'])
|
||||
->where('staff_id',$get['staff_id'])
|
||||
->page($get['page'],$get['pageSize'])
|
||||
->select();
|
||||
foreach ($lists as $k => $v){
|
||||
$order=Db::name('order_exe')->where('id',$lists[$k]['orderid'])->field('order_sn,addtime')->find(); //获取子订单信息
|
||||
if($order){
|
||||
$order_info=Db::name('order')->where('order_sn',$order['order_sn'])->find();
|
||||
if($order_info){
|
||||
$lists[$k]['order_sn']=$order_info['order_sn'];
|
||||
$lists[$k]['name']=$order_info['consignee'];
|
||||
$lists[$k]['phone']=$order_info['mobile'];
|
||||
$lists[$k]['address']= $order_info['address'];
|
||||
$lists[$k]['lat']= $order_info['lat'];
|
||||
$lists[$k]['lng']= $order_info['lng'];
|
||||
}
|
||||
$goods=Db::name('goods')->where('id',$order_info['goods_id'])->find();
|
||||
$lists[$k]['goods_name']= $goods['name'];
|
||||
|
||||
|
||||
|
||||
if($order['addtime']==1){
|
||||
$lists[$k]['sw']='上午';
|
||||
$lists[$k]['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$lists[$k]['sw']='下午';
|
||||
$lists[$k]['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_success('获取数据成功',$lists);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function user_finance(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$lists=Db::name('finance')
|
||||
->where('status',$get['status'])
|
||||
->where('staff_id',$get['staff_id'])
|
||||
->page($get['page'],$get['pageSize'])
|
||||
->select();
|
||||
foreach ($lists as $k => $v){
|
||||
$order=Db::name('order_exe')->where('id',$lists[$k]['order_id'])->find(); //获取子订单信息
|
||||
$order_info=Db::name('order')->where('order_sn',$order['order_sn'])->find();
|
||||
$lists[$k]['order_sn']=$order_info['order_sn'];
|
||||
$lists[$k]['name']=$order_info['consignee'];
|
||||
$lists[$k]['phone']=$order_info['mobile'];
|
||||
|
||||
|
||||
$goods=Db::name('goods')->where('id',$order_info['goods_id'])->find();
|
||||
$lists[$k]['goods_name']= $goods['name'];
|
||||
|
||||
$lists[$k]['address']= $order_info['address'];
|
||||
$lists[$k]['lat']= $order_info['lat'];
|
||||
$lists[$k]['lng']= $order_info['lng'];
|
||||
|
||||
if($order['addtime']==1){
|
||||
$lists[$k]['sw']='上午';
|
||||
$lists[$k]['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$lists[$k]['sw']='下午';
|
||||
$lists[$k]['sw_time']='14:00-18:00';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->_success('获取数据成功过',$lists);
|
||||
}
|
||||
public function get_imgs(){
|
||||
$input = input();
|
||||
if(empty($input['order_id'])){
|
||||
$this->_error('order_id 不能为空');
|
||||
}
|
||||
|
||||
$data = Db::name('user_order_imges')->where('order_id',$input['order_id'])->find();
|
||||
if(!$data){
|
||||
return $this->_success('');
|
||||
}
|
||||
|
||||
$data['image1'] = json_decode($data['image1'],true);
|
||||
$data['image2'] = json_decode($data['image2'],true);
|
||||
$data['image3'] = json_decode($data['image3'],true);
|
||||
|
||||
foreach ($data['image1'] as $k=>$v){
|
||||
$data['image1'][$k]['url'] = 'https://web.dulmao.com'.$v['url'];
|
||||
}
|
||||
foreach ($data['image2'] as $k=>$v){
|
||||
$data['image2'][$k]['url'] = 'https://web.dulmao.com'.$v['url'];
|
||||
}
|
||||
foreach ($data['image3'] as $k=>$v){
|
||||
$data['image3'][$k]['url'] = 'https://web.dulmao.com'.$v['url'];
|
||||
}
|
||||
|
||||
return $this->_success('保存成功',$data);
|
||||
}
|
||||
public function up_imgs(){
|
||||
$input = input();
|
||||
if(empty($input['data'])){
|
||||
$this->_error('请上传图片');
|
||||
}
|
||||
|
||||
$imgs = json_decode($input['data'],true);
|
||||
$img1 = $imgs['img1'];
|
||||
$img2 = $imgs['img2'];
|
||||
$img3 = $imgs['img3'];
|
||||
|
||||
foreach ($img1 as $k=>$v){
|
||||
$img1[$k]['url'] = str_replace('https://web.dulmao.com','',$v['url']);
|
||||
}
|
||||
foreach ($img2 as $k=>$v){
|
||||
$img2[$k]['url'] = str_replace('https://web.dulmao.com','',$v['url']);
|
||||
}
|
||||
foreach ($img3 as $k=>$v){
|
||||
$img3[$k]['url'] = str_replace('https://web.dulmao.com','',$v['url']);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'image1'=>json_encode($img1),
|
||||
'image2'=>json_encode($img2),
|
||||
'image3'=>json_encode($img3),
|
||||
'textarea'=>$input['textarea'],
|
||||
'order_id'=>$input['order_id']
|
||||
];
|
||||
$info = Db::name('user_order_imges')->where('order_id',$input['order_id'])->find();
|
||||
if($info){
|
||||
Db::name('user_order_imges')->where('order_id',$input['id'])->update($data);
|
||||
Db::name('order_exe')->where('id',$input['id'])->update(['is_images'=>1]);
|
||||
}else{
|
||||
Db::name('user_order_imges')->insert($data);
|
||||
Db::name('order_exe')->where('id',$input['id'])->update(['is_images'=>1]);
|
||||
}
|
||||
return $this->_success('保存成功');
|
||||
|
||||
}
|
||||
|
||||
//上传服务的图片内容
|
||||
public function order_images(){
|
||||
|
||||
$file = request()->file('file');
|
||||
|
||||
// 移动到框架应用根目录/public/uploads/ 目录下
|
||||
if($file){
|
||||
$info = $file->move(ROOT_PATH . '/uploads/webimges');
|
||||
if($info){
|
||||
// 成功上传后 获取上传信息
|
||||
// 输出 jpg
|
||||
// echo $info->getExtension();
|
||||
// // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getSaveName();
|
||||
// // 输出 42a79759f284b767dfcb2a0197904287.jpg
|
||||
// echo $info->getFilename();
|
||||
return json(['code'=>200,'data'=>'https://web.dulmao.com/uploads/webimges/'.$info->getSaveName()]);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>$file->getError()]);
|
||||
}
|
||||
}
|
||||
$this->_error("请上传文件");
|
||||
|
||||
}
|
||||
|
||||
//根据主订单编号获取到子订单
|
||||
public function sub_orderlist(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$order = new Orderexe();
|
||||
$lists =$order->where('order_sn',$get['order_sn'])
|
||||
->where('staff_status',$get['status'])
|
||||
->order('autotime desc')
|
||||
->select();
|
||||
foreach ($lists as $list){
|
||||
$custom=Db::name('order')->where('order_sn',$list['order_sn'])->find();
|
||||
$list['address']= $custom['address'];
|
||||
$list['lat']= $custom['lat'];
|
||||
$list['lng']= $custom['lng'];
|
||||
$goods=Db::name('goods')->where('id',$custom['goods_id'])->find();
|
||||
$list['goods_name']= $goods['name'];
|
||||
|
||||
if(intval(($list['autotime']-time())/86400)>1){
|
||||
$list['jldate']=intval(($list['autotime']-time())/86400);
|
||||
}else{
|
||||
$list['jldate']='-';
|
||||
}
|
||||
|
||||
$adder=Db::name('user_address')->where('telephone',$custom['mobile'])->find();
|
||||
if($adder){
|
||||
$admin=Db::name('admin')->where('id',$adder['admin_id'])->find();
|
||||
if($admin){
|
||||
$list['admin_name']=$admin['name'];
|
||||
$list['admin_phone']=$admin['phone'];
|
||||
}else{
|
||||
$list['admin_name']='-';
|
||||
$list['admin_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
if($list['addtime']==1){
|
||||
$list['sw']='上午';
|
||||
$list['sw_time']='8:00-12:00';
|
||||
}else{
|
||||
$list['sw']='下午';
|
||||
$list['sw_time']='14:00-18:00';
|
||||
}
|
||||
//查询其他用户
|
||||
$list['autotime']=date("Y-m-d",$list['autotime']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $lists);
|
||||
|
||||
}
|
||||
//主订单下面的子订单
|
||||
public function counts(){
|
||||
$order = new Orderexe();
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$data['toder'] = $order->where('order_sn',$get['order_sn'])
|
||||
->where('staff_status',0)
|
||||
->order('autotime desc')
|
||||
->count();
|
||||
$data['ardfs'] = $order->where('order_sn',$get['order_sn'])
|
||||
->where('staff_status',1)
|
||||
->order('autotime desc')
|
||||
->count();
|
||||
$data['fwz'] = $order->where('order_sn',$get['order_sn'])
|
||||
->where('staff_status',2)
|
||||
->count();
|
||||
$data['fwywc'] = $order->where('order_sn',$get['order_sn'])
|
||||
->where('staff_status',3)
|
||||
->count();
|
||||
$data['ycorder'] = $order->where('order_sn',$get['order_sn'])
|
||||
->where('abnormal',1)
|
||||
->count();
|
||||
$this->_success('获取数据成功',$data);
|
||||
|
||||
}
|
||||
//根据订单ID显示订单详情
|
||||
public function orderinfos(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$orderinfo=Db::name('order')->where('id',$get['order_id'])->find();
|
||||
$goods=Db::name('goods')->where('id',$orderinfo['goods_id'])->find();
|
||||
$orderinfo['goods_name']= $goods['name'];
|
||||
$orderinfo['create_time']=date('Y-m-d H:i:s', $orderinfo['create_time']);
|
||||
|
||||
$orderinfo['goods_images']=UrlServer::getFileUrl($goods['image']);
|
||||
$this->_success('获取数据成功',$orderinfo);
|
||||
}
|
||||
//客户管家的主订单
|
||||
public function order_list(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$staff=Db::name('staff')->where('id',$get['staff_id'])->field('mobile')->find();
|
||||
$admin=Db::name('admin')->where('phone',$staff['mobile'])->find();
|
||||
$lists =Db::name('order')->where('admin_id',$admin['id'])
|
||||
->where('pay_status',1)
|
||||
->limit(10)
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as $k => $v){
|
||||
$goods=Db::name('goods')->where('id',$lists[$k]['goods_id'])->find();
|
||||
$lists[$k]['goods_name']= $goods['name'];
|
||||
$lists[$k]['slect_order']=Db::name('order_exe')->where('order_sn',$lists[$k]['order_sn'])->where('staff_status',3)->count();
|
||||
$lists[$k]['time_payorder']= date('Y-m',$lists[$k]['create_time']);
|
||||
$lists[$k]['dai_order']= $lists[$k]['number']-$lists[$k]['code'];
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功',$lists);
|
||||
}
|
||||
|
||||
//订单的评价
|
||||
public function order_sever(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$order=Db::name('order_exe')->where('id',$get['order_id'])->find(); //获取子订单的信息
|
||||
$user=Db::name('order')->where('order_sn',$order['order_sn'])->find(); //获取主订单信息
|
||||
$data=[
|
||||
|
||||
'name'=> $user['consignee'],
|
||||
'phone'=> $user['mobile'],
|
||||
'adders'=> $user['address'],
|
||||
'order_id'=>$get['order_id'],
|
||||
'staff_id'=>$order['staff_id'],
|
||||
'score'=>$get['score'],
|
||||
'eceives'=>$get['infoReceives'],
|
||||
'eceivesd'=>$get['infoReceivesd'],
|
||||
'content'=>$get['textareaValue'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
$where=Db::name('orderexe_evaluate')->where('order_id',$get['order_id'])->find();
|
||||
if($where){
|
||||
$this->_success('已经提交评价');
|
||||
}else{
|
||||
$inser=Db::name('orderexe_evaluate')->data($data)->insert();
|
||||
$this->_success('评价内容提交成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//员工的工资单
|
||||
public function order_wages(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$lists=StaffgoodsLogic::order_wages($get);
|
||||
return $this->_success('获取数据成功', $lists);
|
||||
}
|
||||
//员工年卡订单
|
||||
public function orderinfo_wages(){
|
||||
$get = $this->request->get();//接受传递过来的参数
|
||||
$lists=StaffgoodsLogic::orderinfo_wages($get);
|
||||
return $this->_success('获取数据成功', $lists);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
38
application/api/controller/Subscribe.php
Normal file
38
application/api/controller/Subscribe.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\SubscribeLogic;
|
||||
|
||||
class Subscribe extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['lists'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$scene = $this->request->get('scene');
|
||||
if (!$scene) {
|
||||
$this->_error('缺少场景scene参数');
|
||||
}
|
||||
$lists = SubscribeLogic::lists($scene);
|
||||
return $this->_success('获取成功', $lists);
|
||||
}
|
||||
}
|
||||
94
application/api/controller/Team.php
Normal file
94
application/api/controller/Team.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\TeamLogic;
|
||||
|
||||
/**
|
||||
* 拼团
|
||||
* Class Team
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Team extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['teamGoodsList'];
|
||||
|
||||
// 拼团商品列表
|
||||
public function teamGoodsList()
|
||||
{
|
||||
$lists = TeamLogic::getTeamGoodsList($this->page_no, $this->page_size);
|
||||
if ($lists) {
|
||||
$this->_success('获取成功', $lists);
|
||||
} else {
|
||||
$this->_error(TeamLogic::getError());
|
||||
}
|
||||
}
|
||||
|
||||
//参与拼团活动
|
||||
public function buy()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$post['client'] = $this->client;
|
||||
$check = $this->validate($post, 'app\api\validate\Team.add');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
|
||||
TeamLogic::setUser($this->user_id);
|
||||
|
||||
TeamLogic::setTeamId($post['team_id']);
|
||||
TeamLogic::setTeamGoodsItem($post['item_id']);
|
||||
TeamLogic::setTeamGoodsNum($post['goods_num']);
|
||||
TeamLogic::setIntegralConfig();
|
||||
|
||||
$info = TeamLogic::calculateInfo($post, $this->user_id);
|
||||
|
||||
if ($info === false){
|
||||
$this->_error(TeamLogic::getError());
|
||||
}
|
||||
|
||||
if($post['action'] == 'info'){
|
||||
$this->_success('', $info);
|
||||
}
|
||||
|
||||
$order = TeamLogic::buy($this->user_id, $info, $post);
|
||||
|
||||
if ($order === false){
|
||||
$this->_error(TeamLogic::getError());
|
||||
}
|
||||
$this->_success('', $order);
|
||||
}
|
||||
|
||||
|
||||
//验证拼团
|
||||
public function check()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$check = $this->validate($post, 'app\api\validate\Team.check');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$this->_success();
|
||||
}
|
||||
}
|
||||
15
application/api/controller/Test.php
Normal file
15
application/api/controller/Test.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
class Test extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['sms'];
|
||||
|
||||
public function sms()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
418
application/api/controller/User.php
Normal file
418
application/api/controller/User.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\UserLogic;
|
||||
use think\Db;
|
||||
use app\common\server\UrlServer;
|
||||
use app\api\logic\SmsLogic;
|
||||
use app\common\logic\SmsLogic as CommonSmsLogic;
|
||||
|
||||
class User extends ApiBase{
|
||||
|
||||
/**
|
||||
* Notes:个人中心接口
|
||||
* @author: 2021/3/10 10:13
|
||||
*/
|
||||
public function center(){
|
||||
$info = UserLogic::center($this->user_id);
|
||||
$this->_success('获取成功',$info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:用户信息
|
||||
* @author: 2021/3/10 10:13
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$this->_success('获取成功', UserLogic::getUserInfo($this->user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:设置用户手机号码
|
||||
* @author: 2021/3/10 10:13
|
||||
*/
|
||||
public function setInfo()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$check = $this->validate($data, 'app\api\validate\UpdateUser.set');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
UserLogic::setUserInfo($this->user_id, $data);
|
||||
$this->_success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:账户流水
|
||||
* @author: 2021/3/10 10:13
|
||||
*/
|
||||
public function accountLog(){
|
||||
$source = $this->request->get('source');
|
||||
$type = $this->request->get('type',0);
|
||||
$list = [];
|
||||
if($source){
|
||||
$list = UserLogic::accountLog($this->user_id, $source,$type, $this->page_no, $this->page_size);
|
||||
}
|
||||
$this->_success('获取成功',$list);
|
||||
}
|
||||
|
||||
|
||||
//更换手机号
|
||||
public function changeMobile()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
//默认绑定手机号码
|
||||
$data['message_key'] = 'BDSJHM';
|
||||
$data['client'] = $this->client;
|
||||
$validate = 'app\api\validate\ChangeMobile.binding';
|
||||
//更换手机号码、替换短信key、验证规则
|
||||
if(isset($data['action']) && 'change' == $data['action']){
|
||||
$data['message_key'] = 'BGSJHM';
|
||||
$validate = 'app\api\validate\ChangeMobile';
|
||||
}
|
||||
$data['user_id'] = $this->user_id;
|
||||
$check = $this->validate($data, $validate);
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$res = UserLogic::changeMobile($this->user_id, $data);
|
||||
if($res){
|
||||
$this->_success('操作成功');
|
||||
}
|
||||
$this->_error('操作失败');
|
||||
}
|
||||
|
||||
|
||||
//获取微信手机号
|
||||
public function getMobile()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$check = $this->validate($post, 'app\api\validate\WechatMobile');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
return UserLogic::getMobileByMnp($post);
|
||||
}
|
||||
|
||||
|
||||
//我的粉丝
|
||||
public function fans()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$this->_success('', UserLogic::fans($this->user_id, $get, $page, $size));
|
||||
}
|
||||
|
||||
/**
|
||||
* note 我的钱包
|
||||
* create_time 2020/11/27 16:58
|
||||
*/
|
||||
public function myWallet(){
|
||||
$info = UserLogic::myWallet($this->user_id);
|
||||
$this->_success('获取成功',$info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 我的拼团
|
||||
* @author 张无忌(2021/1/14 18:43)
|
||||
*/
|
||||
public function myTeam()
|
||||
{
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$status = $this->request->get('status', -1);
|
||||
$info = UserLogic::myTeam($this->user_id, $status, $page, $size);
|
||||
$this->_success('获取成功',$info);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 更新微信的用户信息
|
||||
* @author 段誉(2021/4/7 15:28)
|
||||
*/
|
||||
public function setWechatInfo()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$check = $this->validate($data, 'app\api\validate\SetWechatUser');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$res = UserLogic::updateWechatInfo($this->user_id, $data);
|
||||
if (true === $res) {
|
||||
$this->_success('操作成功');
|
||||
}
|
||||
$this->_error('操作失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置支付密码
|
||||
*/
|
||||
public function setPayPassword()
|
||||
{
|
||||
if($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $this->validate($data,'app\api\validate\User.setPayPassword');
|
||||
if(true !== $result){
|
||||
$this->_error($result);
|
||||
}
|
||||
$data['user_id'] = $this->user_id;
|
||||
$data['pay_password'] = md5(trim($data['pay_password']));
|
||||
$result = UserLogic::setPassword($data);
|
||||
if($result) {
|
||||
$this->_success('设置支付密码成功');
|
||||
}else{
|
||||
$this->_error('设置支付密码失败');
|
||||
}
|
||||
}else{
|
||||
$this->_error('请求类型错误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员转账
|
||||
*/
|
||||
public function transfer()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$result = $this->validate($data,'app\api\validate\User.transfer');
|
||||
if(true !== $result){
|
||||
$this->_error($result);
|
||||
}
|
||||
$data['user_id'] = $this->user_id;
|
||||
$result = UserLogic::transfer($data);
|
||||
if($result['code']) {
|
||||
$this->_success($result['msg']);
|
||||
}else{
|
||||
$this->_error($result['msg']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断会员是否有设置支付密码
|
||||
*/
|
||||
public function hasPayPassword()
|
||||
{
|
||||
$payPassword = Db::name('user')->where('id', $this->user_id)->value('pay_password');
|
||||
if($payPassword) {
|
||||
$this->_success('已设置支付密码');
|
||||
}else{
|
||||
// 应前端要求,未设置密码show返回0
|
||||
$this->_error('未设置支付密码', [], 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账记录
|
||||
*/
|
||||
public function transferRecord()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['page_no'] = $get['page_no'] ?? $this->page_no;
|
||||
$get['page_size'] = $get['page_size'] ?? $this->page_size;
|
||||
$get['user_id'] = $this->user_id;
|
||||
$get['type'] = $get['type'] ?? 'all';
|
||||
$result = UserLogic::transferRecord($get);
|
||||
$this->_success('', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 最近转账(取最近3条)
|
||||
*/
|
||||
public function transferRecent()
|
||||
{
|
||||
$list = Db::name('user_transfer')->alias('ut')
|
||||
->distinct(true)
|
||||
->field('u.sn, u.nickname, u.avatar')
|
||||
->leftJoin('user u', 'u.id=ut.transfer_to_id')
|
||||
->where('ut.transfer_from_id', $this->user_id)
|
||||
->order('ut.create_time', 'desc')
|
||||
->limit(3)
|
||||
->select();
|
||||
foreach($list as &$item) {
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
}
|
||||
return $this->_success('', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款会员信息
|
||||
*/
|
||||
public function transferToInfo()
|
||||
{
|
||||
$transferTo = $this->request->get('transferTo', '', 'trim');
|
||||
if(!$transferTo) {
|
||||
return $this->_error('收款会员信息不能为空');
|
||||
}
|
||||
$user = Db::name('user')->field('sn,nickname,avatar')->where('sn', $transferTo)->find();
|
||||
if(!$user) {
|
||||
$user = Db::name('user')->field('sn,nickname,avatar')->where('mobile', $transferTo)->find();
|
||||
if(!$user){
|
||||
return $this->_error('收款会员不存在');
|
||||
}
|
||||
}
|
||||
$user['avatar'] = UrlServer::getFileUrl($user['avatar']);
|
||||
return $this->_success('', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改支付密码
|
||||
*/
|
||||
public function changePayPassword()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
if(empty($post['origin_pay_password'])) {
|
||||
return $this->_error('原支付密码不能为空');
|
||||
}
|
||||
if(empty($post['new_pay_password'])) {
|
||||
return $this->_error('新支付密码不能为空');
|
||||
}
|
||||
$user = Db::name('user')->where('id', $this->user_id)->find();
|
||||
if(md5(trim($post['origin_pay_password'])) != $user['pay_password']) {
|
||||
return $this->_error('原支付密码错误');
|
||||
}
|
||||
$result = Db::name('user')->where('id', $this->user_id)->update([
|
||||
'pay_password' => md5(trim($post['new_pay_password'])),
|
||||
'update_time' => time()
|
||||
]);
|
||||
if($result) {
|
||||
return $this->_success('修改成功');
|
||||
}else{
|
||||
return $this->_error('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 找回密码获取验证码
|
||||
*/
|
||||
public function send(){
|
||||
$mobile = $this->request->post('mobile');
|
||||
$key = 'ZHZFMM'; // 找回支付密码
|
||||
$result = $this->validate(['mobile'=>$mobile,'key'=>$key],'app\api\validate\SmsSend');
|
||||
if($result !== true){
|
||||
$this->_error($result);
|
||||
}
|
||||
$send_result = SmsLogic::send($mobile,$key);
|
||||
if($send_result !== true){
|
||||
$this->_error($send_result);
|
||||
}
|
||||
$this->_success('发送成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 找回支付密码
|
||||
*/
|
||||
public function retrievePayPassword()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
if(empty($post['mobile'])) {
|
||||
return $this->_error('手机号码不能为空');
|
||||
}
|
||||
if(empty($post['code'])) {
|
||||
return $this->_error('验证码不能为空');
|
||||
}
|
||||
if(empty($post['new_pay_password'])) {
|
||||
return $this->_error('新支付密码不能为空');
|
||||
}
|
||||
|
||||
$sms_logic = new CommonSmsLogic('ZHZFMM',$post['mobile'],$post['code']);
|
||||
$check = $sms_logic->checkCode();
|
||||
//检查验证码是否正确
|
||||
if($check !== true){
|
||||
return $this->_error('验证码错误');
|
||||
}
|
||||
//标记验证码已验证
|
||||
$sms_logic->cancelCode();
|
||||
// 设置新的支付密码
|
||||
$result = Db::name('user')->where('id', $this->user_id)->update([
|
||||
'update_time' => time(),
|
||||
'pay_password' => md5(trim($post['new_pay_password']))
|
||||
]);
|
||||
if($result) {
|
||||
return $this->_success('设置成功');
|
||||
}else{
|
||||
return $this->_error('设置失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function staffinfo(){
|
||||
$result = Db::name('staff')->where('user_id', $this->user_id)->where('onwork',1)->find();
|
||||
if($result){
|
||||
|
||||
$data['ordermonth']=Db::name('order_exe')->where('staff_id', $result['id'])->whereTime('autotime', 'month')->where('status',2)->count();
|
||||
|
||||
|
||||
$data['finish']=Db::name('order_exe')->where('staff_id', $result['id'])->whereTime('autotime', 'month')->where('status',2)->where('addtime',1)->sum('add')/60; //上午加时间
|
||||
$data['notfinish']=Db::name('order_exe')->where('staff_id', $result['id'])->whereTime('autotime', 'month')->where('status',2)->where('addtime',2)->sum('add')/60; //下午加时
|
||||
$data['access']=Db::name('order_exe')->where('staff_id', $result['id'])->whereTime('autotime', 'month')->where('status',2)->sum('account'); //下午加时
|
||||
$data['Integral']=$result['number'];
|
||||
$data['abnormal']=Db::name('order_exe')->where('staff_id', $result['id'])->whereTime('autotime', 'month')->where('status',4)->count();
|
||||
// $data=[
|
||||
// 'ordermonth'=>$ordermonth
|
||||
// ];
|
||||
|
||||
return $this->_success('是员工信息',$data);
|
||||
}else{
|
||||
return $this->_error('不是员工信息');
|
||||
}
|
||||
|
||||
}
|
||||
public function addtimeinfo(){
|
||||
$post = $this->request->post();
|
||||
$result = Db::name('order_exe')->where('id', $post['id']['id'])->find();
|
||||
return $this->_success('获取成功', $result);
|
||||
|
||||
}
|
||||
|
||||
public function addtime(){
|
||||
$post = $this->request->post();
|
||||
$add = Db::name('order_exe')->where('id', $post['id']['id'])->find();
|
||||
if($add['add']>0){
|
||||
return $this->_error('已经申请加时');
|
||||
}
|
||||
$result = Db::name('order_exe')->where('id', $post['id']['id'])->update(['add'=>$post['money']]);
|
||||
return $this->_success('加时间成功', $result);
|
||||
}
|
||||
|
||||
public function accountinfo(){
|
||||
$post = $this->request->post();
|
||||
$result = Db::name('order_exe')->where('id', $post['id']['id'])->find();
|
||||
return $this->_success('获取成功', $result);
|
||||
|
||||
}
|
||||
|
||||
public function addaccount(){
|
||||
$post = $this->request->post();
|
||||
$add = Db::name('order_exe')->where('id', $post['id']['id'])->find();
|
||||
if($add['account']>0){
|
||||
return $this->_error('已经申请报销');
|
||||
}
|
||||
$result = Db::name('order_exe')->where('id', $post['id']['id'])->update(['account'=>$post['money']]);
|
||||
return $this->_success('加时间成功', $result);
|
||||
}
|
||||
|
||||
|
||||
public function staffsel(){
|
||||
$post = $this->request->post();
|
||||
$start = strtotime($post['day'][0]); //开始时间
|
||||
$end = strtotime($post['day'][1].'23:59:59'); //结束时间
|
||||
$result = Db::name('staff')->where('user_id', $this->user_id)->where('onwork',1)->find();
|
||||
if($result){
|
||||
|
||||
$data['ordermonth']=Db::name('order_exe')->where('staff_id', $result['id'])->where('autotime','>=',$start)->where('autotime','<=',$end)->where('status',2)->count();
|
||||
$data['finish']=Db::name('order_exe')->where('staff_id', $result['id'])->where('autotime','>=',$start)->where('autotime','<=',$end)->where('status',2)->where('addtime',1)->sum('add')/60; //上午加时间
|
||||
$data['notfinish']=Db::name('order_exe')->where('staff_id', $result['id'])->where('autotime','>=',$start)->where('autotime','<=',$end)->where('status',2)->where('addtime',2)->sum('add')/60; //下午加时
|
||||
$data['access']=Db::name('order_exe')->where('staff_id', $result['id'])->where('autotime','>=',$start)->where('autotime','<=',$end)->where('status',2)->sum('account'); //下午加时
|
||||
$data['Integral']=$result['number'];
|
||||
$data['abnormal']=Db::name('order_exe')->where('staff_id', $result['id'])->where('autotime','>=',$start)->where('autotime','<=',$end)->where('status',4)->count();
|
||||
|
||||
|
||||
return $this->_success('获取数据成功',$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
145
application/api/controller/UserAddress.php
Normal file
145
application/api/controller/UserAddress.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\UserAddressLogic;
|
||||
use think\Db;
|
||||
class UserAddress extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['handleregion'];
|
||||
|
||||
|
||||
//获取地址列表
|
||||
public function lists()
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::infoUserAddress($user_id);
|
||||
$this->_success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取一条地址详情
|
||||
public function detail()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$result = $this->validate($get, 'app\api\validate\UserAddress.one');
|
||||
if ($result === true) {
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::getOneAddress($user_id, $get);
|
||||
if ($result) {
|
||||
$this->_success('获取成功', $result);
|
||||
}
|
||||
$result = '获取失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
//获取默认地址
|
||||
public function getDefault()
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::getDefaultAddress($user_id);
|
||||
if ($result) {
|
||||
$this->_success('获取成功', $result);
|
||||
}
|
||||
$this->_error('获取失败');
|
||||
}
|
||||
|
||||
|
||||
//设置默认地址
|
||||
public function setDefault()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\UserAddress.set');
|
||||
if ($result === true) {
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::setDefaultAddress($user_id, $post);
|
||||
if ($result) {
|
||||
$this->_success('设置成功', $result);
|
||||
}
|
||||
$result = '设置失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//添加收货地址
|
||||
public function add()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\UserAddress.add');
|
||||
if ($result === true) {
|
||||
$user_id = $this->user_id;
|
||||
$adder=Db::name('user_address')->whereLike('telephone',$post['telephone'])->find(); //判断电话号码存在
|
||||
if($adder){
|
||||
$adderss=Db::name('user_address')->whereLike('telephone',$post['telephone'])->update(['user_id'=>$user_id]);
|
||||
$this->_success('添加成功', $adderss);
|
||||
}
|
||||
$result = UserAddressLogic::addUserAddress($user_id, $post);
|
||||
if ($result) {
|
||||
$this->_success('添加成功', $result);
|
||||
}
|
||||
$result = '添加失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
//更新收货地址
|
||||
public function update()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\UserAddress.edit');
|
||||
if ($result === true) {
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::editUserAddress($user_id, $post);
|
||||
if ($result) {
|
||||
$this->_success('修改成功', $result);
|
||||
}
|
||||
$result = '修改失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
//删除收货地址
|
||||
public function del()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\UserAddress.del');
|
||||
if ($result === true) {
|
||||
$user_id = $this->user_id;
|
||||
$result = UserAddressLogic::delUserAddress($user_id, $post);
|
||||
if ($result) {
|
||||
$this->_success('删除成功', $result);
|
||||
}
|
||||
$result = '删除失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
|
||||
//将省市区名称转换成省市区id
|
||||
public function handleRegion()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$result = $this->validate($post, 'app\api\validate\UserAddress.handleRegion');
|
||||
if ($result === true) {
|
||||
$province = $this->request->post('province');
|
||||
$city = $this->request->post('city');
|
||||
$district = $this->request->post('district');
|
||||
$res = UserAddressLogic::handleRegion($province, $city, $district);
|
||||
if ($res) {
|
||||
$this->_success('获取成功', $res);
|
||||
}
|
||||
$result = '获取失败';
|
||||
}
|
||||
$this->_error($result);
|
||||
}
|
||||
|
||||
}
|
||||
28
application/api/controller/UserLevel.php
Normal file
28
application/api/controller/UserLevel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\UserLevelLogic;
|
||||
|
||||
class UserLevel extends ApiBase{
|
||||
public function lists(){
|
||||
$list = UserLevelLogic::lists($this->user_id);
|
||||
$this->_success('获取成功',$list);
|
||||
|
||||
}
|
||||
}
|
||||
63
application/api/controller/WeChat.php
Normal file
63
application/api/controller/WeChat.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\WeChatLogic;
|
||||
|
||||
class WeChat extends ApiBase
|
||||
{
|
||||
|
||||
public $like_not_need_login = ['jsconfig', 'index'];
|
||||
|
||||
/**
|
||||
* showdoc
|
||||
* @catalog 接口列表/微信
|
||||
* @title 微信JSSDK授权接口
|
||||
* @description
|
||||
* @method get
|
||||
* @url we_chat/jsconfig
|
||||
* @param url 必填 varchar 前端当前url
|
||||
* @return_param appId string appid,公众号的唯一标识
|
||||
* @return_param timestamp int 生成签名的时间戳
|
||||
* @return_param nonceStr string 生成签名的随机串
|
||||
* @return_param signature string 签名
|
||||
* @return_param jsApiList array 需要使用的JS接口列表
|
||||
* @remark allow_share: 传入1时,则返回允许分享到朋友圈的配置
|
||||
* @number 0
|
||||
* @return {"code":1,"msg":"获取成功","data":{"config":{"debug":true,"beta":false,"jsApiList":["onMenuShareTimeline","onMenuShareWeibo","openLocation","getLocation","chooseWXPay","updateTimelineShareData"],"appId":"wx9d4……","nonceStr":"Ge8wD……","timestamp":1592707100,"url":"http:\/\/dragon.yixiang……","signature":"8421cfbc……"}}}
|
||||
*/
|
||||
public function jsConfig()
|
||||
{
|
||||
$url = $this->request->get('url');
|
||||
$result = WeChatLogic::jsConfig($url);
|
||||
if ($result['code'] != 1) {
|
||||
$this->_error('', ['config' => $result['data']]);
|
||||
}
|
||||
$this->_success('', ['config' => $result['data']]);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
WeChatLogic::index();
|
||||
}
|
||||
|
||||
}
|
||||
340
application/api/controller/Webmaster.php
Normal file
340
application/api/controller/Webmaster.php
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\WebmasterLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
class Webmaster extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['staffList','Leaveapproval','leavethroug','leavethroug','reject','punishlists','punishthroug','punishreject','material','materialthroug','materialreject','Scheduling','occupy','occupy_del'];
|
||||
|
||||
/**
|
||||
* note 获取站长下面的员工
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
|
||||
public function staffList(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
$this->_success('获取数据成功', $data);
|
||||
}
|
||||
/**
|
||||
* note 请假审批
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function Leaveapproval(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$leave=Db::name('leavesd')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
|
||||
foreach ($leave as &$item){
|
||||
$item['time']=date('Y-m-d',$item['time']);
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $leave);
|
||||
}else{
|
||||
$this->_error('获取数据失败');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* note 请假审批通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function leavethroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('leavesd')->where('id',$param['id'])->update(['status'=>1]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
/**
|
||||
* note 驳回请假
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function reject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('leavesd')->where('id',$param['id'])->update(['status'=>2,'refuse'=>$param['refuse']]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
/**
|
||||
* note 处罚的列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishlists(){
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$punish=Db::name('fine')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach($punish as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s");
|
||||
$user=Db::name('order_exe')->where('id',$item['order_id'])->find();
|
||||
$item['user_name']=$user['name'];
|
||||
$item['user_phone']=$user['phone'];
|
||||
$order=Db::name('order')->where('order_sn',$user['order_sn'])->find();
|
||||
$item['user_adder']=$order['address'];
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
$item['staff_name']= $staff['name'];
|
||||
$item['staff_phone']= $staff['mobile'];
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $punish);
|
||||
}else{
|
||||
$this->_error('网络错误');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* note 审批处罚通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishthroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('fine')->where('id',$param['id'])->update(['status'=>1]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* note 驳回处罚的审核
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function punishreject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('fine')->where('id',$param['id'])->update(['status'=>2]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* note 物料的申请列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function material(){
|
||||
$param = $this->request->post();
|
||||
$param = $this->request->get();
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$material=Db::name('erp_staff')
|
||||
->whereIN('staff_id',$ids)
|
||||
->where('status',$param['status'])
|
||||
->order('id', 'asc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach ($material as &$item){
|
||||
$erp_goods=Db::name('epr')->where('id',$item['goods_id'])->find();
|
||||
if($erp_goods){
|
||||
$item['goods_name']= $erp_goods['name'];
|
||||
$item['goods_img']=UrlServer::getFileUrl($erp_goods['abs_avatar']);
|
||||
|
||||
}else{
|
||||
$item['goods_name']='-';
|
||||
$item['goods_img']='-';
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('获取数据成功', $material);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* note 无聊审批通过
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function materialthroug(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('erp_staff')->where('id',$param['id'])->update(['status'=>2]);
|
||||
$this->_success('审批成功');
|
||||
}
|
||||
/**
|
||||
* note 物料驳回申请
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function materialreject(){
|
||||
$param = $this->request->post();
|
||||
$data=Db::name('erp_staff')->where('id',$param['id'])->update(['status'=>3,'reason'=>$param['reason']]);
|
||||
$this->_success('修改成功');
|
||||
}
|
||||
/**
|
||||
* note 员工排班
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function Scheduling(){
|
||||
$param = $this->request->get();
|
||||
if (!isset($param['id']) || empty($param['id'])) {
|
||||
throw new Exception('员工ID不能为空');
|
||||
}
|
||||
$where=[];
|
||||
//判断检索框
|
||||
$selval = trim($param['selval'] ?? '');
|
||||
if (!empty($selval)) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $selval)) {
|
||||
$where[] = ['s2.mobile', '=', $selval];
|
||||
} else {
|
||||
$where[] = ['s2.name', 'LIKE', '%' . $selval . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
//判断时间的检索
|
||||
if($param['startDate']){
|
||||
$startTime = strtotime($param['startDate']); //开始时间
|
||||
$endTime = strtotime($param['startDate'] . ' 23:59:59'); //结束时间
|
||||
}else{
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
$endTime = strtotime(date('Y-m-d') . ' 23:59:59');
|
||||
}
|
||||
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->where($where)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
foreach ($data as &$item){
|
||||
$item['sw_order']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('autotime', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',1)
|
||||
->find();
|
||||
$item['xw_order']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('autotime', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
$item['sw_zy']=Db::name('leave')
|
||||
->where('user_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',1)
|
||||
->find();
|
||||
$item['xw_zy']=Db::name('leave')
|
||||
->where('user_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
$item['sw_qj']=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->where('status',1)
|
||||
->where('addtime',1)
|
||||
->field('id')
|
||||
->find();
|
||||
$item['xw_qj']=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->whereBetween('time', [$startTime, $endTime])
|
||||
->field('id')
|
||||
->where('status',1)
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
}
|
||||
|
||||
$this->_success('获取数据成功',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 员工占用列表
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function occupy(){
|
||||
$param = $this->request->get();
|
||||
if (!isset($param['id']) || empty($param['id'])) {
|
||||
throw new Exception('站长ID不能为空');
|
||||
}
|
||||
$where=[];
|
||||
$selval = trim($param['selval'] ?? '');
|
||||
if (!empty($selval)) {
|
||||
if (preg_match('/^1[3-9]\d{9}$/', $selval)) {
|
||||
$where[] = ['phone','=',$selval];
|
||||
} else {
|
||||
$where[] = ['name', 'LIKE', '%' . $selval . '%'];
|
||||
}
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
//检索框
|
||||
$data = Db::name('staff')
|
||||
->alias('s1')
|
||||
->field('s1.*, s2.*')
|
||||
->where('s1.id', $param['id'])
|
||||
->where('s2.onwork',1)
|
||||
->join('staff s2', 's1.grouping_id = s2.grouping_id')
|
||||
->select();
|
||||
if($data){
|
||||
$ids = array_column($data, 'id');
|
||||
$occupy=Db::name('leave')
|
||||
->whereIN('user_id',$ids)
|
||||
->where($where)
|
||||
->order('id', 'desc')
|
||||
->page($param['page'], $param['limt'])
|
||||
->select();
|
||||
foreach ($occupy as &$item){
|
||||
$item['time']=date('Y-m-d',$item['time']);
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}else{
|
||||
$item['admin_name']='-';
|
||||
}
|
||||
$type=Db::name('leave_statype')->where('id',$item['type'])->find();
|
||||
if($type){
|
||||
$item['type_name']=$type['name'];
|
||||
}else{
|
||||
$item['type_name']='-';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$this->_success('修改成功', $occupy);
|
||||
}
|
||||
/**
|
||||
* note 删除占用数据
|
||||
* create_time 2020/10/21 19:05
|
||||
*/
|
||||
public function occupy_del(){
|
||||
$param = $this->request->get();
|
||||
$data=Db::name('leave')->where('id',$param['id'])->delete();
|
||||
$this->_success('删除数据成功');
|
||||
}
|
||||
|
||||
}
|
||||
68
application/api/controller/Withdraw.php
Normal file
68
application/api/controller/Withdraw.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\WithdrawLogic;
|
||||
|
||||
class Withdraw extends ApiBase
|
||||
{
|
||||
|
||||
//提现申请
|
||||
public function apply()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
$check = $this->validate($post, 'app\api\validate\Withdraw.apply');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
return WithdrawLogic::apply($this->user_id, $post);
|
||||
}
|
||||
|
||||
//提现配置
|
||||
public function config()
|
||||
{
|
||||
$data = WithdrawLogic::config($this->user_id);
|
||||
$this->_success('', $data);
|
||||
}
|
||||
|
||||
|
||||
//提现记录
|
||||
public function records()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
$res = WithdrawLogic::records($this->user_id, $get, $page, $size);
|
||||
$this->_success('', $res);
|
||||
}
|
||||
|
||||
|
||||
//提现详情
|
||||
public function info()
|
||||
{
|
||||
$get = $this->request->get('');
|
||||
$check = $this->validate($get, 'app\api\validate\Withdraw.info');
|
||||
if (true !== $check) {
|
||||
$this->_error($check);
|
||||
}
|
||||
$this->_success('', WithdrawLogic::info($get['id'], $this->user_id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user