StoreOrderTakeServices.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\order;
  12. use app\dao\order\StoreOrderDao;
  13. use app\jobs\integral\IntegralJob;
  14. use app\jobs\order\AutoTakeOrderJob;
  15. use app\jobs\notice\SmsAdminJob;
  16. use app\services\BaseServices;
  17. use app\services\message\service\StoreServiceServices;
  18. use app\services\message\sms\SmsSendServices;
  19. use app\services\user\member\MemberCardServices;
  20. use app\services\user\UserBillServices;
  21. use app\services\user\UserBrokerageServices;
  22. use app\services\user\level\UserLevelServices;
  23. use app\services\user\UserServices;
  24. use think\exception\ValidateException;
  25. use think\facade\Log;
  26. /**
  27. * 订单收货
  28. * Class StoreOrderTakeServices
  29. * @package app\services\order
  30. * @mixin StoreOrderDao
  31. */
  32. class StoreOrderTakeServices extends BaseServices
  33. {
  34. /**
  35. * 构造方法
  36. * StoreOrderTakeServices constructor.
  37. * @param StoreOrderDao $dao
  38. */
  39. public function __construct(StoreOrderDao $dao)
  40. {
  41. $this->dao = $dao;
  42. }
  43. /**
  44. * 小程序订单服务收货
  45. * @param $order_id
  46. * @return bool
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. */
  51. public function miniOrderTakeOrder($order_id)
  52. {
  53. $orderArr = explode('_', $order_id);
  54. if (count($orderArr) == 2) {
  55. $order_id = $orderArr[1] ?? $order_id;
  56. }
  57. //查找订单信息
  58. $order = $this->dao->getOne(['order_id' => $order_id]);
  59. if (!$order) {
  60. return true;
  61. }
  62. if ($order['pid'] == -1) { // 有子订单
  63. // 查找待收货的子订单
  64. $son_order_list = $this->dao->getSubOrderNotSendList((int)$order['id']);
  65. foreach ($son_order_list as $son_order) {
  66. $this->takeOrder($son_order['order_id'], $son_order['uid']);
  67. }
  68. } else {
  69. $this->takeOrder($order_id, $order['uid']);
  70. }
  71. return true;
  72. }
  73. /**
  74. * 用户订单收货
  75. * @param $uni
  76. * @param $uid
  77. * @return bool
  78. */
  79. public function takeOrder(string $uni, int $uid)
  80. {
  81. $order = $this->dao->getUserOrderDetail($uni, $uid);
  82. if (!$order) {
  83. throw new ValidateException('订单不存在!');
  84. }
  85. /** @var StoreOrderServices $orderServices */
  86. $orderServices = app()->make(StoreOrderServices::class);
  87. $order = $orderServices->tidyOrder($order);
  88. if ($order['_status']['_type'] != 2) {
  89. throw new ValidateException('订单状态错误!');
  90. }
  91. //存在拆分发货 需要分开收货
  92. if ($this->dao->count(['pid' => $order['id']])) {
  93. throw new ValidateException('拆分发货,请去订单详情中包裹确认收货');
  94. }
  95. if ($order['type'] != 8) {
  96. $order->status = 2;
  97. } else {
  98. $order->status = 3;
  99. }
  100. /** @var StoreOrderStatusServices $statusService */
  101. $statusService = app()->make(StoreOrderStatusServices::class);
  102. $res = $order->save() && $statusService->save([
  103. 'oid' => $order['id'],
  104. 'change_type' => 'user_take_delivery',
  105. 'change_message' => '用户已收货',
  106. 'change_time' => time()
  107. ]);
  108. $res = $res && $this->storeProductOrderUserTakeDelivery($order);
  109. if (!$res) {
  110. throw new ValidateException('收货失败');
  111. }
  112. //核销订单 修改订单商品核销状态
  113. if ($order['shipping_type'] == 2 || (in_array($order['shipping_type'], [1, 3]) && $order['delivery_type'] == 'send')) {
  114. //修改原来订单商品信息
  115. $cartData['is_writeoff'] = 1;
  116. $cartData['write_surplus_times'] = 0;
  117. /** @var StoreOrderCartInfoServices $cartInfoServices */
  118. $cartInfoServices = app()->make(StoreOrderCartInfoServices::class);
  119. $cartInfoServices->update(['oid' => $order['id']], $cartData);
  120. }
  121. return $order;
  122. }
  123. /**
  124. * 订单确认收货
  125. * @param $order
  126. * @return bool
  127. */
  128. public function storeProductOrderUserTakeDelivery($order, bool $isTran = true)
  129. {
  130. $res = true;
  131. //获取购物车内的商品标题
  132. /** @var StoreOrderCartInfoServices $orderInfoServices */
  133. $orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
  134. $storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  135. $storeTitle = substrUTf8($storeName, 20, 'UTF-8', '');
  136. if ($order['uid']) {
  137. /** @var UserServices $userServices */
  138. $userServices = app()->make(UserServices::class);
  139. $userInfo = $userServices->get((int)$order['uid']);
  140. $res = $this->transaction(function () use ($order, $userInfo, $storeTitle) {
  141. //赠送积分
  142. $res1 = $this->gainUserIntegral($order, $userInfo, $storeTitle);
  143. //返佣
  144. $res2 = $this->backOrderBrokerage($order, $userInfo);
  145. //经验
  146. $res3 = $this->gainUserExp($order, $userInfo);
  147. if (!($res1 && $res2 && $res3)) {
  148. throw new ValidateException('收货失败!');
  149. }
  150. IntegralJob::dispatchDo('dealOrderIntegral', [$order]);
  151. return true;
  152. }, $isTran);
  153. }
  154. if ($res) {
  155. //订单收货事件
  156. event('order.take', [$order, $storeTitle]);
  157. return true;
  158. } else {
  159. return false;
  160. }
  161. }
  162. /**
  163. * 赠送积分
  164. * @param $order
  165. * @param $userInfo
  166. * @param $storeTitle
  167. * @return bool
  168. */
  169. public function gainUserIntegral($order, $userInfo, $storeTitle)
  170. {
  171. $res2 = true;
  172. if (!$userInfo) {
  173. return true;
  174. }
  175. // 营销产品送积分
  176. if (!isset($order['type']) || in_array($order['type'], [1, 2, 3, 5, 8])) {
  177. return true;
  178. }
  179. /** @var UserBillServices $userBillServices */
  180. $userBillServices = app()->make(UserBillServices::class);
  181. $balance = $userInfo['integral'];
  182. if ($order['gain_integral'] > 0) {
  183. $balance = bcadd((string)$balance, (string)$order['gain_integral']);
  184. $res2 = false != $userBillServices->income('pay_give_integral', $order['uid'], (int)$order['gain_integral'], (int)$balance, $order['id']);
  185. }
  186. $order_integral = 0;
  187. $res3 = true;
  188. $order_give_integral = sys_config('order_give_integral');
  189. if ($order['pay_price'] && $order_give_integral) {
  190. //会员消费返积分翻倍
  191. if ($userInfo['is_money_level'] > 0) {
  192. //看是否开启消费返积分翻倍奖励
  193. /** @var MemberCardServices $memberCardService */
  194. $memberCardService = app()->make(MemberCardServices::class);
  195. $integral_rule_number = $memberCardService->isOpenMemberCardCache('integral');
  196. if ($integral_rule_number) {
  197. $order_integral = bcmul((string)$order['pay_price'], (string)$integral_rule_number, 2);
  198. }
  199. }
  200. $order_integral = bcmul((string)$order_give_integral, (string)($order_integral ? $order_integral : $order['pay_price']), 0);
  201. $balance = bcadd((string)$balance, (string)$order_integral);
  202. $res3 = false != $userBillServices->income('order_give_integral', $order['uid'], (int)$order_integral, (int)$balance, $order['id']);
  203. }
  204. $give_integral = $order_integral + $order['gain_integral'];
  205. if ($give_integral > 0) {
  206. $integral = $userInfo['integral'] + $give_integral;
  207. $userInfo->integral = $integral;
  208. $res1 = false != $userInfo->save();
  209. $res = $res1 && $res2 && $res3;
  210. //发送消息
  211. event('notice.notice', [['order' => $order, 'storeTitle' => $storeTitle, 'give_integral' => $give_integral, 'integral' => $integral], 'integral_accout']);
  212. return $res;
  213. }
  214. return true;
  215. }
  216. /**
  217. * 一级返佣
  218. * @param $orderInfo
  219. * @param $userInfo
  220. * @return bool
  221. */
  222. public function backOrderBrokerage($orderInfo, $userInfo)
  223. {
  224. // 当前订单|用户不存在 直接返回
  225. if (!$orderInfo || !$userInfo) {
  226. return true;
  227. }
  228. //商城分销功能是否开启 0关闭1开启
  229. if (!sys_config('brokerage_func_status')) return true;
  230. // 营销产品不返佣金
  231. if (!isset($orderInfo['type']) || in_array($orderInfo['type'], [1, 2, 3, 5, 8])) {
  232. return true;
  233. }
  234. //绑定失效
  235. if (isset($orderInfo['spread_uid']) && $orderInfo['spread_uid'] == -1) {
  236. return true;
  237. }
  238. //是否开启自购返佣
  239. $isSelfBrokerage = sys_config('is_self_brokerage', 0);
  240. if (!isset($orderInfo['spread_uid']) || !$orderInfo['spread_uid']) {//兼容之前订单表没有spread_uid情况
  241. //没开启自购返佣 没有上级 或者 当用用户上级时自己 直接返回
  242. if (!$isSelfBrokerage && (!$userInfo['spread_uid'] || $userInfo['spread_uid'] == $orderInfo['uid'])) {
  243. return true;
  244. }
  245. $one_spread_uid = $isSelfBrokerage ? $userInfo['uid'] : $userInfo['spread_uid'];
  246. } else {
  247. $one_spread_uid = $orderInfo['spread_uid'];
  248. }
  249. $one_spread_uid = (int)$one_spread_uid;
  250. //冻结时间
  251. $broken_time = intval(sys_config('extract_time'));
  252. $frozen_time = time() + $broken_time * 86400;
  253. //订单中取出
  254. $brokeragePrice = $orderInfo['one_brokerage'] ?? 0;
  255. // 一级返佣金额小于等于0
  256. if ($brokeragePrice <= 0) {//直接二级返佣
  257. return $this->backOrderBrokerageTwo($orderInfo, $userInfo, $isSelfBrokerage, $frozen_time);
  258. }
  259. // 获取上级推广员信息
  260. /** @var UserServices $userServices */
  261. $userServices = app()->make(UserServices::class);
  262. $spreadPrice = $userServices->value(['uid' => $one_spread_uid], 'brokerage_price');
  263. // 上级推广员返佣之后的金额
  264. $balance = bcadd($spreadPrice, $brokeragePrice, 2);
  265. // 添加佣金记录
  266. /** @var UserBrokerageServices $userBrokerageServices */
  267. $userBrokerageServices = app()->make(UserBrokerageServices::class);
  268. //自购返佣 || 上级
  269. $type = $one_spread_uid == $orderInfo['uid'] ? 'get_self_brokerage' : 'get_brokerage';
  270. $res1 = $userBrokerageServices->income($type, $one_spread_uid, [
  271. 'nickname' => $userInfo['nickname'],
  272. 'pay_price' => floatval($orderInfo['pay_price']),
  273. 'number' => floatval($brokeragePrice),
  274. 'frozen_time' => $frozen_time
  275. ], $balance, $orderInfo['id']);
  276. // 添加用户佣金
  277. $res2 = $userServices->bcInc($one_spread_uid, 'brokerage_price', $brokeragePrice, 'uid');
  278. //给上级发送获得佣金的模板消息
  279. $this->sendBackOrderBrokerage($orderInfo, $one_spread_uid, $brokeragePrice);
  280. // 一级返佣成功 跳转二级返佣
  281. $res = $res1 && $res2 && $this->backOrderBrokerageTwo($orderInfo, $userInfo, $isSelfBrokerage, $frozen_time);
  282. return $res;
  283. }
  284. /**
  285. * 二级推广返佣
  286. * @param $orderInfo
  287. * @param $userInfo
  288. * @param int $isSelfbrokerage
  289. * @param int $frozenTime
  290. * @return bool
  291. */
  292. public function backOrderBrokerageTwo($orderInfo, $userInfo, $isSelfbrokerage = 0, $frozenTime = 0)
  293. {
  294. //绑定失效
  295. if (isset($orderInfo['spread_two_uid']) && $orderInfo['spread_two_uid'] == -1) {
  296. return true;
  297. }
  298. /** @var UserServices $userServices */
  299. $userServices = app()->make(UserServices::class);
  300. if (isset($orderInfo['spread_two_uid']) && $orderInfo['spread_two_uid']) {
  301. $spread_two_uid = $orderInfo['spread_two_uid'];
  302. } else {
  303. // 获取上推广人
  304. $userInfoTwo = $userServices->get((int)$userInfo['spread_uid']);
  305. // 订单|上级推广人不存在 直接返回
  306. if (!$orderInfo || !$userInfoTwo) {
  307. return true;
  308. }
  309. //没开启自购返佣 或者 上推广人没有上级 或者 当用用户上上级时自己 直接返回
  310. if (!$isSelfbrokerage && (!$userInfoTwo['spread_uid'] || $userInfoTwo['spread_uid'] == $orderInfo['uid'])) {
  311. return true;
  312. }
  313. $spread_two_uid = $isSelfbrokerage ? $userInfoTwo['uid'] : $userInfoTwo['spread_uid'];
  314. }
  315. $spread_two_uid = (int)$spread_two_uid;
  316. //订单中取出
  317. $brokeragePrice = $orderInfo['two_brokerage'] ?? 0;
  318. // 返佣金额小于等于0 直接返回不返佣金
  319. if ($brokeragePrice <= 0) {
  320. return true;
  321. }
  322. // 获取上上级推广员信息
  323. $spreadPrice = $userServices->value(['uid' => $spread_two_uid], 'brokerage_price');
  324. // 获取上上级推广员返佣之后余额
  325. $balance = bcadd($spreadPrice, $brokeragePrice, 2);
  326. // 添加佣金记录
  327. /** @var UserBrokerageServices $userBrokerageServices */
  328. $userBrokerageServices = app()->make(UserBrokerageServices::class);
  329. $res1 = $userBrokerageServices->income('get_two_brokerage', $spread_two_uid, [
  330. 'nickname' => $userInfo['nickname'],
  331. 'pay_price' => floatval($orderInfo['pay_price']),
  332. 'number' => floatval($brokeragePrice),
  333. 'frozen_time' => $frozenTime
  334. ], $balance, $orderInfo['id']);
  335. // 添加用户佣金
  336. $res2 = $userServices->bcInc($spread_two_uid, 'brokerage_price', $brokeragePrice, 'uid');
  337. //给上级发送获得佣金的模板消息
  338. $this->sendBackOrderBrokerage($orderInfo, $spread_two_uid, $brokeragePrice);
  339. return $res1 && $res2;
  340. }
  341. /**
  342. * 佣金到账发送模板消息
  343. * @param $orderInfo
  344. * @param $spread_uid
  345. * @param $brokeragePrice
  346. */
  347. public function sendBackOrderBrokerage($orderInfo, $spread_uid, $brokeragePrice, string $type = 'order')
  348. {
  349. /** @var UserServices $userServices */
  350. $userServices = app()->make(UserServices::class);
  351. $user = $userServices->getUserInfo($spread_uid, 'phone,user_type');
  352. if ($type == 'order') {
  353. /** @var StoreOrderCartInfoServices $storeOrderCartInfoService */
  354. $storeOrderCartInfoService = app()->make(StoreOrderCartInfoServices::class);
  355. $cartInfo = $storeOrderCartInfoService->getOrderCartInfo($orderInfo['id']);
  356. if ($cartInfo) {
  357. $cartInfo = array_column($cartInfo, 'cart_info');
  358. $goodsPrice = 0;
  359. $goodsName = "";
  360. foreach ($cartInfo as $k => $v) {
  361. $goodsName .= $v['productInfo']['store_name'];
  362. $price = $v['productInfo']['attrInfo']['price'] ?? $v['productInfo']['price'] ?? 0;
  363. $goodsPrice = bcadd((string)$goodsPrice, (string)$price, 2);
  364. }
  365. }
  366. } else {
  367. $goodsName = '推广用户获取佣金';
  368. $goodsPrice = $brokeragePrice;
  369. }
  370. //提醒推送
  371. event('notice.notice', [['spread_uid' => $spread_uid, 'phone' => $user['phone'], 'userType' => $user['user_type'], 'brokeragePrice' => $brokeragePrice, 'goodsName' => $goodsName, 'goodsPrice' => $goodsPrice, 'add_time' => $orderInfo['add_time'] ?? time()], 'order_brokerage']);
  372. return true;
  373. }
  374. /**
  375. * 发送短信
  376. * @param $order
  377. * @param $storeTitle
  378. */
  379. public function smsSend($order, $storeTitle)
  380. {
  381. /** @var SmsSendServices $smsServices */
  382. $smsServices = app()->make(SmsSendServices::class);
  383. $switch = (bool)sys_config('confirm_take_over_switch');
  384. //模板变量
  385. $store_name = $storeTitle;
  386. $order_id = $order['order_id'];
  387. $smsServices->send($switch, $order['user_phone'], compact('store_name', 'order_id'), 'TAKE_DELIVERY_CODE');
  388. }
  389. /**
  390. * 发送确认收货管理员短信
  391. * @param $order
  392. */
  393. public function smsSendTake($order)
  394. {
  395. $switch = (bool)sys_config('admin_confirm_take_over_switch');
  396. /** @var StoreServiceServices $services */
  397. $services = app()->make(StoreServiceServices::class);
  398. $adminList = $services->getStoreServiceOrderNotice();
  399. SmsAdminJob::dispatchDo('sendAdminConfirmTakeOver', [$switch, $adminList, $order]);
  400. return true;
  401. }
  402. /**
  403. * 赠送经验
  404. * @param $order
  405. * @param $userInfo
  406. * @return bool
  407. */
  408. public function gainUserExp($order, $userInfo)
  409. {
  410. if (!$userInfo) {
  411. return true;
  412. }
  413. //用户等级是否开启
  414. if (!sys_config('member_func_status', 1)) {
  415. return true;
  416. }
  417. /** @var UserBillServices $userBillServices */
  418. $userBillServices = app()->make(UserBillServices::class);
  419. $order_exp = 0;
  420. $res3 = true;
  421. $order_give_exp = sys_config('order_give_exp');
  422. $balance = $userInfo['exp'];
  423. if ($order['pay_price'] && $order_give_exp) {
  424. $order_exp = bcmul($order_give_exp, (string)$order['pay_price'], 2);
  425. $balance = bcadd((string)$balance, (string)$order_exp, 2);
  426. $res3 = false != $userBillServices->income('order_give_exp', $order['uid'], $order_exp, $balance, $order['id']);
  427. }
  428. $res = true;
  429. if ($order_exp > 0) {
  430. $userInfo->exp = $balance;
  431. $res1 = false != $userInfo->save();
  432. $res = $res1 && $res3;
  433. }
  434. /** @var UserLevelServices $levelServices */
  435. $levelServices = app()->make(UserLevelServices::class);
  436. $levelServices->detection((int)$order['uid']);
  437. return $res;
  438. }
  439. /**
  440. * 加入队列
  441. * @param array $where
  442. * @param int $count
  443. * @param int $maxLimit
  444. * @return bool
  445. */
  446. public function batchJoinJobs(array $where, int $count, int $maxLimit)
  447. {
  448. $page = ceil($count / $maxLimit);
  449. for ($i = 1; $i <= $page; $i++) {
  450. AutoTakeOrderJob::dispatch([$where, $i, $maxLimit]);
  451. }
  452. return true;
  453. }
  454. /**
  455. * 执行自动收货
  456. * @param array $where
  457. * @param int $page
  458. * @param int $maxLimit
  459. * @return bool
  460. */
  461. public function runAutoTakeOrder(array $where, int $page = 0, int $maxLimit = 0)
  462. {
  463. /** @var StoreOrderStoreOrderStatusServices $service */
  464. $service = app()->make(StoreOrderStoreOrderStatusServices::class);
  465. $orderList = $service->getOrderIds($where, $page, $maxLimit);
  466. /** @var StoreOrderRefundServices $storeOrderRefundServices */
  467. $storeOrderRefundServices = app()->make(StoreOrderRefundServices::class);
  468. foreach ($orderList as $order) {
  469. if ($order['status'] == 2) {
  470. continue;
  471. }
  472. if ($order['paid'] == 1 && $order['status'] == 1) {
  473. $data['status'] = 2;
  474. } else if ($order['pay_type'] == 'offline') {
  475. $data['status'] = 2;
  476. } else {
  477. continue;
  478. }
  479. if ($storeOrderRefundServices->count(['store_order_id' => $order['id'], 'refund_type' => [0, 1, 2, 4, 5], 'is_cancel' => 0, 'is_del' => 1])) {
  480. continue;
  481. }
  482. try {
  483. /** @var StoreOrderStatusServices $statusService */
  484. $statusService = app()->make(StoreOrderStatusServices::class);
  485. $res = $this->dao->update($order['id'], $data) && $statusService->save([
  486. 'oid' => $order['id'],
  487. 'change_type' => 'take_delivery',
  488. 'change_message' => '已收货[自动收货]',
  489. 'change_time' => time()
  490. ]);
  491. $res = $res && $this->storeProductOrderUserTakeDelivery($order);
  492. if (!$res) {
  493. throw new ValidateException('订单号' . $order['order_id'] . '自动收货失败');
  494. }
  495. } catch (\Throwable $e) {
  496. Log::error('自动收货失败,失败原因:' . $e->getMessage());
  497. }
  498. }
  499. return true;
  500. }
  501. /**
  502. * 自动收货
  503. * @return bool
  504. */
  505. public function autoTakeOrder()
  506. {
  507. //7天前时间戳
  508. $systemDeliveryTime = (int)sys_config('system_delivery_time', 0);
  509. //0为取消自动收货功能
  510. if ($systemDeliveryTime == 0) {
  511. return true;
  512. }
  513. $sevenDay = strtotime(date('Y-m-d H:i:s', strtotime('-' . $systemDeliveryTime . ' day')));
  514. /** @var StoreOrderStoreOrderStatusServices $service */
  515. $service = app()->make(StoreOrderStoreOrderStatusServices::class);
  516. $where = [
  517. 'change_time' => $sevenDay,
  518. 'is_del' => 0,
  519. 'paid' => 1,
  520. 'status' => 1,
  521. 'change_type' => ['delivery_goods', 'delivery_fictitious', 'delivery', 'city_delivery']
  522. ];
  523. $maxLimit = 20;
  524. $count = $service->getOrderCount($where);
  525. if ($count > $maxLimit) {
  526. return $this->batchJoinJobs($where, $count, $maxLimit);
  527. }
  528. return $this->runAutoTakeOrder($where);
  529. }
  530. }