安徽博创起重服务端程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

101 lines
3.1 KiB

<?php
namespace app\admin\logic\content;
use app\common\basics\Logic;
use app\common\enum\PayEnum;
use app\common\model\Client_;
use app\common\model\order\OrderResource;
use app\common\model\order\OrderUser;
use app\common\model\user\UserShip;
use app\common\model\user\UserTag;
use app\common\model\user\User;
class ResourceLogLogic extends Logic
{
public static function lists($get)
{
// 订单来源
$order_source = Client_::getClient(true);
// 支付方式
$pay_way = PayEnum::getPayWay(true);
$where = [];
$where[] = ['a.del','=',0];
//订单类型
if (isset($get['keyword']) && $get['keyword'] != '') {
$where[] = ['a.order_sn|b.nickname|b.mobile', 'like', "%".$get['keyword']."%"];
}
//订单类型
if (isset($get['title']) && $get['title'] != '') {
$where[] = ['c.title', 'like', "%".$get['title']."%"];
}
//支付状态
if (isset($get['pay_status']) && $get['pay_status'] != '') {
$where[] = ['a.pay_status', '=', $get['pay_status']];
}
//付款方式
if (isset($get['pay_way']) && $get['pay_way'] != '') {
$where[] = ['a.pay_way', '=', $get['pay_way']];
}
//订单来源
if (isset($get['order_source']) && $get['order_source'] != '') {
$where[] = ['a.order_source', '=', $get['order_source']];
}
//下单时间
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'])];
}
$orderuser = new OrderResource();
$lists = $orderuser
->where($where)
->field("a.*,b.nickname,b.avatar,b.mobile,c.title as resource_name")
->alias('a')
->join('user b','a.user_id=b.id','LEFT')
->join('resource c','a.org_id=c.id','LEFT')
->page($get['page'], $get['limit'])->order('a.create_time desc')->select()->toArray();
$count = $orderuser ->alias('a')->alias('a')
->join('user b','a.user_id=b.id','LEFT')->where($where)->count();
foreach ($lists as &$item){
$item['pay_time_str'] = $item['pay_time']>0?date("Y-m-d H:i:s",$item['pay_time']):'--';
$item['pay_status_str'] = $item['pay_status']==0?'未支付':'已支付';
$item['order_source_name'] = $order_source[$item['order_source']];
$item['pay_way_name'] = $item['pay_way']==0?'无':$pay_way[$item['pay_way']];
}
return [
'lists' => $lists,
'count' => $count
];
}
public static function del($id)
{
try{
$data = [
'id' => $id,
'update_time' => time(),
'del' => 1
];
UserShip::update($data);
return true;
}catch(\Exception $e){
self::$error = $e->getMessage();
return false;
}
}
}