| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- /*
- * @description:
- * @Author: CP
- * @Date: 2021-01-21 10:54:21
- * @FilePath: \cld\protected\services\invoice_service.php
- */
- class invoice_service
- {
- private $invoiceTraining;
- private $invoice;
- private $invoiceItem;
- private $XDeode;
- function __construct()
- {
- Doo::loadClass('XDeode');
- $this->XDeode = new XDeode(9);
- $this->XDeode5 = new XDeode(5);
- Doo::loadModel('cld/invoice_training_cld');
- $this->invoiceTraining = new invoice_training_cld();
- Doo::loadModel('cld/invoice_cld');
- $this->invoice = new invoice_cld();
- Doo::loadModel('cld/invoice_item');
- $this->invoiceItem = new invoice_item();
- }
- // 获得发票项
- public function getInvoiceItem()
- {
- // 获得全部发票项
- $list = $this->invoiceItem->getAll();
- $data = array();
- foreach ($list as $value) {
- $item = $this->makeInvoiceItem($value);
- array_push($data, $item);
- }
- return $data;
- }
- /* 获得办事处和创建的 培训班发票 */
- public function getTrainByCategoryStaff($status, $categoryIdString, $staffId)
- {
- Doo::loadModel('staff');
- $staff = new staff();
- Doo::loadModel('L_category');
- $lCategory = new L_category();
- // 1.获得培训班
- $list = $this->invoiceTraining->getStatusByCategoryStaff($status, $categoryIdString, $staffId);
- // 2.获得培训班发票总数-
- foreach ($list as $key => $value) {
- $list[$key]['trainingKey'] = $this->XDeode5->encode($value['itid']);
- $detail = $staff->getStaffBySid($value['creator']);
- $list[$key]['staff'] = $detail;
- $detail = $lCategory->getCategoryById($value['cid']);
- $list[$key]['category'] = $detail;
- // 每个培训班发票总数和金额,入账总数
- $invoiceList = $this->invoice->GetTrainByUnFinish($value['itid']);
- $list[$key]['invoiceTotal'] = count($invoiceList);
- $priceTotle = 0;
- $BalancePriceTotle = 0;
- foreach ($invoiceList as $k => $v) {
- $priceTotle += $v['invoicePrice'];
- if ($v['status'] == 2 && $v['untreadStatus'] == 3) {
- $BalancePriceTotle += $v['invoiceBalance'];
- } else {
- $BalancePriceTotle += $v['invoicePrice'];
- }
- }
- $list[$key]['invoiceTotalAmount'] = $priceTotle;
- $list[$key]['invoiceArriveAmount'] = $priceTotle - $BalancePriceTotle;
- $list[$key]['arriveSchedule'] = 0;
- if ($list[$key]['invoiceTotal'] != 0) {
- $list[$key]['arriveSchedule'] = round($list[$key]['invoiceArriveAmount'] / $list[$key]['invoiceTotalAmount'] * 100, 2);
- }
- }
- return $list;
- // print_r ( $list );
- // die ();
- }
-
- private function makeInvoiceItem($data)
- {
- $resultData = array();
- if (!empty($data)) {
- $resultData = [
- 'id' => $this->XDeode->encode($data['id']),
- 'name' => $data['name'],
- 'rate' => $data['rate'],
- 'sort' => $data['sort'],
- ];
- }
-
- return $resultData;
- }
- }
|