赛亿提成统计系统

Index.php 4.8KB

    <?php namespace app\index\controller; use daswork\Controller; use daswork\lib\Config; use app\index\model\MonthPicker; use app\index\model\Commission; use app\index\model\Company; use app\index\model\Sales; class Index extends Controller { public $maonth_picker; public $commission; public function __construct() { parent::__construct(); $this->maonth_picker = new MonthPicker(); $this->commission = new Commission(); } public function index() { $slect_time = isset($_GET['select_time']) ? $_GET['select_time'] : ''; if ($slect_time != '') { $this->maonth_picker->cur_month = $slect_time; } $this->assign('maonth_picker', $this->maonth_picker); $this->fetch(); // $sql = "select sel.id,sel.name,su.id as su_id,su.other_expenses,su.overdraft,su.remark,sel.department from seller sel left join summary su on sel.name = su.name and su.month='$maonth_picker->cur_month';"; // $data = $this->mydb->select($sql); // // var_dump($data); // // exit; // // 后勤 // $total_profit_all = 0; // $tp_all = 0; // $hq_rate = 0.05; // $hq_tp_rate = 0.002; // $hq_money_all = 0; // $hq_tp_money_all = 0; // // 郑总, 刘总 // // $ling_rate = 0.014; // $ling1 = [ // 'rate' => 0.014, // 'total_profit' => 0, // 'tp' => 0, // 'geren' => 0 // ]; // $ling2 = [ // 'rate' => 0.014, // 'total_profit' => 0, // 'tp' => 0, // 'geren' => 0 // ]; // $other_expenses_all = 0; // // 总计提成 // $all_money = 0; // for ($i = 0; $i < count($data); $i++) { // $value = $data[$i]; // $name = $value['name']; // $sql_total_profit = "select sum(amount*(price-base_price)-agency-shipping-project) as total_profit from commission where seller='$name' and month='$maonth_picker->cur_month' and type=0"; // // echo $sql_total_profit . "<br/>"; // $res_total_profit = $mydb->query($sql_total_profit)->fetchArray(SQLITE3_ASSOC); // $value['total_profit'] = $res_total_profit['total_profit']; // $value['g_rate'] = 0.25; // $value['g_money'] = ($value['total_profit'] - $value['other_expenses']) * $value['g_rate']; // // var_dump($value); // $sql_tepi1 = "select sum((amount*price-agency-shipping)*(CASE WHEN (price/base_price)<1.05 THEN 0.01 WHEN (price/base_price)<1.1 THEN 0.015 ELSE 0.02 END)) as tp1 from commission where seller='$name' and month='$maonth_picker->cur_month' and type=1"; // // echo $sql_tepi1 . '<br>'; // $res_tepi1 = $mydb->query($sql_tepi1)->fetchArray(SQLITE3_ASSOC); // // var_dump($res_tepi1); // // slqite3 整数乘 1.0 可强制使用浮点除法 php 调用是 报无 floor 函数 // // "select sum((amount*price-agency-shipping)*(floor((((price/base_price - 1) / 0.1) * 0.01 + 0.01) * 100)*1.0 / 100)) from commission where seller='$name' and month='$maonth_picker->cur_month' and type=2"; // $sql_tepi2 = "select amount,price,agency,shipping,base_price from commission where seller='$name' and month='$maonth_picker->cur_month' and type=2"; // // echo $sql_tepi2 . "<br/>"; // $res_tepi2 = $mydb->query($sql_tepi2); // $data_tepi2 = 0; // // var_dump($result);exit; // while ($arr = $res_tepi2->fetchArray(SQLITE3_ASSOC)) { // // var_dump($arr); // $data_tepi2 += ($arr['amount'] * $arr['price'] - $arr['agency'] - $arr['shipping']) * (floor(((($arr['price'] / $arr['base_price'] - 1) / 0.1) * 0.01 + 0.01) * 100) * 1.0 / 100); // } // $value['tepi'] = $res_tepi1['tp1'] + $data_tepi2; // $value['t_rate'] = 1; // $value['t_money'] = $value['tepi'] * $value['t_rate']; // $value['s_money'] = $value['g_money'] + $value['t_money'] + $value['overdraft']; // } } public function test() { $data = "test--dasdsd"; $this->assign('data', $data); $this->fetch(); } public function market() { $slect_time = isset($_GET['select_time']) ? $_GET['select_time'] : ''; if ($slect_time != '') { $this->maonth_picker->cur_month = $slect_time; } $this->assign('maonth_picker', $this->maonth_picker); $company = new Company(); $data_company = $company->listByName(); var_dump($data_company); } public function salesData() { $sales = new Sales(); echo json_encode(['code' => 0, 'data'=>$sales->data]); $sales->data = null; // 清空数据 } }