CountRepository.php 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  1. <?php
  2. namespace app\common\repositories\system;
  3. use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\AddShortUrlResponseBody\data;
  4. use app\common\repositories\BaseRepository;
  5. use app\common\repositories\community\CommunityRepository;
  6. use app\common\repositories\store\broadcast\BroadcastGoodsRepository;
  7. use app\common\repositories\store\broadcast\BroadcastRoomRepository;
  8. use app\common\repositories\system\notice\SystemNoticeLogRepository;
  9. use app\common\repositories\store\order\{StoreOrderProductRepository,
  10. StoreOrderReceiptRepository,
  11. StoreOrderRepository,
  12. StoreRefundOrderRepository
  13. };
  14. use app\common\repositories\store\product\{ProductAssistRepository,
  15. ProductGroupRepository,
  16. ProductPresellRepository,
  17. ProductReplyRepository,
  18. ProductRepository
  19. };
  20. use app\common\repositories\system\financial\FinancialRepository;
  21. use app\common\repositories\system\merchant\{
  22. MerchantIntentionRepository,
  23. MerchantRepository
  24. };
  25. use app\common\repositories\user\{
  26. FeedbackRepository,
  27. UserExtractRepository
  28. };
  29. use think\facade\Cache;
  30. use think\facade\Config;
  31. class CountRepository extends BaseRepository
  32. {
  33. const CACHE_KEY = 'sys_count';
  34. protected $is_cache = true;
  35. protected $cache_method = [
  36. 'getMerchantSalesTop',
  37. 'getMerchantSalesPriceTop',
  38. 'getMerchantProductSalesPriceTop'
  39. ];
  40. public $admin_prefix = '';
  41. public $merchant_prefix = '';
  42. public function __construct()
  43. {
  44. $this->admin_prefix = Config::get('admin.admin_prefix');
  45. $this->merchant_prefix = Config::get('admin.merchant_prefix');
  46. }
  47. /**
  48. * @param $type
  49. * @param $callback
  50. * @return mixed
  51. * @throws \Exception
  52. *
  53. * @date 2023/10/21
  54. * @author yyw
  55. */
  56. protected function cache($type, $callback)
  57. {
  58. if (!$this->is_cache || !in_array($type, $this->cache_method) || env('APP_DEBUG', false)) {
  59. return $callback();
  60. }
  61. $res = Cache::get(self::CACHE_KEY . '_' . $type);
  62. if ($res) {
  63. return json_decode($res, true);
  64. } else {
  65. $res = $callback();
  66. Cache::set(self::CACHE_KEY . '_' . $type, json_encode($res), $res['ttl'] ?? 300);
  67. return $res;
  68. }
  69. }
  70. /**
  71. * 删除为空数组项
  72. * @param array $data
  73. * @return array
  74. *
  75. * @date 2023/10/25
  76. * @author yyw
  77. */
  78. public function deleteArrayEmpty(array $data): array
  79. {
  80. foreach ($data as $key => $item) {
  81. if (empty($item)) {
  82. unset($data[$key]);
  83. }
  84. }
  85. return array_values($data);
  86. }
  87. /**
  88. * 获取平台首页统计
  89. * @return array
  90. *
  91. * @date 2023/10/21
  92. * @author yyw
  93. */
  94. public function getAdminCount()
  95. {
  96. return $this->deleteArrayEmpty(array_merge(
  97. $this->getAuditProductCount(),
  98. // $this->getAuditActiveProductCount(),
  99. $this->getAuditDistributionInfo(null),
  100. $this->getAuditMerchantCount(),
  101. $this->getAuditExtractCount(),
  102. $this->getAuditFinancialCount(),
  103. $this->getAuditCommunityCount(),
  104. $this->getAuditRefundOrderCount(),
  105. $this->getAuditFeedbackCount(),
  106. $this->getIntegralOrderShipInfo()
  107. ));
  108. }
  109. /**
  110. * 获取平台代办
  111. * @return array
  112. *
  113. * @date 2023/10/25
  114. * @author yyw
  115. */
  116. public function getAdminTodo()
  117. {
  118. return $this->deleteArrayEmpty(array_merge(
  119. $this->getAuditProductCount('todo'),
  120. $this->getAuditDistributionInfo(null, 'todo'),
  121. $this->getAuditExtractCount('todo'),
  122. $this->getAuditFinancialCount('todo'),
  123. $this->getAuditMerchantCount('todo'),
  124. $this->getAuditCommunityCount('todo'),
  125. $this->getAuditFeedbackCount('todo'),
  126. // $this->getAuditActiveProductCount('todo'),
  127. $this->getAuditLiveRoomCount('todo'),
  128. $this->getAuditLiveProdouctCount('todo'),
  129. $this->getIntegralOrderShipInfo('todo')
  130. ));
  131. }
  132. /**
  133. * 获取去待审核的普通商品数量
  134. * @return mixed
  135. *
  136. * @date 2023/10/21
  137. * @author yyw
  138. */
  139. public function getAuditProductCount(string $type = 'count')
  140. {
  141. return $this->cache(__FUNCTION__, function () use ($type) {
  142. $productRepository = app()->make(ProductRepository::class);
  143. $normal_count = $productRepository->search(null, $productRepository->switchType(6, null, 0))->count();
  144. $seckill_count = $productRepository->search(null, $productRepository->switchType(6, null, 1))->count();
  145. $group_count = app()->make(ProductGroupRepository::class)->search(['product_status' => 0])->count();
  146. $presell_count = app()->make(ProductPresellRepository::class)->search(['product_status' => 0])->count();
  147. $assist_count = app()->make(ProductAssistRepository::class)->search(['product_status' => 0])->count();
  148. $normal_path = '/'.$this->admin_prefix.'/product/examine';
  149. $seckill_path = '/'.$this->admin_prefix.'/marketing/seckill/list';
  150. $group_path = '/'.$this->admin_prefix.'/marketing/combination/combination_goods?product_status=0';
  151. $presell_path = '/'.$this->admin_prefix.'/marketing/presell/list?product_status=0';
  152. $assist_path = '/'.$this->admin_prefix.'/marketing/assist/goods_list?product_status=0';
  153. $data = [];
  154. switch ($type) {
  155. case 'count':
  156. $children = [];
  157. if ($normal_count > 0) {
  158. $children[] = [
  159. 'title' => '普通商品',
  160. 'path' => $normal_path,
  161. 'count' => $normal_count,
  162. 'message' => '普通商品(' . $normal_count . ')',
  163. ];
  164. }
  165. if ($seckill_count > 0) {
  166. $children[] = [
  167. 'title' => '秒杀商品',
  168. 'path' => $seckill_path,
  169. 'count' => $seckill_count,
  170. 'message' => '秒杀商品(' . $seckill_count . ')',
  171. ];
  172. }
  173. if ($group_count > 0) {
  174. $children[] = [
  175. 'title' => '拼团商品',
  176. 'path' => $group_path,
  177. 'count' => $group_count,
  178. 'message' => '拼团商品(' . $group_count . ')',
  179. ];
  180. }
  181. if ($presell_count > 0) {
  182. $children[] = [
  183. 'title' => '预售商品',
  184. 'path' => $presell_path,
  185. 'count' => $presell_count,
  186. 'message' => '预售商品(' . $presell_count . ')',
  187. ];
  188. }
  189. if ($assist_count > 0) {
  190. $children[] = [
  191. 'title' => '助力商品',
  192. 'path' => $assist_path,
  193. 'count' => $assist_count,
  194. 'message' => '助力商品(' . $assist_count . ')',
  195. ];
  196. }
  197. $count = 0;
  198. foreach ($children as $child) {
  199. $count += $child['count'];
  200. }
  201. $data[] = [
  202. 'title' => '待审核商品',
  203. 'icon' => 'iconputongshangpin',
  204. 'path' => '/',
  205. 'count' => $count,
  206. 'children' => $children
  207. ];
  208. break;
  209. case 'todo':
  210. if ($normal_count > 0) {
  211. $data[] = [
  212. 'title' => '待审核普通商品提醒',
  213. 'path' => $normal_path,
  214. 'message' => '您有' . $normal_count . '个商品待审核'
  215. ];
  216. }
  217. if ($seckill_count > 0) {
  218. $data[] = [
  219. 'title' => '待审核秒杀商品提醒',
  220. 'path' => $seckill_path,
  221. 'message' => '您有' . $seckill_count . '个秒杀商品待审核'
  222. ];
  223. }
  224. if ($group_count > 0) {
  225. $data[] = [
  226. 'title' => '待审核拼团商品提醒',
  227. 'path' => $group_path,
  228. 'message' => '您有' . $group_count . '个拼团商品待审核'
  229. ];
  230. }
  231. if ($assist_count > 0) {
  232. $data[] = [
  233. 'title' => '待审核助力商品提醒',
  234. 'path' => $assist_path,
  235. 'message' => '您有' . $assist_count . '个助力商品待审核'
  236. ];
  237. }
  238. if ($presell_count > 0) {
  239. $data[] = [
  240. 'title' => '待审核预售商品提醒',
  241. 'path' => $presell_path,
  242. 'message' => '您有' . $presell_count . '个预售商品待审核'
  243. ];
  244. }
  245. break;
  246. }
  247. return $data;
  248. });
  249. }
  250. /**
  251. * 获取活动商品待审核数量
  252. * @return array
  253. *
  254. * @date 2023/10/21
  255. * @author yyw
  256. */
  257. public function getAuditActiveProductCount(string $type = 'count')
  258. {
  259. return $this->cache(__FUNCTION__, function () use ($type) {
  260. $productRepository = app()->make(ProductRepository::class);
  261. $seckill_count = $productRepository->search(null, $productRepository->switchType(6, null, 1))->count();
  262. $group_count = app()->make(ProductGroupRepository::class)->search(['product_status' => 0])->count();
  263. $presell_count = app()->make(ProductPresellRepository::class)->search(['product_status' => 0])->count();
  264. $assist_count = app()->make(ProductAssistRepository::class)->search(['product_status' => 0])->count();
  265. $seckill_path = '/'.$this->admin_prefix.'/marketing/seckill/list';
  266. $group_path = '/'.$this->admin_prefix.'/marketing/combination/combination_goods?product_status=0';
  267. $presell_path = '/'.$this->admin_prefix.'/marketing/presell/list?product_status=0';
  268. $assist_path = '/'.$this->admin_prefix.'/marketing/assist/goods_list?product_status=0';
  269. $data = [];
  270. switch ($type) {
  271. case 'count':
  272. $children = [];
  273. if ($seckill_count > 0) {
  274. $children[] = [
  275. 'title' => '秒杀',
  276. 'path' => $seckill_path,
  277. 'count' => $seckill_count,
  278. 'message' => '秒杀(' . $seckill_count . ')',
  279. ];
  280. }
  281. if ($group_count > 0) {
  282. $children[] = [
  283. 'title' => '拼团',
  284. 'path' => $group_path,
  285. 'count' => $group_count,
  286. 'message' => '拼团(' . $group_count . ')',
  287. ];
  288. }
  289. if ($presell_count > 0) {
  290. $children[] = [
  291. 'title' => '预售',
  292. 'path' => $presell_path,
  293. 'count' => $presell_count,
  294. 'message' => '预售(' . $presell_count . ')',
  295. ];
  296. }
  297. if ($assist_count > 0) {
  298. $children[] = [
  299. 'title' => '助力',
  300. 'path' => $assist_path,
  301. 'count' => $assist_count,
  302. 'message' => '助力(' . $assist_count . ')',
  303. ];
  304. }
  305. $count = 0;
  306. foreach ($children as $child) {
  307. $count += $child['count'];
  308. }
  309. $data[] = [
  310. 'title' => '待审核活动商品',
  311. 'icon' => 'iconhuodongshangpin',
  312. 'path' => '/',
  313. 'count' => $count,
  314. 'children' => $children
  315. ];
  316. break;
  317. case 'todo':
  318. if ($seckill_count > 0) {
  319. $data[] = [
  320. 'title' => '待审核秒杀商品提醒',
  321. 'path' => $seckill_path,
  322. 'message' => '您有' . $seckill_count . '个秒杀商品待审核'
  323. ];
  324. }
  325. if ($group_count > 0) {
  326. $data[] = [
  327. 'title' => '待审核拼团商品提醒',
  328. 'path' => $group_path,
  329. 'message' => '您有' . $group_count . '个拼团商品待审核'
  330. ];
  331. }
  332. if ($assist_count > 0) {
  333. $data[] = [
  334. 'title' => '待审核助力商品提醒',
  335. 'path' => $assist_path,
  336. 'message' => '您有' . $assist_count . '个助力商品待审核'
  337. ];
  338. }
  339. if ($presell_count > 0) {
  340. $data[] = [
  341. 'title' => '待审核预售商品提醒',
  342. 'path' => $presell_path,
  343. 'message' => '您有' . $presell_count . '个预售商品待审核'
  344. ];
  345. }
  346. break;
  347. }
  348. return $data;
  349. });
  350. }
  351. /**
  352. * 获取分销商品待审核数量
  353. * @param int|null $mer_id
  354. * @param string $type
  355. * @return mixed
  356. * @throws \Exception
  357. *
  358. * @date 2023/10/25
  359. * @author yyw
  360. */
  361. public function getAuditDistributionInfo(?int $mer_id, string $type = 'count')
  362. {
  363. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  364. $productRepository = app()->make(ProductRepository::class);
  365. $count = $productRepository->search($mer_id, $productRepository->switchType(6, null, 10))->count();
  366. $path = '/'.$this->admin_prefix.'/promoter/gift?type=6';
  367. if ($mer_id) {
  368. $path = '/'.$this->merchant_prefix.'/product/list?type=6&is_gift_bag=1';
  369. }
  370. $data = [];
  371. switch ($type) {
  372. case 'count':
  373. $data[] = [
  374. 'title' => empty($mer_id) ? '待审核分销礼包' : '审核未通过分销礼包',
  375. 'icon' => 'icondaihexiao-fenxiaolibao',
  376. 'path' => $path,
  377. 'count' => $count,
  378. 'children' => []
  379. ];
  380. break;
  381. case 'todo':
  382. if ($count > 0) {
  383. $data[] = [
  384. 'title' => empty($mer_id) ? '待审核分销礼包提醒' : '分销礼包审核未通过提醒',
  385. 'path' => $path,
  386. 'message' => '您有' . $count . (empty($mer_id) ? '个分销礼包待审核' : '个分销礼包审核未通过')
  387. ];
  388. }
  389. break;
  390. }
  391. return $data;
  392. });
  393. }
  394. /**
  395. * 获取商户审核
  396. * @return array
  397. *
  398. * @date 2023/10/21
  399. * @author yyw
  400. */
  401. public function getAuditMerchantCount(string $type = 'count')
  402. {
  403. return $this->cache(__FUNCTION__, function () use ($type) {
  404. $merchantIntentionRepository = app()->make(MerchantIntentionRepository::class);
  405. $count = $merchantIntentionRepository->search(['status' => 0])->count();
  406. $path = '/'.$this->admin_prefix.'/'.$this->merchant_prefix.'/application';
  407. $data = [];
  408. switch ($type) {
  409. case 'count':
  410. $data[] = [
  411. 'title' => '待审核商户入驻',
  412. 'icon' => 'icondaishenhe-shanghuruzhu',
  413. 'path' => $path,
  414. 'count' => $count,
  415. 'children' => []
  416. ];
  417. break;
  418. case 'todo':
  419. if ($count > 0) {
  420. $data[] = [
  421. 'title' => '待审核商户入驻提醒',
  422. 'path' => $path,
  423. 'message' => '您有' . $count . '个商户入驻待审核'
  424. ];
  425. }
  426. break;
  427. }
  428. return $data;
  429. });
  430. }
  431. /**
  432. * 获取提现待审核
  433. * @return array
  434. *
  435. * @date 2023/10/21
  436. * @author yyw
  437. */
  438. public function getAuditExtractCount(string $type = 'count')
  439. {
  440. return $this->cache(__FUNCTION__, function () use ($type) {
  441. $userExtractRepository = app()->make(UserExtractRepository::class);
  442. $count = $userExtractRepository->search(['status' => 0])->count();
  443. $path = '/'.$this->admin_prefix.'/accounts/extract';
  444. $data = [];
  445. switch ($type) {
  446. case 'count':
  447. $data[] = [
  448. 'title' => '待审核提现',
  449. 'icon' => 'icondaishenhe-tixian',
  450. 'path' => $path,
  451. 'count' => $count,
  452. 'children' => []
  453. ];
  454. break;
  455. case 'todo':
  456. if ($count > 0) {
  457. $data[] = [
  458. 'title' => '待审核提现提醒',
  459. 'path' => $path,
  460. 'message' => '您有' . $count . '个提现待审核'
  461. ];
  462. }
  463. break;
  464. }
  465. return $data;
  466. });
  467. }
  468. /**
  469. * 获取转账待审核
  470. * @return array
  471. *
  472. * @date 2023/10/21
  473. * @author yyw
  474. */
  475. public function getAuditFinancialCount(string $type = 'count')
  476. {
  477. return $this->cache(__FUNCTION__, function () use ($type) {
  478. $financialRepository = app()->make(FinancialRepository::class);
  479. $count = $financialRepository->search(['status' => 0])->count();
  480. $path = '/'.$this->admin_prefix.'/accounts/transferRecord';
  481. $data = [];
  482. switch ($type) {
  483. case 'count':
  484. $data[] = [
  485. 'title' => '待审核转账',
  486. 'icon' => 'icondaishenhe-zhuanzhang',
  487. 'path' => $path,
  488. 'count' => $count,
  489. 'children' => []
  490. ];
  491. break;
  492. case 'todo':
  493. if ($count > 0) {
  494. $data[] = [
  495. 'title' => '待审核转账提醒',
  496. 'path' => $path,
  497. 'message' => '您有' . $count . '个转账待审核'
  498. ];
  499. }
  500. break;
  501. }
  502. return $data;
  503. });
  504. }
  505. /**
  506. * 待审核社区内容
  507. * @return array
  508. *
  509. * @date 2023/10/21
  510. * @author yyw
  511. */
  512. public function getAuditCommunityCount(string $type = 'count')
  513. {
  514. return $this->cache(__FUNCTION__, function () use ($type) {
  515. $communityRepository = app()->make(CommunityRepository::class);
  516. $count = $communityRepository->search(['status' => 0,'is_del' => 0])->count();
  517. $path = '/'.$this->admin_prefix.'/community/list';
  518. $data = [];
  519. switch ($type) {
  520. case 'count':
  521. $data[] = [
  522. 'title' => '待审核社区内容',
  523. 'icon' => 'icondaishenhe-shequneirong',
  524. 'path' => $path,
  525. 'count' => $count,
  526. 'children' => []
  527. ];
  528. break;
  529. case 'todo':
  530. if ($count > 0) {
  531. $data[] = [
  532. 'title' => '待审核社区内容提醒',
  533. 'path' => $path,
  534. 'message' => '您有' . $count . '个社区内容待审核'
  535. ];
  536. }
  537. break;
  538. }
  539. return $data;
  540. });
  541. }
  542. /**
  543. * 待退款订单
  544. * @return array
  545. *
  546. * @date 2023/10/21
  547. * @author yyw
  548. */
  549. public function getAuditRefundOrderCount(string $type = 'count')
  550. {
  551. return $this->cache(__FUNCTION__, function () use ($type) {
  552. $storeRefundOrderRepository = app()->make(StoreRefundOrderRepository::class);
  553. $count = $storeRefundOrderRepository->search(['status' => 0])->count();
  554. $path = '/'.$this->admin_prefix.'/order/refund';
  555. $data = [];
  556. switch ($type) {
  557. case 'count':
  558. $data[] = [
  559. 'title' => '待退款订单',
  560. 'icon' => 'icondaituikuan',
  561. 'path' => $path,
  562. 'count' => $count,
  563. 'children' => []
  564. ];
  565. break;
  566. case 'todo':
  567. if ($count > 0) {
  568. $data[] = [
  569. 'title' => '待退款订单提醒',
  570. 'path' => $path,
  571. 'message' => '您有' . $count . '个待退款订单待审核'
  572. ];
  573. }
  574. break;
  575. }
  576. return $data;
  577. });
  578. }
  579. /**
  580. * 待处理用户反馈
  581. * @return array
  582. *
  583. * @date 2023/10/21
  584. * @author yyw
  585. */
  586. public function getAuditFeedbackCount(string $type = 'count')
  587. {
  588. return $this->cache(__FUNCTION__, function () use ($type) {
  589. $feedbackRepository = app()->make(FeedbackRepository::class);
  590. $count = $feedbackRepository->search(['status' => 0])->count();
  591. $path = '/'.$this->admin_prefix.'/feedback/list';
  592. $data = [];
  593. switch ($type) {
  594. case 'count':
  595. $data[] = [
  596. 'title' => '待处理用户反馈',
  597. 'icon' => 'icondaichuli-yonghufankui',
  598. 'path' => $path,
  599. 'count' => $count,
  600. 'children' => []
  601. ];
  602. break;
  603. case 'todo':
  604. if ($count > 0) {
  605. $data[] = [
  606. 'title' => '待处理用户反馈提醒',
  607. 'path' => $path,
  608. 'message' => '您有' . $count . '个用户反馈待处理'
  609. ];
  610. }
  611. break;
  612. }
  613. return $data;
  614. });
  615. }
  616. /**
  617. * 待处理直播间审核
  618. * @return array
  619. *
  620. * @date 2023/10/21
  621. * @author yyw
  622. */
  623. public function getAuditLiveRoomCount(string $type = 'count')
  624. {
  625. return $this->cache(__FUNCTION__, function () use ($type) {
  626. $count = app()->make(BroadcastRoomRepository::class)->search(['status_tag' => 0])->count();
  627. $path = '/'.$this->admin_prefix.'/marketing/studio/list';
  628. $data = [];
  629. switch ($type) {
  630. case 'count':
  631. $data[] = [
  632. 'title' => '待审核直播间',
  633. 'icon' => '',
  634. 'path' => $path,
  635. 'count' => $count,
  636. 'children' => []
  637. ];
  638. break;
  639. case 'todo':
  640. if ($count > 0) {
  641. $data[] = [
  642. 'title' => '待审核直播间提醒',
  643. 'path' => $path,
  644. 'message' => '您有' . $count . '个直播间待审核'
  645. ];
  646. }
  647. break;
  648. }
  649. return $data;
  650. });
  651. }
  652. /**
  653. * 待处理直播商品审核
  654. * @return array
  655. *
  656. * @date 2023/10/21
  657. * @author yyw
  658. */
  659. public function getAuditLiveProdouctCount(string $type = 'count')
  660. {
  661. return $this->cache(__FUNCTION__, function () use ($type) {
  662. $count = app()->make(BroadcastGoodsRepository::class)->search(['status_tag' => 0])->count();
  663. $path = '/'.$this->admin_prefix.'/marketing/broadcast/list';
  664. $data = [];
  665. switch ($type) {
  666. case 'count':
  667. $data[] = [
  668. 'title' => '待审核直播商品',
  669. 'icon' => '',
  670. 'path' => $path,
  671. 'count' => $count,
  672. 'children' => []
  673. ];
  674. break;
  675. case 'todo':
  676. if ($count > 0) {
  677. $data[] = [
  678. 'title' => '待审核直播商品提醒',
  679. 'path' => $path,
  680. 'message' => '您有' . $count . '个直播商品待审核'
  681. ];
  682. }
  683. break;
  684. }
  685. return $data;
  686. });
  687. }
  688. /**
  689. * 待发货积分订单订单
  690. * @param string $type
  691. * @return mixed
  692. * @throws \Exception
  693. *
  694. * @date 2023/11/02
  695. * @author yyw
  696. */
  697. public function getIntegralOrderShipInfo(string $type = 'count')
  698. {
  699. return $this->cache(__FUNCTION__, function () use ($type) {
  700. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  701. $stay_delivery_count = $storeOrderRepository->searchAll(['status' => 0, 'activity_type' => 20], 0, 1)->count();
  702. $stay_delivery_path = '/'.$this->admin_prefix.'/marketing/integral/orderList?status=0';
  703. $data = [];
  704. switch ($type) {
  705. case 'count':
  706. $data[] = [
  707. 'title' => '待发货积分订单',
  708. 'icon' => 'icondaifahuo-jifen',
  709. 'path' => $stay_delivery_path,
  710. 'count' => $stay_delivery_count,
  711. 'children' => []
  712. ];
  713. break;
  714. case 'todo':
  715. if ($stay_delivery_count) {
  716. $data[] = [
  717. 'title' => '待发货积分订单提醒',
  718. 'path' => $stay_delivery_path,
  719. 'message' => '您有' . $stay_delivery_count . '个待发货的积分订单'
  720. ];
  721. }
  722. break;
  723. }
  724. return $data;
  725. });
  726. }
  727. /**
  728. * 获取商户排行榜
  729. * @param string $date
  730. * @param string $type
  731. * @param string $sort
  732. * @return mixed
  733. * @throws \Exception
  734. */
  735. public function getMerchantTop(string $date, string $type = 'sales', string $sort = 'desc')
  736. {
  737. return $this->cache(__FUNCTION__, function () use ($date, $type, $sort) {
  738. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  739. $list = $storeOrderRepository->getMerchantTop($date, $type, $sort);
  740. foreach ($list as &$item) {
  741. $item['mer_name'] = $item['merchant']['mer_name'] ?? '未知商户';
  742. $item['mer_avatar'] = $item['merchant']['mer_avatar'] ?? rtrim(systemConfig('site_url'), '/') . '/static/images/mer_logo.png';
  743. $item['care_count'] = $item['merchant']['care_count'] ?? 0;
  744. unset($item['merchant']);
  745. }
  746. return compact('list');
  747. });
  748. }
  749. /**
  750. * 获取商户首页统计
  751. * @param int $mer_id
  752. * @return array
  753. * @throws \Exception
  754. */
  755. public function getMerchantCount(int $mer_id)
  756. {
  757. return $this->deleteArrayEmpty(array_merge(
  758. $this->getMerchantOrderShipInfo($mer_id),
  759. $this->getMerchantRefuseProductInfo($mer_id),
  760. // $this->getMerchantActivityProductInfo($mer_id),
  761. $this->getMerchantPendWriteOffOrderInfo($mer_id),
  762. $this->getMerchantAlertProductInfo($mer_id),
  763. $this->getMerchantSellOutProductInfo($mer_id),
  764. $this->getMerchantRefundOrderInfo($mer_id),
  765. $this->getMerchantOrderReceiptInfo($mer_id),
  766. $this->getMerchantSellProductInfo($mer_id),
  767. $this->getMerchantStayReviewsInfo($mer_id)
  768. // $this->getAuditDistributionInfo($mer_id)
  769. ));
  770. }
  771. /**
  772. * 获取商户小铃铛代办
  773. * @param int $mer_id
  774. * @return array
  775. * @throws \Exception
  776. */
  777. public function getMerchantTodo(int $mer_id)
  778. {
  779. return $this->deleteArrayEmpty(array_merge(
  780. $this->getMerchantOrderShipInfo($mer_id, 'todo'),
  781. $this->getMerchantRefuseProductInfo($mer_id, 'todo'),
  782. // $this->getMerchantActivityProductInfo($mer_id, 'todo'),
  783. $this->getMerchantPendWriteOffOrderInfo($mer_id, 'todo'),
  784. $this->getMerchantAlertProductInfo($mer_id, 'todo'),
  785. $this->getMerchantSellOutProductInfo($mer_id, 'todo'),
  786. $this->getMerchantRefundOrderInfo($mer_id, 'todo'),
  787. $this->getMerchantOrderReceiptInfo($mer_id, 'todo'),
  788. $this->getMerchantStayReviewsInfo($mer_id, 'todo')
  789. // $this->getAuditDistributionInfo($mer_id, 'todo')
  790. ));
  791. }
  792. /**
  793. * 出售商品
  794. * @param int $mer_id
  795. * @param string $type
  796. * @return mixed
  797. * @throws \Exception
  798. *
  799. * @date 2023/11/02
  800. * @author yyw
  801. */
  802. public function getMerchantSellProductInfo(int $mer_id, string $type = 'count')
  803. {
  804. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  805. $productRepository = app()->make(ProductRepository::class);
  806. $data = [];
  807. $productType = 0;
  808. $sell_count = $productRepository->search($mer_id, $productRepository->switchType(1, $mer_id, $productType))->count();
  809. $sell_path = '/'.$this->merchant_prefix.'/product/list?type=1';
  810. switch ($type) {
  811. case 'count':
  812. $data[] = [
  813. 'title' => '出售商品',
  814. 'icon' => 'iconzaishoushangpin',
  815. 'path' => $sell_path,
  816. 'count' => $sell_count,
  817. 'children' => []
  818. ];
  819. break;
  820. case 'todo':
  821. break;
  822. }
  823. return $data;
  824. });
  825. }
  826. /**
  827. * 售罄商品
  828. * @param int $mer_id
  829. * @param string $type
  830. * @return mixed
  831. * @throws \Exception
  832. *
  833. * @date 2023/11/02
  834. * @author yyw
  835. */
  836. public function getMerchantSellOutProductInfo(int $mer_id, string $type = 'count')
  837. {
  838. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  839. $productRepository = app()->make(ProductRepository::class);
  840. $data = [];
  841. $productType = 0;
  842. $sell_out_count = $productRepository->search($mer_id, $productRepository->switchType(3, $mer_id, $productType))->count();
  843. $sell_out_path = '/'.$this->merchant_prefix.'/product/list?type=3';
  844. switch ($type) {
  845. case 'count':
  846. $data[] = [
  847. 'title' => '售罄商品',
  848. 'icon' => 'iconshouqingshangpin',
  849. 'path' => $sell_out_path,
  850. 'count' => $sell_out_count,
  851. 'children' => []
  852. ];
  853. break;
  854. case 'todo':
  855. if ($sell_out_count > 0) {
  856. $data[] = [
  857. 'title' => '已售罄商品提醒',
  858. 'path' => $sell_out_path,
  859. 'message' => '您有' . $sell_out_count . '个商品已售罄'
  860. ];
  861. }
  862. break;
  863. }
  864. return $data;
  865. });
  866. }
  867. /**
  868. * 警戒库存商品
  869. * @param int $mer_id
  870. * @param string $type
  871. * @return mixed
  872. * @throws \Exception
  873. *
  874. * @date 2023/11/02
  875. * @author yyw
  876. */
  877. public function getMerchantAlertProductInfo(int $mer_id, string $type = 'count')
  878. {
  879. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  880. $productRepository = app()->make(ProductRepository::class);
  881. $data = [];
  882. $productType = 0;
  883. $alert_count = $productRepository->search($mer_id, $productRepository->switchType(4, $mer_id, $productType))->count();
  884. $alert_path = '/'.$this->merchant_prefix.'/product/list?type=4';
  885. switch ($type) {
  886. case 'count':
  887. $data[] = [
  888. 'title' => '警戒库存商品',
  889. 'icon' => 'iconjingjiekucun',
  890. 'path' => $alert_path,
  891. 'count' => $alert_count,
  892. 'children' => []
  893. ];
  894. break;
  895. case 'todo':
  896. if ($alert_count) {
  897. $data[] = [
  898. 'title' => '警戒库存商品提醒',
  899. 'path' => $alert_path,
  900. 'message' => '您有' . $alert_count . '个商品已售罄'
  901. ];
  902. }
  903. break;
  904. }
  905. return $data;
  906. });
  907. }
  908. /**
  909. * 审核未通过普通商品
  910. * @param int $mer_id
  911. * @param string $type
  912. * @return array
  913. *
  914. * @date 2023/10/25
  915. * @author yyw
  916. */
  917. public function getMerchantRefuseProductInfo(int $mer_id, string $type = 'count')
  918. {
  919. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  920. $productRepository = app()->make(ProductRepository::class);
  921. $data = [];
  922. // 普通商品
  923. $refuse_count = $productRepository->search($mer_id, $productRepository->switchType(7, $mer_id, 0))->count();
  924. // 审核未通过活动商品
  925. $seckill_count = $productRepository->search($mer_id, $productRepository->switchType(7, null, 1))->count();
  926. $group_count = app()->make(ProductGroupRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  927. $presell_count = app()->make(ProductPresellRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  928. $assist_count = app()->make(ProductAssistRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  929. $live_room_count = app()->make(BroadcastRoomRepository::class)->search(['mer_id' => $mer_id, 'status_tag' => -1])->count();
  930. $live_goods_count = app()->make(BroadcastGoodsRepository::class)->search(['mer_id' => $mer_id, 'status_tag' => -1])->count();
  931. // 分销礼包
  932. $distribution_count = $productRepository->search($mer_id, $productRepository->switchType(6, null, 10))->count();
  933. $refuse_path = '/'.$this->merchant_prefix.'/product/list?type=7';
  934. $seckill_path = '/'.$this->merchant_prefix.'/marketing/seckill/product/list?type=-1';
  935. $group_path = '/'.$this->merchant_prefix.'/marketing/combination/combination_goods?product_status=-1';
  936. $presell_path = '/'.$this->merchant_prefix.'/marketing/presell/list?product_status=-1';
  937. $assist_path = '/'.$this->merchant_prefix.'/marketing/assist/list?product_status=-1';
  938. $live_room_path = '/'.$this->merchant_prefix.'/marketing/studio/list?status_tag=-1';
  939. $live_goods_path = '/'.$this->merchant_prefix.'/marketing/broadcast/list?status_tag=-1';
  940. $distribution_path = '/'.$this->merchant_prefix.'/product/list?type=6&is_gift_bag=1';
  941. $status_path = '/'.$this->merchant_prefix.'/product/list?type=7';
  942. switch ($type) {
  943. case 'count':
  944. $children = [];
  945. if ($refuse_count > 0) {
  946. $children[] = [
  947. 'title' => '普通商品',
  948. 'path' => $refuse_path,
  949. 'count' => $refuse_count,
  950. 'message' => '普通商品(' . $refuse_count . ')',
  951. ];
  952. }
  953. if ($seckill_count > 0) {
  954. $children[] = [
  955. 'title' => '秒杀',
  956. 'path' => $seckill_path,
  957. 'count' => $seckill_count,
  958. 'message' => '秒杀(' . $seckill_count . ')',
  959. ];
  960. }
  961. if ($group_count > 0) {
  962. $children[] = [
  963. 'title' => '拼团',
  964. 'path' => $group_path,
  965. 'count' => $group_count,
  966. 'message' => '拼团(' . $group_count . ')',
  967. ];
  968. }
  969. if ($assist_count > 0) {
  970. $children[] = [
  971. 'title' => '助力',
  972. 'path' => $assist_path,
  973. 'count' => $assist_count,
  974. 'message' => '助力(' . $assist_count . ')',
  975. ];
  976. }
  977. if ($presell_count > 0) {
  978. $children[] = [
  979. 'title' => '预售',
  980. 'path' => $presell_path,
  981. 'count' => $presell_count,
  982. 'message' => '预售(' . $presell_count . ')',
  983. ];
  984. }
  985. if ($live_room_count > 0) {
  986. $children[] = [
  987. 'title' => '直播间',
  988. 'path' => $live_room_path,
  989. 'count' => $live_room_count,
  990. 'message' => '直播间(' . $live_room_count . ')',
  991. ];
  992. }
  993. if ($live_goods_count > 0) {
  994. $children[] = [
  995. 'title' => '直播间商品',
  996. 'path' => $live_goods_path,
  997. 'count' => $live_goods_count,
  998. 'message' => '直播间商品(' . $live_goods_count . ')',
  999. ];
  1000. }
  1001. if ($distribution_count > 0) {
  1002. $children[] = [
  1003. 'title' => '分销礼包商品',
  1004. 'path' => $distribution_path,
  1005. 'count' => $distribution_count,
  1006. 'message' => '分销礼包商品(' . $distribution_count . ')',
  1007. ];
  1008. }
  1009. $count = 0;
  1010. foreach ($children as $child) {
  1011. $count += $child['count'];
  1012. }
  1013. $data[] = [
  1014. 'title' => '审核未通过商品',
  1015. 'icon' => 'iconputongshangpin',
  1016. 'path' => $status_path,
  1017. 'count' => $count,
  1018. 'children' => $children
  1019. ];
  1020. break;
  1021. case 'todo':
  1022. if ($refuse_count > 0) {
  1023. $data[] = [
  1024. 'title' => '普通商品审核未通过提醒',
  1025. 'path' => $refuse_path,
  1026. 'message' => '您有' . $refuse_count . '个普通商品审核未通过'
  1027. ];
  1028. }
  1029. if ($seckill_count > 0) {
  1030. $data[] = [
  1031. 'title' => '秒杀商品审核未通过提醒',
  1032. 'path' => $seckill_path,
  1033. 'message' => '您有' . $seckill_count . '个秒杀商品审核未通过'
  1034. ];
  1035. }
  1036. if ($group_count > 0) {
  1037. $data[] = [
  1038. 'title' => '拼团商品审核未通过提醒',
  1039. 'path' => $group_path,
  1040. 'message' => '您有' . $group_count . '个拼团商品审核未通过'
  1041. ];
  1042. }
  1043. if ($assist_count > 0) {
  1044. $data[] = [
  1045. 'title' => '助力商品审核未通过提醒',
  1046. 'path' => $assist_path,
  1047. 'message' => '您有' . $assist_count . '个助力商品审核未通过'
  1048. ];
  1049. }
  1050. if ($presell_count > 0) {
  1051. $data[] = [
  1052. 'title' => '预售商品审核未通过提醒',
  1053. 'path' => $presell_path,
  1054. 'message' => '您有' . $presell_count . '个预售商品审核未通过'
  1055. ];
  1056. }
  1057. if ($live_room_count > 0) {
  1058. $data[] = [
  1059. 'title' => '直播商品审核未通过提醒',
  1060. 'path' => $live_room_path,
  1061. 'message' => '您有' . $live_room_count . '个直播商品审核未通过'
  1062. ];
  1063. }
  1064. if ($live_goods_count > 0) {
  1065. $data[] = [
  1066. 'title' => '直播间审核未通过提醒',
  1067. 'path' => $live_goods_path,
  1068. 'message' => '您有' . $live_goods_count . '个直播间审核未通过'
  1069. ];
  1070. }
  1071. if ($distribution_count > 0) {
  1072. $data[] = [
  1073. 'title' => '分销礼包审核未通过提醒',
  1074. 'path' => $distribution_path,
  1075. 'message' => '您有' . $distribution_count . '个分销礼包审核未通过'
  1076. ];
  1077. }
  1078. break;
  1079. }
  1080. return $data;
  1081. });
  1082. }
  1083. public function getMerchantActivityProductInfo(int $mer_id, string $type = 'count')
  1084. {
  1085. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1086. $productRepository = app()->make(ProductRepository::class);
  1087. $seckill_count = $productRepository->search($mer_id, $productRepository->switchType(7, null, 1))->count();
  1088. $group_count = app()->make(ProductGroupRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  1089. $presell_count = app()->make(ProductPresellRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  1090. $assist_count = app()->make(ProductAssistRepository::class)->search(['mer_id' => $mer_id, 'product_status' => -1])->count();
  1091. $live_room_count = app()->make(BroadcastRoomRepository::class)->search(['mer_id' => $mer_id, 'status_tag' => -1])->count();
  1092. $live_goods_count = app()->make(BroadcastGoodsRepository::class)->search(['mer_id' => $mer_id, 'status_tag' => -1])->count();
  1093. $seckill_path = '/'.$this->merchant_prefix.'/marketing/seckill/list?type=-1';
  1094. $group_path = '/'.$this->merchant_prefix.'/marketing/combination/combination_goods?product_status=-1';
  1095. $presell_path = '/'.$this->merchant_prefix.'/marketing/presell/list?product_status=-1';
  1096. $assist_path = '/'.$this->merchant_prefix.'/marketing/assist/list?product_status=-1';
  1097. $live_room_path = '/'.$this->merchant_prefix.'/marketing/studio/list?status_tag=-1';
  1098. $live_goods_path = '/'.$this->merchant_prefix.'/marketing/broadcast/list?status_tag=-1';
  1099. $data = [];
  1100. switch ($type) {
  1101. case 'count':
  1102. $children = [];
  1103. if ($seckill_count > 0) {
  1104. $children[] = [
  1105. 'title' => '秒杀',
  1106. 'path' => $seckill_path,
  1107. 'count' => $seckill_count,
  1108. 'message' => '秒杀(' . $seckill_count . ')',
  1109. ];
  1110. }
  1111. if ($group_count > 0) {
  1112. $children[] = [
  1113. 'title' => '拼团',
  1114. 'path' => $group_path,
  1115. 'count' => $group_count,
  1116. 'message' => '拼团(' . $group_count . ')',
  1117. ];
  1118. }
  1119. if ($assist_count > 0) {
  1120. $children[] = [
  1121. 'title' => '助力',
  1122. 'path' => $assist_path,
  1123. 'count' => $assist_count,
  1124. 'message' => '助力(' . $assist_count . ')',
  1125. ];
  1126. }
  1127. if ($presell_count > 0) {
  1128. $children[] = [
  1129. 'title' => '预售',
  1130. 'path' => $presell_path,
  1131. 'count' => $presell_count,
  1132. 'message' => '预售(' . $presell_count . ')',
  1133. ];
  1134. }
  1135. if ($live_room_count > 0) {
  1136. $children[] = [
  1137. 'title' => '直播间',
  1138. 'path' => $live_room_path,
  1139. 'count' => $live_room_count,
  1140. 'message' => '直播间(' . $live_room_count . ')',
  1141. ];
  1142. }
  1143. if ($live_goods_count > 0) {
  1144. $children[] = [
  1145. 'title' => '直播间商品',
  1146. 'path' => $live_goods_path,
  1147. 'count' => $live_goods_count,
  1148. 'message' => '直播间商品(' . $live_goods_count . ')',
  1149. ];
  1150. }
  1151. $count = 0;
  1152. foreach ($children as $child) {
  1153. $count += $child['count'];
  1154. }
  1155. $data[] = [
  1156. 'title' => '审核未通过活动商品',
  1157. 'icon' => 'iconhuodongshangpin',
  1158. 'path' => '/',
  1159. 'count' => $count,
  1160. 'children' => $children
  1161. ];
  1162. break;
  1163. case 'todo':
  1164. if ($seckill_count > 0) {
  1165. $data[] = [
  1166. 'title' => '秒杀商品审核未通过提醒',
  1167. 'path' => $seckill_path,
  1168. 'message' => '您有' . $seckill_count . '个秒杀商品审核未通过'
  1169. ];
  1170. }
  1171. if ($group_count > 0) {
  1172. $data[] = [
  1173. 'title' => '拼团商品审核未通过提醒',
  1174. 'path' => $group_path,
  1175. 'message' => '您有' . $group_count . '个拼团商品审核未通过'
  1176. ];
  1177. }
  1178. if ($assist_count > 0) {
  1179. $data[] = [
  1180. 'title' => '助力商品审核未通过提醒',
  1181. 'path' => $assist_path,
  1182. 'message' => '您有' . $assist_count . '个助力商品审核未通过'
  1183. ];
  1184. }
  1185. if ($presell_count > 0) {
  1186. $data[] = [
  1187. 'title' => '预售商品审核未通过提醒',
  1188. 'path' => $presell_path,
  1189. 'message' => '您有' . $presell_count . '个预售商品审核未通过'
  1190. ];
  1191. }
  1192. if ($live_room_count > 0) {
  1193. $data[] = [
  1194. 'title' => '直播商品审核未通过提醒',
  1195. 'path' => $live_room_path,
  1196. 'message' => '您有' . $live_room_count . '个直播商品审核未通过'
  1197. ];
  1198. }
  1199. if ($live_goods_count > 0) {
  1200. $data[] = [
  1201. 'title' => '直播间审核未通过提醒',
  1202. 'path' => $live_goods_path,
  1203. 'message' => '您有' . $live_goods_count . '个直播间审核未通过'
  1204. ];
  1205. }
  1206. break;
  1207. }
  1208. return $data;
  1209. });
  1210. }
  1211. /**
  1212. * 待发货订单
  1213. * @param int $mer_id
  1214. * @param string $type
  1215. * @return mixed
  1216. * @throws \Exception
  1217. *
  1218. * @date 2023/11/02
  1219. * @author yyw
  1220. */
  1221. public function getMerchantOrderShipInfo(int $mer_id, string $type = 'count')
  1222. {
  1223. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1224. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  1225. $stay_delivery_count = $storeOrderRepository->search(['mer_id' => $mer_id])->where($storeOrderRepository->getOrderType(2))->count();
  1226. $stay_delivery_path = '/'.$this->merchant_prefix.'/order/list?status=2';
  1227. $data = [];
  1228. switch ($type) {
  1229. case 'count':
  1230. $data[] = [
  1231. 'title' => '待发货订单',
  1232. 'icon' => 'icondaifahuo2',
  1233. 'path' => $stay_delivery_path,
  1234. 'count' => $stay_delivery_count,
  1235. 'children' => []
  1236. ];
  1237. break;
  1238. case 'todo':
  1239. if ($stay_delivery_count) {
  1240. $data[] = [
  1241. 'title' => '待发货订单提醒',
  1242. 'path' => $stay_delivery_path,
  1243. 'message' => '您有' . $stay_delivery_count . '个待发货的订单'
  1244. ];
  1245. }
  1246. break;
  1247. }
  1248. return $data;
  1249. });
  1250. }
  1251. /**
  1252. * 待核销订单
  1253. * @param int $mer_id
  1254. * @param string $type
  1255. * @return mixed
  1256. * @throws \Exception
  1257. *
  1258. * @date 2023/11/02
  1259. * @author yyw
  1260. */
  1261. public function getMerchantPendWriteOffOrderInfo(int $mer_id, string $type = 'count')
  1262. {
  1263. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1264. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  1265. $stay_cancel_count = $storeOrderRepository->search(['mer_id' => $mer_id, 'order_type' => 1, 'status' => 0, 'paid' => 1])->count();
  1266. $stay_cancel_path = '/'.$this->merchant_prefix.'/order/list?order_type=1&type=1';
  1267. $data = [];
  1268. switch ($type) {
  1269. case 'count':
  1270. $data[] = [
  1271. 'title' => '待核销订单',
  1272. 'icon' => 'icondaihexiao',
  1273. 'path' => $stay_cancel_path,
  1274. 'count' => $stay_cancel_count,
  1275. 'children' => []
  1276. ];
  1277. break;
  1278. case 'todo':
  1279. if ($stay_cancel_count > 0) {
  1280. $data[] = [
  1281. 'title' => '待核销订单提醒',
  1282. 'path' => $stay_cancel_path,
  1283. 'message' => '您有' . $stay_cancel_count . '个待核销的订单'
  1284. ];
  1285. }
  1286. break;
  1287. }
  1288. return $data;
  1289. });
  1290. }
  1291. /**
  1292. * 待退款订单
  1293. * @param int $mer_id
  1294. * @param string $type
  1295. * @return mixed
  1296. * @throws \Exception
  1297. *
  1298. * @date 2023/10/25
  1299. * @author yyw
  1300. */
  1301. public function getMerchantRefundOrderInfo(int $mer_id, string $type = 'count')
  1302. {
  1303. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1304. $storeRefundOrderRepository = app()->make(StoreRefundOrderRepository::class);
  1305. $stay_refund_count = $storeRefundOrderRepository->search(['mer_id' => $mer_id, 'status' => 0])->count();
  1306. $stay_refund_path = '/'.$this->merchant_prefix.'/order/refund?status=0';
  1307. $data = [];
  1308. switch ($type) {
  1309. case 'count':
  1310. $data[] = [
  1311. 'title' => '待退款订单',
  1312. 'icon' => 'icondaituikuan',
  1313. 'path' => $stay_refund_path,
  1314. 'count' => $stay_refund_count,
  1315. 'children' => []
  1316. ];
  1317. break;
  1318. case 'todo':
  1319. if ($stay_refund_count > 0) {
  1320. $data[] = [
  1321. 'title' => '待退款订单提醒',
  1322. 'path' => $stay_refund_path,
  1323. 'message' => '您有' . $stay_refund_count . '个待退款的订单'
  1324. ];
  1325. }
  1326. break;
  1327. }
  1328. return $data;
  1329. });
  1330. }
  1331. /**
  1332. * 获取商户商品评论代办
  1333. * @param int $mer_id
  1334. * @param string $type
  1335. * @return mixed
  1336. * @throws \Exception
  1337. *
  1338. * @date 2023/10/25
  1339. * @author yyw
  1340. */
  1341. public function getMerchantStayReviewsInfo(int $mer_id, string $type = 'count')
  1342. {
  1343. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1344. $productRepository = app()->make(ProductReplyRepository::class);
  1345. $count = $productRepository->searchJoinQuery(['mer_id' => $mer_id, 'is_reply' => 0, 'is_del' => 0])->count();
  1346. $path = '/'.$this->merchant_prefix.'/product/reviews?is_reply=0';
  1347. $data = [];
  1348. switch ($type) {
  1349. case 'count':
  1350. $data[] = [
  1351. 'title' => '待回复评论',
  1352. 'icon' => 'icondaihuifu',
  1353. 'path' => $path,
  1354. 'count' => $count,
  1355. 'children' => []
  1356. ];
  1357. break;
  1358. case 'todo':
  1359. if ($count > 0) {
  1360. $data[] = [
  1361. 'title' => '评论回复提醒',
  1362. 'path' => $path,
  1363. 'message' => '您有' . $count . '个评论待回复'
  1364. ];
  1365. }
  1366. break;
  1367. }
  1368. return $data;
  1369. });
  1370. }
  1371. /**
  1372. * 获取开发票订单信息
  1373. * @param int $mer_id
  1374. * @param string $type
  1375. * @return mixed
  1376. * @throws \Exception
  1377. *
  1378. * @date 2023/10/25
  1379. * @author yyw
  1380. */
  1381. public function getMerchantOrderReceiptInfo(int $mer_id, string $type = 'count')
  1382. {
  1383. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1384. $storeOrderReceiptRepository = app()->make(StoreOrderReceiptRepository::class);
  1385. $count = $storeOrderReceiptRepository->search(['mer_id' => $mer_id, 'status' => 0])->count();
  1386. $path = '/'.$this->merchant_prefix.'/order/invoice?status=0';
  1387. $data = [];
  1388. switch ($type) {
  1389. case 'count':
  1390. $data[] = [
  1391. 'title' => '待开发票',
  1392. 'icon' => 'icondaikaipiao',
  1393. 'path' => $path,
  1394. 'count' => $count,
  1395. 'children' => []
  1396. ];
  1397. break;
  1398. case 'todo':
  1399. if ($count > 0) {
  1400. $data[] = [
  1401. 'title' => '待开票订单提醒',
  1402. 'path' => $path,
  1403. 'message' => '您有' . $count . '个待开票的订单'
  1404. ];
  1405. }
  1406. break;
  1407. }
  1408. return $data;
  1409. });
  1410. }
  1411. public function getMerchantNoticeInfo(int $mer_id, string $type = 'count')
  1412. {
  1413. return $this->cache(__FUNCTION__, function () use ($mer_id, $type) {
  1414. $systemNoticeLogRepository = app()->make(SystemNoticeLogRepository::class);
  1415. $count = $systemNoticeLogRepository->search(['mer_id' => $mer_id, 'is_read' => 0, 'is_del' => 0])->count();
  1416. $path = '/'.$this->merchant_prefix.'/station/notice?is_read=0';
  1417. $data = [];
  1418. switch ($type) {
  1419. case 'count':
  1420. if ($count > 0) {
  1421. $data[] = [
  1422. 'title' => '平台公告',
  1423. 'icon' => '',
  1424. 'path' => $path,
  1425. 'count' => $count,
  1426. 'children' => []
  1427. ];
  1428. }
  1429. break;
  1430. case 'todo':
  1431. if ($count > 0) {
  1432. $data[] = [
  1433. 'title' => '平台公告',
  1434. 'path' => $path,
  1435. 'message' => '您有' . $count . '条未读消息'
  1436. ];
  1437. }
  1438. break;
  1439. }
  1440. return $data;
  1441. });
  1442. }
  1443. /**
  1444. * 获取商户商品销售金额排行
  1445. * @param string $date
  1446. * @return array
  1447. *
  1448. * @date 2023/10/21
  1449. * @author yyw
  1450. */
  1451. public function getMerchantProductSalesPriceTop(int $mer_id, string $date)
  1452. {
  1453. return $this->cache(__FUNCTION__, function () use ($mer_id, $date) {
  1454. $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
  1455. $list = $storeOrderProductRepository->getProductRate($mer_id, $date);
  1456. return compact('list');
  1457. });
  1458. }
  1459. }