objMCustomer = new MCustomer($this->onlineEnterpriseId, $this->onlineUserId); $this->objMCustomerSource = new MCustomerSource($this->onlineEnterpriseId); $this->objMGoodsCollect = new MGoodsCollect($this->onlineEnterpriseId, $this->onlineUserId); $this->objMCustomerDemand = new MCustomerDemand($this->onlineEnterpriseId, $this->onlineUserId); $this->objMCustomerVisitsLog = new MCustomerVisitsLog($this->onlineEnterpriseId, $this->onlineUserId); $this->objMMemberBalanceDetail = new MMemberBalanceDetail($this->onlineEnterpriseId, $this->onlineUserId); $this->objMReflectDetail = new MReflectDetail($this->onlineEnterpriseId, $this->onlineUserId); $this->objMCustomerBalanceDetail = new MCustomerBalanceDetail($this->onlineEnterpriseId, $this->onlineUserId); $this->agentTool = new AgentTools($this->onlineEnterpriseId); // $this->customerData = $this->agentTool->getCustomerDataByUserCenterId($this->onlineUserId); } /** * 添加和编辑客户管理公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $customerData = [ 'name' => isset($params['name']) ? $params['name'] : '', 'contact' => isset($params['contact']) ? $params['contact'] : '', 'provinceCode' => isset($params['provinceCode']) ? $params['provinceCode'] : '', 'cityCode' => isset($params['cityCode']) ? $params['cityCode'] : '', 'districtCode' => isset($params['districtCode']) ? $params['districtCode'] : '', ]; foreach ($customerData as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $customerData['type'] = isset($params['type']) ? $params['type'] : ''; $customerData['recommenderType'] = isset($params['recommenderType']) ? $params['recommenderType'] : ''; $customerData['recommenderId'] = isset($params['recommenderId']) ? $params['recommenderId'] : ''; $customerData['longitude'] = isset($params['longitude']) ? $params['longitude'] : 0;//经度 $customerData['latitude'] = isset($params['latitude']) ? $params['latitude'] : 0;//纬度 $customerData['avatar'] = isset($params['avatar']) ? $params['avatar'] : ''; $customerData['birthday'] = isset($params['birthday']) ? $params['birthday'] : ''; $customerData['remark'] = isset($params['remark']) ? $params['remark'] : ''; $customerData['extend'] = isset($params['extend']) ? json_encode($params['extend']) : ''; $customerData['address'] = getArrayItem($params, 'address', ''); $customerData['updateTime'] = time(); return $customerData; } /** * 修改当前客户信息 */ public function editCustomerInfo() { $customerData = $this->commonFieldFilter(); $customerData['userCenterId'] = $this->onlineUserId; $result = $this->objMCustomer->editCustomerInfo($customerData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取当前的客户信息 */ public function getCustomerInfo() { $customerData = $this->objMCustomer->getCustomerInfoByUserCenterId($this->onlineUserId, true); if ($customerData->isSuccess()) { $customerInfo = $customerData->getData(); $agentData = $this->agentTool->getAndSetAgentData($customerInfo["id"]); $customerInfo["agentId"] = empty($agentData) ? 0 : $agentData["id"]; $this->sendOutput($customerInfo); } else { $this->sendOutput($customerData->getData(), ErrorCode::$contentNotExists); } } /** * 完善资料获取客户类型 */ public function getCustomerSourceList() { $result = $this->objMCustomerSource->getCustomerSourceList(); if ($result->isSuccess()) { $returnData = $result->getData(); parent::sendOutput($returnData); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 收藏商品 * @throws Exception */ public function collect() { $goodsId = $this->request->param('request_id'); if (!$goodsId) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMGoodsCollect->addGoodsCollect($goodsId); if ($result->isSuccess()) { $this->sendOutput($result->getData()); } $this->sendOutput($result->getData(), $result->getErrorCode()); } /** * 充值余额 * @throws Exception */ public function rechargeBalance() { $params = $this->request->getRawJson(); $data['money'] = isset($params['money']) ? $params['money'] : ''; foreach ($data as $key => $value) { if (empty($value)) { parent::sendOutput($key . '参数错误', ErrorCode::$paramError); } } $data['userCenterId'] = $this->onlineUserId; $data['id'] = $this->request->get_onlineip(); $result = $this->objMCustomer->rechargeBalance($data); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 充值记录列表 */ public function getAllRechargeBalance() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams['shopId'] = isset($params['shopId']) ? $params['shopId'] : ''; foreach ($selectParams as $key => $value) { if (empty($value)) { parent::sendOutput($key . '参数错误', ErrorCode::$paramError); } } $params['page'] = isset($params['page']) ? $params['page'] : 1; $params['pageSize'] = isset($params['pageSize']) ? $params['pageSize'] : 10; $pageParams = pageToOffset($params['page'], $params['pageSize']); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $selectParams['userCenterId'] = $this->onlineUserId; $modelResult = $this->objMCustomer->getAllRechargeBalance($selectParams); if (!$modelResult->isSuccess()) { parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } $returnData = $modelResult->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } /** * 添加客户需求 */ public function addCustomerdemand() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $demandData = [ 'enterpriseId' => $this->onlineEnterpriseId, 'customerId' => getArrayItem($params, 'customerId'), 'demand' => getArrayItem($params, 'demand'), ]; $demandData['updateTime'] = time(); $result = $this->objMCustomerDemand->addCustomerdemand($demandData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 添加客户访问记录 */ public function addCustomerVisitsLog() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $visitsLogData = [ 'usercenterid' => getArrayItem($params, 'usercenterid'), 'customerid' => getArrayItem($params, 'customerid'), 'shopid' => getArrayItem($params, 'shopid'), 'goodsid' => getArrayItem($params, 'goodsid'), ]; $visitsLogData['updateTime'] = time(); $result = $this->objMCustomerVisitsLog->addCustomerVisitsLog($visitsLogData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 添加余额支付密码 */ public function addpayPassword() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $payPasswordData = [ 'enterpriseId' => $this->onlineEnterpriseId, 'id' => getArrayItem($params, 'id'), 'payPassword' => getArrayItem($params, 'payPassword'), ]; foreach ($payPasswordData as $key => $value) { if (empty($value)) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $payPasswordData['updateTime'] = time(); //密码格式化; $payPasswordData['payPassword'] = password_hash($payPasswordData['payPassword'], PASSWORD_DEFAULT); $result = $this->objMCustomer->addpayPassword($payPasswordData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 修改余额支付密码 */ public function updatePayPassword() { $params = $this->request->getRawJson(); if (!$params) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $updatePayPasswordData = [ 'enterpriseId' => $this->onlineEnterpriseId, 'id' => getArrayItem($params, 'id'), 'payPassword' => trim(getArrayItem($params, 'payPassword')), ]; foreach ($updatePayPasswordData as $key => $value) { if (empty($value)) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $updatePayPasswordData['updateTime'] = time(); $updatePayPasswordData['payPassword'] = password_hash($updatePayPasswordData['payPassword'], PASSWORD_DEFAULT); $result = $this->objMCustomer->updatePayPassword($updatePayPasswordData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 校验余额支付密码 */ public function checkPayPassword() { $params = $this->request->getRawJson(); if (!$params) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $checkPayPasswordData = [ 'enterpriseId' => $this->onlineEnterpriseId, 'id' => getArrayItem($params, 'id'), 'payPassword' => trim(getArrayItem($params, 'payPassword')), ]; foreach ($checkPayPasswordData as $key => $value) { if (empty($value)) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $result = $this->objMCustomer->checkPayPassword($checkPayPasswordData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取所有的明细 */ public function getAllMemberBalanceDetail() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $params['userCenterId'] = $this->onlineUserId; $params['customerId'] = getArrayItem($params, 'customerId', ''); $returnData = $this->objMMemberBalanceDetail->getAllMemberBalanceDetail($params); if ($returnData->isSuccess()) { $returnData = $returnData->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($returnData->getData(), ErrorCode::$dberror); } } /** * 申请提现 */ public function addReflectDetail() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $ReflectDetailDate = [ 'customerId' => getArrayItem($params, 'customerId', ''), 'userCenterId' => $this->onlineUserId, 'reflectType' => getArrayItem($params, 'reflectType', ''), 'money' => getArrayItem($params, 'money', ''), 'reflectInfo' => getArrayItem($params, 'reflectInfo', []), 'reflectStatus' => getArrayItem($params, 'reflectStatus', 4), 'auditStatus' => getArrayItem($params, 'auditStatus', StatusCode::$auditStatus['auditing']), ]; foreach ($ReflectDetailDate as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $ReflectDetailDate['reflectInfo'] = json_encode($ReflectDetailDate['reflectInfo']); $ReflectDetailDate['remark'] = getArrayItem($params, 'remark', ''); $ReflectDetailDate['createTime'] = time(); $result = $this->objMReflectDetail->addReflectDetail($ReflectDetailDate); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 所有提现记录 */ public function getAllReflectDetail() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $params['start'] = getArrayItem($params, 'start', ""); $params['end'] = getArrayItem($params, 'end', ""); $params['customerId'] = getArrayItem($params, 'customerId', ''); $returnData = $this->objMReflectDetail->getAllReflectDetail($params); if ($returnData->isSuccess()) { $returnData = $returnData->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($returnData->getData(), ErrorCode::$dberror); } } /** * 积分流水 */ public function getAllCustomerIntegralDesc() { $params = $this->request->getRawJson(); $page = isset($params['page']) ? $params['page'] : 1; $pageSize = isset($params['pageSize']) ? $params['pageSize'] : 10; $pageParams = pageToOffset($params['page'], $params['pageSize']); $data['limit'] = $pageParams['limit']; $data['offset'] = $pageParams['offset']; $data['customerId'] = $params['customerId']; if (empty($params['customerId'])) { parent::sendOutput('customerId参数为空', ErrorCode::$paramError); } if (isset($params['star']) && !empty($params['star']) && isset($params['end']) && !empty($params['end'])) { $data['createTime'] = [ 'star' => $params['star'], 'end' => $params['end'] ]; } $modelResult = $this->objMCustomer->getAllCustomerIntegralDesc($data); if (!$modelResult->isSuccess()) { parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } $returnData = $modelResult->getData(); $pageData = [ 'pageIndex' => $page, 'pageSize' => $pageSize, 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } /** * 小程序充值 */ public function rechargeMemberBalance() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } //记录流水 $memberBalanceDetailData = [ 'customerId' => $params['customerId'], 'type' => StatusCode::$standard, 'userCenterId' => $this->onlineUserId, 'money' => $params['money'], 'purpose' => '充值', 'orderIds' => '', 'remark' => '充值' . $params['money'], 'financeType' => '会员余额充值', ]; foreach ($memberBalanceDetailData as $k => $v) { if (in_array($k, ['customerId', 'money', 'purpose']) && empty($v)) { $this->sendOutput('请输入' . $k, ErrorCode::$paramError); } } $result = $this->objMMemberBalanceDetail->addMemberBalanceDetail($memberBalanceDetailData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 小程序客户余额明细列表 */ public function getAllCustomerBalanceDetail() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = [ 'customerId' => isset($params['customerId']) ? $params['customerId'] : '', ]; foreach ($selectParams as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $selectParams['start'] = !empty($params['start']) ? $params['start'] : 0; $selectParams['end'] = !empty($params['end']) ? strtotime(date('Y-m-d', $params['end']) . '23:59:59') : time(); $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $result = $this->objMCustomerBalanceDetail->getAllCustomerBalanceDetail($selectParams); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], 'openingBalance' => $returnData['openingBalance'], 'endingBalance' => $returnData['endingBalance'], 'shouldReceiveTotal' => $returnData['shouldReceiveTotal'], 'actualReceiveTotal' => $returnData['actualReceiveTotal'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } }