'/index.php/Retail/AloneGuide/get_account_list', ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $this->display(); } /* 获取销售数据 */ public function get_sell_list() { $user = session('guide_userinfo'); if (!$user['id'] || !$user['storeid'] || !$user['guidename']) { $res['code'] = 0; $res['data'] = array(); $res['count'] = 0; $this->ajaxReturn($res); } $moneystate = I('get.moneystate'); /* 状态搜索 */ if ($moneystate) { $map['moneystate'] = $moneystate; } /* 时间搜索 */ $start = I('get.startdate'); $end = I('get.enddate'); if (!empty($start) && !empty($end)) { $startdate = strtotime(I('get.startdate')); $enddate = strtotime(I('get.enddate') . '23:59:59'); $map['paytime'] = array("between", "$startdate,$enddate"); } else if (!empty($start) && empty($end)) { $startdate = strtotime(I('get.startdate')); $map['paytime'] = array('gt', $startdate); } else if (empty($start) && !empty($end)) { $enddate = strtotime(I('get.enddate') . '23:59:59'); $map['paytime'] = array('lt', $enddate); } $map['storeid'] = $user['storeid']; $map['guideid'] = $user['id']; $map['paytype'] = array('in', array('1', '2', '3', '4', '5', '6', '7')); $sell_list = M('retail_guideincome')->where($map)->page((int)$_GET['page'], (int)$_GET['limit'])->order('paytime desc')->select(); $count = M('retail_guideincome')->where($map)->count(); $res = $this->statistics_money($map); foreach ($sell_list as $key => &$val) { $val['index'] = $key + 1; $val['guide_name'] = $user['guidename']; $val['paytime'] = date("Y-m-d H:i:s", $val['paytime']); $val['moneytime'] = $val['moneytime'] ? date('Y-m-d H:i:s', $val['moneytime']) : '未结算'; $val['auditname'] = $val['auditname'] ? $val['auditname'] : '未结算'; $val['auditnotes'] = $val['auditnotes'] ? $val['auditnotes'] : '-- --'; if ($val['vipid']) { $vip = M('retail_vip')->field('name,nickname')->where(array('id' => $val['vipid']))->find(); if ($vip['name']) { $val['vip_name'] = $vip['name']; } else if ($vip['nickname']) { $val['vip_name'] = $vip['nickname']; } else { $val['vip_name'] = '未设置'; } } else { $val['vip_name'] = '散客'; } switch ($val['paytype']) { case 1: $val['pay_name'] = '现金支付'; break; case 2: $val['pay_name'] = '银行卡支付'; break; case 3: $val['pay_name'] = '微信支付'; break; case 4: $val['pay_name'] = '支付宝支付'; break; case 5: $val['pay_name'] = '余额支付'; break; case 6: $val['pay_name'] = '微信支付'; break; case 7: $val['pay_name'] = '其他支付'; break; default: $val['pay_name'] = '其他支付'; } if ($val['moneystate'] == 1) { $val['money_state'] = '未提现'; } else if ($val['moneystate'] == 2) { $val['money_state'] = '待审核'; } else { $val['money_state'] = '已结算'; } /* 类型 */ if ($val['guidetype'] == 1) { $val['guide_type'] = '支付宝'; // 显示打款账号 $val['number'] = $user['paynumber']; } else if ($val['guidetype'] == 2) { $val['guide_type'] = '微信'; // 显示打款账号 $val['number'] = $user['chatnumber']; } else if ($val['guidetype'] == 3) { $val['guide_type'] = '银行卡'; $val['number'] = $user['cardnumber']; } else { $val['guide_type'] = '未结算'; $val['number'] = '未结算'; } } $res['code'] = 0; $res['data'] = $sell_list; $res['count'] = $count; $this->ajaxReturn($res); } public function settlement() { $this->display(); } public function getSettlement() { $user = session('guide_userinfo'); if (!$user['id'] || !$user['storeid'] || !$user['guidename']) { $res['code'] = 0; $res['data'] = array(); $res['count'] = 0; $this->ajaxReturn($res); } $map = array( 'g.storeid' => $user['storeid'], 'g.guideid' => $user['id'], 'g.paytype' => array('neq', 0), 'g.moneystate' => 1, 'g.income' => array('gt', 0), ); $account_list = M('retail_guideincome as g') ->join('ls_retail_bill_order as b on b.id=g.billid') ->join('ls_retail_bill_online as o on o.bill_id=b.id', 'LEFT') ->where($map) ->order('paytime desc') ->field('g.*,b.type,b.finish_time,b.refund_status,o.status,o.receiving_goods_time') ->select(); $refund_time_limit = M('retail_store')->where(array('id' => $user['storeid']))->getField('refund_time_limit'); $time = time(); foreach ($account_list as $key => &$val) { $val['index'] = $key + 1; $val['paytime'] = date("Y-m-d H:i:s", $val['paytime']); $val['guide_name'] = $user['guidename']; switch ($val['paytype']) { case 1: $val['pay_name'] = '现金支付'; break; case 2: $val['pay_name'] = '银行卡支付'; break; case 3: $val['pay_name'] = '微信支付'; break; case 4: $val['pay_name'] = '支付宝支付'; break; case 5: $val['pay_name'] = '余额支付'; break; case 6: $val['pay_name'] = '微信支付'; break; case 7: $val['pay_name'] = '其他支付'; break; default: $val['pay_name'] = '其他支付'; } if ($val['vipid']) { $vip = M('retail_vip')->field('name,nickname')->where(array('id' => $val['vipid']))->find(); if ($vip['name']) { $val['vip_name'] = $vip['name']; } else if ($vip['nickname']) { $val['vip_name'] = $vip['nickname']; } else { $val['vip_name'] = '未设置'; } } else { $val['vip_name'] = '散客'; } $val['can_cash'] = true; if ($val['type'] == 1 && $val['status'] != 3) { $val['can_cash'] = false; $val['status_msg'] = '用户未收货'; } else if ($val['type'] == 1 && ($val['receiving_goods_time'] + $refund_time_limit * 86400 - $time) > 0) { $val['can_cash'] = false; $val['status_msg'] = '用户收货' . $refund_time_limit . '天后才可提现'; } else if ($val['type'] == 2 && ($val['finish_time'] + $refund_time_limit * 86400 - $time) > 0) { $val['can_cash'] = false; $val['status_msg'] = '用户购买' . $refund_time_limit . '天后才可提现'; }else{ $val['status_msg'] = '可提现'; } $val['type_meg'] = $val['type'] == 1 ? '商城订单' : '店内订单'; } $res['status'] = 1; $res['list'] = $account_list; $res['msg'] = '获取成功'; $this->ajaxReturn($res); } /* 统计金额 */ public function statistics_money($map) { $sell_money = M('retail_guideincome')->where($map)->sum('allmoney'); $get_money = M('retail_guideincome')->where($map)->sum('income'); unset($map['paytype']); /* 现金支付 */ $map['paytype'] = 1; $xj = M('retail_guideincome')->where($map)->sum('allmoney'); /* 银行卡支付 */ $map['paytype'] = 2; $yhk = M('retail_guideincome')->where($map)->sum('allmoney'); /* 微信支付 */ $map['paytype'] = array('in', '3,6'); $wx = M('retail_guideincome')->where($map)->sum('allmoney'); /* 支付宝卡支付 */ $map['paytype'] = 4; $zfb = M('retail_guideincome')->where($map)->sum('allmoney'); /* 余额支付 */ $map['paytype'] = 5; $hyk = M('retail_guideincome')->where($map)->sum('allmoney'); /* 其他支付 */ $map['paytype'] = 7; $qt = M('retail_guideincome')->where($map)->sum('allmoney'); $res['sell_money'] = $sell_money ? round($sell_money, 2) . '(元)' : '0(元)'; $res['get_money'] = $get_money ? round($get_money, 2) . '(元)' : '0(元)'; $res['xj'] = $xj ? round($xj, 2) . '(元)' : '0(元)'; $res['yhk'] = $yhk ? round($yhk, 2) . '(元)' : '0(元)'; $res['wx'] = $wx ? round($wx, 2) . '(元)' : '0(元)'; $res['zfb'] = $zfb ? round($zfb, 2) . '(元)' : '0(元)'; $res['hyk'] = $hyk ? round($hyk, 2) . '(元)' : '0(元)'; $res['qt'] = $qt ? round($qt, 2) . '(元)' : '0(元)'; return $res; } /* 发起提现 */ public function settle_accounts() { $user = session('guide_userinfo'); $cash_id = I('post.cash_id'); $guidetype = I('post.guidetype'); if (!$user['id'] || !$user['storeid'] || !$cash_id || !$guidetype) { $res['status'] = 0; $res['msg'] = '参数缺失'; $this->ajaxReturn($res); } $save['guidetype'] = $guidetype; $save['moneytime'] = time(); $save['moneystate'] = 2; $map = array( 'g.storeid' => $user['storeid'], 'g.guideid' => $user['id'], 'g.paytype' => array('neq', 0), 'g.moneystate' => 1, 'g.income' => array('gt', 0), 'g.id' => array('in', $cash_id), ); $account_list = M('retail_guideincome as g') ->join('ls_retail_bill_order as b on b.id=g.billid') ->join('ls_retail_bill_online as o on o.bill_id=b.id', 'LEFT') ->where($map) ->order('paytime desc') ->field('g.id,b.type,b.finish_time,o.status,o.receiving_goods_time') ->select(); $refund_time_limit = M('retail_store')->where(array('id' => $user['storeid']))->getField('refund_time_limit'); $time = time(); $errorArr = array(); foreach ($account_list as $key => $val) { $flag = true; if ($val['type'] == 1 && $val['status'] != 3) { $flag = false; $error_msg = '第' . ($key + 1) . '条用户未收货,不可提现'; } else if ($val['type'] == 1 && ($val['receiving_goods_time'] + $refund_time_limit * 86400 - $time) > 0) { $flag = false; $error_msg = '第' . ($key + 1) . '条用户收货' . $refund_time_limit . '天后才可提现'; } else if ($val['type'] == 2 && ($val['finish_time'] + $refund_time_limit * 86400 - $time) > 0) { $flag = false; $error_msg = '第' . ($key + 1) . '条用户购买' . $refund_time_limit . '天后才可提现'; } if ($flag) { $save['moneystate'] = 2; $up = M('retail_guideincome')->where(array('id' => $val['id']))->save($save); if (!$up) { $errorArr[] = '第' . ($key + 1) . '条发起结算失败'; } } else { $errorArr[] = $error_msg; } } $res['status'] = 1; $res['errorData'] = $errorArr; $res['msg'] = '发起成功'; $this->ajaxReturn($res); } /* 记录 */ public function record() { $this->display(); } /* 记录列表 */ public function get_record_list() { $user = session('guide_userinfo'); if (!$user['id'] || !$user['storeid'] || !$user['guidename']) { $res['code'] = 0; $res['data'] = array(); $res['count'] = 0; $this->ajaxReturn($res); } $map['guideid'] = $user['id']; $map['storeid'] = $user['storeid']; $map['paytype'] = array('in', array('1', '2', '3', '4', '5', '6', '7')); $map['moneystate'] = array('in', '2,3'); /* 时间搜索条件 */ $start = I('get.startdate'); $end = I('get.enddate'); if (!empty($start) && !empty($end)) { $startdate = strtotime($start); $enddate = strtotime($end . '23:59:59'); $map['paytime'] = array("between", "$startdate,$enddate"); } else if (!empty($start) && empty($end)) { $startdate = strtotime($start); $map['paytime'] = array('gt', $startdate); } else if (empty($start) && !empty($end)) { $enddate = strtotime($end . '23:59:59'); $map['paytime'] = array('lt', $enddate); } $record_list = M('retail_guideincome')->where($map)->page((int)$_GET['page'], (int)$_GET['limit'])->order('moneytime desc')->select(); $count = M('retail_guideincome')->where($map)->count(); foreach ($record_list as $key => &$val) { $val['index'] = $key + 1; $val['guide_name'] = $user['guidename']; $val['paytime'] = date("Y-m-d H:i:s", $val['paytime']); $val['moneytime'] = $val['moneytime'] ? date('Y-m-d H:i:s', $val['moneytime']) : '未结算'; $val['auditname'] = $val['auditname'] ? $val['auditname'] : '未结算'; $val['auditnotes'] = $val['auditnotes'] ? $val['auditnotes'] : '-- --'; switch ($val['paytype']) { case 1: $val['pay_name'] = '现金支付'; break; case 2: $val['pay_name'] = '银行卡支付'; break; case 3: $val['pay_name'] = '微信支付'; break; case 4: $val['pay_name'] = '支付宝支付'; break; case 5: $val['pay_name'] = '余额支付'; break; case 6: $val['pay_name'] = '微信支付'; break; case 7: $val['pay_name'] = '其他支付'; break; default: $val['pay_name'] = '其他支付'; } if ($val['vipid']) { $vip = M('retail_vip')->field('name,nickname')->where(array('id' => $val['vipid']))->find(); if ($vip['name']) { $val['vip_name'] = $vip['name']; } else if ($vip['nickname']) { $val['vip_name'] = $vip['nickname']; } else { $val['vip_name'] = '未设置'; } } else { $val['vip_name'] = '散客'; } if ($val['moneystate'] == 1) { $val['money_state'] = '未提现'; } else if ($val['moneystate'] == 2) { $val['money_state'] = '待审核'; } else { $val['money_state'] = '已结算'; } if ($val['guidetype'] == 1) { $val['guide_type'] = '支付宝'; // 显示打款账号 $val['number'] = $user['paynumber']; } else if ($val['guidetype'] == 2) { $val['guide_type'] = '微信'; // 显示打款账号 $val['number'] = $user['chatnumber']; } else if ($val['guidetype'] == 3) { $val['guide_type'] = '银行卡'; $val['number'] = $user['cardnumber']; } else { $val['guide_type'] = '未结算'; $val['number'] = '未结算'; } } $res['code'] = 0; $res['data'] = $record_list; $res['count'] = $count; $this->ajaxReturn($res); } /* 修改密码 */ public function dochangepwd() { if (IS_POST) { $oldpass = I('post.oldpass'); $newpass = I('post.newpass'); $oldpass = strtolower($oldpass); $newpass = strtolower($newpass); $user = session('guide_userinfo'); $user = M('retail_guide')->where(array('id' => $user['id']))->find(); $CryptrModel = new \Addons\Api\Crypto (); $pass = $CryptrModel->encrypt($oldpass, date('YmdHis', $user['addtime'])); $pass_length = mb_strlen($pass, 'UTF8'); if ($pass_length > 32) { $pass = substr($pass, 0, 32); } if ($pass == $user['pass']) { $newpass = $CryptrModel->encrypt($newpass, date('YmdHis', $user['addtime'])); $save['pass'] = $newpass; $ret = M('retail_guide')->where(array('id' => $user['id']))->save($save); if ($ret) { $ret1 = D('JurisdictionUser')->updateUser(array('system_user_id' => $user['id'], 'user_type' => 5), $save); $rt['status'] = 1; $rt['msg'] = '修改成功,重新登录时请输入新密码'; } else { $rt['status'] = 0; $rt['msg'] = '修改失败'; } } else { $rt['status'] = 0; $rt['msg'] = '旧密码错误'; } $rt['get'] = I('get.'); $this->ajaxReturn($rt); } } /* 退出登录 */ Public function loginOut() { session('guide_userinfo', null); header('Location:' . U('/Retail/Login/index')); } //显示数据表 public function gettakeindex() { $user = session('guide_userinfo'); $startdate = I('get.startdate'); $enddate = I('get.enddate'); // 日期搜索 if (!empty($startdate) && !empty($enddate)) { $startdate = strtotime(I('get.startdate')); $enddate = strtotime(I('get.enddate') . '23:59:59'); $where['paytime'] = array("between", "$startdate,$enddate"); } $where['guideid'] = $user['id']; $where['storeid'] = $user['storeid']; $superinfo = M('retail_guideincome')->where($where)->page((int)$_GET['page'], (int)$_GET['limit'])->order('paytime desc')->select(); $count = M('retail_guideincome')->where($where)->count(); // 实例化导购表 $retail_guide = M('retail_guide'); // 实例化会员表 $vip = M('retail_vip'); if ($superinfo) { foreach ($superinfo as $key => &$val) { //显示时间 $val['paytime'] = date('Y-m-d H:i:s', $val['paytime']); if (empty($val['moneytime'])) { $val['moneytime'] = '-- --'; } else { $val['moneytime'] = date('Y-m-d H:i:s', $val['moneytime']); } // 显示导购员名称 $guide_res = $retail_guide->find($val['guideid']); $val['guideid'] = $guide_res['guidename']; // 显示提现状态 if ($val['moneystate'] == 1) { $val['moneystate'] = '未提现'; } else if ($val['moneystate'] == 2) { $val['moneystate'] = '待处理'; } else { $val['moneystate'] = '已提现'; } $val['commission'] = $val['commission'] . '%'; // 显示会员名称 $vip_res = $vip->where(array('id' => $val['vipid']))->find(); if (!empty($vip_res)) { if (!empty($vip_res['name'])) { $val['vipid'] = $vip_res['name']; } else if (!empty($vip_res['nickname'])) { $val['vipid'] = $vip_res['nickname']; } else { $val['vipid'] = '未设置'; } } else { $val['vipid'] = '非会员'; } } } $res['code'] = 0; $res['msg'] = ''; $res['data'] = $superinfo; $res['count'] = $count; $this->ajaxReturn($res); } //按时间条件查询 public function detailsquery() { $guide_userinfo = session('guide_userinfo'); $commission = $guide_userinfo['commission'] / 100; $start = I('post.startdate'); $end = I('post.enddate'); if (!empty($start) && !empty($end)) { $res['status'] = 1; $startdate = strtotime(I('post.startdate')); $enddate = strtotime(I('post.enddate') . '23:59:59'); $where['storeid'] = $guide_userinfo['storeid']; $where['paytype'] = array('in', array('1', '2', '3', '4', '5', '6', '7')); $where['guideid'] = $guide_userinfo['id']; $where['addtime'] = array("between", "$startdate,$enddate"); $sum = M('retail_guideincome')->where($where)->sum('allmoney'); if (!empty($sum)) { $res['allsum'] = $sum; $res['sum'] = $sum * $commission; } else { $res['allsum'] = '0.00'; $res['sum'] = '0.00'; } $where['moneystate'] = 1; $suresum = M('retail_guideincome')->where($where)->sum('allmoney'); if (!empty($suresum)) { $res['suresum'] = $suresum * $commission; } else { $res['suresum'] = '0.00'; } //微信 $where['moneystate'] = 3; $cannotsum = M('retail_guideincome')->where($where)->sum('allmoney'); if (!empty($cannotsum)) { $res['cannotsum'] = $cannotsum * $commission; } else { $res['cannotsum'] = '0.00'; } } else { $res['status'] = 0; } $this->ajaxReturn($res); } //首页展示 public function home_old() { $user = session('guide_userinfo'); $id = $user['id']; $storeid = $user['storeid']; //实例化 $retail_guideincome = M('retail_guideincome'); // 总额 $allsum = $retail_guideincome->where(array('guideid' => $id, 'storeid' => $storeid))->sum('allmoney'); if (empty($allsum)) { $allsum = '0.00'; } $sum = $retail_guideincome->where(array('guideid' => $id, 'storeid' => $storeid))->sum('income'); if (empty($sum)) { $sum = '0.00'; } $where['guideid'] = $id; $where['storeid'] = $storeid; $where['moneystate'] = array('in', array('1', '2')); $suresum = $retail_guideincome->where($where)->sum('income'); if (empty($suresum)) { $suresum = '0.00'; } $cannotsum = $retail_guideincome->where(array('guideid' => $id, 'storeid' => $storeid, 'moneystate' => 3))->sum('income'); if (empty($cannotsum)) { $cannotsum = '0.00'; } // 统计归属会员数 $count = M('retail_vip')->where(array('guideid' => $id, 'status' => 1))->count(); $this->assign('count', $count); $this->assign('allsum', $allsum); $this->assign('suresum', $suresum); $this->assign('cannotsum', $cannotsum); $this->assign('sum', $sum); $this->display(); } //提现页面 public function extract() { $this->display(); } //提现数据表 public function getextract() { $guide_userinfo = session('guide_userinfo'); $where['guideid'] = $guide_userinfo['id']; $where['storeid'] = $guide_userinfo['storeid']; $where['moneystate'] = 1; $superinfo = M('retail_guideincome')->where($where)->page((int)$_GET['page'], (int)$_GET['limit'])->order('paytime desc')->select(); $count = M('retail_guideincome')->where($where)->count(); // 实例化导购表 $retail_guide = M('retail_guide'); // 实例化会员表 $vip = M('retail_vip'); if ($superinfo) { foreach ($superinfo as $key => &$val) { //显示时间 $val['paytime'] = date('Y-m-d H:i:s', $val['paytime']); // 显示导购员名称 $guide_res = $retail_guide->find($val['guideid']); $val['guideid'] = $guide_res['guidename']; // 显示会员名称 $vip_res = $vip->where(array('id' => $val['vipid']))->find(); if ($vip_res) { if (!empty($vip_res['name'])) { $val['vipid'] = $vip_res['name']; } else if (!empty($vip_res['nickname'])) { $val['vipid'] = $vip_res['nickname']; } else { $val['vipid'] = '未设置'; } } else { $val['vipid'] = '非会员'; } } } $res['code'] = 0; $res['msg'] = ''; $res['data'] = $superinfo; $res['count'] = $count; $this->ajaxReturn($res); } public function record_old() { $this->display(); } public function getrecord() { $user = session('guide_userinfo'); $where['guideid'] = $user['id']; $where['storeid'] = $user['storeid']; $where['moneystate'] = 3; $start = I('get.startdate'); $end = I('get.enddate'); // 日期搜索 if (!empty($start) && !empty($end)) { $startdate = strtotime(I('get.startdate')); $enddate = strtotime(I('get.enddate') . '23:59:59'); $where['moneytime'] = array("between", "$startdate,$enddate"); } $superinfo = M('retail_guideincome')->where($where)->page((int)$_GET['page'], (int)$_GET['limit'])->order('paytime desc')->select(); $count = M('retail_guideincome')->where($where)->count(); // 实例化导购表 $retail_guide = M('retail_guide'); // $guide_res = $retail_guide->find($val['guideid']); // 实例化会员表 $vip = M('retail_vip'); if ($superinfo) { foreach ($superinfo as $key => &$val) { //显示时间 $val['paytime'] = date('Y-m-d H:i:s', $val['paytime']); if (empty($val['moneytime'])) { $val['moneytime'] = '-- --'; } else { $val['moneytime'] = date('Y-m-d H:i:s', $val['moneytime']); } // 显示导购员名称 $guide_res = $retail_guide->find($val['guideid']); $val['guideid'] = $guide_res['guidename']; // 显示提现状态 if ($val['moneystate'] == 1) { $val['moneystate'] = '未提现'; } else if ($val['moneystate'] == 2) { $val['moneystate'] = '待处理'; } else { $val['moneystate'] = '已提现'; } // 显示会员名称 $vip_res = $vip->where(array('id' => $val['vipid']))->find(); if ($vip_res) { if (!empty($vip_res['name'])) { $val['vipid'] = $vip_res['name']; } else if (!empty($vip_res['nickname'])) { $val['vipid'] = $vip_res['nickname']; } else { $val['vipid'] = '未设置'; } } else { $val['vipid'] = '非会员'; } // 显示审核人 if (empty($val['auditname'])) { $val['auditname'] = '-- --'; } // 显示审核内容 if (empty($val['auditnotes'])) { $val['auditnotes'] = '-- --'; } // 显示打款类型 if ($val['guidetype'] == 1) { $val['guidetype'] = '支付宝'; // 显示打款账号 $val['number'] = $user['paynumber']; } else if ($val['guidetype'] == 2) { $val['guidetype'] = '微信'; // 显示打款账号 $val['number'] = $user['chatnumber']; } } } $res['code'] = 0; $res['msg'] = ''; $res['data'] = $superinfo; $res['count'] = $count; $this->ajaxReturn($res); } public function tax() { $guidetype = I('post.guidetype'); $id = explode(',', I('post.id')); $where['id'] = array('in', $id); $data['moneytime'] = time(); $data['moneystate'] = 2; $data['guidetype'] = $guidetype; $tax_res = M('retail_guideincome')->where($where)->save($data); if (!empty($tax_res)) { $res['status'] = 1; $res['msg'] = '提交成功,等待处理'; } else { $res['status'] = 0; $res['msg'] = '提交失败'; } $this->ajaxReturn($res); } // 查看所属会员名称 public function vip() { $user = session('guide_userinfo'); $id = $user['id']; $map['id'] = $id; $vip = M('retail_vip')->where(array('guideid' => $id, 'status' => 1))->select(); $this->assign('vip', $vip); $this->display(); } }