SupplierOfferPrice.Class.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. namespace JinDouYun\Controller\Price;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Price\MSupplierOfferPriceSheet;
  5. use Mall\Framework\Core\ErrorCode;
  6. /**
  7. * @copyright Copyright (c) https://www.qianniaovip.com All rights reserved
  8. * Description: 供应商报价单
  9. * Class SupplierOfferPrice
  10. * @package JinDouYun\Controller\Price
  11. */
  12. class SupplierOfferPrice extends BaseController
  13. {
  14. /**
  15. * @var MSupplierOfferPriceSheet
  16. */
  17. private $objMSupplierOfferPriceSheet;
  18. /**
  19. * SupplierOfferPrice constructor.
  20. * @param bool $isCheckAcl
  21. * @param bool $isMustLogin
  22. * @param bool $checkToken
  23. * @param false $getAreaCode
  24. * @param false $checkShopToken
  25. * @throws \Exception
  26. */
  27. public function __construct($isCheckAcl = true, $isMustLogin = true, $checkToken = true, $getAreaCode = false, $checkShopToken = false)
  28. {
  29. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode, $checkShopToken);
  30. $this->objMSupplierOfferPriceSheet = new MSupplierOfferPriceSheet($this->onlineUserId,$this->onlineEnterpriseId);
  31. }
  32. /**
  33. * Doc: (des="")
  34. * User: XMing
  35. * Date: 2020/12/16
  36. * Time: 6:48 下午
  37. * @return array
  38. */
  39. public function commonFieldFilter()
  40. {
  41. $params = $this->request->getRawJson();
  42. if( empty($params) ){
  43. self::sendOutput('参数为空', ErrorCode::$paramError );
  44. }
  45. $data = [
  46. 'details' => getArrayItem($params,'details',null),
  47. 'materielNum' => getArrayItem($params,'materielNum',0),
  48. 'supplierName' => getArrayItem($params,'supplierName',''),
  49. 'supplierId' => $this->supplierId,
  50. ];
  51. foreach($data as $key => $value){
  52. if(is_null($value)){
  53. self::sendOutput($key.'参数错误', ErrorCode::$paramError );
  54. }
  55. }
  56. return $data;
  57. }
  58. /**
  59. * Doc: (des="供应商报价单添加")
  60. * User: XMing
  61. * Date: 2020/12/16
  62. * Time: 6:46 下午
  63. * @throws \Exception
  64. */
  65. public function add()
  66. {
  67. $data = $this->commonFieldFilter();
  68. $result = $this->objMSupplierOfferPriceSheet->add($data,$this->supplierId);
  69. if($result->isSuccess()){
  70. parent::sendOutput($result->getData());
  71. }
  72. parent::sendOutput($result->getData(), $result->getErrorCode());
  73. }
  74. /**
  75. * Doc: (des="编辑报价单")
  76. * User: XMing
  77. * Date: 2020/12/17
  78. * Time: 11:53 上午
  79. */
  80. public function edit()
  81. {
  82. $id = $this->request->param('request_id');
  83. if (empty($id)) {
  84. parent::sendOutput('id参数错误', ErrorCode::$paramError);
  85. }
  86. $data = $this->commonFieldFilter();
  87. $result = $this->objMSupplierOfferPriceSheet->edit($data,$id,$this->supplierId);
  88. if($result->isSuccess()){
  89. parent::sendOutput($result->getData());
  90. }
  91. parent::sendOutput($result->getData(), $result->getErrorCode());
  92. }
  93. /**
  94. * Doc: (des="报价单列表")
  95. * User: XMing
  96. * Date: 2020/12/17
  97. * Time: 10:14 上午
  98. */
  99. public function getAll()
  100. {
  101. $params = $this->request->getRawJson();
  102. $page = getArrayItem($params,'page',1);
  103. $pageSize = getArrayItem($params,'pageSize',10);
  104. $pageParams = pageToOffset($page, $pageSize);
  105. $params['limit'] = $pageParams['limit'];
  106. $params['offset'] = $pageParams['offset'];
  107. $result = $this->objMSupplierOfferPriceSheet->getAll($params);
  108. if ($result->isSuccess()) {
  109. $returnData = $result->getData();
  110. $pageData = [
  111. 'pageIndex' => $page,
  112. 'pageSize' => $pageSize,
  113. 'pageTotal' => $returnData['total'],
  114. ];
  115. parent::sendOutput($returnData['data'], 0, $pageData);
  116. }
  117. parent::sendOutput($result->getData(), $result->getErrorCode());
  118. }
  119. /**
  120. * Doc: (des="报价单详情")
  121. * User: XMing
  122. * Date: 2020/12/17
  123. * Time: 11:35 上午
  124. * @throws \Exception
  125. */
  126. public function get()
  127. {
  128. $id = $this->request->param('request_id');
  129. if (empty($id)) {
  130. parent::sendOutput('id参数错误', ErrorCode::$paramError);
  131. }
  132. $result = $this->objMSupplierOfferPriceSheet->get($id);
  133. if (!$result->isSuccess()) {
  134. parent::sendOutput($result->getData(), $result->getErrorCode());
  135. }
  136. parent::sendOutput($result->getData());
  137. }
  138. /**
  139. * Doc: (des="删除")
  140. * User: XMing
  141. * Date: 2020/12/17
  142. * Time: 11:45 上午
  143. */
  144. public function del()
  145. {
  146. $id = $this->request->param('request_id');
  147. if (empty($id)) {
  148. parent::sendOutput('id参数错误', ErrorCode::$paramError);
  149. }
  150. $result = $this->objMSupplierOfferPriceSheet->del($id);
  151. if (!$result->isSuccess()) {
  152. parent::sendOutput($result->getData(), $result->getErrorCode());
  153. }
  154. parent::sendOutput($result->getData());
  155. }
  156. /**
  157. * Doc: (des="报价单-审核")
  158. * User: XMing
  159. * Date: 2020/12/21
  160. * Time: 4:23 下午
  161. */
  162. public function audit()
  163. {
  164. $id = $this->request->param('request_id');
  165. if (empty($id)) {
  166. parent::sendOutput('id参数错误', ErrorCode::$paramError);
  167. }
  168. $result = $this->objMSupplierOfferPriceSheet->audit($id);
  169. if (!$result->isSuccess()) {
  170. parent::sendOutput($result->getData(), $result->getErrorCode());
  171. }
  172. parent::sendOutput($result->getData());
  173. }
  174. }