初始版本

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,250 @@
<?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\adminapi\lists\order;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\lists\ListsExtendInterface;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
use app\common\model\order\OrderGoods;
use app\common\model\pay\PayConfig;
use app\common\model\pay\PayWay;
use app\common\model\shop\Shop;
use app\common\model\user\User;
use app\common\service\FileService;
class OrderLists extends BaseAdminDataLists implements ListsExtendInterface
{
public $where = [];
/**
* @notes 搜索条件
* @return array
* @author ljj
* @date 2022/2/10 6:14 下午
*/
public function setWhere()
{
$this->where = [];
$params = $this->params;
if(isset($params['order_status']) && '' != $params['order_status']){
$this->where[] = ['O.order_status','=',$params['order_status']];
}
if (isset($params['order_info']) && $params['order_info'] != '') {
$this->where[] = ['O.sn','like','%'.$params['order_info'].'%'];
}
if (isset($params['user_info']) && $params['user_info'] != '') {
$this->where[] = ['U.sn|U.nickname|U.account','like','%'.$params['user_info'].'%'];
}
if (isset($params['goods_info']) && $params['goods_info'] != '') {
$orderIds = OrderGoods::where('goods_name','like','%'.$params['goods_info'].'%')->field('order_id')->select()->toArray();
empty($orderIds) && $orderIds = [];
$orderIds = array_column($orderIds,'order_id');
$this->where[] = ['O.id','in',implode(',',$orderIds)];
}
if (isset($params['pay_status']) && $params['pay_status'] != '') {
$this->where[] = ['O.pay_status','=',$params['pay_status']];
}
if (isset($params['start_time']) && $params['start_time'] != '') {
$timeType = $params['time_type'] ?? 1;
switch ($timeType){
case 1:
$this->where[] = ['O.create_time','>=',strtotime($params['start_time'])];
break;
case 2:
$this->where[] = ['O.pay_time','>=',strtotime($params['start_time'])];
break;
case 3:
$this->where[] = ['O.true_server_finish_time','>=',strtotime($params['start_time'])];
break;
}
}
if (isset($params['end_time']) && $params['end_time'] != '') {
$timeType = $params['time_type'] ?? 1;
switch ($timeType){
case 1:
$this->where[] = ['O.create_time','<=',strtotime($params['end_time'])];
break;
case 2:
$this->where[] = ['O.pay_time','<=',strtotime($params['end_time'])];
break;
case 3:
$this->where[] = ['O.true_server_finish_time','<=',strtotime($params['end_time'])];
break;
}
}
if (isset($params['coach_info']) && $params['coach_info'] != '') {
$this->where[] = ['C.name|C.sn','like','%'.$params['coach_info'].'%'];
}
if(isset($params['pay_way']) && $params['pay_way']){
$this->where[] = ['O.pay_way','=',$params['pay_way']];
}
if(isset($params['sn']) && $params['sn']){
$this->where[] = ['O.sn','like','%'.$params['sn'].'%'];
}
return $this->where;
}
/**
* @notes 订单列表
* @return array
* @author ljj
* @date 2022/2/10 6:19 下午
*/
public function lists(): array
{
self::setWhere();
$lists = Order::alias('O')
->join('user U','O.user_id = U.id')
->join('coach C','O.coach_id = C.id')
->where($this->where)
->order('O.id desc')
->field('O.id,O.shop_id,O.total_order_amount,O.total_refund_amount,O.order_distance,O.pay_status,O.user_id,O.total_amount,O.coach_id,O.sn,O.order_status,O.appoint_time,O.order_amount,O.create_time')
->append(['order_distance_desc','appoint_time','appoint_date','order_status_desc','take_order_btn','depart_btn','dispatch_btn','arrive_btn','server_start_btn','server_finish_btn','refund_btn','cancel_btn','order_cancel_time'])
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
if(empty($lists)){
return [];
}
$orderIds = array_column($lists,'id');
$lists = array_column($lists,null,'id');
$orderGoodsLists = OrderGoods::where(['order_id'=>$orderIds])->select()->toArray();
$coachIds = array_column($lists,'coach_id');
$coachLists = Coach::where(['id'=>$coachIds])->column('sn,name,work_photo,shop_id','id');
$shopIds = array_column($lists,'shop_id');
$shopLists = Shop::where(['id'=>$shopIds])->column('sn,name','id');
$userIds = array_column($lists,'user_id');
$userLists = User::where(['id'=>$userIds])->column('id,sn,nickname,mobile,avatar','id');
foreach ($orderGoodsLists as $orderGoodsList){
$orderGoods = $lists[$orderGoodsList['order_id']]['order_goods'] ?? [];
$orderGoods[] = $orderGoodsList;
$lists[$orderGoodsList['order_id']]['order_goods'] = $orderGoods;
}
foreach ($lists as $key => $order){
$lists[$key]['coach_info'] = $coachLists[$order['coach_id']] ?? [];
$lists[$key]['coach_info']['work_photo'] = FileService::getFileUrl($lists[$key]['coach_info']['work_photo'] ?? '');
$lists[$key]['shop_info'] = $shopLists[$order['shop_id']] ?? [];
$lists[$key]['user_info'] = $userLists[$order['user_id']] ?? [];
$lists[$key]['user_info']['avatar'] = FileService::getFileUrl($lists[$key]['user_info']['avatar'] ?? '');
if(!isset($order['address_snap']['house_number'])){
$lists[$key]['address_snap']['house_number'] = '';
}
}
return array_values($lists);
}
/**
* @notes 订单总数
* @return int
* @author ljj
* @date 2022/2/10 6:19 下午
*/
public function count(): int
{
return Order::alias('O')
->join('user U','O.user_id = U.id')
->join('coach C','O.coach_id = C.id')
->where($this->where)
->count();
}
/**
* @notes 订单数据统计
* @return array
* @author ljj
* @date 2022/2/15 11:07 上午
*/
public function extend(): array
{
if(isset($this->where[0]) && 'O.order_status' == $this->where[0][0]){
unset($this->where[0]);
$this->where = array_values($this->where);
}
$lists = Order::alias('O')
->join('user U','O.user_id = U.id')
->join('coach C','O.coach_id = C.id')
->where($this->where)
->field('O.order_status')
->select();
//全部
$data['all_count'] = 0;
//待支付
$data['wait_pay_count'] = 0;
//待接单
$data['wait_take_count'] = 0;
//待出发
$data['wait_depart_count'] = 0;
//已出发
$data['depart_count'] = 0;
//已到达
$data['arrive_count'] = 0;
//服务中
$data['start_server_count'] = 0;
//完成服务
$data['finish_server_count'] = 0;
//关闭
$data['close_count'] = 0;
$data['pay_way'] = PayConfig::field('id,name,pay_way')->select();
$data['order_status'] = OrderEnum::getOrderStatusDesc();
foreach ($lists as $val) {
//全部
$data['all_count'] += 1;
switch ($val['order_status']){
//待支付
case OrderEnum::ORDER_STATUS_WAIT_PAY:
$data['wait_pay_count']++;
break;
//待接单
case OrderEnum::ORDER_STATUS_WAIT_RECEIVING:
$data['wait_take_count']++;
break;
//待出发
case OrderEnum::ORDER_STATUS_WAIT_DEPART:
$data['wait_depart_count']++;
break;
//已出发
case OrderEnum::ORDER_STATUS_DEPART:
$data['depart_count']++;
break;
//已达到
case OrderEnum::ORDER_STATUS_ARRIVE:
$data['arrive_count']++;
break;
//服务中
case OrderEnum::ORDER_STATUS_START_SERVER:
$data['start_server_count']++;
break;
//完成服务
case OrderEnum::ORDER_STATUS_SERVER_FINISH:
$data['finish_server_count']++;
break;
//服务关闭
case OrderEnum::ORDER_STATUS_CLOSE:
$data['close_count']++;
break;
}
}
return $data;
}
}

