添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
<?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\common\command;
use app\common\model\Bargain;
use app\common\model\BargainLaunch;
use app\common\model\Order;
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\facade\Log;
/**
* 砍价活动结束定时任务
* Class BargainEnd
* @Author 张无忌
* @package app\common\command
*/
class BargainEnd extends Command
{
protected function configure()
{
$this->setName('bargain_end')
->setDescription('结束已超时的砍价');
}
protected function execute(Input $input, Output $output)
{
try {
$now = time();
$bargainModel = new Bargain();
$bargainLaunchModel = new BargainLaunch();
$succeed_ids = [];
$defeat_ids = [];
//砍价成功后的下单时间
$payment_limit_time = ConfigServer::get('bargain', 'payment_limit_time', 0) * 60;
if($payment_limit_time > 0){
$payment_limit_time = $now + $payment_limit_time;
}
//找出所有超时未关掉的订单
$bargainLaunchModel->where([['status','=',BargainLaunch::conductStatus],['launch_end_time','<=',$now]])
->chunk(100, function($launchs) use(&$succeed_ids,&$defeat_ids) {
foreach ($launchs as $launch){
$launch = $launch->toarray();
//任意金额购买时,更新砍价成功
if(2 == $launch['bargain_snap']['payment_where']){
$succeed_ids[] = $launch['id'];
}else{
$defeat_ids[] = $launch['id'];
}
}
});
//标记成功
if($succeed_ids){
$bargainLaunchModel->where(['id'=>$succeed_ids])->update(['status'=>BargainLaunch::successStatus,'payment_limit_time'=>$payment_limit_time,'bargain_end_time'=>$now]);
}
//标记失败
if($defeat_ids){
$bargainLaunchModel->where(['id'=>$defeat_ids])->update(['status'=>BargainLaunch::failStatus,'bargain_end_time'=>$now]);
}
// 查询出要关闭的砍价活动
$bargain_ids = $bargainModel->where([
['activity_end_time', '<', $now],
['del', '=', 0],
['status', '=', 1]
])->column('id');
// 结束砍价活动(结束时间 < 当前时间)
$bargainModel->whereIn('id', $bargain_ids)
->update(['status' => 0]);
} catch (\Exception $e) {
Log::write('结束砍价活动失败:'.$e->getMessage());
}
}
}

View File

