CashierGoods.Class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace JInDouYun\Controller\Cashier;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Goods\MGoods;
  5. use Mall\Framework\Core\ErrorCode;
  6. /**
  7. * Description:
  8. * Class CashierGoods
  9. * @package JInDouYun\Controller\Cashier
  10. */
  11. class CashierGoods extends BaseController
  12. {
  13. public function __construct($isCheckAcl = false, $isMustLogin = false, $checkToken = true, $getAreaCode = false)
  14. {
  15. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
  16. }
  17. /**
  18. * Doc: (des="")
  19. * User: XMing
  20. * Date: 2020/9/7
  21. * Time: 9:27 上午
  22. * @throws \Exception
  23. */
  24. public function getGoodsByCategory()
  25. {
  26. $params = $this->request->getRawJson();
  27. if( empty($params) ){
  28. $this->sendOutput('参数为空', ErrorCode::$paramError );
  29. }
  30. $selectParams = [
  31. 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : '',
  32. 'keyword' => isset($params['keyword']) ? $params['keyword'] : '',
  33. 'areaCode'=> '',
  34. 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',
  35. ];
  36. if(empty($selectParams["shopId"])){
  37. $this->sendOutput('请先选择门店', ErrorCode::$paramError );
  38. }
  39. $pageParams = pageToOffset($params['page']?:1, $params['pageSize']?:10);
  40. $selectParams['limit'] = $pageParams['limit'];
  41. $selectParams['offset'] = $pageParams['offset'];
  42. if (isset($params['userCenterId']) && !empty($params['userCenterId'])){
  43. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$params['userCenterId']);
  44. }else{
  45. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$this->onlineUserId);
  46. }
  47. $selectParams['userCenterId'] = isset($params['userCenterId']) ? $params['userCenterId'] : $this->onlineUserId;
  48. $result = $objMGoods->search($selectParams);
  49. if($result->isSuccess()){
  50. $returnData = $result->getData();
  51. $pageData = [
  52. 'pageIndex' => $params['page'],
  53. 'pageSize' => $params['pageSize'],
  54. 'pageTotal' => $returnData['total'],
  55. ];
  56. parent::sendOutput($returnData['data'], 0, $pageData);
  57. }
  58. parent::sendOutput($result->getData(), $result->getErrorCode());
  59. }
  60. /**
  61. * Doc: (des="")
  62. * User: XMing
  63. * Date: 2020/9/30
  64. * Time: 3:08 下午
  65. * @throws \Exception
  66. */
  67. public function getGoodsByBarCode()
  68. {
  69. $userCenterId = $this->request->param('userCenterId');
  70. if (!empty($userCenterId)){
  71. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$userCenterId);
  72. }else{
  73. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$this->onlineUserId);
  74. }
  75. $params = $this->request->getRawJson();
  76. if (empty($params['barCode'])) {
  77. $this->sendOutput('barCode参数为空', ErrorCode::$paramError);
  78. }
  79. $result = $objMGoods->getGoodsByBarCode($params['barCode']);
  80. if (!$result->isSuccess()) {
  81. parent::sendOutput($result->getData(), $result->getErrorCode());
  82. }
  83. parent::sendOutput($result->getData());
  84. }
  85. /**
  86. * Doc: (des="")
  87. * User: XMing
  88. * Date: 2020/9/7
  89. * Time: 9:44 上午
  90. * @throws \Exception
  91. */
  92. public function getGoodsDetail()
  93. {
  94. $goodsId = $this->request->param('request_id');
  95. $userCenterId = $this->request->param('userCenterId');
  96. if ( !$goodsId ) {
  97. self::sendOutput('参数错误', ErrorCode::$paramError );
  98. }
  99. if (!empty($userCenterId)){
  100. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$userCenterId);
  101. }else{
  102. $objMGoods = new MGoods($this->onlineEnterpriseId,true,$this->onlineUserId);
  103. }
  104. $result = $objMGoods->getApiGoodsInfo($goodsId, '');
  105. if($result->isSuccess()){
  106. $resultData = $result->getData();
  107. self::sendOutput($resultData);
  108. }
  109. self::sendOutput($result->getData(), $result->getErrorCode());
  110. }
  111. }