添加网站文件
This commit is contained in:
281
application/admin/logic/AccountLogLogic.php
Normal file
281
application/admin/logic/AccountLogLogic.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?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\admin\logic;
|
||||
use app\admin\model\User;
|
||||
use app\api\model\Order;
|
||||
use app\api\model\OrderGoods;
|
||||
use app\common\model\AccountLog;
|
||||
use app\common\model\DistributionOrder;
|
||||
use think\Db;
|
||||
use think\helper\Time;
|
||||
|
||||
class AccountLogLogic{
|
||||
public static function lists($get){
|
||||
$source_type = '';
|
||||
$where = [];
|
||||
switch ($get['type']){//记录类型
|
||||
case 1://余额变动
|
||||
$source_type = AccountLog::money_change;
|
||||
break;
|
||||
case 2://积分变动
|
||||
$source_type = AccountLog::integral_change;
|
||||
break;
|
||||
case 3://成长值变动
|
||||
$source_type = AccountLog::growth_change;
|
||||
}
|
||||
if(isset($get['order_source']) && $get['order_source']){
|
||||
$source_type = $get['order_source'];
|
||||
}
|
||||
$where[] = ['source_type','in',$source_type];
|
||||
if(isset($get['change_type']) && $get['change_type']){
|
||||
$where[] = ['source_type','=',$get['change_type']];
|
||||
}
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['keyword_type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where[] = ['a.create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
}
|
||||
|
||||
if(isset($get['create_end']) && $get['create_end']!=''){
|
||||
$where[] = ['ro.create_time','<=',strtotime($get['create_end'])];
|
||||
}
|
||||
|
||||
$count = Db::name('account_log')->alias('a')
|
||||
->join('user u','a.user_id = u.id')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$list = Db::name('account_log')->alias('a')
|
||||
->join('user u','a.user_id = u.id')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('a.id desc')
|
||||
->field('a.*,nickname,sn,mobile,pay')
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
$item['source_type_desc'] = AccountLog::getAcccountDesc($item['source_type']);
|
||||
|
||||
// 获取来源单号
|
||||
$item['order_sn'] = Db::name('order')->where(['del'=>0, 'id'=>$item['source_id']])->value('order_sn');
|
||||
// if($get['type']==2){
|
||||
// if($item['pay']==0){
|
||||
// if($item['create_time']>1735660800){
|
||||
// $user=Db::name('user')->where('id',$item['user_id'])->find();
|
||||
// Db::name('user')->where('id',$item['user_id'])->update(['user_integral'=>$user['user_integral']+$item['change_amount']]);
|
||||
// Db::name('account_log')->where('id',$item['id'])->update(['pay'=>1]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||
}
|
||||
return ['count'=>$count,'lists'=>$list];
|
||||
}
|
||||
|
||||
/**
|
||||
* note 每个资金记录页面的的变动类型
|
||||
* create_time 2020/11/23 9:55
|
||||
*/
|
||||
public static function orderSourceList($type){
|
||||
$list = [];
|
||||
switch ($type){
|
||||
case 1:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::balance_pay_order,
|
||||
'name' => '订单支付',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::admin_add_money.','.AccountLog::recharge_money,
|
||||
'name' => '钱包充值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::withdraw_to_balance,
|
||||
'name' => '佣金提现',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::register_add_integral,
|
||||
'name' => '关注赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::invite_add_integral,
|
||||
'name' => '邀请赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::sign_in_integral,
|
||||
'name' => '签到赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_integral,
|
||||
'name' => '充值赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_add_integral,
|
||||
'name' => '消费赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_deduction_integral,
|
||||
'name' => '订单抵扣积分',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 3:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::sign_give_growth,
|
||||
'name' => '签到赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_growth,
|
||||
'name' => '充值赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_give_growth,
|
||||
'name' => '下单赠送成长值',
|
||||
],
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
public static function getTime(){
|
||||
$today = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::today());
|
||||
$yesterday = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::yesterday());
|
||||
|
||||
$days_ago7 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(7));
|
||||
|
||||
$days_ago30 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(30, true));
|
||||
$time = [
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
'days_ago7' => $days_ago7,
|
||||
'days_ago30' => $days_ago30,
|
||||
];
|
||||
return $time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//佣金记录
|
||||
public static function getDistributionLog($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['distribution_keyword_type']) and !empty($get['distribution_keyword']) and $get['distribution_keyword']) {
|
||||
switch ($get['distribution_keyword_type']) {
|
||||
case 'order_sn':
|
||||
$order_ids = Order::field('id,order_sn')->where('order_sn', $get['distribution_keyword'])->column('id');
|
||||
$og_ids = OrderGoods::field('id,order_id')->whereIn('id', $order_ids)->column('id');
|
||||
$where[] = ['order_goods_id', 'in', $og_ids];
|
||||
break;
|
||||
case 'nickname':
|
||||
$user_ids = User::field('id,sn,nickname')->where('nickname', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'user_sn':
|
||||
$user_ids = User::field('id,sn,nickname')->where('sn', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'mobile':
|
||||
$user_ids = User::field('id,sn,mobile')->where('mobile', '=', $get['distribution_keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($get['distribution_status']) and is_numeric($get['distribution_status'])) {
|
||||
$where[] = ['d.status', '=', $get['distribution_status']];
|
||||
}
|
||||
if (!empty($get['distribution_start_time']) and $get['distribution_start_time']) {
|
||||
$where[] = ['d.create_time', '>=', strtotime($get['distribution_start_time'])];
|
||||
}
|
||||
if (!empty($get['distribution_end_time']) and $get['distribution_end_time']) {
|
||||
$where[] = ['d.create_time', '<=', strtotime($get['distribution_end_time'])];
|
||||
}
|
||||
|
||||
// 查询结果
|
||||
$count = DistributionOrder::where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->count();
|
||||
$lists = DistributionOrder::field('d.*, og.order_id')
|
||||
->where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->with('user')
|
||||
->withAttr('order', function ($value, $data) {
|
||||
return Order::field('id,order_sn,order_amount')->where(['id'=>$data['order_id']])->find();
|
||||
})
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['order'])
|
||||
->order('d.id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['status_text'] = DistributionOrder::getOrderStatus($item['status']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
}
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
|
||||
//佣金统计
|
||||
public static function withdrawTotalCount($get)
|
||||
{
|
||||
// 今天开始和结束时间戳
|
||||
list($startToday, $endToday) = Time::today();
|
||||
// 本月开始和结束时间戳
|
||||
list($startMonth, $endMonth) = Time::month();
|
||||
|
||||
if ($get['type'] == 'distribution') {
|
||||
// 获取分销佣金总计
|
||||
$distributionToday = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startToday)
|
||||
->where('create_time', '<=', $endToday)
|
||||
->sum('money');
|
||||
|
||||
$distributionMonth = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startMonth)
|
||||
->where('create_time', '<=', $endMonth)
|
||||
->sum('money');
|
||||
|
||||
$distributionTotal = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->sum('money');
|
||||
|
||||
return ['today'=>$distributionToday, 'month'=>$distributionMonth, 'total'=>$distributionTotal];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
215
application/admin/logic/ActivityAreaLogic.php
Normal file
215
application/admin/logic/ActivityAreaLogic.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class ActivityAreaLogic{
|
||||
/**
|
||||
* note 活动专区列表
|
||||
* create_time 2020/11/24 11:23
|
||||
*/
|
||||
public static function areaLists(){
|
||||
$count = Db::name('activity_area')
|
||||
->where(['del'=>0])
|
||||
->count();
|
||||
|
||||
$lists = Db::name('activity_area')
|
||||
->where(['del'=>0])
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['status_desc'] = '下架';
|
||||
$item['status'] && $item['status_desc'] = '上架';
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count'=>$count,'lists'=>$lists];
|
||||
|
||||
}
|
||||
/**
|
||||
* note 活动专区商品
|
||||
* create_time 2020/11/24 11:24
|
||||
*/
|
||||
public static function goodsLists($get){
|
||||
$where[] = ['AG.del','=',0];
|
||||
$where[] = ['AA.del','=',0];
|
||||
if(isset($get['name']) && $get['name']){
|
||||
$where[] = ['G.name','like','%'.$get['name'].'%'];
|
||||
}
|
||||
if(isset($get['activity_id']) && $get['activity_id']){
|
||||
$where[] = ['AA.id','=',$get['activity_id']];
|
||||
}
|
||||
|
||||
$count = Db::name('activity_goods')->alias('AG')
|
||||
->join('activity_area AA','AG.activity_id = AA.id')
|
||||
->join('goods G','AG.Goods_id = G.id')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
|
||||
$lists = Db::name('activity_goods')->alias('AG')
|
||||
->join('activity_area AA','AG.activity_id = AA.id')
|
||||
->join('goods G','AG.Goods_id = G.id')
|
||||
->where($where)
|
||||
->field('AG.id,AG.goods_id,AG.activity_id,AA.name,AA.status,G.id,G.name,G.image')
|
||||
->order('AG.id desc')
|
||||
->select();
|
||||
$activity_lisst = Db::name('activity_area')
|
||||
->where(['del'=>0])
|
||||
->column('name,status','id');
|
||||
foreach ($lists as &$item){
|
||||
$item['activity_name'] = '';
|
||||
$item['status_desc'] = '下架';
|
||||
|
||||
if(isset($activity_lisst[$item['activity_id']])){
|
||||
$item['activity_name'] = $activity_lisst[$item['activity_id']]['name'];
|
||||
$activity_lisst[$item['activity_id']]['status'] && $item['status_desc'] = '上架';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$count,'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取全部的活动专区
|
||||
* create_time 2020/11/24 12:01
|
||||
*/
|
||||
public static function getActivityList(){
|
||||
return Db::name('activity_area')
|
||||
->where(['del'=>0])
|
||||
->column('name','id');
|
||||
|
||||
}
|
||||
/**
|
||||
* note 添加活动专区
|
||||
* create_time 2020/11/24 12:01
|
||||
*/
|
||||
public static function addActivity($post){
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'title' => $post['title'],
|
||||
'image' => $post['image'],
|
||||
'status' => $post['status'],
|
||||
'del' => 0,
|
||||
'create_time' => time(),
|
||||
];
|
||||
return Db::name('activity_area')->insert($data);
|
||||
}
|
||||
/**
|
||||
* note 编辑活动专区
|
||||
* create_time 2020/11/24 12:02
|
||||
*/
|
||||
public static function editActivity($post){
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'title' => $post['title'],
|
||||
'image' => $post['image'],
|
||||
'status' => $post['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('activity_area')->where(['id'=>$post['id']])->update($data);
|
||||
}
|
||||
/**
|
||||
* note 删除活动专区
|
||||
* create_time 2020/11/24 12:02
|
||||
*/
|
||||
public static function delActivity($id){
|
||||
Db::name('activity_area')->where(['id'=>$id])->update(['update_time'=>time(),'del'=>1]);
|
||||
Db::name('activity_goods')->where(['activity_id'=>$id])->update(['update_time'=>time(),'del'=>1]);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取活动商品详情
|
||||
* create_time 2020/11/25 10:40
|
||||
*/
|
||||
public static function getActivity($id){
|
||||
$activity = Db::name('activity_area')->where(['id'=>$id])->find();
|
||||
$activity['image'] = UrlServer::getFileUrl($activity['image']);
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* note 添加活动商品
|
||||
* create_time 2020/11/25 10:40
|
||||
*/
|
||||
public static function addGoods($post)
|
||||
{
|
||||
return Db::name('activity_goods')->insert([
|
||||
'activity_id' => $post['activity_id'],
|
||||
'goods_id' => $post['goods_id'][0],
|
||||
'del' => 0,
|
||||
'create_time' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 编辑活动商品
|
||||
* create_time 2020/11/25 10:40
|
||||
*/
|
||||
public static function editGoods($post){
|
||||
$new = time();
|
||||
$update_data = [
|
||||
'activity_id' => $post['activity_id'],
|
||||
'update_time' => $new,
|
||||
];
|
||||
|
||||
return Db::name('activity_goods')
|
||||
->where(['id'=>$post['id'],'activity_id'=>$post['activity_id']])
|
||||
->update($update_data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* note 删除活动商品
|
||||
* create_time 2020/11/25 10:40
|
||||
*/
|
||||
public static function delGoods($goods_id,$activity_id){
|
||||
$update_data = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
return Db::name('activity_goods')->where(['del'=>0,'goods_id'=>$goods_id,'activity_id'=>$activity_id])->update($update_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 获取活动商品详情
|
||||
* create_time 2020/11/25 10:41
|
||||
*/
|
||||
public static function getActivityGoods($goods_id,$activity_id){
|
||||
$activity_list = Db::name('activity_goods')->alias('AG')
|
||||
->join('goods_item GI','AG.item_id = GI.id')
|
||||
->where(['activity_id'=>$activity_id,'AG.goods_id'=>$goods_id])
|
||||
->field('AG.*,GI.price,GI.spec_value_str,GI.image,GI.price')
|
||||
->select();
|
||||
|
||||
$goods_id = $activity_list[0]['goods_id'];
|
||||
$goods = Db::name('goods')->where(['del'=>0,'id'=>$goods_id])->field('image,name')->find();
|
||||
|
||||
foreach ($activity_list as &$item){
|
||||
$item['name'] = $goods['name'];
|
||||
if(empty($item['image'])){
|
||||
$item['image'] = $goods['image'];
|
||||
}
|
||||
}
|
||||
return $activity_list;
|
||||
}
|
||||
}
|
||||
277
application/admin/logic/AdLogic.php
Normal file
277
application/admin/logic/AdLogic.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\model\Ad;
|
||||
use app\admin\model\AdPosition;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class AdLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 广告管理列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$ad = new Ad();
|
||||
$where = [];
|
||||
$where[] = ['del', '=', 0];
|
||||
if ($get['client'] != '') {
|
||||
$where[] = ['client', '=', $get['client']];
|
||||
}
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
|
||||
if (isset($get['pid']) && $get['pid'] != '') {
|
||||
$where[] = ['pid', '=', $get['pid']];
|
||||
}
|
||||
|
||||
$ad_count = $ad
|
||||
->where($where)
|
||||
->count();
|
||||
$ad_list = $ad->where($where)
|
||||
|
||||
->select();
|
||||
|
||||
$position = AdPosition::where('del', 0)->column('id,name', 'id');
|
||||
|
||||
foreach ($ad_list as $item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
|
||||
$url = '';
|
||||
$item['client_name'] = Ad::getAdTypeDesc($item['client']);
|
||||
if (isset($position[$item['pid']])) {
|
||||
$item['position_name'] = $position[$item['pid']];
|
||||
}
|
||||
switch ($item['link_type']) {
|
||||
case 1:
|
||||
$page = Ad::getLinkPage($item['client'], $item['link']);
|
||||
$url = '商城页面:' . $page['name'];
|
||||
break;
|
||||
case 2:
|
||||
$goods = Db::name('goods g')
|
||||
->where(['g.id' => $item['link']])
|
||||
->field('g.name,min_price,max_price')
|
||||
->find();
|
||||
if ($goods) {
|
||||
$price = '¥' . $goods['max_price'];
|
||||
if ($goods['max_price'] !== $goods['min_price']) {
|
||||
$price = '¥' . $goods['min_price'] . '~' . $goods['max_price'];
|
||||
}
|
||||
$url = '商品页面:' . $goods['name'] . '价格:' . $price;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
$url = '自定义链接:' . $item['link'];
|
||||
}
|
||||
$item['link'] = $url;
|
||||
|
||||
|
||||
}
|
||||
return ['count' => $ad_count, 'list' => $ad_list];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
|
||||
$ad = new Ad();
|
||||
|
||||
$post['type'] = isset($post['type']) ? $post['type'] : 1;
|
||||
$post['status'] = isset($post['status']) ? $post['status'] : 0;
|
||||
$post['link_type'] = isset($post['link_type']) ? $post['link_type'] : '';
|
||||
$link = '';
|
||||
|
||||
switch ($post['link_type']) {
|
||||
case '1':
|
||||
$link = $post['page'];
|
||||
break;
|
||||
case '2':
|
||||
$link = $post['goods_id'];
|
||||
break;
|
||||
case '3':
|
||||
$link = $post['url'];
|
||||
break;
|
||||
}
|
||||
$time = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'client' => $post['client'],
|
||||
'pid' => $post['pid'],
|
||||
'image' => $post['image'],
|
||||
'link_type' => $post['link_type'],
|
||||
'link' => $link,
|
||||
'status' => $post['status'],
|
||||
'category_id' => $post['category_id'] ?? 0,
|
||||
'create_time' => $time,
|
||||
];
|
||||
|
||||
return $ad->allowField(true)->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
$ad = new Ad();
|
||||
$post['type'] = isset($post['type']) ? $post['type'] : 1;
|
||||
$post['status'] = isset($post['status']) ? $post['status'] : 0;
|
||||
$post['link_type'] = isset($post['link_type']) ? $post['link_type'] : '';
|
||||
$time = time();
|
||||
$link = '';
|
||||
switch ($post['link_type']) {
|
||||
case '1':
|
||||
$link = $post['page'];
|
||||
break;
|
||||
case '2':
|
||||
$link = $post['goods_id'];
|
||||
break;
|
||||
case '3':
|
||||
$link = $post['url'];
|
||||
break;
|
||||
}
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'client' => $post['client'],
|
||||
'pid' => $post['pid'],
|
||||
'image' => $post['image'],
|
||||
'link_type' => $post['link_type'],
|
||||
'link' => $link,
|
||||
'category_id' => $post['category_id'] ?? 0,
|
||||
'status' => $post['status'],
|
||||
'update_time' => $time,
|
||||
|
||||
];
|
||||
return $ad->allowField(true)->save($data, ['id' => $post['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $delData
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function del($id, $client)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('ad')->where(['client' => $client, 'del' => 0, 'id' => $id])->update($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告表信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
$ad = new Ad();
|
||||
$info = $ad::get(['id' => $id]);
|
||||
$info['goods'] = '';
|
||||
if ($info['link_type'] == 2) {
|
||||
$goods = Db::name('goods g')
|
||||
->where(['g.id' => $info['link']])
|
||||
->field('g.id, g.name, g.image, min_price, max_price')
|
||||
->find();
|
||||
$price = '¥' . $goods['max_price'];
|
||||
if ($goods['max_price'] !== $goods['min_price']) {
|
||||
$price = '¥' . $goods['min_price'] . '~' . $goods['max_price'];
|
||||
}
|
||||
$goods['price'] = $price;
|
||||
$goods['image'] = UrlServer::getFileUrl($goods['image']);
|
||||
$info['goods'] = $goods;
|
||||
}
|
||||
$info['abs_image'] = UrlServer::getFileUrl($info['image']);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告位置列表
|
||||
* @return array
|
||||
*/
|
||||
public static function infoPosition($client)
|
||||
{
|
||||
$position_list = Db::name('ad_position')
|
||||
->where(['client' => $client, 'status' => 1, 'del' => 0])
|
||||
->group('name')
|
||||
->column('id,name', 'id');
|
||||
asort($position_list);
|
||||
return $position_list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更改状态
|
||||
* @param $get
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function switchStatus($get)
|
||||
{
|
||||
$data = [
|
||||
'status' => $get['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('ad')->where(['client' => $get['client'], 'del' => 0, 'id' => $get['id']])->update($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取相应广告位置尺寸
|
||||
* @param $get
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function imgSize($get)
|
||||
{
|
||||
$img_size = Db::name('ad_position')
|
||||
->where(['id' => $get['id'], 'del' => 0])
|
||||
->field('width,height')
|
||||
->find();
|
||||
return $img_size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:筛选首页推荐分类
|
||||
* @return array|\PDOStatement|string|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @author: 2021/3/6 12:01
|
||||
*/
|
||||
public static function getGoodsCategory(){
|
||||
return Db::name('goods_category')->where(['level'=>1,'is_recommend'=>1])->field('id,name')->select();
|
||||
}
|
||||
|
||||
}
|
||||
214
application/admin/logic/AdPositionLogic.php
Normal file
214
application/admin/logic/AdPositionLogic.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\admin\model\AdPosition;
|
||||
use app\common\model\Ad;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class AdPositionLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 广告管理列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$ad_position = new AdPosition();
|
||||
$where = [];
|
||||
$where[] = ['del', '=', 0];
|
||||
|
||||
if ($get['client'] != '') {
|
||||
if ($get['client'] == 3) {
|
||||
$where[] = ['client', ['=', 3], ['=', 4], 'or'];
|
||||
} else {
|
||||
$where[] = ['client', '=', $get['client']];
|
||||
}
|
||||
}
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
|
||||
if (isset($get['attr']) && $get['attr'] != '') {
|
||||
$where[] = ['attr', '=', $get['attr']];
|
||||
}
|
||||
|
||||
$ad_position_count = $ad_position
|
||||
->where($where)
|
||||
->count();
|
||||
$ad_position_list = $ad_position
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
|
||||
foreach ($ad_position_list as $item) {
|
||||
$item['client_name'] = Ad::getAdTypeDesc($item['client']);
|
||||
|
||||
}
|
||||
return ['count' => $ad_position_count, 'list' => $ad_position_list];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function addAdPosition($post)
|
||||
{
|
||||
|
||||
$ad_position = new AdPosition();
|
||||
$post['status'] = isset($post['status']) ? $post['status'] : 0;
|
||||
|
||||
$time = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'width' => $post['width'],
|
||||
'height' => $post['height'],
|
||||
'status' => $post['status'],
|
||||
'client' => $post['client'],
|
||||
'attr' => 0,
|
||||
'create_time' => $time,
|
||||
|
||||
];
|
||||
|
||||
return $ad_position->allowField(true)->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param $post
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function editAdPosition($post)
|
||||
{
|
||||
$ad_position = new AdPosition();
|
||||
|
||||
$post['status'] = isset($post['status']) ? $post['status'] : 0;
|
||||
|
||||
|
||||
$time = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'width' => $post['width'],
|
||||
'height' => $post['height'],
|
||||
'status' => $post['status'],
|
||||
'attr' => 0,
|
||||
'update_time' => $time,
|
||||
|
||||
];
|
||||
|
||||
return $ad_position->allowField(true)->save($data, ['id' => $post['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $delData
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function del($delData, $client, $attr)
|
||||
{
|
||||
|
||||
if (is_array($attr)) {
|
||||
foreach ($attr as $key => $val) {
|
||||
if ($val == 1) {
|
||||
unset($delData[$key]);
|
||||
}
|
||||
}
|
||||
} elseif ($attr == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (is_array($delData)) {
|
||||
$pid = Db::name('ad')
|
||||
->where(['client' => $client, 'pid' => $delData, 'del' => 0])
|
||||
->select();
|
||||
if (!empty($pid)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$pid = Db::name('ad')
|
||||
->where(['client' => $client, 'pid' => $delData, 'del' => 0])
|
||||
->find();
|
||||
if (!empty($pid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
$result = Db::name('ad_position')->where(['client' => $client, 'id' => $delData, 'del' => 0])->update($data);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告表信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
|
||||
$ad_position = new AdPosition();
|
||||
$info = $ad_position::get(['id' => $id]);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改状态
|
||||
* @param $get
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function switchStatus($get)
|
||||
{
|
||||
$data = [
|
||||
'status' => $get['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('ad_position')
|
||||
->where(['client' => $get['client'], 'id' => $get['id'], 'del' => 0])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
}
|
||||
170
application/admin/logic/AdminLogic.php
Normal file
170
application/admin/logic/AdminLogic.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\admin\server\LoginServer;
|
||||
use think\Db;
|
||||
|
||||
class AdminLogic
|
||||
{
|
||||
/**
|
||||
* 管理员列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$role_id_name = Db::name('role')
|
||||
->column('name', 'id');
|
||||
|
||||
$where[] = ['del', '=', 0];
|
||||
if (isset($get['role_id']) && $get['role_id']) {
|
||||
$where[] = ['role_id', '=', $get['role_id']];
|
||||
}
|
||||
if (isset($get['name']) && $get['name']) {
|
||||
$where[] = ['name', 'like', "%{$get['name']}%"];
|
||||
}
|
||||
if (isset($get['account']) && $get['account']) {
|
||||
$where[] = ['account', 'like', "%{$get['account']}%"];
|
||||
}
|
||||
|
||||
$admin_count = Db::name('admin')
|
||||
->where($where)
|
||||
->count();
|
||||
$admin_lists = Db::name('admin')
|
||||
->where($where)
|
||||
->field(['id', 'root', 'name', 'account', 'role_id', 'create_time', 'login_time', 'login_ip', 'disable'])
|
||||
->select();
|
||||
foreach ($admin_lists as $k => $v) {
|
||||
if ($v['root'] == 1) {
|
||||
$admin_lists[$k]['role'] = '超级管理员';
|
||||
} else {
|
||||
$admin_lists[$k]['role'] = $role_id_name[$v['role_id']];
|
||||
}
|
||||
$admin_lists[$k]['create_time_str'] = date('Y-m-d H:i:s', $v['create_time']);
|
||||
$admin_lists[$k]['login_time'] = empty($v['login_time']) ? '' : date('Y-m-d H:i:s', $v['login_time']);
|
||||
$admin_lists[$k]['login_state'] = LoginServer::isLogin($v['id']) ? 1 : 0;
|
||||
}
|
||||
return ['count' => $admin_count, 'lists' => $admin_lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员信息
|
||||
* @param $admin_id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function info($admin_id)
|
||||
{
|
||||
return Db::name('admin')->where(['id' => $admin_id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
* @return array|\PDOStatement|string|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function roleLists()
|
||||
{
|
||||
return Db::name('role')
|
||||
->where(['del' => 0])
|
||||
->field(['id', 'name'])
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加管理员
|
||||
* @param $post
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addAdmin($post)
|
||||
{
|
||||
$time = time();
|
||||
$salt = substr(md5($time . $post['name']), 0, 4);//随机4位密码盐
|
||||
$password = create_password($post['password'], $salt);//生成密码
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'root' => 0,
|
||||
'account' => $post['account'],
|
||||
'password' => $password,
|
||||
'salt' => $salt,
|
||||
'phone' => $post['phone'],
|
||||
'bank' => $post['bank'],
|
||||
'accountyh' => $post['accountyh'],
|
||||
'role_id' => $post['role_id'],
|
||||
'create_time' => $time,
|
||||
'disable' => $post['disable']
|
||||
];
|
||||
return Db::name('admin')->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑管理员
|
||||
* @param $post
|
||||
* @return mixed
|
||||
*/
|
||||
public static function editAdmin($post)
|
||||
{
|
||||
$time = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'account' => $post['account'],
|
||||
'role_id' => $post['role_id'],
|
||||
'update_time' => $time,
|
||||
'phone' => $post['phone'],
|
||||
'bank' => $post['bank'],
|
||||
'accountyh' => $post['accountyh'],
|
||||
'user_id' => $post['user_id'],
|
||||
'disable' => $post['disable']
|
||||
|
||||
];
|
||||
|
||||
if ($post['password']) {
|
||||
$salt = Db::name('admin')->where(['id' => $post['id']])->value('salt');
|
||||
$data['password'] = create_password($post['password'], $salt);//生成密码
|
||||
}
|
||||
|
||||
$role_id = Db::name('admin')->where(['id' => $post['id']])->value('role_id');
|
||||
if ($post['disable'] == 1 || $role_id != $post['role_id']) {
|
||||
//禁用管理员并强制下线
|
||||
LoginServer::setState($post['id'], false);
|
||||
}
|
||||
|
||||
return Db::name('admin')->where(['id' => $post['id']])->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
* @param $admin_id
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function delAdmin($admin_id)
|
||||
{
|
||||
$time = time();
|
||||
return Db::name('admin')
|
||||
->where(['id' => $admin_id, 'del' => 0])
|
||||
->update(['account' => $time . '_' . $admin_id, 'del' => 1]);
|
||||
}
|
||||
/**
|
||||
* 客户归属列表
|
||||
* @param $admin_id
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function useradmin(){
|
||||
return Db::name('admin')->select();
|
||||
}
|
||||
|
||||
}
|
||||
945
application/admin/logic/AdminorderLogic.php
Normal file
945
application/admin/logic/AdminorderLogic.php
Normal file
@@ -0,0 +1,945 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\logic\OrderRefundLogic;
|
||||
use app\common\model\MessageScene_;
|
||||
use app\common\model\NoticeSetting;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\OrderLog;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\model\Pay;
|
||||
use app\common\model\UserLevel;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\YlyPrinter;
|
||||
use expressage\Kd100;
|
||||
use expressage\Kdniao;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Env;
|
||||
use think\facade\Hook;
|
||||
|
||||
class AdminorderLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 列表查询条件
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function getListsCondition($get)
|
||||
{
|
||||
$where = [];
|
||||
|
||||
$where[] = ['o.admin_id','=',session('admin_info.id')];
|
||||
|
||||
//订单状态
|
||||
if ($get['type'] != '') {
|
||||
$where[] = ['o.pay_status', '=', $get['type']];
|
||||
}
|
||||
//订单编号查询
|
||||
if (isset($get['order_sn']) && $get['order_sn'] != '') {
|
||||
$where[] = ['o.order_sn', 'like', '%' . $get['order_sn'] . '%'];
|
||||
}
|
||||
//客户姓名查询
|
||||
if (isset($get['name']) && $get['name'] != '') {
|
||||
$where[] = ['o.consignee', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//客户的电话查询
|
||||
if (isset($get['mobile']) && $get['mobile'] != '') {
|
||||
$where[] = ['o.mobile', 'like', '%' . $get['mobile'] . '%'];
|
||||
}
|
||||
//商品名称
|
||||
if (isset($get['goods_name']) && $get['goods_name'] != '') {
|
||||
$where[] = ['o.goods_name', 'like', '%' . $get['goods_name'] . '%'];
|
||||
}
|
||||
|
||||
//商品名称
|
||||
if (isset($get['goods_id']) && $get['goods_id'] != '') {
|
||||
$where[] = ['o.goods_id', '=', $get['goods_id']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['order_ysck']) && $get['order_ysck'] != '') {
|
||||
$where[] = ['o.order_ysck', '=', $get['order_ysck']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['channel_id']) && $get['channel_id'] != '') {
|
||||
$where[] = ['o.channel_id', '=', $get['channel_id']];
|
||||
}
|
||||
|
||||
|
||||
//付款方式
|
||||
if (isset($get['pay_way']) && $get['pay_way'] != '') {
|
||||
$where[] = ['o.pay_way', '=', $get['pay_way']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['admin_id']) && $get['admin_id'] != '') {
|
||||
$where[] = ['o.admin_id', '=', $get['admin_id']];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//配送方式
|
||||
if (isset($get['delivery_type']) && $get['delivery_type'] != '') {
|
||||
$where[] = ['o.delivery_type', '=', $get['delivery_type']];
|
||||
}
|
||||
|
||||
//订单类型
|
||||
if (isset($get['order_type']) && $get['order_type'] != '') {
|
||||
$where[] = ['o.admin_id', '=', NULL];
|
||||
}
|
||||
|
||||
//订单来源
|
||||
if (isset($get['order_source']) && $get['order_source'] != '') {
|
||||
$where[] = ['o.order_source', '=', $get['order_source']];
|
||||
}
|
||||
|
||||
//下单时间
|
||||
if (isset($get['start_time']) && $get['start_time'] != '') {
|
||||
$where[] = ['o.create_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
if (isset($get['end_time']) && $get['end_time'] != '') {
|
||||
$where[] = ['o.create_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 日式保洁订单
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function cleaning($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 1)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 收纳整理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function storage($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 2)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 2)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 深度清洗
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function depth($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 4)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 4)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 宠物保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function pet($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 5)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 5)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 宠物保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function cooking($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 3)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 3)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 粗开荒保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function thick($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 6)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 6)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 细开荒保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function fine($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 7)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',7)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 搬家货运
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function move($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 8)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',8)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 搬家货运
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function detection($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 9)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',9)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 空气治理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function governance($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 10)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',10)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 空气治理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function wash($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 11)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',11)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 清洗
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function linen($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 13)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',13)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 宠物保洁订单
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function pets($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 14)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',14)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
}
|
||||
448
application/admin/logic/AfterSaleLogic.php
Normal file
448
application/admin/logic/AfterSaleLogic.php
Normal file
@@ -0,0 +1,448 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\api\logic\DistributionLogic;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\logic\OrderRefundLogic;
|
||||
use app\common\server\AreaServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\common\logic\AfterSaleLogLogic;
|
||||
use app\common\logic\PaymentLogic;
|
||||
use app\common\model\{AccountLog, AfterSale, AfterSaleLog, Goods, MessageScene_, NoticeSetting, Order, OrderGoods, Pay};
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\facade\Env;
|
||||
use think\facade\Hook;
|
||||
|
||||
class AfterSaleLogic
|
||||
{
|
||||
/**
|
||||
* Notes: 列表
|
||||
* @param $get
|
||||
* @author 段誉(2021/1/30 16:56)
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$after_sale = new AfterSale();
|
||||
$where = [];
|
||||
|
||||
$where[] = ['a.del', '=', 0];
|
||||
//订单类型
|
||||
if (isset($get['type']) && $get['type'] != '') {
|
||||
$where[] = ['a.status', '=', $get['type']];
|
||||
}
|
||||
|
||||
//订单搜素
|
||||
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
||||
$keyword = $get['keyword'];
|
||||
switch ($get['search_key']) {
|
||||
case 'sn':
|
||||
$where[] = ['a.sn', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
case 'order_sn':
|
||||
$where[] = ['o.order_sn', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
case 'goods_name':
|
||||
$where[] = ['g.goods_name', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
case 'user_sn':
|
||||
$where[] = ['u.sn', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
case 'nickname':
|
||||
$where[] = ['u.nickname', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
case 'user_mobile':
|
||||
$where[] = ['u.mobile', 'like', '%' . $keyword . '%'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($get['status']) && $get['status'] != '') {
|
||||
$where[] = ['a.status', '=', $get['status']];
|
||||
}
|
||||
|
||||
//下单时间
|
||||
if (isset($get['start_time']) && $get['start_time'] != '') {
|
||||
$where[] = ['a.create_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
if (isset($get['end_time']) && $get['end_time'] != '') {
|
||||
$where[] = ['a.create_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$field = 'a.id,a.sn,a.status,a.order_id,a.order_goods_id,
|
||||
a.user_id,a.refund_type,a.create_time,a.refund_price,
|
||||
o.order_status,o.pay_way';
|
||||
|
||||
$count = $after_sale
|
||||
->alias('a')
|
||||
->join('order o', 'o.id = a.order_id')
|
||||
->join('user u', 'u.id = a.user_id')
|
||||
->join('order_goods g', 'g.id = a.order_goods_id')
|
||||
->with(['order_goods', 'user', 'order'])
|
||||
->where($where)
|
||||
->group('a.id')
|
||||
->count();
|
||||
|
||||
$lists = $after_sale
|
||||
->alias('a')
|
||||
->field($field)
|
||||
->join('order o', 'o.id = a.order_id')
|
||||
->join('user u', 'u.id = a.user_id')
|
||||
->join('order_goods g', 'g.id = a.order_goods_id')
|
||||
->with(['order_goods', 'user', 'order'])
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('a.id desc')
|
||||
->append(['user.base_avatar', 'order_goods.base_image'])
|
||||
->group('a.id')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$list) {
|
||||
$list['order']['pay_way'] = Pay::getPayWay($list['order']['pay_way']);
|
||||
$list['order']['order_status'] = Order::getOrderStatus($list['order']['order_status']);
|
||||
$list['refund_type'] = AfterSale::getRefundTypeDesc($list['refund_type']);
|
||||
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
|
||||
$list['status'] = AfterSale::getStatusDesc($list['status']);
|
||||
|
||||
foreach ($list['order_goods'] as &$good) {
|
||||
$info = json_decode($good['goods_info'], true);
|
||||
$good['goods_name'] = $info['goods_name'];
|
||||
$good['spec_value'] = $info['spec_value_str'];
|
||||
$good['image'] = empty($info['spec_image']) ?
|
||||
UrlServer::getFileUrl($info['image']) : UrlServer::getFileUrl($info['spec_image']);
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 详情
|
||||
* @param $id
|
||||
* @author 段誉(2021/1/30 16:56)
|
||||
* @return array
|
||||
*/
|
||||
public static function getDetail($id)
|
||||
{
|
||||
$after_sale = new AfterSale();
|
||||
$result = $after_sale
|
||||
->with(['order_goods', 'user', 'order', 'logs'])
|
||||
->where('id', $id)
|
||||
->find()->toArray();
|
||||
|
||||
$result['refund_type_text'] = AfterSale::getRefundTypeDesc($result['refund_type']);
|
||||
$result['status_text'] = AfterSale::getStatusDesc($result['status']);
|
||||
$result['order']['pay_way'] = Pay::getPayWay($result['order']['pay_way']);
|
||||
$result['order']['order_status'] = Order::getOrderStatus($result['order']['order_status']);
|
||||
$result['create_time'] = date('Y-m-d H:i:s', $result['create_time']);
|
||||
|
||||
foreach ($result['order_goods'] as &$good) {
|
||||
$info = json_decode($good['goods_info'], true);
|
||||
$good['goods_name'] = $info['goods_name'];
|
||||
$good['spec_value'] = $info['spec_value_str'];
|
||||
$good['image'] = empty($info['spec_image']) ?
|
||||
UrlServer::getFileUrl($info['image']) : UrlServer::getFileUrl($info['spec_image']);
|
||||
}
|
||||
|
||||
foreach ($result['order_goods'] as &$good) {
|
||||
$info = json_decode($good['goods_info'], true);
|
||||
$good['goods_name'] = $info['goods_name'];
|
||||
$good['spec_value'] = $info['spec_value_str'];
|
||||
$good['image'] = empty($info['spec_image']) ?
|
||||
UrlServer::getFileUrl($info['image']) : UrlServer::getFileUrl($info['spec_image']);
|
||||
}
|
||||
|
||||
foreach ($result['logs'] as &$log){
|
||||
$log['create_time'] = date('Y-m-d H:i:s', $log['create_time']);
|
||||
|
||||
$log['log_img'] = '';
|
||||
$log['log_remark'] = '';
|
||||
switch ($log['channel']){
|
||||
//会员申请售后
|
||||
case AfterSaleLog::USER_APPLY_REFUND:
|
||||
$log['log_img'] = empty($result['refund_image']) ? '' : UrlServer::getFileUrl($result['refund_image']);
|
||||
$refund_reason = empty($result['refund_reason']) ? '未知' : $result['refund_reason'];
|
||||
$refund_remark = empty($result['refund_remark']) ? '暂无' : $result['refund_remark'];
|
||||
$log['log_remark'] = '退款原因('.$refund_reason.')'.'退款说明('.$refund_remark.')';
|
||||
break;
|
||||
//会员发快递
|
||||
case AfterSaleLog::USER_SEND_EXPRESS:
|
||||
$log['log_img'] = empty($result['express_image']) ? '' : UrlServer::getFileUrl($result['express_image']);
|
||||
$express_name = $result['express_name'];
|
||||
$invoice_no = $result['invoice_no'];
|
||||
$express_remark = empty($result['express_remark']) ? '暂无' : $result['express_remark'];
|
||||
$log['log_remark'] = '快递公司('.$express_name.')'.'单号('.$invoice_no.')'.'备注说明('.$express_remark.')';
|
||||
break;
|
||||
//商家拒绝退款 //商家拒绝收货
|
||||
case AfterSaleLog::SHOP_REFUSE_REFUND:
|
||||
case AfterSaleLog::SHOP_REFUSE_TAKE_GOODS:
|
||||
$admin_remark = empty($result['admin_remark']) ? '暂无' : $result['admin_remark'];
|
||||
$log['log_remark'] = '备注:'.$admin_remark;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result['shop_address'] = self::getShopAddress();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商家同意售后
|
||||
* @param $id
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/30 16:56)
|
||||
*/
|
||||
public static function agree($id, $admin_id)
|
||||
{
|
||||
$after_sale = AfterSale::get($id);
|
||||
|
||||
$after_sale->update_time = time();
|
||||
//仅退款
|
||||
if ($after_sale['refund_type'] == AfterSale::TYPE_ONLY_REFUND) {
|
||||
$after_sale->status = AfterSale::STATUS_WAIT_REFUND;//更新为等待退款状态
|
||||
}
|
||||
|
||||
//退款退货
|
||||
if ($after_sale['refund_type'] == AfterSale::TYPE_REFUND_RETURN) {
|
||||
$after_sale->status = AfterSale::STATUS_WAIT_RETURN_GOODS;//更新为商品待退货状态
|
||||
}
|
||||
|
||||
$after_sale->save();
|
||||
//记录日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::SHOP_AGREE_REFUND,
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::SHOP_AGREE_REFUND
|
||||
);
|
||||
|
||||
// 仅退款;更新订单商品为等待退款
|
||||
if ($after_sale['refund_type'] == AfterSale::TYPE_ONLY_REFUND) {
|
||||
$order_goods = OrderGoods::get(['id' => $after_sale['order_goods_id']]);
|
||||
$order_goods->refund_status = OrderGoods::REFUND_STATUS_WAIT;//等待退款
|
||||
$order_goods->save();
|
||||
}
|
||||
|
||||
$mobile = Db::name('order')->where(['id'=>$after_sale->order_id])->value('mobile');
|
||||
//发送短信
|
||||
$nickname = Db::name('user')->where(['id' => $after_sale->user_id])->value('nickname');
|
||||
Hook::listen('sms_send', [
|
||||
'key' => NoticeSetting::PLATFORM_PASS_REFUND_NOTICE,
|
||||
'mobile' => $mobile,
|
||||
'user_id' => $after_sale['user_id'],
|
||||
'params' => ['nickname' => $nickname, 'order_sn' => $after_sale->sn],
|
||||
]);
|
||||
|
||||
//消息通知
|
||||
Hook::listen('notice', [
|
||||
'user_id' => $after_sale['user_id'],
|
||||
'order_id' => $after_sale['order_id'],
|
||||
'refund_amount' => $after_sale['refund_price'],
|
||||
'scene' => NoticeSetting::PLATFORM_PASS_REFUND_NOTICE,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商家拒绝
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/30 16:56)
|
||||
*/
|
||||
public static function refuse($post, $admin_id)
|
||||
{
|
||||
$id = $post['id'];
|
||||
$after_sale = AfterSale::get($id);
|
||||
$after_sale->update_time = time();
|
||||
$after_sale->status = AfterSale::STATUS_REFUSE_REFUND;//更新为拒绝退款状态
|
||||
$after_sale->admin_remark = isset($post['remark']) ? $post['remark'] : '';
|
||||
$after_sale->save();
|
||||
//记录日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::SHOP_REFUSE_REFUND,
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::SHOP_REFUSE_REFUND
|
||||
);
|
||||
$nickname = Db::name('user')->where(['id' => $after_sale->user_id])->value('nickname');
|
||||
$mobile = Db::name('order')->where(['id'=>$after_sale->order_id])->value('mobile');
|
||||
//发送短信
|
||||
Hook::listen('sms_send', [
|
||||
'key' => NoticeSetting::PLATFORM_REFUSE_REFUND_NOTICE,
|
||||
'mobile' => $mobile,
|
||||
'user_id' => $after_sale['user_id'],
|
||||
'params' => ['nickname' => $nickname, 'order_sn' => $after_sale->sn],
|
||||
]);
|
||||
|
||||
//消息通知
|
||||
Hook::listen('notice', [
|
||||
'user_id' => $after_sale['user_id'],
|
||||
'order_id' => $after_sale['order_id'],
|
||||
'scene' => NoticeSetting::PLATFORM_REFUSE_REFUND_NOTICE,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商家收货
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/30 16:56)
|
||||
*/
|
||||
public static function takeGoods($post, $admin_id)
|
||||
{
|
||||
$id = $post['id'];
|
||||
$after_sale = AfterSale::get($id);
|
||||
$after_sale->update_time = time();
|
||||
$after_sale->status = AfterSale::STATUS_WAIT_REFUND;//更新为等待退款状态
|
||||
$after_sale->save();
|
||||
//记录日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::SHOP_TAKE_GOODS,
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::SHOP_TAKE_GOODS
|
||||
);
|
||||
//更新订单商品为等待退款状态
|
||||
$order_goods = OrderGoods::get(['id' => $after_sale['order_goods_id']]);
|
||||
$order_goods->refund_status = OrderGoods::REFUND_STATUS_WAIT;//等待退款
|
||||
$order_goods->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商家拒绝收货
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/30 16:57)
|
||||
*/
|
||||
public static function refuseGoods($post, $admin_id)
|
||||
{
|
||||
$id = $post['id'];
|
||||
$after_sale = AfterSale::get($id);
|
||||
$after_sale->update_time = time();
|
||||
$after_sale->status = AfterSale::STATUS_REFUSE_RECEIVE_GOODS;//更新为拒绝收货状态
|
||||
$after_sale->admin_remark = isset($post['remark']) ? $post['remark'] : '';
|
||||
$after_sale->save();
|
||||
//记录日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::SHOP_REFUSE_TAKE_GOODS,
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::SHOP_REFUSE_TAKE_GOODS
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 确认退款 ===> 退款
|
||||
* @param $id
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/30 16:57)
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function confirm($id, $admin_id)
|
||||
{
|
||||
//售后记录状态
|
||||
$after_sale = AfterSale::get($id);
|
||||
$order = Order::get(['id' => $after_sale['order_id']]);
|
||||
$order_goods = OrderGoods::get(['id' => $after_sale['order_goods_id']]);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//更新售后为退款成功状态
|
||||
$after_sale->update_time = time();
|
||||
$after_sale->status = AfterSale::STATUS_SUCCESS_REFUND;
|
||||
$after_sale->save();
|
||||
//售后日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::REFUND_SUCCESS,
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::REFUND_SUCCESS
|
||||
);
|
||||
//更新订单和订单商品状态
|
||||
OrderRefundLogic::afterSaleRefundUpdate($order, $order_goods['id'], $admin_id);
|
||||
//订单退款
|
||||
OrderRefundLogic::refund($order, $order['order_amount'], $after_sale['refund_price']);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
//增加退款失败记录
|
||||
OrderRefundLogic::addErrorRefund($order, $e->getMessage());
|
||||
//记录日志
|
||||
AfterSaleLogLogic::record(
|
||||
AfterSaleLog::TYPE_SHOP,
|
||||
AfterSaleLog::REFUND_ERROR,//退款失败
|
||||
$after_sale['order_id'],
|
||||
$after_sale['id'],
|
||||
$admin_id,
|
||||
AfterSaleLog::REFUND_ERROR,//退款失败
|
||||
$e->getMessage()
|
||||
);
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 获取商家地址
|
||||
* @author 段誉(2021/1/30 16:57)
|
||||
* @return string
|
||||
*/
|
||||
public static function getShopAddress()
|
||||
{
|
||||
$shop_province = ConfigServer::get('shop', 'province_id', '');
|
||||
$shop_city = ConfigServer::get('shop', 'city_id', '');
|
||||
$shop_district = ConfigServer::get('shop', 'district_id', '');
|
||||
$shop_address = ConfigServer::get('shop', 'address', '');
|
||||
$shop_contact = ConfigServer::get('shop', 'contact', '');
|
||||
$shop_mobile = ConfigServer::get('shop', 'mobile', '');
|
||||
$shop_address = AreaServer::getAddress([$shop_province, $shop_city, $shop_district], $shop_address);
|
||||
return $shop_address.'('.$shop_contact.','.$shop_mobile.')';
|
||||
}
|
||||
|
||||
}
|
||||
117
application/admin/logic/ArticleCategoryLogic.php
Normal file
117
application/admin/logic/ArticleCategoryLogic.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\ArticleCategory;
|
||||
use think\Db;
|
||||
|
||||
class ArticleCategoryLogic
|
||||
{
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
|
||||
$article_category = new ArticleCategory();
|
||||
$count = $article_category->where($where)->count();
|
||||
$list = $article_category->where($where)->page($get['page'], $get['limit'])->select();
|
||||
|
||||
foreach ($list as &$item) {
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
if ($item['is_show'] == 1) {
|
||||
$item['is_show_text'] = '启用';
|
||||
} else {
|
||||
$item['is_show_text'] = '停用';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $list];
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 添加文章分类
|
||||
* @param $post array 文章分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function addArticleCategory($post)
|
||||
{
|
||||
$article_category = new ArticleCategory();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'is_show' => $post['is_show'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
return $article_category->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 编辑文章分类
|
||||
* @param $post array 文章分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function editArticleCategory($post)
|
||||
{
|
||||
$article_category = new ArticleCategory();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return $article_category->save($data, ['id' => $post['id'], 'del' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 删除文章分类
|
||||
* @param $id int 文章分类id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delArticleCategory($id)
|
||||
{
|
||||
$article_category = new ArticleCategory();
|
||||
$data = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
return $article_category->save($data, ['id' => $id, 'del' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 获取单条文章分类
|
||||
* @param $id int 文章分类id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getArticleCategory($id = 0)
|
||||
{
|
||||
$where[] = ['del', '=', 0];
|
||||
if ($id) {
|
||||
$where[] = ['id', '=', $id];
|
||||
}
|
||||
$article_category = new ArticleCategory();
|
||||
return $article_category->where($where)->column('*', 'id');
|
||||
}
|
||||
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
$data = [
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('article_category')->where(['del' => 0, 'id' => $post['id']])->update($data);
|
||||
}
|
||||
}
|
||||
137
application/admin/logic/ArticleLogic.php
Normal file
137
application/admin/logic/ArticleLogic.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\Article;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class ArticleLogic
|
||||
{
|
||||
|
||||
public static function lists($get, $category)
|
||||
{
|
||||
$article = Db::name('article');
|
||||
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
if (isset($get['is_notice']) && $get['is_notice'] != '') {
|
||||
$where[] = ['is_notice', '=', $get['is_notice']];
|
||||
}
|
||||
|
||||
if (isset($get['title']) && $get['title']) {
|
||||
$where[] = ['title', 'like', '%' . $get['title'] . '%'];
|
||||
}
|
||||
|
||||
if (isset($get['cid']) && $get['cid']) {
|
||||
$where[] = ['cid', '=', $get['cid']];
|
||||
}
|
||||
|
||||
|
||||
$count = $article->where($where)->count();
|
||||
$list = $article->where($where)->page($get['page'], $get['limit'])->order('id desc')->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
if (isset($category[$item['cid']])) {
|
||||
$item['cat_name'] = $category[$item['cid']]['name'];
|
||||
}
|
||||
if ($item['is_show'] == 1) {
|
||||
$item['is_show_text'] = '显示';
|
||||
} else {
|
||||
$item['is_show_text'] = '隐藏';
|
||||
}
|
||||
|
||||
if ($item['is_notice'] == 1) {
|
||||
$item['is_notice'] = '是';
|
||||
|
||||
} else if ($item['is_notice'] == 0) {
|
||||
$item['is_notice'] = '否';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $list];
|
||||
}
|
||||
|
||||
|
||||
public static function addArticle($post)
|
||||
{
|
||||
$article = new Article();
|
||||
|
||||
$data = [
|
||||
'title' => $post['title'],
|
||||
'cid' => $post['cid'],
|
||||
'image' => $post['image'],
|
||||
'content' => $post['content'],
|
||||
'is_show' => $post['is_show'],
|
||||
'is_notice' => $post['is_notice'],
|
||||
'create_time' => time(),
|
||||
'sort' => $post['sort'],
|
||||
'synopsis' => $post['synopsis']
|
||||
];
|
||||
return $article->save($data);
|
||||
}
|
||||
|
||||
public static function editArticle($post)
|
||||
{
|
||||
$article = new Article();
|
||||
$data = [
|
||||
'title' => $post['title'],
|
||||
'cid' => $post['cid'],
|
||||
'image' => $post['image'],
|
||||
'content' => $post['content'],
|
||||
'is_show' => $post['is_show'],
|
||||
'is_notice' => $post['is_notice'],
|
||||
'update_time' => time(),
|
||||
'sort' => $post['sort'],
|
||||
'synopsis' => $post['synopsis']
|
||||
|
||||
];
|
||||
return $article->save($data, ['id' => $post['id'], 'del' => 0]);
|
||||
}
|
||||
|
||||
public static function getArticle($id)
|
||||
{
|
||||
$article = new Article();
|
||||
$detail = $article::get(['id' => $id, 'del' => 0]);
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
public static function delArticle($id)
|
||||
{
|
||||
$article = new Article();
|
||||
|
||||
$data = [
|
||||
'del' => time(),
|
||||
'update_time' => 1
|
||||
];
|
||||
return $article->save($data, ['id' => $id, 'del' => 0]);
|
||||
}
|
||||
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
$data = [
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('article')->where(['del' => 0, 'id' => $post['id']])->update($data);
|
||||
}
|
||||
|
||||
}
|
||||
333
application/admin/logic/AuthLogic.php
Normal file
333
application/admin/logic/AuthLogic.php
Normal file
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class AuthLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
$lists = Db::name('dev_auth')
|
||||
->where(['del' => 0])
|
||||
->field(['id', 'type', 'system', 'pid', 'name', 'sort', 'icon', 'uri', 'disable'])
|
||||
->order(['sort' => 'desc', 'type' => 'asc'])
|
||||
->select();
|
||||
$pids = Db::name('dev_auth')
|
||||
->where(['del'=>0,'type'=>1])
|
||||
->column('pid');
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['type_str'] = $v['type'] == 1 ? '菜单' : '权限';
|
||||
$lists[$k]['open'] = in_array($v['id'],$pids) ? true : false;
|
||||
}
|
||||
return linear_to_tree($lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单信息
|
||||
* @param $id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('dev_auth')
|
||||
->where(['del' => 0, 'id' => $id])
|
||||
->field(['id', 'pid', 'type', 'name', 'sort', 'icon', 'uri', 'disable'])
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单选项
|
||||
* @param string $id 当前编辑菜单id(选项不包含该菜单的子菜单)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function chooseMenu($id = '')
|
||||
{
|
||||
$lists = Db::name('dev_auth')
|
||||
->field(['id', 'pid', 'name'])
|
||||
->where(['del' => 0, 'type' => 1])
|
||||
->select();
|
||||
if ($id) {
|
||||
$remove_ids = self::getChildIds($lists, $id);
|
||||
$remove_ids[] = $id;
|
||||
foreach ($lists as $key => $row) {
|
||||
if (in_array($row['id'], $remove_ids)) {
|
||||
unset($lists[$key]);
|
||||
}
|
||||
}
|
||||
$lists = array_values($lists);
|
||||
}
|
||||
return multilevel_linear_sort($lists, '|-');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子类id
|
||||
* @param $lists
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
private static function getChildIds($lists, $id)
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($lists as $key => $row) {
|
||||
if ($row['pid'] == $id) {
|
||||
$ids[] = $row['id'];
|
||||
$child_ids = self::getChildIds($lists, $row['id']);
|
||||
foreach ($child_ids as $child_id) {
|
||||
$ids[] = $child_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function addMenu($post)
|
||||
{
|
||||
if ($post['type'] == 1) {
|
||||
$level = self::getParent($post['pid']);
|
||||
if ($level >= 3) {
|
||||
return '菜单不允许超出三级';
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'pid' => $post['pid'],
|
||||
'type' => $post['type'],
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'sort' => $post['sort'],
|
||||
'uri' => $post['uri'],
|
||||
'disable' => $post['disable'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
return Db::name('dev_auth')->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查找层级
|
||||
* @param $pid
|
||||
* @author 张无忌(2021/2/6 11:08)
|
||||
* @return int
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getParent($pid)
|
||||
{
|
||||
static $count = 0;
|
||||
$auth = Db::name('dev_auth')->where(['id' => $pid])->find();
|
||||
if ($auth) {
|
||||
$count += 1;
|
||||
if ($count < 3) {
|
||||
self::getParent($auth['pid']);
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function updateMenu($post)
|
||||
{
|
||||
if ($post['type'] == 1) {
|
||||
$level = self::getParent($post['pid']);
|
||||
if ($level >= 3) {
|
||||
return '菜单不允许超出三级';
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'pid' => $post['pid'],
|
||||
'type' => $post['type'],
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'sort' => $post['sort'],
|
||||
'uri' => $post['uri'],
|
||||
'disable' => $post['disable'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('dev_auth')
|
||||
->where(['id' => $post['id'], 'system' => 0])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置菜单状态
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function setStatus($post)
|
||||
{
|
||||
$data = [
|
||||
'disable' => $post['disable'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('dev_auth')
|
||||
->where(['id' => $post['id'], 'system' => 0])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
* @param $ids
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function delMenu($ids)
|
||||
{
|
||||
$lists = Db::name('dev_auth')
|
||||
->where(['del' => 0])
|
||||
->field(['id', 'pid', 'name', 'sort', 'icon', 'disable'])
|
||||
->select();
|
||||
$del_ids = $ids;
|
||||
foreach ($ids as $id) {
|
||||
$temp = self::getChildIds($lists, $id);
|
||||
$del_ids = array_merge($del_ids, $temp);
|
||||
}
|
||||
return Db::name('dev_auth')
|
||||
->where('id', 'in', $del_ids)
|
||||
->where(['del' => 0, 'system' => 0])
|
||||
->update(['del' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取到员工的权限
|
||||
* @param $ids
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function stafflists(){
|
||||
$lists = Db::name('dev_staffauth')
|
||||
->where(['del' => 0])
|
||||
|
||||
->order(['sort' => 'desc', 'type' => 'asc'])
|
||||
->select();
|
||||
$pids = Db::name('dev_staffauth')
|
||||
->where(['del'=>0,'type'=>1])
|
||||
->column('pid');
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['type_str'] = $v['type'] == 1 ? '菜单' : '权限';
|
||||
$lists[$k]['open'] = in_array($v['id'],$pids) ? true : false;
|
||||
}
|
||||
return linear_to_tree($lists);
|
||||
}
|
||||
/**
|
||||
* 获取菜单选项
|
||||
* @param string $id 当前编辑菜单id(选项不包含该菜单的子菜单)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function staffchooseMenu($id = '')
|
||||
{
|
||||
$lists = Db::name('dev_staffauth')
|
||||
->field(['id', 'pid', 'name'])
|
||||
->where(['del' => 0, 'type' => 1])
|
||||
->select();
|
||||
if ($id) {
|
||||
$remove_ids = self::getChildIds($lists, $id);
|
||||
$remove_ids[] = $id;
|
||||
foreach ($lists as $key => $row) {
|
||||
if (in_array($row['id'], $remove_ids)) {
|
||||
unset($lists[$key]);
|
||||
}
|
||||
}
|
||||
$lists = array_values($lists);
|
||||
}
|
||||
return multilevel_linear_sort($lists, '|-');
|
||||
}
|
||||
/**
|
||||
* 创建功能
|
||||
* @param string $id 当前编辑菜单id(选项不包含该菜单的子菜单)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
|
||||
public static function add_staffauth($post){
|
||||
$data = [
|
||||
'pid' => $post['pid'],
|
||||
'type' => $post['type'],
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'sort' => $post['sort'],
|
||||
'url' => $post['uri'],
|
||||
'disable' => $post['disable'],
|
||||
'update_time' => time(),
|
||||
'create_time' =>time()
|
||||
];
|
||||
return Db::name('dev_staffauth') ->insert($data);
|
||||
}
|
||||
/**
|
||||
* 获取权限id
|
||||
* @param string $id 当前编辑菜单id(选项不包含该菜单的子菜单)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function staffauthinfo($id){
|
||||
return Db::name('dev_staffauth')
|
||||
->where(['del' => 0, 'id' => $id])
|
||||
->find();
|
||||
}
|
||||
/**
|
||||
* 编辑权限功能
|
||||
* @param string $id 当前编辑菜单id(选项不包含该菜单的子菜单)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function edit_staffauth($post){
|
||||
$data = [
|
||||
'pid' => $post['pid'],
|
||||
'type' => $post['type'],
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'sort' => $post['sort'],
|
||||
'url' => $post['url'],
|
||||
'disable' => $post['disable'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('dev_staffauth')
|
||||
->where(['id' => $post['id']])
|
||||
->update($data);
|
||||
}
|
||||
}
|
||||
533
application/admin/logic/BargainLogic.php
Normal file
533
application/admin/logic/BargainLogic.php
Normal file
@@ -0,0 +1,533 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\Bargain;
|
||||
use app\common\model\BargainItem;
|
||||
use app\common\model\BargainKnife;
|
||||
use app\common\model\BargainLaunch;
|
||||
use app\common\model\Goods as GoodsModel;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\TeamActivity as TeamActivityModel;
|
||||
use app\common\model\User;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class BargainLogic
|
||||
{
|
||||
protected static $error; //错误信息
|
||||
|
||||
/**
|
||||
* Notes: 错误错误信息
|
||||
* @author 张无忌(2021/1/12 16:01)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 砍价活动列表
|
||||
* @param $get
|
||||
* @author 张无忌(2021/2/24 11:11)
|
||||
* @return array
|
||||
*/
|
||||
public static function activity($get) {
|
||||
|
||||
$where = [
|
||||
['del', '=', 0]
|
||||
];
|
||||
|
||||
// 查询条件
|
||||
if ( !empty($get['goods_name']) and $get['goods_name'] !== '') {
|
||||
$goodsModel = new GoodsModel();
|
||||
$ids = $goodsModel->field('id,name')->where([
|
||||
['name', 'like', '%' . $get['goods_name'] . '%']
|
||||
])->column('id');
|
||||
|
||||
$where[] = ['goods_id', 'in', $ids];
|
||||
}
|
||||
|
||||
if (isset($get['status']) and is_numeric($get['status'])) {
|
||||
$where[] = ['status', '=', (int)$get['status']];
|
||||
}
|
||||
|
||||
$bargainModel = new Bargain();
|
||||
$count = $bargainModel->where($where)->count('id');
|
||||
$lists = $bargainModel->field(true)
|
||||
->where($where)
|
||||
->with(['goods'])
|
||||
->withCount(['launchPeopleNumber', 'successKnifePeopleNumber'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['goods']['image'] = UrlServer::getFileUrl($item['goods']['image']);
|
||||
$item['activity_start_time'] = date('Y-m-d H:i:s', $item['activity_start_time']);
|
||||
$item['activity_end_time'] = date('Y-m-d H:i:s', $item['activity_end_time']);
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取砍价活动详细
|
||||
* @param $id
|
||||
* @author 张无忌(2021/2/24 11:11)
|
||||
* @return Bargain
|
||||
*/
|
||||
public static function getDetail($id)
|
||||
{
|
||||
$bargainModel = new Bargain();
|
||||
$bargainItemModel = new BargainItem();
|
||||
|
||||
$detail = $bargainModel->field(true)
|
||||
->where(['id'=>(int)$id])
|
||||
->with(['goods'])
|
||||
->find();
|
||||
|
||||
$goodItem = $bargainItemModel->field('t.*,gi.id as spec_item_id,
|
||||
gi.spec_value_str, gi.price as spec_item_price, gi.stock')
|
||||
->where(['bargain_id'=>(int)$id])
|
||||
->alias('t')
|
||||
->rightJoin('goods_item gi', 'gi.id = t.item_id')
|
||||
->select();
|
||||
|
||||
$detail['min_knife_price'] = 0;
|
||||
$detail['max_knife_price'] = 0;
|
||||
$detail['fixed_knife_price'] = 0;
|
||||
if ($detail['knife_type'] == 1) {
|
||||
$knife_price_arr = explode(',', $detail['knife_price']);
|
||||
$detail['min_knife_price'] = empty($knife_price_arr[0]) ? 0 : $knife_price_arr[0];
|
||||
$detail['max_knife_price'] = empty($knife_price_arr[1]) ? 0 : $knife_price_arr[1];
|
||||
} else {
|
||||
$detail['fixed_knife_price'] = $detail['knife_price'];
|
||||
}
|
||||
|
||||
// 处理判断商品规格是否已发生变化, 没变化是true, 否则false
|
||||
$detail['is_goods_item'] = true;
|
||||
foreach ($goodItem as $item) {
|
||||
if (!$item['spec_value_str'] || $item['spec_value_str'] == ''
|
||||
|| $item['spec_item_price'] == '') {
|
||||
$detail['is_goods_item'] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$detail['item'] = $goodItem;
|
||||
$detail['goods']['image'] = UrlServer::getFileUrl($detail['goods']['image']);
|
||||
$detail['activity_start_time'] = date('Y-m-d H:i:s', $detail['activity_start_time']);
|
||||
$detail['activity_end_time'] = date('Y-m-d H:i:s', $detail['activity_end_time']);
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 新增砍价活动
|
||||
* @param $post
|
||||
* @author 张无忌(2021/2/23 15:46)
|
||||
* @return bool
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 校验拼团活动是否存在
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
$team = $teamActivityModel->where([
|
||||
'goods_id' => intval($post['goods_id']),
|
||||
'del' => 0
|
||||
])->find();
|
||||
|
||||
if ($team) {
|
||||
static::$error = '商品正在参与拼团活动, 请先移除活动再添加';
|
||||
return false;
|
||||
}
|
||||
|
||||
//秒杀验证
|
||||
$seckill_goods = Db::name('seckill_goods')
|
||||
->where(['goods_id'=>intval($post['goods_id']),'del'=>0])
|
||||
->find();
|
||||
if($seckill_goods){
|
||||
static::$error = '商品正在参与秒杀活动,无法修改';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 每刀金额(随机 / 固定)
|
||||
$knife_price = 0;
|
||||
if ($post['knife_type'] == 1) {
|
||||
$knife_price = [$post['min_knife_price'], $post['max_knife_price']];
|
||||
$knife_price = implode(',', $knife_price);
|
||||
} else {
|
||||
$knife_price = $post['fixed_knife_price'];
|
||||
}
|
||||
|
||||
// 查出最大低价和最少价格
|
||||
$bargain_price = [];
|
||||
foreach ($post['floor_price'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
array_push($bargain_price, $item);
|
||||
}
|
||||
}
|
||||
$bargain_max_price = !empty($bargain_price) ? max($bargain_price) : 0;
|
||||
$bargain_min_price = !empty($bargain_price) ? min($bargain_price) : 0;
|
||||
|
||||
// 新增砍价活动
|
||||
$bargainModel = new Bargain();
|
||||
$bargain_id = $bargainModel->insertGetId([
|
||||
'goods_id' => $post['goods_id'],
|
||||
'time_limit' => $post['time_limit'],
|
||||
'activity_start_time' => strtotime($post['activity_start_time']),
|
||||
'activity_end_time' => strtotime($post['activity_end_time']),
|
||||
'bargain_min_price' => $bargain_min_price,
|
||||
'bargain_max_price' => $bargain_max_price,
|
||||
'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
|
||||
'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
|
||||
'payment_where' => $post['payment_where'],
|
||||
'knife_type' => $post['knife_type'],
|
||||
'knife_price' => $knife_price,
|
||||
'status' => $post['status'],
|
||||
'del' => 0,
|
||||
]);
|
||||
|
||||
// 新增砍价商品SKU
|
||||
$lists = [];
|
||||
foreach ($post['floor_price'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
$lists[] = [
|
||||
'bargain_id' => $bargain_id,
|
||||
'goods_id' => $key,
|
||||
'item_id' => $K,
|
||||
'floor_price' => $item,
|
||||
'first_knife_price' => $post['first_knife_price'][$key][$K]
|
||||
];
|
||||
}
|
||||
}
|
||||
if ( !empty($lists)) {
|
||||
$bargainItemModel = new BargainItem();
|
||||
$bargainItemModel->saveAll($lists);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑砍价活动
|
||||
* @param $post
|
||||
* @author 张无忌(2021/2/24 11:10)
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 查询商品信息
|
||||
$goodsModel = new GoodsModel();
|
||||
$goods = $goodsModel->field('id,name,image')
|
||||
->where(['id' => (int)$post['goods_id']])->find();
|
||||
|
||||
if (!$goods) {
|
||||
static::$error = '选择的商品已不存在,可能已被删除';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 每刀金额(随机 / 固定)
|
||||
$knife_price = 0;
|
||||
if ($post['knife_type'] == 1) {
|
||||
$knife_price = [$post['min_knife_price'], $post['max_knife_price']];
|
||||
$knife_price = implode(',', $knife_price);
|
||||
} else {
|
||||
$knife_price = $post['fixed_knife_price'];
|
||||
}
|
||||
|
||||
// 查出最大低价和最少价格
|
||||
$bargain_price = [];
|
||||
foreach ($post['floor_price'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
array_push($bargain_price, $item);
|
||||
}
|
||||
}
|
||||
$bargain_max_price = !empty($bargain_price) ? max($bargain_price) : 0;
|
||||
$bargain_min_price = !empty($bargain_price) ? min($bargain_price) : 0;
|
||||
|
||||
// 新增砍价活动
|
||||
$bargainModel = new Bargain();
|
||||
$bargainModel->where(['id' => (int)$post['id']])->update([
|
||||
'goods_id' => $post['goods_id'],
|
||||
'time_limit' => $post['time_limit'],
|
||||
'activity_start_time' => strtotime($post['activity_start_time']),
|
||||
'activity_end_time' => strtotime($post['activity_end_time']),
|
||||
'bargain_min_price' => $bargain_min_price,
|
||||
'bargain_max_price' => $bargain_max_price,
|
||||
'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
|
||||
'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
|
||||
'payment_where' => $post['payment_where'],
|
||||
'knife_type' => $post['knife_type'],
|
||||
'knife_price' => $knife_price,
|
||||
'status' => $post['status']
|
||||
]);
|
||||
|
||||
// 删除旧的SKU
|
||||
$bargainItemModel = new BargainItem();
|
||||
$bargainItemModel->where(['bargain_id' => (int)$post['id']])->delete();
|
||||
|
||||
// 新增砍价商品SKU
|
||||
$lists = [];
|
||||
foreach ($post['floor_price'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
$lists[] = [
|
||||
'bargain_id' => $post['id'],
|
||||
'goods_id' => $key,
|
||||
'item_id' => $K,
|
||||
'floor_price' => $item,
|
||||
'first_knife_price' => $post['first_knife_price'][$key][$K]
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!empty($lists)) {
|
||||
$bargainItemModel->saveAll($lists);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 软删除
|
||||
* @param int $id
|
||||
* @author 张无忌(2021/1/13 18:02)
|
||||
* @return bool
|
||||
*/
|
||||
public static function softDelete(int $id)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$bargainModel = new Bargain();
|
||||
$bargainModel->where(['id'=>(int)$id])->update(['del'=>1]);
|
||||
|
||||
// 关闭活动未完成的
|
||||
$bargainLaunchModel = new BargainLaunch();
|
||||
$bargainLaunchModel->where(['bargain_id'=>$id, 'status'=>0])
|
||||
->update(['status'=>2]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 切换状态
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/13 17:53)
|
||||
* @return bool
|
||||
*/
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$bargainModel = new Bargain();
|
||||
// 切换状态
|
||||
$bargainModel->where(['id' => (int)$post['id']])
|
||||
->update([ $post['field'] => $post['status'] ]);
|
||||
// 关闭活动未完成的
|
||||
// if ($post['status']) {
|
||||
$bargainLaunchModel = new BargainLaunch();
|
||||
// $bargainLaunchModel->where(['bargain_id'=>$post['id'], 'status'=>0])
|
||||
// ->update(['status'=>2]);
|
||||
// }
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 砍价列表
|
||||
* @param $get
|
||||
* @author 张无忌(2021/2/24 17:43)
|
||||
* @return array
|
||||
*/
|
||||
public static function getLaunch($get)
|
||||
{
|
||||
// 查询条件
|
||||
$where = [];
|
||||
|
||||
if (isset($get['bargain_id']) and $get['bargain_id']) {
|
||||
$where[] = ['bargain_id', '=', (int)$get['bargain_id']];
|
||||
}
|
||||
|
||||
if (isset($get['goods_name']) and $get['goods_name'] !== '') {
|
||||
$goodsModel = new GoodsModel();
|
||||
$ids = $goodsModel->field('id,name')->where([
|
||||
['name', 'like', '%' . $get['goods_name'] . '%']
|
||||
])->column('id');
|
||||
|
||||
$where[] = ['goods_id', 'in', $ids];
|
||||
}
|
||||
|
||||
if (isset($get['status']) and is_numeric($get['status'])) {
|
||||
$where[] = ['status', '=', (int)$get['status']];
|
||||
}
|
||||
|
||||
if (isset($get['launch_start_time']) and $get['launch_start_time'] !== '') {
|
||||
$where[] = ['launch_start_time', '>=', strtotime($get['launch_start_time'])];
|
||||
}
|
||||
|
||||
if (isset($get['launch_end_time']) and $get['launch_end_time'] !== '') {
|
||||
$where[] = ['launch_end_time', '<=', strtotime($get['launch_end_time'])];
|
||||
}
|
||||
|
||||
if (isset($get['type']) and $get['type'] !== '') {
|
||||
if (isset($get['keyword']) and $get['keyword'] !== '') {
|
||||
switch ($get['type']) {
|
||||
case 'sn':
|
||||
$uid = User::where('sn', '=', $get['keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
case 'nickname':
|
||||
$uid = User::where('nickname', 'like', '%' . $get['keyword'] . '%')->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
case 'mobile':
|
||||
$uid = User::where('mobile', '=', $get['keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$model = new BargainLaunch();
|
||||
$count = $model->where($where)->count('id');
|
||||
$lists = $model->field(true)
|
||||
->where($where)
|
||||
->with(['user.level'])
|
||||
->order('id', 'desc')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['launch_start_time'] = date('Y-m-d H:i:s', $item['launch_start_time']);
|
||||
$item['launch_end_time'] = date('Y-m-d H:i:s', $item['launch_end_time']);
|
||||
$item['domain'] = UrlServer::getFileUrl('/');
|
||||
$item['status'] = BargainLaunch::getStatusDesc($item['status']);
|
||||
$item['goods_image'] = $item['goods_snap']['image'] == "" ? $item['goods_snap']['goods_iamge'] : $item['goods_snap']['image'] ;
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 砍价详细
|
||||
* @param $id
|
||||
* @author 张无忌(2021/2/24 17:43)
|
||||
* @return array
|
||||
*/
|
||||
public static function getLaunchDetail($id)
|
||||
{
|
||||
$model = new BargainLaunch();
|
||||
$detail = $model->field(true)
|
||||
->where(['id'=>(int)$id])
|
||||
->with(['user.level'])
|
||||
->find()->toArray();
|
||||
|
||||
$detail['domain'] = UrlServer::getFileUrl();
|
||||
$detail['goods_snap']['goods_iamge'] = UrlServer::getFileUrl($detail['goods_snap']['goods_iamge']);
|
||||
$detail['launch_start_time'] = date('Y-m-d H:i:s', $detail['launch_start_time']);
|
||||
$detail['launch_end_time'] = date('Y-m-d H:i:s', $detail['launch_end_time']);
|
||||
$detail['payment_where'] = $detail['bargain_snap']['payment_where'] == 1 ? '任意金额购买' : '固定金额购买';
|
||||
$detail['status'] = BargainLaunch::getStatusDesc($detail['status']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 砍价订单
|
||||
* @param $launch_id
|
||||
* @param $get
|
||||
* @author 张无忌(2021/2/24 17:43)
|
||||
* @return array
|
||||
*/
|
||||
public static function getKnifeOrderRecord($launch_id, $get)
|
||||
{
|
||||
$model = new BargainLaunch();
|
||||
$count = $model->where(['id'=>(int)$launch_id])
|
||||
->where('order_id', '>', 0)->count('id');
|
||||
$lists = $model->field(true)
|
||||
->where(['id'=>(int)$launch_id])
|
||||
->where('order_id', '>', 0)
|
||||
->with(['user.level', 'order'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['order_status'] = Order::getOrderStatus($item['order']['order_status']);
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 砍价记录
|
||||
* @param $launch_id
|
||||
* @param $get
|
||||
* @author 张无忌(2021/2/24 15:48)
|
||||
* @return array
|
||||
*/
|
||||
public static function getKnifeRecord($launch_id, $get)
|
||||
{
|
||||
$model = new BargainKnife();
|
||||
|
||||
$count = $model->where(['launch_id'=>(int)$launch_id])->count();
|
||||
$lists = $model->field(true)
|
||||
->where(['launch_id'=>(int)$launch_id])
|
||||
->with(['user.level'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['help_time'] = date('Y-m-d H:i:s', $item['help_time']);
|
||||
$item['help_price'] = '¥'.$item['help_price'];
|
||||
$item['surplus_price'] = '¥'.$item['surplus_price'];
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
}
|
||||
15
application/admin/logic/ChartLogic.php
Normal file
15
application/admin/logic/ChartLogic.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
class ChartLogic
|
||||
{
|
||||
public static function order_chart($get){
|
||||
$where=[];
|
||||
}
|
||||
|
||||
}
|
||||
951
application/admin/logic/ClasorderLogic.php
Normal file
951
application/admin/logic/ClasorderLogic.php
Normal file
@@ -0,0 +1,951 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\logic\OrderRefundLogic;
|
||||
use app\common\model\MessageScene_;
|
||||
use app\common\model\NoticeSetting;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\OrderLog;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\model\Pay;
|
||||
use app\common\model\UserLevel;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\YlyPrinter;
|
||||
use expressage\Kd100;
|
||||
use expressage\Kdniao;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Env;
|
||||
use think\facade\Hook;
|
||||
|
||||
class ClasorderLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 列表查询条件
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function getListsCondition($get)
|
||||
{
|
||||
$where = [];
|
||||
|
||||
//订单状态
|
||||
if ($get['type'] != '') {
|
||||
$where[] = ['o.pay_status', '=', $get['type']];
|
||||
}
|
||||
//订单编号查询
|
||||
if (isset($get['order_sn']) && $get['order_sn'] != '') {
|
||||
$where[] = ['o.order_sn', 'like', '%' . $get['order_sn'] . '%'];
|
||||
}
|
||||
//客户姓名查询
|
||||
if (isset($get['name']) && $get['name'] != '') {
|
||||
$where[] = ['o.consignee', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//客户的电话查询
|
||||
if (isset($get['mobile']) && $get['mobile'] != '') {
|
||||
$where[] = ['o.mobile', 'like', '%' . $get['mobile'] . '%'];
|
||||
}
|
||||
//商品名称
|
||||
if (isset($get['goods_name']) && $get['goods_name'] != '') {
|
||||
$where[] = ['o.goods_name', 'like', '%' . $get['goods_name'] . '%'];
|
||||
}
|
||||
|
||||
//商品名称
|
||||
if (isset($get['goods_id']) && $get['goods_id'] != '') {
|
||||
$where[] = ['o.goods_id', '=', $get['goods_id']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['order_ysck']) && $get['order_ysck'] != '') {
|
||||
$where[] = ['o.order_ysck', '=', $get['order_ysck']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['channel_id']) && $get['channel_id'] != '') {
|
||||
$where[] = ['o.channel_id', '=', $get['channel_id']];
|
||||
}
|
||||
|
||||
|
||||
//付款方式
|
||||
if (isset($get['pay_way']) && $get['pay_way'] != '') {
|
||||
$where[] = ['o.pay_way', '=', $get['pay_way']];
|
||||
}
|
||||
//付款方式
|
||||
if (isset($get['admin_id']) && $get['admin_id'] != '') {
|
||||
$where[] = ['o.admin_id', '=', $get['admin_id']];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//配送方式
|
||||
if (isset($get['delivery_type']) && $get['delivery_type'] != '') {
|
||||
$where[] = ['o.delivery_type', '=', $get['delivery_type']];
|
||||
}
|
||||
|
||||
//订单类型
|
||||
if (isset($get['order_type']) && $get['order_type'] != '') {
|
||||
$where[] = ['o.admin_id', '=', NULL];
|
||||
}
|
||||
|
||||
//订单来源
|
||||
if (isset($get['order_source']) && $get['order_source'] != '') {
|
||||
$where[] = ['o.order_source', '=', $get['order_source']];
|
||||
}
|
||||
|
||||
//下单时间
|
||||
if (isset($get['start_time']) && $get['start_time'] != '') {
|
||||
$where[] = ['o.create_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
if (isset($get['end_time']) && $get['end_time'] != '') {
|
||||
$where[] = ['o.create_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 日式保洁订单
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function cleaning($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 1)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 收纳整理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function storage($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 2)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 2)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 深度清洗
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function depth($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 4)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 4)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 宠物保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function pet($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 5)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 5)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 宠物保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function cooking($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 3)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 3)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 粗开荒保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function thick($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 6)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id', 6)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 细开荒保洁
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function fine($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 7)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',7)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 搬家货运
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function move($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 8)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',8)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 搬家货运
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function detection($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 9)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',9)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 空气治理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function governance($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 10)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',10)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 空气治理
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function wash($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 11)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',11)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 清洗
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function linen($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 13)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',13)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
/**
|
||||
* Notes: 宠物保洁订单
|
||||
* @param $get
|
||||
* @author 段誉(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
public static function pets($get)
|
||||
{
|
||||
$order = new Order();
|
||||
$where = self::getListsCondition($get);
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text';
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id'); //订单类型
|
||||
$admin=Db::name('admin')->column('name','id');
|
||||
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 14)
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = $order
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where($where)
|
||||
->where('g.brand_id',14)
|
||||
->field('o.*')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('o.id desc')
|
||||
->select();
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
foreach ($lists as &$item){
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
if(isset($admin[$item['admin_id']])){
|
||||
$item['admin_id'] = $admin[$item['admin_id']];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=GoodsLogic::goodsinfo($item['goods_id']);
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['goods_image']=UrlServer::getFileUrl($goods['image']);
|
||||
$item['code']=$goods['code'];
|
||||
}else{
|
||||
$item['goods_name']='';
|
||||
$item['goods_image']='';
|
||||
$item['code']='';
|
||||
}
|
||||
|
||||
$gord_id=Db::name('collection')->where('id',$item['gord_id'])->find();
|
||||
if($gord_id){
|
||||
$item['gord_name']= $gord_id['cqname'];
|
||||
}else{
|
||||
$item['gord_name']='-';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
119
application/admin/logic/CollectionLogic.php
Normal file
119
application/admin/logic/CollectionLogic.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\admin\server\LoginServer;
|
||||
use think\Db;
|
||||
|
||||
class CollectionLogic
|
||||
{
|
||||
/**
|
||||
* 管理员列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
|
||||
$admin_count = Db::name('collection')
|
||||
->count();
|
||||
$admin_lists = Db::name('collection')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
foreach( $admin_lists as &$itme){
|
||||
$itme['create_time']= date('Y-m-d H:i:s',$itme['create_time']);
|
||||
}
|
||||
return ['count' => $admin_count, 'lists' => $admin_lists];
|
||||
}
|
||||
/**
|
||||
* 编辑管理员
|
||||
* @param $post
|
||||
* @return mixed
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
$post['create_time']=time();
|
||||
return Db::name('collection')->where(['id' => $post['id']])->update($post);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示派单配置列表
|
||||
* @param $post
|
||||
* @return mixed
|
||||
*/
|
||||
public static function stafflists($get){
|
||||
$where = [];
|
||||
|
||||
//根据员工编号查询
|
||||
if(isset($get['type']) && $get['type'] != ''){
|
||||
$where[] = ['onwork','=',$get['type']];
|
||||
}
|
||||
|
||||
if(isset($get['id']) && $get['id'] != ''){
|
||||
$where[] = ['id','=',$get['id']];
|
||||
}
|
||||
//根据姓名查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//手机号码查询
|
||||
if(isset($get['mobile']) && $get['mobile'] != ''){
|
||||
$where[] = ['mobile', 'like', '%' . $get['mobile'] . '%'];
|
||||
}
|
||||
//地区查询
|
||||
if(isset($get['area_id']) && $get['area_id'] != ''){
|
||||
$where[] = ['area','=',$get['area_id']];
|
||||
}
|
||||
//是否结婚查询
|
||||
if(isset($get['marry']) && $get['marry'] != ''){
|
||||
$where[] = ['marry','=',$get['marry']];
|
||||
}
|
||||
//是否过敏
|
||||
if(isset($get['allergy']) && $get['allergy'] != ''){
|
||||
$where[] = ['allergy','=',$get['allergy']];
|
||||
}
|
||||
//员工性别
|
||||
if(isset($get['sex']) && $get['sex'] != ''){
|
||||
$where[] = ['sex','=',$get['sex']];
|
||||
}
|
||||
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$user_count = Db::name('staff')
|
||||
->where($where)
|
||||
->where('onwork',1)
|
||||
->count();
|
||||
$user_list = Db::name('staff')
|
||||
->where($where)
|
||||
->where('onwork',1)
|
||||
->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
//员工分组
|
||||
$user_group = Db::name('staff_group')->column('name','id');
|
||||
foreach ($user_list as &$item){
|
||||
if(isset($user_group[$item['group_id']])){
|
||||
$item['group_name'] = $user_group[$item['group_id']];
|
||||
}
|
||||
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
||||
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
101
application/admin/logic/CommonLogic.php
Normal file
101
application/admin/logic/CommonLogic.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
class CommonLogic{
|
||||
/**
|
||||
* note 修改制定表的某个字段
|
||||
* author cjh 2020/10/14 14:51
|
||||
* @param $table 表名
|
||||
* @param $pk_name id
|
||||
* @param $pk_value id的值
|
||||
* @param $field 需要修改的字段
|
||||
* @param $field_value 需要修改的值
|
||||
* @return bool
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function changeTableValue($table,$pk_name,$pk_value,$field,$field_value){
|
||||
//允许修改的字段
|
||||
$allow_field = [
|
||||
'is_show','sort','status','is_new','is_best','is_like','is_recommend'
|
||||
];
|
||||
if(!in_array($field,$allow_field)){
|
||||
return false;
|
||||
}
|
||||
if(is_array($pk_value)){
|
||||
$where[] = [$pk_name,'in',$pk_value];
|
||||
}else{
|
||||
$where[] = [$pk_name,'=',$pk_value];
|
||||
}
|
||||
|
||||
$data= [
|
||||
$field => $field_value,
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
if ($field == 'status' and $field_value == 0) {
|
||||
$res = Db::name('team_activity')
|
||||
->where(['goods_id'=>$pk_value])
|
||||
->find();
|
||||
if ($res) {
|
||||
return '该商品正在参与拼团,请先关闭后才允许下架';
|
||||
}
|
||||
}
|
||||
|
||||
$result = Db::name($table)->where($where)->update($data);
|
||||
return $result ? true : '修改失败';
|
||||
}
|
||||
|
||||
//获取商品列表
|
||||
public static function getGoodsList($get,$is_item = false){
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
$where[] = ['status','=',1];
|
||||
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
if(isset($get['cid']) && $get['cid']){
|
||||
$where[] = ['first_category_id|second_category_id|third_category_id','=',$get['cid']];
|
||||
}
|
||||
|
||||
$goods_count = Db::name('goods')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$goods_list = Db::name('goods')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->column('*','id');
|
||||
|
||||
foreach ($goods_list as &$item) {
|
||||
$item['goods_item'] = [];
|
||||
$item['price'] = '¥'.$item['min_price'];
|
||||
if($item['max_price'] != $item['min_price']){
|
||||
$item['price'] = '¥'.$item['max_price'].'~'.'¥'.$item['min_price'];
|
||||
}
|
||||
$item['create_time_desc'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
if($is_item){
|
||||
$goods_ids = array_keys($goods_list);
|
||||
$goods_item = Db::name('goods_item')->where(['goods_id'=>$goods_ids])->select();
|
||||
foreach ($goods_item as $items){
|
||||
if(isset($goods_list[$items['goods_id']])){
|
||||
if($items['image']){
|
||||
$items['image'] = UrlServer::getFileUrl($items['image']);
|
||||
}else{
|
||||
$items['image'] = $goods_list[$items['goods_id']]['image'];
|
||||
}
|
||||
$goods_list[$items['goods_id']]['goods_item'][] = $items;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['count' => $goods_count, 'list' =>array_values($goods_list)];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
258
application/admin/logic/ControlLogic.php
Normal file
258
application/admin/logic/ControlLogic.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\Logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
class ControlLogic{
|
||||
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
|
||||
//查询
|
||||
//根据员工编号查询
|
||||
if(isset($get['order_id']) && $get['order_id'] != ''){
|
||||
$where[] = ['order_id','=',$get['order_id']];
|
||||
}
|
||||
if(isset($get['staff_id']) && $get['staff_id'] != ''){
|
||||
$where[] = ['staff_id','=',$get['staff_id']];
|
||||
}
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_score']) && $get['start_score']!=''){
|
||||
$where[] = ['score','>=',$get['start_score']];
|
||||
}
|
||||
if(isset($get['end_score']) && $get['end_score']!=''){
|
||||
$where[] = ['score','<=',$get['end_score']];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$count = Db::name('order_trace')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('order_trace')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
|
||||
$order_info=Db::name('order_exe')->where('id',$item['order_id'])->find(); //获取子订单信息
|
||||
$staffinfo=Db::name('staff')->where('id',$order_info['staff_id'])->find();
|
||||
$item['staff_name']=$staffinfo['name'];
|
||||
$item['start_time']=date('Y-m-d H:i:s', $order_info['start_time']);
|
||||
$item['timeout']=date('Y-m-d H:i:s', $order_info['timeout']);
|
||||
$item['add']=$order_info['add'];
|
||||
|
||||
$order=Db::name('order')->where('order_sn',$order_info['order_sn'])->find();
|
||||
$item['adderss']=$order['address'];
|
||||
|
||||
$goods=Db::name('goods')->where('id',$order['goods_id'])->find();
|
||||
|
||||
$item['goods_name']=$goods['name'];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
public static function info($id){
|
||||
return Db::name('order_trace')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function edit($post){
|
||||
$data=[
|
||||
'score' => $post['score'],
|
||||
'ptance' =>$post['ptance'],
|
||||
'storaged' =>$post['storaged'],
|
||||
'leanin' => $post['leanin'],
|
||||
'munity'=>$post['munity'],
|
||||
'advise' => $post['advise'],
|
||||
'profound' => $post['profound'],
|
||||
'adjust'=>$post['adjust']
|
||||
];
|
||||
return Db::name('order_trace')->where('id',$post['id'])->data($data)->update();
|
||||
}
|
||||
public static function sale_add($post){
|
||||
$order=Db::name('order_exe')->where('id',$post['id'])->find();
|
||||
$data=[
|
||||
'name'=>$order['name'],
|
||||
'phone'=>$order['phone'],
|
||||
'problem'=>$post['problem'],
|
||||
'autotime'=>$order['autotime'],
|
||||
'staff_id'=>$order['staff_id'],
|
||||
'status' =>0,
|
||||
'adjust'=>$post['adjust'],
|
||||
'order_id'=>$post['id'],
|
||||
'goods_images'=>$post['goods_images'],
|
||||
'video' =>$post['video'],
|
||||
'time' =>time(),
|
||||
];
|
||||
|
||||
return Db::name('order_sale')->data($data)->insert();
|
||||
}
|
||||
|
||||
public static function visit_order($get){
|
||||
$where=[];
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$count = Db::name('order_sale')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('order_sale')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['autotime']=date('Y-m-d', $item['autotime']);
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
if($staff){
|
||||
$item['staff_name']= $staff['name'];
|
||||
$item['staff_phone']= $staff['mobile'];
|
||||
}
|
||||
|
||||
$item['time']=date('Y-m-d:H:i:s', $item['time']);
|
||||
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function sale_info($id){
|
||||
return Db::name('order_sale')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function sale_edit($post){
|
||||
return Db::name('order_sale')->where('id',$post['id'])->update(['problem'=>$post['problem'],'adjust'=>$post['adjust']]);
|
||||
}
|
||||
|
||||
public static function sale_status($id){
|
||||
return Db::name('order_sale')->where('id',$id)->update(['status'=>1]);
|
||||
}
|
||||
|
||||
public static function sale_del($id){
|
||||
return Db::name('order_sale')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
public static function follow($get){
|
||||
return $get;
|
||||
}
|
||||
|
||||
public static function abnormal_lists($get){
|
||||
|
||||
$where=[];
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
if(isset($get['staff_id']) && $get['staff_id'] != ''){
|
||||
$where[] = ['staff_id','=',$get['staff_id']];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$count = Db::name('order_abnormal')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('order_abnormal')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
$item['staff_name']= $staff['name'];
|
||||
$item['staff_mobile']= $staff['mobile'];
|
||||
$coust=Db::name('order_exe')->where('id',$item['order_id'])->find();
|
||||
if($coust){
|
||||
$item['coust_name']= $coust['name'];
|
||||
$item['coust_mobile']= $coust['phone'];
|
||||
}else{
|
||||
$item['coust_name']="-";
|
||||
$item['coust_mobile']="-";
|
||||
}
|
||||
$item['create_time']=date('Y-m-d:H:i:s', $item['create_time']);
|
||||
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
public static function abnormal_info($id){
|
||||
return Db::name('order_abnormal')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function abnormal_eidt($post){
|
||||
return Db::name('order_abnormal')->where('id',$post['id'])
|
||||
->update(['problem'=>$post['problem'],'adjust'=>$post['adjust']]);
|
||||
}
|
||||
|
||||
public static function abnormal_del($id){
|
||||
return Db::name('order_abnormal')->where('id',$id)->delete();
|
||||
}
|
||||
public static function controlimg($post){
|
||||
$data=Db::name('user_order_imges')->where('order_id',$post)->find();
|
||||
return $data;
|
||||
}
|
||||
//查看投诉图片
|
||||
public static function images($id){
|
||||
$data=Db::name('order_sale')->where('order_id',$id)->find();
|
||||
$array = explode(',', $data['goods_images']);
|
||||
$datas=[
|
||||
'images'=>$array,
|
||||
'video' =>$data['video'],
|
||||
];
|
||||
return $datas;
|
||||
}
|
||||
|
||||
//生成处罚单据
|
||||
public static function punish($id){
|
||||
Db::name('order_sale')->where('order_id',$id)->update(['punish'=>1]);
|
||||
$data=Db::name('order_sale')->where('order_id',$id)->find();
|
||||
$datas=[
|
||||
'staff_id'=>$data['staff_id'],
|
||||
'order_id' =>$data['order_id'],
|
||||
'create_time' =>time()
|
||||
];
|
||||
Db::name('fine')->data($datas)->insert();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
325
application/admin/logic/CouponLogic.php
Normal file
325
application/admin/logic/CouponLogic.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?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\admin\Logic;
|
||||
use app\admin\model\Coupon;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
|
||||
class CouponLogic{
|
||||
public static function lists($get){
|
||||
//更新过期优惠券
|
||||
$now = time();
|
||||
Db::name('coupon')
|
||||
->where([['send_time_start','<',$now], ['send_time_end','<',$now],['status','=',1]])
|
||||
->update(['status'=>0,'update_time'=>$now]);
|
||||
|
||||
$where[] = ['del','=',0];
|
||||
//优惠券名称搜索
|
||||
if(isset($get['name']) && $get['name']){
|
||||
$where[] = ['name','like','%'.$get['name'].'%'];
|
||||
}
|
||||
//发放优惠券
|
||||
if(isset($get['type']) && $get['type'] === 'send'){
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['get_type','=',2];
|
||||
|
||||
}
|
||||
if(isset($get['type']) && $get['type'] !== 'send' && $get['type'] !== ''){
|
||||
$where[] = ['status','=',$get['type']];
|
||||
}
|
||||
$coupon = new Coupon();
|
||||
|
||||
$coupon_count = $coupon
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$coupon_list = $coupon
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
$coupon_list->append(['status_desc','sent_total','send_time']);
|
||||
return ['count' => $coupon_count, 'list' => $coupon_list];
|
||||
|
||||
}
|
||||
|
||||
//添加优惠券
|
||||
public static function add($post){
|
||||
//拼接数据
|
||||
$add_data = [
|
||||
'name' => $post['name'],
|
||||
'money' => $post['money'],
|
||||
'send_time_start' => $post['send_time_start'],
|
||||
'send_time_end' => $post['send_time_end'],
|
||||
'send_total_type' => $post['send_total_type'],
|
||||
'send_total' => $post['send_total_type'] == 2 ? $post['send_total'] : '',
|
||||
'condition_type' => $post['condition_type'],
|
||||
'condition_money' => $post['condition_type'] == 2 ? $post['condition_money'] : '',
|
||||
'use_time_type' => $post['use_time_type'],
|
||||
'use_time_start' => $post['use_time_type'] == 1 ? $post['use_time_start'] : '',
|
||||
'use_time_end' => $post['use_time_type'] == 1 ? $post['use_time_end'] : '',
|
||||
'use_time' => $post['use_time_type'] == 2 ? $post['use_time'] : '',
|
||||
'get_type' => $post['get_type'],
|
||||
'get_num_type' => $post['get_num_type'],
|
||||
'get_num' => $post['get_num'],
|
||||
'use_goods_type' => $post['use_goods_type'],
|
||||
'status' => 1,
|
||||
];
|
||||
//用券时间
|
||||
if($post['use_time_type'] == 3){
|
||||
$add_data['use_time'] = $post['tomorrow_use_time'];
|
||||
}
|
||||
//领取次数
|
||||
if($post['get_num_type'] == 3){
|
||||
$add_data['get_num'] = $post['day_get_num'];
|
||||
}
|
||||
//提交订单
|
||||
Db::startTrans();
|
||||
try {
|
||||
$coupon = Coupon::create($add_data);
|
||||
if($coupon && $coupon['use_goods_type'] != 1){
|
||||
$goods_coupon = [];
|
||||
$now = time();
|
||||
foreach ($post['goods_ids'] as $item){
|
||||
$goods_coupon[] = [
|
||||
'coupon_id' => $coupon->id,
|
||||
'goods_id' => $item,
|
||||
'create_time' => $now,
|
||||
];
|
||||
}
|
||||
Db::name('coupon_goods')->insertAll($goods_coupon);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public static function edit($post){
|
||||
|
||||
$coupon = new Coupon();
|
||||
//拼接数据
|
||||
$update_data = [
|
||||
'name' => $post['name'],
|
||||
'money' => $post['money'],
|
||||
'send_time_start' => $post['send_time_start'],
|
||||
'send_time_end' => $post['send_time_end'],
|
||||
'send_total_type' => $post['send_total_type'],
|
||||
'send_total' => $post['send_total_type'] == 2 ? $post['send_total'] : '',
|
||||
'condition_type' => $post['condition_type'],
|
||||
'condition_money' => $post['condition_type'] == 2 ? $post['condition_money'] : '',
|
||||
'use_time_type' => $post['use_time_type'],
|
||||
'use_time_start' => $post['use_time_type'] == 1 ? $post['use_time_start'] : '',
|
||||
'use_time_end' => $post['use_time_type'] == 1 ? $post['use_time_end'] : '',
|
||||
'use_time' => $post['use_time_type'] == 2 ? $post['use_time'] : '',
|
||||
'get_type' => $post['get_type'],
|
||||
'get_num_type' => $post['get_num_type'],
|
||||
'get_num' => $post['get_num_type'] == 2 ? $post['get_num'] : '',
|
||||
'use_goods_type' => $post['use_goods_type'],
|
||||
];
|
||||
//用券时间
|
||||
if($post['use_time_type'] == 3){
|
||||
$update_data['use_time'] = $post['tomorrow_use_time'];
|
||||
}
|
||||
//领取次数
|
||||
if($post['get_num_type'] == 3){
|
||||
$update_data['get_num'] = $post['day_get_num'];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$coupon->save($update_data,['id'=>$post['id']]);
|
||||
Db::name('coupon_goods')->where(['coupon_id'=>$post['id']])->delete();
|
||||
|
||||
if($coupon && $coupon['use_goods_type'] != 1){
|
||||
$goods_coupon = [];
|
||||
$now = time();
|
||||
foreach ($post['goods_ids'] as $item){
|
||||
$goods_coupon[] = [
|
||||
'coupon_id' => $post['id'],
|
||||
'goods_id' => $item,
|
||||
'create_time' => $now,
|
||||
];
|
||||
}
|
||||
Db::name('coupon_goods')->insertAll($goods_coupon);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function getCoupon($id,$get_data = false){
|
||||
$coupon = Coupon::get($id);
|
||||
$coupon['goods_coupon'] = [];
|
||||
if($get_data) {
|
||||
$coupon = $coupon->getData();
|
||||
$coupon['send_time_start'] = date('Y-m-d H:i:s',$coupon['send_time_start']);
|
||||
$coupon['send_time_end'] = date('Y-m-d H:i:s',$coupon['send_time_end']);
|
||||
if($coupon['use_goods_type'] != 1){
|
||||
$goods_coupon= Db::name('coupon_goods cg')
|
||||
->join('goods g','cg.goods_id = g.id')
|
||||
->where(['coupon_id'=>$id])
|
||||
->field('g.id,name,max_price,min_price,stock')
|
||||
->select();
|
||||
foreach ($goods_coupon as &$item){
|
||||
$item['price'] = '¥'.$item['min_price'].'~'.'¥'.$item['max_price'];
|
||||
if($item['max_price'] == $item['min_price']){
|
||||
$item['price'] = '¥'.$item['min_price'];
|
||||
}
|
||||
}
|
||||
$coupon['goods_coupon'] = $goods_coupon;
|
||||
}
|
||||
if($coupon['use_time_start']){
|
||||
$coupon['use_time_start'] = date('Y-m-d H:i:s',$coupon['use_time_start']);
|
||||
$coupon['use_time_end'] = date('Y-m-d H:i:s',$coupon['use_time_end']);
|
||||
}
|
||||
}
|
||||
|
||||
return $coupon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 删除优惠券
|
||||
*/
|
||||
public static function del($id){
|
||||
Db::startTrans();
|
||||
try{
|
||||
$coupon = new Coupon();
|
||||
$coupon->save(['del'=>1,'update_time'=>time()],['id'=>$id]);
|
||||
|
||||
// 同步删除已领取未使用的用户的优惠券
|
||||
Db::name('coupon_list')->where([
|
||||
'status' => 0,
|
||||
'coupon_id' => $id,
|
||||
'del' => 0
|
||||
])->update([
|
||||
'del' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch(\Exception $e) {
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 发放记录
|
||||
*/
|
||||
public static function log($get){
|
||||
$where[] = ['cl.del','=',0];
|
||||
$where[] = ['coupon_id','=',$get['id']];
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = ['nickname|mobile','like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
|
||||
$log_count = Db::name('coupon_list cl')
|
||||
->join('user u','cl.user_id = u.id')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$log_list = Db::name('coupon_list cl')
|
||||
->join('user u','cl.user_id = u.id')
|
||||
->where($where)
|
||||
->field('coupon_id,status,coupon_code,cl.create_time as create_time,cl.use_time,u.nickname,u.avatar,u.mobile,u.sex,u.sn,u.level,u.create_time as u_create_time')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
$coupon_list = Db::name('coupon')->where(['del'=>0])->column('name','id');
|
||||
$level_name = Db::name('user_level')->where(['del'=>0])->column('name','id');
|
||||
foreach ($log_list as &$item)
|
||||
{
|
||||
$item['use_time_desc'] = '-';
|
||||
$item['status_desc'] = '未使用';
|
||||
$item['create_time_desc'] = '';
|
||||
$item['sex_desc'] = '未知';
|
||||
if($item['use_time']){
|
||||
$item['use_time_desc'] = date('Y-m-d H:i:s',$item['use_time']);
|
||||
}
|
||||
$item['u_create_time'] = date('Y-m-d H:i:s',$item['u_create_time']);
|
||||
|
||||
if ($item['status'] == 1) {
|
||||
$item['status_desc'] = '已使用';
|
||||
} else if($item['status'] == 2) {
|
||||
$item['status_desc'] = '已过期';
|
||||
}
|
||||
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['coupon_name'] = $coupon_list[$item['coupon_id']] ?? '';
|
||||
$item['create_time_desc'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||
|
||||
$item['level_name'] = $level_name[$item['level']] ?? '';
|
||||
switch ($item['sex']){
|
||||
case 1:
|
||||
$item['sex_desc'] = '男';
|
||||
case 2:
|
||||
$item['sex_desc'] = '女';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return ['count'=>$log_count , 'lists'=>$log_list];
|
||||
}
|
||||
|
||||
/*
|
||||
* 关闭优惠券
|
||||
*/
|
||||
public static function close($id){
|
||||
$coupon = new Coupon();
|
||||
return $coupon->save(['status'=>0,'update_time'=>time()],['id'=>$id]);
|
||||
}
|
||||
|
||||
|
||||
public static function sendCoupon($post){
|
||||
$user_ids = $post['user_ids'];
|
||||
$coupon_ids = $post['coupon_ids'];
|
||||
$now = time();
|
||||
foreach ($coupon_ids as $coupon_id){
|
||||
foreach ($user_ids as $user_id){
|
||||
$add_data = [
|
||||
'user_id' => $user_id,
|
||||
'coupon_id' => $coupon_id,
|
||||
'status' => 0,
|
||||
'coupon_code' => create_coupon_code(),
|
||||
'create_time' => $now,
|
||||
];
|
||||
Db::name('coupon_list')->insert($add_data);
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
213
application/admin/logic/CrontabLogic.php
Normal file
213
application/admin/logic/CrontabLogic.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\Crontab_;
|
||||
use Cron\CronExpression;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CrontabLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取定时任务列表
|
||||
* @return array|\PDOStatement|string|\think\Collection|\think\model\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
|
||||
$lists = Db::name('dev_crontab')
|
||||
->order(['system' => 'desc'])
|
||||
->select();
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['type_str'] = Crontab_::$type[$v['type']];
|
||||
$lists[$k]['last_time_str'] = empty($v['last_time']) ? '-' : date('m-d H:i:s', $v['last_time']);
|
||||
if ($v['type'] == 2) {
|
||||
$lists[$k]['expression'] = '-';
|
||||
}
|
||||
}
|
||||
return ['count' => count($lists), 'lists' => $lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务信息
|
||||
* @param $id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作
|
||||
* @param $operation
|
||||
* @param $id
|
||||
* @return bool|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function operation($operation, $id)
|
||||
{
|
||||
try {
|
||||
$cron = Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->find();
|
||||
if ($cron['type'] == 1 && CronExpression::isValidExpression($cron['expression']) === false) {
|
||||
throw new Exception("规则设置错误"); //定时任务运行规则错误,不执行
|
||||
}
|
||||
|
||||
switch ($operation) {
|
||||
case 'start':
|
||||
case 'restart':
|
||||
Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->update(['status' => 1]);
|
||||
break;
|
||||
case 'stop':
|
||||
Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->update(['status' => 2]);
|
||||
default;
|
||||
}
|
||||
/*$count = Db::name('dev_crontab')
|
||||
->where(['status' => 1])
|
||||
->count();
|
||||
|
||||
|
||||
$crontab_server = new CrontabServer();
|
||||
if ($count == 0) {
|
||||
$crontab_server->run(true);
|
||||
} else {
|
||||
$crontab_server->run(false);
|
||||
}*/
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->update(['status' => 3, 'error' => $e->getMessage()]);
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接下来几次执行时间
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function expression($get)
|
||||
{
|
||||
if (CronExpression::isValidExpression($get['expression']) === false) {
|
||||
return [['time' => 0, 'date' => '规则设置错误']];
|
||||
}
|
||||
$cron_expression = CronExpression::factory($get['expression']);
|
||||
try {
|
||||
$res = $cron_expression->getMultipleRunDates(5);
|
||||
} catch (Exception $e) {
|
||||
return [['time' => 0, 'date' => '规则设置错误']];
|
||||
}
|
||||
$res = json_decode(json_encode($res), true);
|
||||
$lists = [];
|
||||
foreach ($res as $k => $v) {
|
||||
$lists[$k]['time'] = $k + 1;
|
||||
$lists[$k]['date'] = str_replace('.000000', '', $v['date']);
|
||||
}
|
||||
$lists[] = ['time' => 'x', 'date' => '……'];
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加系统任务
|
||||
* @param $post
|
||||
* @return int|string
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'type' => $post['type'],
|
||||
'remark' => $post['remark'],
|
||||
'command' => $post['command'],
|
||||
'parameter' => $post['parameter'],
|
||||
'status' => $post['status'],
|
||||
'expression' => $post['expression'],
|
||||
'create_time' => time()
|
||||
];
|
||||
$result = Db::name('dev_crontab')
|
||||
->insert($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统任务
|
||||
* @param $post
|
||||
* @return int|string
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'type' => $post['type'],
|
||||
'remark' => $post['remark'],
|
||||
'command' => $post['command'],
|
||||
'parameter' => $post['parameter'],
|
||||
'status' => $post['status'],
|
||||
'expression' => $post['expression'],
|
||||
'update_time' => time()
|
||||
];
|
||||
$result = Db::name('dev_crontab')
|
||||
->where(['id' => $post['id']])
|
||||
->update($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
* @param $id
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
$system = Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->value('system');
|
||||
if ($system === 1) {
|
||||
return false;
|
||||
}
|
||||
$flag = Db::name('dev_crontab')
|
||||
->where(['id' => $id])
|
||||
->delete();
|
||||
return $flag;
|
||||
}
|
||||
}
|
||||
529
application/admin/logic/CustomLogic.php
Normal file
529
application/admin/logic/CustomLogic.php
Normal file
@@ -0,0 +1,529 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
use Cron\CronExpression;
|
||||
use think\Db;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\Pay;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Exception;
|
||||
|
||||
class CustomLogic
|
||||
{
|
||||
/**
|
||||
* 客户列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function list($get){
|
||||
|
||||
$where = [];
|
||||
//根据客户电话查询
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['telephone','=',$get['phone']];
|
||||
|
||||
}
|
||||
//根据客户姓名查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$phone=Db::name('user_address')->whereLike('consignee',$get['name'])->find();
|
||||
$where[] = ['user_id','=',$phone['user_id']];
|
||||
}
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$user_count = Db::name('user_address')
|
||||
->where($where)
|
||||
->where('admin_id',0)
|
||||
->field('password,pay_password,salt',true)
|
||||
->order('id desc')
|
||||
->count();
|
||||
$user_list = Db::name('user_address')
|
||||
->where($where)
|
||||
->where('admin_id',0)
|
||||
->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach($user_list as &$item){
|
||||
$staff=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
if($staff){
|
||||
$item['name']= $staff['name'];
|
||||
}
|
||||
|
||||
$item['qudao']=Db::name('staffchannel')->where('id', $item['brand_id'])->column('name');
|
||||
$custom=Db::name('custom')->where('custom_id',$item['id'])->order('id desc')->find();
|
||||
$item['custom']=Db::name('custom')->where('custom_id', $item['id'])->order('id desc')->limit(1)->column('connect');
|
||||
if($custom){
|
||||
$item['create_timess']=date("Y年m月d日 H:i",$custom['create_time']);
|
||||
}else{
|
||||
$item['create_timess']="-";
|
||||
}
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 我的客户列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function userlist($get){
|
||||
$where = [];
|
||||
$where[] = ['admin_id', '=', session('admin_info.id')];
|
||||
if(isset($get['id']) && $get['id'] != ''){
|
||||
$where[] = ['id','=',$get['id']];
|
||||
}
|
||||
//根据客户电话查询
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['telephone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
//根据客户姓名查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['contact', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
if(isset($get['area']) && $get['area'] != ''){
|
||||
$where[] = ['district_id','=',$get['area']];
|
||||
}
|
||||
//客户标签检索
|
||||
if(isset($get['label_id']) && $get['label_id'] != ''){
|
||||
$where[] = ['label_id','=',$get['label_id']];
|
||||
}
|
||||
|
||||
//根据客户的时间去查询内容
|
||||
if(isset($get['pet']) && $get['pet'] != ''){
|
||||
$where[] = ['pet','=',$get['pet']];
|
||||
}
|
||||
if(isset($get['hbl']) && $get['hbl'] != ''){
|
||||
$where[] = ['hbl','=',$get['hbl']];
|
||||
}
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$user_count = Db::name('user_address')
|
||||
->where($where)
|
||||
->field('password,pay_password,salt',true)
|
||||
->order('id desc')
|
||||
->count();
|
||||
$user_list = Db::name('user_address')
|
||||
->where($where)
|
||||
->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
//跟进人信息
|
||||
$staff=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
$item['name']= $staff['name'];
|
||||
$custom=Db::name('custom')->where('admin_id',$item['admin_id'])->order('id desc')->find();
|
||||
if($custom){
|
||||
$item['create_time']=date("Y年m月d日 H:i",$custom['create_time']);
|
||||
}
|
||||
|
||||
|
||||
$item['qudao']=Db::name('staffchannel')->where('id', $item['brand_id'])->column('name');
|
||||
|
||||
$staff=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
$item['name']= $staff['name'];
|
||||
$item['qudao']=Db::name('staffchannel')->where('id', $item['brand_id'])->column('name');
|
||||
$custom=Db::name('custom')->where('custom_id',$item['id'])->order('id desc')->find();
|
||||
$item['custom']=Db::name('custom')->where('custom_id', $item['id'])->order('id desc')->limit(1)->column('connect');
|
||||
if($custom){
|
||||
$item['create_timess']=date("Y年m月d日 H:i",$custom['create_time']);
|
||||
}else{
|
||||
$item['create_timess']="-";
|
||||
}
|
||||
$label=Db::name('user_label')->where('id',$item['label_id'])->find();
|
||||
if($label){
|
||||
$item['user_label']=$label['name'];
|
||||
}else{
|
||||
$item['user_label']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 订单备注
|
||||
* @param $post
|
||||
* @param string $type
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
* @author 张无忌(2021/2/1 18:50)
|
||||
*/
|
||||
public static function user_remarks($post, $type="get")
|
||||
{
|
||||
if ($type==='get') {
|
||||
|
||||
return Db::name('user_address')->field('id,user_remarks')
|
||||
->where(['id'=>$post['id']])
|
||||
->findOrEmpty();
|
||||
} else {
|
||||
return Db::name('user_address')
|
||||
->where(['id'=>$post['id']])
|
||||
->update(['user_remarks'=>$post['user_remarks']]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Notes: 管理员备注
|
||||
* @param $post
|
||||
* @param string $type
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
* @author 张无忌(2021/2/1 18:50)
|
||||
*/
|
||||
public static function admin_remarks($post, $type="get")
|
||||
{
|
||||
if ($type==='get') {
|
||||
|
||||
return Db::name('user_address')->field('id,admin_remarks')
|
||||
->where(['id'=>$post['id']])
|
||||
->findOrEmpty();
|
||||
} else {
|
||||
return Db::name('user_address')
|
||||
->where(['id'=>$post['id']])
|
||||
->update(['admin_remarks'=>$post['admin_remarks']]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Notes: 保洁师备注信息
|
||||
* @param $post
|
||||
* @param string $type
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
* @author 杨左(2021/2/1 18:50)
|
||||
*/
|
||||
public static function staff_remarks($post, $type="get")
|
||||
{
|
||||
if ($type==='get') {
|
||||
|
||||
return Db::name('user_address')->field('id,staff_remarks')
|
||||
->where(['id'=>$post['id']])
|
||||
->findOrEmpty();
|
||||
} else {
|
||||
return Db::name('user_address')
|
||||
->where(['id'=>$post['id']])
|
||||
->update(['staff_remarks'=>$post['staff_remarks']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//客户档案的编辑
|
||||
public static function edit($post){
|
||||
|
||||
$data=[
|
||||
'contact' =>$post['name'],
|
||||
'telephone' =>$post['phone'],
|
||||
'sex' =>$post['sex'],
|
||||
'province_id' =>$post['first_category_id'],
|
||||
'city_id' =>$post['second_category_id'],
|
||||
'district_id' =>$post['third_category_id'],
|
||||
'lng' =>$post['store_latitude'],
|
||||
'lat' =>$post['store_longitude'],
|
||||
'areas' =>$post['areas'],
|
||||
'brand_id' =>$post['brand_id'],
|
||||
'pet' =>$post['pet'],
|
||||
'hbl' =>$post['hbl'],
|
||||
'address' =>$post['address'],
|
||||
'admin_id' =>session('admin_info.id'),
|
||||
'updatetime' =>time(),
|
||||
'createtime' =>time(),
|
||||
];
|
||||
return Db::name('user_address')->where('id',$post['id'])->data($data)->update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* order: 哆啦猫客户来源渠道
|
||||
* Desc: 查询分类列表
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('staffchannel')->where('id',$id)->find();
|
||||
}
|
||||
/**
|
||||
* order: 哆啦猫客户来源渠道
|
||||
* Desc: 客户的渠道列表查询
|
||||
*/
|
||||
public static function infolist(){
|
||||
return Db::name('staffchannel')->where('deletetime','NULL')->select();
|
||||
}
|
||||
|
||||
public static function ordertypeedit($post){
|
||||
$now = time();
|
||||
$data['createtime'] = $now;
|
||||
$data['updatetime'] = $now;
|
||||
$data['name']=$post['name'];
|
||||
$data['sort']=$post['sort'];
|
||||
$data['pid']=$post['pid'];
|
||||
return Db::name('staffchannel')
|
||||
->where('id',$post['id'])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
//查看客户档案的信息
|
||||
|
||||
public static function getCustom($id,$getdata = false,$expenditure = false){
|
||||
$custom = Db::name('user_address')->where('id',$id)->find(); //获取客户的基本信息
|
||||
if($custom){
|
||||
$user=Db::name('user')->where('id',$custom['user_id'])->find();
|
||||
if($user){
|
||||
$custom['abs_avatar'] = UrlServer::getFileUrl($user['avatar']);
|
||||
$custom['birthday'] = date('Y-m-d',$user['birthday']);
|
||||
$custom['nickname']=$user['nickname'];
|
||||
}else{
|
||||
$custom['nickname']='-';
|
||||
$custom['birthday'] ='-';
|
||||
$custom['abs_avatar'] ='-';
|
||||
}
|
||||
|
||||
}
|
||||
if($expenditure){
|
||||
//本月的消费金额
|
||||
$month_amount = Db::name('order')
|
||||
->where(['mobile'=>$custom['telephone'],'pay_status'=>Pay::ISPAID])
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
//本月的订单笔数
|
||||
$month_num = Db::name('order')
|
||||
->where(['mobile'=>$custom['telephone'],'pay_status'=>Pay::ISPAID])
|
||||
->whereTime('create_time', 'month')
|
||||
->count();
|
||||
$month_number = Db::name('order')
|
||||
->where(['mobile'=>$custom['telephone'],'pay_status'=>Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
//累计消费笔数
|
||||
$total_num =Db::name('order')
|
||||
->where(['mobile'=>$custom['telephone'],'pay_status'=>Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
|
||||
$avg_amount = Db::name('order')
|
||||
->where(['mobile'=>$custom['telephone'],'pay_status'=>Pay::ISPAID])
|
||||
->avg('order_amount');
|
||||
$custom['month_amount'] = '¥'.round($month_amount,2);
|
||||
$custom['month_num'] = round($month_num,2);
|
||||
$custom['total_num'] = round($total_num,2);
|
||||
$custom['total_order_amount']=$month_number;
|
||||
$custom['avg_amount'] = '¥'.round($avg_amount,2);
|
||||
|
||||
}
|
||||
return $custom;
|
||||
|
||||
//档案下单页面
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function Customlist($get){
|
||||
switch ($get['type']){
|
||||
case 0://下单明细
|
||||
$custom=Db::name('user_address')->where('id',$get['user_id'])->find();
|
||||
$count = Db::name('order')->alias('o')
|
||||
->where(['mobile'=>$custom['telephone']])
|
||||
->where('order_status','not in',[Order::STATUS_CLOSE,Order::STATUS_WAIT_PAY])
|
||||
->count();
|
||||
|
||||
$list =Db::name('order')->alias('o')
|
||||
->where(['mobile'=>$custom['telephone']])
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->field('o.id,order_sn,total_num,pay_time,total_amount,order_amount,discount_amount,
|
||||
o.create_time,consignee,province,city,district,o.address,mobile,code,number')
|
||||
->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['total_nums']='1';
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$item['code_number']=$item['number']-$item['code']; //计算待服务次数
|
||||
$item['codes_number']=$item['number']-$item['code_number']; //计算已服务次数
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case 1://积分明细
|
||||
$account_log =new AccountLog();
|
||||
$count = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::integral_change])
|
||||
->count();
|
||||
$list = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::integral_change])
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
break;
|
||||
case 2://签到明细
|
||||
$account_log =new AccountLog();
|
||||
$count = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::sign_in_integral])
|
||||
->count();
|
||||
$list = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::sign_in_integral])
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
break;
|
||||
case 3://余额明细
|
||||
$account_log = new AccountLog();
|
||||
$count = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::money_change])
|
||||
->count();
|
||||
$list = $account_log
|
||||
->where(['user_id'=>$get['user_id'],'source_type'=>AccountLog::money_change])
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
break;
|
||||
case 4://推广明细
|
||||
$count = 1;
|
||||
$first_leader = Db::name('user')->where(['id'=>$get['user_id']])->value('first_leader');
|
||||
$list = [];
|
||||
if($first_leader){
|
||||
$user = new User();
|
||||
$list = $user
|
||||
->where(['id'=>$first_leader])
|
||||
->field('id,sn,nickname,mobile,avatar,level,sex,create_time,total_order_amount,user_money,user_integral')
|
||||
->order('id desc')
|
||||
->select();
|
||||
$level_list = Db::name('user_level')->where(['del'=>0])->column('name','id');
|
||||
foreach ($list as &$item) {
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['level_name'] = '-';
|
||||
if(isset($level_list[$item['level']])){
|
||||
$item['level_name'] = $level_list[$item['level']];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5://房屋的地址
|
||||
$count = Db::name('user_address')
|
||||
->where(['user_id'=>$get['user_id'],'del'=>0])
|
||||
->count();
|
||||
$list = Db::name('user_address')
|
||||
->where(['user_id'=>$get['user_id'],'del'=>0])
|
||||
->order('id desc')
|
||||
->select();
|
||||
break;
|
||||
case 6://投诉建议的内容
|
||||
$count = Db::name('user_report')
|
||||
->where(['user_id'=>$get['user_id']])
|
||||
->count();
|
||||
$list = Db::name('user_report')
|
||||
->where(['user_id'=>$get['user_id']])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
}
|
||||
|
||||
break;
|
||||
case 7://回访记录
|
||||
$count = Db::name('user_follow')
|
||||
->where(['user_id'=>$get['user_id']])
|
||||
->count();
|
||||
$list = Db::name('user_follow')
|
||||
->where(['user_id'=>$get['user_id']])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
$item['name']=$staff['name'];
|
||||
$item['phone']=$staff['mobile'];
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$count , 'lists'=>$list];
|
||||
}
|
||||
|
||||
//删除客户的档案
|
||||
|
||||
public static function del($post){
|
||||
return Db::name('user_address')->where('id',$post['id'])->delete();
|
||||
}
|
||||
|
||||
|
||||
//客户来源渠道
|
||||
public static function staff_channel(){
|
||||
$lists = Db::name('staffchannel')
|
||||
->where('deletetime','NULL')
|
||||
->order(['sort' => 'desc', 'id' => 'asc'])
|
||||
->select();
|
||||
$pids = Db::name('staffchannel')
|
||||
->column('pid');
|
||||
foreach ($lists as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
||||
}
|
||||
return linear_to_tree($lists);
|
||||
}
|
||||
/**
|
||||
* order: 客户来源列表
|
||||
* Desc: 现实客户渠道来源列表
|
||||
*/
|
||||
public static function Menu($id =1){
|
||||
$lists = Db::name('staffchannel')
|
||||
->where('deletetime','NULL')
|
||||
->select();
|
||||
if ($id) {
|
||||
$remove_ids = self::getChildIds($lists, $id);
|
||||
$remove_ids[] = $id;
|
||||
foreach ($lists as $key => $row) {
|
||||
if (in_array($row['id'], $remove_ids)) {
|
||||
unset($lists[$key]);
|
||||
}
|
||||
}
|
||||
$lists = array_values($lists);
|
||||
}
|
||||
return multilevel_linear_sort($lists, '|-');
|
||||
|
||||
}
|
||||
|
||||
private static function getChildIds($lists, $id)
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($lists as $key => $row) {
|
||||
if ($row['pid'] == $id) {
|
||||
$ids[] = $row['id'];
|
||||
$child_ids = self::getChildIds($lists, $row['id']);
|
||||
foreach ($child_ids as $child_id) {
|
||||
$ids[] = $child_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
public static function channel_add($post){
|
||||
$now = time();
|
||||
$data['createtime'] = $now;
|
||||
$data['updatetime'] = $now;
|
||||
$data['name']=$post['name'];
|
||||
$data['sort']=$post['sort'];
|
||||
$data['pid']=$post['pid'];
|
||||
$datas = Db::name('staffchannel')->insertGetId($data);
|
||||
return $datas;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
488
application/admin/logic/DistributionMemberLogic.php
Normal file
488
application/admin/logic/DistributionMemberLogic.php
Normal file
@@ -0,0 +1,488 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\DistributionMemberApply;
|
||||
use app\admin\model\User;
|
||||
use app\common\model\DistributionMember;
|
||||
use app\common\model\DistributionOrder;
|
||||
use app\common\model\Withdraw;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class DistributionMemberLogic
|
||||
{
|
||||
/**
|
||||
* 分销会员列表
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function memberLists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['is_distribution', '=', 1];
|
||||
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
||||
$keyword = $get['keyword'];
|
||||
if ($get['search_key'] == 'mobile') {
|
||||
$where[] = ['mobile', 'like', '%' . $keyword . '%'];
|
||||
} else {
|
||||
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
|
||||
}
|
||||
}
|
||||
//分销状态
|
||||
if (isset($get['freeze_distribution']) && $get['freeze_distribution'] != '') {
|
||||
$where[] = ['freeze_distribution', '=', $get['freeze_distribution']];
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$count = $user->where($where)->count();
|
||||
|
||||
$lists = $user
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['fans', 'distribution_order'])
|
||||
->hidden(['password,pay_password,salt'])
|
||||
->order('id desc')
|
||||
->select()->toArray();
|
||||
|
||||
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
|
||||
$leader_ids = array_column($lists, 'first_leader');
|
||||
$leaders = Db::name('user')
|
||||
->where('id', 'in', $leader_ids)
|
||||
->column('sn,nickname,mobile,level', 'id');
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['level'] = $user_level[$item['level']] ?? '无等级';
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['leader'] = $leaders[$item['first_leader']] ?? [];
|
||||
if (!empty($item['leader'])) {
|
||||
$leader_level = $item['leader']['level'] ?? 0;
|
||||
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
|
||||
}
|
||||
$item['distribution_num'] = $item['distribution_order']['num'] ?? 0;//分销订单数
|
||||
$item['distribution_amount'] = $item['distribution_order']['amount'] ?? 0;//分销订单金额
|
||||
$item['distribution_money'] = $item['distribution_order']['money'] ?? 0;//分销佣金
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销会员审核列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function auditLists($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
||||
$keyword = $get['keyword'];
|
||||
if ($get['search_key'] == 'mobile') {
|
||||
$where[] = ['u.mobile', 'like', '%' . $keyword . '%'];
|
||||
} else {
|
||||
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
|
||||
}
|
||||
}
|
||||
//审核状态
|
||||
if (isset($get['status']) && $get['status'] != '') {
|
||||
$where[] = ['status', '=', $get['status']];
|
||||
}
|
||||
|
||||
|
||||
$field = [
|
||||
'a.*', 'u.sn', 'u.nickname', 'u.mobile', 'u.level', 'u.sex', 'a.reason',
|
||||
'u.create_time' => 'register_time', 'u.avatar', 'u.first_leader'
|
||||
];
|
||||
|
||||
$count = Db::name('distribution_member_apply a')
|
||||
->join('user u', 'u.id = a.user_id')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = Db::name('distribution_member_apply a')
|
||||
->field($field)
|
||||
->join('user u', 'u.id = a.user_id')
|
||||
->order('a.id desc')
|
||||
->page($get['page'], $get['limit'])
|
||||
->where($where)
|
||||
->select();
|
||||
|
||||
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
|
||||
|
||||
$leader_ids = array_column($lists, 'first_leader');
|
||||
$leaders = Db::name('user')
|
||||
->where('id', 'in', $leader_ids)
|
||||
->column('sn,nickname,mobile,level', 'id');
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['level'] = $user_level[$item['level']] ?? '无等级';
|
||||
$item['sex'] = self::getSexText($item['sex']);
|
||||
$item['register_time'] = date('Y-m-d H:i:s', $item['register_time']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['status_text'] = DistributionMember::getApplyStatus($item['status']);
|
||||
$item['leader'] = $leaders[$item['first_leader']] ?? [];
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
if (!empty($item['leader'])) {
|
||||
$leader_level = $item['leader']['level'] ?? 0;
|
||||
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
public static function getSexText($value)
|
||||
{
|
||||
switch ($value) {
|
||||
case 1:
|
||||
return '男';
|
||||
case 2:
|
||||
return '女';
|
||||
default:
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function auditPass($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$apply = DistributionMemberApply::where('id', $post['id'])->find();
|
||||
$apply->status = DistributionMember::STATUS_AUDIT_SUCCESS;
|
||||
$apply->update_time = time();
|
||||
$apply->save();
|
||||
|
||||
$user = \app\admin\model\User::where('id', $apply['user_id'])->find();
|
||||
$user->is_distribution = 1;
|
||||
$user->save();
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核拒绝
|
||||
* @param $post
|
||||
*/
|
||||
public static function auditRefuse($post)
|
||||
{
|
||||
$apply = DistributionMemberApply::where('id', $post['id'])->find();
|
||||
$apply->status = DistributionMember::STATUS_AUDIT_ERROR;
|
||||
$apply->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结/解冻分销会员资格
|
||||
* @param $post
|
||||
*/
|
||||
public static function freeze($post)
|
||||
{
|
||||
$user = User::where('id', $post['id'])->find();
|
||||
$user->freeze_distribution = 1;
|
||||
if ($post['type'] == 'unfreeze'){
|
||||
$user->freeze_distribution = 0;
|
||||
}
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销会员信息
|
||||
* @param $get
|
||||
* @return User
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getMemberInfo($get)
|
||||
{
|
||||
$user_id = $get['id'];
|
||||
$user_model = new User();
|
||||
$user = $user_model->alias('u')
|
||||
->field('u.*,u.sn as user_sn')
|
||||
->leftJoin('distribution_order_goods d', 'd.user_id = u.id')
|
||||
->where('u.id', $user_id)
|
||||
->append(['distribution_order'])
|
||||
->hidden(['password', 'pay_password', 'salt'])
|
||||
->find();
|
||||
|
||||
$user['distribution_text'] = '否';
|
||||
if ($user['is_distribution'] == 1) {
|
||||
$user['distribution_text'] = '是';
|
||||
}
|
||||
|
||||
//上级编号
|
||||
$user['first_leader_sn'] = Db::name('user')
|
||||
->where('id', $user['first_leader'])
|
||||
->value('sn');
|
||||
//直推会员数
|
||||
$user['first_fans'] = Db::name('user')
|
||||
->where(['first_leader' => $user_id, 'del' => 0])
|
||||
->count();
|
||||
|
||||
$have_withdraw = Db::name('withdraw_apply')
|
||||
->where(['status' => Withdraw::STATUS_SUCCESS, 'user_id' => $user_id])
|
||||
->sum('money');
|
||||
|
||||
$user['distribution_num'] = $user['distribution_order']['num'] ?? 0;//分销订单数
|
||||
$user['distribution_amount'] = $user['distribution_order']['amount'] ?? 0;//分销订单金额
|
||||
$user['distribution_money'] = $user['distribution_order']['money'] ?? 0;//分销佣金
|
||||
$user['have_withdraw'] = $have_withdraw;//已提现金额
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 粉丝列表(推广会员)
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function getFansLists($get)
|
||||
{
|
||||
$user_id = $get['id'];
|
||||
$where = [];
|
||||
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
||||
$keyword = $get['keyword'];
|
||||
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
|
||||
}
|
||||
|
||||
$fans_type = $get['type'] ?? 'all';
|
||||
if ($fans_type == 'all') {
|
||||
$where[] = ['', 'exp', Db::raw("FIND_IN_SET($user_id, ancestor_relation)")];
|
||||
} else {
|
||||
$where[] = [$fans_type, '=', $user_id];
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$count = $user
|
||||
->where($where)
|
||||
->append(['fans', 'distribution_order'])
|
||||
->hidden(['password,pay_password,salt'])
|
||||
->count();
|
||||
|
||||
$lists = $user
|
||||
->where($where)
|
||||
->append(['fans', 'distribution_order'])
|
||||
->hidden(['password,pay_password,salt'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select()->toArray();
|
||||
|
||||
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
|
||||
$leader_ids = array_column($lists, 'first_leader');
|
||||
$leaders = Db::name('user')
|
||||
->where('id', 'in', $leader_ids)
|
||||
->column('sn,nickname,mobile,level', 'id');
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['leader'] = $leaders[$item['first_leader']] ?? [];
|
||||
if (!empty($item['leader'])) {
|
||||
$leader_level = $item['leader']['level'] ?? 0;
|
||||
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
|
||||
}
|
||||
$item['distribution_num'] = $item['distribution_order']['num'] ?? 0;//分销订单数
|
||||
$item['distribution_amount'] = $item['distribution_order']['amount'] ?? 0;//分销订单金额
|
||||
$item['distribution_money'] = $item['distribution_order']['money'] ?? 0;//分销佣金
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销收入明细
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getEarningsDetail($get)
|
||||
{
|
||||
$user_id = $get['id'];
|
||||
$where = [];
|
||||
$where[] = ['d.user_id', '=', $user_id];
|
||||
$where[] = ['d.status', '=', DistributionOrder::STATUS_SUCCESS];
|
||||
|
||||
//记录时间
|
||||
if (isset($get['start_time']) && $get['start_time'] != '') {
|
||||
$where[] = ['d.create_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
if (isset($get['end_time']) && $get['end_time'] != '') {
|
||||
$where[] = ['d.create_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$count = Db::name('distribution_order_goods')->alias('d')
|
||||
->field('d.id as distribution_id, d.sn, o.order_sn, d.money, d.create_time')
|
||||
->join('order_goods og', 'og.id = d.order_goods_id')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = Db::name('distribution_order_goods')->alias('d')
|
||||
->field('d.id as distribution_id, d.sn, o.order_sn, d.money, d.create_time')
|
||||
->join('order_goods og', 'og.id = d.order_goods_id')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['type'] = '分销佣金';
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取上级名称和编号
|
||||
* @param $user_id
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getLeaderInfo($user_id)
|
||||
{
|
||||
$first_leader = Db::name('user u')
|
||||
->field('u1.nickname,u1.sn')
|
||||
->join('user u1', 'u1.id = u.first_leader')
|
||||
->where('u.id', $user_id)
|
||||
->find();
|
||||
|
||||
$leader_data = '无';
|
||||
if ($first_leader) {
|
||||
$leader_data = $first_leader['nickname'] . '(' . $first_leader['sn'] . ')';
|
||||
}
|
||||
return $leader_data;
|
||||
}
|
||||
|
||||
|
||||
//更新关系
|
||||
public static function updateRelation($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try{
|
||||
|
||||
$user_id = $post['user_id'];//需要调整上级的user_id
|
||||
$referrer_sn = $post['referrer_sn'];//新上级推荐人编号
|
||||
|
||||
//清空上级
|
||||
$data = [
|
||||
'first_leader' => 0,
|
||||
'second_leader' => 0,
|
||||
'third_leader' => 0,
|
||||
'ancestor_relation' => '',
|
||||
];
|
||||
$my_leader_id = 0;
|
||||
$my_first_leader = 0;
|
||||
$my_ancestor_relation = '';
|
||||
|
||||
if ($post['change_type'] == 'appoint'){
|
||||
//指定上级
|
||||
$my_leader = Db::name('user')->where(['sn' => $referrer_sn])->find();
|
||||
|
||||
//更新我的第一上级、第二上级、第三上级、关系链
|
||||
$my_leader_id = $my_leader['id'];
|
||||
$my_first_leader = $my_leader['first_leader'];
|
||||
$my_third_leader = $my_leader['second_leader'];
|
||||
$my_ancestor_relation = trim("{$my_leader_id},{$my_leader['ancestor_relation']}", ',');
|
||||
$data = [
|
||||
'first_leader' => $my_leader_id,
|
||||
'second_leader' => $my_first_leader,
|
||||
'third_leader' => $my_third_leader,
|
||||
'ancestor_relation' => $my_ancestor_relation,
|
||||
];
|
||||
}
|
||||
|
||||
Db::name('user')->where(['id' => $user_id])->update($data);
|
||||
|
||||
//更新我向下一级的第二上级、第三上级
|
||||
$data = [
|
||||
'second_leader' => $my_leader_id,
|
||||
'third_leader' => $my_first_leader,
|
||||
];
|
||||
Db::name('user')->where(['first_leader' => $user_id])->update($data);
|
||||
|
||||
//更新我向下二级的第三级
|
||||
$data = [
|
||||
'third_leader' => $my_leader_id,
|
||||
];
|
||||
Db::name('user')->where(['second_leader' => $user_id])->update($data);
|
||||
|
||||
|
||||
//更新与我相关的所有关系链
|
||||
Db::name('user')
|
||||
->where("find_in_set({$user_id},ancestor_relation)")
|
||||
->exp('ancestor_relation', "replace(ancestor_relation,'{$user_id}','" . trim("{$user_id},{$my_ancestor_relation}", ',') . "')")
|
||||
->update();
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 添加分销会员
|
||||
* @author 张无忌(2021/1/11 16:49)
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function addMember($post)
|
||||
{
|
||||
$userModel = new User();
|
||||
// 根据会员编号查询用户
|
||||
$user = $userModel->field('id,sn,is_distribution,distribution_add_remarks,del')
|
||||
->where(['sn'=>$post['sn']])->find();
|
||||
// 校验用户
|
||||
if (!$user) { return '该用户不存在!'; }
|
||||
if ($user['del'] === 1) { return '该用户已被删除!'; }
|
||||
if ($user['is_distribution']) { return '该用户已是分销会员,无需重复添加'; }
|
||||
try {
|
||||
// 更新用户为分销会员
|
||||
$result = $userModel->where(['id' => (int)$user['id']])->update([
|
||||
'is_distribution' => 1,
|
||||
'distribution_add_remarks' => $post['remarks']
|
||||
]);
|
||||
return $result ? true : '添加失败';
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
186
application/admin/logic/ExpressLogic.php
Normal file
186
application/admin/logic/ExpressLogic.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class ExpressLogic
|
||||
{
|
||||
/**
|
||||
* 列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
|
||||
if (isset($get['express_name']) && $get['express_name'] != '') {
|
||||
$where[] = ['name', 'like', '%' . $get['express_name'] . '%'];
|
||||
}
|
||||
|
||||
$count = Db::name('express')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = Db::name('express')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['icon'] = UrlServer::getFileUrl($item['icon']);
|
||||
}
|
||||
|
||||
return ['lists' => $lists, 'count' => $count];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param $post
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function addExpress($post)
|
||||
{
|
||||
$time = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'website' => $post['website'],
|
||||
'code' => $post['code'],
|
||||
'code100' => $post['code100'],
|
||||
'codebird' => $post['codebird'],
|
||||
'sort' => $post['sort'],
|
||||
'create_time' => $time
|
||||
];
|
||||
$result = Db::name('express')->insert($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
* @param $id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
$detail = Db::name('express')->where(['id' => $id, 'del' => 0])->find();
|
||||
$detail['abs_icon'] = UrlServer::getFileUrl($detail['icon']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function editExpress($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'icon' => $post['icon'],
|
||||
'website' => $post['website'],
|
||||
'code' => $post['code'],
|
||||
'code100' => $post['code100'],
|
||||
'codebird' => $post['codebird'],
|
||||
'sort' => $post['sort'],
|
||||
'update_time' => time()
|
||||
];
|
||||
Db::name('express')->where(['id' => $post['id']])->update(['name' => $post['name'],]);
|
||||
$result = Db::name('express')->where(['id' => $post['id']])->update($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $delData
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function delExpress($delData)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('express')->where(['del' => 0, 'id' => $delData])->update($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getExpress()
|
||||
{
|
||||
$config = [
|
||||
'way' => ConfigServer::get('express', 'way', 'kd100'),
|
||||
'kd100_appkey' => ConfigServer::get('kd100', 'appkey', ''),
|
||||
'kd100_customer' => ConfigServer::get('kd100', 'appsecret', ''),
|
||||
'kdniao_appkey' => ConfigServer::get('kdniao', 'appkey', ''),
|
||||
'kdniao_ebussinessid' => ConfigServer::get('kdniao', 'appsecret', ''),
|
||||
'kdniao_type' => ConfigServer::get('kdniao', 'type', 'free'),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
//快递100
|
||||
public static function kd100(){
|
||||
$config = [
|
||||
'appkey' => ConfigServer::get('kd100', 'appkey', ''),
|
||||
'appsecret' => ConfigServer::get('kd100', 'appsecret', ''),
|
||||
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
//快递鸟
|
||||
public static function kdniao(){
|
||||
$res=[
|
||||
'appkey2' => ConfigServer::get('kdniao', 'appkey', ''),
|
||||
'appsecret2' => ConfigServer::get('kdniao', 'appsecret', ''),
|
||||
];
|
||||
return $res;
|
||||
}
|
||||
//快递方式
|
||||
public static function way(){
|
||||
$way = ConfigServer::get('express', 'way', '');
|
||||
return $way;
|
||||
}
|
||||
|
||||
}
|
||||
242
application/admin/logic/FileNewLogic.php
Normal file
242
application/admin/logic/FileNewLogic.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\model\FileCate;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class FileNewLogic
|
||||
{
|
||||
public static function lists($get)
|
||||
{
|
||||
$field = 'id,name,uri';
|
||||
$where = [
|
||||
'del' => 0,
|
||||
'partner_id' => $get['partner_id'],
|
||||
'type' => FileCate::getTypeNumber($get['type']),
|
||||
'cate_id' => $get['cate_id']
|
||||
];
|
||||
$lists = Db::name('file')->field($field)->where($where)->page($get['page_no'], $get['page_size'])->select();
|
||||
$count = Db::name('file')->where($where)->count();
|
||||
foreach($lists as &$item) {
|
||||
$item['uri'] = UrlServer::getFileUrl($item['uri']);
|
||||
}
|
||||
return ['lists'=>$lists, 'count'=>$count];
|
||||
}
|
||||
|
||||
public static function pagelists($get)
|
||||
{
|
||||
$field = 'id,name,uri';
|
||||
$where = [
|
||||
['del', '=', 0],
|
||||
['partner_id', '=', $get['partner_id']],
|
||||
['type', '=', FileCate::getTypeNumber($get['type'])]
|
||||
];
|
||||
if($get['cate_id']) {
|
||||
// 查找子分类,属于当前分类或当前分类下的子分类的文件都显示出来
|
||||
$child = self::getChildren($get['cate_id']);
|
||||
$child[] = intval($get['cate_id']);
|
||||
$where[] = ['cate_id', 'in', $child];
|
||||
}
|
||||
$lists = Db::name('file')->field($field)->where($where)->page($get['page_no'], $get['page_size'])->select();
|
||||
$count = Db::name('file')->where($where)->count();
|
||||
foreach($lists as &$item) {
|
||||
$item['uri'] = UrlServer::getFileUrl($item['uri']);
|
||||
}
|
||||
return ['lists'=>$lists, 'count'=>$count, 'page_no'=>$get['page_no'], 'page_size'=>$get['page_size']];
|
||||
}
|
||||
|
||||
public static function addCate($post)
|
||||
{
|
||||
// 同级别不允许有同名分类
|
||||
$fileCate = FileCate::where([
|
||||
'del' => 0,
|
||||
'name' => $post['name'],
|
||||
'pid' => $post['pid']
|
||||
])->select()->toArray();
|
||||
if($fileCate) {
|
||||
return ['flag'=>false, 'msg'=>'同级别下已存在同名分类'];
|
||||
}
|
||||
// 分类不允许超过3级
|
||||
if(!empty($post['pid'])) {
|
||||
$level = FileCate::where(['id'=>$post['pid']])->value('level');
|
||||
if($level > 2) {
|
||||
return ['flag'=>false, 'msg'=>'分类不允许超过3级'];
|
||||
}
|
||||
$level = $level + 1;
|
||||
}else{
|
||||
$post['pid'] = 0;
|
||||
$level = 1;
|
||||
}
|
||||
switch($post['type']) {
|
||||
case 'video':
|
||||
$post['type'] = 2;
|
||||
break;
|
||||
}
|
||||
$post['level'] = $level;
|
||||
$post['create_time'] = time();
|
||||
$result = FileCate::create($post);
|
||||
if($result) {
|
||||
return ['flag'=>true, 'msg'=>'添加成功'];
|
||||
}else{
|
||||
return ['flag'=>false, 'msg'=>'添加失败'];
|
||||
}
|
||||
}
|
||||
|
||||
public static function editCate($post)
|
||||
{
|
||||
if(empty($post['pid'])) {
|
||||
$post['pid'] = 0;
|
||||
$pidLevel = 1;
|
||||
}
|
||||
// 同级分类下不允许重名
|
||||
$pidChildren = FileCate::where([
|
||||
['pid', '=', $post['pid']],
|
||||
['del', '=', 0],
|
||||
['id', '<>', $post['id']],
|
||||
['name', '=', $post['name']]
|
||||
])->select()->toArray();
|
||||
if($pidChildren) {
|
||||
return ['flag'=>false, 'msg'=>'同级下已存在该名称的分类'];
|
||||
}
|
||||
// 上级不能是自身或自己的子分类
|
||||
$children = self::getChildren($post['id']);
|
||||
if($post['pid'] == $post['id'] || in_array($post['pid'], $children)) {
|
||||
return ['flag'=>false, 'msg'=>'上级分类不能为自身或自己的子分类'];
|
||||
}
|
||||
// 分类层级不能超过3级
|
||||
$level = self::calcLevel($post['id']);
|
||||
$pidLevel = FileCate::where('id', $post['pid'])->value('level');
|
||||
if($level + $pidLevel > 3) {
|
||||
return ['flag'=>false, 'msg'=>'分类层级不允许超过3级'];
|
||||
}
|
||||
FileCate::where('id', $post['id'])->update([
|
||||
'name'=>trim($post['name']),
|
||||
'sort' => $post['sort'],
|
||||
'pid' => $post['pid'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
self::updateLevel($post['id']);
|
||||
|
||||
return ['flag'=>true, 'msg'=>'编辑成功'];
|
||||
}
|
||||
|
||||
public static function delCate($post)
|
||||
{
|
||||
// 分类下还有子分类不允许删除
|
||||
$children = FileCate::where([
|
||||
'del' => 0,
|
||||
'pid' => $post['id']
|
||||
])->select()->toArray();
|
||||
if($children) {
|
||||
return ['flag'=>false, 'msg'=>'该分类下还有子分类不允许删除'];
|
||||
}
|
||||
// 有文件正在使用该分类不允许删除
|
||||
$files = Db::name('file')->where(['del'=>0, 'cate_id'=>$post['id']])->select();
|
||||
if($files) {
|
||||
return ['flag'=>false, 'msg'=>'有文件正在使用该分类不允许删除'];
|
||||
}
|
||||
FileCate::where(['id'=>$post['id']])->update(['del'=>1, 'update_time'=>time()]);
|
||||
return ['flag'=>true, 'msg'=>'删除成功'];
|
||||
}
|
||||
|
||||
public static function getChildren($id)
|
||||
{
|
||||
$child = [];
|
||||
$firstChild = FileCate::where(['del'=>0, 'pid'=>$id])->column('id');
|
||||
$child = $firstChild;
|
||||
foreach($firstChild as $firstId) {
|
||||
$secordChild = FileCate::where(['del'=>0, 'pid'=>$firstId])->column('id');
|
||||
$child = array_merge($child, $secordChild);
|
||||
}
|
||||
return $child;
|
||||
}
|
||||
|
||||
public static function calcLevel($id)
|
||||
{
|
||||
$level = 1;
|
||||
$two_ids = FileCate::where(['pid' => $id, 'del' => 0])->column('id');
|
||||
if ($two_ids) {
|
||||
$level = 2;
|
||||
$three_ids = FileCate::where([
|
||||
['del', '=', 0],
|
||||
['pid', 'in', $two_ids]
|
||||
])->column('id');
|
||||
if ($three_ids) $level = 3;
|
||||
}
|
||||
return $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新自己及后代分类的level
|
||||
*/
|
||||
public static function updateLevel($id)
|
||||
{
|
||||
$me = FileCate::find($id);
|
||||
if($me['pid'] == 0) { // 上级为顶级分类
|
||||
FileCate::update([
|
||||
'id' => $id,
|
||||
'level' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
$two_ids = FileCate::where([
|
||||
'pid' => $id,
|
||||
'del' => 0
|
||||
])->column('id');
|
||||
if($two_ids) {
|
||||
FileCate::where('id', 'in', $two_ids)->update([
|
||||
'level' => 2,
|
||||
'update_time' => time()
|
||||
]);
|
||||
$three_ids = FileCate::where([
|
||||
['pid', 'in', $two_ids],
|
||||
['del', '=', 0]
|
||||
])->column('id');
|
||||
if($three_ids) {
|
||||
FileCate::where('id', 'in', $three_ids)->update([
|
||||
'level' => 3,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$parent = FileCate::find($me['pid']);
|
||||
if($parent['level'] == 1) {
|
||||
FileCate::update([
|
||||
'id' => $id,
|
||||
'level' => 2,
|
||||
'update_time' => time()
|
||||
]);
|
||||
$three_ids = FileCate::where([
|
||||
'pid' => $id,
|
||||
'del' => 0
|
||||
])->column('id');
|
||||
if($three_ids) {
|
||||
FileCate::where('id', 'in', $three_ids)->update([
|
||||
'level' => 3,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
}else if($parent['level'] == 2){
|
||||
FileCate::update([
|
||||
'id' => $id,
|
||||
'level' => 3,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function delFile($post)
|
||||
{
|
||||
try{
|
||||
$result = Db::name('file')->where('id', 'in', $post['ids'])->update([
|
||||
'del' => 1
|
||||
]);
|
||||
return true;
|
||||
}catch(\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
284
application/admin/logic/FinanceLogic.php
Normal file
284
application/admin/logic/FinanceLogic.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\model\DistributionOrder;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\Pay;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\model\Withdraw;
|
||||
use think\Db;
|
||||
|
||||
class FinanceLogic
|
||||
{
|
||||
public static function lists()
|
||||
{
|
||||
//本月订单金额
|
||||
$month_order_amount = Db::name('order')
|
||||
->where(['pay_status' => Pay::ISPAID, 'refund_status' => OrderGoods::REFUND_STATUS_NO])
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
|
||||
//订单总金额
|
||||
$order = Db::name('order')
|
||||
->field('sum(order_amount) as amount, count(id) as num')
|
||||
->where('pay_status' , 'in', [Pay::ISPAID, Pay::REFUNDED])
|
||||
->find();
|
||||
|
||||
//退款订单
|
||||
$refund_order = Db::name('order_refund')
|
||||
->field('sum(refund_amount) as amount, count(id) as num')
|
||||
->where(['refund_status' => 1])
|
||||
->find();
|
||||
|
||||
//会员相关
|
||||
$user = Db::name('user')
|
||||
->field('sum(user_money) as money, sum(user_integral) as integral, sum(earnings) as earnings')
|
||||
->where(['del' => 0])
|
||||
->find();
|
||||
|
||||
//已提现佣金
|
||||
$have_withdraw_earnings = Db::name('withdraw_apply')
|
||||
->where(['status' => Withdraw::STATUS_SUCCESS])
|
||||
->sum('money');
|
||||
|
||||
//提现中
|
||||
$wait_withdraw_earnings = Db::name('withdraw_apply')
|
||||
->where(['status' => Withdraw::STATUS_ING])
|
||||
->sum('money');
|
||||
|
||||
|
||||
//本月分销佣金金额
|
||||
$month_earnings = Db::name('distribution_order_goods')
|
||||
->where('status', '<>', DistributionOrder::STATUS_ERROR)
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('money');
|
||||
|
||||
//分销佣金总佣金
|
||||
$distribution_earnings = Db::name('distribution_order_goods')
|
||||
->where('status', '<>', DistributionOrder::STATUS_ERROR)
|
||||
->sum('money');
|
||||
|
||||
return [
|
||||
'month_order_amount' => round($month_order_amount, 2),
|
||||
'total_amount' => round($order['amount'], 2),
|
||||
'order_num' => $order['num'] ?? 0,
|
||||
'refund_amount' => round($refund_order['amount'], 2),
|
||||
'refund_num' => $refund_order['num'] ?? 0,
|
||||
|
||||
'total_user_money' => round($user['money'], 2),
|
||||
'total_user_integral' => $user['integral'] ?? 0,
|
||||
'able_earnings' => round($user['earnings'], 2),
|
||||
'have_withdraw_earnings' => round($have_withdraw_earnings, 2),
|
||||
|
||||
'month_earnings' => round($month_earnings, 2),
|
||||
'distribution_earnings' => round($distribution_earnings, 2),
|
||||
'wait_earnings' => round($wait_withdraw_earnings, 2),
|
||||
];
|
||||
}
|
||||
|
||||
public static function acctypelist($get){
|
||||
$user_count = Db::name('finance_type')
|
||||
->count();
|
||||
$user_list = Db::name('finance_type')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['time']=date("Y-m-d H:i:s",$item['time']);
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
public static function acctypeadd($post){
|
||||
$data = [
|
||||
'name' =>$post['name'],
|
||||
'time' =>time(),
|
||||
];
|
||||
return Db::name('finance_type')->data($data)->insert();
|
||||
}
|
||||
|
||||
public static function typelist(){
|
||||
return Db::name('finance_type')->select();
|
||||
}
|
||||
//
|
||||
public static function add($post){
|
||||
$post['create_time']=time();
|
||||
$post['user_id']=$post['order_id'];
|
||||
return Db::name('finance')->insert($post);
|
||||
}
|
||||
//
|
||||
public static function fidlists($get){
|
||||
$where=[];
|
||||
if (isset($get['staffid']) && $get['staffid']) {
|
||||
$where[] = ['user_id','=',$get['staffid']];
|
||||
}
|
||||
if (isset($get['type']) && $get['type']) {
|
||||
$where[] = ['brand_id','=',$get['type']];
|
||||
}
|
||||
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$fidlists = Db::name('finance')->where($where)
|
||||
->count();
|
||||
$fidlists_list = Db::name('finance')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($fidlists_list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$staff=Db::name('order_exe')->where('id',$item['order_id'])->find(); //获取订单的基本信息
|
||||
if($staff){
|
||||
$item['time']=date('Y-m-d',$staff['autotime']);
|
||||
$order=Db::name('order')->where('order_sn',$staff['order_sn'])->find(); //获取主订单信息
|
||||
|
||||
if($order){
|
||||
$item['adder']=$order['address'];
|
||||
}
|
||||
$goods=Db::name('goods')->where('id',$staff['goods_id'])->find(); //判断套餐名称
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
}
|
||||
$user=Db::name('staff')->where('id', $staff['staff_id'])->find(); //判断员工信息
|
||||
if($user){
|
||||
$item['staff_name']=$user['name'];
|
||||
$item['staff_phone']=$user['mobile'];
|
||||
}
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
if($admin){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}
|
||||
|
||||
$type=Db::name('finance_type')->where('id',$item['brand_id'])->find();
|
||||
if($type){
|
||||
$item['type_name']=$type['name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return ['count'=>$fidlists , 'lists'=>$fidlists_list];
|
||||
}
|
||||
//
|
||||
public static function info($id){
|
||||
$info['base'] = Db::name('finance')
|
||||
->where(['id' => $id])
|
||||
->withAttr('image', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['image']);
|
||||
})
|
||||
->withAttr('content', function ($value){
|
||||
$preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
|
||||
$local_url = UrlServer::getFileUrl('/');
|
||||
return preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
|
||||
})
|
||||
->append(['abs_avatar','abs_video'])->find();
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function eidt($post){
|
||||
return Db::name('finance')->where('id',$post['id'])->data($post)->update();
|
||||
|
||||
}
|
||||
|
||||
public static function stafftime($get){
|
||||
$where=[];
|
||||
if (isset($get['staffid']) && $get['staffid']) {
|
||||
$where[]=['user_id','=',$get['staffid']];
|
||||
}
|
||||
if (isset($get['pay_status']) && $get['pay_status']) {
|
||||
$where[] = ['pay_status','=',$get['pay_status']];
|
||||
}
|
||||
if (isset($get['admin_id']) && $get['admin_id']) {
|
||||
$where[] = ['admin_id','=',$get['admin_id']];
|
||||
}
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['phone', 'like', '%' . $get['phone'] . '%'];
|
||||
}
|
||||
//增加时间检索
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
|
||||
$fidlists = Db::name('order_timeadd')->where($where)
|
||||
->count();
|
||||
$fidlists_list = Db::name('order_timeadd')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($fidlists_list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$staff=Db::name('order_exe')->where('id',$item['orderid'])->find(); //获取订单的基本信息
|
||||
if(!empty($staff)){
|
||||
$item['order_id']=$staff['id'];
|
||||
$item['order_name']=$staff['name'];
|
||||
$item['order_phone']=$staff['phone'];
|
||||
$item['order_time']=date('Y-m-d',$staff['autotime']);
|
||||
$user=Db::name('staff')->where('id', $staff['staff_id'])->find();
|
||||
if($user){
|
||||
$item['staff_name']=$user['name'];
|
||||
$item['staff_phone']=$user['mobile'];
|
||||
}else{
|
||||
$item['staff_name']='-';
|
||||
$item['staff_phone']='-';
|
||||
}
|
||||
}
|
||||
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
if(!empty($admin)){
|
||||
$item['admin_name']=$admin['name'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($item['admin_id']=='0'){
|
||||
$user_adder=Db::name('user_address')->where('telephone',$staff['phone'])->find();
|
||||
if($user_adder){
|
||||
$date=Db::name('order_timeadd')->where('id',$item['id'])->update(['admin_id'=>$user_adder['admin_id'],'name'=>$staff['name'],'phone'=>$staff['phone']]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$fidlists , 'lists'=>$fidlists_list];
|
||||
}
|
||||
|
||||
public static function stafftimeinfo($id){
|
||||
return Db::name('order_timeadd')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function editaddtimup($post){
|
||||
if($post['pay_type']==1){
|
||||
|
||||
return Db::name('order_timeadd')->where('id',$post['id'])->update(['pay_type'=>1]);
|
||||
}
|
||||
if($post['pay_type']==0){
|
||||
|
||||
return Db::name('order_timeadd')->where('id',$post['id'])->update(['pay_type'=>0,'pay'=>$post['pay']]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
137
application/admin/logic/FineLogic.php
Normal file
137
application/admin/logic/FineLogic.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class FineLogic
|
||||
{
|
||||
public static function type_add($post){
|
||||
$post['crem_time']=time();
|
||||
return Db::name('staff_fine')->data($post)->insert();
|
||||
}
|
||||
|
||||
public static function type($get){
|
||||
|
||||
$count = Db::name('staff_fine')
|
||||
->count();
|
||||
|
||||
$lists = Db::name('staff_fine')
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['crem_time']=date("Y-m-d H:i:s",$item['crem_time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
public static function type_fineinfo($id){
|
||||
return Db::name('staff_fine')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function type_eidt($post){
|
||||
return Db::name('staff_fine')->where('id',$post['id'])->update(['name'=>$post['name'],'amount'=>$post['amount'],'integral'=>$post['integral']]);
|
||||
}
|
||||
|
||||
public static function type_del($id){
|
||||
return Db::name('staff_fine')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
public static function type_lists(){
|
||||
return Db::name('staff_fine')->select();
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$post['create_time']=time();
|
||||
return Db::name('fine')->data($post)->insert();
|
||||
}
|
||||
|
||||
public static function lists($get){
|
||||
$where=[];
|
||||
|
||||
if(isset($get['staff_id']) && $get['staff_id'] != ''){
|
||||
$where[] = ['staff_id','=',$get['staff_id']];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$count = Db::name('fine')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$lists = Db::name('fine')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
if($staff){
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_mobile']=$staff['mobile'];
|
||||
}
|
||||
|
||||
$type=Db::name('staff_fine')->where('id',$item['type_id'])->find();
|
||||
if($type){
|
||||
$item['type_name']=$type['name'];
|
||||
}else{
|
||||
$item['type_name']='-';
|
||||
}
|
||||
|
||||
$order=Db::name('order_exe')->where('id',$item['order_id'])->find();
|
||||
if($order){
|
||||
$item['user_name']=$order['name'];
|
||||
$item['user_mobile']=$order['phone'];
|
||||
$goods=db::name('goods')->where('id',$order['goods_id'])->find();
|
||||
if($goods){
|
||||
$item['goods_name']= $goods['name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function fineinfo($id){
|
||||
return Db::name('fine')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function finedel($id){
|
||||
return Db::name('fine')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
public static function edit($post){
|
||||
return Db::name('fine')->where('id',$post['id'])->data($post)->update();
|
||||
}
|
||||
//审核员工的分
|
||||
public static function done($post){
|
||||
Db::name('fine')->where('id',$post['id'])->update(['status'=>1]);
|
||||
$staff=Db::name('staff')->where('id',$post['staff_id'])->find();
|
||||
Db::name('staff')->where('id',$post['staff_id'])->update(['number'=>$staff['number']-$post['integral']]);
|
||||
$data=[
|
||||
'staff_id'=>$post['staff_id'],
|
||||
'type' =>0,
|
||||
'ysjf' =>$staff['number'],
|
||||
'bdjf' =>$post['integral'],
|
||||
'type_name'=>'服务违规',
|
||||
'add_time'=>time()
|
||||
];
|
||||
if($staff['number']>10){
|
||||
db::name('staff')->where('id',$post['id'])->update(['state'=>1]);
|
||||
}else{
|
||||
db::name('staff')->where('id',$post['id'])->update(['state'=>0]);
|
||||
}
|
||||
Db::name('staff_points')->data($data)->insert();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
65
application/admin/logic/FootprintLogic.php
Normal file
65
application/admin/logic/FootprintLogic.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\Footprint;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class FootprintLogic
|
||||
{
|
||||
// 列表
|
||||
public static function lists()
|
||||
{
|
||||
$footprintModel = new Footprint();
|
||||
return $footprintModel->select();
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
public static function info($id)
|
||||
{
|
||||
$footprintModel = new Footprint();
|
||||
return $footprintModel->where(['id'=>(int)$id])->find();
|
||||
}
|
||||
|
||||
public static function edit($post)
|
||||
{
|
||||
try {
|
||||
$footprintModel = new Footprint();
|
||||
$footprintModel->where(['id' => (int)$post['id']])
|
||||
->update(['status' => $post['status']]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function set($post)
|
||||
{
|
||||
try {
|
||||
ConfigServer::set('footprint', 'footprint_duration', $post['duration']);
|
||||
ConfigServer::set('footprint', 'footprint_status', $post['status']);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
245
application/admin/logic/FreightLogic.php
Normal file
245
application/admin/logic/FreightLogic.php
Normal file
@@ -0,0 +1,245 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\common\model\Freight;
|
||||
use app\common\model\FreightConfig;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class FreightLogic
|
||||
{
|
||||
|
||||
public static function lists($get)
|
||||
{
|
||||
$freight = new Freight();
|
||||
$where = [];
|
||||
|
||||
if (isset($get['name']) && $get['name'] != '') {
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
|
||||
if (isset($get['charge_way']) && $get['charge_way'] != '') {
|
||||
$where[] = ['charge_way', '=', $get['charge_way']];
|
||||
}
|
||||
|
||||
$count = $freight->where($where)->count();
|
||||
$list = $freight
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['charge_way_text'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
if (!$list) {
|
||||
return ['count' => '', 'lists' => []];
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function add($post)
|
||||
{
|
||||
$freight = new Freight();
|
||||
$freight->name = $post['name'];
|
||||
$freight->charge_way = $post['charge_way'];
|
||||
$freight->remark = $post['remark'];
|
||||
$freight->allowField(true)->save();
|
||||
|
||||
$freight_config = new FreightConfig();
|
||||
|
||||
$config_data = [];
|
||||
foreach ($post as &$item) {
|
||||
if (is_array($item)) {
|
||||
$item = array_values($item);
|
||||
}
|
||||
}
|
||||
|
||||
$post = form_to_linear($post);
|
||||
foreach ($post as $v) {
|
||||
$v['freight_id'] = $freight->id;
|
||||
$v['create_time'] = time();
|
||||
$config_data[] = $v;
|
||||
}
|
||||
$freight_config->allowField(true)->insertAll($config_data);
|
||||
}
|
||||
|
||||
|
||||
public static function edit($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$freight = Freight::where(['id' => $post['id']])
|
||||
->with('configs')
|
||||
->find();
|
||||
|
||||
//删除之前保存的配置,再增加
|
||||
FreightConfig::where(['freight_id' => $freight['id']])->delete();
|
||||
|
||||
$freight->save([
|
||||
'name' => $post['name'],
|
||||
'charge_way' => $post['charge_way'],
|
||||
'remark' => $post['remark'],
|
||||
], ['id' => $freight['id']]);
|
||||
|
||||
|
||||
$config_data = [];
|
||||
foreach ($post as &$item) {
|
||||
if (is_array($item)) {
|
||||
$item = array_values($item);
|
||||
}
|
||||
}
|
||||
|
||||
$post = form_to_linear($post);
|
||||
|
||||
foreach ($post as $v) {
|
||||
$v['freight_id'] = $freight->id;
|
||||
$config_data[] = $v;
|
||||
}
|
||||
|
||||
$freight_config = new FreightConfig();
|
||||
$freight_config->allowField(true)->insertAll($config_data);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function del($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
Freight::where(['id' => $post['id']])->delete();
|
||||
FreightConfig::where(['freight_id' => $post['id']])->delete();
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function detail($id)
|
||||
{
|
||||
$freight = Freight::where(['id' => $id])
|
||||
->with('configs')
|
||||
->append(['charge_way_text'])
|
||||
->find()->toArray();
|
||||
|
||||
$regions = Db::name('dev_region')->column('name', 'id');
|
||||
|
||||
foreach ($freight['configs'] as &$item) {
|
||||
$item['region_name'] = '';
|
||||
|
||||
if ($item['region'] == 'all'){
|
||||
$item['region_name'] = '全国';
|
||||
continue;
|
||||
}
|
||||
|
||||
$region = explode(',', $item['region']);
|
||||
|
||||
foreach ($region as $v) {
|
||||
if (isset($regions[$v])) {
|
||||
$item['region_name'] .= $regions[$v] . ',';
|
||||
}
|
||||
}
|
||||
$item['region_name'] = rtrim($item['region_name'], ',');
|
||||
}
|
||||
return $freight;
|
||||
}
|
||||
|
||||
public static function areaTree()
|
||||
{
|
||||
$lists = Db::name('dev_region')
|
||||
->field('id,parent_id,level,name as title')
|
||||
->order('parent_id', 'desc')
|
||||
->select();
|
||||
|
||||
$result = self::areaSort($lists);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function areaSort(&$lists)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($lists as $k1 => $province) {
|
||||
if ($province['level'] == 1) {
|
||||
|
||||
//树形结构参数
|
||||
$province['checkArr']['type'] = 0;
|
||||
$province['checkArr']['checked'] = 0;
|
||||
$province['last'] = false;
|
||||
$province['parentId'] = -1;
|
||||
|
||||
//钓鱼岛这个没有下级
|
||||
if ($province['id'] == 900000) {
|
||||
$province['children'] = [];
|
||||
$province['last'] = true;
|
||||
}
|
||||
|
||||
$tree[$k1] = $province;
|
||||
unset($lists[$k1]);
|
||||
foreach ($lists as $k2 => $city) {
|
||||
$city['parentId'] = $city['parent_id'];
|
||||
if ($city['parentId'] == $province['id']) {
|
||||
foreach ($lists as $k3 => $district) {
|
||||
$district['parentId'] = $district['parent_id'];
|
||||
if ($district['parentId'] == $city['id']) {
|
||||
|
||||
//树形结构参数
|
||||
$district['checkArr']['type'] = 0;
|
||||
$district['checkArr']['checked'] = 0;
|
||||
$district['last'] = true;
|
||||
|
||||
$city['children'][] = $district;
|
||||
unset($lists[$k3]);
|
||||
}
|
||||
}
|
||||
|
||||
//树形结构参数
|
||||
$city['checkArr']['type'] = 0;
|
||||
$city['checkArr']['checked'] = 0;
|
||||
$city['last'] = false;
|
||||
|
||||
$tree[$k1]['children'][] = $city;
|
||||
unset($lists[$k2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_values($tree);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* note 获取全部运费模板
|
||||
*/
|
||||
public static function getFreightList()
|
||||
{
|
||||
return Db::name('freight')->field('id,name')->select();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
109
application/admin/logic/GoodsBrandLogic.php
Normal file
109
application/admin/logic/GoodsBrandLogic.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
|
||||
class GoodsBrandLogic
|
||||
{
|
||||
//列表
|
||||
public static function lists($get)
|
||||
{
|
||||
$where[] = ['del','=',0];
|
||||
|
||||
if(isset($get['name']) && $get['name']){
|
||||
$where[] = ['name','like','%'.$get['name'].'%'];
|
||||
}
|
||||
|
||||
$count = Db::name('goods_brand')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('goods_brand')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order(['sort' => 'desc', 'id'=>'desc'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count' => $count,'list' => $lists];
|
||||
}
|
||||
//添加
|
||||
public static function add($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'initial' => $post['initial'],
|
||||
'image' => $post['image'],
|
||||
'sort' => $post['sort'],
|
||||
'is_show' => $post['is_show'],
|
||||
'remark' => $post['remark'],
|
||||
'del' => 0,
|
||||
'create_time' => time()
|
||||
];
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_brand')->insert($data);
|
||||
}
|
||||
|
||||
//获取单个品牌
|
||||
public static function getGoodsBrand($id)
|
||||
{
|
||||
$detail = Db::name('goods_brand')->where(['id' => $id])->find();
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
|
||||
}
|
||||
|
||||
//编辑品牌
|
||||
public static function edit($post,$id)
|
||||
{
|
||||
$update_data = [
|
||||
'name' => $post['name'],
|
||||
'initial' => $post['initial'],
|
||||
'image' => $post['image'],
|
||||
'sort' => $post['sort'],
|
||||
'is_show' => $post['is_show'],
|
||||
'remark' => $post['remark'],
|
||||
'del' => 0,
|
||||
'update_time' => time()
|
||||
];
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_brand')->where(['id' => $id])->update($update_data);
|
||||
}
|
||||
|
||||
//删除品牌
|
||||
public static function del($id)
|
||||
{
|
||||
$update_data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_brand')->where(['del' => 0, 'id' => $id])->update($update_data);
|
||||
}
|
||||
//更新品牌状态
|
||||
public static function switchStatus($data)
|
||||
{
|
||||
$update_data = [
|
||||
'is_show' => $data['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_brand')->where(['del' =>0,'id' =>$data['id']])->update($update_data);
|
||||
}
|
||||
//获取品牌列表
|
||||
public static function getGoodsBrandList(){
|
||||
return Db::name('goods_brand')->where(['del'=>0])->field('id,name')->select();
|
||||
}
|
||||
|
||||
public static function getGoodsBrandLists(){
|
||||
return Db::name('goods_brand')->where(['del'=>0])->where('id','<>',5)->field('id,name')->select();
|
||||
}
|
||||
}
|
||||
318
application/admin/logic/GoodsCategoryLogic.php
Normal file
318
application/admin/logic/GoodsCategoryLogic.php
Normal file
@@ -0,0 +1,318 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use app\admin\model\GoodsCategory;
|
||||
use think\facade\Cache;
|
||||
|
||||
class GoodsCategoryLogic
|
||||
{
|
||||
/**
|
||||
* Desc: 添加商品分类
|
||||
* @param $post array 分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
$level = 0;
|
||||
if ($post['pid']) {
|
||||
$level = Db::name('goods_category')->where(['id' => $post['pid']], ['del' => 0])->value('level');
|
||||
}
|
||||
$is_recommend = $post['is_recommend'] ?? 0;
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'pid' => $post['pid'],
|
||||
'sort' => $post['sort'],
|
||||
'is_show' => $post['is_show'],
|
||||
'image' => $post['image'],
|
||||
'level' => $level + 1,
|
||||
'is_recommend' => $post['pid'] == 0 ? $is_recommend : 0,
|
||||
'remark' => $post['remark'],
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_category')->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 编辑商品分类
|
||||
* @param $post array 分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
$level = 0;
|
||||
if ($post['pid']) {
|
||||
$level = Db::name('goods_category')->where(['id' => $post['pid']], ['del' => 0])->value('level');
|
||||
}
|
||||
$is_recommend = $post['is_recommend'] ?? 0;
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'sort' => $post['sort'],
|
||||
'is_show' => $post['is_show'],
|
||||
'image' => $post['image'],
|
||||
'level' => $level+1,
|
||||
'pid' => $post['pid'],
|
||||
'is_recommend' => $post['pid'] == 0 ? $is_recommend : 0,
|
||||
'remark' => $post['remark'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_category')->where(['id'=>$post['id']])->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 删除商品分类
|
||||
* @param $id array 分类id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_category')->where(['del' => 0, 'id' => $id])->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 获取商品完整二级分类
|
||||
* @return array
|
||||
*/
|
||||
public static function categoryTwoTree()
|
||||
{
|
||||
$goods_category = new GoodsCategory();
|
||||
|
||||
$cateogry_list = $goods_category::with('sons')
|
||||
->where(['del' => 0, 'level' => 1])
|
||||
->field('id,name,pid,level')
|
||||
->select();
|
||||
|
||||
return self::categoryToSelect($cateogry_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 获取完整的商品分类
|
||||
* @return array
|
||||
*/
|
||||
public static function categoryThirdTree()
|
||||
{
|
||||
|
||||
$lists = Db::name('goods_category')
|
||||
->where(['del' => 0])
|
||||
->order('id asc')
|
||||
->column('id,name,pid,is_recommend,is_show,level,image,sort');
|
||||
foreach ($lists as $k => $item){
|
||||
$lists[$k]['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
$lists = linear_to_tree($lists);
|
||||
|
||||
foreach ($lists as $key => $list){
|
||||
|
||||
if(1 == $list['is_recommend']){
|
||||
$sub = [];
|
||||
foreach ($list['sub'] as $key1 => $sub1){
|
||||
$sub1['is_recommend'] = 1;
|
||||
|
||||
|
||||
foreach ($sub1['sub'] as $key2 => $sub2){
|
||||
$sub1['sub'][$key2]['is_recommend'] = 1;
|
||||
|
||||
}
|
||||
$sub[] = $sub1;
|
||||
|
||||
}
|
||||
|
||||
$lists[$key]['sub'] = $sub;
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 列表结构转换成树形结构
|
||||
* @param $lists array 分类数据
|
||||
* @return array
|
||||
*/
|
||||
public static function categoryToTree($lists)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($lists as $val) {
|
||||
$temp = [
|
||||
'id' => $val['id'],
|
||||
'title' => $val['name'],
|
||||
'children' => [],
|
||||
'spread' => false
|
||||
];
|
||||
|
||||
if ($val['child']) {
|
||||
|
||||
foreach ($val['child'] as $child_val) {
|
||||
$children = [
|
||||
'id' => $child_val['id'],
|
||||
'title' => $child_val['name'],
|
||||
];
|
||||
$temp['spread'] = true;
|
||||
$temp['children'][] = $children;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$tree[] = $temp;
|
||||
}
|
||||
|
||||
return $tree;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc:将树形结构数组输出
|
||||
* @param $items array 要输出的数组
|
||||
* @param $select_id int 已选中项
|
||||
* @return string
|
||||
*/
|
||||
public static function categoryToSelect($lists, $select_id = 0)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($lists as $val) {
|
||||
$tree[$val['id']]['level'] = $val['level'];
|
||||
$tree[$val['id']]['name'] = '|----' . $val['name'];
|
||||
if ($val['sons']) {
|
||||
foreach ($val['sons'] as $val_sons) {
|
||||
$tree[$val_sons['id']]['level'] = $val_sons['level'];
|
||||
$tree[$val_sons['id']]['name'] = '|--------' . $val_sons['name'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $tree;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Desc: 获取某个商品分类
|
||||
* @param $id int 分类id
|
||||
* @return string
|
||||
*/
|
||||
public static function getCategory($id)
|
||||
{
|
||||
$detail = GoodsCategory::get(['id' => $id, 'del' => 0]);
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 返回该分类下有多少级子类
|
||||
* @param array $category 分类信息
|
||||
* @return string
|
||||
*/
|
||||
public static function getCategoryLevel($category)
|
||||
{
|
||||
$level = 1;
|
||||
$two_id = Db::name('goods_category')->where(['pid' => $category['id'], 'del' => 0])->value('id');
|
||||
if ($two_id) {
|
||||
$level = 2;
|
||||
$three_id = Db::name('goods_category')->where(['pid' => $two_id, 'del' => 0])->value('id');
|
||||
if ($three_id) $level = 3;
|
||||
|
||||
}
|
||||
return $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 根据分类等级返回该级别的所有分类
|
||||
* @param $level int 需要获取的分类等级
|
||||
* @return string
|
||||
*/
|
||||
public static function getGoodsCategoryLevel($level = 3)
|
||||
{
|
||||
$where['level'] = $level;
|
||||
$where['del'] = 0;
|
||||
return Db::name('goods_category')->where($where)->column('name', 'id');
|
||||
}
|
||||
|
||||
|
||||
public static function categoryTreeeTree()
|
||||
{
|
||||
$goods_category = new GoodsCategory();
|
||||
$lists = $goods_category->where(['del' => 0])->column('id,name,pid,level', 'id');
|
||||
return self::cateToTree($lists, 0, '|-----', 1);
|
||||
}
|
||||
|
||||
public static function cateToTree($lists, $pid = 0, $html = '|-----', $level = 1, $clear = true)
|
||||
{
|
||||
static $tree = [];
|
||||
if ($clear) $tree = [];
|
||||
foreach ($lists as $k => $v) {
|
||||
if ($v['pid'] == $pid) {
|
||||
$v['html'] = str_repeat($html, $level);
|
||||
$tree[] = $v;
|
||||
unset($lists[$k]);
|
||||
self::cateToTree($lists, $v['id'], $html, $level + 1, false);
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有分类树形结构
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getAllTree()
|
||||
{
|
||||
$lists = Db::name('goods_category')
|
||||
->field(['name', 'id', 'pid', 'level'])
|
||||
->where(['del' => 0])
|
||||
->order(['sort' => 'desc'])
|
||||
->select();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
//更新分类状态
|
||||
public static function switchStatus($data)
|
||||
{
|
||||
$update_data = [
|
||||
'is_show' => $data['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
Cache::rm('goods_category_1');
|
||||
Cache::rm('goods_category_2');
|
||||
return Db::name('goods_category')->where(['del' =>0,'id' =>$data['id']])->update($update_data);
|
||||
}
|
||||
|
||||
}
|
||||
178
application/admin/logic/GoodsCommentLogic.php
Normal file
178
application/admin/logic/GoodsCommentLogic.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?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\admin\logic;
|
||||
use think\db;
|
||||
use app\common\server\UrlServer;
|
||||
class GoodsCommentLogic{
|
||||
//评价
|
||||
public static function lists($get){
|
||||
|
||||
$where = [];
|
||||
if(isset($get['type'])&&$get['type'] == 1){
|
||||
$where = [];
|
||||
}elseif (isset($get['type'])&&$get['type'] == 2){
|
||||
$where[] = ['reply','=',null];
|
||||
}
|
||||
//搜索条件
|
||||
if (isset($get['choice'])&& $get['choice']==1){
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['g.name', 'like', "%{$get['keyword']}%"];
|
||||
}
|
||||
}elseif (isset($get['choice'])&& $get['choice']==2){
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['user_id', 'like', "%{$get['keyword']}%"];
|
||||
}
|
||||
}elseif (isset($get['choice'])&& $get['choice']==3){
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['nickname', 'like', "%{$get['keyword']}%"];
|
||||
}
|
||||
}elseif (isset($get['choice'])&& $get['choice']==4){
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['mobile', 'like', "%{$get['keyword']}%"];
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($get['goods_comment'])&& $get['goods_comment']==1){
|
||||
$where[] = ['goods_comment', '>', 3];
|
||||
}elseif (isset($get['goods_comment'])&& $get['goods_comment']==2){
|
||||
$where[] = ['goods_comment', '=', 3];
|
||||
}elseif (isset($get['goods_comment'])&& $get['goods_comment']==3){
|
||||
$where[] = ['goods_comment', '<', 3];
|
||||
}
|
||||
|
||||
if(isset($get['start_time']) && $get['start_time']){
|
||||
$where[] = ['gc.create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']){
|
||||
$where[] = ['gc.create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$res = Db::name('goods_comment gc')
|
||||
->join('goods g','g.id = gc.goods_id')
|
||||
->leftjoin('goods_item gi','gi.id = gc.item_id')
|
||||
->join('user u','u.id = gc.user_id')
|
||||
->where('gc.del',0)
|
||||
->where($where)
|
||||
->withAttr('comment_image', function ($value, $data){
|
||||
$imgs = Db::name('goods_comment_image')->where([
|
||||
'goods_comment_id' => $data['id']
|
||||
])->column('uri');
|
||||
foreach ($imgs as $k => $img) {
|
||||
$imgs[$k] = UrlServer::getFileUrl($img);
|
||||
}
|
||||
return $imgs;
|
||||
})
|
||||
->field('u.id as user_id,u.nickname,u.mobile,u.sex,u.create_time,g.name,gi.spec_value_str
|
||||
,gc.goods_comment,gc.comment,gc.create_time as comment_time,gc.status,u.avatar,g.image,gc.reply,u.sn,u.level
|
||||
,gc.id')
|
||||
->order('gc.create_time','desc')
|
||||
->append(['comment_image']);
|
||||
$count = $res->count();
|
||||
$lists = $res->page($get['page'],$get['limit'])->select();
|
||||
|
||||
$user_level = Db::name('user_level')
|
||||
->where(['del'=>0])
|
||||
->column('name','id');
|
||||
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['level_name'] = $user_level[$item['level']] ?? '无等级';
|
||||
switch($item['sex']){
|
||||
case 0:
|
||||
$item['sex'] ='未知';
|
||||
break;
|
||||
case 1:
|
||||
$item['sex'] ='男';
|
||||
break;
|
||||
case 2:
|
||||
$item['sex'] ='女';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if($item['goods_comment'] > 3){
|
||||
$item['goods_comment'] = '好评';
|
||||
}elseif ($item['goods_comment'] == 3){
|
||||
$item['goods_comment'] = '中评';
|
||||
}elseif ($item['goods_comment'] < 3){
|
||||
$item['goods_comment'] = '差评';
|
||||
}
|
||||
if($item['status'] == 1){
|
||||
$item['status'] = '显示';
|
||||
$item['info_state_switch'] = '隐藏';
|
||||
}elseif ($item['status'] == 0){
|
||||
$item['status'] = '隐藏';
|
||||
$item['info_state_switch'] = '显示';
|
||||
}
|
||||
|
||||
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||
$item['comment_time'] = date('Y-m-d H:i:s',$item['comment_time']);
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return [
|
||||
'lists' => $lists,
|
||||
'count'=> $count
|
||||
];
|
||||
}
|
||||
|
||||
//删除
|
||||
public static function del($delData)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),];
|
||||
return Db::name('goods_comment')
|
||||
->where(['del' => 0, 'id' =>$delData])
|
||||
->update($data); //逻辑删除
|
||||
}
|
||||
|
||||
|
||||
//切换状态
|
||||
public static function switchStatus($get)
|
||||
{
|
||||
$data = [
|
||||
'status' => $get['status'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('goods_comment')->where(['del' => 0, 'id' => $get['id']])->update($data);
|
||||
}
|
||||
|
||||
//回复
|
||||
public static function reply($post){
|
||||
|
||||
$reply = db::name('goods_comment')
|
||||
->where([
|
||||
'id'=>$post['id'],
|
||||
'del'=>0
|
||||
])
|
||||
->update(['reply'=>$post['reply']]);
|
||||
return $reply;
|
||||
}
|
||||
|
||||
//评论信息
|
||||
public static function info($id){
|
||||
$info = db::name('goods_comment')
|
||||
->where('del',0)
|
||||
->where('id',$id)
|
||||
->find();
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
838
application/admin/logic/GoodsLogic.php
Normal file
838
application/admin/logic/GoodsLogic.php
Normal file
@@ -0,0 +1,838 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class GoodsLogic
|
||||
{
|
||||
/*
|
||||
* 商品统计
|
||||
*/
|
||||
public static function statistics(){
|
||||
// 回收站商品数量
|
||||
$goods['recycle'] = Db::name('goods')->where(['del'=>0, 'status'=>-1])->count('id');
|
||||
// 仓库中商品数量(含库存预警)
|
||||
$goods['warehouse'] = Db::name('goods')->where(['del'=>0, 'status'=>0])->count('id');
|
||||
|
||||
// 销售中商品数量(含库存预警)
|
||||
$goods['sell'] = Db::name('goods')->where(['del'=>0, 'status'=>1])->count('id');
|
||||
|
||||
// 仓库中、销售中的库存预警商品数量
|
||||
$goods['warn'] = Db::name('goods')
|
||||
->where([
|
||||
['del', '=', 0],
|
||||
['stock_warn', '>', 0],
|
||||
['stock','exp', Db::raw('<stock_warn')]
|
||||
])->count();
|
||||
return $goods;
|
||||
}
|
||||
|
||||
/*
|
||||
* 商品列表
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
if($get['type']){
|
||||
switch ($get['type']){
|
||||
case 1: //销售中
|
||||
$where[] = ['status','=',1];
|
||||
break;
|
||||
case 2: //仓库中
|
||||
$where[] = ['status','=',0];
|
||||
break;
|
||||
case 3: //库存预警
|
||||
$where[] = ['stock_warn','>',0];
|
||||
$where[] = ['stock','exp', Db::raw('<stock_warn')];
|
||||
break;
|
||||
case 4: //回收站
|
||||
$where[] = ['status','=',-1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
if(isset($get['code']) && $get['code']){
|
||||
$where[] = ['code','like','%'.$get['code'].'%'];
|
||||
}
|
||||
if(isset($get['supplier_id']) && $get['supplier_id']){
|
||||
$where[] = ['supplier_id','=',$get['supplier_id']];
|
||||
}
|
||||
if(isset($get['category_id']) && $get['category_id']){
|
||||
$where[] = ['first_category_id|second_category_id|third_category_id','=',$get['category_id']];
|
||||
}
|
||||
|
||||
$goods_count = Db::name('goods')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$goods_list = Db::name('goods')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->field('*,virtual_sales_sum+sales_sum as total_sales_sum')
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
|
||||
$goods_category_list = Db::name('goods_category')->where(['del'=>0])->column('name','id');
|
||||
|
||||
foreach ($goods_list as &$item) {
|
||||
$item['type'] = $get['type'];
|
||||
$item['cat_name'] = self::getCateName($goods_category_list, $item);
|
||||
$item['commission_status'] = '关闭';
|
||||
if($item['is_commission']){
|
||||
$item['commission_status'] = '开启';
|
||||
}
|
||||
$item['price'] = '¥'.$item['min_price'];
|
||||
if($item['spec_type'] == 2 && $item['max_price'] !== $item['min_price']){
|
||||
$item['price'] = '¥'.$item['min_price'].'~'.'¥'.$item['max_price'];
|
||||
}
|
||||
$item['create_time_desc'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||
$item['first_ratio_desc'] = 0;
|
||||
$item['second_ratio_desc'] = 0;
|
||||
$item['three_ratio_desc'] = 0;
|
||||
$item['region_ratio_desc'] = 0;
|
||||
$item['shareholder_ratio_desc'] = 0;
|
||||
|
||||
if($item['first_ratio'] > 0) $item['first_ratio_desc'] = $item['first_ratio'] .'%';
|
||||
if($item['second_ratio'] > 0) $item['second_ratio_desc'] = $item['second_ratio'] .'%';
|
||||
if($item['three_ratio'] > 0) $item['three_ratio_desc'] = $item['three_ratio'] .'%';
|
||||
if($item['region_ratio'] > 0) $item['region_ratio_desc'] = $item['region_ratio'] .'%';
|
||||
if($item['shareholder_ratio'] > 0) $item['shareholder_ratio_desc'] = $item['shareholder_ratio'] /100 .'%';
|
||||
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count' => $goods_count, 'list' => $goods_list];
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表导出
|
||||
* @param $get
|
||||
*/
|
||||
public static function exportFile($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
if($get['type']){
|
||||
switch ($get['type']){
|
||||
case 1: //销售中
|
||||
$where[] = ['status','=',1];
|
||||
break;
|
||||
case 2: //仓库中
|
||||
$where[] = ['status','=',0];
|
||||
break;
|
||||
case 3: //库存预警
|
||||
$where[] = ['stock_warn','>',0];
|
||||
$where[] = ['stock','exp', Db::raw('<stock_warn')];
|
||||
break;
|
||||
case 4: //回收站
|
||||
$where[] = ['status','=',-1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($get['keyword']) && $get['keyword']) {
|
||||
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
|
||||
}
|
||||
if(isset($get['code']) && $get['code']){
|
||||
$where[] = ['code','like','%'.$get['code'].'%'];
|
||||
}
|
||||
if(isset($get['supplier_id']) && $get['supplier_id']){
|
||||
$where[] = ['supplier_id','=',$get['supplier_id']];
|
||||
}
|
||||
if(isset($get['category_id']) && $get['category_id']){
|
||||
$where[] = ['first_category_id|second_category_id|third_category_id','=',$get['category_id']];
|
||||
}
|
||||
|
||||
$goods_list_export = Db::name('goods')
|
||||
->where($where)
|
||||
->field('*,virtual_sales_sum+sales_sum as total_sales_sum')
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
$goods_category_list = Db::name('goods_category')->where(['del'=>0])->column('name','id');
|
||||
|
||||
$exportTitle = ['商品名称', '商品分类', '是否开启分销', '一级佣金比例', '二级佣金比例', '三级佣金比例', 'SKU最低价', 'SKU最高价', '总库存', '总销量', '新品推荐', '好物优选', '猜你喜欢', '排序', '发布时间'];
|
||||
$exportExt = 'xls';
|
||||
$exportData = [];
|
||||
foreach($goods_list_export as $item) {
|
||||
$cateName = self::getCateName($goods_category_list, $item); // 商品分类
|
||||
$isCommission = $item['is_commission'] ? '开启' : '关闭';
|
||||
$firstRatio = $item['first_ratio'] > 0 ? $item['first_ratio'].'%' : 0;
|
||||
$secondRatio = $item['second_ratio'] > 0 ? $item['second_ratio'].'%' : 0;
|
||||
$threeRatio = $item['three_ratio'] > 0 ? $item['three_ratio'].'%' : 0;
|
||||
$isNew = $item['is_new'] ? '是' : '否';
|
||||
$isBest = $item['is_best'] ? '是' : '否';
|
||||
$isLike = $item['is_like'] ? '是' : '否';
|
||||
$createTime = date('Y-m-d H:i:s',$item['create_time']);
|
||||
$exportData[] = [$item['name'], $cateName, $isCommission, $firstRatio, $secondRatio, $threeRatio, $item['min_price'], $item['max_price'], $item['stock'], $item['total_sales_sum'], $isNew, $isBest, $isLike, $item['sort'], $createTime];
|
||||
}
|
||||
|
||||
return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'商品列表'.date('Y-m-d H:i:s')];
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除商品
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time()
|
||||
];
|
||||
return Db::name('goods')->where(['del' => 0, 'id' => $id])->update($data);
|
||||
}
|
||||
/**
|
||||
* 添加商品
|
||||
* @param $post
|
||||
* @param $spec_lists
|
||||
* @return bool
|
||||
*/
|
||||
public static function add($post, $spec_lists)
|
||||
{
|
||||
|
||||
try {
|
||||
Db::startTrans();
|
||||
$time = time();
|
||||
|
||||
//算出最大最小价格
|
||||
if ($post['spec_type'] == 1) {
|
||||
$max_price = $post['one_price'];
|
||||
$min_price = $post['one_price'];
|
||||
$market_price = $post['one_market_price'];
|
||||
$total_stock = $post['one_stock'];
|
||||
} else {
|
||||
$max_price = max($post['price']);
|
||||
$min_price = min($post['price']);
|
||||
$market_price = max($post['market_price']);
|
||||
$total_stock = array_sum($post['stock']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 替换内容中图片地址
|
||||
$domain = UrlServer::getFileUrl('/');
|
||||
$post['content'] = str_replace($domain, '/', $post['content']);
|
||||
|
||||
//赠送积分类型
|
||||
$give_integral_type = $post['give_integral_type'] ?? 0;
|
||||
switch ($give_integral_type){
|
||||
case 1:
|
||||
$give_integral = empty($post['give_integral_num']) ? 0 : $post['give_integral_num'];
|
||||
break;
|
||||
case 2:
|
||||
$give_integral = empty($post['give_integral_ratio']) ? 0 : $post['give_integral_ratio'];
|
||||
break;
|
||||
default:
|
||||
$give_integral = 0;
|
||||
}
|
||||
|
||||
$video = isset($post['video']) ? UrlServer::setFileUrl($post['video']) : '';
|
||||
|
||||
//写入主表
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'code' => $post['code'],
|
||||
'first_category_id' => $post['first_category_id'],
|
||||
'second_category_id' => $post['second_category_id'],
|
||||
'third_category_id' => $post['third_category_id'],
|
||||
'brand_id' => $post['brand_id'],
|
||||
'supplier_id' => $post['supplier_id'],
|
||||
'image' => $post['image'],
|
||||
'video' => $video,
|
||||
'poster' => $post['poster'] ?? '',
|
||||
'remark' => $post['remark'],
|
||||
'content' => $post['content'],
|
||||
'max_price' => $max_price,
|
||||
'min_price' => $min_price,
|
||||
'market_price' => $market_price,
|
||||
'stock' => $total_stock,
|
||||
'status' => $post['status'],
|
||||
'virtual_sales_sum' => $post['virtual_sales_sum'],
|
||||
'stock_warn' => $post['stock_warn'],
|
||||
'is_show_stock' => $post['is_show_stock'],
|
||||
|
||||
'is_commission' => $post['is_commission'],
|
||||
'first_ratio' => $post['first_ratio'],
|
||||
'second_ratio' => $post['second_ratio'],
|
||||
'three_ratio' => $post['three_ratio'],
|
||||
'is_new' => isset($post['is_new']) && $post['is_new'] == 'on' ? 1 : 0,
|
||||
'is_best' => isset($post['is_best']) && $post['is_best'] == 'on' ? 1 : 0,
|
||||
'is_like' => isset($post['is_like']) && $post['is_like'] == 'on' ? 1 : 0,
|
||||
// 'is_share_bouns' => $post['is_share_bouns'],
|
||||
// 'region_ratio' => $post['region_ratio'],
|
||||
// 'shareholder_ratio' => $post['shareholder_ratio'],
|
||||
'is_integral' => $post['is_integral'],
|
||||
'is_member' => $post['is_member'],
|
||||
'give_integral_type' => $give_integral_type,
|
||||
'give_integral' => $give_integral,
|
||||
'spec_type' => $post['spec_type'],
|
||||
'create_time' => $time
|
||||
];
|
||||
$goods_id = Db::name('goods')->insertGetId($data);
|
||||
|
||||
//写入图片表
|
||||
$data = [];
|
||||
foreach ($post['goods_image'] as $k => $v) {
|
||||
$data[] = [
|
||||
'goods_id' => $goods_id,
|
||||
'uri' => $v,
|
||||
];
|
||||
}
|
||||
Db::name('goods_image')->insertAll($data);
|
||||
|
||||
|
||||
//写入规格表
|
||||
if ($post['spec_type'] == 1) {
|
||||
//单规格写入
|
||||
$goods_spec_id = Db::name('goods_spec')
|
||||
->insertGetId(['goods_id' => $goods_id, 'name' => '默认']);
|
||||
$goods_spec_value_id = Db::name('goods_spec_value')
|
||||
->insertGetId(['spec_id' => $goods_spec_id, 'goods_id' => $goods_id, 'value' => '默认']);
|
||||
|
||||
$data = [
|
||||
'image' => $post['one_spec_image'],
|
||||
'goods_id' => $goods_id,
|
||||
'spec_value_ids' => $goods_spec_value_id,
|
||||
'spec_value_str' => '默认',
|
||||
'market_price' => $post['one_market_price'],
|
||||
'price' => $post['one_price'],
|
||||
'cost_price' => $post['one_cost_price'],
|
||||
'stock' => $post['one_stock'],
|
||||
'volume' => $post['one_volume'],
|
||||
'weight' => $post['one_weight'],
|
||||
'bar_code' => $post['one_bar_code'],
|
||||
];
|
||||
Db::name('goods_item')
|
||||
->insert($data);
|
||||
} else {
|
||||
//多规格写入
|
||||
$goods_specs = [];
|
||||
foreach ($post['spec_name'] as $k => $v) {
|
||||
$temp = ['goods_id' => $goods_id, 'name' => $v];
|
||||
$goods_specs[] = $temp;
|
||||
}
|
||||
Db::name('goods_spec')->insertAll($goods_specs);
|
||||
$goods_spec_name_key_id = Db::name('goods_spec')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->where('name', 'in', $post['spec_name'])
|
||||
->column('id', 'name');
|
||||
|
||||
$data = [];
|
||||
$check_values = []; //检查规格项是否存在相同值,相同值会出现错误
|
||||
|
||||
foreach ($post['spec_values'] as $k => $v) {
|
||||
$row = explode(',', $v);
|
||||
foreach ($row as $k2 => $v2) {
|
||||
if (in_array($v2, $check_values)) {
|
||||
throw new Exception('请勿添加相同规格值');
|
||||
}
|
||||
$temp = [
|
||||
'goods_id' => $goods_id,
|
||||
'spec_id' => $goods_spec_name_key_id[$post['spec_name'][$k]],
|
||||
'value' => $v2,
|
||||
];
|
||||
$data[] = $temp;
|
||||
$check_values[] = $v2;
|
||||
}
|
||||
}
|
||||
|
||||
Db::name('goods_spec_value')->insertAll($data);
|
||||
$goods_spec_name_value_id = Db::name('goods_spec_value')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->column('id', 'value');
|
||||
|
||||
foreach ($spec_lists as $k => $v) {
|
||||
$spec_lists[$k]['spec_value_ids'] = '';
|
||||
$temp = explode(',', $v['spec_value_str']);
|
||||
|
||||
foreach ($temp as $k2 => $v2) {
|
||||
$spec_lists[$k]['spec_value_ids'] .= $goods_spec_name_value_id[$v2] . ',';
|
||||
}
|
||||
$spec_lists[$k]['spec_value_ids'] = trim($spec_lists[$k]['spec_value_ids'], ',');
|
||||
$spec_lists[$k]['image'] = $spec_lists[$k]['spec_image'];
|
||||
$spec_lists[$k]['goods_id'] = $goods_id;
|
||||
unset($spec_lists[$k]['spec_image']);
|
||||
unset($spec_lists[$k]['spec_id']);
|
||||
unset($spec_lists[$k]['item_id']);
|
||||
}
|
||||
Db::name('goods_item')->insertAll($spec_lists);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑商品
|
||||
* @param $post
|
||||
* @param $spec_lists
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit($post, $spec_lists)
|
||||
{
|
||||
|
||||
try {
|
||||
Db::startTrans();
|
||||
$time = time();
|
||||
|
||||
//算出最大最小价格
|
||||
if ($post['spec_type'] == 1) {
|
||||
$max_price = $post['one_price'];
|
||||
$min_price = $post['one_price'];
|
||||
$market_price = $post['one_market_price'];
|
||||
$total_stock = $post['one_stock'];
|
||||
} else {
|
||||
$max_price = max($post['price']);
|
||||
$min_price = min($post['price']);
|
||||
$market_price = max($post['market_price']);
|
||||
$total_stock = array_sum($post['stock']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$old_spec_type = Db::name('goods')
|
||||
->where('id', $post['goods_id'])
|
||||
->value('spec_type');
|
||||
|
||||
// 替换内容中图片地址
|
||||
$domain = UrlServer::getFileUrl('/');
|
||||
$post['content'] = str_replace($domain, '/', $post['content']);
|
||||
|
||||
//赠送积分
|
||||
$give_integral_type = $post['give_integral_type'] ?? 0;
|
||||
switch ($give_integral_type){
|
||||
case 1:
|
||||
$give_integral = empty($post['give_integral_num']) ? 0 : $post['give_integral_num'];
|
||||
break;
|
||||
case 2:
|
||||
$give_integral = empty($post['give_integral_ratio']) ? 0 : $post['give_integral_ratio'];
|
||||
break;
|
||||
default:
|
||||
$give_integral = 0;
|
||||
}
|
||||
|
||||
$video = isset($post['video']) ? UrlServer::setFileUrl($post['video']) : '';
|
||||
//写入主表
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'code' => $post['code'],
|
||||
'first_category_id' => $post['first_category_id'],
|
||||
'second_category_id' => $post['second_category_id'],
|
||||
'third_category_id' => $post['third_category_id'],
|
||||
'brand_id' => $post['brand_id'],
|
||||
'supplier_id' => $post['supplier_id'],
|
||||
'image' => $post['image'],
|
||||
'video' => $video,
|
||||
'poster' => $post['poster'] ?? '',
|
||||
'remark' => $post['remark'],
|
||||
'content' => $post['content'],
|
||||
'max_price' => $max_price,
|
||||
'min_price' => $min_price,
|
||||
'market_price' => $market_price,
|
||||
'stock' => $total_stock,
|
||||
'status' => $post['status'],
|
||||
'virtual_sales_sum' => $post['virtual_sales_sum'],
|
||||
'stock_warn' => $post['stock_warn'],
|
||||
'is_show_stock' => $post['is_show_stock'],
|
||||
|
||||
'is_commission' => $post['is_commission'],
|
||||
'first_ratio' => $post['first_ratio'],
|
||||
'second_ratio' => $post['second_ratio'],
|
||||
'three_ratio' => $post['three_ratio'],
|
||||
'is_new' => isset($post['is_new']) && $post['is_new'] == 'on' ? 1 : 0,
|
||||
'is_best' => isset($post['is_best']) && $post['is_best'] == 'on' ? 1 : 0,
|
||||
'is_like' => isset($post['is_like']) && $post['is_like'] == 'on' ? 1 : 0,
|
||||
// 'is_share_bouns' => $post['is_share_bouns'],
|
||||
// 'region_ratio' => $post['region_ratio'],
|
||||
// 'shareholder_ratio' => $post['shareholder_ratio'],
|
||||
'is_integral' => $post['is_integral'],
|
||||
'is_member' => $post['is_member'],
|
||||
'give_integral_type' => $give_integral_type,
|
||||
'give_integral' => $give_integral,
|
||||
'spec_type' => $post['spec_type'],
|
||||
'update_time' => $time
|
||||
];
|
||||
|
||||
Db::name('goods')
|
||||
->where(['id' => $post['goods_id']])
|
||||
->update($data);
|
||||
|
||||
//重新更新图片表
|
||||
Db::name('goods_image')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->delete();
|
||||
$data = [];
|
||||
foreach ($post['goods_image'] as $k => $v) {
|
||||
$data[] = [
|
||||
'goods_id' => $post['goods_id'],
|
||||
'uri' => $v,
|
||||
];
|
||||
}
|
||||
Db::name('goods_image')->insertAll($data);
|
||||
|
||||
//写入规格表
|
||||
if ($post['spec_type'] == 1) {
|
||||
|
||||
//单规格写入
|
||||
if ($old_spec_type == 1) {
|
||||
//原来是单规格
|
||||
$data = [
|
||||
'image' => $post['one_spec_image'],
|
||||
'price' => $post['one_price'],
|
||||
'market_price' => $post['one_market_price'],
|
||||
'price' => $post['one_price'],
|
||||
'cost_price' => $post['one_cost_price'],
|
||||
'stock' => $post['one_stock'],
|
||||
'volume' => $post['one_volume'],
|
||||
'weight' => $post['one_weight'],
|
||||
'bar_code' => $post['one_bar_code'],
|
||||
];
|
||||
Db::name('goods_item')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->update($data);
|
||||
} else {
|
||||
//原来非单规格
|
||||
//删除多规格
|
||||
Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->delete();
|
||||
Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->delete();
|
||||
Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->delete();
|
||||
$goods_spec_id = Db::name('goods_spec')
|
||||
->insertGetId(['goods_id' => $post['goods_id'], 'name' => '默认']);
|
||||
$goods_spec_value_id = Db::name('goods_spec_value')
|
||||
->insertGetId(['spec_id' => $goods_spec_id, 'goods_id' => $post['goods_id'], 'value' => '默认']);
|
||||
$data = [
|
||||
'image' => $post['one_spec_image'],
|
||||
'goods_id' => $post['goods_id'],
|
||||
'spec_value_ids' => $goods_spec_value_id,
|
||||
'spec_value_str' => '默认',
|
||||
'market_price' => $post['one_market_price'],
|
||||
'price' => $post['one_price'],
|
||||
'stock' => $post['one_stock'],
|
||||
'volume' => $post['one_volume'],
|
||||
'weight' => $post['one_weight'],
|
||||
'bar_code' => $post['one_bar_code'],
|
||||
];
|
||||
Db::name('goods_item')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$goods_specs = [];
|
||||
foreach ($post['spec_name'] as $k => $v) {
|
||||
$temp = ['goods_id' => $post['goods_id'], 'name' => $v, 'spec_id' => $post['spec_id'][$k]];
|
||||
$goods_specs[] = $temp;
|
||||
}
|
||||
$new_spec_name_ids = [];
|
||||
foreach ($goods_specs as $k => $v) {
|
||||
if ($v['spec_id']) {
|
||||
//更新规格名
|
||||
Db::name('goods_spec')
|
||||
->where(['goods_id' => $post['goods_id'], 'id' => $v['spec_id']])
|
||||
->update(['name' => $v['name']]);
|
||||
$new_spec_name_ids[] = $v['spec_id'];
|
||||
} else {
|
||||
//添加规格名
|
||||
$new_spec_name_ids[] = Db::name('goods_spec')
|
||||
->insertGetId(['goods_id' => $post['goods_id'], 'name' => $v['name']]);
|
||||
}
|
||||
}
|
||||
//删除规格名
|
||||
$all_spec_ids = Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->column('id');
|
||||
$del_spec_name_ids = array_diff($all_spec_ids, $new_spec_name_ids);
|
||||
if (!empty($del_spec_name_ids)) {
|
||||
Db::name('goods_spec')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('id', 'in', $del_spec_name_ids)
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
$new_spec_value_ids = [];
|
||||
$goods_spec_name_key_id = Db::name('goods_spec')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->where('name', 'in', $post['spec_name'])
|
||||
->column('id', 'name');
|
||||
|
||||
$check_values = [];//检查规格值是否存在相同
|
||||
|
||||
foreach ($post['spec_values'] as $k => $v) {
|
||||
$value_id_row = explode(',', $post['spec_value_ids'][$k]);
|
||||
$value_row = explode(',', $v);
|
||||
foreach ($value_row as $k2 => $v2) {
|
||||
if (in_array($v2, $check_values)) {
|
||||
throw new Exception('请勿添加相同规格值');
|
||||
}
|
||||
$temp = [
|
||||
'goods_id' => $post['goods_id'],
|
||||
'spec_id' => $goods_spec_name_key_id[$post['spec_name'][$k]],
|
||||
'value' => $v2,
|
||||
];
|
||||
$check_values[] = $v2;
|
||||
if ($value_id_row[$k2]) {
|
||||
//更新规格值
|
||||
Db::name('goods_spec_value')
|
||||
->where(['id' => $value_id_row[$k2]])
|
||||
->update($temp);
|
||||
$new_spec_value_ids[] = $value_id_row[$k2];
|
||||
} else {
|
||||
//添加规格值
|
||||
$new_spec_value_ids[] = Db::name('goods_spec_value')
|
||||
->insertGetId($temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
$all_spec_value_ids = Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->column('id');
|
||||
$del_spec_value_ids = array_diff($all_spec_value_ids, $new_spec_value_ids);
|
||||
if (!empty($del_spec_value_ids)) {
|
||||
//删除规格值
|
||||
Db::name('goods_spec_value')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('id', 'in', $del_spec_value_ids)
|
||||
->delete();
|
||||
}
|
||||
|
||||
$new_item_id = [];
|
||||
$goods_spec_name_value_id = Db::name('goods_spec_value')
|
||||
->where(['goods_id' => $post['goods_id']])
|
||||
->column('id', 'value');
|
||||
foreach ($spec_lists as $k => $v) {
|
||||
$spec_lists[$k]['spec_value_ids'] = '';
|
||||
$temp = explode(',', $v['spec_value_str']);
|
||||
foreach ($temp as $k2 => $v2) {
|
||||
$spec_lists[$k]['spec_value_ids'] .= $goods_spec_name_value_id[$v2] . ',';
|
||||
}
|
||||
$spec_lists[$k]['spec_value_ids'] = trim($spec_lists[$k]['spec_value_ids'], ',');
|
||||
$spec_lists[$k]['image'] = str_replace(UrlServer::getFileUrl('/'), '', $spec_lists[$k]['spec_image']);
|
||||
unset($spec_lists[$k]['spec_image']);
|
||||
$spec_lists[$k]['goods_id'] = $post['goods_id'];
|
||||
unset($spec_lists[$k]['spec_id']);
|
||||
$item_id = $spec_lists[$k]['item_id'];
|
||||
unset($spec_lists[$k]['item_id']);
|
||||
if ($item_id) {
|
||||
Db::name('goods_item')
|
||||
->where(['id' => $item_id])
|
||||
->update($spec_lists[$k]);
|
||||
$new_item_id[] = $item_id;
|
||||
} else {
|
||||
$new_item_id[] = Db::name('goods_item')
|
||||
->insertGetId($spec_lists[$k]);
|
||||
}
|
||||
}
|
||||
$all_item_id = Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->column('id');
|
||||
$del_item_ids = array_diff($all_item_id, $new_item_id);
|
||||
if (!empty($del_item_ids)) {
|
||||
//删除规格值
|
||||
Db::name('goods_item')
|
||||
->where('goods_id', $post['goods_id'])
|
||||
->where('id', 'in', $del_item_ids)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 商品信息
|
||||
*/
|
||||
/**
|
||||
* 获取商品信息
|
||||
* @param $goods_id
|
||||
* @return array
|
||||
*/
|
||||
public static function info($goods_id)
|
||||
{
|
||||
|
||||
$info['base'] = Db::name('goods')
|
||||
->where(['id' => $goods_id])
|
||||
->withAttr('abs_image', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['image']);
|
||||
})
|
||||
->withAttr('content', function ($value){
|
||||
$preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
|
||||
$local_url = UrlServer::getFileUrl('/');
|
||||
return preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
|
||||
})
|
||||
->withAttr('abs_video',function ($value,$data){
|
||||
if($data['video']){
|
||||
return UrlServer::getFileUrl($data['video']);
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->withAttr('abs_poster',function ($value,$data){
|
||||
if($data['poster']){
|
||||
return UrlServer::getFileUrl($data['poster']);
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->append(['abs_image','abs_video'])->find();
|
||||
$info['base']['goods_image'] = Db::name('goods_image')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->withAttr('abs_image', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['uri']);})
|
||||
->append(['abs_image'])
|
||||
->select();
|
||||
|
||||
$info['item'] = Db::name('goods_item')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->withAttr('abs_image', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['image']);
|
||||
})->append(['abs_image'])
|
||||
->select();
|
||||
|
||||
$info['spec'] = Db::name('goods_spec')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->select();
|
||||
|
||||
$spec_value = Db::name('goods_spec_value')
|
||||
->where(['goods_id' => $goods_id])
|
||||
->select();
|
||||
|
||||
$data = [];
|
||||
foreach ($spec_value as $k => $v) {
|
||||
$data[$v['spec_id']][] = $v;
|
||||
}
|
||||
foreach ($info['spec'] as $k => $v) {
|
||||
$info['spec'][$k]['values'] = isset($data[$v['id']]) ? $data[$v['id']] : [];
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 上架 / 下架 商品
|
||||
* @author 张无忌(2021/1/11 14:35)
|
||||
* @param array $ids (要更新的数据ID)
|
||||
* @param int $type (类型[0=下架, 1=上架])
|
||||
* @return bool
|
||||
*/
|
||||
public static function upperOrLower(array $ids, int $type=0)
|
||||
{
|
||||
if (empty($ids)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if ($type == 0) {
|
||||
$res = Db::name('team_activity')->whereIn('goods_id', $ids)
|
||||
->where(['status' => 1])->find();
|
||||
if ($res) {
|
||||
return '该商品正在参与拼团,请先关闭后才允许下架';
|
||||
}
|
||||
}
|
||||
|
||||
$result = Db::name('goods')->whereIn('id', $ids)->update([
|
||||
'status' => $type,
|
||||
'update_time' => time()
|
||||
]);
|
||||
return $result ? true : '上架失败';
|
||||
} catch (\Exception $e) {
|
||||
return '上架失败';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 分类名称
|
||||
* @param $cates
|
||||
* @param $item
|
||||
* @author 段誉(2021/6/3 19:45)
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function getCateName($cates, $item)
|
||||
{
|
||||
if(isset($cates[$item['third_category_id']])) {
|
||||
return $cates[$item['third_category_id']];
|
||||
}
|
||||
|
||||
if(isset($cates[$item['second_category_id']])) {
|
||||
return $cates[$item['second_category_id']];
|
||||
}
|
||||
|
||||
if(isset($cates[$item['first_category_id']])) {
|
||||
return $cates[$item['first_category_id']];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function goodsList($get){
|
||||
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
|
||||
$goods_count=Db::name('goods')->where('status',1)
|
||||
->where($where)
|
||||
->count();
|
||||
$goods_list=Db::name('goods')->where('status',1)
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
$brand = Db::name('goods_brand')->where(['del'=>0])->column('name','id');
|
||||
|
||||
foreach ($goods_list as &$item) {
|
||||
$item['image']=UrlServer::getFileUrl($item['image']);
|
||||
if(isset($brand[$item['brand_id']])){
|
||||
$item['type'] = $brand[$item['brand_id']];
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $goods_count, 'list' => $goods_list];
|
||||
}
|
||||
|
||||
|
||||
public static function goodsinfo($id){
|
||||
return Db::name('goods')->where('id',$id)->find();
|
||||
|
||||
}
|
||||
}
|
||||
114
application/admin/logic/HelpCategoryLogic.php
Normal file
114
application/admin/logic/HelpCategoryLogic.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\HelpCategory;
|
||||
use think\Db;
|
||||
|
||||
class HelpCategoryLogic
|
||||
{
|
||||
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
|
||||
$cate = new HelpCategory();
|
||||
$count = $cate->where($where)->count();
|
||||
$list = $cate->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['is_show_text'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
return ['count' => $count, 'lists' => $list];
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 添加文章分类
|
||||
* @param $post array 文章分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function addHelpCategory($post)
|
||||
{
|
||||
$help_category = new HelpCategory();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'is_show' => $post['is_show'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
return $help_category->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 编辑文章分类
|
||||
* @param $post array 文章分类数据
|
||||
* @return boolean
|
||||
*/
|
||||
public static function editHelpCategory($post)
|
||||
{
|
||||
$help_category = new HelpCategory();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return $help_category->save($data, ['id' => $post['id'], 'del' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 删除文章分类
|
||||
* @param $id int 文章分类id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function delHelpCategory($id)
|
||||
{
|
||||
$help_category = new HelpCategory();
|
||||
$data = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
return $help_category->save($data, ['id' => $id, 'del' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc: 获取单条文章分类
|
||||
* @param $id int 文章分类id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getHelpCategory($id = 0)
|
||||
{
|
||||
$where[] = ['del', '=', 0];
|
||||
if ($id) {
|
||||
$where[] = ['id', '=', $id];
|
||||
}
|
||||
$help_category = new HelpCategory();
|
||||
return $help_category->where($where)->column('*', 'id');
|
||||
}
|
||||
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
$data = [
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('help_category')->where(['del' => 0, 'id' => $post['id']])->update($data);
|
||||
}
|
||||
}
|
||||
125
application/admin/logic/HelpLogic.php
Normal file
125
application/admin/logic/HelpLogic.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\Help;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class HelpLogic
|
||||
{
|
||||
|
||||
public static function lists($get, $category)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
if (isset($get['is_show']) && $get['is_show'] != '') {
|
||||
$where[] = ['is_show', '=', $get['is_show']];
|
||||
}
|
||||
|
||||
if (isset($get['title']) && $get['title']) {
|
||||
$where[] = ['title', 'like', '%' . $get['title'] . '%'];
|
||||
}
|
||||
|
||||
if (isset($get['cid']) && $get['cid']) {
|
||||
$where[] = ['cid', '=', $get['cid']];
|
||||
}
|
||||
|
||||
$help_count = Db::name('help')->where($where)->count();
|
||||
$help_list = Db::name('help')->where($where)->page($get['page'], $get['limit'])->order('id desc')->select();
|
||||
|
||||
foreach ($help_list as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
if (isset($category[$item['cid']])) {
|
||||
$item['cat_name'] = $category[$item['cid']]['name'];
|
||||
}
|
||||
if ($item['is_show'] == 1) {
|
||||
$item['is_show_text'] = '显示';
|
||||
} else {
|
||||
$item['is_show_text'] = '隐藏';
|
||||
}
|
||||
}
|
||||
return ['count' => $help_count, 'lists' => $help_list];
|
||||
}
|
||||
|
||||
|
||||
public static function addHelp($post)
|
||||
{
|
||||
$help = new Help();
|
||||
$data = [
|
||||
'title' => $post['title'],
|
||||
'cid' => $post['cid'],
|
||||
'image' => $post['image'],
|
||||
'content' => $post['content'],
|
||||
'is_show' => $post['is_show'],
|
||||
'create_time' => time(),
|
||||
'sort' => $post['sort'],
|
||||
'synopsis' => $post['synopsis'],
|
||||
'del' => 0
|
||||
];
|
||||
return $help->save($data);
|
||||
}
|
||||
|
||||
public static function editHelp($post)
|
||||
{
|
||||
$help = new Help();
|
||||
$data = [
|
||||
'title' => $post['title'],
|
||||
'cid' => $post['cid'],
|
||||
'image' => $post['image'],
|
||||
'content' => $post['content'],
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
'sort' => $post['sort'],
|
||||
'synopsis' => $post['synopsis']
|
||||
];
|
||||
return $help->save($data, ['id' => $post['id'], 'del' => 0]);
|
||||
}
|
||||
|
||||
public static function getHelp($id)
|
||||
{
|
||||
$help = new Help();
|
||||
$detail = $help::get(['id' => $id, 'del' => 0]);
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
public static function delHelp($id)
|
||||
{
|
||||
$help = new Help();
|
||||
|
||||
$data = [
|
||||
'del' => time(),
|
||||
'update_time' => 1
|
||||
];
|
||||
return $help->save($data, ['id' => $id, 'del' => 0]);
|
||||
}
|
||||
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
$data = [
|
||||
'is_show' => $post['is_show'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('help')->where(['del' => 0, 'id' => $post['id']])->update($data);
|
||||
}
|
||||
|
||||
}
|
||||
30
application/admin/logic/HotSearchLogic.php
Normal file
30
application/admin/logic/HotSearchLogic.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class HotSearchLogic
|
||||
{
|
||||
|
||||
public static function info(){
|
||||
|
||||
$info = ConfigServer::get('hot_search','hot_keyword',[]);
|
||||
if (empty($info)){
|
||||
return [''];
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function set($post){
|
||||
|
||||
if ($post['hot_keyword'] == ['']){
|
||||
return ConfigServer::set('hot_search','hot_keyword',[]);
|
||||
}
|
||||
$hot_keyword = array_values(array_filter($post['hot_keyword']));
|
||||
|
||||
return ConfigServer::set('hot_search','hot_keyword',$hot_keyword);
|
||||
}
|
||||
}
|
||||
101
application/admin/logic/LabelLogic.php
Normal file
101
application/admin/logic/LabelLogic.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\admin\logic;
|
||||
use think\Db;
|
||||
|
||||
class LabelLogic
|
||||
{
|
||||
|
||||
/*
|
||||
* 分组列表
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del','=', '0'];
|
||||
|
||||
//查询条数
|
||||
$user_group_count = Db::name('user_label')
|
||||
->where($where)
|
||||
->count();
|
||||
//数据查询
|
||||
$user_group_list = Db::name('user_label')
|
||||
->where($where)
|
||||
->field(['id','name', 'remark'])
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
|
||||
//返回数据及页面条数
|
||||
return ['list'=>$user_group_list,'count' =>$user_group_count];
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('user_label')->where(['id' => $id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public static function addUserGroup($post)
|
||||
{
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'remark' => $post['remark'],
|
||||
'create_time' => $time
|
||||
];
|
||||
return Db::name('user_label')->insert($data); //插入数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public static function editUserGroup($post)
|
||||
{
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'remark' => $post['remark'],
|
||||
'update_time' => $time
|
||||
];
|
||||
return Db::name('user_label')->where(['del' => 0, 'id' => $post['id']])->update($data); //逻辑删除
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public static function delUserGroup($id)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('user_label')->where(['del' => 0, 'id' => $id])->update($data); //逻辑删除
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
267
application/admin/logic/LeaveLogic.php
Normal file
267
application/admin/logic/LeaveLogic.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\admin\logic\StaffLogic;
|
||||
use app\admin\logic\UserLogic;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class LeaveLogic{
|
||||
/**
|
||||
* 列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
//查询
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['keyword_type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
//等级查询
|
||||
if(isset($get['level']) && $get['level'] != ''){
|
||||
$where[] = ['level','=',$get['level']];
|
||||
}
|
||||
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
|
||||
//日期查询
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_count = Db::name('leave')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$user_list = Db::name('leave')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
// //请假类型
|
||||
$type = Db::name('leave_type')->column('name','id');
|
||||
foreach ($user_list as &$item){
|
||||
// //会员所属分组
|
||||
if(isset($type[$item['type']])){
|
||||
$item['type'] = $type[$item['type']];
|
||||
}
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$item['time']=date("Y-m-d",$item['time']);
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
if($admin){
|
||||
$item['admin']=$admin['name'];
|
||||
}else{
|
||||
$item['admin']="-";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
public static function user(){
|
||||
return Db::name('staff')->where('onwork',1)->select();
|
||||
}
|
||||
|
||||
|
||||
public static function type(){
|
||||
return Db::name('leave_type')->select();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function add($post){
|
||||
|
||||
$staff=StaffLogic::info($post['privilege']);
|
||||
$starttime_h = date('H',strtotime($post['start_time']));
|
||||
$enttime_h = date('H',strtotime($post['end_time']));
|
||||
//处理0
|
||||
$enttime_0 = date('H:i:s',strtotime($post['end_time']));
|
||||
if($enttime_0 == '00:00:00'){
|
||||
$post['end_time'] = date('Y-m-d',strtotime($post['end_time'])). '00:00:01';
|
||||
}
|
||||
|
||||
$days = [];
|
||||
$period = new \DatePeriod(
|
||||
new \DateTime($post['start_time']),
|
||||
new \DateInterval('P1D'),
|
||||
new \DateTime($post['end_time'])
|
||||
);
|
||||
$len = 0;
|
||||
foreach($period as $k=>$v){
|
||||
$len++;
|
||||
}
|
||||
foreach($period as $k=>$v){
|
||||
if($k == 0 && $starttime_h > 12){
|
||||
$days[] = ['addtime'=>1,'time'=>$v->format('Y-m-d')];
|
||||
continue;
|
||||
}
|
||||
|
||||
if($k === ($len - 1) && $enttime_h < 12){
|
||||
$days[] = ['addtime'=>1,'time'=>$v->format('Y-m-d')];
|
||||
continue;
|
||||
}
|
||||
|
||||
$days[] = ['addtime'=>1,'time'=>$v->format('Y-m-d')];
|
||||
$days[] = ['addtime'=>2,'time'=>$v->format('Y-m-d')];
|
||||
}
|
||||
|
||||
|
||||
if(empty($days)){
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
foreach($days as $v){
|
||||
|
||||
$data[] = [
|
||||
'name'=> $staff['base']['name'],
|
||||
'phone'=>$staff['base']['mobile'],
|
||||
'user_id'=>$staff['base']['id'],
|
||||
'status'=>0,
|
||||
'admin_id'=>$post['admin_id'],
|
||||
'time'=>strtotime($v['time']),
|
||||
'type'=>$post['level'],
|
||||
'remark'=>$post['remark'],
|
||||
'addtime'=>$v['addtime'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
}
|
||||
// $staff['base']['admin_id']=$post['admin_id'];
|
||||
return Db::name('leave')->insertAll($data);
|
||||
|
||||
|
||||
$data=[
|
||||
'name'=> $staff['base']['name'],
|
||||
'phone'=>$staff['base']['mobile'],
|
||||
'user_id'=>$staff['base']['id'],
|
||||
'status'=>0,
|
||||
'time'=>strtotime($post['end_time']),
|
||||
'type'=>$post['level'],
|
||||
'remark'=>$post['remark'],
|
||||
'addtime'=>$post['level'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function info($id){
|
||||
return Db::name('leave')->where('id',$id)->find();
|
||||
|
||||
}
|
||||
|
||||
public static function leave_statype(){
|
||||
return Db::name('leave_statype')->select();
|
||||
}
|
||||
|
||||
//员工请假内容
|
||||
|
||||
public static function staff_leave($get){
|
||||
$where = [];
|
||||
//查询
|
||||
//等级查询
|
||||
if(isset($get['staff_id']) && $get['staff_id'] != ''){
|
||||
$where[] = ['staff_id','=',$get['staff_id']];
|
||||
}
|
||||
|
||||
//分组查询
|
||||
if(isset($get['addtimes']) && $get['addtimes']!= ''){
|
||||
$where[] = ['addtime','=',$get['addtimes']];
|
||||
}
|
||||
if(isset($get['type']) && $get['type']){
|
||||
$where[] = ['type','=',$get['type']];
|
||||
}
|
||||
if(isset($get['statussd']) && $get['statussd']!= ''){
|
||||
$where[] = ['status','=',$get['statussd']];
|
||||
}
|
||||
|
||||
//日期查询
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_count = Db::name('leavesd')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$user_list = Db::name('leavesd')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
// //请假类型
|
||||
$type = Db::name('leave_statype')->column('name','id');
|
||||
foreach ($user_list as &$item){
|
||||
// //会员所属分组
|
||||
if(isset($type[$item['type']])){
|
||||
$item['type'] = $type[$item['type']];
|
||||
}
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$item['time']=date("Y-m-d",$item['time']);
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
|
||||
//请假审核通过
|
||||
public static function passed($post){
|
||||
// return Db::name('leavesd')->where('id',$post['id'])->update(['status'=>1]);
|
||||
$data=Db::name('leavesd')->where('id',$post['id'])->find(); //获取订单的基本信息
|
||||
|
||||
if($data['addtime']=0){ //判断上午订单
|
||||
$ord=Db::name('order_exe')
|
||||
->where('staff_id',$data['staff_id'])
|
||||
// ->where('autotime',$data['time'])
|
||||
->where('addtime',1)
|
||||
->find();
|
||||
return $ord;
|
||||
}
|
||||
else if($data['addtime']=1){ //判断上午订单
|
||||
$ord=Db::name('order_exe')
|
||||
->where('staff_id',$data['staff_id'])
|
||||
->where('autotime',$data['time'])
|
||||
->where('addtime',2)
|
||||
->find();
|
||||
return $ord;
|
||||
}
|
||||
else{
|
||||
return Db::name('leavesd')->where('id',$post['id'])->update(['status'=>1]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//根据id查询内容出来
|
||||
public static function refuse($id){
|
||||
return Db::name('leavesd')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
//根据id更新请假的状态
|
||||
public static function refusesd($post){
|
||||
return Db::name('leavesd')->where('id',$post['id'])->update(['status'=>2,'refuse'=>$post['code']]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
79
application/admin/logic/LogLogic.php
Normal file
79
application/admin/logic/LogLogic.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\admin\logic;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\helper\Time;
|
||||
|
||||
class LogLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取日志列表
|
||||
* @param $page_no
|
||||
* @param $size
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($page_no, $size, $get)
|
||||
{
|
||||
|
||||
$where[] = ['create_time', 'between', Time::today()];
|
||||
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where[] = ['create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
}
|
||||
|
||||
|
||||
if (isset($get['account']) && $get['account']) {
|
||||
$where[] = ['account', 'like', "%{$get['account']}%"];
|
||||
}
|
||||
if (isset($get['type']) && $get['type']) {
|
||||
$where[] = ['type', 'eq', $get['type']];
|
||||
}
|
||||
if (isset($get['uri']) && $get['uri']) {
|
||||
$where[] = ['uri', 'like', "%{$get['uri']}%"];
|
||||
}
|
||||
if (isset($get['ip']) && $get['ip']) {
|
||||
$where[] = ['ip', 'like', "%{$get['ip']}%"];
|
||||
}
|
||||
|
||||
|
||||
$lists = Db::name('system_log')
|
||||
->where($where)
|
||||
->page($page_no, $size)
|
||||
->order(['id' => 'desc'])
|
||||
->select();
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['create_time_str'] = date('Y-m-d H:i:s', $v['create_time']);
|
||||
$lists[$k]['param'] = str_replace([" ", " ", "\t", "\n", "\r"], '', $v['param']);
|
||||
}
|
||||
|
||||
$count = Db::name('system_log')
|
||||
->where($where)
|
||||
->count();
|
||||
return ['lists' => $lists, 'count' => $count];
|
||||
}
|
||||
}
|
||||
96
application/admin/logic/LoginLogic.php
Normal file
96
application/admin/logic/LoginLogic.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\server\LoginServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
|
||||
class LoginLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param $post
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function login($post)
|
||||
{
|
||||
//session激活
|
||||
$admin_info = Db::name('admin')
|
||||
->field(['id', 'account', 'name', 'role_id'])
|
||||
->where(['account' => $post['account'], 'del' => 0])
|
||||
->find();
|
||||
session('admin_info', $admin_info);
|
||||
LoginServer::setState($admin_info['id']);
|
||||
//登录信息更新
|
||||
$ip = request()->ip();
|
||||
$time = time();
|
||||
Db::name('admin')
|
||||
->where(['account' => $post['account'], 'del' => 0])
|
||||
->update(['login_ip' => $ip, 'login_time' => $time]);
|
||||
|
||||
//记住账号
|
||||
if (isset($post['remember_account']) && $post['remember_account'] == 'on') {
|
||||
\think\facade\Cookie::set('account', $post['account']);
|
||||
} else {
|
||||
\think\facade\Cookie::delete('account');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
* @param $admin_id
|
||||
*/
|
||||
public static function logout($admin_id)
|
||||
{
|
||||
if ($admin_id) {
|
||||
//清除登录标识
|
||||
LoginServer::setState($admin_id, false);
|
||||
}
|
||||
session(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录页面配置
|
||||
* @return array
|
||||
*/
|
||||
public static function config()
|
||||
{
|
||||
$config = [
|
||||
'company_name' => ConfigServer::get('copyright', 'company_name'),
|
||||
'number' => ConfigServer::get('copyright', 'number'),
|
||||
'link' => ConfigServer::get('copyright', 'link'),
|
||||
'admin_image' => ConfigServer::get('website', 'admin_image'),
|
||||
'admin_title' => ConfigServer::get('website', 'admin_title'),
|
||||
'name' => ConfigServer::get('website', 'name'),
|
||||
'login_logo' => ConfigServer::get('website', 'login_logo'),
|
||||
'slogan' => ConfigServer::get('website', 'slogan'),
|
||||
'slogan_status' => ConfigServer::get('website', 'slogan_status'),
|
||||
'web_favicon' => ConfigServer::get('website', 'web_favicon'),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
}
|
||||
234
application/admin/logic/LuckDrawLogic.php
Normal file
234
application/admin/logic/LuckDrawLogic.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\Luckdraw;
|
||||
use app\common\model\LuckdrawRecord;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class LuckDrawLogic
|
||||
{
|
||||
protected static $error; //错误信息
|
||||
|
||||
/**
|
||||
* Notes: 错误错误信息
|
||||
* @author 张无忌(2021/1/12 16:01)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 奖品列表
|
||||
* @author 张无忌(2021/1/25 11:28)
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [
|
||||
['is_delete', '=', 0]
|
||||
];
|
||||
|
||||
$model = new Luckdraw();
|
||||
$count = $model->where($where)->count();
|
||||
$lists = $model->field(true)->where($where)
|
||||
->order(['sort'=>'desc'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['number'] = $item['prize_type'] == 2 ? '-' : $item['number'];
|
||||
$item['probability'] = $item['probability'] . '%';
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'list'=>$lists];
|
||||
}
|
||||
|
||||
public static function detail($id)
|
||||
{
|
||||
$model = new Luckdraw();
|
||||
return $model->field(true)
|
||||
->where('id', '=', (int)$id)
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 新增奖品
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/26 10:28)
|
||||
* @return bool
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
try {
|
||||
$name_text = ['', '实物商品', '虚拟商品', '优惠券','商城积分'.'谢谢参与'];
|
||||
$post['name'] = $name_text[$post['prize_type']];
|
||||
$post['image'] = !empty($post['image']) ? $post['image'] : '';
|
||||
|
||||
$model = new Luckdraw();
|
||||
return $model->save([
|
||||
'prize_type' => $post['prize_type'],
|
||||
'name' => $post['name'],
|
||||
'image' => $post['image'],
|
||||
'number' => $post['number'],
|
||||
'sort' => $post['sort'],
|
||||
'probability' => $post['probability'],
|
||||
'status' => $post['status'],
|
||||
'is_delete' => 0,
|
||||
'create_time' => time(),
|
||||
'update_time' => time()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑奖品
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/26 10:28)
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
try {
|
||||
$name_text = ['', '实物商品', '虚拟商品', '优惠券','商城积分'.'谢谢参与'];
|
||||
$post['name'] = $name_text[$post['prize_type']];
|
||||
$post['image'] = !empty($post['image']) ? $post['image'] : '';
|
||||
|
||||
$model = new Luckdraw();
|
||||
$result = $model->where(['id'=>(int)$post['id']])->update([
|
||||
'prize_type' => $post['prize_type'],
|
||||
'name' => $post['name'],
|
||||
'image' => $post['image'],
|
||||
'number' => $post['number'],
|
||||
'sort' => $post['sort'],
|
||||
'probability' => $post['probability'],
|
||||
'status' => $post['status'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
return $result ? true : false;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 删除奖品
|
||||
* @param $id
|
||||
* @author 张无忌(2021/1/26 11:17)
|
||||
* @return bool
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
try {
|
||||
$model = new Luckdraw();
|
||||
$result = $model->where(['id'=>(int)$id])->update([
|
||||
'is_delete' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
return $result ? true : false;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 更新抽奖设置
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/26 11:40)
|
||||
* @return bool
|
||||
* @throws \think\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function set($post)
|
||||
{
|
||||
if ($post['status'] == 1) {
|
||||
$model = new Luckdraw();
|
||||
$count = $model->field(true)
|
||||
->where(['is_delete' => 0, 'status'=>1])
|
||||
->order(['id'=>'desc', 'sort'=>'desc'])
|
||||
->count();
|
||||
if ($count < 8) {
|
||||
static::$error = '请设置最少8个抽奖商品再来启动';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigServer::set('luckdraw', 'limit', $post['limit']);
|
||||
ConfigServer::set('luckdraw', 'rule', $post['rule']);
|
||||
ConfigServer::set('luckdraw', 'status', $post['status']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 抽奖记录
|
||||
* @param $get
|
||||
* @author 张无忌(2021/1/26 14:08)
|
||||
* @return array
|
||||
*/
|
||||
public static function record($get)
|
||||
{
|
||||
$model = new LuckdrawRecord();
|
||||
$count = $model->count();
|
||||
$lists = $model->field(true)
|
||||
->with('user')
|
||||
->order('id', 'desc')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
return ['count'=>$count, 'list'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 切换状态
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/13 17:53)
|
||||
* @return bool
|
||||
*/
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
try {
|
||||
$model = new Luckdraw();
|
||||
$model->where(['id' => (int)$post['id']])->update([
|
||||
'status' => $post['status'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 更新排序
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/13 17:53)
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateSort($post)
|
||||
{
|
||||
try {
|
||||
$model = new Luckdraw();
|
||||
$model->where(['id' => (int)$post['id']])->update([
|
||||
$post['field'] => $post['data'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
application/admin/logic/MarketingConfigLogic.php
Normal file
41
application/admin/logic/MarketingConfigLogic.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
|
||||
class MarketingConfigLogic{
|
||||
public static function getConfig($config_list){
|
||||
$config = [];
|
||||
foreach ($config_list as $config_name){
|
||||
$value = ConfigServer::get('marketing',$config_name,0);
|
||||
$config[$config_name] = $value;
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
public static function setConfig($post){
|
||||
foreach ($post as $config_name => $config_value){
|
||||
ConfigServer::set('marketing',$config_name,$config_value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function getCouponList(){
|
||||
return Db::name('coupon')->where(['status'=>1,'del'=>0,'get_type'=>2])->field('id,name')->select();
|
||||
}
|
||||
}
|
||||
363
application/admin/logic/MaterialLogic.php
Normal file
363
application/admin/logic/MaterialLogic.php
Normal file
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class MaterialLogic{
|
||||
/**
|
||||
* 显示查询列表的内容
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
//查询
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['keyword_type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
//等级查询
|
||||
if(isset($get['level']) && $get['level'] != ''){
|
||||
$where[] = ['level','=',$get['level']];
|
||||
}
|
||||
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
//消费金额
|
||||
if(isset($get['total_amount_start']) && $get['total_amount_start']){
|
||||
$where[] = ['total_order_amount','>=',$get['total_amount_start']];
|
||||
}
|
||||
if(isset($get['total_amount_end']) && $get['total_amount_end']){
|
||||
$where[] = ['total_order_amount','<=',$get['total_amount_end']];
|
||||
}
|
||||
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_count = Db::name('epr')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$user_list = Db::name('epr')
|
||||
->where($where)
|
||||
// ->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
$user_group = Db::name('staff_group')->column('name','id');
|
||||
|
||||
foreach ($user_list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
$item['abs_avatar']=UrlServer::getFileUrl($item['abs_avatar']);
|
||||
$grue=Db::name('staff_group')->where('id',$item['bellist_id'])->find();
|
||||
if($grue){
|
||||
$item['grue_name']=$grue['name'];
|
||||
}else{
|
||||
$item['grue_name']='-';
|
||||
}
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 修改原料的分类名称
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function typelist($get){
|
||||
$user_count = Db::name('material_type')
|
||||
->count();
|
||||
$user_list = Db::name('material_type')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['time']=date("Y-m-d H:i:s",$item['time']);
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 修改原料的分类列表
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function typelists(){
|
||||
$typelists = Db::name('material_type')->select();
|
||||
return $typelists;
|
||||
}
|
||||
/**
|
||||
* 增加原料的库存
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function add($get){
|
||||
$data = [
|
||||
'name' =>$get['name'],
|
||||
'namebm' =>$get['namebm'],
|
||||
'type' =>$get['brand_id'],
|
||||
'abs_avatar' =>$get['image'],
|
||||
'goodskc' =>$get['goodskc'],
|
||||
'price' =>$get['price'],
|
||||
'goodsxh' =>$get['goodsxh'],
|
||||
'goodsdw' =>$get['goodsdw'],
|
||||
'nots' =>$get['remarks'],
|
||||
'goodsyj' =>$get['goodsyj'],
|
||||
'bellist_id' =>$get['bellist_id'],
|
||||
'create_time' =>time(),
|
||||
];
|
||||
return Db::name('epr')->data($data)->insert();
|
||||
}
|
||||
/**
|
||||
* 查询材料库存
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function infolist($id){
|
||||
$info['base'] = Db::name('epr')
|
||||
->where(['id' => $id])
|
||||
->withAttr('abs_avatar', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['abs_avatar']);
|
||||
})
|
||||
->withAttr('content', function ($value){
|
||||
$preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
|
||||
$local_url = UrlServer::getFileUrl('/');
|
||||
return preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
|
||||
})
|
||||
->append(['abs_avatar','abs_video'])->find();
|
||||
return $info;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 编辑原料的内容
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function edit($get){
|
||||
$data = [
|
||||
'name' =>$get['name'],
|
||||
'namebm' =>$get['namebm'],
|
||||
'type' =>$get['brand_id'],
|
||||
'abs_avatar' =>$get['image'],
|
||||
'goodskc' =>$get['goodskc'],
|
||||
'price' =>$get['price'],
|
||||
'goodsxh' =>$get['goodsxh'],
|
||||
'goodsdw' =>$get['goodsdw'],
|
||||
'nots' =>$get['remarks'],
|
||||
'goodsyj' =>$get['goodsyj'],
|
||||
'bellist_id' =>$get['bellist_id'],
|
||||
'create_time' =>time(),
|
||||
];
|
||||
return Db::name('epr')->where('id',$get['id'])->data($data)->update();
|
||||
}
|
||||
/**
|
||||
* 编辑员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beedit($get){
|
||||
return Db::name('staff_group')->where(['id'=>$get['id']])->update(['name'=>$get['name']]);
|
||||
}
|
||||
/**
|
||||
* 增加员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beeadd($get){
|
||||
return Db::name('staff_group')->data(['name'=>$get['name']])->insert();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beedel($id){
|
||||
return Db::name('staff_group')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改员工的服务类别
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typeedit($post){
|
||||
return Db::name('staff_type')->where(['id'=>$post['id']])->update(['name'=>$post['name']]);
|
||||
}
|
||||
/**
|
||||
* 删除员工服务类别
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typedel($id){
|
||||
return Db::name('staff_type')->where('id',$id)->delete();
|
||||
}
|
||||
/**
|
||||
* 获取员工的分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beed(){
|
||||
return Db::name('staff_group')->field('id,name')->select();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function exportFile($get)
|
||||
{
|
||||
$where[] = ['del','=', '0'];
|
||||
|
||||
//查询
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['keyword_type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
//等级查询
|
||||
if(isset($get['level']) && $get['level'] != ''){
|
||||
$where[] = ['level','=',$get['level']];
|
||||
}
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
//消费金额
|
||||
if(isset($get['total_amount_start']) && $get['total_amount_start']){
|
||||
$where[] = ['total_order_amount','>=',$get['total_amount_start']];
|
||||
}
|
||||
if(isset($get['total_amount_end']) && $get['total_amount_end']){
|
||||
$where[] = ['total_order_amount','<=',$get['total_amount_end']];
|
||||
}
|
||||
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_list = Db::name('user')->where($where)
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
//会员分组
|
||||
$user_group = Db::name('user_group')->where(['del'=>0])->column('name','id');
|
||||
//会员等级
|
||||
$user_level = Db::name('user_level')->where(['del'=>0])->column('name','id');
|
||||
// 所有会员信息
|
||||
$all_user_list = User::where(['del'=>0])->column('sn,nickname,mobile,level','id');
|
||||
|
||||
$exportData = [];
|
||||
foreach ($user_list as $item){
|
||||
$groupName = '-';
|
||||
$levelName = '无等级';
|
||||
//会员所属分组
|
||||
if(isset($user_group[$item['group_id']])){
|
||||
$groupName = $user_group[$item['group_id']];
|
||||
}
|
||||
|
||||
if(isset($user_level[$item['level']])){
|
||||
$levelName = $user_level[$item['level']];
|
||||
}
|
||||
|
||||
$referrer_user_info = '';
|
||||
$referrer_nickname = '';
|
||||
$referrer_sn = '';
|
||||
$referrer_mobile = '';
|
||||
$referrer_level_name = '-';
|
||||
if(isset($all_user_list[$item['first_leader']])){
|
||||
$referrer_user = $all_user_list[$item['first_leader']];
|
||||
$referrer_nickname = $referrer_user['nickname'];
|
||||
$referrer_sn = $referrer_user['sn'];
|
||||
$referrer_mobile = $referrer_user['mobile'];
|
||||
if(isset($user_level[$referrer_user['level']])){
|
||||
$referrer_level_name =$user_level[$referrer_user['level']];
|
||||
}
|
||||
$referrer_user_info.= '【昵称:'.$referrer_nickname.' 编号:'.$referrer_sn. ' 手机:'. $referrer_mobile . ' 等级:'. $referrer_level_name.'】';
|
||||
}
|
||||
$loginTime = date('Y-m-d H:i:s', $item['login_time']);
|
||||
|
||||
$exportData[] = [$item['sn'], $item['nickname'], $levelName, $groupName, $referrer_user_info, $item['total_order_amount'], $item['user_money'], $item['user_integral'], $loginTime];
|
||||
}
|
||||
|
||||
$exportTitle = ['会员编号', '会员昵称', '会员等级', '会员分组', '推荐人信息', '消费金额', '账户余额', '积分', '最后登录时间'];
|
||||
$exportExt = 'xls';
|
||||
return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'会员列表'.date('Y-m-d H:i:s')];
|
||||
}
|
||||
|
||||
public static function usermaterial($post){
|
||||
|
||||
$where = [];
|
||||
//分组查询
|
||||
if(isset($post['staffid']) && $post['staffid']!=''){
|
||||
$where[] = ['staff_id','=',$post['staffid']];
|
||||
}
|
||||
|
||||
if(isset($post['name']) && $post['name']!=''){
|
||||
|
||||
$where[] = ['name', 'like', '%' . $post['name'] . '%'];
|
||||
}
|
||||
//注册时间
|
||||
if(isset($post['start_time']) && $post['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($post['start_time'])];
|
||||
}
|
||||
if(isset($post['end_time']) && $post['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($post['end_time'])];
|
||||
}
|
||||
|
||||
$user_count = Db::name('erp_staff')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$user_list = Db::name('erp_staff')
|
||||
->where($where)
|
||||
->page($post['page'],$post['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
if($staff){
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_phone']=$staff['mobile'];
|
||||
}
|
||||
$mater=Db::name('epr')->where('id',$item['goods_id'])->find();
|
||||
if($mater){
|
||||
$item['mater_name']=$mater['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
|
||||
}
|
||||
|
||||
public static function delusermaterial($id){
|
||||
return Db::name('erp_staff')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
public static function audit($id){
|
||||
return Db::name('erp_staff')->where('id',$id)->update(['status'=>2]);
|
||||
}
|
||||
|
||||
public static function noaudit(){
|
||||
return Db::name('erp_staff')->where('id',$id)->update(['status'=>1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
299
application/admin/logic/MenuDecorateLogic.php
Normal file
299
application/admin/logic/MenuDecorateLogic.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\model\Menu_;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class MenuDecorateLogic{
|
||||
/*
|
||||
* 获取列表
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$type = $get['type'] ?? 1;
|
||||
$where[] = ['del','=',0];
|
||||
$where[] = ['decorate_type', '=', $type];
|
||||
|
||||
$count = Db::name('menu_decorate')->where($where)->count();
|
||||
$lists = Db::name('menu_decorate')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
if($item['link_type'] == 1){
|
||||
$content = Menu_::getMenuContent($type,$item['link_address']);
|
||||
$item['link_address'] = $content['link'] ?? '';
|
||||
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
// 首页
|
||||
public static function indexList($get)
|
||||
{
|
||||
$where[] = ['del','=',0];
|
||||
$where[] = ['decorate_type', '=', 1];
|
||||
|
||||
$count = Db::name('menu_decorate')->where($where)->count();
|
||||
$lists = Db::name('menu_decorate')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
if($item['link_type'] == 1){
|
||||
$content = Menu_::getMenuContent(1,$item['link_address']);
|
||||
$item['link_address'] = $content['link'] ?? '';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
// 首页
|
||||
public static function centerList($get)
|
||||
{
|
||||
$where[] = ['del','=',0];
|
||||
$where[] = ['decorate_type', '=', 2];
|
||||
|
||||
$count = Db::name('menu_decorate')->where($where)->count();
|
||||
$lists = Db::name('menu_decorate')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
if($item['link_type'] == 1){
|
||||
$content = Menu_::getMenuContent(1,$item['link_address']);
|
||||
$item['link_address'] = $content['link'] ?? '';
|
||||
}
|
||||
}
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
/*
|
||||
* 新增
|
||||
*/
|
||||
public static function add($post){
|
||||
$link_address = $post['menu'];
|
||||
if($post['link_type'] == 2){
|
||||
$link_address = $post['url'];
|
||||
}
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'image' => $post['image'],
|
||||
'decorate_type' => $post['decorate_type'],
|
||||
'link_type' => $post['link_type'],
|
||||
'link_address' => $link_address,
|
||||
'sort' => $post['sort']?:0,
|
||||
'update_time' => $time,
|
||||
'create_time' => $time,
|
||||
'is_show' => $post['is_show'],
|
||||
];
|
||||
return Db::name('menu_decorate')->insert($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑菜单
|
||||
*/
|
||||
public static function edit($post){
|
||||
$link_address = $post['menu'];
|
||||
if($post['link_type'] == 2){
|
||||
$link_address = $post['url'];
|
||||
}
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'image' => $post['image'],
|
||||
'decorate_type' => $post['decorate_type'],
|
||||
'link_type' => $post['link_type'],
|
||||
'link_address' => $link_address,
|
||||
'sort' => $post['sort']?:0,
|
||||
'update_time' => $time,
|
||||
'is_show' => $post['is_show'],
|
||||
];
|
||||
return Db::name('menu_decorate')->where(['id'=>$post['id']])->update($data);
|
||||
}
|
||||
/*
|
||||
* 删除菜单
|
||||
*/
|
||||
public static function del($id){
|
||||
$data= [
|
||||
'del' =>1,
|
||||
'update_time' =>time()
|
||||
];
|
||||
return Db::name('menu_decorate')->where(['id'=>$id])->update($data);
|
||||
}
|
||||
/*
|
||||
* 批量删除菜单
|
||||
*/
|
||||
public static function batchDelMenuDecorate($ids){
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
return Db::name('menu_decorate')->where(['id'=>$ids])->update($data);
|
||||
}
|
||||
/*
|
||||
* 获取菜单
|
||||
*/
|
||||
public static function getMenuDecorate($id){
|
||||
$detail = Db::name('menu_decorate')->where(['id'=>$id])->find();
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加 - 底部导航
|
||||
*/
|
||||
public static function addNavigation($post)
|
||||
{
|
||||
if(empty($post['name'])) {
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '导航名称不能为空'
|
||||
];
|
||||
}
|
||||
$count = Db::name('dev_navigation')->where([
|
||||
['del', '=', 0],
|
||||
['name', '=', trim($post['name']) ]
|
||||
])->count();
|
||||
if($count) {
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '导航名称已存在'
|
||||
];
|
||||
}
|
||||
$data = [
|
||||
'name' => trim($post['name']),
|
||||
'selected_icon' => trim($post['selected_icon']),
|
||||
'un_selected_icon' => trim($post['un_selected_icon']),
|
||||
'create_time' => time(),
|
||||
'del' => 0
|
||||
];
|
||||
$result = Db::name('dev_navigation')->insert($data);
|
||||
if($result) {
|
||||
return [
|
||||
'flag' => true,
|
||||
'msg' => '添加成功'
|
||||
];
|
||||
}else{
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '添加失败'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航 - 列表
|
||||
*/
|
||||
public static function bottomNavigation($get)
|
||||
{
|
||||
$lists = Db::name('dev_navigation')
|
||||
->where('del', 0)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
$count = Db::name('dev_navigation')->count();
|
||||
foreach($lists as &$item) {
|
||||
$item['selected_icon'] = UrlServer::getFileUrl($item['selected_icon']);
|
||||
$item['un_selected_icon'] = UrlServer::getFileUrl($item['un_selected_icon']);
|
||||
}
|
||||
$data = [
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航 - 详情
|
||||
*/
|
||||
public static function getNavigation($id)
|
||||
{
|
||||
$navigation = Db::name('dev_navigation')->where('id', $id)->find();
|
||||
$navigation['selected_icon'] = $navigation['selected_icon'] ? UrlServer::getFileUrl($navigation['selected_icon']) : '';
|
||||
$navigation['un_selected_icon'] = $navigation['un_selected_icon'] ? UrlServer::getFileUrl($navigation['un_selected_icon']) : '';
|
||||
return $navigation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航 - 编辑
|
||||
*/
|
||||
public static function editNavigation($post)
|
||||
{
|
||||
if(empty($post['name'])) {
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '导航名称不能为空'
|
||||
];
|
||||
}
|
||||
$count = Db::name('dev_navigation')->where([
|
||||
['del', '=', 0],
|
||||
['name', '=', trim($post['name']) ],
|
||||
['id', '<>', $post['id']]
|
||||
])->count();
|
||||
if($count) {
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '导航名称已存在'
|
||||
];
|
||||
}
|
||||
$updateData = [
|
||||
'name' => trim($post['name']),
|
||||
'selected_icon' => trim($post['selected_icon']),
|
||||
'un_selected_icon' => trim($post['un_selected_icon']),
|
||||
'update_time' => time()
|
||||
];
|
||||
$result = Db::name('dev_navigation')->where('id', $post['id'])->update($updateData);
|
||||
if($result) {
|
||||
return [
|
||||
'flag' => true,
|
||||
'msg' => '编辑成功'
|
||||
];
|
||||
}else{
|
||||
return [
|
||||
'flag' => false,
|
||||
'msg' => '编辑失败'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 - 底部导航
|
||||
*/
|
||||
public static function delNavigation($id)
|
||||
{
|
||||
return Db::name('dev_navigation')->where('id', $id)->update([
|
||||
'del' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
79
application/admin/logic/MessageLogic.php
Normal file
79
application/admin/logic/MessageLogic.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\admin\logic;
|
||||
use think\Db;
|
||||
|
||||
class MessageLogic{
|
||||
|
||||
public static function config(){
|
||||
$list = Db::name('dev_message m')
|
||||
->join('dev_message_extend e','m.id = e.message_id')
|
||||
->where(['m.del'=>0])
|
||||
->field('m.*,e.status')
|
||||
->select();
|
||||
|
||||
$config = [
|
||||
'member' => [],
|
||||
'platform' => [],
|
||||
];
|
||||
|
||||
foreach ($list as $item){
|
||||
if($item['dev_type'] == 1){
|
||||
$config['member'][] = $item;
|
||||
}else{
|
||||
$config['platform'][] = $item;
|
||||
}
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function set($id,$type){
|
||||
|
||||
}
|
||||
|
||||
public static function getMessage($id){
|
||||
$config = Db::name('dev_message_extend e')
|
||||
->join('dev_message d','e.message_id = d.id')
|
||||
->where(['e.id'=>$id])
|
||||
->field('d.name,e.*')
|
||||
->find();
|
||||
|
||||
if($config['variable']){
|
||||
$config['variable'] = json_decode($config['variable'],true);
|
||||
}else{
|
||||
$config['variable'] = [];
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function setConfig($post){
|
||||
$post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 0;
|
||||
return Db::name('dev_message_extend')->where(['id'=>$post['id']])->update($post);
|
||||
}
|
||||
|
||||
|
||||
public static function addmess($post){
|
||||
return Db::name('user_message')->where('id',1)->update([
|
||||
'names'=>$post['name'],
|
||||
'keys'=>$post['key'],
|
||||
'selectkey'=>$post['select'],
|
||||
'show'=>$post['remark']
|
||||
]);
|
||||
}
|
||||
}
|
||||
69
application/admin/logic/MnpLogic.php
Normal file
69
application/admin/logic/MnpLogic.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
class MnpLogic{
|
||||
public static function getMnp(){
|
||||
$domain_name = $_SERVER['SERVER_NAME'];
|
||||
$qr_code = ConfigServer::get('mnp', 'qr_code', '');
|
||||
$config = [
|
||||
'name' => ConfigServer::get('mnp', 'name', ''),
|
||||
'original_id' => ConfigServer::get('mnp', 'original_id', ''),
|
||||
'qr_code' => $qr_code,
|
||||
'abs_qr_code' => UrlServer::getFileUrl($qr_code),
|
||||
'app_id' => ConfigServer::get('mnp', 'app_id', ''),
|
||||
'app_secret' => ConfigServer::get('mnp', 'secret', ''),
|
||||
'request_domain' => 'https://'.$domain_name,
|
||||
'socket_domain' => 'wss://'.$domain_name,
|
||||
'uploadfile_domain' => 'https://'.$domain_name,
|
||||
'downloadfile_domain' => 'https://'.$domain_name,
|
||||
'udp_domain' => 'udp://'.$domain_name,
|
||||
'business_domain' => $domain_name,
|
||||
'url' => url('api/weChat/index','','',true),
|
||||
'token' => ConfigServer::get('mnp', 'token', 'LikeShop'),
|
||||
'encoding_ses_key' => ConfigServer::get('mnp', 'encoding_ses_key', ''),
|
||||
'encryption_type' => ConfigServer::get('mnp', 'encryption_type', ''),
|
||||
'data_type' => ConfigServer::get('mnp', 'data_type', ''),
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
public static function setMnp($post){
|
||||
if($post){
|
||||
if(!isset($post['encryption_type'])){
|
||||
$post['encryption_type'] = '';
|
||||
}
|
||||
if(!isset($post['data_type'])){
|
||||
$post['data_type'] = '';
|
||||
}
|
||||
ConfigServer::set('mnp','name',$post['name']);
|
||||
ConfigServer::set('mnp','original_id',$post['original_id']);
|
||||
ConfigServer::set('mnp','qr_code',$post['qr_code']);
|
||||
ConfigServer::set('mnp','app_id',$post['app_id']);
|
||||
ConfigServer::set('mnp','secret',$post['app_secret']);
|
||||
// ConfigServer::set('mnp','token',$post['token']);
|
||||
// ConfigServer::set('mnp','encoding_ses_key',$post['encoding_ses_key']);
|
||||
// ConfigServer::set('mnp','encryption_type',$post['encryption_type']);
|
||||
// ConfigServer::set('mnp','data_type',$post['data_type']);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
96
application/admin/logic/MnpMessageLogic.php
Normal file
96
application/admin/logic/MnpMessageLogic.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\LogicBase;
|
||||
use app\common\model\MessageScene_;
|
||||
use app\common\server\WeChatServer;
|
||||
use EasyWeChat\Factory;
|
||||
use think\Db;
|
||||
|
||||
class MnpMessageLogic extends LogicBase
|
||||
{
|
||||
// 获取表
|
||||
public static function lists($get)
|
||||
{
|
||||
$where[] = ['type', '=', 1];
|
||||
|
||||
if(isset($get['disable']) && is_numeric($get['disable'])){
|
||||
$where[] = ['disable', '=', (int)$get['disable']];
|
||||
}
|
||||
|
||||
$count = Db::name('dev_message_template')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('dev_message_template')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
|
||||
$scene = (new MessageScene_());
|
||||
foreach ($lists as &$item) {
|
||||
$item['scene'] = $scene->getName($item['scene']);
|
||||
}
|
||||
|
||||
return ['count' => $count,'list' => $lists];
|
||||
}
|
||||
|
||||
// 获取单个消息模板
|
||||
public static function getTemplateMessage($id)
|
||||
{
|
||||
return Db::name('dev_message_template')->where(['id' => (int)$id])->find();
|
||||
}
|
||||
|
||||
// 更新消息模板状态
|
||||
public static function switchStatus($data)
|
||||
{
|
||||
$update_data = [
|
||||
'disable' => $data['disable']
|
||||
];
|
||||
return Db::name('dev_message_template')->where(['id' => (int)$data['id']])->update($update_data);
|
||||
}
|
||||
|
||||
// 同步消息模板到公众号
|
||||
public static function synchro($data)
|
||||
{
|
||||
try {
|
||||
$model = Db::name('dev_message_template')->where(['id' => (int)$data['id']])->find();
|
||||
|
||||
// 发起同步到公众号
|
||||
$config = WeChatServer::getMnpConfig();
|
||||
$app = Factory::miniProgram($config);
|
||||
$result = $app->subscribe_message->addTemplate($model['template_id_short'], explode(',', $model['keywords']), $model['name']);
|
||||
|
||||
// 获取关键词库(调试用)
|
||||
// $result = $app->subscribe_message->getTemplateKeywords('492');
|
||||
|
||||
// 保存返回的template_id
|
||||
if ($result['errcode'] === 0 && isset($result['priTmplId'])) {
|
||||
$update_data = ['template_id' => $result['priTmplId']];
|
||||
Db::name('dev_message_template')->where(['id' => (int)$data['id']])->update($update_data);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
application/admin/logic/MyLogic.php
Normal file
45
application/admin/logic/MyLogic.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class MyLogic
|
||||
{
|
||||
/**
|
||||
* 修改密码
|
||||
* @param $password
|
||||
* @param $admin_id
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function updatePassword($password, $admin_id)
|
||||
{
|
||||
$salt = Db::name('admin')
|
||||
->where(['id' => $admin_id])
|
||||
->value('salt');
|
||||
$password = create_password($password, $salt);
|
||||
|
||||
Db::name('admin')
|
||||
->where(['id' => $admin_id])
|
||||
->update(['update_time' => time(), 'password' => $password]);
|
||||
}
|
||||
|
||||
}
|
||||
190
application/admin/logic/NoticeSettingLogic.php
Normal file
190
application/admin/logic/NoticeSettingLogic.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\NoticeSetting;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 逻辑
|
||||
* Class NoticeSettingLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class NoticeSettingLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 列表
|
||||
* @param $type
|
||||
* @author 段誉(2021/4/26 16:18)
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($type)
|
||||
{
|
||||
$count = NoticeSetting::where('type', $type)->count();
|
||||
$lists = NoticeSetting::where('type', $type)->select();
|
||||
return ['lists' => $lists, 'count' => $count];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 设置通知消息
|
||||
* @param $post
|
||||
* @author 段誉(2021/4/26 16:18)
|
||||
* @return bool
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function set($post)
|
||||
{
|
||||
switch ($post['type']) {
|
||||
case 'system':
|
||||
$setting = [
|
||||
'title' => $post['title'],
|
||||
'content' => $post['content'],
|
||||
'is_push' => $post['is_push'],
|
||||
'status' => $post['status'],
|
||||
];
|
||||
break;
|
||||
case 'sms':
|
||||
$setting = [
|
||||
'template_code' => $post['template_code'],
|
||||
'content' => $post['content'],
|
||||
'status' => $post['status'],
|
||||
];
|
||||
break;
|
||||
case 'oa':
|
||||
$setting = [
|
||||
'name' => $post['name'],
|
||||
'first' => $post['first'],
|
||||
'template_sn' => $post['template_sn'],
|
||||
'template_id' => $post['template_id'],
|
||||
'remark' => $post['remark'],
|
||||
'status' => $post['status'],
|
||||
'tpl' => self::formatTplData($post)
|
||||
];
|
||||
break;
|
||||
case 'mnp':
|
||||
$setting = [
|
||||
'name' => $post['name'],
|
||||
'template_sn' => $post['template_sn'],
|
||||
'template_id' => $post['template_id'],
|
||||
'status' => $post['status'],
|
||||
'tpl' => self::formatTplData($post),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$setting = [];
|
||||
}
|
||||
|
||||
NoticeSetting::where('id', $post['id'])
|
||||
->update([
|
||||
$post['type'].'_notice' => json_encode($setting, JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 详情
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @author 段誉(2021/4/26 17:34)
|
||||
* @return NoticeSetting
|
||||
*/
|
||||
public static function info($id, $type)
|
||||
{
|
||||
return NoticeSetting::where('id', $id)->find();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 格式化模板数据
|
||||
* @param $post
|
||||
* @author 段誉(2021/4/26 14:55)
|
||||
* @return array
|
||||
*/
|
||||
public static function formatTplData($post)
|
||||
{
|
||||
foreach ($post as &$value) {
|
||||
if (is_array($value)) {
|
||||
$value = array_values($value);
|
||||
}
|
||||
}
|
||||
return form_to_linear($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知记录
|
||||
*/
|
||||
public static function record($get)
|
||||
{
|
||||
$where = [
|
||||
['send_type', '=', $get['send_type']]
|
||||
];
|
||||
|
||||
if(isset($get['content']) && !empty(trim($get['content']))) {
|
||||
$where[] = ['content', 'like', '%' . trim($get['content']) . '%'];
|
||||
}
|
||||
if(isset($get['create_time']) && !empty(trim($get['create_time']))) {
|
||||
$createTimeArr = explode('#', $get['create_time']);
|
||||
$start_time = strtotime(trim($createTimeArr[0]));
|
||||
$end_time = strtotime(trim($createTimeArr[1]));
|
||||
$where[] = ['create_time', '>=', $start_time];
|
||||
$where[] = ['create_time', '<=', $end_time];
|
||||
}
|
||||
|
||||
$scene = Db::name('dev_notice_setting')->where(['id'=>$get['id']])->value('scene');
|
||||
$where[] = ['scene', '=', $scene];
|
||||
|
||||
$lists = Db::name('notice')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('create_time', 'desc')
|
||||
->select();
|
||||
$count = Db::name('notice')->where($where)->count();
|
||||
foreach($lists as &$item) {
|
||||
$item['sceneDesc'] = NoticeSetting::getSceneDesc($item['scene']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
switch ($item['receive_type']) {
|
||||
case 1: // 平台
|
||||
$item['userInfo'] = '平台';
|
||||
break;
|
||||
case 2:
|
||||
$user = Db::name('user')->field('sn,nickname')->where('id',$item['user_id'])->find();
|
||||
$item['userInfo'] = $user;
|
||||
break;
|
||||
case 3:
|
||||
$item['userInfo'] = '游客';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
}
|
||||
}
|
||||
140
application/admin/logic/OaLogic.php
Normal file
140
application/admin/logic/OaLogic.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\logic\LogicBase;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use EasyWeChat\Factory;
|
||||
use think\Db;
|
||||
use EasyWeChat\Kernel\Exceptions\Exception;
|
||||
|
||||
class OaLogic extends LogicBase{
|
||||
public static function getOa(){
|
||||
$domain_name = $_SERVER['SERVER_NAME'];
|
||||
$qr_code = ConfigServer::get('oa', 'qr_code', '');
|
||||
$config = [
|
||||
'name' => ConfigServer::get('oa', 'name', ''),
|
||||
'original_id' => ConfigServer::get('oa', 'original_id', ''),
|
||||
'qr_code' => $qr_code,
|
||||
'abs_qr_code' => UrlServer::getFileUrl($qr_code),
|
||||
'app_id' => ConfigServer::get('oa', 'app_id', ''),
|
||||
'app_secret' => ConfigServer::get('oa', 'secret', ''),
|
||||
'url' => url('api/weChat/index','','',true),
|
||||
'token' => ConfigServer::get('oa', 'token', 'LikeShop'),
|
||||
'encoding_ses_key' => ConfigServer::get('oa', 'encoding_ses_key', ''),
|
||||
'encryption_type' => ConfigServer::get('oa', 'encryption_type', 1),
|
||||
'business_domain' => $domain_name,
|
||||
'safety_domain' => $domain_name,
|
||||
'auth_domain' => $domain_name,
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
public static function setOa($post){
|
||||
if($post){
|
||||
if(!isset($post['encryption_type'])){
|
||||
$post['encryption_type'] = '';
|
||||
}
|
||||
ConfigServer::set('oa','name',$post['name']);
|
||||
ConfigServer::set('oa','original_id',$post['original_id']);
|
||||
ConfigServer::set('oa','qr_code',$post['qr_code']);
|
||||
ConfigServer::set('oa','app_id',$post['app_id']);
|
||||
ConfigServer::set('oa','secret',$post['app_secret']);
|
||||
ConfigServer::set('oa','token',$post['token']);
|
||||
ConfigServer::set('oa','encoding_ses_key',$post['encoding_ses_key']);
|
||||
ConfigServer::set('oa','encryption_type',$post['encryption_type']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function pulishMenu($buttons){
|
||||
try {
|
||||
$config = WeChatServer::getOaConfig();
|
||||
|
||||
if(empty($config['app_id']) || empty($config['secret'])){
|
||||
return self::dataError('请先配置微信公众号参数');
|
||||
}
|
||||
|
||||
$app = Factory::officialAccount($config);
|
||||
|
||||
$result = $app->menu->create($buttons);
|
||||
|
||||
if($result['errcode'] == 0){
|
||||
|
||||
ConfigServer::set('menu','wechat_menu',$buttons);
|
||||
return self::dataSuccess('菜单发布成功');
|
||||
}
|
||||
return self::dataError('菜单发布失败:'.json_encode($result));
|
||||
|
||||
} catch (Exception $e){
|
||||
return self::dataError($e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function data($get){
|
||||
$where = [];
|
||||
// //查询
|
||||
if(isset($get['order_sn']) && $get['order_sn']!=''){
|
||||
$where[] = ['order_sn','=',$get['order_sn']];
|
||||
}
|
||||
if(isset($get['order_sn']) && $get['order_sn']!=''){
|
||||
$where[] = ['order_sn','=',$get['order_sn']];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone']!=''){
|
||||
// $where[] = [$get['phone'],'like','%'.$get['phone'].'%'];
|
||||
$where[] = ['phone','=',$get['phone']];
|
||||
}
|
||||
if(isset($get['area_id']) && $get['area_id']!=''){
|
||||
$where[] = ['area_id','=',$get['area_id']];
|
||||
}
|
||||
if(isset($get['channel_id']) && $get['channel_id']!=''){
|
||||
$where[] = ['channel_id','=',$get['channel_id']];
|
||||
}
|
||||
if(isset($get['status']) && $get['status']!=''){
|
||||
$where[] = ['status','=',$get['status']];
|
||||
}
|
||||
//下单时间检索
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
if(isset($get['consignee']) && $get['consignee']!=''){
|
||||
$where[] = ['consignee', 'like', '%' . $get['consignee'] . '%'];
|
||||
}
|
||||
|
||||
$user_count =Db::name('order_yearcard')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_list =Db::name('order_yearcard')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
}
|
||||
93
application/admin/logic/OaMessageLogic.php
Normal file
93
application/admin/logic/OaMessageLogic.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\LogicBase;
|
||||
use app\common\model\MessageScene_;
|
||||
use app\common\server\WeChatServer;
|
||||
use EasyWeChat\Factory;
|
||||
use think\Db;
|
||||
|
||||
class OaMessageLogic extends LogicBase
|
||||
{
|
||||
|
||||
// 获取表
|
||||
public static function lists($get)
|
||||
{
|
||||
$where[] = ['type', '=', 2];
|
||||
|
||||
if(isset($get['disable']) && is_numeric($get['disable'])){
|
||||
$where[] = ['disable', '=', (int)$get['disable']];
|
||||
}
|
||||
|
||||
$count = Db::name('dev_message_template')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('dev_message_template')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
|
||||
$scene = (new MessageScene_());
|
||||
foreach ($lists as &$item) {
|
||||
$item['scene'] = $scene->getName($item['scene']);
|
||||
}
|
||||
|
||||
return ['count' => $count,'list' => $lists];
|
||||
}
|
||||
|
||||
// 获取单个消息模板
|
||||
public static function getTemplateMessage($id)
|
||||
{
|
||||
return Db::name('dev_message_template')->where(['id' => (int)$id])->find();
|
||||
}
|
||||
|
||||
// 更新消息模板状态
|
||||
public static function switchStatus($data)
|
||||
{
|
||||
$update_data = [
|
||||
'disable' => $data['disable']
|
||||
];
|
||||
return Db::name('dev_message_template')->where(['id' => (int)$data['id']])->update($update_data);
|
||||
}
|
||||
|
||||
// 同步消息模板到公众号
|
||||
public static function synchro($data)
|
||||
{
|
||||
try {
|
||||
$model = Db::name('dev_message_template')->where(['id' => (int)$data['id']])->find();
|
||||
// 发起同步到公众号
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$result = $app->template_message->addTemplate($model['template_id_short']);
|
||||
|
||||
// 保存返回的template_id
|
||||
if ($result['errcode'] === 0 && isset($result['template_id'])) {
|
||||
$update_data = ['template_id' => $result['template_id']];
|
||||
Db::name('dev_message_template')->where(['id' => (int)$data['id']])->update($update_data);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
application/admin/logic/OpLogic.php
Normal file
24
application/admin/logic/OpLogic.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class OpLogic{
|
||||
public static function getConfig($config_list){
|
||||
$config = [];
|
||||
foreach ($config_list as $config_name){
|
||||
$value = ConfigServer::get('op', $config_name, '');
|
||||
$config[$config_name] = $value;
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
public static function setConfig($config_list){
|
||||
foreach ($config_list as $config_name => $config_value){
|
||||
ConfigServer::set('op',$config_name,$config_value);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1143
application/admin/logic/OrderLogic.php
Normal file
1143
application/admin/logic/OrderLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
705
application/admin/logic/OrderautoLogic.php
Normal file
705
application/admin/logic/OrderautoLogic.php
Normal file
@@ -0,0 +1,705 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\admin\logic\UserLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
class OrderautoLogic{
|
||||
/**
|
||||
* 显示查询列表的内容
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
//判断已经支付的订单
|
||||
$where[] = ['pay_status', '=', 1];
|
||||
if(isset($get['type']) && $get['type'] != ''){
|
||||
$where[] = ['static','=',$get['type']];
|
||||
}
|
||||
//等级查询
|
||||
if(isset($get['id']) && $get['id'] != ''){
|
||||
$where[] = ['order_sn','=',$get['id']];
|
||||
}
|
||||
if(isset($get['name']) && $get['name']!= ''){
|
||||
$where[] = ['consignee', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//电话查询
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$where[] = ['mobile','=',$get['phone']];
|
||||
}
|
||||
//地区查询
|
||||
if(isset($get['area_id']) && $get['area_id']!= ''){
|
||||
$where[] = ['area_id','=',$get['area_id']];
|
||||
}
|
||||
// 执行状态查询
|
||||
if(isset($get['status']) && $get['status']!= ''){
|
||||
$where[] = ['status','=',$get['status']];
|
||||
}
|
||||
|
||||
// 执行状态查询
|
||||
if(isset($get['admin']) && $get['admin']!= ''){
|
||||
$where[] = ['admin_id','=',$get['admin']];
|
||||
}
|
||||
// 订单的来源查询
|
||||
if(isset($get['pid']) && $get['pid']!= ''){
|
||||
$where[] = ['channel_id','=',$get['pid']];
|
||||
}
|
||||
//执行时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
//订单的来源
|
||||
$channel = Db::name('orderchannel')->column('name','id');
|
||||
//订单的类型
|
||||
$brand = Db::name('goods_brand')->where('del',0)->column('name','id');
|
||||
$order_count = Db::name('order')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
$order_list = Db::name('order')
|
||||
->where($where)
|
||||
->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($order_list as &$item){
|
||||
$item['channel'] = '系统自助下单';
|
||||
$item['create_time']=date("Y-m-d",$item['create_time']);
|
||||
if(isset($channel[$item['channel_id']])){
|
||||
$item['channel'] = $channel[$item['channel_id']];
|
||||
}
|
||||
if(isset($brand[$item['type_id']])){
|
||||
$item['brand'] = $brand[$item['type_id']];
|
||||
}
|
||||
//获取到用户信息
|
||||
$user=Db::name('user_address')->where('id',$item['user_id'])->find();
|
||||
if($user){
|
||||
$item['nickname']=$user['contact'];
|
||||
if($user['wx']==2){
|
||||
$item['wx']='已添加企业微信';
|
||||
}else{
|
||||
$item['wx']='未添加企业微信';
|
||||
}
|
||||
$item['areas']=$user['areas'];
|
||||
$item['staff_remarks']=$user['staff_remarks'];
|
||||
$item['admin_remarks']=$user['admin_remarks'];
|
||||
$item['pet']=$user['pet'];
|
||||
$item['hbl']=$user['hbl'];
|
||||
}
|
||||
|
||||
$userimg=Db::name('user')->where('id',$item['user_id'])->find();
|
||||
if($userimg){
|
||||
$item['avatar']=$userimg['avatar'];
|
||||
}
|
||||
//获取订单的商品
|
||||
$goods=Db::name('goods')->where('id',$item['goods_id'])->find();
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
}
|
||||
$item['sycs']=Db::name('order_exe')->where('order_sn',$item['order_sn'])->where('status',1)->count();
|
||||
if($item['code']==0){
|
||||
$update=Db::name('order')->where('order_sn',$item['order_sn'])->update(['static'=>2]);
|
||||
}
|
||||
if($item['number']==$item['sycs']){
|
||||
$update=Db::name('order')->where('order_sn',$item['order_sn'])->update(['static'=>2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$order_count , 'lists'=>$order_list];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择客户的列表
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function getUserList($get,$is_item = false){
|
||||
$where = [];
|
||||
$where[] = ['del', '=', '0'];
|
||||
//根据客户电话查询
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$phone=Db::name('user_address')->whereLike('phone',$get['phone'])->find();
|
||||
$where[] = ['user_id','=',$phone['user_id']];
|
||||
}
|
||||
//根据客户姓名查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$phone=Db::name('user_address')->whereLike('consignee',$get['name'])->find();
|
||||
$where[] = ['user_id','=',$phone['user_id']];
|
||||
}
|
||||
$goods_count = Db::name('user')
|
||||
->where($where)
|
||||
->count();
|
||||
$goods_list = Db::name('user')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->column('*','id');
|
||||
foreach ($goods_list as &$item) {
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$adder=Db::name('user_address')->where('user_id',$item['user_id'])->find();
|
||||
$item['phone']= $adder['phone'];
|
||||
$item['name']= $adder['consignee'];
|
||||
}
|
||||
return ['count' => $goods_count, 'list' =>array_values($goods_list)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加预排的订单
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function add($post,$admin){
|
||||
$orderinfo=OrderLogic::orderinfo($post['order_sn']);
|
||||
$logdate=[
|
||||
'admin_id'=>$admin,
|
||||
'order_sn'=>$orderinfo['id'],
|
||||
'show'=>'创建预排订单',
|
||||
'cram_time'=>time()
|
||||
];
|
||||
$log=Db::name('log_order')->data($logdate)->insert();
|
||||
$count=count(explode(',',$post['privilege']));
|
||||
$staff=explode(',',$post['privilege']);
|
||||
$post['fworder_sn']=createSn('order_exe', 'fworder_sn', '', 6);
|
||||
//非常固定单执行的代码
|
||||
if($post['type']==3){
|
||||
for($i=0;$i<$post['number'];$i++){
|
||||
$data=[
|
||||
'order_sn'=>$post['order_sn'],
|
||||
'remark'=>$post['remark'],
|
||||
'create_time'=>time(),
|
||||
'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$post['end_time'],
|
||||
'xq'=>UserLogic::Get_Chinese_WeekDay($post['end_time']),
|
||||
'type'=>$post['type'],
|
||||
'status'=>0,
|
||||
'addtime'=>$post['addtim'],
|
||||
'autotime'=>strtotime($post['end_time']),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
}
|
||||
|
||||
if($list){
|
||||
$order=db::name('order')->where('order_sn',$post['order_sn'])->update(['code'=>$orderinfo['code']-$post['number']]);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
//判断日期固定派单
|
||||
else if($post['type']==1){
|
||||
if($post['datas']==''){
|
||||
return $list=3;
|
||||
}
|
||||
//段一个人去执行的炒作
|
||||
for($s=0;$s<$count;$s++){
|
||||
$data=[
|
||||
'order_sn'=>$post['order_sn'],
|
||||
'staff_id'=>$staff[$s++],
|
||||
'remark'=>$post['remark'],
|
||||
'create_time'=>time(),
|
||||
'fworder_sn'=> $post['fworder_sn'],
|
||||
'xq'=>UserLogic::Get_Chinese_WeekDay($post['end_time']),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>$post['addtims'],
|
||||
'autotime'=>strtotime($post['end_time']),
|
||||
];
|
||||
for($i=0;$i<$post['datas'];$i+1){
|
||||
$number=$post['datatime']*$i++;
|
||||
$time=strtotime($post['end_time']);
|
||||
$seconds_to= $number*24*60*60;
|
||||
$data['autotime']=$time+$seconds_to;
|
||||
$data['date']=date("Y-m-d H:i:s", $data['autotime']);;
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
}
|
||||
if($list){
|
||||
$order=db::name('order')->where('order_sn',$post['order_sn'])->update(['code'=>$orderinfo['code']-$post['datas']]);
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
else if($post['type']==2){
|
||||
|
||||
if($count!=(int)$post['number']){
|
||||
return $list=3;
|
||||
}
|
||||
if(isset($post['arr1_data'])) {
|
||||
$data1=$post['arr1_data'];
|
||||
}else{
|
||||
$data1=[];
|
||||
}
|
||||
|
||||
//判断获取数组二为空
|
||||
if(isset($post['arr2_data'])) {
|
||||
$data2=$post['arr2_data'];
|
||||
}else{
|
||||
$data2=[];
|
||||
}
|
||||
foreach($data1 as $v=>$k){
|
||||
foreach($data1[$v] as $item=>$s){
|
||||
$data1[$v][$item]['order_sn']=$post['order_sn'];
|
||||
$data1[$v][$item]['fworder_sn']= $post['fworder_sn'];
|
||||
$data1[$v][$item]['create_time']=time();
|
||||
$data1[$v][$item]['addtime']=1;
|
||||
$data1[$v][$item]['staff_id']=$staff[0];
|
||||
$data1[$v][$item]['remark']=$post['remark'];
|
||||
}
|
||||
}
|
||||
foreach($data2 as $v=>$k){
|
||||
foreach($data2[$v] as $item=>$s){
|
||||
$data2[$v][$item]['order_sn']=$post['order_sn'];
|
||||
$data2[$v][$item]['fworder_sn']= $post['fworder_sn'];
|
||||
$data2[$v][$item]['create_time']=time();
|
||||
$data2[$v][$item]['addtime']=2;
|
||||
$data2[$v][$item]['staff_id']=$staff[0];
|
||||
$data2[$v][$item]['remark']=$post['remark'];
|
||||
}
|
||||
}
|
||||
$data=array_merge($data1,$data2);
|
||||
$one_dimensional_array = call_user_func_array('array_merge', $data);
|
||||
foreach($one_dimensional_array as $v=>$k){
|
||||
$list=Db::name('order_exe')->data($one_dimensional_array[$v])->insert();
|
||||
}
|
||||
//判断是不是俩个人
|
||||
if($count==2){
|
||||
$data1=$post['arr1_data'];
|
||||
//判断获取数组二为空
|
||||
if(isset($post['arr2_data'])) {
|
||||
$data2=$post['arr2_data'];
|
||||
}else{
|
||||
$data2=[];
|
||||
}
|
||||
foreach($data1 as $v=>$k){
|
||||
foreach($data1[$v] as $item=>$s){
|
||||
$data1[$v][$item]['order_sn']=$post['order_sn'];
|
||||
$data1[$v][$item]['fworder_sn']= $post['fworder_sn'];
|
||||
$data1[$v][$item]['create_time']=time();
|
||||
$data1[$v][$item]['addtime']=1;
|
||||
$data1[$v][$item]['staff_id']=$staff[1];
|
||||
$data1[$v][$item]['remark']=$post['remark'];
|
||||
}
|
||||
}
|
||||
foreach($data2 as $v=>$k){
|
||||
foreach($data2[$v] as $item=>$s){
|
||||
$data2[$v][$item]['order_sn']=$post['order_sn'];
|
||||
$data2[$v][$item]['fworder_sn']= $post['fworder_sn'];
|
||||
$data2[$v][$item]['create_time']=time();
|
||||
$data2[$v][$item]['addtime']=2;
|
||||
$data2[$v][$item]['staff_id']=$staff[1];
|
||||
$data2[$v][$item]['remark']=$post['remark'];
|
||||
}
|
||||
}
|
||||
$data=array_merge($data1,$data2);
|
||||
$one_dimensional_array = call_user_func_array('array_merge', $data);
|
||||
foreach($one_dimensional_array as $v=>$k){
|
||||
$list=Db::name('order_exe')->data($one_dimensional_array[$v])->insert();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$order=db::name('order')->where('order_sn',$post['order_sn'])->update(['code'=>0,'type'=>1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取渠道来源
|
||||
* @return array
|
||||
*/
|
||||
public static function infoPosition($pid)
|
||||
{
|
||||
$position_list = Db::name('orderchannel')
|
||||
->where(['id' => $pid])
|
||||
->group('name')
|
||||
->column('id,name', 'id');
|
||||
asort($position_list);
|
||||
return $position_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改员工的基础信息
|
||||
* @param $id 员工的ID
|
||||
* @return array
|
||||
*/
|
||||
public static function edits($post){
|
||||
|
||||
$data = [
|
||||
'updatetime' => time(),
|
||||
'name'=>$post['name'],
|
||||
'mobile'=>$post['mobile'],
|
||||
'sex'=>$post['sex'],
|
||||
'age'=>$post['age'],
|
||||
'group_id'=>$post['brand_id'],
|
||||
'first_order'=>2,
|
||||
'identity'=>$post['identity'],
|
||||
'lng'=>$post['lng'],
|
||||
'addr'=>$post['addr'],
|
||||
'avatar'=>$post['image'],
|
||||
'lat'=>$post['lat'],
|
||||
'province'=>$post['first_category_id'],
|
||||
'city'=>$post['second_category_id'],
|
||||
'area'=>$post['third_category_id'],
|
||||
|
||||
];
|
||||
$list=Db::name('staff')->where('id',$post['id'])->data($data)->update();
|
||||
return $list;
|
||||
}
|
||||
public static function exportFile($get)
|
||||
{
|
||||
$where[] = ['del','=', '0'];
|
||||
|
||||
//查询
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['keyword_type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
//等级查询
|
||||
if(isset($get['level']) && $get['level'] != ''){
|
||||
$where[] = ['level','=',$get['level']];
|
||||
}
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
//消费金额
|
||||
if(isset($get['total_amount_start']) && $get['total_amount_start']){
|
||||
$where[] = ['total_order_amount','>=',$get['total_amount_start']];
|
||||
}
|
||||
if(isset($get['total_amount_end']) && $get['total_amount_end']){
|
||||
$where[] = ['total_order_amount','<=',$get['total_amount_end']];
|
||||
}
|
||||
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['create_time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['create_time','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_list = Db::name('user')->where($where)
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
//会员分组
|
||||
$user_group = Db::name('user_group')->where(['del'=>0])->column('name','id');
|
||||
//会员等级
|
||||
$user_level = Db::name('user_level')->where(['del'=>0])->column('name','id');
|
||||
// 所有会员信息
|
||||
$all_user_list = User::where(['del'=>0])->column('sn,nickname,mobile,level','id');
|
||||
|
||||
$exportData = [];
|
||||
foreach ($user_list as $item){
|
||||
$groupName = '-';
|
||||
$levelName = '无等级';
|
||||
//会员所属分组
|
||||
if(isset($user_group[$item['group_id']])){
|
||||
$groupName = $user_group[$item['group_id']];
|
||||
}
|
||||
|
||||
if(isset($user_level[$item['level']])){
|
||||
$levelName = $user_level[$item['level']];
|
||||
}
|
||||
|
||||
$referrer_user_info = '';
|
||||
$referrer_nickname = '';
|
||||
$referrer_sn = '';
|
||||
$referrer_mobile = '';
|
||||
$referrer_level_name = '-';
|
||||
if(isset($all_user_list[$item['first_leader']])){
|
||||
$referrer_user = $all_user_list[$item['first_leader']];
|
||||
$referrer_nickname = $referrer_user['nickname'];
|
||||
$referrer_sn = $referrer_user['sn'];
|
||||
$referrer_mobile = $referrer_user['mobile'];
|
||||
if(isset($user_level[$referrer_user['level']])){
|
||||
$referrer_level_name =$user_level[$referrer_user['level']];
|
||||
}
|
||||
$referrer_user_info.= '【昵称:'.$referrer_nickname.' 编号:'.$referrer_sn. ' 手机:'. $referrer_mobile . ' 等级:'. $referrer_level_name.'】';
|
||||
}
|
||||
$loginTime = date('Y-m-d H:i:s', $item['login_time']);
|
||||
|
||||
$exportData[] = [$item['sn'], $item['nickname'], $levelName, $groupName, $referrer_user_info, $item['total_order_amount'], $item['user_money'], $item['user_integral'], $loginTime];
|
||||
}
|
||||
|
||||
$exportTitle = ['会员编号', '会员昵称', '会员等级', '会员分组', '推荐人信息', '消费金额', '账户余额', '积分', '最后登录时间'];
|
||||
$exportExt = 'xls';
|
||||
return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'会员列表'.date('Y-m-d H:i:s')];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取会员信息
|
||||
* @param $id
|
||||
* @param bool $getdata 是否获取原始数据
|
||||
* @param bool $expenditure 是否显示会员消费
|
||||
* @return User|mixed
|
||||
*/
|
||||
public static function getUser($id,$getdata = false,$expenditure = false){
|
||||
$user = User::get($id);
|
||||
$user->append(['level_name','group_name']);
|
||||
if($getdata){
|
||||
$user = $user->getData();
|
||||
if($user['birthday']) $user['birthday'] = date('Y-m-d',$user['birthday']);
|
||||
}
|
||||
$user['abs_avatar'] = UrlServer::getFileUrl($user['avatar']);
|
||||
if($expenditure){
|
||||
//本月的消费金额
|
||||
$month_amount = Db::name('order')
|
||||
->where('order_status','not in',[Order::STATUS_CLOSE,Order::STATUS_WAIT_PAY])
|
||||
->where(['user_id'=>$id,'pay_status'=>Pay::ISPAID])
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
//本月的订单笔数
|
||||
$month_num = Db::name('order')
|
||||
->where('order_status','not in',[Order::STATUS_CLOSE,Order::STATUS_WAIT_PAY])
|
||||
->where(['user_id'=>$id,'pay_status'=>Pay::ISPAID])
|
||||
->whereTime('create_time', 'month')
|
||||
->count();
|
||||
//累计消费笔数
|
||||
$total_num =Db::name('order')
|
||||
->where('order_status','not in',[Order::STATUS_CLOSE,Order::STATUS_WAIT_PAY])
|
||||
->where(['user_id'=>$id,'pay_status'=>Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
$avg_amount = Db::name('order')
|
||||
->where('order_status','not in',[Order::STATUS_CLOSE,Order::STATUS_WAIT_PAY])
|
||||
->where(['user_id'=>$id,'pay_status'=>Pay::ISPAID])
|
||||
->avg('order_amount');
|
||||
$user['month_amount'] = '¥'.round($month_amount,2);
|
||||
$user['month_num'] = round($month_num,2);
|
||||
$user['total_num'] = round($total_num,2);
|
||||
$user['avg_amount'] = '¥'.round($avg_amount,2);
|
||||
//分销会员
|
||||
$user['distribution_tips'] = '否';
|
||||
$user['superior_referrer'] = '-';
|
||||
$user['superior_referrer_sn'] = '-';
|
||||
if($user['is_distribution']){
|
||||
$user['distribution_tips'] = '是';
|
||||
$superior_referrer = Db::name('user')->where(['id'=>$user['first_leader']])->field('nickname,sn')->findOrEmpty();
|
||||
$user['superior_referrer'] = '-';
|
||||
$user['superior_referrer_sn'] = '-';
|
||||
if($superior_referrer) {
|
||||
$user['superior_referrer'] = $superior_referrer['nickname'];
|
||||
$user['superior_referrer_sn'] = $superior_referrer['sn'];
|
||||
}
|
||||
}
|
||||
// 头像
|
||||
$user['avatar'] = UrlServer::getFileUrl($user['avatar']);
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
/*
|
||||
* 批量设置会员分组
|
||||
*/
|
||||
public static function setGroup($post){
|
||||
return Db::name('user')->where(['id'=>$post['user_ids']])->update(['group_id'=>$post['group_id']]);
|
||||
}
|
||||
/*
|
||||
* 根据订单编号查询订单编号
|
||||
*/
|
||||
public static function info($id){
|
||||
$list=Db::name('order')->where('order_sn',$id)->find();
|
||||
$ordernumber=Db::name('order_exe')->where('order_sn', $list['order_sn'])->where('status',0)->count();
|
||||
$list['sycs']= $ordernumber;
|
||||
$list['ysycs']= Db::name('order_exe')->where('order_sn', $list['order_sn'])->where('status',1)->count();
|
||||
$list['ztcs']=Db::name('order_exe')->where('order_sn', $list['order_sn'])->where('status',3)->count();
|
||||
return $list;
|
||||
}
|
||||
|
||||
/*
|
||||
* 查看预排的订单的
|
||||
*/
|
||||
|
||||
public static function infolist($get){
|
||||
|
||||
$order=Db::name('order')->where('order_sn',$get['order_sn'])->find(); //获取订单的坐标
|
||||
$orderexe=Db::name('order_exe')->where('order_sn',$get['order_sn'])->count(); //获取订单的总条数
|
||||
$number= $orderexe- $order['number'];
|
||||
if($number>0){
|
||||
$del=Db::name('order_exe')->where('order_sn',$get['order_sn'])->order('autotime desc')->limit($number)->delete();
|
||||
}
|
||||
$list=Db::name('order_exe')->where('order_sn',$get['order_sn'])
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('autotime asc')
|
||||
->select();
|
||||
$count=Db::name('order_exe')->where('order_sn',$get['order_sn'])
|
||||
->order('autotime asc')
|
||||
->count();
|
||||
foreach ($list as &$item){
|
||||
if($item['staff_id']==0){
|
||||
$staff=[];
|
||||
$staff['lat']='26.59064600';
|
||||
$staff['lng']='106.67770700';
|
||||
$item['staff_name']='无保洁';
|
||||
$item['mobile']='无';
|
||||
|
||||
}else{
|
||||
$staff=StaffLogic::infostaff($item['staff_id']); //获取员工定位
|
||||
if($staff){
|
||||
$item['staff_id']=$staff['id'];
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_mobile']=$staff['mobile'];
|
||||
$item['km']=number_format(UserLogic::haversine_distance($order['lat'], $order['lng'],$staff['lat'],$staff['lng'])/ 1000,1);
|
||||
}
|
||||
|
||||
}
|
||||
if(intval(($item['autotime']-time())/86400)>1){
|
||||
$item['jldate']=intval(($item['autotime']-time())/86400);
|
||||
}else{
|
||||
$item['jldate']='-';
|
||||
}
|
||||
|
||||
$item['autotime']=date("Y-m-d",$item['autotime']);
|
||||
|
||||
|
||||
if($item['addtime']==1){
|
||||
$item['addtime']="上午";
|
||||
}else if($item['addtime']==2){
|
||||
$item['addtime']="下午";
|
||||
}
|
||||
|
||||
$item['consignee']=$order['consignee'];
|
||||
$item['mobile']=$order['mobile'];
|
||||
$item['address']=$order['address'];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$count,'list' =>$list];
|
||||
}
|
||||
/*
|
||||
* 修改固定排单的时间
|
||||
*/
|
||||
public static function eittime($id,$post){
|
||||
|
||||
$xq=UserLogic::Get_Chinese_WeekDay($post['end_time']); //获取星期
|
||||
$date=date('Y-m-d',strtotime($post['end_time']));
|
||||
$addtime=intval($post['addtime']);
|
||||
|
||||
|
||||
return Db::name('order_exe')->where('id',$id)->update(['xq'=>$xq,'autotime'=>strtotime($post['end_time']),'addtime'=>$addtime,'staff_id'=>$post['privilege'],'date'=>$date,'staff_status'=>0]);
|
||||
}
|
||||
public static function staff($id,$post){
|
||||
$count=count(explode(',',$post['privilege']));
|
||||
$staff=explode(',',$post['privilege']);
|
||||
if($count>=2){
|
||||
return $list=2;
|
||||
}else{
|
||||
return Db::name('order_exe')->where('id',$id)->update(['staff_id'=>intval($post['privilege'])]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function prent($id){
|
||||
$list=Db::name('order')->where('id',$id)->update(['status'=>1]);
|
||||
$order_id=OrderLogic::orderinfoid($id);
|
||||
$order_exe=Db::name('order_exe')->where('order_sn',$order_id['order_sn'])->where('status',0)->update(['status'=>3]);
|
||||
return $order_exe;
|
||||
}
|
||||
public static function prentsd($id){
|
||||
$list=Db::name('order')->where('id',$id)->update(['status'=>0,'type'=>0]);
|
||||
$order_id=OrderLogic::orderinfoid($id);
|
||||
$order_exe=Db::name('order_exe')->where('order_sn',$order_id['order_sn'])->where('status',3)->update(['status'=>0]);
|
||||
return $order_exe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 订单备注
|
||||
* @param $post
|
||||
* @param string $type
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function remarks($post, $type="get")
|
||||
{
|
||||
if ($type==='get') {
|
||||
|
||||
return Db::name('order_exe')->field('id,remark')
|
||||
->where(['id'=>$post['id']])
|
||||
->findOrEmpty();
|
||||
} else {
|
||||
return Db::name('order_exe')
|
||||
->where(['id'=>$post['id']])
|
||||
->update(['remark'=>$post['order_remarks']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 根据执行ID查询订单的经纬度
|
||||
* @param $post
|
||||
* @param string $type
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function orderexeinfo($id){
|
||||
$list=Db::name('order_exe')->where('id',$id)->find();
|
||||
$order=OrderLogic::orderinfo($list['order_sn']);
|
||||
$list['lng']= $order['lng'];
|
||||
$list['lat']= $order['lat'];
|
||||
$list['date']=date('Y-m-d H:i:s',strtotime($list['date']));
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
public static function log($get){
|
||||
$count=Db::name('log_order')->where('order_sn',$get['order_sn'])->count();
|
||||
$lists=Db::name('log_order')->where('order_sn',$get['order_sn'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item) {
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
$item['admin_name']=$admin['name'];
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['cram_time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function orderlog($get){
|
||||
|
||||
$count=Db::name('log_orders')->where('order_sn',$get['order_sn'])->count();
|
||||
$lists = Db::name('log_orders')
|
||||
//->where('order_sn', 'like', '%' . $get['order_sn'] . '%')
|
||||
->where('order_sn',$get['order_sn'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item) {
|
||||
$admin=Db::name('admin')->where('id',$item['admin_id'])->find();
|
||||
$item['admin_name']=$admin['name'];
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['cram_time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function orderinfo($get){
|
||||
|
||||
$data=Db::name('user_order_imges')->where('order_id',$get['id'])->find();
|
||||
if($data){
|
||||
$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 $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
109
application/admin/logic/OrderchanelLogic.php
Normal file
109
application/admin/logic/OrderchanelLogic.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use think\Db;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class OrderchanelLogic{
|
||||
public static function ordertypelist(){
|
||||
$lists = Db::name('orderchannel')
|
||||
->where('deletetime','NULL')
|
||||
->order('sort','desc')
|
||||
->select();
|
||||
|
||||
$pids = Db::name('orderchannel')
|
||||
->column('pid');
|
||||
foreach ($lists as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
||||
}
|
||||
return linear_to_tree($lists);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* order: 哆啦猫订单渠道
|
||||
* Desc: 显示增加渠道的分类
|
||||
*/
|
||||
public static function Menu($id =1){
|
||||
$lists = Db::name('orderchannel')
|
||||
->where('deletetime','NULL')
|
||||
->select();
|
||||
if ($id) {
|
||||
$remove_ids = self::getChildIds($lists, $id);
|
||||
$remove_ids[] = $id;
|
||||
foreach ($lists as $key => $row) {
|
||||
if (in_array($row['id'], $remove_ids)) {
|
||||
unset($lists[$key]);
|
||||
}
|
||||
}
|
||||
$lists = array_values($lists);
|
||||
}
|
||||
return multilevel_linear_sort($lists, '|-');
|
||||
|
||||
}
|
||||
|
||||
private static function getChildIds($lists, $id)
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($lists as $key => $row) {
|
||||
if ($row['pid'] == $id) {
|
||||
$ids[] = $row['id'];
|
||||
$child_ids = self::getChildIds($lists, $row['id']);
|
||||
foreach ($child_ids as $child_id) {
|
||||
$ids[] = $child_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* order: 哆啦猫订单渠道
|
||||
* Desc: 增加渠道的类别
|
||||
*/
|
||||
public static function ordertypeadd($post){
|
||||
$now = time();
|
||||
$data['createtime'] = $now;
|
||||
$data['updatetime'] = $now;
|
||||
$data['name']=$post['name'];
|
||||
$data['sort']=$post['sort'];
|
||||
$data['pid']=$post['pid'];
|
||||
$datas = Db::name('orderchannel')->insertGetId($data);
|
||||
return $datas;
|
||||
}
|
||||
/**
|
||||
* order: 哆啦猫订单渠道
|
||||
* Desc: 增加渠道的类别
|
||||
*/
|
||||
public static function ordertypeedit($post){
|
||||
$now = time();
|
||||
$data['createtime'] = $now;
|
||||
$data['updatetime'] = $now;
|
||||
$data['name']=$post['name'];
|
||||
$data['sort']=$post['sort'];
|
||||
$data['pid']=$post['pid'];
|
||||
return Db::name('orderchannel')
|
||||
->where('id',$post['id'])
|
||||
->update($data);
|
||||
}
|
||||
/**
|
||||
* order: 哆啦猫订单渠道
|
||||
* Desc: 查询分类列表
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('orderchannel')->where('id',$id)->find();
|
||||
}
|
||||
/**
|
||||
* order: 哆啦猫订单渠道
|
||||
* Desc: 订单的渠道列表查询
|
||||
*/
|
||||
public static function infolist(){
|
||||
return Db::name('orderchannel')->where('deletetime','NULL')
|
||||
->order('sort','desc')
|
||||
->select();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
174
application/admin/logic/OrderserLogic.php
Normal file
174
application/admin/logic/OrderserLogic.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use think\Db;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class OrderserLogic{
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
// //查询
|
||||
if(isset($get['order_sn']) && $get['order_sn']!=''){
|
||||
$where[] = ['order_sn','=',$get['order_sn']];
|
||||
}
|
||||
if(isset($get['order_sn']) && $get['order_sn']!=''){
|
||||
$where[] = ['order_sn','=',$get['order_sn']];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone']!=''){
|
||||
// $where[] = [$get['phone'],'like','%'.$get['phone'].'%'];
|
||||
$where[] = ['phone','=',$get['phone']];
|
||||
}
|
||||
if(isset($get['area_id']) && $get['area_id']!=''){
|
||||
$where[] = ['area_id','=',$get['area_id']];
|
||||
}
|
||||
if(isset($get['channel_id']) && $get['channel_id']!=''){
|
||||
$where[] = ['channel_id','=',$get['channel_id']];
|
||||
}
|
||||
if(isset($get['status']) && $get['status']!=''){
|
||||
$where[] = ['status','=',$get['status']];
|
||||
}
|
||||
//下单时间检索
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
if(isset($get['consignee']) && $get['consignee']!=''){
|
||||
$where[] = ['consignee', 'like', '%' . $get['consignee'] . '%'];
|
||||
}
|
||||
|
||||
$user_count =Db::name('order_service')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_list =Db::name('order_service')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
// //会员分组
|
||||
$user_group = Db::name('orderchannel')->column('name','id');
|
||||
// //会员等级
|
||||
// $user_level = Db::name('user_level')->where(['del'=>0])->column('name','id');
|
||||
|
||||
$all_user_list =Db::name('staff')->column('name,age,addr,mobile','id');
|
||||
|
||||
// $group_list = db::name('user_group')->where(['del'=>0])->column('name','id');
|
||||
|
||||
foreach ($user_list as &$item){
|
||||
$item['createtime'] = date("Y-m-d H:i:s",$item['createtime']);
|
||||
$item['ordertype'] = '次卡订单';
|
||||
|
||||
if(isset($user_group[$item['channel_id']])){
|
||||
$item['orderchannel'] = $user_group[$item['channel_id']];
|
||||
}
|
||||
|
||||
//根据家政订单获取服务人员信息
|
||||
$staff=Db::name('order_cleaner')->where('order_id',$item['id'])->find();
|
||||
$staffinfo=Db::name('staff')->where('id',$staff['cleaner_id'])->find();
|
||||
$item['referrer_nickname'] = $staffinfo['name'];
|
||||
$item['age'] = $staffinfo['age'];
|
||||
$item['referrer_mobile'] = $staffinfo['mobile'];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
//获取员工分组
|
||||
public static function stafftype(){
|
||||
|
||||
return Db::name('orderchannel')->field('id,name')->select();
|
||||
}
|
||||
/*
|
||||
* 获取分组
|
||||
*/
|
||||
public static function getGroupList(){
|
||||
return Db::name('user_group')->where(['del'=>0])->field('id,name')->select();
|
||||
}
|
||||
|
||||
public static function info($get){
|
||||
return Db::name('order_service')->where('id',$get['id'])->find();
|
||||
}
|
||||
|
||||
public static function orderinfo($get){
|
||||
return Db::name('order_service')->where('id',$get)->find();
|
||||
}
|
||||
|
||||
public static function staffdel($post){
|
||||
return Db::name('order_cleaner')->where('id',$post['id'])->where('status',0)->where('cleaner_id',$post['cleaner_id'])->delete();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取员工列表
|
||||
*/
|
||||
public static function stafflist($get){
|
||||
|
||||
$order=Db::name('order_service')->where('id',$get['id'])->find();
|
||||
$user_group = Db::name('staff_group')->column('name','id');
|
||||
$staff=Db::name('staff')->where('onwork',1)->count(); //统计员工列表的条数
|
||||
$list_staff=Db::name('staff')->where('onwork',1)
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ( $list_staff as &$item){
|
||||
$lon1 = $order['lng'];
|
||||
$lat1 = $order['lat'];
|
||||
$lon2 = $item['lng'];
|
||||
$lat2 = $item['lat'];
|
||||
$distanceKm =UserLogic::haversine_distance($lon1, $lat1, $lon2, $lat2, 'km');
|
||||
$item['addersjl'] = (int)$distanceKm;
|
||||
if(isset($user_group[$item['group_id']])){
|
||||
$item['group_name'] = $user_group[$item['group_id']];
|
||||
}
|
||||
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
||||
$item['abs_avatar']=UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count'=>$staff, 'lists'=> $list_staff];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getList($get){
|
||||
switch ($get['type']){
|
||||
case 0://员工服务的订单
|
||||
$list=Db::name('order_cleaner')->where('order_id',$get['user_id'])->select(); //获取保洁师傅列表
|
||||
foreach ($list as &$item) {
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
$staff=Db::name('staff')->where('id',$item['cleaner_id'])->find();
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['mobile']=$staff['mobile'];
|
||||
$item['confirmtime'] = date('Y-m-d H:i:s', $item['confirmtime']);
|
||||
|
||||
}
|
||||
$count =Db::name('order_cleaner')->where('order_id',$get['user_id'])->count();
|
||||
|
||||
|
||||
break;
|
||||
case 1://订单报销列表
|
||||
$count =Db::name('finance')->where('order_id',$get['user_id'])->count();
|
||||
$list=Db::name('finance')->where('order_id',$get['user_id'])->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
$item['staff_name']=$staff['name'];
|
||||
$type=Db::name('finance_type')->where('id',$item['brand_id'])->find();
|
||||
|
||||
$item['type']=$type['name'];
|
||||
// $item['confirmtime'] = date('Y-m-d H:i:s', $item['confirmtime']);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
350
application/admin/logic/OrderstaffLogic.php
Normal file
350
application/admin/logic/OrderstaffLogic.php
Normal file
@@ -0,0 +1,350 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use think\Db;
|
||||
use app\common\server\UrlServer;
|
||||
use think\helper\Time;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
class OrderstaffLogic{
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
|
||||
if(isset($get['type']) && $get['type'] != ''){
|
||||
switch($get['type']) {
|
||||
case '1':
|
||||
|
||||
$where[] = ['staff_status', '=', 3];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$where[] = ['status', '=', $get['type']];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($get['satff']) && $get['satff']!=''){
|
||||
$where[] = ['staff_id','=',$get['satff']];
|
||||
}
|
||||
|
||||
if(isset($get['order_sn']) && $get['order_sn']!=''){
|
||||
$where[] = ['order_sn','=',$get['order_sn']];
|
||||
}
|
||||
if(isset($get['id']) && $get['id']!=''){
|
||||
$where[] = ['id','=',$get['id']];
|
||||
}
|
||||
if(isset($get['staf_stuts']) && $get['staf_stuts']!=''){
|
||||
if($get['staf_stuts']==0){
|
||||
$where[] = ['staff_id','=',0];
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone']!=''){
|
||||
$where[] = ['phone','=',$get['phone']];
|
||||
}
|
||||
if(isset($get['admin']) && $get['admin']!=''){
|
||||
$where[] = ['admin','=',$get['admin']];
|
||||
}
|
||||
if(isset($get['name']) && $get['name']!=''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//下单时间检索
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['autotime','>=',strtotime($get['start_time'])];
|
||||
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['autotime','<=',strtotime($get['end_time'])];
|
||||
|
||||
}
|
||||
if(isset($get['channel']) && $get['channel']!=''){
|
||||
$where[] = ['channel_id','=',$get['channel']];
|
||||
}
|
||||
|
||||
$user_count =Db::name('order_exe')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_list =Db::name('order_exe')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['autotime'] = date("Y-m-d",$item['autotime']);
|
||||
$cumst=Db::name('order')->where('order_sn',$item['order_sn'])->find(); //获取订单的基本信息
|
||||
|
||||
if($cumst){
|
||||
$item['consignee']= $cumst['consignee'];
|
||||
$item['phone']= $cumst['mobile'];
|
||||
$item['address']= $cumst['address'];
|
||||
$item['typeorder']= $cumst['type'];
|
||||
$item['order_remarks']= $cumst['order_remarks'];
|
||||
$cumsts=Db::name('user_address')->where('telephone',$cumst['mobile'])->find(); //获取到客户的基本信息
|
||||
if($cumsts){
|
||||
$item['pet']= $cumsts['pet'];
|
||||
$item['hbl']= $cumsts['hbl'];
|
||||
$item['user_remarks']= $cumsts['user_remarks'];
|
||||
$item['square']= $cumsts['areas'];
|
||||
$item['admin_remarks']= $cumsts['admin_remarks'];
|
||||
$item['staff_remarks']= $cumsts['staff_remarks'];
|
||||
}
|
||||
|
||||
}
|
||||
$admin=Db::name('admin')->where('id',$item['admin'])->find(); //获取管理员信息
|
||||
if($admin){
|
||||
$item['admin']=$admin['name'];
|
||||
}else{
|
||||
$item['admin']='-';
|
||||
}
|
||||
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find(); //获取到订单的保洁师人员
|
||||
if($staff){
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_id']= $staff['id'];
|
||||
$item['staff_mobile']= $staff['mobile'];
|
||||
$item['staff_addr']= $staff['addr'];
|
||||
}
|
||||
|
||||
|
||||
$goods=Db::name('goods')->where('id',$item['goods_id'])->find(); //获取商品到信息
|
||||
|
||||
$channel=Db::name('orderchannel')->where('id',$cumst['channel_id'])->find();
|
||||
if($channel){
|
||||
$item['channel_name']= $channel['name'];
|
||||
}else{
|
||||
$item['channel_name']='客户自助下单';
|
||||
}
|
||||
|
||||
if($goods){
|
||||
$item['goods_name']=$goods['name'];
|
||||
}else{
|
||||
$item['goods_name']='-';
|
||||
}
|
||||
|
||||
//保洁师服务时间
|
||||
if($item['start_time']){
|
||||
$item['start_time']=date("Y-m-d H:i:s",$item['start_time']);
|
||||
}else{
|
||||
$item['start_time']='-';
|
||||
}
|
||||
|
||||
if($item['timeout']){
|
||||
$item['timeout']=date("Y-m-d H:i:s",$item['timeout']);
|
||||
}else{
|
||||
$item['timeout']='-';
|
||||
}
|
||||
|
||||
//售后订单回访控制
|
||||
$track=Db::name('order_trace')->where('order_id',$item['id'])->find();
|
||||
if($track){
|
||||
$item['is_show']=-1;
|
||||
}else{
|
||||
$item['is_show']=1;
|
||||
}
|
||||
|
||||
//控制异常订单显示
|
||||
|
||||
$abnormal=Db::name('order_sale')->where('order_id',$item['id'])->find();
|
||||
if($abnormal){
|
||||
$item['sale_show']=-1;
|
||||
}else{
|
||||
$item['sale_show']=1;
|
||||
}
|
||||
|
||||
if($item['admin']==0){
|
||||
$coustdd=Db::name('user_address')->where('telephone',$cumst['mobile'])->find();
|
||||
if($coustdd){
|
||||
$date=Db::name('order_exe')->where('id',$item['id'])->update(['name'=>$cumst['consignee'],'phone'=>$cumst['mobile'],'admin'=>$coustdd['admin_id']]);
|
||||
}
|
||||
|
||||
}
|
||||
//自动更新套餐
|
||||
if($item['goods_id']==0){
|
||||
$date=Db::name('order_exe')->where('id',$item['id'])->update(['goods_id'=>$cumst['goods_id']]);
|
||||
}
|
||||
if($item['channel_id']==0){
|
||||
$date=Db::name('order_exe')->where('id',$item['id'])->update(['channel_id'=>$cumst['channel_id']]);
|
||||
}
|
||||
|
||||
if(strtotime($item['autotime'])!=strtotime($item['date'])){
|
||||
$date=Db::name('order_exe')->where('id',$item['id'])->update(['date'=>$item['autotime']]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
|
||||
public static function orderlist($get){
|
||||
//今天时间戳
|
||||
$where=[];
|
||||
$where1=[];
|
||||
$where2=[];
|
||||
$where3=[];
|
||||
|
||||
|
||||
$startTimestamp = strtotime(date('Y-m-d 00:00:00'));
|
||||
|
||||
// 获取今天结束时间戳
|
||||
$endTimestamp = strtotime(date('Y-m-d 23:59:59'));
|
||||
|
||||
if(empty($get['start_time'])){
|
||||
$get['start_time'] = date('Y-m-d');
|
||||
}
|
||||
|
||||
if(isset($get['start_time']) && $get['start_time']==''){
|
||||
|
||||
$where[] = ['autotime','>=',$startTimestamp];
|
||||
$where[] = ['autotime','<=',$endTimestamp];
|
||||
$where1[] = ['time','>=', $startTimestamp];
|
||||
$where1[] = ['time','<=', $endTimestamp];
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$edtime=strtotime($get['start_time'])+(24 * 60 * 60) - 1;
|
||||
$where[] = ['autotime','>=',strtotime($get['start_time'])];
|
||||
$where[] = ['autotime','<=', $edtime];
|
||||
$where1[] = ['time','<=',strtotime($get['start_time'])+(24 * 60 * 60) - 1];
|
||||
$where1[] = ['time','>=',strtotime($get['start_time'])];
|
||||
|
||||
$where4[] = ['time','>=',strtotime($get['start_time'])];
|
||||
$where4[] = ['time','<=',strtotime($get['start_time'])+(24 * 60 * 60) - 1];
|
||||
|
||||
}
|
||||
if(isset($get['staff_id']) && $get['staff_id']!=''){
|
||||
$where2[] = ['id','=',$get['staff_id']];
|
||||
}
|
||||
if(isset($get['type']) && $get['type']!=''){
|
||||
$where3[] = ['goods_id','=',$get['type']];
|
||||
}
|
||||
$order_count=Db::name('staff')
|
||||
->where('onwork',1)
|
||||
->where($where2)->where($where3)
|
||||
->count();
|
||||
$order_list =Db::name('staff')
|
||||
->where($where2)
|
||||
->where($where3)
|
||||
->where('onwork',1)
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($order_list as &$item){
|
||||
$addersw=Db::name('order_exe')->where($where)->where('staff_id',$item['id'])->where('addtime',1)->find(); // 上午订单订单
|
||||
if($addersw){
|
||||
$order=Db::name('order')->where('order_sn',$addersw['order_sn'])->find();
|
||||
$item['morning']=$order['address'];
|
||||
$item['ids']='订单ID:'.$addersw['id'];
|
||||
$item['types']=$addersw['type'];
|
||||
}else{
|
||||
|
||||
$leave=Db::name('leave')->where($where1)->where('user_id',$item['id'])->where('addtime',1)->find();
|
||||
if($leave){
|
||||
$item['morning']="占用";
|
||||
$item['ids']="";
|
||||
$item['types']="";
|
||||
}else{
|
||||
$item['morning']="-";
|
||||
$item['ids']="";
|
||||
$item['types']="";
|
||||
}
|
||||
}
|
||||
|
||||
$addersws=Db::name('order_exe')->where($where)->where('staff_id',$item['id'])->where('addtime',2)->find(); // 下午的订单
|
||||
|
||||
if($addersws){
|
||||
$orderss=Db::name('order')->where('order_sn',$addersws['order_sn'])->find();
|
||||
$item['noon']=$orderss['address'];
|
||||
$item['idss']='订单ID:'.$addersws['id'];
|
||||
$item['types']= $addersws['type'];
|
||||
}else{
|
||||
$leave=Db::name('leave')->where('user_id',$item['id'])->where('addtime',2)->where($where1)->find();
|
||||
if($leave){
|
||||
$item['noon']='占用';
|
||||
$item['idss']="";
|
||||
$item['types']="";
|
||||
}else{
|
||||
$item['noon']='-';
|
||||
$item['idss']="";
|
||||
$item['types']="";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$leade=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('status','=',1)
|
||||
->where('time','>=',strtotime($get['start_time']))
|
||||
->where('time','<=',strtotime($get['start_time'])+(24 * 60 * 60) - 1)
|
||||
->select();
|
||||
|
||||
if(!empty($leade)){
|
||||
foreach ($leade as $v){
|
||||
if($v['addtime']==0){
|
||||
$item['order_count']='请假';
|
||||
}else if($v['addtime']==1){
|
||||
$item['order_counts']='请假';
|
||||
}else if($v['addtime']==2){
|
||||
$item['order_count']='请假';
|
||||
$item['order_counts']='请假';
|
||||
}else{
|
||||
$item['order_count']='-';
|
||||
$item['order_counts']='-';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$order_count , 'lists'=>$order_list];
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function stafflist($get){
|
||||
$order_count=1;
|
||||
$where=[];
|
||||
$where12=[];
|
||||
list($start_t, $end_t) = Time::today();
|
||||
|
||||
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$edtime=strtotime($get['start_time'])+(24 * 60 * 60) - 1;
|
||||
$where[] = ['autotime','>=',strtotime($get['start_time'])];
|
||||
$where[] = ['autotime','<=', $edtime];
|
||||
$where12[] = ['time','<=',strtotime($get['start_time'])+(24 * 60 * 60) - 1];
|
||||
$where12[] = ['time','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
|
||||
|
||||
$lists =Db::name('order_exe')
|
||||
->whereTime('autotime', 'today')
|
||||
->limit(1)
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$staff=Db::name('staff')->where('onwork',1)->count(); //保洁是总数
|
||||
$sworder=Db::name('order_exe')->where($where)->where('addtime',1)->group('staff_id')->count(); //上午订单
|
||||
$xworder=Db::name('order_exe')->where($where)->where('addtime',2)->group('staff_id')->count(); //上午订单
|
||||
$qtlent=Db::name('leave')->where($where12)->group('user_id')->count(); //上午请假
|
||||
$swlent=Db::name('leave')->where($where12)->where('addtime',1)->group('user_id')->count(); //上午请假
|
||||
$xwlent=Db::name('leave')->where($where12)->where('addtime',2)->group('user_id')->count(); //下午请假
|
||||
$item['zsnumber']=$sworder+$xworder;
|
||||
$item['swnumber']=$staff- $sworder- $swlent;
|
||||
$item['xwnumber']=$staff- $xworder-$xwlent;
|
||||
$item['cdsnumber']= $item['swnumber']+ $item['xwnumber'];
|
||||
$item['wpd']=Db::name('order_exe')->where($where)->where('staff_id',null)->group('staff_id')->count();
|
||||
|
||||
}
|
||||
return ['count'=>$order_count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
100
application/admin/logic/PayConfigLogic.php
Normal file
100
application/admin/logic/PayConfigLogic.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\common\model\Pay;
|
||||
use think\Db;
|
||||
|
||||
class PayConfigLogic
|
||||
{
|
||||
|
||||
public static function lists()
|
||||
{
|
||||
$payModel = new Pay();
|
||||
$count = $payModel->count();
|
||||
$lists = $payModel->order('sort')->select();
|
||||
$lists->append(['status_text']);
|
||||
return ['list' => $lists, 'count' => $count];
|
||||
}
|
||||
|
||||
|
||||
public static function info($pay_code)
|
||||
{
|
||||
$payModel = new Pay();
|
||||
$result = $payModel->where(['code' => $pay_code])->append(['status_text'])->find();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 余额支付
|
||||
* @param $post
|
||||
* @author 段誉(2021/3/10 11:42)
|
||||
* @return bool
|
||||
*/
|
||||
public static function editBalance($post)
|
||||
{
|
||||
$payModel = new Pay();
|
||||
return $payModel->allowField(true)->save($post, ['code' => 'balance']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 微信支付
|
||||
* @param $post
|
||||
* @author 段誉(2021/3/10 10:30)
|
||||
* @return bool
|
||||
*/
|
||||
public static function editWechat($post)
|
||||
{
|
||||
$config = [
|
||||
'pay_sign_key' => $post['pay_sign_key'],
|
||||
'mch_id' => $post['mch_id'],
|
||||
'apiclient_cert' => $post['apiclient_cert'],
|
||||
'apiclient_key' => $post['apiclient_key']
|
||||
];
|
||||
$post['config'] = json_encode($config, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$payModel = new Pay();
|
||||
return $payModel->allowField(true)->save($post, ['code' => 'wechat']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 支付宝
|
||||
* @param $post
|
||||
* @author 段誉(2021/3/10 11:43)
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function editAlipay($post)
|
||||
{
|
||||
$config = [
|
||||
'app_id' => $post['app_id'],
|
||||
'private_key' => $post['private_key'],//应用私钥
|
||||
'ali_public_key' => $post['ali_public_key']//支付宝公钥
|
||||
];
|
||||
$post['config'] = json_encode($config, JSON_UNESCAPED_UNICODE);
|
||||
$payModel = new Pay();
|
||||
return $payModel->allowField(true)->save($post, ['code' => 'alipay']);
|
||||
}
|
||||
|
||||
}
|
||||
161
application/admin/logic/PointsLogic.php
Normal file
161
application/admin/logic/PointsLogic.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\logic;
|
||||
use think\Db;
|
||||
use app\common\server\UrlServer;
|
||||
class PointsLogic{
|
||||
|
||||
|
||||
/**
|
||||
* 积分商品列表内容
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public static function lists($get){
|
||||
$where=[];
|
||||
$where[] = ['del', '=', 0];
|
||||
$count =Db::name('printer_goods')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists =Db::name('printer_goods')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date('Y-m-d H:i:s');
|
||||
$type_name=self::typeinfo($item['brand_id']);
|
||||
if($type_name){
|
||||
$item['tpye_name']=$type_name['name'];
|
||||
}else{
|
||||
$item['tpye_name']='-';
|
||||
}
|
||||
|
||||
$item['images'] = UrlServer::getFileUrl($item['images']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
/**
|
||||
* 根据ID查询积分商品内容
|
||||
* @return mixed
|
||||
*/
|
||||
public static function info($id){
|
||||
$data=Db::name('printer_goods')->where('id',$id)->find();
|
||||
$data['images']= UrlServer::getFileUrl($data['images']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改积分套餐的内容
|
||||
* @return mixed
|
||||
*/
|
||||
public static function edit($post){
|
||||
|
||||
$data=[
|
||||
'name' => $post['name'],
|
||||
'price' => $post['price'],
|
||||
'unit' => $post['unit'],
|
||||
'images' => $post['image'],
|
||||
'inventory' => $post['inventory'],
|
||||
'warn' => $post['warn'],
|
||||
'content' => $post['content'],
|
||||
'brand_id' => $post['brand_id'],
|
||||
];
|
||||
|
||||
return Db::name('printer_goods')->where('id',$post['id'])->update($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建积分商品
|
||||
* @return mixed
|
||||
*/
|
||||
public static function add($post){
|
||||
$data=[
|
||||
'name' => $post['name'],
|
||||
'price' => $post['price'],
|
||||
'unit' => $post['unit'],
|
||||
'images' => $post['image'],
|
||||
'inventory' => $post['inventory'],
|
||||
'warn' => $post['warn'],
|
||||
'content' => $post['content'],
|
||||
'brand_id' => $post['brand_id'],
|
||||
'create_time'=> time()
|
||||
];
|
||||
return Db::name('printer_goods')->data($data)->insert();
|
||||
}
|
||||
/**
|
||||
* 删除积分商品
|
||||
* @return mixed
|
||||
*/
|
||||
public static function del($id){
|
||||
|
||||
return Db::name('printer_goods')->where('id',$id)->update(['del'=>1]);
|
||||
}
|
||||
/**
|
||||
* 积分分类列表
|
||||
* @return mixed
|
||||
*/
|
||||
public static function type($get){
|
||||
$where=[];
|
||||
$where[] = ['del', '=', 0];
|
||||
$count =Db::name('printer_type')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists =Db::name('printer_type')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date('Y-m-d H:i:s');
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分商品分类
|
||||
* @return mixed
|
||||
*/
|
||||
public static function typeadd($post){
|
||||
return Db::name('printer_type')->data($post)->insert();
|
||||
}
|
||||
/**
|
||||
* 根据ID查询分类的
|
||||
* @return mixed
|
||||
*/
|
||||
public static function typeinfo($id){
|
||||
return Db::name('printer_type')->where(['del'=>0,'id'=>$id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类的名称
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public static function typeedit($post){
|
||||
return Db::name('printer_type')->where('id',$post['id'])->update(['name'=>$post['name']]);
|
||||
}
|
||||
/**
|
||||
* 修改分类的名称
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public static function typedel($id){
|
||||
|
||||
return Db::name('printer_type')->where('id',$id)->update(['del'=>1]);
|
||||
}
|
||||
/**
|
||||
* 获取积分商城的全部分类
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public static function typelist(){
|
||||
return Db::name('printer_type')->where('del',0)->select();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
414
application/admin/logic/PrinterLogic.php
Normal file
414
application/admin/logic/PrinterLogic.php
Normal file
@@ -0,0 +1,414 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\YlyPrinter;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Hook;
|
||||
|
||||
class PrinterLogic{
|
||||
|
||||
/**
|
||||
* Notes:打印机列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @author: cjhao 2021/4/24 14:45
|
||||
*/
|
||||
public static function lists($get){
|
||||
|
||||
switch ($get['type']){
|
||||
case 1:
|
||||
$list = Db::name('printer')
|
||||
->where(['del'=>0])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($list as $key => $value){
|
||||
$list[$key]['type_name'] = Db::name('printer_config')->where(['id'=>$value['type']])->value('name');
|
||||
$list[$key]['status'] = $value['status'] ? '开启' : '关闭';
|
||||
$list[$key]['auto_print'] = $value['auto_print'] ? '开启' : '关闭';
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$list = Db::name('printer_config')
|
||||
->where(['del'=>0])
|
||||
->select();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$list = ConfigServer::get('printer', 'yly_template', []);
|
||||
$list['file_url'] = UrlServer::getFileUrl('');
|
||||
break;
|
||||
}
|
||||
|
||||
return['lists' => $list];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes:设置添加打印机
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
* @author: cjhao 2021/4/24 14:45
|
||||
*/
|
||||
public static function add($post){
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$now = time();
|
||||
$data = [
|
||||
'type' => $post['type'],
|
||||
'name' => $post['name'],
|
||||
'machine_code' => $post['machine_code'],
|
||||
'private_key' => $post['private_key'],
|
||||
'print_number' => $post['print_number'],
|
||||
'auto_print' => $post['auto_print'],
|
||||
'status' => $post['status'],
|
||||
'create_time' => $now,
|
||||
'update_time' => $now,
|
||||
'del' => 0,
|
||||
];
|
||||
Db::name('printer')->insert($data);
|
||||
|
||||
$printer_config = Db::name('printer_config')->where(['id'=>$post['type']])->field('client_id,client_secret')->find();
|
||||
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
|
||||
|
||||
//调用易联云添加打印机
|
||||
$yly_print->addPrinter($post['machine_code'],$post['private_key'],$post['name']);
|
||||
|
||||
//获取打印机状态,设置logo
|
||||
$response = $yly_print->getPrintStatus($post['machine_code']);
|
||||
//打印机在线时,设置logo
|
||||
$yly_template = ConfigServer::get('printer', 'yly_template', []);
|
||||
if(1 == $response->body->state && isset($yly_template['logo'])){
|
||||
|
||||
$yly_print->setIcon($post['machine_code'],UrlServer::getFileUrl($yly_template['logo']));
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
|
||||
}catch (\Exception $e){
|
||||
|
||||
|
||||
$msg = json_decode($e->getMessage(),true);
|
||||
if($msg && isset($msg['error'])){
|
||||
return '易联云:'.$msg['error_description'];
|
||||
}
|
||||
if(18 === $e->getCode()){
|
||||
//todo token过期重新拿
|
||||
Cache::rm('yly_access_token');
|
||||
Cache::rm('yly_refresh_token');
|
||||
};
|
||||
Db::rollback();
|
||||
return '易联云:'.$e->getMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Notes:编辑打印机
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
* @author: cjhao 2021/4/24 14:44
|
||||
*/
|
||||
public static function edit($post){
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$now = time();
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'print_number' => $post['print_number'],
|
||||
'status' => $post['status'],
|
||||
'auto_print' => $post['auto_print'],
|
||||
'update_time' => $now,
|
||||
];
|
||||
Db::name('printer')->where(['id'=>$post['id']])->update($data);
|
||||
|
||||
//调用易联云,更新打印机
|
||||
$printer_config = Db::name('printer_config')->where(['id'=>$post['type']])->field('client_id,client_secret')->find();
|
||||
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
|
||||
|
||||
$yly_print->addPrinter($post['machine_code'],$post['private_key'],$post['name']);
|
||||
|
||||
//获取打印机状态,设置logo
|
||||
$response = $yly_print->getPrintStatus($post['machine_code']);
|
||||
//打印机在线时,设置logo
|
||||
$yly_template = ConfigServer::get('printer', 'yly_template', []);
|
||||
|
||||
if(1 == $response->body->state && isset($yly_template['logo'])){
|
||||
$yly_print->setIcon($post['machine_code'],UrlServer::getFileUrl($yly_template['logo']));
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
}catch (\Exception $e){
|
||||
|
||||
|
||||
$msg = json_decode($e->getMessage(),true);
|
||||
|
||||
if($msg && isset($msg['error'])){
|
||||
return '易联云:'.$msg['error_description'];
|
||||
}
|
||||
if(18 === $e->getCode()){
|
||||
//todo token过期重新拿
|
||||
Cache::rm('yly_access_token');
|
||||
Cache::rm('yly_refresh_token');
|
||||
};
|
||||
Db::rollback();
|
||||
return '易联云:'.$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:获取打印机配置
|
||||
* @param $id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @author: cjhao 2021/4/24 14:44
|
||||
*/
|
||||
public static function getPrinter($id){
|
||||
return Db::name('printer')->where(['del'=>0,'id'=>$id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:设置配置
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @author: cjhao 2021/4/24 14:44
|
||||
*/
|
||||
public static function setConfig($post){
|
||||
$post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 0;
|
||||
if($post['status']){
|
||||
Db::name('printer_config')->where(['status'=>1])->update(['status'=>0]);
|
||||
}
|
||||
$update_data = [
|
||||
'client_id' => $post['client_id'],
|
||||
'client_secret' => $post['client_secret'],
|
||||
'update_time' => time(),
|
||||
'status' => $post['status'],
|
||||
];
|
||||
return Db::name('printer_config')->where(['id'=>$post['id']])->update($update_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取配置
|
||||
* @param $id
|
||||
* @return array|\PDOStatement|string|\think\Model|null
|
||||
* @author: cjhao 2021/4/24 14:45
|
||||
*/
|
||||
public static function getConfig($id){
|
||||
return Db::name('printer_config')->where(['id'=>$id])->find();
|
||||
}
|
||||
|
||||
/***
|
||||
* Notes:获取打印配置类型
|
||||
* @return array|\PDOStatement|string|\think\Collection
|
||||
* @author: cjhao 2021/4/24 14:44
|
||||
*/
|
||||
public static function getTypeList(){
|
||||
return Db::name('printer_config')->where(['del'=>0])->field('id,name')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:设置打印模板
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
* @author: cjhao 2021/4/24 14:44
|
||||
*/
|
||||
public static function setTemplate($post){
|
||||
try{
|
||||
|
||||
$printer_config = Db::name('printer_config')->where(['id'=>$post['type']])->field('client_id,client_secret')->find();
|
||||
|
||||
if($post['logo'] && $printer_config){
|
||||
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
|
||||
$printer_list = self::getPrinterList(0);
|
||||
//调用易联云,更新打印机
|
||||
$logo = UrlServer::getFileUrl($post['logo']);
|
||||
|
||||
foreach ($printer_list as $printer){
|
||||
|
||||
//获取打印机状态,设置logo
|
||||
$response = $yly_print->getPrintStatus($printer['machine_code']);
|
||||
|
||||
if(1 == $response->body->state){
|
||||
$yly_print->setIcon($printer['machine_code'],$logo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ConfigServer::set('printer', 'yly_template', $post);
|
||||
return true;
|
||||
}catch (\Exception $e){
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取打印机列表
|
||||
* @param bool $status
|
||||
* @return array
|
||||
* @author: cjhao 2021/4/24 14:43
|
||||
*/
|
||||
public static function getPrinterList($status = false){
|
||||
$where[] = ['del','=',0];
|
||||
$where[] = ['type','=',1];
|
||||
$status && $where[] = ['status','=',1];
|
||||
return Db::name('printer')
|
||||
->where($where)
|
||||
->column('machine_code,private_key,print_number','machine_code');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:测试打印
|
||||
* @param $post
|
||||
* @return bool|string
|
||||
* @author: cjhao 2021/4/24 14:43
|
||||
*/
|
||||
public static function testPrint($post){
|
||||
try {
|
||||
|
||||
$printer = Db::name('printer')->where(['id'=>$post['id'],'del'=>0])->find();
|
||||
|
||||
$printer_config = Db::name('printer_config')->where(['id'=>$post['type']])->field('client_id,client_secret')->find();
|
||||
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
|
||||
|
||||
//获取打印机状态
|
||||
$response = $yly_print->getPrintStatus($printer['machine_code']);
|
||||
|
||||
if(1 == $response->body->state){
|
||||
$data = static::testData();
|
||||
$template_config = ConfigServer::get('printer', 'yly_template', []);
|
||||
$yly_print->ylyPrint([['machine_code'=>$printer['machine_code'],'print_number'=>$printer['print_number']]],$data,$template_config);
|
||||
return true;
|
||||
}
|
||||
$msg = '打印机离线';
|
||||
|
||||
if(2 == $response->body->state){
|
||||
$msg = '打印机缺纸';
|
||||
}
|
||||
throw new Exception($msg);
|
||||
}catch (\Exception $e){
|
||||
|
||||
|
||||
$msg = json_decode($e->getMessage(),true);
|
||||
if($msg && isset($msg['error'])){
|
||||
return '易联云:'.$msg['error_description'];
|
||||
}
|
||||
if(18 === $e->getCode()){
|
||||
//todo token过期重新拿
|
||||
Cache::rm('yly_access_token');
|
||||
Cache::rm('yly_refresh_token');
|
||||
};
|
||||
return '易联云:'.$e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:测试打印数据
|
||||
* @return array
|
||||
* @author: cjhao 2021/4/24 14:45
|
||||
*/
|
||||
public static function testData(){
|
||||
$order = [
|
||||
'order_sn' => date("Ymd").'88888888888',
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'consignee' => '张先生',
|
||||
'mobile' => '138888888888',
|
||||
'delivery_address' => '广东省广州市天河区XXXX科技园',
|
||||
'user_remark' => '这是用户备注',
|
||||
'order_goods' => [
|
||||
[
|
||||
'name' => 'iPhone 11',
|
||||
'spec_value_str'=> '全网通256G,银色',
|
||||
'goods_num' => '88',
|
||||
'goods_price' => '3689',
|
||||
'total_price' => '88888',
|
||||
],
|
||||
[
|
||||
'name' => '小米手机Plus',
|
||||
'spec_value_str'=> '全网通256G,黑色',
|
||||
'goods_num' => '88',
|
||||
'goods_price' => '3689',
|
||||
'total_price' => '88888',
|
||||
],
|
||||
[
|
||||
'name' => '华为 P40',
|
||||
'spec_value_str'=> '全网通256G,黑色',
|
||||
'goods_num' => '88',
|
||||
'goods_price' => '3689',
|
||||
'total_price' => '88888',
|
||||
],
|
||||
],
|
||||
'total_amount' => '888888', //商品总价
|
||||
'discount_amount' => '80', //优惠金额
|
||||
'shipping_price' => '12', //应付
|
||||
'order_amount' => '222' //应付金额
|
||||
];
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:删除打印机
|
||||
* @param $id
|
||||
* @return bool|string
|
||||
* @author: cjhao 2021/4/24 14:45
|
||||
*/
|
||||
public static function del($id){
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
Db::name('printer')->where(['id'=>$id])->update(['del'=>1,'update_time'=>time()]);
|
||||
$printer = Db::name('printer')->where(['id'=>$id])->find();
|
||||
$printer_config = Db::name('printer_config')->where(['id'=>$printer['type']])->field('client_id,client_secret')->find();
|
||||
//调用易联云接口,删除打印机
|
||||
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
|
||||
$yly_print->deletePrinter($printer['machine_code']);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
}catch (\Exception $e){
|
||||
|
||||
$msg = json_decode($e->getMessage(),true);
|
||||
if($msg && isset($msg['error'])){
|
||||
return '易联云:'.$msg['error_description'];
|
||||
}
|
||||
if(18 === $e->getCode()){
|
||||
//todo token过期重新拿
|
||||
Cache::rm('yly_access_token');
|
||||
Cache::rm('yly_refresh_token');
|
||||
};
|
||||
Db::rollback();
|
||||
return '易联云:'.$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
68
application/admin/logic/RechargeLogLogic.php
Normal file
68
application/admin/logic/RechargeLogLogic.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\admin\logic;
|
||||
use app\common\model\Pay;
|
||||
use think\Db;
|
||||
use think\helper\Time;
|
||||
|
||||
class RechargeLogLogic{
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
if(isset($get['order_source']) && $get['order_source']){
|
||||
$where[] = ['order_source','=',$get['order_source']];
|
||||
}
|
||||
if(isset($get['pay_status']) && $get['pay_status']){
|
||||
$where[] = ['pay_status','=',$get['pay_status']];
|
||||
}
|
||||
if(isset($get['pay_way']) && $get['pay_way']){
|
||||
$where[] = ['pay_way','=',$get['pay_way']];
|
||||
}
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where[] = ['ro.create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
}
|
||||
if(isset($get['create_end']) && $get['create_end']!=''){
|
||||
$where[] = ['ro.create_time','<=',strtotime($get['create_end'])];
|
||||
}
|
||||
|
||||
$count = Db::name('recharge_order')->alias('ro')
|
||||
->join('user u','ro.user_id = u.id')
|
||||
->where($where)
|
||||
->count();
|
||||
$list = Db::name('recharge_order')->alias('ro')
|
||||
->join('user u','ro.user_id = u.id')
|
||||
->where($where)
|
||||
->field('ro.id,order_sn,order_amount,give_money,give_integral,give_growth,pay_time,pay_way,pay_status,ro.create_time')
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('ro.id desc')
|
||||
->select();
|
||||
foreach ($list as &$order){
|
||||
$order['order_amount'] = '¥'.$order['order_amount'];
|
||||
$order['pay_way'] = Pay::getPayWay($order['pay_way']);
|
||||
$order['pay_status'] = Pay::getPayStatus($order['pay_status']);
|
||||
if($order['pay_time']){
|
||||
$order['pay_time'] = date('Y-m-d H:i:s',$order['pay_time']);
|
||||
}
|
||||
$order['create_time'] = date('Y-m-d H:i:s',$order['create_time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$list];
|
||||
}
|
||||
}
|
||||
82
application/admin/logic/RechargeLogic.php
Normal file
82
application/admin/logic/RechargeLogic.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
|
||||
class RechargeLogic{
|
||||
public static function templatelists(){
|
||||
$list = Db::name('recharge_template')->where(['del'=>0])->select();
|
||||
foreach ($list as &$item){
|
||||
$item['money'] && $item['money'] = '¥'.$item['money'];
|
||||
$item['give_money'] && $item['give_money'] = '¥'.$item['give_money'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function getRechargeConfig(){
|
||||
$config = [
|
||||
'open_racharge' => ConfigServer::get('recharge','open_racharge',0),
|
||||
'give_integral' => ConfigServer::get('recharge', 'give_integral', ''),
|
||||
'give_growth' => ConfigServer::get('recharge', 'give_growth', ''),
|
||||
'min_money' => ConfigServer::get('recharge', 'min_money', ''),
|
||||
];
|
||||
return [$config];
|
||||
}
|
||||
public static function setRecharge($post){
|
||||
ConfigServer::set('recharge','open_racharge',$post['open_racharge']);
|
||||
ConfigServer::set('recharge','give_integral',$post['give_integral']);
|
||||
ConfigServer::set('recharge','give_growth',$post['give_growth']);
|
||||
ConfigServer::set('recharge','min_money',$post['min_money']);
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$new = time();
|
||||
$add_data = [
|
||||
'money' => $post['money'],
|
||||
'give_money' => $post['give_money'],
|
||||
'sort' => $post['sort'],
|
||||
'is_recommend' => $post['is_recommend'],
|
||||
'create_time' => $new,
|
||||
'update_time' => $new,
|
||||
];
|
||||
return Db::name('recharge_template')->insert($add_data);
|
||||
}
|
||||
|
||||
public static function edit($post){
|
||||
$new = time();
|
||||
$update_data = [
|
||||
'money' => $post['money'],
|
||||
'give_money' => $post['give_money'],
|
||||
'sort' => $post['sort'],
|
||||
'is_recommend' => $post['is_recommend'],
|
||||
'update_time' => $new,
|
||||
];
|
||||
return Db::name('recharge_template')->where(['id'=>$post['id']])->update($update_data);
|
||||
}
|
||||
|
||||
public static function getRechargeTemplate($id){
|
||||
return Db::name('recharge_template')->where(['id'=>$id])->find();
|
||||
}
|
||||
|
||||
|
||||
public static function del($id){
|
||||
return Db::name('recharge_template')->where(['id'=>$id])->update(['update_time'=>time(),'del'=>1]);
|
||||
}
|
||||
}
|
||||
155
application/admin/logic/RecruitLogic.php
Normal file
155
application/admin/logic/RecruitLogic.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class RecruitLogic
|
||||
{
|
||||
|
||||
//招聘的岗位
|
||||
public static function type($get){
|
||||
$user_count = Db::name('recruitype')
|
||||
->count();
|
||||
$user_list = Db::name('recruitype')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
|
||||
}
|
||||
|
||||
public static function type_list(){
|
||||
return Db::name('recruitype')->select();
|
||||
}
|
||||
|
||||
public static function typeadd($get){
|
||||
$now = time();
|
||||
$get['createtime'] = $now;
|
||||
return Db::name('recruitype')->insertGetId($get);
|
||||
}
|
||||
public static function typeedit($post){
|
||||
return Db::name('recruitype')->where('id',$post['id'])->update(['zpname'=>$post['zpname'],'number'=>$post['number']]);
|
||||
}
|
||||
public static function typedel($id){
|
||||
return Db::name('recruitype')->where('id',$id)->delete();
|
||||
|
||||
}
|
||||
|
||||
//员工薪资显示列表
|
||||
public static function salary($get){
|
||||
$count=Db::name('recrui_salary')->count();
|
||||
$lists=Db::name('recrui_salary')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function salary_list(){
|
||||
return Db::name('recrui_salary')->select();
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$post['createtime']=time();
|
||||
return Db::name('recrui')->data($post)->insert();
|
||||
}
|
||||
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
if(isset($get['sex']) && $get['sex'] != ''){
|
||||
$where[] = ['sex','=',$get['sex']];
|
||||
}
|
||||
if(isset($get['onwork']) && $get['onwork'] != ''){
|
||||
$where[] = ['onwork','=',$get['onwork']];
|
||||
}
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
|
||||
//创建时间查询
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$count = Db::name('recrui')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('recrui')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$branch=Db::name('staff_group')->where('id',$item['branch_id'])->find();
|
||||
if($branch){
|
||||
$item['branch_name']=$branch['name'];
|
||||
}else{
|
||||
$item['branch_name']='-';
|
||||
}
|
||||
|
||||
$type=Db::name('recruitype')->where('id',$item['type_id'])->find();
|
||||
$item['type_name']=$type['zpname'];
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function recruiinfo($id){
|
||||
|
||||
return Db::name('recrui')->where('id',$id)->find();
|
||||
|
||||
}
|
||||
|
||||
public static function edits($post){
|
||||
$post['createtime']=time();
|
||||
return Db::name('recrui')->where('id',$post['id'])->data($post)->update();
|
||||
}
|
||||
|
||||
public static function filed_lists($get){
|
||||
$where = [];
|
||||
if(isset($get['sex']) && $get['sex'] != ''){
|
||||
$where[] = ['sex','=',$get['sex']];
|
||||
}
|
||||
if(isset($get['onwork']) && $get['onwork'] != ''){
|
||||
$where[] = ['onwork','=',$get['onwork']];
|
||||
}
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
|
||||
//创建时间查询
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
$count = Db::name('user_recruit')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('user_recruit')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$branch=Db::name('recrui')->where('id',$item['position'])->find();
|
||||
$item['branch_name']=$branch['name'];
|
||||
//$type=Db::name('recruitype')->where('id',$item['type_id'])->find();
|
||||
///$item['type_name']=$type['zpname'];
|
||||
$item['crem_time']=date("Y-m-d H:i:s",$item['crem_time']);
|
||||
}
|
||||
|
||||
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
}
|
||||
265
application/admin/logic/RoleLogic.php
Normal file
265
application/admin/logic/RoleLogic.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class RoleLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
* @return array|\PDOStatement|string|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
$result = Db::name('role_dev_auth_index r')
|
||||
->join('dev_auth m', 'r.menu_auth_id=m.id')
|
||||
->where(['m.del' => 0])
|
||||
->order(['sort' => 'desc'])
|
||||
->field(['m.name' => 'name', 'r.role_id' => 'role_id'])
|
||||
->select();
|
||||
$role_id_menu_auth_names = [];
|
||||
|
||||
foreach ($result as $k => $v) {
|
||||
if (isset($role_id_menu_auth_names[$v['role_id']])) {
|
||||
$role_id_menu_auth_names[$v['role_id']] .= $v['name'] . ',';
|
||||
} else {
|
||||
$role_id_menu_auth_names[$v['role_id']] = $v['name'] . ',';
|
||||
}
|
||||
}
|
||||
|
||||
$lists = Db::name('role')
|
||||
->where(['del' => 0])
|
||||
->select();
|
||||
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['auth_str'] = isset($role_id_menu_auth_names[$v['id']]) ? $role_id_menu_auth_names[$v['id']] : '';
|
||||
$lists[$k]['auth_str'] = rtrim($lists[$k]['auth_str'], ',');
|
||||
$lists[$k]['create_time_str'] = date('Y-m-d H:i:s', $v['create_time']);
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public static function roleInfo($role_id)
|
||||
{
|
||||
return Db::name('role')->where(['id' => $role_id])->field(['id', 'name', 'desc'])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
* @param $post
|
||||
* @return int|string
|
||||
*/
|
||||
public static function addRole($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'desc' => $post['desc'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
|
||||
try {
|
||||
Db::startTrans();
|
||||
$role_id = Db::name('role')->insertGetId($data);
|
||||
$data = [];
|
||||
$post['auth_ids'] = empty($post['auth_ids'])?[]:$post['auth_ids'];
|
||||
foreach ($post['auth_ids'] as $k => $v) {
|
||||
$data[] = [
|
||||
'role_id' => $role_id,
|
||||
'menu_auth_id' => $v,
|
||||
];
|
||||
}
|
||||
Db::name('role_dev_auth_index')
|
||||
->insertAll($data);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
* @param $post
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function editRole($post)
|
||||
{
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'desc' => $post['desc'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
try {
|
||||
Db::startTrans();
|
||||
Db::name('role')
|
||||
->where(['del' => 0, 'id' => $post['id']])
|
||||
->update($data);
|
||||
$data = [];
|
||||
Db::name('role_dev_auth_index')
|
||||
->where(['role_id' => $post['id']])
|
||||
->delete();
|
||||
$post['auth_ids'] = empty($post['auth_ids'])?[]:$post['auth_ids'];
|
||||
foreach ($post['auth_ids'] as $k => $v) {
|
||||
$data[] = [
|
||||
'role_id' => $post['id'],
|
||||
'menu_auth_id' => $v,
|
||||
];
|
||||
}
|
||||
Db::name('role_dev_auth_index')
|
||||
->insertAll($data);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除成功
|
||||
* @param $role_id
|
||||
* @return int|string
|
||||
* @throws \think\Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function delRole($role_id)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('role')->where(['del' => 0, 'id' => $role_id])->update($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取菜单权限树
|
||||
* @param string $role_id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function authTree($role_id = '')
|
||||
{
|
||||
|
||||
$lists = Db::name('dev_auth')
|
||||
->where(['disable' => 0, 'del' => 0])
|
||||
->select();
|
||||
$pids = Db::name('dev_auth')
|
||||
->where(['disable' => 0, 'type' => 1, 'del' => 0])
|
||||
->column('pid');
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['spread'] = in_array($v['id'], $pids) ? true : false;
|
||||
}
|
||||
$menu_auth_ids = [];
|
||||
if ($role_id) {
|
||||
$menu_auth_ids = Db::name('role_dev_auth_index')
|
||||
->where(['role_id' => $role_id])
|
||||
->column('menu_auth_id');
|
||||
}
|
||||
return self::authListToTree($lists, 0, $menu_auth_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表结构转换成树形结构
|
||||
* @param $lists
|
||||
* @param int $pid
|
||||
* @param array $menu_auth_ids
|
||||
* @return array
|
||||
*/
|
||||
public static function authListToTree($lists, $pid = 0, $menu_auth_ids = [])
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($lists as $k => $v) {
|
||||
if ($v['pid'] == $pid) {
|
||||
$temp['id'] = $v['id'];
|
||||
$temp['field'] = 'auth_ids[' . $v['id'] . ']';
|
||||
$temp['title'] = $v['name'];
|
||||
$temp['children'] = self::authListToTree($lists, $v['id'], $menu_auth_ids);
|
||||
$temp['checked'] = in_array($v['id'], $menu_auth_ids) && empty($temp['children']) ? true : false;
|
||||
$temp['spread'] = $v['spread'];
|
||||
$tree[] = $temp;
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门权限
|
||||
* @param $lists
|
||||
* @param int $pid
|
||||
* @param array $menu_auth_ids
|
||||
* @return array
|
||||
*/
|
||||
public static function staffauthTree($role_id = '')
|
||||
{
|
||||
|
||||
$lists = Db::name('dev_staffauth')
|
||||
->where(['disable' => 0, 'del' => 0])
|
||||
->select();
|
||||
$pids = Db::name('dev_staffauth')
|
||||
->where(['disable' => 0, 'type' => 1, 'del' => 0])
|
||||
->column('pid');
|
||||
foreach ($lists as $k => $v) {
|
||||
$lists[$k]['spread'] = in_array($v['id'], $pids) ? true : false;
|
||||
}
|
||||
$menu_auth_ids = [];
|
||||
|
||||
return self::authListToTree($lists, 0, $menu_auth_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取的员工的权限
|
||||
* @param $lists
|
||||
* @param int $pid
|
||||
* @param array $menu_auth_ids
|
||||
* @return array
|
||||
*/
|
||||
public static function staffroleInfo($role_id)
|
||||
{
|
||||
return Db::name('staff_group')->where(['id' => $role_id])->field(['id', 'name'])->find();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑员工端权限
|
||||
* @param $lists
|
||||
* @param int $pid
|
||||
* @param array $menu_auth_ids
|
||||
* @return array
|
||||
*/
|
||||
public static function editstaffAuth(){
|
||||
|
||||
}
|
||||
}
|
||||
208
application/admin/logic/SeckillLogic.php
Normal file
208
application/admin/logic/SeckillLogic.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class SeckillLogic{
|
||||
|
||||
public static function goodsList($get){
|
||||
$where = [];
|
||||
$where[] = ['sg.del','=',0];
|
||||
$where[] = ['g.del','=',0];
|
||||
if(isset($get['name']) && $get['name']) {
|
||||
$where[] = ['name','like','%'.$get['name'].'%'];
|
||||
}
|
||||
|
||||
if(isset($get['seckill_id']) && $get['seckill_id']){
|
||||
$where[] = ['seckill_id','=',$get['seckill_id']];
|
||||
}
|
||||
|
||||
$count = Db::name('seckill_goods sg')
|
||||
->join('goods g','sg.goods_id = g.id')
|
||||
->where($where)
|
||||
->group('goods_id,seckill_id')
|
||||
->count();
|
||||
|
||||
|
||||
$list = Db::name('seckill_goods sg')
|
||||
->join('goods g','sg.goods_id = g.id')
|
||||
->where($where)
|
||||
->group('goods_id,seckill_id')
|
||||
->field('sg.id,seckill_id,goods_id,g.name,g.image,g.max_price,g.min_price,sg.sales_sum')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('sg.id desc')
|
||||
->select();
|
||||
$goods_ids = array_column($list,'goods_id');
|
||||
$seckill_goods_list = Db::name('seckill_goods')->where(['goods_id'=>$goods_ids])->column('*','id');
|
||||
|
||||
$seckill = Db::name('seckill_time')->where(['del'=>0])->column('*','id');
|
||||
foreach ($list as &$item){
|
||||
$price_array = [];
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['goods_price'] = '¥'.$item['min_price'];
|
||||
if($item['max_price'] != $item['min_price']){
|
||||
$item['goods_price'] = '¥'.$item['min_price'].' ~ '.'¥'.$item['max_price'];
|
||||
}
|
||||
if(isset($seckill[$item['seckill_id']])){
|
||||
$item['start_time'] = $seckill[$item['seckill_id']]['start_time'];
|
||||
$item['end_time'] = $seckill[$item['seckill_id']]['end_time'];
|
||||
}
|
||||
//该秒杀商品的全部规格
|
||||
$seckill_goods_item = Db::name('seckill_goods')
|
||||
->where(['seckill_id'=>$item['seckill_id'],'goods_id'=>$item['goods_id']])
|
||||
->column('*','id');
|
||||
foreach ($seckill_goods_item as $seckill_id => $seckill_item){
|
||||
|
||||
if(isset($seckill_goods_list[$seckill_id])){
|
||||
$price_array[] = $seckill_goods_list[$seckill_id]['price'];
|
||||
}
|
||||
}
|
||||
|
||||
$max_price = max($price_array);
|
||||
$min_price = min($price_array);
|
||||
|
||||
$item['seckill_price'] = '¥'.$max_price;
|
||||
if($max_price != $min_price){
|
||||
$item['seckill_price'] = '¥'.$min_price.' ~ '.'¥'.$max_price;
|
||||
}
|
||||
}
|
||||
|
||||
return ['count' => $count, 'list' => $list];
|
||||
}
|
||||
|
||||
public static function timeList($get){
|
||||
$where = [];
|
||||
$where[] = ['del','=',0];
|
||||
$count = Db::name('seckill_time')->where($where)->count();
|
||||
$list = Db::name('seckill_time')
|
||||
->where($where)
|
||||
->order('start_time asc')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
foreach ($list as &$item){
|
||||
$item['time'] = $item['start_time'].' ~ '.$item['end_time'];
|
||||
}
|
||||
return ['count' => $count, 'list' => $list];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function addTime($post){
|
||||
$post['create_time'] = time();
|
||||
$post['update_time'] = time();
|
||||
return Db::name('seckill_time')->insert($post);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function editTime($post){
|
||||
$post['update_time'] = time();
|
||||
return Db::name('seckill_time')->where(['id'=>$post['id']])->update($post);
|
||||
}
|
||||
|
||||
public static function addGoods($post){
|
||||
$now = time();
|
||||
$add_data = [];
|
||||
|
||||
foreach ($post['item'] as $item){
|
||||
$add_data[] =[
|
||||
'seckill_id' => $post['seckill_id'],
|
||||
'goods_id' => $item['goods_id'],
|
||||
'item_id' => $item['item_id'],
|
||||
'price' => $item['price'],
|
||||
'create_time' => $now,
|
||||
'sales_sum' => 0,
|
||||
'update_time' => $now,
|
||||
'del' => 0,
|
||||
];
|
||||
}
|
||||
return Db::name('seckill_goods')->insertAll($add_data);
|
||||
}
|
||||
|
||||
public static function editGoods($post){
|
||||
$now = time();
|
||||
|
||||
foreach ($post['item'] as $goods){
|
||||
|
||||
$update_data = [
|
||||
'seckill_id' => $post['seckill_id'],
|
||||
'price' => $goods['price'],
|
||||
'update_time' => $now,
|
||||
];
|
||||
Db::name('seckill_goods')->where(['id'=>$goods['id']])->update($update_data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function delGoods($id,$seckill_id){
|
||||
$update_data = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
return Db::name('seckill_goods')->where(['del'=>0,'goods_id'=>$id,'seckill_id'=>$seckill_id])->update($update_data);
|
||||
}
|
||||
|
||||
|
||||
public static function delTime($id){
|
||||
$update_data = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
Db::name('seckill_time')->where(['id'=>$id])->update($update_data);
|
||||
Db::name('seckill_goods')->where(['del'=>0,'seckill_id'=>$id])->update($update_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getTime($id){
|
||||
return Db::name('seckill_time')->where(['del'=>0,'id'=>$id])->find();
|
||||
}
|
||||
|
||||
public static function getTimeAll(){
|
||||
|
||||
$time_list = Db::name('seckill_time')->where(['del'=>0])->order('start_time asc')->select();
|
||||
foreach ($time_list as &$item){
|
||||
$item['time'] = $item['start_time'].' ~ '.$item['end_time'];
|
||||
}
|
||||
return $time_list;
|
||||
}
|
||||
|
||||
public static function getSeckillGoods($id,$seckill_id){
|
||||
$skill_goods = Db::name('seckill_goods sg')
|
||||
->join('goods_item gi','sg.item_id = gi.id')
|
||||
->where(['del'=>0,'sg.goods_id'=>$id,'sg.seckill_id'=>$seckill_id ])
|
||||
->field('sg.*,gi.image,gi.spec_value_str,gi.price as goods_price')
|
||||
->select();
|
||||
|
||||
$goods_id = $skill_goods[0]['goods_id'];
|
||||
$goods = Db::name('goods')->where(['del'=>0,'id'=>$goods_id])->field('image,name')->find();
|
||||
|
||||
foreach ($skill_goods as &$item){
|
||||
$item['name'] = $goods['name'];
|
||||
if(!$item['image']){
|
||||
$item['image'] = $goods['image'];
|
||||
}
|
||||
}
|
||||
|
||||
return $skill_goods;
|
||||
}
|
||||
|
||||
}
|
||||
42
application/admin/logic/ServiceConfigLogic.php
Normal file
42
application/admin/logic/ServiceConfigLogic.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\admin\logic;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
class ServiceConfigLogic{
|
||||
public static function getConfig(){
|
||||
$config = [
|
||||
'file_url' => UrlServer::getFileUrl('/'),
|
||||
'wechat' => ConfigServer::get('service','wechat',''),
|
||||
'phone' => ConfigServer::get('service','phone',''),
|
||||
'time' => ConfigServer::get('service','time',''),
|
||||
'image' => ConfigServer::get('service','image',''),
|
||||
];
|
||||
return $config;
|
||||
|
||||
}
|
||||
public static function setConfig($post){
|
||||
|
||||
foreach ($post as $config_name => $config_value){
|
||||
ConfigServer::set('service',$config_name,$config_value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
244
application/admin/logic/SignDailyLogic.php
Normal file
244
application/admin/logic/SignDailyLogic.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class SignDailyLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* 签到设置列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
$where[] = ['type', '=',2];
|
||||
$where[] = ['del','=',0];
|
||||
$count = Db::name('sign_daily')->where($where)->count();
|
||||
$lists = Db::name('sign_daily')->where($where)->select();
|
||||
return ['count' => $count,'list' => $lists];
|
||||
|
||||
}
|
||||
/**
|
||||
* 签到记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function record($get){
|
||||
$where = [];
|
||||
|
||||
if (isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = [$get['type'],'like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
|
||||
|
||||
$count = Db::name('user_sign us')
|
||||
->where(['us.del'=>0,'u.del'=>0])
|
||||
->where($where )
|
||||
->join('user u','u.id = us.user_id')
|
||||
->count();
|
||||
$lists = Db::name('user_sign us')
|
||||
->where(['us.del'=>0,'u.del'=>0])
|
||||
->where($where )
|
||||
->join('user u','u.id = us.user_id')
|
||||
->field('us.user_id,nickname,avatar,mobile,sex,u.create_time ,days,integral,growth,
|
||||
continuous_integral, continuous_growth,sign_time,mobile,us.sign_time')
|
||||
->order('us.id desc')
|
||||
->select();
|
||||
|
||||
foreach ( $lists as &$item){
|
||||
switch ($item['sex']){
|
||||
case 1:
|
||||
$item['sex'] = '男';
|
||||
break;
|
||||
case 2:
|
||||
$item['sex'] = '女';
|
||||
break;
|
||||
default:
|
||||
$item['sex'] = '未知';
|
||||
}
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['sign_time'] = date('Y-m-d H:i:s', $item['sign_time']);
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
}
|
||||
|
||||
return ['count' => $count,'list' => $lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加连续签到奖励
|
||||
* @param $post
|
||||
*/
|
||||
public static function add($post)
|
||||
{
|
||||
$data = [
|
||||
'type' =>'2',
|
||||
'days' => $post['days'],
|
||||
'integral' => $post['integral'],
|
||||
'integral_status' => $post['integral_status'],
|
||||
'growth' => $post['growth'],
|
||||
'growth_status' => $post['growth_status'],
|
||||
'del' =>0,
|
||||
'create_time' =>time()
|
||||
|
||||
|
||||
];
|
||||
return Db::name('sign_daily')->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连续签到奖励
|
||||
* @param $id
|
||||
* @return array|null|\PDOStatement|string|\think\Model
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function getSignDaily($id)
|
||||
{
|
||||
return Db::name('sign_daily')->where(['id' =>$id])->find();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑连续签到奖励
|
||||
* @param $post
|
||||
* @param $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit($post,$id)
|
||||
{
|
||||
$data = [
|
||||
'type' =>'2',
|
||||
'days' => $post['days'],
|
||||
'integral' => $post['integral'],
|
||||
'integral_status' => $post['integral_status'],
|
||||
'growth' => $post['growth'],
|
||||
'growth_status' => $post['growth_status'],
|
||||
'del' =>0,
|
||||
'update_time' =>time()
|
||||
];
|
||||
return Db::name('sign_daily')->where(['id' =>$id])->update($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除连续签到奖励列表
|
||||
* @param $id
|
||||
* @return int|string
|
||||
* @throws Exception
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
$data = [
|
||||
'id' =>$id,
|
||||
'del' =>1,
|
||||
'update_time' =>time()
|
||||
];
|
||||
$result = Db::name('sign_daily')->where(['id' =>$id])->update($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置签到
|
||||
* @param $post
|
||||
* @throws Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
* @throws \think\exception\PDOException
|
||||
*/
|
||||
public static function setSignRule($post)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'type' =>1,
|
||||
'days' => 0,
|
||||
'integral' =>$post['integral'],
|
||||
'growth' =>$post['growth'],
|
||||
'integral_status' =>$post['integral_status'],
|
||||
'growth_status' =>$post['growth_status'],
|
||||
'create_time' =>time(),
|
||||
'del' =>0,
|
||||
|
||||
];
|
||||
|
||||
$info = [
|
||||
'type' =>1,
|
||||
'days' => 0,
|
||||
'integral' =>$post['integral'],
|
||||
'growth' =>$post['growth'],
|
||||
'integral_status' =>$post['integral_status'],
|
||||
'growth_status' =>$post['growth_status'],
|
||||
'update_time' =>time(),
|
||||
'del' =>0,
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
$name = Db::name('sign_daily')->where(['type' =>1])->find();
|
||||
if (empty($name)){
|
||||
Db::name('sign_daily')->insert($data);
|
||||
}else{
|
||||
Db::name('sign_daily')->where(['type' =>1])->update($info);
|
||||
}
|
||||
|
||||
|
||||
ConfigServer::set('sign_rule','instructions',$post['instructions']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到规则说明
|
||||
* @return array
|
||||
*/
|
||||
public static function getSignRule()
|
||||
{
|
||||
|
||||
|
||||
$data = Db::name('sign_daily')->where(['type' =>1])->find();
|
||||
$config = [
|
||||
'instructions' => ConfigServer::get('sign_rule','instructions'),
|
||||
'dailySign' => $data
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $config;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
107
application/admin/logic/SmsLogic.php
Normal file
107
application/admin/logic/SmsLogic.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\model\NoticeSetting;
|
||||
use app\common\model\SmsLog;
|
||||
use think\Db;
|
||||
class SmsLogic{
|
||||
|
||||
public static function configLists(){
|
||||
$list = Db::name('sms_config')->where(['del'=>0])
|
||||
->field('id,name,status,describe')
|
||||
->select();
|
||||
foreach ($list as &$item){
|
||||
$item['status_desc'] = '关闭';
|
||||
if($item['status']){
|
||||
$item['status_desc'] = '开启';
|
||||
}
|
||||
}
|
||||
return ['count'=>count($list),'list'=>$list];
|
||||
}
|
||||
|
||||
public static function logLists($get){
|
||||
$where = [];
|
||||
if(isset($get['name']) && $get['name']){
|
||||
$where[] = ['d.name','like','%'.$get['name'].'%'];
|
||||
}
|
||||
if(isset($get['mobile']) && $get['mobile']){
|
||||
$where[] = ['mobile','like','%'.$get['mobile'].'%'];
|
||||
}
|
||||
if(isset($get['send_status']) && $get['send_status']){
|
||||
$where[] = ['send_status','=',$get['send_status']];
|
||||
}
|
||||
if(isset($get['start_time']) && $get['start_time']){
|
||||
$where[] = ['create_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']){
|
||||
$where[] = ['create_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
$sms_log = new SmsLog();
|
||||
|
||||
$count = $sms_log->alias('s')
|
||||
->where($where)
|
||||
->where('message_key', 'in', NoticeSetting::SMS_SCENE)
|
||||
->count();
|
||||
|
||||
|
||||
$list = $sms_log->alias('s')
|
||||
->field('s.*')
|
||||
->where('message_key', 'in', NoticeSetting::SMS_SCENE)
|
||||
->where($where)
|
||||
->order('s.id desc')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($list as $item) {
|
||||
$item['name'] = NoticeSetting::getSceneDesc($item['message_key']) ?? '短信通知';
|
||||
}
|
||||
|
||||
return ['count'=>$count,'list'=>$list];
|
||||
|
||||
}
|
||||
|
||||
public static function setConfig($post){
|
||||
$post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 0;
|
||||
|
||||
if ($post['status'] == 1) {
|
||||
Db::name('sms_config')->whereIn('id', [1, 2])
|
||||
->update(['status' => 0]);
|
||||
}
|
||||
|
||||
Db::name('sms_config')->where(['id'=>$post['id']])->update($post);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static function getConfig($id){
|
||||
return Db::name('sms_config')->where(['id'=>$id,'del'=>0])->find();
|
||||
}
|
||||
|
||||
public static function detail($id){
|
||||
$sms_log = new SmsLog();
|
||||
$log = $sms_log->alias('s')
|
||||
->where('s.message_key', 'in', NoticeSetting::SMS_SCENE)
|
||||
->field('s.*')->where(['s.id'=>$id])
|
||||
->find();
|
||||
|
||||
$log['name'] = NoticeSetting::getSceneDesc($log['message_key']);
|
||||
return $log;
|
||||
}
|
||||
|
||||
}
|
||||
2508
application/admin/logic/SonstatisLogic.php
Normal file
2508
application/admin/logic/SonstatisLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
673
application/admin/logic/StaffLogic.php
Normal file
673
application/admin/logic/StaffLogic.php
Normal file
@@ -0,0 +1,673 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class StaffLogic{
|
||||
/**
|
||||
* 显示查询列表的内容
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
|
||||
//判断离职
|
||||
if(isset($get['type']) && intval($get['type'])==1){
|
||||
$where[] = ['onwork','=',0];
|
||||
}
|
||||
//判断行政部
|
||||
if(isset($get['type']) && intval($get['type'])==5){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',17];
|
||||
}
|
||||
//判断客服部
|
||||
if(isset($get['type']) && intval($get['type'])==4){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',8];
|
||||
}
|
||||
//保洁部门
|
||||
if(isset($get['type']) && intval($get['type'])==6){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',10];
|
||||
}
|
||||
//做饭部
|
||||
if(isset($get['type']) && intval($get['type'])==3){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',15];
|
||||
}
|
||||
//工程部
|
||||
if(isset($get['type']) && intval($get['type'])==2){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',16];
|
||||
}
|
||||
//收纳部
|
||||
if(isset($get['type']) && intval($get['type'])==7){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',18];
|
||||
}
|
||||
//财务部
|
||||
if(isset($get['type']) && intval($get['type'])==8){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',21];
|
||||
}
|
||||
//财务部
|
||||
if(isset($get['type']) && intval($get['type'])==9){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',19];
|
||||
}
|
||||
|
||||
//财务部
|
||||
if(isset($get['type']) && intval($get['type'])==10){
|
||||
$where[] = ['onwork','=',1];
|
||||
$where[] = ['group_id','=',22];
|
||||
}
|
||||
|
||||
if(isset($get['id']) && $get['id'] != ''){
|
||||
$where[] = ['id','=',$get['id']];
|
||||
}
|
||||
//根据姓名查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//手机号码查询
|
||||
if(isset($get['mobile']) && $get['mobile'] != ''){
|
||||
$where[] = ['mobile', 'like', '%' . $get['mobile'] . '%'];
|
||||
}
|
||||
//地区查询
|
||||
if(isset($get['area_id']) && $get['area_id'] != ''){
|
||||
$where[] = ['area','=',$get['area_id']];
|
||||
}
|
||||
//是否结婚查询
|
||||
if(isset($get['marry']) && $get['marry'] != ''){
|
||||
$where[] = ['marry','=',$get['marry']];
|
||||
}
|
||||
//是否过敏
|
||||
if(isset($get['allergy']) && $get['allergy'] != ''){
|
||||
$where[] = ['allergy','=',$get['allergy']];
|
||||
}
|
||||
//员工性别
|
||||
if(isset($get['sex']) && $get['sex'] != ''){
|
||||
$where[] = ['sex','=',$get['sex']];
|
||||
}
|
||||
//是否在职查询
|
||||
if(isset($get['onwork']) && $get['onwork'] != ''){
|
||||
$where[] = ['onwork','=',$get['onwork']];
|
||||
}
|
||||
//分组查询
|
||||
if(isset($get['group_id']) && $get['group_id']){
|
||||
$where[] = ['group_id','=',$get['group_id']];
|
||||
}
|
||||
//消费金额
|
||||
if(isset($get['total_amount_start']) && $get['total_amount_start']){
|
||||
$where[] = ['total_order_amount','>=',$get['total_amount_start']];
|
||||
}
|
||||
if(isset($get['total_amount_end']) && $get['total_amount_end']){
|
||||
$where[] = ['total_order_amount','<=',$get['total_amount_end']];
|
||||
}
|
||||
|
||||
//注册时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
$where[] = ['createtime','>=',strtotime($get['start_time'])];
|
||||
}
|
||||
if(isset($get['end_time']) && $get['end_time']!=''){
|
||||
$where[] = ['createtime','<=',strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$user_count = Db::name('staff')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_list = Db::name('staff')
|
||||
->where($where)
|
||||
->field('password,pay_password,salt',true)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
//员工分组
|
||||
$user_group = Db::name('staff_group')->column('name','id');
|
||||
foreach ($user_list as &$item){
|
||||
if(isset($user_group[$item['group_id']])){
|
||||
$item['group_name'] = $user_group[$item['group_id']];
|
||||
}
|
||||
$user=Db::name('user')->where('id', $item['user_id'])->find(); //获取用户的基本信息
|
||||
if($user){
|
||||
$item['abs_avatar']=UrlServer::getFileUrl($user['avatar']);
|
||||
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
||||
|
||||
// 用户的出生日期
|
||||
$birthday = date("Y-m-d",$user['birthday']);
|
||||
// 获取当前日期
|
||||
$currentDate = date('Y-m-d');
|
||||
// 计算出生日期到当前日期的时间差
|
||||
$diff = date_diff(date_create($birthday), date_create($currentDate));
|
||||
// 获取年龄
|
||||
$item['age']= $diff->format('%y');
|
||||
}else{
|
||||
$item['abs_avatar']='-';
|
||||
$item['updatetime']='-';
|
||||
$item['age']='-';
|
||||
}
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 显示员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_bellistgoic($get){
|
||||
$user_count = Db::name('staff_group')
|
||||
->count();
|
||||
$user_list = Db::name('staff_group')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
|
||||
}
|
||||
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 获取到员工部门
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_bellist(){
|
||||
return Db::name('staff_group')->select();
|
||||
}
|
||||
/**
|
||||
* 根据获取员工部门的信息
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beliinfo($id){
|
||||
return Db::name('staff_group')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function staff_beedit($get){
|
||||
|
||||
return Db::name('staff_group')->where(['id'=>$get['id']])->update(['name'=>$get['name'],'rloe'=>$get['auth_ids']]);
|
||||
}
|
||||
/**
|
||||
* 增加员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beeadd($get){
|
||||
return Db::name('staff_group')->data(['name'=>$get['name']])->insert();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除员工分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beedel($id){
|
||||
return Db::name('staff_group')->where('id',$id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工类型列表
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typelist($get){
|
||||
$user_count = Db::name('staff_type')->count();
|
||||
$user_list = Db::name('staff_type')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
/**
|
||||
* 员工类型增加方法
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typeadd($post){
|
||||
return Db::name('staff_group')->where(['id'=>$post['id']])->update(['name'=>$get['name']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改员工的服务类别
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typeedit($post){
|
||||
return Db::name('staff_type')->where(['id'=>$post['id']])->update(['name'=>$post['name']]);
|
||||
}
|
||||
/**
|
||||
* 删除员工服务类别
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_typedel($id){
|
||||
return Db::name('staff_type')->where('id',$id)->delete();
|
||||
}
|
||||
/**
|
||||
* 获取员工的类别
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function type(){
|
||||
return Db::name('staff_type')->field('id,name')->select();
|
||||
}
|
||||
/**
|
||||
* 获取员工的分组
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function staff_beed(){
|
||||
return Db::name('staff_group')->field('id,name')->select();
|
||||
|
||||
}
|
||||
/**
|
||||
* 员工地区的分类
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public static function goods_type(){
|
||||
return Db::name('goods_brand')->field('id,name')->where('del',0)->where('id','<>',5)->select();
|
||||
}
|
||||
|
||||
public static function getAllTree()
|
||||
{
|
||||
$lists = Db::name('dev_region')
|
||||
->field(['name', 'id', 'parent_id', 'level'])
|
||||
->order(['parent_id' => 'desc'])
|
||||
->select();
|
||||
return $lists;
|
||||
}
|
||||
/**
|
||||
* 增加新的员工
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public static function add($post){
|
||||
$now = time();
|
||||
$post['createtime'] = $now;
|
||||
$post['updatetime'] = $now;
|
||||
return Db::name('staff')->insertGetId($post);
|
||||
|
||||
}
|
||||
/*
|
||||
* 员工基本信息
|
||||
*/
|
||||
/**
|
||||
* 员工基本信息
|
||||
* @param $goods_id
|
||||
* @return array
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
$info['base'] = Db::name('staff')
|
||||
->where(['id' => $id])
|
||||
->withAttr('abs_image', function ($value, $data) {
|
||||
return UrlServer::getFileUrl($data['image']);
|
||||
})
|
||||
->withAttr('content', function ($value){
|
||||
$preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
|
||||
$local_url = UrlServer::getFileUrl('/');
|
||||
return preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
|
||||
})
|
||||
->append(['abs_image','abs_video'])->find();
|
||||
|
||||
return $info;
|
||||
}
|
||||
/**
|
||||
* 修改员工的基础信息
|
||||
* @param $id 员工的ID
|
||||
* @return array
|
||||
*/
|
||||
public static function edits($post){
|
||||
$data = [
|
||||
'updatetime' => time(),
|
||||
'name'=>$post['name'],
|
||||
'mobile'=>$post['mobile'],
|
||||
'sex'=>$post['sex'],
|
||||
'identity'=>$post['identity'],
|
||||
'nation'=>$post['nation'],
|
||||
'group_id'=>$post['brand_id'],
|
||||
'goods_id'=>$post['goods_id'],
|
||||
'lng'=>$post['store_latitude'],
|
||||
'addr'=>$post['addr'],
|
||||
'lat'=>$post['store_longitude'],
|
||||
'onwork'=>$post['onwork'],
|
||||
'remark'=>$post['remark'],
|
||||
'first_category_id'=>$post['first_category_id'],
|
||||
'second_category_id'=>$post['second_category_id'],
|
||||
'third_category_id'=>$post['third_category_id'],
|
||||
'jon'=>$post['jon'],
|
||||
'education'=>$post['education'],
|
||||
'urgent_name'=>$post['urgent_name'],
|
||||
'urgent_phone'=>$post['urgent_phone'],
|
||||
'birthday'=>$post['birthday'],
|
||||
'marry'=>$post['marry'],
|
||||
'native'=>$post['native'],
|
||||
'mooney'=>$post['mooney'],
|
||||
'score'=>$post['score'],
|
||||
'star'=>$post['star'],
|
||||
'bank'=>$post['bank'],
|
||||
'physical'=>$post['physical'],
|
||||
'account'=>$post['account'],
|
||||
'sbyhk'=>$post['sbyhk'],
|
||||
'social'=>$post['social'],
|
||||
'sign'=>$post['sign'],
|
||||
'transit'=>$post['transit'],
|
||||
'security'=>$post['security'],
|
||||
'insurances'=>$post['insurances'],
|
||||
'password'=>md5(md5($post['password'])),
|
||||
'type'=>$post['type'],
|
||||
'uid'=>$post['uid'],
|
||||
'lnglat'=>$post['lnglat'],
|
||||
'grouping_id'=>$post['grouping_id']
|
||||
|
||||
|
||||
];
|
||||
$list=Db::name('staff')->where('id',$post['goodss_id'])->data($data)->update();
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
//获取在职所有的员工
|
||||
public static function sfaffinfo($id){
|
||||
$where=[];
|
||||
$where[] = ['id','=', $id];
|
||||
$where[] = ['onwork','=','1'];
|
||||
return Db::name('staff')->where($where)->find();
|
||||
}
|
||||
//获取所有的员工内容
|
||||
public static function infostaff($id){
|
||||
$where=[];
|
||||
$where[] = ['id','=', $id];
|
||||
return Db::name('staff')->where($where)->find();
|
||||
}
|
||||
|
||||
//获取员工的列表
|
||||
public static function stafflist(){
|
||||
return Db::name('staff')->where('onwork',1)->select();
|
||||
}
|
||||
//获取员工的分组
|
||||
public static function grouping(){
|
||||
return Db::name('staff_grouping')->select();
|
||||
}
|
||||
//根据员工ID查询请假
|
||||
public static function havestaff($time){
|
||||
return $time;
|
||||
}
|
||||
|
||||
//员工分组内容
|
||||
|
||||
public static function group_list($post){
|
||||
$count=Db::name('staff_grouping')->count();
|
||||
$lists=Db::name('staff_grouping')
|
||||
->page($post['page'],$post['limit'])
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date("Y-m-d H:i:s",$item['create_time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
//员工端口最新公告
|
||||
public static function staff_notice($get){
|
||||
$count=Db::name('staff_notice')->count();
|
||||
$lists=Db::name('staff_notice')
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['time']=date("Y-m-d H:i:s",$item['time']);
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
//增加员工端口公告
|
||||
public static function staff_noticeadd($post){
|
||||
$post['time']=time();
|
||||
$inser=Db::name('staff_notice')->data($post)->insert();
|
||||
return $inser;
|
||||
}
|
||||
|
||||
//修改员工端公告
|
||||
public static function staff_noticedit($get){
|
||||
$renewal=Db::name('staff_notice')->where('id',$get['id'])->update(['title'=>$get['title'],'connect'=>$get['connect'],'introduction'=>$get['introduction'],'time'=>time()]);
|
||||
return $renewal;
|
||||
}
|
||||
|
||||
|
||||
public static function wages($get){
|
||||
$where=[];
|
||||
$whereOrdertime=[];
|
||||
$findtime=[];
|
||||
$currentDate = date('Y-m-d');
|
||||
$firstDayOfLastMonth = date('Y-m-01', strtotime('-1 month', strtotime($currentDate)));
|
||||
$daysInLastMonth = date('t', strtotime($firstDayOfLastMonth));
|
||||
|
||||
$current_timestamp = time(); //当前时间戳
|
||||
$wherestaff=[];
|
||||
if(isset($get['staff_id']) && $get['staff_id'] != ''){
|
||||
$wherestaff[]=['id','=',$get['staff_id']];
|
||||
}
|
||||
if(isset($get['phone']) && $get['phone'] != ''){
|
||||
$wherestaff[]=['mobile','=',$get['phone']];
|
||||
}
|
||||
if(isset($get['type']) && $get['type'] != ''){
|
||||
$wherestaff[]=['goods_id','=',$get['type']];
|
||||
}
|
||||
//增加时间
|
||||
if(isset($get['start_time']) && $get['start_time']!=''){
|
||||
|
||||
$data=date('Y-m',strtotime($get['start_time']));
|
||||
$start_of_last_month = strtotime($data . '-01');
|
||||
|
||||
$lastday = date('Y-m-d', strtotime("$data +1 month -1 day"));
|
||||
$end_of_last_month=strtotime($lastday);
|
||||
|
||||
$whereOrdertime[]=['autotime','>=',$start_of_last_month];
|
||||
$whereOrdertime[]=['autotime','<=',$end_of_last_month];
|
||||
|
||||
$findtime[]=['create_time','>=',$start_of_last_month];
|
||||
$findtime[]=['create_time','<=',$end_of_last_month];
|
||||
|
||||
|
||||
}else{
|
||||
$now = time();
|
||||
$start_of_last_month = strtotime(date('Y-m-01 00:00:00', strtotime('-1 month', $now)));
|
||||
$end_of_last_month = strtotime("last day of last month", $current_timestamp); //上一个月结束时间搓
|
||||
|
||||
$whereOrdertime[]=['autotime','>=',$start_of_last_month];
|
||||
$whereOrdertime[]=['autotime','<=',$end_of_last_month];
|
||||
|
||||
$findtime[]=['create_time','>=',$start_of_last_month];
|
||||
$findtime[]=['create_time','<=',$end_of_last_month];
|
||||
|
||||
}
|
||||
|
||||
|
||||
$count = Db::name('staff')
|
||||
->where($wherestaff)
|
||||
->where('onwork',1)
|
||||
->count();
|
||||
$lists = Db::name('staff')
|
||||
->where($wherestaff)
|
||||
->where('onwork',1)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$order_exe=Db::name('order_exe')->where('staff_id',$item['id'])->where($whereOrdertime)->where('staff_status',3)->select(); //获取当月的订单
|
||||
//统计总订单
|
||||
$item['total_orders']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->where($whereOrdertime)
|
||||
->where('staff_status',3)
|
||||
->count();
|
||||
//上午订单
|
||||
$item['sw_orders']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->where($whereOrdertime)
|
||||
->where('staff_status',3)
|
||||
->where('addtime',1)
|
||||
->count();
|
||||
//下午
|
||||
$item['xw_orders']=Db::name('order_exe')
|
||||
->where('staff_id',$item['id'])
|
||||
->where($whereOrdertime)
|
||||
->where('staff_status',3)
|
||||
->where('addtime',2)
|
||||
->count();
|
||||
//财务报销
|
||||
$item['finance']=Db::name('finance')
|
||||
->where('user_id',$item['id'])
|
||||
->whereTime('create_time','last month')
|
||||
->where('status',2)
|
||||
->sum('pay');
|
||||
|
||||
//上午加时
|
||||
$item['sw_addtime']=Db::name('order_exe a')
|
||||
->join('order_timeadd u','u.orderid=a.id')
|
||||
->where('a.staff_id',$item['id'])
|
||||
->where('a.autotime','>=',$start_of_last_month)
|
||||
->where('a.autotime','<=',$end_of_last_month)
|
||||
->where('u.status',2)
|
||||
->where('a.addtime',1)
|
||||
->sum('minute');
|
||||
|
||||
$item['sw_addtimes']=$item['sw_addtime']/60;
|
||||
$item['xw_addtime']=Db::name('order_exe a')
|
||||
->join('order_timeadd u','u.orderid=a.id')
|
||||
->where('a.staff_id',$item['id'])
|
||||
->where('a.autotime','>=',$start_of_last_month)
|
||||
->where('a.autotime','<=',$end_of_last_month)
|
||||
->where('u.status',2)
|
||||
->where('a.addtime',2)
|
||||
->sum('minute');
|
||||
$item['xw_addtimes']=round($item['xw_addtime']/60,2);
|
||||
|
||||
//请假
|
||||
$item['leave']=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('time','>=',$start_of_last_month)
|
||||
->where('time','<=',$end_of_last_month)
|
||||
->where('status',1)
|
||||
->where('addtime','<>',2)
|
||||
->count();
|
||||
$number=Db::name('leavesd')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('time','>=',$start_of_last_month)
|
||||
->where('time','<=',$end_of_last_month)
|
||||
->where('status',1)
|
||||
->where('addtime',2)
|
||||
->count();
|
||||
$item['leaves']= $item['leave']/2+$number;
|
||||
|
||||
$item['attendance']=$daysInLastMonth-$item['leaves'];
|
||||
|
||||
$item['fine']=Db::name('fine')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('create_time','>=',$start_of_last_month)
|
||||
->where('create_time','<=',$end_of_last_month)
|
||||
->sum('score');
|
||||
|
||||
//异常订单
|
||||
$item['abnormal']=Db::name('order_abnormal')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('create_time','>=',$start_of_last_month)
|
||||
->where('create_time','<=',$end_of_last_month)
|
||||
->count();
|
||||
|
||||
$item['annual']=Db::name('order_exe a')
|
||||
->join('order u','u.order_sn=a.order_sn')
|
||||
->where('a.staff_id',$item['id'])
|
||||
->where('a.autotime','>=',$start_of_last_month)
|
||||
->where('a.autotime','<=',$end_of_last_month)
|
||||
->where('u.number','>',9)
|
||||
->count();
|
||||
$item['erp_staff']=Db::name('erp_staff')
|
||||
->where('staff_id',$item['id'])
|
||||
->where('status',2)
|
||||
->where('create_time','>=',$start_of_last_month)
|
||||
->where('create_time','<=',$end_of_last_month)
|
||||
->sum('number');
|
||||
}
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function wagesdel($post){
|
||||
return Db::name('staff_wages')->where('id',$post)->delete();
|
||||
}
|
||||
|
||||
public static function serverstaff(){
|
||||
return Db::name('staff')->where('onwork',1)->where('type',0)->select();
|
||||
}
|
||||
|
||||
public static function goods_brand(){
|
||||
return Db::name('goods_brand')->where('id','<>',5)->select();
|
||||
}
|
||||
|
||||
public static function adder($post){
|
||||
return Db::name('staff')->where('id',$post['id'])->update(['lng'=>$post['store_longitude'],'lat'=>$post['store_latitude']]);
|
||||
}
|
||||
|
||||
//获取员工积分记录
|
||||
public static function points($get){
|
||||
$where=[];
|
||||
if(isset($get['mobile']) && $get['mobile'] != ''){
|
||||
$where[] = ['mobile', 'like', '%' . $get['mobile'] . '%'];
|
||||
}
|
||||
$user_count = Db::name('staff_points')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_list = Db::name('staff_points')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($user_list as &$item){
|
||||
$staff=Db::name('staff')->where('id',$item['staff_id'])->find();
|
||||
if($staff){
|
||||
$item['staff_name']=$staff['name'];
|
||||
$item['staff_mobile']=$staff['mobile'];
|
||||
$item['staff_number']=$staff['number'];
|
||||
}
|
||||
$item['add_time']=date("Y-m-d H:i:s",$item['add_time']);
|
||||
}
|
||||
return ['count'=>$user_count , 'lists'=>$user_list];
|
||||
}
|
||||
//根据部门ID获取到
|
||||
|
||||
public static function infolist($get){
|
||||
$count=Db::name('staff_grouping')
|
||||
->alias('s')
|
||||
->join('staff sg', 's.id = sg.grouping_id')
|
||||
->where('sg.onwork',1)
|
||||
->where('s.id',$get['id'])
|
||||
->count();
|
||||
$result = Db::name('staff_grouping')
|
||||
->alias('s')
|
||||
->join('staff sg', 's.id = sg.grouping_id')
|
||||
->where('sg.onwork',1)
|
||||
->where('s.id',$get['id'])
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
return ['count'=>$count , 'list'=>$result];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
171
application/admin/logic/StatLogic.php
Normal file
171
application/admin/logic/StatLogic.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\common\model\Pay;
|
||||
use think\helper\Time;
|
||||
use think\Db;
|
||||
|
||||
class StatLogic
|
||||
{
|
||||
//工作台基本数据
|
||||
public static function stat()
|
||||
{
|
||||
//更新时间
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//总
|
||||
$order_num_all = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->count();
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//总
|
||||
$order_amount_all = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
|
||||
// 今天新增会员数量
|
||||
$add_user_today = Db::name('user')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//昨天
|
||||
$add_user_yesterday = Db::name('user')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
//总
|
||||
$user_all = Db::name('user')
|
||||
->where('del', 0)
|
||||
->count();
|
||||
//变化
|
||||
$add_change = $add_user_today - $add_user_yesterday;
|
||||
if ($add_change >= 0) {
|
||||
$add_change = '+' . $add_change;
|
||||
}
|
||||
|
||||
$today_ip = Db::name('stat')
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
$yesterday_ip = Db::name('stat')
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
$ip_change = $today_ip - $yesterday_ip;
|
||||
if ($ip_change >= 0) {
|
||||
$ip_change = '+' . $ip_change;
|
||||
}
|
||||
$total_ip = Db::name('stat')->count();
|
||||
|
||||
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'add_user_today' => $add_user_today,
|
||||
'add_user_yesterday' => $add_user_yesterday,
|
||||
'add_user_change' => $add_change,
|
||||
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
'user_all' => $user_all,
|
||||
|
||||
'today_user_ip' => $today_ip ?? 0,
|
||||
'yesterday_user_ip' => $yesterday_ip ?? 0,
|
||||
'ip_change' => $ip_change,
|
||||
'total_user_ip' => $total_ip ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
//图标数据
|
||||
public static function graphData()
|
||||
{
|
||||
//今天时间戳
|
||||
list($start_t, $end_t) = Time::dayToNow(15);
|
||||
//echarts图表数据
|
||||
|
||||
$echarts_order_amount = [];
|
||||
$echarts_user_pv = [];
|
||||
$dates = [];
|
||||
for ($i = 1; $i <= 15; $i++) {
|
||||
$where_start = strtotime("+ ".$i."day", $start_t);
|
||||
$where_end = strtotime("+ ".$i."day", $start_t) + 86399;
|
||||
$dates[] = date('m-d',$where_end);
|
||||
|
||||
//每天订单金额
|
||||
$order_amount = Db::name('order')
|
||||
->where('create_time', '<=', $where_end)
|
||||
->where('create_time', '>=', $where_start)
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
|
||||
//每天用户访问量
|
||||
$user_pv = Db::name('stat')
|
||||
->where('create_time', '<=', $where_end)
|
||||
->where('create_time', '>=', $where_start)
|
||||
->value('today_user_pv');
|
||||
|
||||
$echarts_order_amount[] = $order_amount ?:0;
|
||||
$echarts_user_pv[] = $user_pv ?:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'echarts_order_amount' => $echarts_order_amount,
|
||||
'echarts_user_visit' => $echarts_user_pv,
|
||||
'dates' => $dates,
|
||||
];
|
||||
}
|
||||
}
|
||||
472
application/admin/logic/StatcLogic.php
Normal file
472
application/admin/logic/StatcLogic.php
Normal file
@@ -0,0 +1,472 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\Pay;
|
||||
use think\helper\Time;
|
||||
use think\Db;
|
||||
class StatcLogic{
|
||||
|
||||
/**
|
||||
* Notes: 时间
|
||||
* @author 段誉(2021/2/5 18:39)
|
||||
*/
|
||||
public static function timeData()
|
||||
{
|
||||
//今天时间戳
|
||||
list($start_t, $end_t) = Time::today();
|
||||
$start_today = date('Y-m-d H:i:s', $start_t);
|
||||
$end_today = date('Y-m-d H:i:s', $end_t);
|
||||
|
||||
//获取7天前零点到现在的时间戳
|
||||
list($start_s, $end_s) = Time::dayToNow(7);
|
||||
$start_seven = date('Y-m-d H:i:s', $start_s);
|
||||
$end_seven = date('Y-m-d H:i:s', $end_s);
|
||||
|
||||
// 获取15天前零点到现在的时间戳
|
||||
list($start_f, $end_f) = Time::dayToNow(15);
|
||||
$start_fifteen = date('Y-m-d H:i:s', $start_f);
|
||||
$end_fifteen = date('Y-m-d H:i:s', $end_f);
|
||||
|
||||
return [
|
||||
'start_t' => $start_t,
|
||||
'end_t' => $end_t,
|
||||
'start_s' => $start_s,
|
||||
'end_s' => $end_s,
|
||||
'start_f' => $start_f,
|
||||
'end_f' => $end_f,
|
||||
|
||||
'start_today' => $start_today,
|
||||
'end_today' => $end_today,
|
||||
'start_seven' => $start_seven,
|
||||
'end_seven' => $end_seven,
|
||||
'start_fifteen' => $start_fifteen,
|
||||
'end_fifteen' => $end_fifteen,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 统计订单列表的内容
|
||||
* @author 杨左(2021/2/5 18:39)
|
||||
*/
|
||||
public static function Numorder(){
|
||||
//更新时间
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where(['del' => 0])
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//统计订单总数月
|
||||
$order_amount_all = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
//应收账款
|
||||
$order_past_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('pay_zd',0)
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_past_yesterday = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('pay_zd',0)
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_past_change = $order_past_today - $order_past_yesterday;
|
||||
if ($order_past_change >= 0) {
|
||||
$order_past_change = '+' . $order_past_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_past_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',0)
|
||||
->where(['del' => 0])
|
||||
->sum('order_amount');
|
||||
|
||||
|
||||
//未收账款
|
||||
$order_not_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('pay_zd',1)
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_not_yesterday = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('pay_zd',1)
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_not_change = $order_not_today - $order_not_yesterday;
|
||||
if ($order_not_change >= 1) {
|
||||
$order_not_change = '+' . $order_not_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_not_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',1)
|
||||
->where(['del' => 0])
|
||||
->sum('order_amount');
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'order_past_today' => $order_past_today??0,
|
||||
'order_past_yesterday' => $order_past_yesterday??0,
|
||||
'order_past_all' => $order_past_all??0,
|
||||
'order_past_change' => $order_past_change,
|
||||
|
||||
|
||||
'order_not_today' => $order_not_today??0,
|
||||
'order_not_yesterday' => $order_not_yesterday??0,
|
||||
'order_not_all' => $order_not_all??0,
|
||||
'order_not_change' => $order_not_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 统计订单列表的内容
|
||||
* @author 杨左(2021/2/5 18:39)
|
||||
*/
|
||||
public static function UserNumorder(){
|
||||
//更新时间
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->where(['del' => 0,])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->where(['del' => 0])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//统计订单总数月
|
||||
$order_amount_all = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
//应收账款
|
||||
$order_past_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_past_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_past_change = $order_past_today - $order_past_yesterday;
|
||||
if ($order_past_change >= 0) {
|
||||
$order_past_change = '+' . $order_past_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_past_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
|
||||
|
||||
//未收账款
|
||||
$order_not_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_not_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_not_change = $order_not_today - $order_not_yesterday;
|
||||
if ($order_not_change >= 1) {
|
||||
$order_not_change = '+' . $order_not_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_not_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'order_past_today' => $order_past_today??0,
|
||||
'order_past_yesterday' => $order_past_yesterday??0,
|
||||
'order_past_all' => $order_past_all??0,
|
||||
'order_past_change' => $order_past_change,
|
||||
|
||||
|
||||
'order_not_today' => $order_not_today??0,
|
||||
'order_not_yesterday' => $order_not_yesterday??0,
|
||||
'order_not_all' => $order_not_all??0,
|
||||
'order_not_change' => $order_not_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function cleaning(){
|
||||
//日式保洁订单统计
|
||||
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->count();
|
||||
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//统计订单总数月
|
||||
$order_amount_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
//应收账款
|
||||
$order_past_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_past_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_past_change = $order_past_today - $order_past_yesterday;
|
||||
if ($order_past_change >= 0) {
|
||||
$order_past_change = '+' . $order_past_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_past_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
|
||||
|
||||
//未收账款
|
||||
$order_not_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_not_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_not_change = $order_not_today - $order_not_yesterday;
|
||||
if ($order_not_change >= 1) {
|
||||
$order_not_change = '+' . $order_not_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_not_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'order_past_today' => $order_past_today??0,
|
||||
'order_past_yesterday' => $order_past_yesterday??0,
|
||||
'order_past_all' => $order_past_all??0,
|
||||
'order_past_change' => $order_past_change,
|
||||
|
||||
|
||||
'order_not_today' => $order_not_today??0,
|
||||
'order_not_yesterday' => $order_not_yesterday??0,
|
||||
'order_not_all' => $order_not_all??0,
|
||||
'order_not_change' => $order_not_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
705
application/admin/logic/StatcubLogic.php
Normal file
705
application/admin/logic/StatcubLogic.php
Normal file
@@ -0,0 +1,705 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\Pay;
|
||||
use think\helper\Time;
|
||||
use think\Db;
|
||||
class StatcubLogic{
|
||||
|
||||
/**
|
||||
* Notes: 时间
|
||||
* @author 段誉(2021/2/5 18:39)
|
||||
*/
|
||||
public static function timeData()
|
||||
{
|
||||
//今天时间戳
|
||||
list($start_t, $end_t) = Time::today();
|
||||
$start_today = date('Y-m-d H:i:s', $start_t);
|
||||
$end_today = date('Y-m-d H:i:s', $end_t);
|
||||
|
||||
//获取7天前零点到现在的时间戳
|
||||
list($start_s, $end_s) = Time::dayToNow(7);
|
||||
$start_seven = date('Y-m-d H:i:s', $start_s);
|
||||
$end_seven = date('Y-m-d H:i:s', $end_s);
|
||||
|
||||
// 获取15天前零点到现在的时间戳
|
||||
list($start_f, $end_f) = Time::dayToNow(15);
|
||||
$start_fifteen = date('Y-m-d H:i:s', $start_f);
|
||||
$end_fifteen = date('Y-m-d H:i:s', $end_f);
|
||||
|
||||
return [
|
||||
'start_t' => $start_t,
|
||||
'end_t' => $end_t,
|
||||
'start_s' => $start_s,
|
||||
'end_s' => $end_s,
|
||||
'start_f' => $start_f,
|
||||
'end_f' => $end_f,
|
||||
|
||||
'start_today' => $start_today,
|
||||
'end_today' => $end_today,
|
||||
'start_seven' => $start_seven,
|
||||
'end_seven' => $end_seven,
|
||||
'start_fifteen' => $start_fifteen,
|
||||
'end_fifteen' => $end_fifteen,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 统计订单列表的内容
|
||||
* @author 杨左(2021/2/5 18:39)
|
||||
*/
|
||||
public static function Numorder(){
|
||||
//更新时间
|
||||
$time = time();
|
||||
$time_end =$time + 86399;
|
||||
|
||||
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order_exe')
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order_exe')
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order_exe')
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
//暂停订单数据
|
||||
$order_stop_today = Db::name('order_exe')
|
||||
->where('status',3)
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
//昨日
|
||||
$order_stop_yesterday = Db::name('order_exe')
|
||||
->where('status',3)
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_stop_change = $order_stop_today - $order_stop_yesterday;
|
||||
if ($order_stop_change >= 0) {
|
||||
$order_stop_change = '+' . $order_stop_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_stop_all = Db::name('order_exe')
|
||||
->where('status',3)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
//待接单
|
||||
$order_wait_today = Db::name('order_exe')
|
||||
->where('staff_status',0)
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
//昨日
|
||||
$order_wait_yesterday = Db::name('order_exe')
|
||||
->where('staff_status',0)
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_wait_change = $order_wait_today - $order_wait_yesterday;
|
||||
if ($order_wait_change >= 0) {
|
||||
$order_wait_change = '+' . $order_wait_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_wait_all = Db::name('order_exe')
|
||||
->where('staff_status',0)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//已完成统计
|
||||
$order_comp_today = Db::name('order_exe')
|
||||
->whereTime('autotime', 'today')
|
||||
->where('staff_status',3)
|
||||
->count();
|
||||
//昨日
|
||||
$order_comp_yesterday = Db::name('order_exe')
|
||||
->where('staff_status',3)
|
||||
|
||||
->whereTime('autotime', 'yesterday')
|
||||
->count();
|
||||
|
||||
//统计订单笔数
|
||||
$order_comp_all = Db::name('order_exe')
|
||||
->where('staff_status',3)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
//是否上传图片
|
||||
$order_img_today = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_img_yesterday = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'yesterday')
|
||||
->count();
|
||||
|
||||
//统计订单笔数
|
||||
$order_img_all = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
//今天未派单
|
||||
$order_pary_today=Db::name('order_exe')
|
||||
->whereNull('staff_id')
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
|
||||
$order_pary_yesterday=Db::name('order_exe')
|
||||
->whereNull('staff_id')
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
|
||||
$pary=Db::name('order_exe')
|
||||
->where('abnormal',1)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
|
||||
'order_stop_today' => $order_stop_today,
|
||||
'order_stop_yesterday' => $order_stop_yesterday,
|
||||
'order_stop_change' => $order_stop_change,
|
||||
'order_stop_all' => $order_stop_all,
|
||||
|
||||
'order_wait_today' => $order_wait_today-$order_stop_today,
|
||||
'order_wait_yesterday' => $order_wait_yesterday-$order_stop_yesterday,
|
||||
'order_wait_change' => $order_wait_change,
|
||||
'order_wait_all' => $order_wait_all-$order_stop_all,
|
||||
|
||||
'order_comp_today' => $order_comp_today,
|
||||
'order_comp_yesterday' => $order_comp_yesterday,
|
||||
'order_comp_all' => $order_comp_all,
|
||||
|
||||
|
||||
'order_img_today' => $order_img_today,
|
||||
'order_img_yesterday' => $order_img_yesterday,
|
||||
'order_img_all' => $order_img_all,
|
||||
|
||||
'order_pary_today' => $order_pary_today,
|
||||
'order_pary_yesterday' => $order_pary_yesterday,
|
||||
'pary' =>$pary
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 统计订单列表的内容
|
||||
* @author 杨左(2021/2/5 18:39)
|
||||
*/
|
||||
public static function UserNumorder(){
|
||||
//更新时间
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//统计订单总数月
|
||||
$order_amount_all = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'month')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
//应收账款
|
||||
$order_past_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_past_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_past_change = $order_past_today - $order_past_yesterday;
|
||||
if ($order_past_change >= 0) {
|
||||
$order_past_change = '+' . $order_past_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_past_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',0)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
|
||||
|
||||
//未收账款
|
||||
$order_not_today = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//昨日
|
||||
$order_not_yesterday = Db::name('order')
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->whereTime('create_time', 'yesterday')
|
||||
->sum('order_amount');
|
||||
//变化
|
||||
$order_not_change = $order_not_today - $order_not_yesterday;
|
||||
if ($order_not_change >= 1) {
|
||||
$order_not_change = '+' . $order_not_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_not_all = Db::name('order')
|
||||
->whereTime('create_time', 'month')
|
||||
->where('pay_zd',1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['del' => 0, 'pay_status' => Pay::ISPAID])
|
||||
->sum('order_amount');
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'order_past_today' => $order_past_today??0,
|
||||
'order_past_yesterday' => $order_past_yesterday??0,
|
||||
'order_past_all' => $order_past_all??0,
|
||||
'order_past_change' => $order_past_change,
|
||||
|
||||
|
||||
'order_not_today' => $order_not_today??0,
|
||||
'order_not_yesterday' => $order_not_yesterday??0,
|
||||
'order_not_all' => $order_not_all??0,
|
||||
'order_not_change' => $order_not_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 我的日式保洁
|
||||
* @param $get
|
||||
* @author 杨左(2021/2/1 10:12)
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public static function Usercleaning(){
|
||||
//日式保洁订单统计
|
||||
|
||||
$time = date('Y-m-d H:i:s', time());
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->count();
|
||||
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//今日销售金额(元)
|
||||
$order_amount_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_amount_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//统计订单总数月
|
||||
$order_amount_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_amount_change = $order_amount_today - $order_amount_yesterday;
|
||||
if ($order_amount_change >= 0) {
|
||||
$order_amount_change = '+' . $order_amount_change;
|
||||
}
|
||||
|
||||
//应收账款
|
||||
$order_past_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_past_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_past_change = $order_past_today - $order_past_yesterday;
|
||||
if ($order_past_change >= 0) {
|
||||
$order_past_change = '+' . $order_past_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_past_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>0])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
|
||||
|
||||
//未收账款
|
||||
$order_not_today = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'today')
|
||||
->sum('o.order_amount');
|
||||
//昨日
|
||||
$order_not_yesterday = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'yesterday')
|
||||
->sum('o.order_amount');
|
||||
//变化
|
||||
$order_not_change = $order_not_today - $order_not_yesterday;
|
||||
if ($order_not_change >= 1) {
|
||||
$order_not_change = '+' . $order_not_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_not_all = Db::name('order')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('admin_id',session('admin_info.id'))
|
||||
->where('g.brand_id', 1)
|
||||
->where(['o.del' => 0,'o.pay_zd'=>1])
|
||||
->whereTime('o.create_time', 'month')
|
||||
->sum('o.order_amount');
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_amount_today' => $order_amount_today,
|
||||
'order_amount_yesterday' => $order_amount_yesterday,
|
||||
'order_amount_change' => $order_amount_change,
|
||||
|
||||
'order_past_today' => $order_past_today??0,
|
||||
'order_past_yesterday' => $order_past_yesterday??0,
|
||||
'order_past_all' => $order_past_all??0,
|
||||
'order_past_change' => $order_past_change,
|
||||
|
||||
|
||||
'order_not_today' => $order_not_today??0,
|
||||
'order_not_yesterday' => $order_not_yesterday??0,
|
||||
'order_not_all' => $order_not_all??0,
|
||||
'order_not_change' => $order_not_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
'order_amount_all' => $order_amount_all,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 产能中心子订单统计
|
||||
* @author 杨左(2021/2/5 18:39)
|
||||
*/
|
||||
|
||||
public static function capcleaning(){
|
||||
//更新时间
|
||||
$time = time();
|
||||
$time_end =$time + 86399;
|
||||
|
||||
|
||||
//今日成交订单
|
||||
$order_num_today = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->where('o.autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
//昨日
|
||||
$order_num_yesterday = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->whereTime('o.autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_num_change = $order_num_today - $order_num_yesterday;
|
||||
if ($order_num_change >= 0) {
|
||||
$order_num_change = '+' . $order_num_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_num_all = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->whereTime('o.autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
//暂停订单数据
|
||||
$order_stop_today = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.status',3)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->where('o.autotime', 'between', [$time, $time_end])
|
||||
|
||||
->count();
|
||||
//昨日
|
||||
$order_stop_yesterday = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.status',3)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->whereTime('o.autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_stop_change = $order_stop_today - $order_stop_yesterday;
|
||||
if ($order_stop_change >= 0) {
|
||||
$order_stop_change = '+' . $order_stop_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_stop_all = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.status',3)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->whereTime('o.autotime', 'month')
|
||||
->count();
|
||||
|
||||
//待接单
|
||||
$order_wait_today = Db::name('order_exe')
|
||||
->alias('o')
|
||||
->join('goods g', 'o.goods_id = g.id')
|
||||
->where('g.brand_id', 1)
|
||||
->where('o.admin_id',session('admin_info.id'))
|
||||
->where('staff_status',0)
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
//昨日
|
||||
$order_wait_yesterday = Db::name('order_exe')
|
||||
->where('staff_status',0)
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//变化
|
||||
$order_wait_change = $order_wait_today - $order_wait_yesterday;
|
||||
if ($order_wait_change >= 0) {
|
||||
$order_wait_change = '+' . $order_wait_change;
|
||||
}
|
||||
//统计订单笔数
|
||||
$order_wait_all = Db::name('order_exe')
|
||||
->where('staff_status',0)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
|
||||
//已完成统计
|
||||
$order_comp_today = Db::name('order_exe')
|
||||
->whereTime('autotime', 'today')
|
||||
->where('staff_status',3)
|
||||
->count();
|
||||
//昨日
|
||||
$order_comp_yesterday = Db::name('order_exe')
|
||||
->where('staff_status',3)
|
||||
|
||||
->whereTime('autotime', 'yesterday')
|
||||
->count();
|
||||
|
||||
//统计订单笔数
|
||||
$order_comp_all = Db::name('order_exe')
|
||||
->where('staff_status',3)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
|
||||
|
||||
//是否上传图片
|
||||
$order_img_today = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
//昨日
|
||||
$order_img_yesterday = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'yesterday')
|
||||
->count();
|
||||
|
||||
//统计订单笔数
|
||||
$order_img_all = Db::name('order_exe')
|
||||
->where('is_images',1)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
//今天未派单
|
||||
$order_pary_today=Db::name('order_exe')
|
||||
->whereNull('staff_id')
|
||||
->where('autotime', 'between', [$time, $time_end])
|
||||
->count();
|
||||
|
||||
$order_pary_yesterday=Db::name('order_exe')
|
||||
->whereNull('staff_id')
|
||||
->whereTime('autotime', 'today')
|
||||
->count();
|
||||
|
||||
$pary=Db::name('order_exe')
|
||||
->where('abnormal',1)
|
||||
->whereTime('autotime', 'month')
|
||||
->count();
|
||||
return [
|
||||
'time' => $time,
|
||||
'order_num_today' => $order_num_today,
|
||||
'order_num_yesterday' => $order_num_yesterday,
|
||||
'order_num_change' => $order_num_change,
|
||||
'order_num_all' => $order_num_all,
|
||||
|
||||
'order_stop_today' => $order_stop_today,
|
||||
'order_stop_yesterday' => $order_stop_yesterday,
|
||||
'order_stop_change' => $order_stop_change,
|
||||
'order_stop_all' => $order_stop_all,
|
||||
|
||||
'order_wait_today' => $order_wait_today-$order_stop_today,
|
||||
'order_wait_yesterday' => $order_wait_yesterday-$order_stop_yesterday,
|
||||
'order_wait_change' => $order_wait_change,
|
||||
'order_wait_all' => $order_wait_all-$order_stop_all,
|
||||
|
||||
'order_comp_today' => $order_comp_today,
|
||||
'order_comp_yesterday' => $order_comp_yesterday,
|
||||
'order_comp_all' => $order_comp_all,
|
||||
|
||||
|
||||
'order_img_today' => $order_img_today,
|
||||
'order_img_yesterday' => $order_img_yesterday,
|
||||
'order_img_all' => $order_img_all,
|
||||
|
||||
'order_pary_today' => $order_pary_today,
|
||||
'order_pary_yesterday' => $order_pary_yesterday,
|
||||
'pary' =>$pary
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
615
application/admin/logic/StatisticsLogic.php
Normal file
615
application/admin/logic/StatisticsLogic.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
use app\common\model\OrderGoods;
|
||||
use app\common\model\Pay;
|
||||
use think\helper\Time;
|
||||
use think\Db;
|
||||
|
||||
class StatisticsLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 时间
|
||||
* @author 段誉(2021/2/5 18:39)
|
||||
*/
|
||||
public static function timeData()
|
||||
{
|
||||
//今天时间戳
|
||||
list($start_t, $end_t) = Time::today();
|
||||
$start_today = date('Y-m-d H:i:s', $start_t);
|
||||
$end_today = date('Y-m-d H:i:s', $end_t);
|
||||
|
||||
//获取7天前零点到现在的时间戳
|
||||
list($start_s, $end_s) = Time::dayToNow(7);
|
||||
$start_seven = date('Y-m-d H:i:s', $start_s);
|
||||
$end_seven = date('Y-m-d H:i:s', $end_s);
|
||||
|
||||
// 获取15天前零点到现在的时间戳
|
||||
list($start_f, $end_f) = Time::dayToNow(15);
|
||||
$start_fifteen = date('Y-m-d H:i:s', $start_f);
|
||||
$end_fifteen = date('Y-m-d H:i:s', $end_f);
|
||||
|
||||
return [
|
||||
'start_t' => $start_t,
|
||||
'end_t' => $end_t,
|
||||
'start_s' => $start_s,
|
||||
'end_s' => $end_s,
|
||||
'start_f' => $start_f,
|
||||
'end_f' => $end_f,
|
||||
|
||||
'start_today' => $start_today,
|
||||
'end_today' => $end_today,
|
||||
'start_seven' => $start_seven,
|
||||
'end_seven' => $end_seven,
|
||||
'start_fifteen' => $start_fifteen,
|
||||
'end_fifteen' => $end_fifteen,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 会员统计
|
||||
* @param $post
|
||||
* @author 段誉(2021/2/5 17:17)
|
||||
* @return array
|
||||
*/
|
||||
public static function member($post)
|
||||
{
|
||||
$timeData = self::timeData();
|
||||
|
||||
// 会员总数
|
||||
$count = Db::name('user')->where('del', 0)->count();
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'today') {
|
||||
// 今天新增会员数量
|
||||
$add_today = Db::name('user')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_today'],
|
||||
'end' => $timeData['end_today'],
|
||||
'count' => $count,
|
||||
'add' => $add_today,
|
||||
'start_seven' => $timeData['start_seven'],
|
||||
'end_seven' => $timeData['end_seven'],
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_seven') {
|
||||
// 获取7天新增会员数量
|
||||
$add_seven = Db::name('user')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
return [
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven'],
|
||||
'count' => $count,
|
||||
'add' => $add_seven
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_fifteen') {
|
||||
// 获取15天新增会员数量
|
||||
$add_thirty = Db::name('user')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
return [
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen'],
|
||||
'count' => $count,
|
||||
'add' => $add_thirty
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (isset($post['member']) && $post['member'] == 'ago_seven') {
|
||||
$echarts_data = self::getMemberData($timeData['start_s'], 7);
|
||||
return [
|
||||
'echarts_count' => $echarts_data['count'],
|
||||
'echarts_add' => $echarts_data['new'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven']
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['member']) && $post['member'] == 'ago_fifteen') {
|
||||
$echarts_data = self::getMemberData($timeData['start_f'], 15);
|
||||
return [
|
||||
'echarts_count' => $echarts_data['count'],
|
||||
'echarts_add' => $echarts_data['new'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 会员图表数据
|
||||
* @param $end_stamp
|
||||
* @param $days
|
||||
* @author 段誉(2021/2/5 17:17)
|
||||
* @return array
|
||||
*/
|
||||
public static function getMemberData($start_stamp, $days)
|
||||
{
|
||||
$dates = [];
|
||||
for ($i = 1; $i <= $days; $i++) {
|
||||
$time_start = strtotime("+ ".$i."day", $start_stamp);
|
||||
$time_end = strtotime("+ ".$i."day", $start_stamp) + 86399;
|
||||
|
||||
$dates[] = date('m-d', $time_end);
|
||||
|
||||
$echarts_count[] = Db::name('user')
|
||||
->where('create_time', '<=', $time_end)
|
||||
->where('del', 0)
|
||||
->count();
|
||||
|
||||
$echarts_new[] = Db::name('user')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->where('del', 0)
|
||||
->count();
|
||||
}
|
||||
|
||||
return [
|
||||
'count' => $echarts_count,
|
||||
'new' => $echarts_new,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商品统计
|
||||
* @param $post
|
||||
* @author 段誉(2021/2/5 17:45)
|
||||
* @return array
|
||||
*/
|
||||
public static function goods($post)
|
||||
{
|
||||
$timeData = self::timeData();
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'today') {
|
||||
|
||||
$goods_click_today = Db::name('goods_click')
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
$goods_sale_today = Db::name('order')
|
||||
->where(['pay_status' => Pay::ISPAID, 'refund_status' => OrderGoods::REFUND_STATUS_NO])
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('total_num');
|
||||
|
||||
$goods_collect_today = Db::name('goods_collect')
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_today'],
|
||||
'end' => $timeData['end_today'],
|
||||
'goods_click' => $goods_click_today,
|
||||
'goods_sale' => $goods_sale_today,
|
||||
'goods_collect' => $goods_collect_today,
|
||||
'start_seven' => $timeData['start_seven'],
|
||||
'end_seven' => $timeData['end_seven'],
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_seven') {
|
||||
|
||||
$goods_click_seven = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
|
||||
$goods_sale_seven = Db::name('order')
|
||||
->where(['pay_status' => Pay::ISPAID, 'refund_status' => OrderGoods::REFUND_STATUS_NO])
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->sum('total_num');
|
||||
|
||||
$goods_collect_seven = Db::name('goods_collect')
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven'],
|
||||
'goods_click' => $goods_click_seven,
|
||||
'goods_sale' => $goods_sale_seven,
|
||||
'goods_collect' => $goods_collect_seven
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_fifteen') {
|
||||
|
||||
$goods_click_fifteen = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
|
||||
$goods_sale_fifteen = Db::name('order')
|
||||
->where(['pay_status' => Pay::ISPAID, 'refund_status' => OrderGoods::REFUND_STATUS_NO])
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->sum('total_num');
|
||||
|
||||
$goods_collect_fifteen = Db::name('goods_collect')
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen'],
|
||||
'goods_click' => $goods_click_fifteen,
|
||||
'goods_sale' => $goods_sale_fifteen,
|
||||
'goods_collect' => $goods_collect_fifteen
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (isset($post['goods']) && $post['goods'] == 'ago_seven') {
|
||||
$echarts_data = self::getGoodsData($timeData['start_s'], 7);
|
||||
return [
|
||||
'echarts_goods_click' => $echarts_data['click'],
|
||||
'echarts_goods_collect' => $echarts_data['collect'],
|
||||
'echarts_goods_sale' => $echarts_data['sale'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven']
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['goods']) && $post['goods'] == 'ago_fifteen') {
|
||||
$echarts_data = self::getGoodsData($timeData['start_f'], 15);
|
||||
return [
|
||||
'echarts_goods_click' => $echarts_data['click'],
|
||||
'echarts_goods_collect' => $echarts_data['collect'],
|
||||
'echarts_goods_sale' => $echarts_data['sale'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['start_fifteen']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 商品图表数据
|
||||
* @param $end_stamp
|
||||
* @param $days
|
||||
* @author 段誉(2021/2/5 17:45)
|
||||
* @return array
|
||||
*/
|
||||
public static function getGoodsData($start_stamp, $days)
|
||||
{
|
||||
$dates = [];
|
||||
for ($i = 1; $i <= $days; $i++) {
|
||||
|
||||
$time_start = strtotime("+ ".$i."day", $start_stamp);
|
||||
$time_end = strtotime("+ ".$i."day", $start_stamp) + 86399;
|
||||
|
||||
$dates[] = date('m-d', $time_end);
|
||||
|
||||
//7天每天商品浏览量
|
||||
$echarts_goods_click[] = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
//7天每天商品收藏量
|
||||
$echarts_goods_collect[] = Db::name('goods_collect')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
//7天每天商品销量
|
||||
$echarts_goods_sale[] = Db::name('order')
|
||||
->where(['pay_status' => Pay::ISPAID, 'refund_status' => OrderGoods::REFUND_STATUS_NO])
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->sum('total_num');
|
||||
}
|
||||
|
||||
return [
|
||||
'click' => $echarts_goods_click,
|
||||
'collect' => $echarts_goods_collect,
|
||||
'sale' => $echarts_goods_sale,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 交易统计
|
||||
* @param $post
|
||||
* @author 段誉(2021/2/5 18:06)
|
||||
* @return array
|
||||
*/
|
||||
public static function deal($post)
|
||||
{
|
||||
$timeData = self::timeData();
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'today') {
|
||||
//订单金额
|
||||
$order_amount_today = Db::name('order')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'today')
|
||||
->sum('order_amount');
|
||||
//订单数量
|
||||
$order_num_today = Db::name('order')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
//商家售后单数量
|
||||
$after_num_today = Db::name('after_sale')
|
||||
->where('del', 0)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_today'],
|
||||
'end' => $timeData['end_today'],
|
||||
'start_seven' => $timeData['start_seven'],
|
||||
'end_seven' => $timeData['end_seven'],
|
||||
'order_amount' => $order_amount_today,
|
||||
'order_num' => $order_num_today,
|
||||
'after_num' => $after_num_today
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_seven') {
|
||||
//订单金额
|
||||
$order_amount_seven = Db::name('order')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->sum('order_amount');
|
||||
//订单数量
|
||||
$order_num_seven = Db::name('order')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
//商家售后单数量
|
||||
$after_num_seven = Db::name('after_sale')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven'],
|
||||
'order_amount' => $order_amount_seven,
|
||||
'order_num' => $order_num_seven,
|
||||
'after_num' => $after_num_seven
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_fifteen') {
|
||||
//订单金额
|
||||
$order_amount_fifteen = Db::name('order')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->sum('order_amount');
|
||||
//订单数量
|
||||
$order_num_fifteen = Db::name('order')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
//商家售后单数量
|
||||
$after_num_fifteen = Db::name('after_sale')
|
||||
->where('del', 0)
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen'],
|
||||
'order_amount' => $order_amount_fifteen,
|
||||
'order_num' => $order_num_fifteen,
|
||||
'after_num' => $after_num_fifteen
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['deal']) && $post['deal'] == 'ago_seven') {
|
||||
|
||||
$echarts_data = self::getDealData($timeData['start_s'], 7);
|
||||
|
||||
return [
|
||||
'echarts_order_amount' => $echarts_data['amount'],
|
||||
'echarts_order_num' => $echarts_data['num'],
|
||||
'echarts_after_num' => $echarts_data['after'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven']
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['deal']) && $post['deal'] == 'ago_fifteen') {
|
||||
|
||||
$echarts_data = self::getDealData($timeData['start_f'], 15);
|
||||
|
||||
return [
|
||||
'echarts_order_amount' => $echarts_data['amount'],
|
||||
'echarts_order_num' => $echarts_data['num'],
|
||||
'echarts_after_num' => $echarts_data['after'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 交易数据
|
||||
* @param $end_stamp
|
||||
* @param $days
|
||||
* @author 段誉(2021/2/5 18:07)
|
||||
* @return array
|
||||
*/
|
||||
public static function getDealData($start_stamp, $days)
|
||||
{
|
||||
$dates = [];
|
||||
for ($i = 1; $i <= $days; $i++) {
|
||||
|
||||
$time_start = strtotime("+ ".$i."day", $start_stamp);
|
||||
$time_end = strtotime("+ ".$i."day", $start_stamp) + 86399;
|
||||
$dates[] = date('m-d', $time_end);
|
||||
|
||||
//每天订单金额
|
||||
$echarts_order_amount[] = Db::name('order')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->sum('order_amount');
|
||||
//每天订单数量
|
||||
$echarts_order_num[] = Db::name('order')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
//每天售后量
|
||||
$echarts_after_num[] = Db::name('after_sale')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
}
|
||||
|
||||
return [
|
||||
'amount' => $echarts_order_amount,
|
||||
'num' => $echarts_order_num,
|
||||
'after' => $echarts_after_num,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 访问统计
|
||||
* @param $post
|
||||
* @author 段誉(2021/2/5 18:36)
|
||||
* @return array
|
||||
*/
|
||||
public static function visit($post)
|
||||
{
|
||||
$timeData = self::timeData();
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'today') {
|
||||
|
||||
$goods_click_today = Db::name('goods_click')
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
$user_click_today = Db::name('stat')
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_today'],
|
||||
'end' => $timeData['end_today'],
|
||||
'goods_click' => $goods_click_today,
|
||||
'user_click' => $user_click_today,
|
||||
'start_seven' => $timeData['start_seven'],
|
||||
'end_seven' => $timeData['end_seven'],
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_seven') {
|
||||
|
||||
$goods_click_seven = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
$user_click_seven = Db::name('stat')
|
||||
->where('create_time', 'between', [$timeData['start_s'], $timeData['end_s']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven'],
|
||||
'goods_click' => $goods_click_seven,
|
||||
'user_click' => $user_click_seven
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['days']) && $post['days'] == 'ago_fifteen') {
|
||||
|
||||
$goods_click_fifteen = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
$user_click_fifteen = Db::name('stat')
|
||||
->where('create_time', 'between', [$timeData['start_f'], $timeData['end_f']])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen'],
|
||||
'goods_click' => $goods_click_fifteen,
|
||||
'user_click' => $user_click_fifteen
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (isset($post['goods']) && $post['goods'] == 'ago_seven') {
|
||||
$echarts_data = self::getVisitData($timeData['start_s'], 7);
|
||||
return [
|
||||
'echarts_goods_click' => $echarts_data['goods'],
|
||||
'echarts_user_click' => $echarts_data['user'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_seven'],
|
||||
'end' => $timeData['end_seven'],
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($post['goods']) && $post['goods'] == 'ago_fifteen') {
|
||||
$echarts_data = self::getVisitData($timeData['start_f'], 15);
|
||||
return [
|
||||
'echarts_goods_click' => $echarts_data['goods'],
|
||||
'echarts_user_click' => $echarts_data['user'],
|
||||
'days' => $echarts_data['days'],
|
||||
'start' => $timeData['start_fifteen'],
|
||||
'end' => $timeData['end_fifteen'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 访问统计数据
|
||||
* @param $end_stamp
|
||||
* @param $days
|
||||
* @author 段誉(2021/2/5 18:36)
|
||||
* @return array
|
||||
*/
|
||||
public static function getVisitData($start_stamp, $days)
|
||||
{
|
||||
$dates = [];
|
||||
for ($i = 1; $i <= $days; $i++) {
|
||||
|
||||
$time_start = strtotime("+ ".$i."day", $start_stamp);
|
||||
$time_end = strtotime("+ ".$i."day", $start_stamp) + 86399;
|
||||
$dates[] = date('m-d', $time_end);
|
||||
|
||||
//每天商品浏览量
|
||||
$echarts_goods_click[] = Db::name('goods_click')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
//每天用户浏览量
|
||||
$echarts_user_click[] = Db::name('stat')
|
||||
->where('create_time', 'between', [$time_start, $time_end])
|
||||
->count();
|
||||
}
|
||||
|
||||
return [
|
||||
'goods' => $echarts_goods_click,
|
||||
'user' => $echarts_user_click,
|
||||
'days' => $dates,
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Notes: 统计订单的数据
|
||||
* @param $end_stamp
|
||||
* @param $days
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public static function Numorder(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1678
application/admin/logic/SuborderLogic.php
Normal file
1678
application/admin/logic/SuborderLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
1677
application/admin/logic/SudorderLogic.php
Normal file
1677
application/admin/logic/SudorderLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
113
application/admin/logic/SupplierLogic.php
Normal file
113
application/admin/logic/SupplierLogic.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\admin\logic;
|
||||
use think\db;
|
||||
|
||||
class SupplierLogic{
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public static function lists($get){
|
||||
$where =[];
|
||||
if(isset($get['keyword']) && $get['keyword']){
|
||||
$where[] = ['name','like','%'.$get['keyword'].'%'];
|
||||
}
|
||||
$res = db::name('supplier')
|
||||
->where('del',0)
|
||||
->where($where);
|
||||
$count = $res->count();
|
||||
$lists = $res->page($get['page'],$get['limit'])->select();
|
||||
return[
|
||||
'count' =>$count,
|
||||
'lists' =>$lists,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public static function add($post){
|
||||
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'contact' => $post['contact'],
|
||||
'tel' => $post['tel'],
|
||||
'remark' => $post['remark'],
|
||||
'address' => $post['address'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
|
||||
db::name('supplier')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public static function edit($post){
|
||||
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'contact' => $post['contact'],
|
||||
'tel' => $post['tel'],
|
||||
'remark' => $post['remark'],
|
||||
'address' => $post['address'],
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
db::name('supplier')
|
||||
->where(['id'=>$post['id']])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
public static function info($id){
|
||||
$info = db::name('supplier')
|
||||
->where(['id'=>$id])
|
||||
->find();
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public static function del($id)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time()];
|
||||
return Db::name('supplier')->where(['del' => 0, 'id' =>$id])->update($data); //逻辑删除
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* note 获取所有供应商
|
||||
*/
|
||||
public static function getSupplierList(){
|
||||
$list = Db::name('supplier')
|
||||
->field('id,name')
|
||||
->where(['del' => 0])
|
||||
->select();
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
447
application/admin/logic/TeamActivityLogic.php
Normal file
447
application/admin/logic/TeamActivityLogic.php
Normal file
@@ -0,0 +1,447 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\Goods as GoodsModel;
|
||||
use app\common\model\Team;
|
||||
use app\common\model\TeamActivity as TeamActivityModel;
|
||||
use app\common\model\TeamFollow as TeamFollowModel;
|
||||
use app\common\model\TeamFound as TeamFoundModel;
|
||||
use app\common\model\TeamGoodsItem as TeamGoodsItemModel;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 拼团商品逻辑层
|
||||
* Class TeamActivityLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class TeamActivityLogic
|
||||
{
|
||||
protected static $error; //错误信息
|
||||
|
||||
/**
|
||||
* Notes: 错误错误信息
|
||||
* @author 张无忌(2021/1/12 16:01)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 列表数据
|
||||
* @author 张无忌(2021/1/13 15:03)
|
||||
* @param array $get
|
||||
* @return array
|
||||
*/
|
||||
public static function lists(array $get)
|
||||
{
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
|
||||
// 查询条件
|
||||
$where = [];
|
||||
if ( !empty($get['goods_name']) and $get['goods_name'] !== '') {
|
||||
$goodsModel = new GoodsModel();
|
||||
$ids = $goodsModel->field('id,name')->where([
|
||||
['name', 'like', '%' . $get['goods_name'] . '%']
|
||||
])->column('id');
|
||||
|
||||
$where[] = ['goods_id', 'in', $ids];
|
||||
}
|
||||
|
||||
if (isset($get['status']) and is_numeric($get['status'])) {
|
||||
$where[] = ['t.status', '=', (int)$get['status']];
|
||||
}
|
||||
|
||||
if ( !empty($get['start_time']) and $get['start_time'] !== '') {
|
||||
$where[] = ['start_time', '>=', strtotime($get['start_time'])];
|
||||
}
|
||||
|
||||
if ( !empty($get['end_time']) and $get['end_time'] !== '') {
|
||||
$where[] = ['end_time', '<=', strtotime($get['end_time'])];
|
||||
}
|
||||
|
||||
$count = $teamActivityModel->alias('t')->where(['del' => 0])->where($where)->count();
|
||||
$lists = $teamActivityModel->alias('t')
|
||||
->where(['t.del' => 0])
|
||||
->where($where)->field('t.*,g.name,g.image,g.max_price,g.min_price')
|
||||
->withAttr('team_count', function ($value, $data) {
|
||||
return TeamFoundModel::where(['team_id'=>$data['team_id']])->count();
|
||||
})
|
||||
->withAttr('follow_count', function ($value, $data) {
|
||||
return TeamFollowModel::where(['team_id'=>$data['team_id']])->count();
|
||||
})
|
||||
->join('Goods g', 't.goods_id=g.id')
|
||||
->order('team_id', 'desc')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select()->append(['team_count', 'follow_count']);
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['status'] = $item['end_time'] <= time() ? 0 : $item['status'];
|
||||
$item['start_time'] = date('Y-m-d H:i:s', $item['start_time']);
|
||||
$item['end_time'] = date('Y-m-d H:i:s', $item['end_time']);
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
public static function getDetail(int $id)
|
||||
{
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
$teamGoodsItemModel = new TeamGoodsItemModel();
|
||||
|
||||
$detail = $teamActivityModel->field('t.*,g.name,g.image')
|
||||
->alias('t')
|
||||
->join('Goods g', 't.goods_id=g.id')
|
||||
->where(['team_id' => $id])->find();
|
||||
|
||||
$goods_item = $teamGoodsItemModel->field('t.*,gi.id as spec_item_id, gi.spec_value_str, gi.price as spec_item_price')
|
||||
->alias('t')->where(['team_id' => $id])
|
||||
->rightJoin('goods_item gi', 'gi.id = t.item_id')
|
||||
->select();
|
||||
|
||||
$detail['item'] = $goods_item;
|
||||
$detail['image'] = UrlServer::getFileUrl($detail['image']);
|
||||
$detail['start_time'] = date('Y-m-d H:i:s', $detail['start_time']);
|
||||
$detail['end_time'] = date('Y-m-d H:i:s', $detail['end_time']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 新增拼团商品
|
||||
* @author 张无忌(2021/1/13 11:46)
|
||||
* @param array $post
|
||||
* @return bool
|
||||
*/
|
||||
public static function add(array $post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$goodsModel = new GoodsModel();
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
|
||||
// 查询商品信息
|
||||
$goods = $goodsModel->field('id,name,image')
|
||||
->where(['id' => (int)$post['goods_id']])->find();
|
||||
|
||||
if (!$goods) {
|
||||
static::$error = '选择的商品不存在';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 拼团商品已存在
|
||||
$teamGoods = $teamActivityModel->field('goods_id')
|
||||
->where(['goods_id'=>(int)$goods['id'], 'del'=>0])->find();
|
||||
|
||||
if ($teamGoods) {
|
||||
static::$error = '该商品已是拼团商品,无需重复添加';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该商品是否开启了秒杀活动
|
||||
$seckillGoods = Db::name('seckill_goods')->field(true)
|
||||
->where(['goods_id'=>(int)$goods['id'], 'del'=>0])->find();
|
||||
|
||||
if ($seckillGoods) {
|
||||
static::$error = '该商品开启了秒杀活动,请先移除';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查出最大和最少价格
|
||||
$team_price = [];
|
||||
foreach ($post['item'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
array_push($team_price, $item);
|
||||
}
|
||||
}
|
||||
$team_max_price = !empty($team_price) ? max($team_price) : 0;
|
||||
$team_min_price = !empty($team_price) ? min($team_price) : 0;
|
||||
|
||||
// 新增拼团商品信息
|
||||
$activity = $teamActivityModel->insertGetId([
|
||||
'goods_id' => $post['goods_id'],
|
||||
'sales_sum' => 0,
|
||||
'people_num' => $post['people_num'],
|
||||
'time_limit' => $post['time_limit'],
|
||||
'start_time' => strtotime($post['start_time']),
|
||||
'end_time' => strtotime($post['end_time']),
|
||||
'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
|
||||
'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
|
||||
'team_max_price' => $team_max_price,
|
||||
'team_min_price' => $team_min_price,
|
||||
'status' => $post['status'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
|
||||
// 新增拼团商品规格
|
||||
$lists = [];
|
||||
foreach ($post['item'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
$lists[] = [
|
||||
'team_id' => $activity,
|
||||
'goods_id' => $key,
|
||||
'item_id' => $K,
|
||||
'team_price' => $item
|
||||
];
|
||||
}
|
||||
}
|
||||
if ( !empty($lists)) {
|
||||
$teamGoodsItemModel = new TeamGoodsItemModel();
|
||||
$teamGoodsItemModel->saveAll($lists);
|
||||
}
|
||||
|
||||
// 回调更新商品表拼团字段
|
||||
if ($post['status'] == 1) {
|
||||
$goodsModel->where(['id' => (int)$post['goods_id']])->update([
|
||||
'is_team' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 编辑
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/13 17:41)
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$goodsModel = new GoodsModel();
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
|
||||
// 查询商品信息
|
||||
$goods = $goodsModel->field('id,name,image')
|
||||
->where(['id' => (int)$post['goods_id']])->find();
|
||||
|
||||
if ( !$goods) {
|
||||
static::$error = '选择的商品不存在';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 拼团商品已存在
|
||||
$teamGoods = $teamActivityModel->field('goods_id')
|
||||
->where(['goods_id'=>(int)$goods['id'], 'del'=>0])
|
||||
->where('team_id', '<>', (int)$post['team_id'])
|
||||
->find();
|
||||
|
||||
if ($teamGoods) {
|
||||
static::$error = '该商品已是拼团商品,换一个吧';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该商品是否开启了秒杀活动
|
||||
$seckillGoods = Db::name('seckill_goods')->field(true)
|
||||
->where(['goods_id'=>(int)$goods['id'], 'del'=>0])->find();
|
||||
|
||||
if ($seckillGoods) {
|
||||
static::$error = '该商品开启了秒杀活动,请先移除';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查出最大和最少价格
|
||||
$team_price = [];
|
||||
foreach ($post['item'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
array_push($team_price, $item);
|
||||
}
|
||||
}
|
||||
$team_max_price = !empty($team_price) ? max($team_price) : 0;
|
||||
$team_min_price = !empty($team_price) ? min($team_price) : 0;
|
||||
|
||||
// 新增拼团商品信息
|
||||
$teamActivityModel->where(['team_id' => (int)$post['team_id']])->update([
|
||||
'goods_id' => $post['goods_id'],
|
||||
'people_num' => $post['people_num'],
|
||||
'time_limit' => $post['time_limit'],
|
||||
'start_time' => strtotime($post['start_time']),
|
||||
'end_time' => strtotime($post['end_time']),
|
||||
'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
|
||||
'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
|
||||
'team_max_price' => $team_max_price,
|
||||
'team_min_price' => $team_min_price,
|
||||
'status' => $post['status']
|
||||
]);
|
||||
|
||||
// 删除旧的规格
|
||||
$teamGoodsItemModel = new TeamGoodsItemModel();
|
||||
$teamGoodsItemModel->where(['team_id' => (int)$post['team_id']])->delete();
|
||||
|
||||
// 新增拼团商品规格
|
||||
$lists = [];
|
||||
foreach ($post['item'] as $key => $value) {
|
||||
foreach ($value as $K => $item) {
|
||||
$lists[] = [
|
||||
'team_id' => (int)$post['team_id'],
|
||||
'goods_id' => $key,
|
||||
'item_id' => $K,
|
||||
'team_price' => $item
|
||||
];
|
||||
}
|
||||
}
|
||||
if ( !empty($lists)) {
|
||||
$teamGoodsItemModel->saveAll($lists);
|
||||
}
|
||||
|
||||
// 回调更新商品表拼团字段
|
||||
if ($post['status'] == 1) {
|
||||
$goodsModel->where(['id' => (int)$post['goods_id']])->update([
|
||||
'is_team' => 1,
|
||||
'update_time' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 软删除
|
||||
* @param int $id
|
||||
* @author 张无忌(2021/1/13 18:02)
|
||||
* @return bool
|
||||
*/
|
||||
public static function softDelete(int $id)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
|
||||
$team = $teamActivityModel->field(true)->where(['team_id' => (int)$id])->find();
|
||||
if (!$team) {
|
||||
static::$error = '该拼团活动不存在';
|
||||
return false;
|
||||
}
|
||||
|
||||
$teamActivityModel->where(['team_id' => (int)$id])->update([
|
||||
'del' => 1
|
||||
]);
|
||||
|
||||
$goodsModel = new GoodsModel();
|
||||
$goodsModel->where(['id' => (int)$team['goods_id']])->update([
|
||||
'is_team' => 0,
|
||||
'update_time' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 切换状态
|
||||
* @param $post
|
||||
* @author 张无忌(2021/1/13 17:53)
|
||||
* @return bool
|
||||
*/
|
||||
public static function switchStatus($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
$teamActivityModel->where(['team_id' => (int)$post['id']])->update([
|
||||
$post['field'] => $post['status']
|
||||
]);
|
||||
|
||||
$activity = $teamActivityModel->field('goods_id')->where(['team_id' => (int)$post['id']])->find();
|
||||
|
||||
$goodsModel = new GoodsModel();
|
||||
$goodsModel->where(['id' => (int)$activity['goods_id']])->update([
|
||||
'is_team' => $post['status'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
static::$error = $e->getMessage();
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 拼团列表
|
||||
* @author 张无忌(2021/1/14 14:25)
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function teamOrder($get)
|
||||
{
|
||||
$where = [
|
||||
['f.team_id', '=', (int)$get['team_id']]
|
||||
];
|
||||
|
||||
if ( !empty($get['goods_name']) and $get['goods_name'] !== '') {
|
||||
$goodsModel = new GoodsModel();
|
||||
$goods_ids = $goodsModel->where('name', 'like', '%' . $get['goods_name'] . '%')->column('id');
|
||||
if ( !empty($goods_ids)) {
|
||||
$teamActivityModel = new TeamActivityModel();
|
||||
$team_ids = $teamActivityModel->whereIn('goods_id', $goods_ids)->column('team_id');
|
||||
if ( !empty($team_ids)) {
|
||||
$where[] = ['f.team_id', 'in', $team_ids];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty($get['nickname']) and $get['nickname'] !== '') {
|
||||
$where[] = ['nickname', 'like', '%' . $get['nickname'] . '%'];
|
||||
}
|
||||
|
||||
if ( !empty($get['found_time']) and $get['found_time'] !== '') {
|
||||
$where[] = ['found_time', '>=', strtotime($get['found_time'])];
|
||||
}
|
||||
|
||||
if ( !empty($get['found_end_time']) and $get['found_end_time'] !== '') {
|
||||
$where[] = ['found_end_time', '<=', strtotime($get['found_end_time'])];
|
||||
}
|
||||
|
||||
if (isset($get['status']) and is_numeric($get['status'])) {
|
||||
$where[] = ['f.status', '=', (int)$get['status']];
|
||||
}
|
||||
|
||||
$teamFoundModel = new TeamFoundModel();
|
||||
$count = $teamFoundModel->where($where)->alias('f')->count();
|
||||
|
||||
$lists = $teamFoundModel->field('f.*,t.goods_id,g.name,g.image')
|
||||
->alias('f')->where($where)
|
||||
->with('user.level')
|
||||
->join('team_activity t', 't.team_id = f.team_id')
|
||||
->join('goods g', 't.goods_id = g.id')
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('f.id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['found_time'] = date('Y-m-d H:i:s', $item['found_time']);
|
||||
$item['found_end_time'] = date('Y-m-d H:i:s', $item['found_end_time']);
|
||||
$item['status'] = Team::getStatusDesc($item['status']);
|
||||
$item['user_level'] = $item['user']['level']['name'] ?? '无等级';
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
}
|
||||
255
application/admin/logic/TeamFoundLogic.php
Normal file
255
application/admin/logic/TeamFoundLogic.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\admin\model\User;
|
||||
use app\common\logic\OrderRefundLogic;
|
||||
use app\common\model\Goods as GoodsModel;
|
||||
use app\common\model\Order;
|
||||
use app\common\model\OrderLog;
|
||||
use app\common\model\Pay;
|
||||
use app\common\model\Team;
|
||||
use app\common\model\TeamActivity as TeamActivityModel;
|
||||
use app\common\model\TeamFollow as TeamFollowModel;
|
||||
use app\common\model\TeamFound as TeamFoundModel;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class TeamFoundLogic
|
||||
{
|
||||
protected static $error; //错误信息
|
||||
|
||||
/**
|
||||
* Notes: 错误错误信息
|
||||
* @author 张无忌(2021/1/12 16:01)
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getError()
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 拼团列表
|
||||
* @param $get
|
||||
* @author 张无忌(2021/1/15 18:24)
|
||||
* @return array
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
// 查询条件
|
||||
$where = [];
|
||||
|
||||
if (isset($get['goods_name']) and $get['goods_name'] !== '') {
|
||||
$goodsModel = new GoodsModel();
|
||||
$ids = $goodsModel->field('id,name')->where([
|
||||
['name', 'like', '%' . $get['goods_name'] . '%']
|
||||
])->column('id');
|
||||
|
||||
$team_ids = TeamActivityModel::where('goods_id', 'in', $ids)->column('team_id');
|
||||
|
||||
$where[] = ['f.team_id', 'in', $team_ids];
|
||||
}
|
||||
|
||||
if (isset($get['status']) and is_numeric($get['status'])) {
|
||||
$where[] = ['f.status', '=', (int)$get['status']];
|
||||
}
|
||||
|
||||
if (isset($get['found_time']) and $get['found_time'] !== '') {
|
||||
$where[] = ['found_time', '>=', strtotime($get['found_time'])];
|
||||
}
|
||||
|
||||
if (isset($get['found_end_time']) and $get['found_end_time'] !== '') {
|
||||
$where[] = ['found_end_time', '<=', strtotime($get['found_end_time'])];
|
||||
}
|
||||
|
||||
if (isset($get['type']) and $get['type'] !== '') {
|
||||
if (isset($get['keyword']) and $get['keyword'] !== '') {
|
||||
switch ($get['type']) {
|
||||
case 'sn':
|
||||
$uid = User::where('sn', '=', $get['keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
case 'nickname':
|
||||
$uid = User::where('nickname', 'like', '%' . $get['keyword'] . '%')->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
case 'mobile':
|
||||
$uid = User::where('mobile', '=', $get['keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $uid];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//执行查询
|
||||
$teamFollowModel = new TeamFoundModel();
|
||||
$count = $teamFollowModel->where($where)->alias('f')->count();
|
||||
$lists = $teamFollowModel->alias('f')
|
||||
->field('f.*,g.name,g.image')
|
||||
->where($where)
|
||||
->with('user.level')
|
||||
->order('id', 'desc')
|
||||
->join('team_activity a', 'a.team_id = f.team_id')
|
||||
->join('goods g', 'g.id = a.goods_id')
|
||||
->append(['user.base_avatar'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['found_time'] = date('Y-m-d H:i:s', $item['found_time']);
|
||||
$item['found_end_time'] = date('Y-m-d H:i:s', $item['found_end_time']);
|
||||
$item['status_text'] = Team::getStatusDesc($item['status']);
|
||||
$item['user_level'] = $item['user']['level']['name'] ?? '无等级';
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 拼团详细信息
|
||||
* @param $fount_id (团ID)
|
||||
* @author 张无忌(2021/1/18 15:09)
|
||||
* @return array
|
||||
*/
|
||||
public static function getDetail($fount_id)
|
||||
{
|
||||
$teamFoundModel = new TeamFoundModel();
|
||||
$detail = $teamFoundModel->field(true)
|
||||
->with('user.level')
|
||||
->where(['id'=>(int)$fount_id])
|
||||
->find()->toArray();
|
||||
|
||||
$detail['found_time'] = date('Y-m-d H:i:s', $detail['found_time']);
|
||||
$detail['found_end_time'] = date('Y-m-d H:i:s', $detail['found_end_time']);
|
||||
$detail['status'] = Team::getStatusDesc($detail['status']);
|
||||
$detail['user_level'] = $detail['user']['level']['name'] ?? '无等级';
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 根据团ID, 获取团下面的订单
|
||||
* @param $get
|
||||
* @author 张无忌(2021/1/18 15:10)
|
||||
* @return array
|
||||
*/
|
||||
public static function teamOrderListById($get)
|
||||
{
|
||||
$where = [
|
||||
['found_id', '=', (int)$get['found_id']]
|
||||
];
|
||||
|
||||
$teamFollowModel = new TeamFollowModel();
|
||||
$count = $teamFollowModel->where($where)->count();
|
||||
$lists = $teamFollowModel->alias('f')
|
||||
->field('f.*,o.order_sn,o.order_status,o.create_time,o.total_amount,t.goods_id,g.name,g.image')
|
||||
->where($where)
|
||||
->with('user.level')
|
||||
->join('order o', 'o.id = f.order_id')
|
||||
->join('team_activity t', 't.team_id = f.team_id')
|
||||
->join('goods g', 't.goods_id = g.id')
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['relation'] = $item['type'] ? '团长' : '团员';
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['order_status'] = Order::getOrderStatus($item['order_status']);
|
||||
$item['user_level'] = $item['user']['level']['name'] ?? '无等级';
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取团退款详细信息
|
||||
* @author 张无忌(2021/1/18 18:43)
|
||||
* @param $get
|
||||
* @return array
|
||||
*/
|
||||
public static function getRefundDetail($get)
|
||||
{
|
||||
$where = [
|
||||
['found_id', '=', (int)$get['found_id']]
|
||||
];
|
||||
|
||||
$teamFollowModel = new TeamFollowModel();
|
||||
$count = $teamFollowModel->where($where)->count();
|
||||
$lists = $teamFollowModel->field(true)
|
||||
->with('user.level')
|
||||
->withAttr('order', function ($value, $data) {
|
||||
$orderModel = new Order();
|
||||
return $orderModel->field('id,order_sn,order_source,order_status,
|
||||
pay_status,pay_way,order_amount')
|
||||
->where('user_id', $data['follow_user_id'])
|
||||
->where('id', $data['order_id'])
|
||||
->where('team_found_id', (int)$data['found_id'])
|
||||
->append(['pay_way_text', 'pay_status_text', 'order_status_text', 'order_source_text'])
|
||||
->find();
|
||||
})
|
||||
->where('found_id', '=', $get['found_id'])
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['order'])
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($lists as &$item){
|
||||
$item['user_level'] = $item['user']['level']['name'] ?? '无等级';
|
||||
}
|
||||
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 取消订单并退款
|
||||
* @param $post
|
||||
* @param $admin_id
|
||||
* @author 段誉(2021/1/29 18:28)
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function handleRefund($post, $admin_id)
|
||||
{
|
||||
Db::startTrans();
|
||||
try{
|
||||
$orderModel = new Order();
|
||||
$order = $orderModel->field(true)
|
||||
->where('id', '=', (int)$post['order_id'])
|
||||
->where(['order_status' => 1, 'pay_status' => 1])
|
||||
->find();
|
||||
|
||||
if (!$order){
|
||||
throw new Exception('订单信息错误');
|
||||
}
|
||||
|
||||
//取消订单
|
||||
OrderRefundLogic::cancelOrder($order['id'], OrderLog::TYPE_SHOP, $admin_id);
|
||||
//退款
|
||||
if ($order['pay_status'] == Pay::ISPAID){
|
||||
//更新订单状态
|
||||
OrderRefundLogic::cancelOrderRefundUpdate($order);
|
||||
//订单退款
|
||||
OrderRefundLogic::refund($order, $order['order_amount'], $order['order_amount']);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
||||
Db::rollback();
|
||||
static::$error = $e->getMessage();
|
||||
OrderRefundLogic::addErrorRefund($order, $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
100
application/admin/logic/TrainingLogic.php
Normal file
100
application/admin/logic/TrainingLogic.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
|
||||
class TrainingLogic{
|
||||
|
||||
public static function lists($get){
|
||||
$count = Db::name('video_type')
|
||||
->count();
|
||||
$lists = Db::name('video_type')
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
}
|
||||
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
}
|
||||
|
||||
public static function setlistadd($post){
|
||||
$data=[
|
||||
'title'=>$post['name'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
return Db::name('video_type')->data($data)->insert();
|
||||
}
|
||||
|
||||
public static function seteidt($post){
|
||||
return Db::name('video_type')->where('id',$post['id'])->update(['title'=>$post['title'],'create_time'=>time()]);
|
||||
}
|
||||
|
||||
public static function setlistinfo($id){
|
||||
return Db::name('video_type')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function setlist(){
|
||||
return Db::name('video_type')->select();
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$post['create_time']=time();
|
||||
return Db::name('video')->data($post)->insert();
|
||||
}
|
||||
|
||||
public static function video_lists($get){
|
||||
$where = [];
|
||||
// 查询
|
||||
if(isset($get['name']) && $get['name'] != ''){
|
||||
$where[] = ['name', 'like', '%' . $get['name'] . '%'];
|
||||
}
|
||||
//视频类型
|
||||
if(isset($get['type_id']) && $get['type_id']){
|
||||
$where[] = ['type_id','=',$get['type_id']];
|
||||
}
|
||||
//上传时间
|
||||
if(isset($get['start_times']) && $get['start_times']!=''){
|
||||
$where[] = ['login_time','>=',strtotime($get['start_times'])];
|
||||
}
|
||||
if(isset($get['end_times']) && $get['end_times']!=''){
|
||||
$where[] = ['login_time','<=',strtotime($get['end_times'])];
|
||||
}
|
||||
|
||||
$count = Db::name('video')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = Db::name('video')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
foreach ($lists as &$item){
|
||||
$item['create_time']=date('Y-m-d H:i:s',$item['create_time']);
|
||||
$item['image']= UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count'=>$count , 'lists'=>$lists];
|
||||
|
||||
}
|
||||
|
||||
public static function videoinfo($id){
|
||||
$data=Db::name('video')->where('id',$id)->find();
|
||||
$data['image']= UrlServer::getFileUrl($data['image']);
|
||||
return $data;
|
||||
// return Db::name('video')->where('id',$id)->find();
|
||||
}
|
||||
|
||||
public static function edits($post){
|
||||
$post['create_time']=time();
|
||||
return Db::name('video')->where('id',$post['id'])->update($post);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
101
application/admin/logic/UserGroupLogic.php
Normal file
101
application/admin/logic/UserGroupLogic.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\admin\logic;
|
||||
use think\Db;
|
||||
|
||||
class UserGroupLogic
|
||||
{
|
||||
|
||||
/*
|
||||
* 分组列表
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['del','=', '0'];
|
||||
|
||||
//查询条数
|
||||
$user_group_count = Db::name('user_group')
|
||||
->where($where)
|
||||
->count();
|
||||
//数据查询
|
||||
$user_group_list = Db::name('user_group')
|
||||
->where($where)
|
||||
->field(['id','name', 'remark'])
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
|
||||
//返回数据及页面条数
|
||||
return ['list'=>$user_group_list,'count' =>$user_group_count];
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*/
|
||||
public static function info($id)
|
||||
{
|
||||
return Db::name('user_group')->where(['id' => $id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public static function addUserGroup($post)
|
||||
{
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'remark' => $post['remark'],
|
||||
'create_time' => $time
|
||||
];
|
||||
return Db::name('user_group')->insert($data); //插入数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public static function editUserGroup($post)
|
||||
{
|
||||
$time = time(); //当前时间截
|
||||
$data = [
|
||||
'name' => $post['name'],
|
||||
'remark' => $post['remark'],
|
||||
'update_time' => $time
|
||||
];
|
||||
return Db::name('user_group')->where(['del' => 0, 'id' => $post['id']])->update($data); //逻辑删除
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public static function delUserGroup($id)
|
||||
{
|
||||
$data = [
|
||||
'del' => 1,
|
||||
'update_time' => time(),
|
||||
];
|
||||
return Db::name('user_group')->where(['del' => 0, 'id' => $id])->update($data); //逻辑删除
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
88
application/admin/logic/UserLevelLogic.php
Normal file
88
application/admin/logic/UserLevelLogic.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\logic\UserLevelLogic as CommonUserLevelLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class UserLevelLogic{
|
||||
|
||||
public static function lists($get){
|
||||
|
||||
$count = Db::name('user_level')->where(['del'=>0])->count();
|
||||
$list = Db::name('user_level')
|
||||
->where(['del'=>0])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
$item['privilege_list'] = '';
|
||||
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
$item['background_image'] = UrlServer::getFileUrl($item['background_image']);
|
||||
if($item['privilege']){
|
||||
$privileges = explode(',',$item['privilege']);
|
||||
$privilege_list = Db::name('user_privilege')
|
||||
->where(['del'=>0,'id'=>$privileges])
|
||||
->column('name');
|
||||
$item['privilege_list'] = $privilege_list ? implode('、',$privilege_list) : '';
|
||||
}
|
||||
|
||||
}
|
||||
return ['count' => $count, 'list' => $list];
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$now = time();
|
||||
$post['create_time'] = $now;
|
||||
$post['update_time'] = $now;
|
||||
$id = Db::name('user_level')->insertGetId($post);
|
||||
if($id){
|
||||
CommonUserLevelLogic::updateAllUserLevel($id);
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function edit($post){
|
||||
$now = time();
|
||||
$post['update_time'] = $now;
|
||||
Db::name('user_level')->where(['id'=>$post['id']])->update($post);
|
||||
CommonUserLevelLogic::updateAllUserLevel($post['id']);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function del($id){
|
||||
$now = time();
|
||||
$post['update_time'] = $now;
|
||||
$post['del'] = 1;
|
||||
return Db::name('user_level')->where(['id'=>$id])->update($post);
|
||||
}
|
||||
|
||||
public static function getUserLevel($id){
|
||||
$detail = Db::name('user_level')->where(['id'=>$id,'del'=>0])->find();
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
$detail['abs_background_image'] = UrlServer::getFileUrl($detail['background_image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
public static function getPrivilegeList(){
|
||||
return Db::name('user_privilege')->where(['del'=>0])->field('id,name')->select();
|
||||
}
|
||||
|
||||
}
|
||||
1294
application/admin/logic/UserLogic.php
Normal file
1294
application/admin/logic/UserLogic.php
Normal file
File diff suppressed because it is too large
Load Diff
68
application/admin/logic/UserPrivilegeLogic.php
Normal file
68
application/admin/logic/UserPrivilegeLogic.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\admin\logic;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
|
||||
class UserPrivilegeLogic{
|
||||
|
||||
public static function lists($get){
|
||||
$count = Db::name('user_privilege')
|
||||
->where(['del'=>0])
|
||||
->count();
|
||||
|
||||
$list = Db::name('user_privilege')
|
||||
->where(['del'=>0])
|
||||
->page($get['page'], $get['limit'])
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item) {
|
||||
$item['image'] = UrlServer::getFileUrl($item['image']);
|
||||
}
|
||||
|
||||
return ['count' => $count, 'list' => $list];
|
||||
|
||||
}
|
||||
|
||||
public static function add($post){
|
||||
$post['create_time'] = time();
|
||||
$post['del'] = 0;
|
||||
return Db::name('user_privilege')->insert($post);
|
||||
}
|
||||
|
||||
public static function edit($post){
|
||||
$post['update_time'] = time();
|
||||
return Db::name('user_privilege')->where(['id'=>$post['id']])->update($post);
|
||||
}
|
||||
|
||||
public static function del($id){
|
||||
$update_date = [
|
||||
'update_time' => time(),
|
||||
'del' => 1,
|
||||
];
|
||||
return Db::name('user_privilege')->where(['id'=>$id,'del'=>0])->update($update_date);
|
||||
}
|
||||
|
||||
public static function getPrivilege($id){
|
||||
$detail = Db::name('user_privilege')->where(['id'=>$id,'del'=>0])->find();
|
||||
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
}
|
||||
269
application/admin/logic/WechatCorporatePaymentLogic.php
Normal file
269
application/admin/logic/WechatCorporatePaymentLogic.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
namespace app\admin\logic;
|
||||
/**
|
||||
* 功能: 微信企业付款
|
||||
* 用途:企业向微信用户个人付款
|
||||
* 证书:需要
|
||||
* 失败后一定要用【原来的商户订单号】去重试,不然有可能存在重复支付的风险!!!
|
||||
* 商户订单号: 必须唯一且需要为33位以下的数字或字母
|
||||
*/
|
||||
|
||||
use EasyWeChat\Factory;
|
||||
use app\common\model\Pay;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use think\Db;
|
||||
use app\common\model\User;
|
||||
|
||||
class WechatCorporatePaymentLogic
|
||||
{
|
||||
/**
|
||||
* 获取app
|
||||
*/
|
||||
public static function getApp($client)
|
||||
{
|
||||
$config = WeChatServer::getPayConfigBySource($client)['config'];
|
||||
$app = Factory::payment($config);
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业付款
|
||||
*/
|
||||
public static function pay($withdraw)
|
||||
{
|
||||
// 微信零钱最小提现金额 1元
|
||||
if($withdraw['left_money'] < 1) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '扣除手续费后提现金额不能小于1元'
|
||||
];
|
||||
}
|
||||
// 每天最多可向同一用户付款10次
|
||||
$count = Db::name('withdraw_apply')
|
||||
->whereTime('update_time', 'd') // 今天
|
||||
->where('user_id', $withdraw['user_id'])
|
||||
->where('type', 2) // 微信零钱
|
||||
->where('status', '>=', 2) // 提现中、提现成功、提现失败
|
||||
->count();
|
||||
if($count > 10) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '同一个用户一天最多可付款10次'
|
||||
];
|
||||
}
|
||||
// 一天一个用户累计提现金额不能超过5000元
|
||||
$sum = Db::name('withdraw_apply')
|
||||
->whereTime('update_time', 'd') // 今天
|
||||
->where('user_id', $withdraw['user_id'])
|
||||
->where('type', 2) // 微信零钱
|
||||
->where('status', 'in', [2, 3]) // 提现中、提现成功
|
||||
->sum('left_money');
|
||||
$sum = $sum + $withdraw['left_money'];
|
||||
if($sum > 5000) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '一天一个用户累计提现金额(不算手续费)不能超过5000元'
|
||||
];
|
||||
}
|
||||
|
||||
// 用户授权信息(同一个用户可能有多条,取client最小的一条)
|
||||
$userAuth = Db::name('user_auth')->where('user_id', $withdraw['user_id'])->order('client', 'asc')->find();
|
||||
if(!$userAuth) {
|
||||
// 无授权记录
|
||||
return [
|
||||
'code'=> 0,
|
||||
'msg' => '查询不到该用户的openid'
|
||||
];
|
||||
}
|
||||
// 获取app
|
||||
$app = self::getApp($userAuth['client']);
|
||||
// 商户唯一订单号
|
||||
$partner_trade_no = $withdraw['sn'];
|
||||
// 发起企业付款
|
||||
$result = $app->transfer->toBalance([
|
||||
// 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
||||
'partner_trade_no' => $partner_trade_no,
|
||||
'openid' => $userAuth['openid'],
|
||||
// NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
||||
'check_name' => 'NO_CHECK',
|
||||
// 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
|
||||
're_user_name' => '',
|
||||
// 企业付款金额,单位为分 100分=1元
|
||||
'amount' => 100 * $withdraw['left_money'],
|
||||
// 企业付款操作说明信息。必填
|
||||
'desc' => '佣金提现'
|
||||
]);
|
||||
// 马上将提现申请单状态修改为提现中,并记录微信返回信息,避免同一提现单多次点击发起多次企业付款
|
||||
$fiterField = ['appid','mch_appid', 'mchid', 'mch_id', 'openid']; // 过滤敏感字段
|
||||
$filterResult = array_filter($result, function($key) use ($fiterField) {
|
||||
return !in_array($key, $fiterField);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'status' => 2, // 提现中
|
||||
'update_time' => time(),
|
||||
'pay_desc' => json_encode($filterResult)
|
||||
]);
|
||||
// 通信标识 return_code
|
||||
if($result['return_code'] == 'SUCCESS') {
|
||||
// 业务结果 result_code
|
||||
if($result['result_code'] == 'SUCCESS') {
|
||||
// 企业付款成功, 更新提现申请单状态为提现成功并记录支付单号及支付时间
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'status' => 3, // 提现成功
|
||||
'payment_no' => $result['payment_no'],
|
||||
'payment_time' => strtotime($result['payment_time']),
|
||||
'update_time' => time()
|
||||
]);
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '成功提现至微信零钱'
|
||||
];
|
||||
}else{
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => $result['err_code_des']
|
||||
];
|
||||
}
|
||||
}else{
|
||||
// 提现至零钱失败,更新提现申请单为提现失败,并回退佣金
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'status' => 4, // 提现失败
|
||||
'update_time' => time()
|
||||
]);
|
||||
//回退佣金
|
||||
$user = User::get($withdraw['user_id']);
|
||||
$user->earnings = ['inc', $withdraw['money']];
|
||||
$user->save();
|
||||
|
||||
//增加佣金变动记录
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw['user_id'],
|
||||
$withdraw['money'],
|
||||
1,
|
||||
AccountLog::withdraw_back_earnings,
|
||||
'',
|
||||
$withdraw['id'],
|
||||
$withdraw['sn']
|
||||
);
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => $result['return_msg']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询企业付款
|
||||
*/
|
||||
public static function search($withdraw)
|
||||
{
|
||||
$userAuth = Db::name('user_auth')->where('user_id', $withdraw['user_id'])->order('client', 'asc')->find();
|
||||
if(!$userAuth) {
|
||||
// 无授权记录
|
||||
return [
|
||||
'code'=> 0,
|
||||
'msg' => '查询不到该用户的openid'
|
||||
];
|
||||
}
|
||||
$app = self::getApp($userAuth['client']);
|
||||
$partnerTradeNo = $withdraw['sn'];
|
||||
$result = $app->transfer->queryBalanceOrder($partnerTradeNo);
|
||||
$fiterField = ['appid','mch_appid', 'mchid', 'mch_id', 'openid']; // 过滤敏感字段
|
||||
$filterResult = array_filter($result, function($key) use ($fiterField) {
|
||||
return !in_array($key, $fiterField);
|
||||
}, ARRAY_FILTER_USE_KEY );
|
||||
// 记录查询结果
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'update_time' => time(),
|
||||
'pay_search_desc' => json_encode($filterResult)
|
||||
]);
|
||||
if($result['return_code'] == 'SUCCESS') { // 通信标识
|
||||
if($result['result_code'] == 'SUCCESS') { // 另一个标识
|
||||
if($result['status'] == 'SUCCESS') { // 业务结果
|
||||
// 转账成功,标记提现申请单为提现成功,记录支付信息
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'status' => 3, // 提现成功
|
||||
'payment_no' => $result['detail_id'],
|
||||
'payment_time' => strtotime($result['payment_time']),
|
||||
'update_time' => time()
|
||||
]);
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '已提现成功'
|
||||
];
|
||||
}else if($result['status'] == 'FAILED'){
|
||||
// 转账失败
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $withdraw['id'])
|
||||
->update([
|
||||
'status' => 4, // 提现失败
|
||||
'update_time' => time()
|
||||
]);
|
||||
//回退佣金
|
||||
$user = User::get($withdraw['user_id']);
|
||||
$user->earnings = ['inc', $withdraw['money']];
|
||||
$user->save();
|
||||
|
||||
//增加佣金变动记录
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw['user_id'],
|
||||
$withdraw['money'],
|
||||
1,
|
||||
AccountLog::withdraw_back_earnings,
|
||||
'',
|
||||
$withdraw['id'],
|
||||
$withdraw['sn']
|
||||
);
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '提现至微信零钱失败'
|
||||
];
|
||||
}else{
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => $result['reason']
|
||||
];
|
||||
}
|
||||
}else{
|
||||
// 查看这个提现单今天是否有重新发起过付款,如果没有则尝试使用【相同的商户订单号】再次发起付款
|
||||
// $count = Db::name('withdraw_apply')
|
||||
// ->whereTime('repay_time', 'd') // 今天
|
||||
// ->where('id', $withdraw['id']) // 提现申请单号
|
||||
// ->count();
|
||||
// if(!$count) {
|
||||
// // 记录重新发起支付的时间
|
||||
// Db::name('withdraw_apply')->where('id', $withdraw['id'])->update([
|
||||
// 'repay_time' => time(),
|
||||
// 'update_time' => time()
|
||||
// ]);
|
||||
// return self::pay($withdraw);
|
||||
// }else{
|
||||
// return [
|
||||
// 'code' => 0,
|
||||
// 'msg' => $result['err_code_des']
|
||||
// ];
|
||||
// }
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => $result['err_code_des']
|
||||
];
|
||||
}
|
||||
}else{
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => $result['return_msg']
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
105
application/admin/logic/WechatReplyLogic.php
Normal file
105
application/admin/logic/WechatReplyLogic.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?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\admin\logic;
|
||||
use app\common\model\WeChat;
|
||||
use think\Db;
|
||||
|
||||
class WechatReplyLogic{
|
||||
public static function lists($get){
|
||||
$where[] = ['del','=',0];
|
||||
if(isset($get['type'])){
|
||||
$where[] = ['reply_type','=',$get['type']];
|
||||
}
|
||||
$count = Db::name('wechat_reply')
|
||||
->where($where)
|
||||
->count();
|
||||
$list = Db::name('wechat_reply')
|
||||
->where($where)
|
||||
->page($get['page'],$get['limit'])
|
||||
->select();
|
||||
foreach ($list as $key => $reply) {
|
||||
$reply['content_type'] && $list[$key]['content_type'] = '文本';
|
||||
switch ($reply['matching_type']){
|
||||
case 1:
|
||||
$list[$key]['matching_type'] = '全匹配';
|
||||
break;
|
||||
case 2:
|
||||
$list[$key]['matching_type'] = '模糊匹配';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ['count'=>$count,'list'=>$list];
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* note 添加微信回复
|
||||
* create_time 2020/12/5 15:24
|
||||
*/
|
||||
public static function add($post){
|
||||
$post['create_time'] = time();
|
||||
$post['del'] = 0;
|
||||
if($post['reply_type'] !== WeChat::msg_type_text && $post['status']){
|
||||
Db::name('wechat_reply')->where(['reply_type'=>$post['reply_type']])->update(['update_time'=>time(),'status'=>0]);
|
||||
}
|
||||
return Db::name('wechat_reply')->insert($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 编辑微信回复
|
||||
* create_time 2020/12/5 15:24
|
||||
*/
|
||||
public static function edit($post){
|
||||
$post['update_time'] = time();
|
||||
if($post['reply_type'] !== WeChat::msg_type_text && $post['status']){
|
||||
Db::name('wechat_reply')->where(['reply_type'=>$post['reply_type']])->update(['update_time'=>time(),'status'=>0]);
|
||||
}
|
||||
return Db::name('wechat_reply')->where(['id'=>$post['id']])->update($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* note 删除微信回复
|
||||
* create_time 2020/12/5 15:25
|
||||
*/
|
||||
public static function del($id){
|
||||
|
||||
return Db::name('wechat_reply')->where(['id'=>$id])->update(['update_time'=>time(),'del'=>1]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* note 获取微信回复
|
||||
* create_time 2020/12/5 15:25
|
||||
*/
|
||||
public static function getReply($id){
|
||||
return Db::name('wechat_reply')->where(['id'=>$id])->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* note
|
||||
* create_time 2020/12/5 18:56
|
||||
*/
|
||||
public static function changeFields($id,$field,$field_value,$reply_type){
|
||||
if( 'status' === $field && $field_value && $reply_type !== WeChat::msg_type_text){
|
||||
Db::name('wechat_reply')->where(['reply_type'=>$reply_type])->update(['update_time'=>time(),'status'=>0]);
|
||||
}
|
||||
return Db::name('wechat_reply')->where(['id'=>$id])->update(['update_time'=>time(),$field=>$field_value]);
|
||||
}
|
||||
}
|
||||
341
application/admin/logic/WithdrawLogic.php
Normal file
341
application/admin/logic/WithdrawLogic.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?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\admin\logic;
|
||||
|
||||
use app\admin\model\WithdrawApply;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\admin\logic\WechatCorporatePaymentLogic;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\model\AccountLog;
|
||||
use app\common\model\User;
|
||||
use app\common\model\Withdraw;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\helper\Time;
|
||||
|
||||
class WithdrawLogic
|
||||
{
|
||||
/**
|
||||
* 佣金提现列表
|
||||
* @param $get
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function lists($get)
|
||||
{
|
||||
$where = [];
|
||||
// 会员信息
|
||||
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
||||
$keyword = $get['keyword'];
|
||||
if ($get['search_key'] == 'user_sn') {
|
||||
$where[] = ['u.sn', '=', $keyword];
|
||||
} elseif ($get['search_key'] == 'nickname'){
|
||||
$where[] = ['u.nickname', 'like', '%' . $keyword . '%'];
|
||||
}
|
||||
}
|
||||
|
||||
//提现单号
|
||||
if (isset($get['withdraw_sn']) && $get['withdraw_sn'] != '') {
|
||||
$where[] = ['w.sn', '=', $get['withdraw_sn']];
|
||||
}
|
||||
|
||||
//提现方式
|
||||
if (isset($get['type']) && $get['type'] != '') {
|
||||
$where[] = ['type', '=', $get['type']];
|
||||
}
|
||||
|
||||
//提现状态
|
||||
if (isset($get['status']) && $get['status'] != '') {
|
||||
$where[] = ['status', '=', $get['status']];
|
||||
}
|
||||
|
||||
// 提现时间
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where[] = ['w.create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
}else{
|
||||
// $where[] = ['w.create_time', 'between', Time::today()];
|
||||
}
|
||||
|
||||
$lists = Db::name('withdraw_apply w')
|
||||
->field('w.*, u.nickname,u.avatar, u.sn as user_sn, u.mobile, ul.name as user_level_name')
|
||||
->leftJoin('user u', 'u.id = w.user_id')
|
||||
->leftJoin('user_level ul', 'ul.id = u.level')
|
||||
->where($where)
|
||||
->page($get['page'], $get['limit'])
|
||||
->order('w.id desc')
|
||||
->select();
|
||||
|
||||
$count = Db::name('withdraw_apply w')
|
||||
->field('w.*, u.nickname,u.avatar, u.sn as user_sn, u.mobile, ul.name as user_level_name')
|
||||
->leftJoin('user u', 'u.id = w.user_id')
|
||||
->leftJoin('user_level ul', 'ul.id = u.level')
|
||||
->where($where)
|
||||
->order('w.id desc')
|
||||
->count();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['type_text'] = Withdraw::getTypeDesc($item['type']);
|
||||
$item['status_text'] = Withdraw::getStatusDesc($item['status']);
|
||||
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
||||
$item['user_level_name'] = $item['user_level_name'] ? $item['user_level_name'] : '无等级';
|
||||
$item['create_time'] = date('Y-m-d h:i:s', $item['create_time']);
|
||||
$item['payment_time'] = date('Y-m-d h:i:s', $item['payment_time']);
|
||||
}
|
||||
|
||||
return ['count' => $count, 'lists' => $lists];
|
||||
}
|
||||
|
||||
|
||||
//审核通过
|
||||
public static function confirm($post)
|
||||
{
|
||||
$id = $post['id'];
|
||||
$withdraw = Db::name('withdraw_apply')
|
||||
->where('id', $id)
|
||||
->find();
|
||||
|
||||
// 判断提现单是否为待提现状态 1
|
||||
if($withdraw['status'] != 1) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '不是待提现申请单'
|
||||
];
|
||||
}
|
||||
|
||||
//提现到钱包余额
|
||||
if ($withdraw['type'] == Withdraw::TYPE_BALANCE){
|
||||
$user = User::get($withdraw['user_id']);
|
||||
$user->user_money = ['inc', $withdraw['left_money']];
|
||||
$user->save();
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw['user_id'],
|
||||
$withdraw['left_money'],
|
||||
1,
|
||||
AccountLog::withdraw_to_balance,
|
||||
'',
|
||||
$withdraw['id'],
|
||||
$withdraw['sn']
|
||||
);
|
||||
//更新提现申请单状态为提现成功
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $id)
|
||||
->update(['status' => Withdraw::STATUS_SUCCESS, 'update_time' => time(), 'description'=>$post['description']]);
|
||||
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '提现至钱包余额成功'
|
||||
];
|
||||
}
|
||||
//提现到微信零钱
|
||||
if($withdraw['type'] == Withdraw::TYPE_WECHAT_CHANGE) {
|
||||
// 先更新审核备注
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $id)
|
||||
->update(['update_time' => time(),'description'=>$post['description']]);
|
||||
return WechatCorporatePaymentLogic::pay($withdraw);
|
||||
}
|
||||
|
||||
//提现到微信收款码、支付收款码
|
||||
if($withdraw['type'] == Withdraw::TYPE_WECHAT_CODE || $withdraw['type'] == Withdraw::TYPE_ALI_CODE || Withdraw::TYPE_BANK) {
|
||||
// 直接标识为提现中状态
|
||||
Db::name('withdraw_apply')
|
||||
->where('id', $id)
|
||||
->update(['status' => Withdraw::STATUS_ING, 'update_time' => time(),'description'=>$post['description']]);
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '审核通过,提现中'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//审核拒绝
|
||||
public static function refuse($post)
|
||||
{
|
||||
Db::startTrans();
|
||||
try{
|
||||
$withdraw_apply = WithdrawApply::where('id', $post['id'])->find();
|
||||
$withdraw_apply->status = Withdraw::STATUS_FAIL; // 提现失败
|
||||
$withdraw_apply->description = $post['description'];
|
||||
$withdraw_apply->update_time = time();
|
||||
$withdraw_apply->save();
|
||||
|
||||
//拒绝提现,回退佣金
|
||||
$user = User::get($withdraw_apply['user_id']);
|
||||
$user->earnings = ['inc', $withdraw_apply['money']];
|
||||
$user->save();
|
||||
|
||||
//增加佣金变动记录
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw_apply['user_id'],
|
||||
$withdraw_apply['money'],
|
||||
1,
|
||||
AccountLog::withdraw_back_earnings,
|
||||
'',
|
||||
$withdraw_apply['id'],
|
||||
$withdraw_apply['sn']
|
||||
);
|
||||
Db::commit();
|
||||
} catch (Exception $e){
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现失败
|
||||
*/
|
||||
public static function withdrawFailed($id)
|
||||
{
|
||||
$withdraw_apply = WithdrawApply::where('id', $id)->find();
|
||||
$withdraw_apply->status = Withdraw::STATUS_FAIL; // 提现失败
|
||||
$withdraw_apply->update_time = time();
|
||||
$withdraw_apply->save();
|
||||
|
||||
//拒绝提现,回退佣金
|
||||
$user = User::get($withdraw_apply['user_id']);
|
||||
$user->earnings = ['inc', $withdraw_apply['money']];
|
||||
$user->save();
|
||||
|
||||
//增加佣金变动记录
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw_apply['user_id'],
|
||||
$withdraw_apply['money'],
|
||||
1,
|
||||
AccountLog::withdraw_back_earnings,
|
||||
'',
|
||||
$withdraw_apply['id'],
|
||||
$withdraw_apply['sn']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
*/
|
||||
public static function detail($id)
|
||||
{
|
||||
$detail = Db::name('withdraw_apply w')
|
||||
->field('w.*,u.sn as user_sn, u.nickname, u.mobile')
|
||||
->leftJoin('user u', 'u.id=w.user_id')
|
||||
->where('w.id', $id)
|
||||
->find();
|
||||
$detail['typeDesc'] = Withdraw::getTypeDesc($detail['type']);
|
||||
$detail['statusDesc'] = Withdraw::getStatusDesc($detail['status']);
|
||||
$detail['create_time'] = Date('Y-m-d h:i:s', $detail['create_time']);
|
||||
$detail['payment_time'] = Date('Y-m-d h:i:s', $detail['payment_time']);
|
||||
$detail['transfer_time'] = $detail['transfer_time'] ? Date('Y-m-d h:i:s', $detail['transfer_time']) : '';
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现结果查询
|
||||
*/
|
||||
public static function search($id)
|
||||
{
|
||||
$withdraw = Db::name('withdraw_apply')
|
||||
->where('id', $id)
|
||||
->find();
|
||||
|
||||
// 判断提现单是否为提现中状态 2 且 提现方式为 微信零钱 2
|
||||
if($withdraw['status'] == 2 && $withdraw['type'] == 2) {
|
||||
return WechatCorporatePaymentLogic::search($withdraw);
|
||||
}else{
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '不是提现中的微信零钱申请单,无法查询'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账失败
|
||||
*/
|
||||
public static function transferFail($post)
|
||||
{
|
||||
if(empty($post['transfer_description'])) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '请填写转账说明'
|
||||
];
|
||||
}
|
||||
// 标识提现失败
|
||||
Db::name('withdraw_apply')->where('id', $post['id'])->update([
|
||||
'status' => 4, // 提现失败
|
||||
'transfer_description' => $post['transfer_description'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
$withdraw_apply = Db::name('withdraw_apply')->where('id', $post['id'])->find();
|
||||
// 退回佣金
|
||||
$user = User::get($withdraw_apply['user_id']);
|
||||
$user->earnings = ['inc', $withdraw_apply['money']];
|
||||
$user->save();
|
||||
|
||||
//增加佣金变动记录
|
||||
AccountLogLogic::AccountRecord(
|
||||
$withdraw_apply['user_id'],
|
||||
$withdraw_apply['money'],
|
||||
1,
|
||||
AccountLog::withdraw_back_earnings,
|
||||
'',
|
||||
$withdraw_apply['id'],
|
||||
$withdraw_apply['sn']
|
||||
);
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '转账失败,提现金额已退回佣金账户'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账成功
|
||||
*/
|
||||
public static function transferSuccess($post)
|
||||
{
|
||||
if(empty($post['transfer_voucher'])) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '请上传转账凭证'
|
||||
];
|
||||
}
|
||||
|
||||
$post['transfer_voucher'] = UrlServer::getFileUrl($post['transfer_voucher']);
|
||||
|
||||
if(empty($post['transfer_description'])) {
|
||||
return [
|
||||
'code' => 0,
|
||||
'msg' => '请填写转账说明'
|
||||
];
|
||||
}
|
||||
// 标识提现成功
|
||||
Db::name('withdraw_apply')->where('id', $post['id'])->update([
|
||||
'status' => 3, // 提现成功
|
||||
'transfer_voucher' => $post['transfer_voucher'],
|
||||
'transfer_description' => $post['transfer_description'],
|
||||
'update_time' => time(),
|
||||
'transfer_time' => time()
|
||||
]);
|
||||
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '转账成功'
|
||||
];
|
||||
}
|
||||
}
|
||||
238
application/admin/logic/WorkersLogLogic.php
Normal file
238
application/admin/logic/WorkersLogLogic.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
use app\admin\model\User;
|
||||
use app\api\model\Order;
|
||||
use app\api\model\OrderGoods;
|
||||
use app\common\model\AccountLog;
|
||||
use app\common\model\DistributionOrder;
|
||||
use think\Db;
|
||||
use think\helper\Time;
|
||||
|
||||
class WorkersLogLogic{
|
||||
public static function lists($get){
|
||||
$where = [];
|
||||
$where1 = [];
|
||||
$where2 = [];
|
||||
$where3 = [];
|
||||
|
||||
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
||||
$where1[] = ['autotime', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
$where2[] = ['create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
$where3[] = ['createtime', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
|
||||
|
||||
}
|
||||
|
||||
if(isset($get['create_end']) && $get['create_end']!=''){
|
||||
$where1[] = ['autotime','<=',strtotime($get['create_end'])];
|
||||
$where2[] = ['create_time','<=',strtotime($get['create_end'])];
|
||||
$where3[] = ['createtime','<=',strtotime($get['create_end'])];
|
||||
}
|
||||
|
||||
$count = Db::name('admin')
|
||||
|
||||
->count();
|
||||
|
||||
$list = Db::name('admin')
|
||||
->page($get['page'],$get['limit'])
|
||||
->order('id desc')
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
$item['fworder']=Db::name('order_exe')->where($where1)->where('admin',$item['id'])->where('staff_id','<>',Null)->where('staff_id','<>',0)->count();
|
||||
$item['nuorder']=Db::name('order')->where($where2)->where('admin_id',$item['id'])->where('pay_status',1)->Sum('order_amount');
|
||||
$item['adder']=Db::name('user_address')->where($where3)->where('admin_id',$item['id'])->count();
|
||||
|
||||
}
|
||||
return ['count'=>$count,'lists'=>$list];
|
||||
}
|
||||
|
||||
/**
|
||||
* note 每个资金记录页面的的变动类型
|
||||
* create_time 2020/11/23 9:55
|
||||
*/
|
||||
public static function orderSourceList($type){
|
||||
$list = [];
|
||||
switch ($type){
|
||||
case 1:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::balance_pay_order,
|
||||
'name' => '订单支付',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::admin_add_money.','.AccountLog::recharge_money,
|
||||
'name' => '钱包充值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::withdraw_to_balance,
|
||||
'name' => '佣金提现',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::register_add_integral,
|
||||
'name' => '关注赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::invite_add_integral,
|
||||
'name' => '邀请赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::sign_in_integral,
|
||||
'name' => '签到赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_integral,
|
||||
'name' => '充值赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_add_integral,
|
||||
'name' => '消费赠送积分',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_deduction_integral,
|
||||
'name' => '订单抵扣积分',
|
||||
],
|
||||
|
||||
];
|
||||
break;
|
||||
case 3:
|
||||
$list = [
|
||||
[
|
||||
'source' => AccountLog::sign_give_growth,
|
||||
'name' => '签到赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::recharge_give_growth,
|
||||
'name' => '充值赠送成长值',
|
||||
],
|
||||
[
|
||||
'source' => AccountLog::order_give_growth,
|
||||
'name' => '下单赠送成长值',
|
||||
],
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
public static function getTime(){
|
||||
$today = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::today());
|
||||
$yesterday = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::yesterday());
|
||||
|
||||
$days_ago7 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(7));
|
||||
|
||||
$days_ago30 = array_map(function ($time) {
|
||||
return date('Y-m-d H:i:s', $time);
|
||||
}, Time::dayToNow(30, true));
|
||||
$time = [
|
||||
'today' => $today,
|
||||
'yesterday' => $yesterday,
|
||||
'days_ago7' => $days_ago7,
|
||||
'days_ago30' => $days_ago30,
|
||||
];
|
||||
return $time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//佣金记录
|
||||
public static function getDistributionLog($get)
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($get['distribution_keyword_type']) and !empty($get['distribution_keyword']) and $get['distribution_keyword']) {
|
||||
switch ($get['distribution_keyword_type']) {
|
||||
case 'order_sn':
|
||||
$order_ids = Order::field('id,order_sn')->where('order_sn', $get['distribution_keyword'])->column('id');
|
||||
$og_ids = OrderGoods::field('id,order_id')->whereIn('id', $order_ids)->column('id');
|
||||
$where[] = ['order_goods_id', 'in', $og_ids];
|
||||
break;
|
||||
case 'nickname':
|
||||
$user_ids = User::field('id,sn,nickname')->where('nickname', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'user_sn':
|
||||
$user_ids = User::field('id,sn,nickname')->where('sn', 'like', '%'.$get['distribution_keyword'].'%')->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
case 'mobile':
|
||||
$user_ids = User::field('id,sn,mobile')->where('mobile', '=', $get['distribution_keyword'])->column('id');
|
||||
$where[] = ['user_id', 'in', $user_ids];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($get['distribution_status']) and is_numeric($get['distribution_status'])) {
|
||||
$where[] = ['d.status', '=', $get['distribution_status']];
|
||||
}
|
||||
if (!empty($get['distribution_start_time']) and $get['distribution_start_time']) {
|
||||
$where[] = ['d.create_time', '>=', strtotime($get['distribution_start_time'])];
|
||||
}
|
||||
if (!empty($get['distribution_end_time']) and $get['distribution_end_time']) {
|
||||
$where[] = ['d.create_time', '<=', strtotime($get['distribution_end_time'])];
|
||||
}
|
||||
|
||||
// 查询结果
|
||||
$count = DistributionOrder::where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->count();
|
||||
$lists = DistributionOrder::field('d.*, og.order_id')
|
||||
->where($where)->alias('d')
|
||||
->join('order_goods og', 'order_goods_id = og.id')
|
||||
->with('user')
|
||||
->withAttr('order', function ($value, $data) {
|
||||
return Order::field('id,order_sn,order_amount')->where(['id'=>$data['order_id']])->find();
|
||||
})
|
||||
->page($get['page'], $get['limit'])
|
||||
->append(['order'])
|
||||
->order('d.id desc')
|
||||
->select();
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$item['status_text'] = DistributionOrder::getOrderStatus($item['status']);
|
||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
}
|
||||
return ['count'=>$count, 'lists'=>$lists];
|
||||
}
|
||||
|
||||
|
||||
//佣金统计
|
||||
public static function withdrawTotalCount($get)
|
||||
{
|
||||
// 今天开始和结束时间戳
|
||||
list($startToday, $endToday) = Time::today();
|
||||
// 本月开始和结束时间戳
|
||||
list($startMonth, $endMonth) = Time::month();
|
||||
|
||||
if ($get['type'] == 'distribution') {
|
||||
// 获取分销佣金总计
|
||||
$distributionToday = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startToday)
|
||||
->where('create_time', '<=', $endToday)
|
||||
->sum('money');
|
||||
|
||||
$distributionMonth = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->where('create_time', '>=', $startMonth)
|
||||
->where('create_time', '<=', $endMonth)
|
||||
->sum('money');
|
||||
|
||||
$distributionTotal = DistributionOrder::where('status', 'in', [DistributionOrder::STATUS_WAIT_HANDLE, DistributionOrder::STATUS_SUCCESS])
|
||||
->sum('money');
|
||||
|
||||
return ['today'=>$distributionToday, 'month'=>$distributionMonth, 'total'=>$distributionTotal];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user