model = new Model(); $this->order_goods_model = new OrderGoods(); $this->refund_order_model = new RefundOrder(); } /** * @author chenniang * @DataTime: 2021-03-15 14:43 * @功能说明:列表 */ public function orderList(){ $input = $this->_param; $dis[] = ['a.uniacid','=',$this->_uniacid]; //时间搜素 if(!empty($input['start_time'])&&!empty($input['end_time'])){ $start_time = $input['start_time']; $end_time = $input['end_time']; $dis[] = ['a.create_time','between',"$start_time,$end_time"]; } //商品名字搜索 if(!empty($input['goods_name'])){ $dis[] = ['b.goods_name','like','%'.$input['goods_name'].'%']; } //手机号搜索 if(!empty($input['mobile'])){ $dis[] = ['a.mobile','like','%'.$input['mobile'].'%']; } if(!empty($input['pay_type'])){ //订单状态搜索 $dis[] = ['a.pay_type','=',$input['pay_type']]; } //除开删除的 $dis[] = ['a.is_show','=',1]; if(!empty($input['order_code'])){ $dis[] = ['a.order_code','like','%'.$input['order_code'].'%']; } $data = $this->model->adminDataSelect($dis,$input['limit']); $name = '订单列表'; $header=[ '订单ID', '产品', '产品价格', '数量', '下单人', '手机号', // '服务项目费用', '实收金额', '系统订单号', '付款订单号', '下单时间', '支付方式', '状态', ]; $new_data = []; foreach ($data as $v){ $info = array(); $info[] = $v['id']; $info[] = $v['goods_name']; $info[] = $v['goods_price']; $info[] = $v['num']; $info[] = $v['nickName']; $info[] = $v['mobile']; // $info[] = $v['init_service_price']; $info[] = $v['pay_price']; $info[] = $v['order_code']; $info[] = $v['transaction_id']; $info[] = date('Y-m-d H:i:s',$v['create_time']); $info[] = !empty($v['balance'])?'余额支付':'微信支付'; $info[] = $this->orderStatusText($v['pay_type']); $new_data[] = $info; } $excel = new Excel(); $excel->excelExport($name,$header,$new_data,'',1); return $this->success($data); } /** * @author chenniang * @DataTime: 2021-03-30 16:32 * @功能说明: */ public function orderStatusText($status){ switch ($status){ case 1: return '待支付'; break; case 2: return '待签到'; break; case 3: return '待核销'; break; case 7: return '已完成'; break; case -1: return '已取消'; break; } } /** * @author chenniang * @DataTime: 2021-03-18 13:37 * @功能说明:财务数据统计导出 */ public function dateCount(){ $input = $this->_param; $cap_id = $input['cap_id']; $date_model = new Date(); $wallet_model = new Wallet(); $cap_model = new Cap(); $date_model->dataInit($this->_uniacid); $dis[] = ['uniacid','=',$this->_uniacid]; //时间搜素 if(!empty($input['start_time'])&&!empty($input['end_time'])){ $start_time = $input['start_time']; $end_time = $input['end_time']; $dis[] = ['date_str','between',"$start_time,$end_time"]; } $date_list = $date_model->dataList($dis,100000); //店铺名字 $store_name = $cap_model->where(['id'=>$cap_id])->value('store_name'); //开始时间结束时间 if(!empty($start_time)){ $date_list['start_time'] = $start_time; $date_list['end_time'] = $end_time; }else{ $date_list['start_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->min('date_str'); $date_list['end_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->max('date_str'); } if(!empty($date_list['data'])){ foreach ($date_list['data'] as $k=>$v){ //订单金额 $date_list['data'][$k]['order_price'] = $this->model->datePrice($v['date_str'],$this->_uniacid,$cap_id); //退款金额 $date_list['data'][$k]['refund_price'] = $this->refund_order_model->datePrice($v['date_str'],$this->_uniacid,$cap_id); //提现金额 $date_list['data'][$k]['wallet_price'] = $wallet_model->datePrice($v['date_str'],$this->_uniacid,$cap_id); } } $name = $store_name.'财务报表'; $header=[ '收支时间', '订单收入', '订单退款', '提现(元)', ]; $new_data = []; foreach ($date_list['data'] as $v){ $info = array(); $info[] = $v['date']; $info[] = $v['order_price']; $info[] = $v['refund_price']; $info[] = $v['wallet_price']; $new_data[] = $info; } $excel = new Excel(); $excel->excelExport($name,$header,$new_data); return $this->success($date_list); } }