多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 营业状况 >[info]功能: 1,显示数据:通过 `yf_shop_base` 门店表 显示门店 /* *@desc ajax列表页面数据处理 */ static function ajax_data_reset($data){ $payment_way = config('payment'); $arr = [ '商品销售'=>'wp_order,payid,good_price,ended,wp_order_return,goods_price', /*'会员充值'=>'wp_recharge,payment_way,money,created',*/ '现金收支'=>[ 'user_price', 'return_price' ], '总计'=>'wp_order', ]; foreach ($data as $v){ unset($new_data); $new_data['title'] = $title = $v->title; $new_data['first'] = "-"; $i = 0; $total = []; foreach($arr as $k1=>$relative){ //各种支付方式,对应的总数sum foreach($payment_way as $_k => $payid){ $new_data[$_k] = "-"; } $flag = false; switch ($k1) { case '商品销售': $flag = true; $xiao = $v->wp_order->sum('good_price') - $v->wp_order_return->sum('goods_price'); $new_data['first'] = __("销售额")." ".$xiao." ".__("订单数")." ".$v->wp_order->count(); break; /*case '会员充值': $flag = true; $new_data['first'] = __("充值")." ".$v->wp_recharge->sum('money'); break;*/ case '现金收支': $flag = false; $obj = $v->wp_order->where('payid',$payment_way['cash']); $a = $obj->sum('user_price'); $b = $obj->sum('return_price'); $new_data['first'] = __("收入")." ".$a ." ".__("支出")." ".$b; $new_data['cash'] = $obj->sum('good_price'); break; case '总计': $flag = true; $new_data['first'] = "-"; break; } if($flag === true){ if(strpos($relative,',')!==false){ $ex = explode(',', $relative); $orm = $ex[0]; $whereKey = $ex[1]; $sum = $ex[2]; //各种支付方式,对应的总数sum foreach($payment_way as $_k => $payid){ $new_data[$_k] = $v->$orm->where($whereKey,$payid)->sum($sum); } } } if($k1 == '总计'){ foreach($payment_way as $_k => $payid){ $new_data[$_k] = "-"; } } $output[$title][$k1] = (object)$new_data; $i++; } } return $output; } >[info] 2,通过支付方式 configs payment 文件 `wp_order` 订单表 和 `wp_order_return` 退货表计算 当天的营业情况 /** *@desc 订单 */ public function wp_order() { $start_time = request_data('start_time')?:date('Y-m-d 00:00:00', time()); $end_time = request_data('end_time')?:date('Y-m-d 23:59:59', time()); $end_time = ($end_time == $start_time)?date('Y-m-d 23:59:59', strtotime($end_time)):$end_time; return $this->hasMany('models\wp_order','shop_id') ->where('ended','>=',strtotime($start_time)) ->where('ended','<=',strtotime($end_time)) ->where('type','!=',1); } /** *@desc 订单 */ public function wp_order_return() { $start_time = request_data('start_time')?:date('Y-m-d 00:00:00', time()); $end_time = request_data('end_time')?:date('Y-m-d 23:59:59', time()); $end_time = ($end_time == $start_time)?date('Y-m-d 23:59:59', strtotime($end_time)):$end_time; return $this->hasMany('models\wp_order_return','shop_id') ->where('created','>=',strtotime($start_time)) ->where('created','<=',strtotime($end_time)) ->where('type','!=',1); }