objMCashier = new MCashier($this->onlineUserId, $this->onlineEnterpriseId); $this->objMEnterprise = new MEnterprise(); } /** * Doc: (des="") * User: XMing * Date: 2020/9/2 * Time: 12:13 下午 * @throws \Exception */ public function calculatePushMoney() { $params = $this->request->getRawJson(); if (!isset($params['orderId'])) { parent::sendOutput('orderId参数错误', ErrorCode::$paramError); } $result = $this->objMCashier->calculatePushMoney($params['orderId']); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * Doc: (des="收银台统计") * User: XMing * Date: 2020/9/3 * Time: 3:01 下午 */ public function overView() { $params = $this->request->getRawJson(); if (empty($params)) { parent::sendOutput('参数为空', ErrorCode::$dberror); } $pageParams = pageToOffset(isset($params['page']) ? $params['page'] : 1, isset($params['pageSize']) ? $params['pageSize'] : 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $result = $this->objMCashier->overView($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } $returnData = $result->getData(); $pageData = [ 'pageIndex' => isset($params['page']) ? $params['page'] : 1, 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : 10, 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } /** * Doc: (des="根据手机号检索会员信息") * User: XMing * Date: 2020/9/11 * Time: 2:23 下午 * @throws \Exception */ public function searchCustomerDetails() { $mobile = $this->request->param('mobile'); if (empty($mobile)) { parent::sendOutput('mobile参数错误', ErrorCode::$paramError); } $result = $this->objMCashier->searchCustomerDetails($mobile); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * Doc: (des="获取通用收银客户信息") * User: XMing * Date: 2020/9/11 * Time: 2:23 下午 * @throws \Exception */ public function getCommonCustomerInfo() { if(empty($this->onlineEnterpriseId)){ parent::sendOutput('企业信息不存在', ErrorCode::$paramError); } $params['enterpriseId'] = $this->onlineEnterpriseId; $result = $this->objMEnterprise->getEnterpriseInfo($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } $data = $result->getData(); if(empty($data )){ parent::sendOutput('企业信息不存在', ErrorCode::$paramError); } // $mobile = $data["commonCashierCustomerMobile"]; $mobile = "13600000001"; $result = $this->objMCashier->searchCustomerDetails($mobile); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 添加购物车,公共字段 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { parent::sendOutput('参数为空', ErrorCode::$paramError); } $cartData = [ 'goodsData' => isset($params['goodsData']) ? $params['goodsData'] : [],//商品数据 ]; foreach ($cartData as $key => $value) { if (empty($value) && $value !== 0) { parent::sendOutput($key . '参数错误', ErrorCode::$paramError); } } $goodsData = []; foreach ($cartData['goodsData'] as $key => $val) { $goodsData[$key] = [ 'goodsBasicId' => isset($val['goodsBasicId']) ? $val['goodsBasicId'] : '', 'goodsId' => isset($val['goodsId']) ? $val['goodsId'] : '', 'skuId' => isset($val['skuId']) ? $val['skuId'] : '', 'buyNum' => isset($val['buyNum']) ? $val['buyNum'] : '', 'shopId' => isset($val['shopId']) ? $val['shopId'] : '', 'source' => isset($val['source']) ? $val['source'] : '', 'warehouseId' => isset($val['warehouseId']) ? $val['warehouseId'] : '', ]; foreach ($goodsData[$key] as $k => $v) { if (empty($v)) { parent::sendOutput($k . '参数错误', ErrorCode::$paramError); } } $goodsData[$key]['goodsCode'] = createCode(StatusCode::$code['goodsBasic']['prefix'], $goodsData[$key]['goodsId'], StatusCode::$code['goodsBasic']['length']); } $cartData['goodsData'] = $goodsData;//过滤后数据 return $cartData; } /** * Doc: (des="加入购物车") * User: XMing * Date: 2020/9/12 * Time: 9:58 上午 * @throws \Exception */ public function addCart() { $userCenterId = $this->request->param('userCenterId'); $warehouseId = $this->request->param('warehouseId'); $cartData = $this->commonFieldFilter(); if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;// } $result = false; $objMCashierCart = new MCashierCart($userCenterId,$this->onlineEnterpriseId,$this->onlineUserId); foreach ($cartData['goodsData'] as $val){ $result = $objMCashierCart->addCartApi(['goodsData' => [$val]]); } if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 更新商品数量(购物车内操作) * @throws \Exception */ public function updateBuyNum() { $userCenterId = $this->request->param('userCenterId'); $cartId = $this->request->param('request_id'); if (empty($cartId)) { parent::sendOutput('id参数错误', ErrorCode::$paramError); } $params = $this->request->getRawJson(); $params['cartId'] = $cartId; if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $objMCashierCart = new MCashierCart($userCenterId, $this->onlineEnterpriseId,$this->onlineUserId); $result = $objMCashierCart->updateBuyNumApi($params); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 删除购物车中商品(可批量) * @throws \Exception */ public function delCart() { $userCenterId = $this->request->param('userCenterId'); $params = $this->request->getRawJson(); $paramsData = [ 'id' => isset($params['cartId']) ? $params['cartId'] : 0, ]; foreach ($paramsData as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $objMCashierCart = new MCashierCart($userCenterId, $this->onlineEnterpriseId,$this->onlineUserId); $result = $objMCashierCart->delCart($paramsData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * 获取用户购物车数据 * @throws \Exception */ public function getCartByUserCenterId() { $userCenterId = $this->request->param('userCenterId'); $userCouponId = $this->request->param('userCouponId');//优惠券id $params = $this->request->getRawJson(); if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $objMCashierCart = new MCashierCart($userCenterId, $this->onlineEnterpriseId, $this->onlineUserId); $isZero = isset($params['isZero']) && !empty($params['isZero']) ? $params['isZero'] : StatusCode::$delete; $result = $objMCashierCart->getCashierCartByUserCenterIdApi($isZero,$userCouponId); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => 0, 'pageSize' => 0, 'pageTotal' => $returnData['total'] ]; parent::sendOutput($returnData['data'], 0, $pageData); } parent::sendOutput($result->getData(), ErrorCode::$dberror); } /** * Doc: (des="") * User: XMing * Date: 2020/9/12 * Time: 10:57 上午 * @throws \Exception */ public function clearCart() { $userCenterId = $this->request->param('userCenterId'); if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $objMCashierCart = new MCashierCart($userCenterId, $this->onlineEnterpriseId,$this->onlineUserId); $result = $objMCashierCart->clearCart(); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * Doc: (des="") * User: XMing * Date: 2020/9/11 * Time: 6:09 下午 */ public function saveEntryData() { $params = $this->request->getRawJson(); $data = [ 'shopId' => isset($params['shopId']) ? $params['shopId'] : null, 'entryData' => isset($params['entryData']) ? json_encode($params['entryData']) : null, ]; foreach ($data as $key => $val){ if (empty($val)){ parent::sendOutput($key.'参数错误',ErrorCode::$paramError); } } $result = $this->objMCashier->saveEntryData($data); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } parent::sendOutput($result->getData(), $result->getErrorCode()); } /** * Doc: (des="获取挂单记录") * User: XMing * Date: 2020/9/12 * Time: 6:20 下午 */ public function getAllEntryData() { $paramsData = $this->request->getRawJson(); $params = [ 'pageSize' => isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10, 'page' => isset($paramsData['page']) ? $paramsData['page'] : 1, 'shopId' => isset($paramsData['shopId']) ? $paramsData['shopId'] : null, ]; foreach ($params as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $offset = ($params['page'] - 1) * $params['pageSize']; $selectParams = [ 'limit' => $params['pageSize'], 'offset' => $offset, 'shopId' => $params['shopId'] ]; $dbResult = $this->objMCashier->getAllEntryData($selectParams); if ($dbResult->isSuccess()) { $returnData = $dbResult->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } parent::sendOutput($dbResult->getData(), ErrorCode::$dberror); } /** * Doc: (des="取单") * User: XMing * Date: 2020/9/12 * Time: 6:27 下午 */ public function getEntryData() { $id = $this->request->param('request_id'); if (empty($id)){ parent::sendOutput('id参数错误',ErrorCode::$paramError); } $dbResult = $this->objMCashier->getEntryData($id); if ($dbResult->isSuccess()) { parent::sendOutput($dbResult->getData()); } parent::sendOutput($dbResult->getData(), $dbResult->getErrorCode()); } /** * Doc: (des="删除挂单") * User: XMing * Date: 2020/9/12 * Time: 6:38 下午 */ public function delEntryData() { $id = $this->request->param('request_id'); if (empty($id)){ parent::sendOutput('id参数错误',ErrorCode::$paramError); } $dbResult = $this->objMCashier->delEntryData($id); if ($dbResult->isSuccess()) { parent::sendOutput($dbResult->getData()); } parent::sendOutput($dbResult->getData(), $dbResult->getErrorCode()); } /** * Doc: (des="收银台修改商品价格") * User: XMing * Date: 2020/9/14 * Time: 9:24 上午 */ public function changePrice() { $userCenterId = $this->request->param('userCenterId'); if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $params = $this->request->getRawJson(); $data = [ 'goodsId'=>isset($params['goodsId']) ? $params['goodsId'] : null, 'skuId' => isset($params['skuId']) ? $params['skuId'] : null, 'changePrice' => isset($params['changePrice']) ? $params['changePrice'] : null, 'customerUid' => $userCenterId, ]; foreach ($data as $key => $val){ if (empty($val)){ parent::sendOutput($key.'参数错误',ErrorCode::$paramError); } } $dbResult = $this->objMCashier->changePrice($data); if ($dbResult->isSuccess()) { parent::sendOutput($dbResult->getData()); } parent::sendOutput($dbResult->getData(), $dbResult->getErrorCode()); } /** * Doc: (des="收银台营销活动") * User: XMing * Date: 2020/9/14 * Time: 2:26 下午 * @throws \Exception */ public function activityAll() { $userCenterId = $this->request->param('userCenterId'); if (empty($userCenterId)) { $userCenterId = StatusCode::$noneUserCenter;//TODO(匿名用户,客户表中存一个匿名客户) } $paramsData = $this->request->getRawJson(); $pageParams = pageToOffset(isset($paramsData['page']) ? $paramsData['page'] : 1, isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $params['type'] = StatusCode::$standard; $objMCoupon = new MCoupon($userCenterId,$this->onlineEnterpriseId); $result = $objMCoupon->selectAll($params); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => isset($paramsData['page']) ? $paramsData['page'] : 1, 'pageSize' => isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10, 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } parent::sendOutput($result->getData(), $result->getErrorCode()); } }