初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 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系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\common\command;
use app\common\enum\OrderEnum;
use app\common\model\goods\GoodsComment;
use app\common\model\order\Order;
use app\common\model\order\OrderGoods;
use app\common\service\ConfigService;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\Db;
use think\facade\Log;
class OrderComment extends Command
{
protected function configure()
{
$this->setName('order_comment')
->setDescription('订单自动评论');
}
protected function execute(Input $input, Output $output)
{
$overTimeComment = ConfigService::get('order_setting', 'over_time_comment') * 60 * 60 * 60;
$now = time();
$lists = Order::alias('O')
->join('order_goods OG','O.id = OG.order_id')
->whereRaw("true_server_finish_time+$overTimeComment < $now")
->where(['order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH,'is_comment'=>0])
->where('true_server_finish_time','>',0)
->field('O.user_id,O.shop_id,O.coach_id,OG.*')
->select()
->toArray();
if (empty($lists)) {
return true;
}
$overTimeCommentContent = ConfigService::get('order_setting', 'over_time_comment_content');
foreach ($lists as $order) {
Db::startTrans();
try{
GoodsComment::create([
'goods_id' => $order['goods_id'],
'user_id' => $order['user_id'],
'order_goods_id' => $order['id'],
'service_comment' => 5,
'comment' => $overTimeCommentContent,
'reply' => '',
'coach_id' => $order['coach_id'],
'shop_id' => $order['shop_id'],
]);
\app\common\logic\CoachLogic::updateCoachComment($order['coach_id']);
if($order['shop_id']){
\app\common\logic\ShopLogic::updateShopComment($order['shop_id']);
}
OrderGoods::where(['id'=>$order['id']])->update(['is_comment' => 1]);
Db::commit();
} catch(\Exception $e) {
Db::rollback();
Log::write('订单评论失败:' . $e->getMessage());
}
}
}
}