View File

@@ -0,0 +1,175 @@
<?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\adminapi\lists\order;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\enum\OrderRefundEnum;
use app\common\lists\ListsExtendInterface;
use app\common\model\order\OrderRefund;
class OrderRefundLists extends BaseAdminDataLists implements ListsExtendInterface
{
/**
* @notes 搜索条件
* @return array
* @author ljj
* @date 2022/9/9 4:31 下午
*/
public function where()
{
$where = [];
$params = $this->params;
if (isset($params['refund_sn']) && $params['refund_sn'] != '') {
$where[] = ['or.sn','like','%'.$params['refund_sn'].'%'];
}
if (isset($params['source_sn']) && $params['source_sn'] != '') {
$where[] = ['o.sn','like','%'.$params['source_sn'].'%'];
}
if (isset($params['user_info']) && $params['user_info'] != '') {
$where[] = ['u.sn|u.nickname','like','%'.$params['user_info'].'%'];
}
if (isset($params['refund_type']) && $params['refund_type'] != '') {
$where[] = ['or.type','=',$params['refund_type']];
}
if (isset($params['start_time']) && $params['start_time'] != '') {
$where[] = ['or.create_time','>=',strtotime($params['start_time'])];
}
if (isset($params['end_time']) && $params['end_time'] != '') {
$where[] = ['or.create_time','<=',strtotime($params['end_time'])];
}
if (isset($params['refund_status']) && $params['refund_status'] != '') {
switch ($params['refund_status']) {
case 1:
$where[] = ['or.refund_status','=',0];
break;
case 2:
$where[] = ['or.refund_status','=',1];
break;
case 3:
$where[] = ['or.refund_status','=',2];
break;
}
}
return $where;
}
/**
* @notes 订单退款列表
* @return array
* @author ljj
* @date 2022/9/9 4:37 下午
*/
public function lists(): array
{
$where = self::where();
$lists = (new OrderRefund())->alias('or')
->join('user u', 'u.id = or.user_id')
->join('order o', 'o.id = or.order_id')
->field('or.id,or.sn as refund_sn,or.user_id,or.type,round(or.refund_amount+or.refund_car_amount,2) as refund_amount,or.refund_status,or.create_time,o.sn as source_sn')
->with(['user' => function($query){
$query->field('id,sn,nickname,avatar,mobile');
}])
->where($where)
->order(['or.id'=>'desc'])
->append(['type_desc','refund_status_desc'])
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
return $lists;
}
/**
* @notes 订单退款数量
* @return int
* @author ljj
* @date 2022/9/9 4:37 下午
*/
public function count(): int
{
$where = self::where();
return (new OrderRefund())->alias('or')
->join('user u', 'u.id = or.user_id')
->join('order o', 'o.id = or.order_id')
->where($where)
->count();
}
/**
* @notes 订单退款数据统计
* @return array
* @author ljj
* @date 2022/9/9 4:41 下午
*/
public function extend(): array
{
$where = self::where();
foreach ($where as $key=>$val) {
if ($val[0] == 'or.refund_status') {
unset($where[$key]);
}
}
$lists = (new OrderRefund())->alias('or')
->join('user u', 'u.id = or.user_id')
->join('order o', 'o.id = or.order_id')
->field('or.refund_status,or.refund_amount')
->where($where)
->select()
->toArray();
$all_count = 0;
$refund_wait_count = 0;
$refund_success_count = 0;
$refund_fail_count = 0;
$total_refund_amount = OrderRefund::sum('refund_amount');
$refund_ing_amount = OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_ING])->sum('refund_amount');
$refund_success_amount = OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_SUCCESS])->sum('refund_amount');
$refund_fail_amount = OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_FAIL])->sum('refund_amount');
foreach ($lists as $val) {
$all_count += 1;
if ($val['refund_status'] == OrderRefundEnum::STATUS_ING) {
$refund_wait_count += 1;
}
if ($val['refund_status'] == OrderRefundEnum::STATUS_SUCCESS) {
$refund_success_count += 1;
}
if ($val['refund_status'] == OrderRefundEnum::STATUS_FAIL) {
$refund_fail_count += 1;
}
}
return [
'all_count' => $all_count,
'refund_wait_count' => $refund_wait_count,
'refund_success_count' => $refund_success_count,
'refund_fail_count' => $refund_fail_count,
'total_refund_amount' => $total_refund_amount,
'refund_ing_amount' => $refund_ing_amount,
'refund_success_amount' => $refund_success_amount,
'refund_fail_amount' => $refund_fail_amount,
];
}
}

