12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /**
- * 订单日志
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/12/3
- * Time: 14:25
- */
- namespace JinDouYun\Model\Log;
- use JinDouYun\Dao\Customer\DCustomer;
- use JinDouYun\Dao\Log\DOrderLog;
- class MOrderLog
- {
- private $objDOrderLog;
- private $enterpriseId;
- /**
- * MOrderLog constructor.
- * @param $enterpriseId
- * @throws \Exception
- */
- public function __construct($enterpriseId)
- {
- $this->enterpriseId = $enterpriseId;
- $this->objDOrderLog = new DOrderLog('log');
- $this->objDOrderLog->setTable($this->objDOrderLog->get_Table() . '_' . date('Y') . '_' . ceil(date('m') / 3));
- }
- /**
- * @param $selectParams
- * @return array
- * @throws \Exception
- */
- public function getOrderLog($selectParams)
- {
- $dbResult = $this->objDOrderLog->select($selectParams, '*', 'createTime DESC');
- if ($dbResult === false) {
- return [];
- }
- $map = [];
- $allUserCenterIds = array_column($dbResult,'userCenterId');
- if (!empty($allUserCenterIds)){
- $objDCustomer = new DCustomer();
- $objDCustomer->setTable('qianniao_customer_'.$this->enterpriseId);
- $list = $objDCustomer->select(['userCenterId' => $allUserCenterIds],'userCenterId,name');
- if ($list !== false){
- foreach ($list as $value){
- $map[$value['userCenterId']] = $value['name'];
- }
- }
- }
- $allOrderLog = [];
- foreach ($dbResult as $key => &$val) {
- $val['userName'] = isset($map[$val['userCenterId']]) ? $map[$val['userCenterId']] : '';
- $allOrderLog[$val['no']][] = $val;
- }
- return $allOrderLog;
- }
- }
|