💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 示例代码 ``` <?php /** * +---------------------------------------------------------------------- * | 草帽支付系统 [ WE CAN DO IT JUST THINK ] * +---------------------------------------------------------------------- * | Copyright (c) 2018 http://www.iredcap.cn All rights reserved. * +---------------------------------------------------------------------- * | Licensed ( https://www.apache.org/licenses/LICENSE-2.0 ) * +---------------------------------------------------------------------- * | Author: Brian Waring <BrianWaring98@gmail.com> * +---------------------------------------------------------------------- */ namespace app\common\logic; use app\common\library\exception\OrderException; use think\Db; use think\Log; class Orders extends BaseLogic { /** * * 获取订单列表 * * @author 勇敢的小笨羊 * @param array $where * @param bool $field * @param string $order * @param int $paginate * @return mixed */ public function getOrderList($where = [], $field = true, $order = 'create_time desc', $paginate = 15) { $this->modelOrders->limit = !$paginate; return $this->modelOrders->getList($where, $field, $order, $paginate); } /** * 获取单总数 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @param $where * @return mixed */ public function getOrdersCount($where = []){ return $this->modelOrders->getCount($where); } /** * * 获取结算订单列表 * * @author 勇敢的小笨羊 * @param array $where * @param bool $field * @param string $order * @param int $paginate * @return mixed */ public function getOrderSettleList($where = [], $field = true, $order = 'create_time desc', $paginate = 15) { return $this->modelBalanceSettle->getList($where, $field, $order, $paginate); } /** * 订单统计 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @return array */ public function getOrdersAllStat(){ $order = 'create_time desc'; return [ 'fees' => $this->modelOrders->getInfo([],"sum(amount) as total,sum(if(status=2,amount,0)) as paid", $order, $paginate = false) ]; } /** * 获取控制台统计 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @return array */ public function getWelcomeStat(){ $order = 'create_time desc'; return [ 'order' => $this->modelOrders->getInfo([],"count(id) as total,count(if(status=2,true,null)) as success,count(if(status=1,true,null)) as wait,count(if(status=0,true,null)) as failed,sum(amount) as fees,sum(if(status=1,amount,0)) as unpaid,sum(if(status=2,amount,0)) as paid", $order, $paginate = false), 'user' => $this->modelUser->getInfo([],"count(uid) as total,count(if(is_verify=0,true,null)) as failed", $order, $paginate = false), 'cash' => $this->modelBalanceCash->getInfo([],'count(id) as total,count(if(status=1,true,null)) as success,count(if(status=0,true,null)) as failed', $order, $paginate = false) ]; } /** * 年月订单以及交易额统计 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * */ public function getOrdersMonthStat(){ $this->modelOrders->group = 'month'; return $this->modelOrders->getList([],"count(id) as total_orders,sum(`amount`) as total_amount,FROM_UNIXTIME(create_time,'%m') as month",false,false); } /** * 获取商户订单统计 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @param array $where * @param string $field * @param string $order * @param int $paginate * @return mixed */ public function getOrderUserStat($where = [],$field = "uid,count(uid) as total_orders,sum(amount) as total_fee_all,sum(if(status=1,amount,0)) as total_fee_dis,sum(if(status=2,amount,0)) as total_fee_paid",$order = 'create_time desc', $paginate = 15){ $this->modelOrders->group = 'uid'; return $this->modelOrders->getList($where,$field, $order, $paginate = false); } /** * 获取渠道订单统计 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @param array $where * @param string $field * @param string $order * @param int $paginate * @return mixed */ public function getOrderChannelStat($where = [],$field = "a.cnl_id,count(a.cnl_id) as total_orders,sum(a.amount) as total_fee_all,sum(if(a.status = 1,a.amount,0)) as total_fee_dis,sum(if(a.status = 2,a.amount,0)) as total_fee_paid,b.id,b.name,b.remarks,b.daily,b.rate",$order = 'a.create_time desc', $paginate = 15){ $this->modelOrders->group = 'a.cnl_id'; $this->modelOrders->alias('a'); $join = [ ['pay_channel b', ' b.id = a.cnl_id'], ]; $this->modelOrders->join = $join; return $this->modelOrders->getList($where,$field, $order, $paginate = false); } /** * 获取某订单支付通道配置 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @param $order_no * @return mixed */ public function getOrderPayConfig($order_no){ return $this->logicPay->getChannelParam( $this->modelOrders->getValue( ['trade_no'=>$order_no], 'cnl_id' ) )[1]; } /** * 设置某个字段参数 * * @author 勇敢的小笨羊 <brianwaring98@gmail.com> * * @param array $where * @param string $value */ public function setValue($where = [],$value = ''){ $this->modelOrders->setFieldValue($where, 'cnl_id', $value); } } ```