@@ -0,0 +1,103 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\common\command;
use Cron\CronExpression;
use think\Console;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\facade\Debug;
use think\facade\Log;
class Crontab extends Command
{
protected function configure()
{
$this->setName('crontab')
->setDescription('定时任务');
}
/**
* 启动定时任务守护进程
* @param Input $input
* @param Output $output
* @return int|void|null
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
protected function execute(Input $input, Output $output)
{
Log::close();
$time = time();
$crons = Db::name('dev_crontab')
->where(['status' => 1])
->select();
if (empty($crons)) {
return;
}
foreach ($crons as $cron) {
//规则错误,不执行
if (CronExpression::isValidExpression($cron['expression']) === false) {
continue;
}
//未到时间,不执行
$cron_expression = CronExpression::factory($cron['expression']);
$next_time = $cron_expression->getNextRunDate(date('Y-m-d H:i:s', $cron['last_time']))->getTimestamp();
if ($next_time >= $time) {
continue;
}
//开始执行
try {
Debug::remark('begin');
$parameter = explode(' ', $cron['parameter']);
if (is_array($parameter) && !empty($cron['parameter'])) {
Console::call($cron['command'], $parameter);
} else {
Console::call($cron['command']);
}
Db::name('dev_crontab')
->where(['id' => $cron['id']])
->update(['error' => '']);
} catch (\Exception $e) {
Db::name('dev_crontab')
->where(['id' => $cron['id']])
->update(['error' => $e->getMessage(), 'status' => 3]);
} finally {
Debug::remark('end');
$range_time = Debug::getRangeTime('begin', 'end');
$max_time = max($cron['max_time'], $range_time);
Db::name('dev_crontab')
->where(['id' => $cron['id']])
->update(['last_time' => $time, 'time' => $range_time, 'max_time' => $max_time]);
}
}
}
}

View File

@@ -0,0 +1,172 @@
<?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\common\command;
use app\common\logic\AccountLogLogic;
use app\common\model\{AccountLog, AfterSale, NoticeSetting, Order, User, DistributionOrder as DistributionOrderModel};
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\facade\Hook;
use think\facade\Log;
class DistributionOrder extends Command
{
/**
* 分佣逻辑 => (没有售后订单且符合其他条件可结算)
* 售后订单为 申请退款, 待退货, 待收货 属于情况不明, 不结算分佣订单
* 售后订单为 等待退款 或 退款成功, 不结算分佣订单 分佣订单状态改为已失效
* 售后订单为 拒绝 或 拒收货 情况清晰 不退钱 可结算分佣订单
*/
protected function configure()
{
$this->setName('distribution_order')
->setDescription('结算分销订单');
}
protected function execute(Input $input, Output $output)
{
//查看分销配置是否开启
$setting = ConfigServer::get('distribution', 'is_open', 1);
if ($setting != 1) {
return true;
}
//售后时间(未过售后时间的分销订单不处理)
$after_sale_time = ConfigServer::get('after_sale', 'refund_days', 7);
$after_sale_time = $after_sale_time * 24 * 60 * 60;
$now = time();
Db::startTrans();
try{
//待分佣的分销订单
$orders = Db::name('distribution_order_goods')->alias('d')
->field('o.id as order_id,o.confirm_take_time, d.money, d.id as distribution_id, d.user_id, d.sn, d.order_goods_id')
->join('order_goods og', 'og.id = d.order_goods_id')
->join('order o', 'o.id = og.order_id')
->where('d.status', DistributionOrderModel::STATUS_WAIT_HANDLE)
->where('o.order_status', Order::STATUS_FINISH)
->where(Db::raw("o.confirm_take_time+$after_sale_time < $now"))
->select();
//处理用户表字段earnings为null时自增佣金报错的情况
$check_user = User::whereNull('earnings')->find();
if ($check_user) {
User::whereNull('earnings')->update(['earnings' => 0]);
}
foreach ($orders as $order) {
$user = User::get($order['user_id']);
//当前分佣订单是否可结算 //非分销会员或已被冻结的分销会员不参与分佣
if ( false === self::isSettle($order) || empty($user)
|| $user['is_distribution'] != 1
|| $user['freeze_distribution'] == 1
) {
continue;
}
//增加佣金
$user->earnings = ['inc', $order['money']];
$user->update_time = time();
$user->save();
//增加佣金变动记录
AccountLogLogic::AccountRecord(
$order['user_id'],
$order['money'],
1,
AccountLog::distribution_inc_earnings,
'',
$order['distribution_id'],
$order['sn']
);
//更新分销订单状态
DistributionOrderModel::updateOrderStatus($order['distribution_id'], DistributionOrderModel::STATUS_SUCCESS);
//通知会员
Hook::listen('notice', [
'user_id' => $order['user_id'],
'earnings' => $order['money'],
'scene' => NoticeSetting::GET_EARNINGS_NOTICE,
]);
// 赠送成长值和积分
Hook::listen('give_reward', [
'order_id' => $order['order_id'],
'scene' => 4, //4=订单结算
]);
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
Log::write('结算分佣订单错误:'.$e->getMessage());
}
}
//是否可以结算分佣订单 (检查是否有售后记录 没有则可结算, 有则需要检查售后记录状态)
protected function isSettle($order)
{
//订单是否在售后(正在退款或已退款)
$check = Db::name('after_sale')
->where(['order_goods_id' => $order['order_goods_id']])
->where('del', 0)
->find();
if (!$check) {
return true;
}
//有售后订单记录且状态 $no_settlement中的 不结算分佣订单
$no_settlement = [
AfterSale::STATUS_APPLY_REFUND, //申请退款
AfterSale::STATUS_WAIT_RETURN_GOODS, //商品待退货
AfterSale::STATUS_WAIT_RECEIVE_GOODS, //商家待收货
];
//不结算且分佣订单改为已失效
$set_fail = [
AfterSale::STATUS_WAIT_REFUND, //等待退款
AfterSale::STATUS_SUCCESS_REFUND, //退款成功
];
//售后情况不明 不结算
if (in_array($check['status'], $no_settlement)) {
return false;
}
//分佣订单更新为已失效 不结算
if (in_array($check['status'], $set_fail)) {
DistributionOrderModel::updateOrderStatus($order['distribution_id'], DistributionOrderModel::STATUS_ERROR);
return false;
}
return true;
}
}

View File

@@ -0,0 +1,143 @@
<?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\common\command;
use app\api\model\{
Order,Goods,GoodsItem
};
use app\common\logic\AccountLogLogic;
use app\common\model\AccountLog;
use app\common\model\Pay;
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
class OrderClose extends Command{
protected function configure()
{
$this->setName('order_close')
->setDescription('关闭订单');
}
protected function execute(Input $input, Output $output)
{
//是否下单扣库存 todo 默认是下单扣库存
$deduct_type = ConfigServer::get('trading', 'deduct_type', 1);
//取消订单时长 todo 默认是30分钟
$order_cancel_time = ConfigServer::get('trading','order_cancel', 30) * 60;
$now = time();
if ($order_cancel_time == 0) {
return false;
}
$order = new Order();
$where[] = ['order_status','=',\app\common\model\Order::STATUS_WAIT_PAY];
$where[] = ['pay_status','=',Pay::UNPAID];
$order_list = $order
->where($where)
->where(Db::raw("create_time+$order_cancel_time < $now"))
->with(['orderGoods'])
->select()->toArray();
$order_ids = []; //更新的订单
$update_total_stock = []; //更新总库存
$update_stock = []; //更新规格库存
$total_stock_num = []; //总库存
$stock_num = []; //规格库存
$update_coupon_ids = []; //更新优惠券状态
foreach ($order_list as $order){
$order_ids[] = $order['id'];
//返回优惠券
if($order['coupon_list_id']){
$update_coupon_ids[] = $order['coupon_list_id'];
}
//更新积分
if($order['use_integral'] > 0){
Db::name('user')->where(['id'=>$order['user_id']])->setInc('user_integral',$order['use_integral']);
AccountLogLogic::AccountRecord(
$order['user_id'],
$order['use_integral'],
1,
AccountLog::cancel_order_refund_integral
);
}
//更新库存
if($deduct_type){
foreach ($order['order_goods'] as $order_goods){
//更新商品总库存数据
if(isset($update_total_stock[$order_goods['goods_id']])){
$total_stock_num[$order_goods['goods_id']] = $total_stock_num[$order_goods['goods_id']] + $order_goods['goods_num'];
$update_total_stock[$order_goods['goods_id']]['stock'] = Db::raw('stock+'.$total_stock_num[$order_goods['goods_id']]);
}else{
$total_stock_num[$order_goods['goods_id']] = $order_goods['goods_num'];
$update_total_stock[$order_goods['goods_id']] = [
'id' => $order_goods['goods_id'],
'stock' => Db::raw('stock+'.$total_stock_num[$order_goods['goods_id']])
];
}
//更新商品规格库存数据
if(isset($update_stock[$order_goods['item_id']])){
$stock_num[$order_goods['item_id']] = $stock_num[$order_goods['item_id']] + $order_goods['goods_num'];
$update_stock[$order_goods['item_id']]['stock'] = Db::raw('stock+'.$stock_num[$order_goods['item_id']]);
}else{
$stock_num[$order_goods['item_id']] = $order_goods['goods_num'];
$update_stock[$order_goods['item_id']] = [
'id' => $order_goods['item_id'],
'stock' => Db::raw('stock+'.$stock_num[$order_goods['item_id']])
];
}
}
}
}
if($order_ids){
$update_data = [
'order_status' => \app\common\model\Order::STATUS_CLOSE,
'update_time' => $now,
];
Db::name('order')->where(['id'=>$order_ids])->update($update_data);
}
//批量更新库存
if($update_total_stock){
$goods = new Goods();
$goods_item = new GoodsItem();
$goods->saveAll(array_values($update_total_stock));
$goods_item->saveAll(array_values($update_stock));
}
//更新优惠券
if($update_coupon_ids){
$update_coupon = [
'status' => 0,
'use_time' => '',
'order_id' => '',
'update_time' => $now,
];
Db::name('coupon_list')->where(['id'=>$update_coupon_ids])->update($update_coupon);
}
}
}

View File

@@ -0,0 +1,97 @@
<?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\common\command;
use app\common\logic\OrderLogLogic;
use app\common\model\Order;
use app\common\model\OrderLog;
use app\common\model\Pay;
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\facade\Hook;
use think\facade\Log;
/**
* 确认收货
* Class OrderFinish
* @package app\common\command
*/
class OrderFinish extends Command
{
protected function configure()
{
$this->setName('order_finish')
->setDescription('自动确认收货(待收货订单)');
}
protected function execute(Input $input, Output $output)
{
$now = time();
$config = ConfigServer::get('trading', 'order_finish', 0);
if($config == 0){
return true;
}
$finish_limit = $config * 24 * 60 * 60;
$orders = Db::name('order')
->where(['order_status' => Order::STATUS_WAIT_RECEIVE, 'pay_status' => Pay::ISPAID, 'del' => 0])
->where(Db::raw("shipping_time+$finish_limit < $now"))
->select();
if (empty($orders)){
return true;
}
Db::startTrans();
try{
foreach ($orders as $order){
Db::name('order')
->where(['id' => $order['id']])
->update([
'order_status' => Order::STATUS_FINISH,
'update_time' => $now,
'confirm_take_time' => $now,
]);
// 赠送成长值和积分
Hook::listen('give_reward', [
'order_id' => $order['id'],
'scene' => 4, //4=订单结算
]);
//订单日志
OrderLogLogic::record(
OrderLog::TYPE_SYSTEM,
OrderLog::SYSTEM_CONFIRM_ORDER,
$order['id'],
0,
OrderLog::SYSTEM_CONFIRM_ORDER
);
}
Db::commit();
} catch (\Exception $e){
Log::write('订单自动确认失败,失败原因:'.$e->getMessage());
Db::rollback();
}
}
}

View File

@@ -0,0 +1,152 @@
<?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\common\command;
use app\common\logic\OrderRefundLogic;
use app\common\model\Order;
use app\common\model\OrderLog;
use app\common\model\Pay;
use app\common\model\Team;
use app\common\model\TeamFollow;
use app\common\model\TeamFound;
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
use think\facade\Log;
class TeamEnd extends Command
{
protected function configure()
{
$this->setName('team_end')
->setDescription('结束已超时的拼团');
}
protected function execute(Input $input, Output $output)
{
$now = time();
//关闭活动
$activity = Db::name('team_activity')
->where('end_time', '<=', $now)
->select();
//更新商品is_team
$team_ids = array_column($activity, 'team_id');
Db::name('goods g')
->join('team_goods_item i', 'i.goods_id = g.id')
->where('i.team_id', 'in', $team_ids)
->update(['is_team' => 0]);
Db::name('team_activity')
->where('team_id', 'in', $team_ids)
->update(['status' => 0]);
$map1 = [
['found_end_time', '<=', $now],
['status', '=', 0]
];
$map2 = [
['team_id', 'in', $team_ids],
['status', '=', 0]
];
//已过团结束时间,但未成团
$lists = Db::name('team_found')
->field('id')
->whereOr([$map1, $map2])
->select();
if (empty($lists)) {
return true;
}
//需要退款的团id
$refound_found_ids = [];
//系统自动成团: 0-关闭; 1-开启
$setting = ConfigServer::get('team', 'automatic', 0);
//更新拼团状态
foreach ($lists as $item) {
$found = TeamFound::get($item['id']);
if ($found['join'] == $found['need'] || $setting == 1) {
//人数凑齐,拼团成功 或者 系统自动成团
$team_status = Team::STATUS_SUCCESS;
} else {
//人数不齐,拼团失败
$team_status = Team::STATUS_ERROR;
$refound_found_ids[] = $item['id'];
}
$found->status = $team_status;
$found->team_end_time = time();
$found->save();
TeamFollow::where(['found_id' => $item['id']])
->update(['status' => $team_status, 'team_end_time' => time()]);
}
if (empty($refound_found_ids)) {
return true;
}
//失败的订单才退款
$orders = Db::name('order')
->where(['team_found_id' => $refound_found_ids, 'del' => 0])
->select();
Db::startTrans();
try {
foreach ($orders as $order) {
if ($order['order_status'] == Order::STATUS_CLOSE) {
continue;
}
if ($order['pay_status'] == Pay::REFUNDED || $order['pay_status'] == Pay::UNPAID) {
continue;
}
//取消订单
OrderRefundLogic::cancelOrder($order['id'], OrderLog::TYPE_SYSTEM);
//更新订单状态
OrderRefundLogic::cancelOrderRefundUpdate($order);
//订单退款
OrderRefundLogic::refund($order, $order['order_amount'], $order['order_amount']);
}
Db::commit();
} catch (Exception $e) {
Db::rollback();
//错误记录
Log::write('拼购退款失败:' . $e->getMessage());
} catch (\EasyWeChat\Kernel\Exceptions\Exception $e) {
Db::rollback();
//错误记录
Log::write('拼购退款失败:' . $e->getMessage());
} catch (\Exception $e) {
Db::rollback();
//错误记录
Log::write('拼购退款失败:' . $e->getMessage());
}
}
}

View File

@@ -0,0 +1,63 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\common\command;
use app\common\server\ConfigServer;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\facade\Config;
use think\facade\Log;
class Update extends Command
{
protected function configure()
{
$this->setName('update')
->setDescription('更新代码、同步数据以后执行');
}
protected function execute(Input $input, Output $output)
{
//修改旧活动专区错误
$lists = Db::name('activity_goods')->where(['del' => 0])->select();
$temp = [];
$count = 0;
foreach ($lists as $k => $v) {
$temp_key = $v['goods_id'].'_'.$v['activity_id'];
if (in_array($temp_key, $temp)) {
Db::name('activity_goods')
->where(['del' => 0, 'id' => $v['id']])
->update(['del' => 1]);
$count += 1;
} else {
$temp[] = $temp_key;
}
}
Log::write('处理活动专区错误,删除'.$count.'数据');
// 更新file_cate表中type=null值的旧记录
Db::name('file_cate')->whereNull('type')->update(['type' => 1]);
}
}

View File

@@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\common\command;
use app\common\model\Pay;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
class UserDistribution extends Command
{
protected function configure()
{
$this->setName('user_distribution')
->setDescription('更新会员分销信息');
}
protected function execute(Input $input, Output $output)
{
$users = Db::name('user u')
->field('d.*')
->join('user_distribution d', 'd.user_id = u.id')
->where(['u.del' => 0])
->select();
if (!$users){
return true;
}
foreach ($users as $user){
//粉丝数量
$where1 = [
['first_leader', '=', $user['user_id']],
];
$where2 = [
['second_leader', '=', $user['user_id']],
];
$fans = Db::name('user')
->whereOr([$where1,$where2])
->count();
//分销订单信息
$distribution = Db::name('distribution_order_goods')
->field('sum(money) as money, count(id) as order_num')
->where(['user_id' => $user['user_id']])
->find();
//订单信息
$order = Db::name('order')
->field('sum(order_amount) as order_amount, count(id) as order_num')
->where([
'user_id' => $user['user_id'],
'pay_status' => Pay::ISPAID,
'refund_status' => 0
])
->find();
$data = [
'distribution_order_num' => $distribution['order_num'] ?? 0,
'distribution_money' => $distribution['money'] ?? 0,
'order_num' => $order['order_num'] ?? 0,
'order_amount' => $order['order_amount'] ?? 0,
'fans' => $fans,
'update_time' => time(),
];
//更新会员分销信息表
Db::name('user_distribution')
->where('user_id', $user['user_id'])
->update($data);
}
}
}