153 行
5.8 KiB
PHP
可执行文件
153 行
5.8 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Vip\Controller;
|
||
|
||
use Think\Controller;
|
||
//[1.4.13]
|
||
class EstatementsController extends BaseController
|
||
{
|
||
/* 加载模板 */
|
||
public function index()
|
||
{
|
||
$userInfo = session('userinfo');
|
||
if($userInfo['style_model']==2){
|
||
$this->display('index2');
|
||
}else if($userInfo['style_model']==3){
|
||
$this->display('index3');
|
||
}else{
|
||
$this->display();
|
||
}
|
||
}
|
||
|
||
/* 获取充值消费金额 */
|
||
public function get_money_statistics()
|
||
{
|
||
$vid = session('vid');
|
||
$where['vid'] = $vid;
|
||
$where['state'] = 1;
|
||
$where['status'] = 1;
|
||
$where['type'] = array('in','1,3,5,6');
|
||
/* 统计充值金额 */
|
||
$sum = D('RechargeOrder')->getSum($where,'all_money');
|
||
/* 统计消费金额 */
|
||
$where['type'] = array('in','2,4');
|
||
$less = D('RechargeOrder')->getSum($where,'all_money');
|
||
$userInfo = session('userinfo');
|
||
$res['balance'] = $userInfo['balance'];
|
||
$res['sum'] = $sum ? round($sum,2) : 0;
|
||
$res['less'] = $less ? round($less,2) : 0;
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/* 获取记录 */
|
||
public function get_recharge_order_list()
|
||
{
|
||
$page = I('post.page');
|
||
$limit = I('post.limit');
|
||
$order_lists = I('post.order_lists') ? I('post.order_lists') : array();
|
||
if(!$page || !$limit){
|
||
$res['status'] = 0;
|
||
$res['msg'] = '参数缺失';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$vid = session('vid');
|
||
$where['vid'] = $vid;
|
||
$where['state'] = 1;
|
||
$where['status'] = 1;
|
||
$order_list = D('RechargeOrder')->getSelect_v1($where,'*','add_time desc',$page,$limit);
|
||
if(!$order_list){
|
||
$res['status'] = 1;
|
||
$res['msg'] = '无更多数据';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
foreach ($order_list as &$val){
|
||
array_push($order_lists,$val);
|
||
}
|
||
if(!$order_lists){
|
||
$res['status'] = 0;
|
||
$res['msg'] = '暂无记录';
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$list = array();
|
||
foreach ($order_lists as $keyword=>&$value){
|
||
$value['timeymd'] = date('Y-m-d',$value['add_time']);
|
||
$value['timedetail'] = date('H:i:s',$value['add_time']);
|
||
$day_data = $value['timeymd'];
|
||
if(array_key_exists($day_data,$list)){
|
||
array_push($list[$day_data]['list'],$value);
|
||
}else{
|
||
$list[$day_data]['list'] = array();
|
||
$list[$day_data]['show'] = true;
|
||
array_push($list[$day_data]['list'],$value);
|
||
}
|
||
}
|
||
$res['status'] = 2;
|
||
$res['msg'] = '查询成功';
|
||
$res['list'] = $list;
|
||
$res['order_lists'] = $order_lists;
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
/**
|
||
* 获取商品列表
|
||
* @param [int] $bill_id bill表id
|
||
* @return [array] $res
|
||
*/
|
||
public function get_goods_list()
|
||
{
|
||
// 接受订单id
|
||
$bill_id = I('post.bill_id');
|
||
if(!$bill_id){
|
||
$res = array('status'=>0,'msg'=>'参数缺失');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
// 查询bill_order数据
|
||
$RBOModel = D('RetailBillOrder');
|
||
$field = array($RBOModel::ALL_MONEY,$RBOModel::TYPE,$RBOModel::ADD_TIME,$RBOModel::STORE_ID,$RBOModel::MERCHANT_ID,$RBOModel::ORDER_NO);
|
||
$bill = $RBOModel->getFind(array($RBOModel::ID => $bill_id),$field);
|
||
if(!$bill){
|
||
$res = array('status'=>0,'msg'=>'查询失败');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
// 查询销售数据(sell)
|
||
$RSellModel = D('RetailSell');
|
||
$field2 = array($RSellModel::ALL_MONEY,$RSellModel::NUM,$RSellModel::GOODS_NAME,$RSellModel::ORIGINAL_PRICE,$RSellModel::VIP_PRICE,$RSellModel::SKU_JSON_INFO);
|
||
$sell_list = $RSellModel->getSelect(array($RSellModel::BILL_ID => $bill_id),$field2);
|
||
if(!$sell_list){
|
||
$res = array('status'=>0,'msg'=>'暂无销售数据');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$RSLModel = D('RetailSkuList'); // 规格模型
|
||
foreach ($sell_list as &$val){
|
||
// 判断会员价
|
||
if($val[$RSellModel::VIP_PRICE] && $val[$RSellModel::VIP_PRICE] > 0){
|
||
$val['money'] = floatval(round($val[$RSellModel::VIP_PRICE] * $val[$RSellModel::NUM],2));
|
||
}else{
|
||
$val['money'] = floatval(round($val[$RSellModel::ORIGINAL_PRICE] * $val[$RSellModel::NUM],2));
|
||
}
|
||
$val[$RSellModel::NUM] = floatval($val[$RSellModel::NUM]);
|
||
$val[$RSellModel::GOODS_NAME] = $val[$RSellModel::GOODS_NAME] ? $val[$RSellModel::GOODS_NAME] : '无码商品';
|
||
if($val[$RSellModel::SKU_JSON_INFO]){
|
||
$sku = json_decode($val[$RSellModel::SKU_JSON_INFO],true);
|
||
// 规格名称
|
||
$sku_name = $RSLModel->getFindField(array($RSLModel::ID => array('in',$sku['sku_id_list'])),$RSLModel::NAME,true);
|
||
$val[$RSellModel::GOODS_NAME] = $val[$RSellModel::GOODS_NAME] . '(' . implode(',', $sku_name) . ')';
|
||
}
|
||
}
|
||
// 获取门店
|
||
$RSModel = D('RetailStore');
|
||
$store_name = $RSModel->getFindField(array($RSModel::ID => $bill[$RBOModel::STORE_ID]),$RSModel::STORE_NAME);
|
||
$res = array(
|
||
'status' => 1,
|
||
'order_data' => array(
|
||
'order_no' => $bill[$RBOModel::ORDER_NO],
|
||
'store_name' => $store_name,
|
||
'sell_scene' => $bill['type'] == 1 ? '商城' : '店内',
|
||
'sell_money' => $bill['all_money'],
|
||
'sell_time' => date('Y-m-d H:i:s',$bill['add_time']),
|
||
),
|
||
'sell_list' => $sell_list
|
||
);
|
||
$this->ajaxReturn($res);
|
||
}
|
||
} |