View File

@@ -0,0 +1,62 @@
<?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\adminapi\lists\order;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\order\OrderRefundLog;
class OrderRefundLogLists extends BaseAdminDataLists
{
/**
* @notes 退款日志列表
* @return array
* @author ljj
* @date 2022/9/9 5:52 下午
*/
public function lists(): array
{
$lists = (new OrderRefundLog())->alias('orl')
->join('order_refund or', 'or.id = orl.refund_id')
->field('orl.id,orl.sn,or.refund_amount + or.refund_car_amount as refund_amount,orl.refund_status,orl.create_time,orl.operator_id,orl.type')
->where(['refund_id'=>$this->params['id']])
->order(['orl.id'=>'desc'])
->append(['operator_desc','refund_status_desc'])
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
return $lists;
}
/**
* @notes 退款日志数量
* @return int
* @author ljj
* @date 2022/9/9 5:52 下午
*/
public function count(): int
{
return (new OrderRefundLog())->alias('orl')
->join('order_refund or', 'or.id = orl.refund_id')
->where(['refund_id'=>$this->params['id']])
->count();
}
}

View File

@@ -0,0 +1,58 @@
<?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\adminapi\lists\order;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\order\OrderTime;
class OrderTimeLists extends BaseAdminDataLists
{
/**
* @notes 订单预约时间段列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/11 5:49 下午
*/
public function lists(): array
{
$lists = (new OrderTime())->field('id,start_time,end_time,sort')
->order(['sort'=>'desc','id'=>'asc'])
->append(['time_desc'])
->select()
->toArray();
return $lists;
}
/**
* @notes 订单预约时间段总数
* @return int
* @author ljj
* @date 2022/2/11 5:49 下午
*/
public function count(): int
{
return (new OrderTime())->count();
}
}