shop_id=$result['storeId']?:Store::getMainStore($this->wqData['uniacid'])['id']; } //外卖概况 public function actionTakeOutIndex(){ $result=axios_request(); // print_R(getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[3]['startTime']),date("Y-m-d",$this->timeArr[3]['endTime'])));die; $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:0; $timeArr=$this->timeArr[$result['timeType']]; $data['allMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//总营业 $orderInfoMoney=Financial::getOrderInfoMoney($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//订单详情金额 $data['deliveryMoney']=$orderInfoMoney['deliveryMoney']?:0; $data['boxMoney']=$orderInfoMoney['boxMoney']?:0; $data['goodsMoney']=$orderInfoMoney['goodsMoney']?:0; $data['estimate']=Financial::getIncome($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//预计 $data['effective']=Financial::getEffective($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//有效 $data['commission']=bcsub($data['allMoney'],$data['estimate'],2);//佣金 $data['invalidCount']=Financial::getInvalidOrder($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId)['count']?:0;//无效订单 $data['invalidMoney']=Financial::getInvalidOrder($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId)['money']?:0;//无效金额 $data['unitPrice']=Financial::getUnitPrice($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId)?:0;//客单价 $beforeStartTime=$this->timeArr[3]['startTime']; $endTime=$this->timeArr[3]['endTime']; $data['allMoneyArr']=Financial::getTurnoverArr($beforeStartTime,$endTime,$uniacid,$storeId); $data['incomeArr']=Financial::getIncomeArr($beforeStartTime,$endTime,$uniacid,$storeId); $data['effectiveArr']=Financial::getEffectiveArr($beforeStartTime,$endTime,$uniacid,$storeId); $data['invalidArr']=Financial::getInvalidOrderArr($beforeStartTime,$endTime,$uniacid,$storeId); $data['weChat']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,1);//微信小程序 $data['ali']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,3);//支付宝小程序 $data['delivery']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,1);//外卖 $data['self']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,2);//自提 $data['weChatPay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,1);//微信支付 $data['aliPay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,2);//支付宝支付 $data['balancePay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,5);//余额支付 $data['onDelivery']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,10);//货到付款 $dataTime=getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[$result['timeType']]['startTime']),date("Y-m-d",$this->timeArr[$result['timeType']]['endTime'])); //print_R($dataTime);die; $data['timeArr']=Financial::getAllArr($dataTime,$uniacid,$storeId); return $this->result(1,'成功',$data); } //外卖支付概况 public function actionTakeOutIndexPay(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:0; $timeArr=$this->timeArr[$result['timeType']]; ////支付曲线//// $beforeStartTime=$this->timeArr[3]['startTime']; $endTime=$this->timeArr[3]['endTime']; $data['weChatPayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[1],[1]);//微信支付曲线 $data['aliPayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[1],[2]);//支付宝支付曲线 $data['balancePayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[1],[5]);//余额支付曲线 $data['onDeliveryArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[1],[10]);//货到付款支付曲线 ////支付曲线//// $data['all']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//总订单数 $data['weChatPay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,1);//微信支付 $data['aliPay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,2);//支付宝支付 $data['balancePay']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,5);//余额支付 $data['onDelivery']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,10);//货到付款 $data['delivery']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,1,1);//外卖 $data['self']=Financial::getEffectiveChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,2,1);//自提 $data['allMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[1]);//总支付金额 $data['weChatPayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[1],[1]);//微信支付金额 $data['aliPayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[1],[2]);//支付宝支付金额 $data['balancePayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[1],[5]);//余额支付金额 $data['onDeliveryMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[1],[10]);//货到付款支付金额 $data['weChatPayProportion']=bcmul(bcdiv($data['weChatPayMoney'],$data['allMoney'],4),100,2); $data['aliPayProportion']=bcmul(bcdiv($data['aliPayMoney'],$data['allMoney'],4),100,2); $data['balancePayProportion']=bcmul(bcdiv($data['balancePayMoney'],$data['allMoney'],4),100,2); $data['onDeliveryProportion']=bcmul(bcdiv($data['onDeliveryMoney'],$data['allMoney'],4),100,2); $dataTime=getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[$result['timeType']]['startTime']),date("Y-m-d",$this->timeArr[$result['timeType']]['endTime'])); //print_R($dataTime);die; $data['timeArr']=Financial::getOrderAllArr($dataTime,$uniacid,$storeId,[1]); return $this->result(1,'成功',$data); } public function actionTakeOutGood(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:0; $type=$result['type']?:1; ////支付曲线//// $beforeStartTime=$this->timeArr[$result['timeType']]['startTime']; $endTime=$this->timeArr[$result['timeType']]['endTime']; $data=Financial::getGoodArr($uniacid,$storeId,$type,1,$beforeStartTime,$endTime); return $this->result(1,'成功',$data); } //店内概况 public function actionInStoreIndex(){ $result=axios_request(); // print_R(getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[3]['startTime']),date("Y-m-d",$this->timeArr[3]['endTime'])));die; $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:0; $timeArr=$this->timeArr[$result['timeType']]; $data['allMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7]);//总营业 $data['fastMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6]);//快餐 $data['inStoreMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[7]);//堂食 $data['estimate']=Financial::getIncome($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7]);//预计 $data['effective']=Financial::getEffective($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7]);//有效 $data['commission']=bcsub($data['allMoney'],$data['estimate'],2);//佣金 $data['invalidCount']=Financial::getInvalidOrder($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7])['count']?:0;//无效订单 $data['invalidMoney']=Financial::getInvalidOrder($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7])['money']?:0;//无效金额 $data['unitPrice']=Financial::getUnitPrice($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7])?:0;//客单价 $beforeStartTime=$this->timeArr[3]['startTime']; $endTime=$this->timeArr[3]['endTime']; $data['allMoneyArr']=Financial::getTurnoverArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7]); $data['incomeArr']=Financial::getIncomeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7]); $data['effectiveArr']=Financial::getEffectiveArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7]); $data['invalidArr']=Financial::getInvalidOrderArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7]); $data['weChat']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,1);//微信小程序 $data['ali']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,3);//支付宝小程序 $data['syt']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,5);//外卖 $data['inStore']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,7);//堂食 $data['fast']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,6);//快餐 $data['weChatPay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,1);//微信支付 $data['aliPay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,2);//支付宝支付 $data['balancePay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,5);//余额支付 $data['cash']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,6);//现金 $data['have']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,7);//自有支付 $dataTime=getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[$result['timeType']]['startTime']),date("Y-m-d",$this->timeArr[$result['timeType']]['endTime'])); //print_R($dataTime);die; $data['timeArr']=Financial::getAllArr($dataTime,$uniacid,$storeId,2); return $this->result(1,'成功',$data); } //店内支付概况 public function actionInStoreIndexPay(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:0; $timeArr=$this->timeArr[$result['timeType']]; ////支付曲线//// $beforeStartTime=$this->timeArr[3]['startTime']; $endTime=$this->timeArr[3]['endTime']; $data['weChatPayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7],[1]); $data['aliPayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7],[2]); $data['balancePayArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7],[5]); $data['cashArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7],[6]); $data['haveArr']=Financial::getPayModeArr($beforeStartTime,$endTime,$uniacid,$storeId,[6,7],[7,8,9]); ////支付曲线//// $data['all']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId);//总订单数 $data['weChatPay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,1);//微信支付 $data['aliPay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,2);//支付宝支付 $data['balancePay']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,5);//余额支付 $data['cash']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,6);//现金 $data['have']=Financial::getEffectiveInStoreChannel($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,0,0,7);//自有支付 $data['inStore']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[7]);//堂食支付金额 $data['fast']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6]);//快餐支付金额 $data['allMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7]);//总支付金额 $data['weChatPayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7],[1]);//微信支付金额 $data['aliPayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7],[2]);//支付宝支付金额 $data['balancePayMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7],[5]);//余额支付金额 $data['cashMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7],[6]);//现价支付金额 $data['haveMoney']=Financial::getTurnover($timeArr['startTime'],$timeArr['endTime'],$uniacid,$storeId,[6,7],[7,8,9]);//自有支付金额 $data['weChatPayProportion']=bcmul(bcdiv($data['weChatPayMoney'],$data['allMoney'],2),100,2); $data['aliPayProportion']=bcmul(bcdiv($data['aliPayMoney'],$data['allMoney'],2),100,2); $data['balancePayProportion']=bcmul(bcdiv($data['balancePayMoney'],$data['allMoney'],2),100,2); $data['cashProportion']=bcmul(bcdiv($data['cashMoney'],$data['allMoney'],2),100,2); $data['haveProportion']=bcmul(bcdiv($data['haveMoney'],$data['allMoney'],2),100,2); $dataTime=getDatesBetweenTwoDays(date("Y-m-d",$this->timeArr[$result['timeType']]['startTime']),date("Y-m-d",$this->timeArr[$result['timeType']]['endTime'])); $data['timeArr']=Financial::getOrderAllArr($dataTime,$uniacid,$storeId,[6,7]); return $this->result(1,'成功',$data); } public function actionInstGood(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:$result['storeId']; $type=$result['type']?:1; $goodsType=2; ////支付曲线/// $beforeStartTime=$this->timeArr[$result['timeType']]['startTime']; $endTime=$this->timeArr[$result['timeType']]['endTime']; $data=Financial::getGoodArr($uniacid,$storeId,$type,$goodsType,$beforeStartTime,$endTime); return $this->result(1,'成功',$data); } //当面付概况 public function actionGetCashierData(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$this->shop_id?:$result['storeId']; ////支付曲线//// $beforeStartTime=$this->timeArr[$result['timeType']]['startTime']; $endTime=$this->timeArr[$result['timeType']]['endTime']; $data=Financial::getCashierData($uniacid,$storeId,$beforeStartTime,$endTime); return $this->result(1,'成功',$data); } //资产总览 public function actionAssetOverview(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$result['storeId']?:$this->shop_id; $res=StoreBill::getMerchantMoney($this->wqData['uniacid'],$storeId); $beforeStartTime=strtotime($result['startTime']);//$this->timeArr[4]['startTime']; $endTime=strtotime($result['endTime']) + 86399;//$this->timeArr[4]['endTime']; $res['allMoneyArr']=Financial::getTurnoverArr($beforeStartTime,$endTime,$uniacid,$storeId); $res['effectiveArr']=Financial::getEffectiveArr($beforeStartTime,$endTime,$uniacid,$storeId); return $this->result(1,'成功',$res); } public function actionGoodExport(){ $result=axios_request(); $uniacid=$this->wqData['uniacid']; $storeId=$result['storeId']?:$this->shop_id; $storeInfo=(new \yii\db\Query())->select('name')->from('{{%ybwm_store}}') ->where(['id'=>$storeId])->one(); $storeName=$storeInfo['name']; $type=$result['type']; $goodsType=$result['goodsType']?:1; if($goodsType==1){ $tableName='ybwm_takeout_order'; }else{ $tableName='ybwm_instore_order'; } ////支付曲线//// $stratTime=$this->timeArr[$result['timeType']]['startTime']; $endTime=$this->timeArr[$result['timeType']]['endTime']; $query=(new \yii\db\Query()) ->select('b.name,sum(a.num)num,(sum(a.num)*(a.money))money,a.money oldMoney,d.name categoryName') ->from('{{%ybwm_order_goods}} as a') ->leftJoin('{{%ybwm_core_goods}} as b','a.goodsId=b.id') ->leftJoin('{{%'.$tableName.'}} as c','a.orderId=c.id') ->leftJoin('{{%ybwm_core_category}} as d','b.typePid=d.id') ->where("a.uniacid=$uniacid AND a.storeId=$storeId") ->andwhere('a.createdAt>=:startTime AND a.createdAt<=:endTime',['startTime'=>$stratTime,'endTime'=>$endTime]) ->andWhere(['in','state',[2,3,4,5,6,9]]) ->groupBy('a.goodsId'); if($goodsType==1){ $query->andWhere(['in','state',[2,3,4,5,6,9]])->andWhere(['a.item'=>1]); }else{ $query->andWhere(['or',('a.item=2 and c.state in (3,4)'),('a.item=3 and c.state in (2,3,4,6,8)')]); //$query->andWhere(['in','a.item',[2,3]]); } if($type==1){ $query->orderBy('num desc'); } if($type==2){ $query->orderBy('money desc'); } //var_dump(ddSql($query));die; $data=$query->limit(100) ->all(); foreach ($data as $k=>$v){ $data[$k]=array( 'id'=>$k+1, 'categoryName'=>$v['categoryName'], 'name'=>$v['name'], 'num'=>$v['num'], 'money'=>$v['money'], ); } $title=array('排名','商品分类','商品名称','销量','销售额(元)'); $fileName=date('Y.m.d',$stratTime).'-'.date('Y.m.d',$endTime).'('.$storeName.')'; exportExcel($title, $data, $fileName, $savePath='./', $isDown=true); } }