MOrderLog.Class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * 订单日志
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/12/3
  7. * Time: 14:25
  8. */
  9. namespace JinDouYun\Model\Log;
  10. use JinDouYun\Dao\Customer\DCustomer;
  11. use JinDouYun\Dao\Log\DOrderLog;
  12. class MOrderLog
  13. {
  14. private $objDOrderLog;
  15. private $enterpriseId;
  16. /**
  17. * MOrderLog constructor.
  18. * @param $enterpriseId
  19. * @throws \Exception
  20. */
  21. public function __construct($enterpriseId)
  22. {
  23. $this->enterpriseId = $enterpriseId;
  24. $this->objDOrderLog = new DOrderLog('log');
  25. $this->objDOrderLog->setTable($this->objDOrderLog->get_Table() . '_' . date('Y') . '_' . ceil(date('m') / 3));
  26. }
  27. /**
  28. * @param $selectParams
  29. * @return array
  30. * @throws \Exception
  31. */
  32. public function getOrderLog($selectParams)
  33. {
  34. $dbResult = $this->objDOrderLog->select($selectParams, '*', 'createTime DESC');
  35. if ($dbResult === false) {
  36. return [];
  37. }
  38. $map = [];
  39. $allUserCenterIds = array_column($dbResult,'userCenterId');
  40. if (!empty($allUserCenterIds)){
  41. $objDCustomer = new DCustomer();
  42. $objDCustomer->setTable('qianniao_customer_'.$this->enterpriseId);
  43. $list = $objDCustomer->select(['userCenterId' => $allUserCenterIds],'userCenterId,name');
  44. if ($list !== false){
  45. foreach ($list as $value){
  46. $map[$value['userCenterId']] = $value['name'];
  47. }
  48. }
  49. }
  50. $allOrderLog = [];
  51. foreach ($dbResult as $key => &$val) {
  52. $val['userName'] = isset($map[$val['userCenterId']]) ? $map[$val['userCenterId']] : '';
  53. $allOrderLog[$val['no']][] = $val;
  54. }
  55. return $allOrderLog;
  56. }
  57. }