DeliverySetting.Class.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <?php
  2. /**
  3. * 配送方式设置
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/10/31
  7. * Time: 15:46
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use Mall\Framework\Core\ErrorCode;
  11. use JinDouYun\Controller\BaseController;
  12. use JinDouYun\Model\System\MDeliverySetting;
  13. class DeliverySetting extends BaseController
  14. {
  15. private $objMDeliverySetting;
  16. /**
  17. * DeliverySetting constructor.
  18. * @param bool $isCheckAcl
  19. * @param bool $isMustLogin
  20. * @throws \Exception
  21. */
  22. public function __construct($isCheckAcl = true, $isMustLogin = true)
  23. {
  24. parent::__construct($isCheckAcl, $isMustLogin);
  25. $this->objMDeliverySetting = new MDeliverySetting($this->onlineUserId, $this->onlineEnterpriseId);
  26. }
  27. /**
  28. * 添加,编辑配送方式公共数据
  29. * @return array
  30. */
  31. public function commonFieldFilter()
  32. {
  33. $params = $this->request->getRawJson();
  34. if (empty($params)) {
  35. $this->sendOutput('参数为空', ErrorCode::$paramError);
  36. }
  37. $data = [
  38. 'title' => isset($params['title']) ? $params['title'] : '',
  39. 'defaultStatus' => isset($params['defaultStatus']) ? $params['defaultStatus'] : '',
  40. 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',
  41. ];
  42. foreach ($data as $key => $value) {
  43. if (empty($value) && $value !== 0) {
  44. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  45. }
  46. }
  47. $data['shopId'] = $this->shopId;
  48. $data['enterpriseId'] = $this->onlineEnterpriseId;
  49. $data['setData'] = getArrayItem( $params,'setData','');
  50. return $data;
  51. }
  52. /**
  53. * Doc: (des="配置运费模版")
  54. * User: XMing
  55. * Date: 2020/9/7
  56. * Time: 10:49 上午
  57. */
  58. public function setData()
  59. {
  60. //$id = $this->request->param('request_id');
  61. $params = $this->request->getRawJson();
  62. if (empty($params)) {
  63. parent::sendOutput('参数为空', ErrorCode::$paramError);
  64. }
  65. if (!isset($params['shopId'])){
  66. $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
  67. }
  68. $result = $this->objMDeliverySetting->setData($params);
  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/9/9
  78. * Time: 10:28 上午
  79. */
  80. public function setSelfData()
  81. {
  82. $params = $this->request->getRawJson();
  83. if (empty($params)) {
  84. parent::sendOutput('参数为空', ErrorCode::$paramError);
  85. }
  86. if (!isset($params['shopId'])){
  87. $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
  88. }
  89. $result = $this->objMDeliverySetting->setSelfData($params);
  90. if ($result->isSuccess()) {
  91. parent::sendOutput($result->getData());
  92. }
  93. parent::sendOutput($result->getData(), $result->getErrorCode());
  94. }
  95. /**
  96. * Doc: (des="删除运费模版规则")
  97. * User: XMing
  98. * Date: 2020/9/7
  99. * Time: 4:56 下午
  100. */
  101. public function delDeliveryRule()
  102. {
  103. $id = $this->request->param('request_id');
  104. $result = $this->objMDeliverySetting->delDeliveryRule($id);
  105. if ($result->isSuccess()) {
  106. parent::sendOutput($result->getData());
  107. }
  108. parent::sendOutput($result->getData(), $result->getErrorCode());
  109. }
  110. /**
  111. * Doc: (des="删除自提点")
  112. * User: XMing
  113. * Date: 2020/9/9
  114. * Time: 10:55 上午
  115. */
  116. public function delDeliverySelfRule()
  117. {
  118. $id = $this->request->param('request_id');
  119. $result = $this->objMDeliverySetting->delDeliverySelfRule($id);
  120. if ($result->isSuccess()) {
  121. parent::sendOutput($result->getData());
  122. }
  123. parent::sendOutput($result->getData(), $result->getErrorCode());
  124. }
  125. /**
  126. * 获取配送方式列表
  127. * @throws \Exception
  128. */
  129. public function getAllDelivery()
  130. {
  131. $page = $this->request->param('page') ?: 1;
  132. $pageSize = $this->request->param('pageSize') ?: 10;
  133. $offset = ($page - 1) * $pageSize;
  134. $selectParams = [
  135. 'limit' => $pageSize,
  136. 'offset' => $offset,
  137. ];
  138. $selectParams['shopId'] = $this->shopId;
  139. $orderData = $this->objMDeliverySetting->getAllDelivery($selectParams);
  140. if ($orderData->isSuccess()) {
  141. $returnData = $orderData->getData();
  142. $pageData = [
  143. 'pageIndex' => $page,
  144. 'pageSize' => $pageSize,
  145. 'pageTotal' => $returnData['total'],
  146. ];
  147. parent::sendOutput($returnData['data'], 0, $pageData);
  148. }
  149. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  150. }
  151. /**
  152. * 更新配送方式,启用/禁用
  153. * @throws \Exception
  154. */
  155. public function updateEnableStatus()
  156. {
  157. $params['id'] = $this->request->param('request_id');
  158. $params['enableStatus'] = $this->request->param('enableStatus');
  159. foreach ($params as $key => $value) {
  160. if (empty($value)) {
  161. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  162. }
  163. }
  164. $result = $this->objMDeliverySetting->updateEnableStatus($params);
  165. if ($result->isSuccess()) {
  166. parent::sendOutput($result->getData());
  167. }
  168. parent::sendOutput($result->getData(), $result->getErrorCode());
  169. }
  170. /**
  171. * 更新配送方式的默认状态
  172. * @throws \Exception
  173. */
  174. public function updateDefaultStatus()
  175. {
  176. $params['id'] = $this->request->param('request_id');
  177. $params['defaultStatus'] = $this->request->param('defaultStatus');
  178. foreach ($params as $key => $value) {
  179. if (empty($value)) {
  180. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  181. }
  182. }
  183. $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
  184. $result = $this->objMDeliverySetting->updateDefaultStatus($params);
  185. if ($result->isSuccess()) {
  186. parent::sendOutput($result->getData());
  187. }
  188. parent::sendOutput($result->getData(), $result->getErrorCode());
  189. }
  190. /**
  191. * Doc: (des="获取配送方式详情")
  192. * User: XMing
  193. * Date: 2020/9/7
  194. * Time: 12:29 下午
  195. */
  196. public function getInfo()
  197. {
  198. $id = $this->request->param('request_id');
  199. $shopId = is_null($this->shopId) ? 0 : $this->shopId;
  200. $result = $this->objMDeliverySetting->getInfo($id,$shopId);
  201. if ($result->isSuccess()) {
  202. parent::sendOutput($result->getData());
  203. }
  204. parent::sendOutput($result->getData(), $result->getErrorCode());
  205. }
  206. /**
  207. * 用于获取配送方式(设置->配送方式列表不要使用此接口)
  208. */
  209. public function allDelivery()
  210. {
  211. $dbResult = $this->objMDeliverySetting->allDelivery();
  212. if ($dbResult->isSuccess()) {
  213. $returnData = $dbResult->getData();
  214. parent::sendOutput($returnData['data'], 0);
  215. }
  216. parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
  217. }
  218. /**
  219. * Doc: (des="设置默认运费模版")
  220. * User: XMing
  221. * Date: 2020/9/10
  222. * Time: 2:07 下午
  223. */
  224. public function setDefaultRule()
  225. {
  226. $id = $this->request->param('request_id');
  227. $shopId = is_null($this->shopId) ? 0 : $this->shopId;
  228. $result = $this->objMDeliverySetting->setDefaultRule($id,$shopId);
  229. if ($result->isSuccess()) {
  230. parent::sendOutput($result->getData());
  231. }
  232. parent::sendOutput($result->getData(), $result->getErrorCode());
  233. }
  234. /**
  235. * Doc: (des="获取运费模版详情")
  236. * User: XMing
  237. * Date: 2020/9/8
  238. * Time: 6:22 下午
  239. */
  240. public function getRuleInfo()
  241. {
  242. $id = $this->request->param('request_id');
  243. $result = $this->objMDeliverySetting->getRuleInfo($id);
  244. if ($result->isSuccess()) {
  245. parent::sendOutput($result->getData());
  246. }
  247. parent::sendOutput($result->getData(), $result->getErrorCode());
  248. }
  249. /**
  250. * Doc: (des="获取自提点详情")
  251. * User: XMing
  252. * Date: 2020/9/9
  253. * Time: 10:48 上午
  254. */
  255. public function getSelfRuleInfo()
  256. {
  257. $id = $this->request->param('request_id');
  258. $result = $this->objMDeliverySetting->getSelfRuleInfo($id);
  259. if ($result->isSuccess()) {
  260. parent::sendOutput($result->getData());
  261. }
  262. parent::sendOutput($result->getData(), $result->getErrorCode());
  263. }
  264. /**
  265. * Doc: (des="获取运费模版")
  266. * User: XMing
  267. * Date: 2020/9/7
  268. * Time: 6:26 下午
  269. */
  270. public function getAllExpressRule()
  271. {
  272. $page = $this->request->param('page') ?: 1;
  273. $pageSize = $this->request->param('pageSize') ?: 10;
  274. $offset = ($page - 1) * $pageSize;
  275. $orderData = $this->objMDeliverySetting->getAllExpressRule();
  276. if ($orderData->isSuccess()) {
  277. $returnData = $orderData->getData();
  278. $pageData = [
  279. 'pageIndex' => $page,
  280. 'pageSize' => $pageSize,
  281. 'pageTotal' => $returnData['total'],
  282. ];
  283. parent::sendOutput($returnData['data'], 0, $pageData);
  284. }
  285. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  286. }
  287. /**
  288. * Doc: (des="获取快递公司")
  289. * User: XMing
  290. * Date: 2020/9/8
  291. * Time: 6:53 下午
  292. */
  293. public function getAllExpress()
  294. {
  295. $page = $this->request->param('page') ?: 1;
  296. $pageSize = $this->request->param('pageSize') ?: 10;
  297. $offset = ($page - 1) * $pageSize;
  298. $orderData = $this->objMDeliverySetting->getAllExpress();
  299. if ($orderData->isSuccess()) {
  300. $returnData = $orderData->getData();
  301. $pageData = [
  302. 'pageIndex' => $page,
  303. 'pageSize' => $pageSize,
  304. 'pageTotal' => $returnData['total'],
  305. ];
  306. parent::sendOutput($returnData['data'], 0, $pageData);
  307. }
  308. parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
  309. }
  310. /**
  311. * Doc: (des="后台-获取自提点")
  312. * User: XMing
  313. * Date: 2020/11/4
  314. * Time: 3:30 下午
  315. */
  316. public function getAllSelfExpressRule()
  317. {
  318. $result = $this->objMDeliverySetting->getAllSelfExpressRule();
  319. if ($result->isSuccess()) {
  320. $pageData = [
  321. 'pageIndex' => 1,
  322. 'pageSize' => 999,
  323. 'pageTotal' => 999,
  324. ];
  325. parent::sendOutput($result->getData(),0,$pageData);
  326. }
  327. parent::sendOutput($result->getData(), $result->getErrorCode());
  328. }
  329. /**
  330. * 物流提醒
  331. */
  332. public function updateLogisticsReminder()
  333. {
  334. $params = $this->request->getRawJson();
  335. if( empty($params) ){
  336. $this->sendOutput('参数为空', ErrorCode::$paramError );
  337. }
  338. $reminderData = [
  339. 'id' => getArrayItem( $params,'id'),
  340. 'reminder' => getArrayItem( $params,'reminder','')
  341. ];
  342. foreach ($reminderData as $key => $value) {
  343. if (empty($value)) {
  344. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  345. }
  346. }
  347. $result = $this->objMDeliverySetting->updateLogisticsReminder($reminderData);
  348. if ($result->isSuccess()) {
  349. parent::sendOutput($result->getData());
  350. }
  351. parent::sendOutput($result->getData(), $result->getErrorCode());
  352. }
  353. }