ApplyService.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace bizGhs\apply\services;
  3. use biz\cp\services\PtCpService;
  4. use biz\shop\classes\ShopClass;
  5. use bizGhs\apply\classes\ApplyClass;
  6. use bizGhs\item\classes\ItemClassClass;
  7. use bizGhs\merchant\services\MerchantService;
  8. use bizGhs\shop\classes\MainClass;
  9. use bizHd\merchant\services\SjService;
  10. use common\components\util;
  11. use bizGhs\base\services\BaseService;
  12. class ApplyService extends BaseService
  13. {
  14. public static $baseFile = '\bizGhs\apply\classes\ApplyClass';
  15. //审核通过,商家初始化 ssh 2021.2.23
  16. public static function pass($id, $remark = '')
  17. {
  18. $apply = ApplyClass::getById($id);
  19. if (empty($apply)) {
  20. util::fail('没有找到申请记录');
  21. }
  22. $applyId = $apply['id'];
  23. $live = isset($apply['live']) ? $apply['live'] : 1;
  24. $mobile = $apply['mobile'] ?? '';
  25. if (empty($mobile)) {
  26. util::fail('没有找到手机号');
  27. }
  28. $lsShop = ShopClass::getByCondition(['mobile' => $mobile, 'ptStyle' => 1], true);
  29. if (empty($lsShop)) {
  30. $main = MainClass::addMain();
  31. $ret = SjService::initHdBaseInfo($apply, $main);
  32. $lsShop = $ret['shop'] ?? [];
  33. } else {
  34. $mainId = $lsShop->mainId ?? 0;
  35. $lsShop->onlyCg = 0;
  36. $lsShop->save();
  37. $main = MainClass::getById($mainId, true);
  38. if (empty($main)) {
  39. util::fail('没有main信息21');
  40. }
  41. }
  42. ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS, 'remark' => $remark]);
  43. $apply['name'] = isset($apply['name']) ? $apply['name'] : '';
  44. //初始化或更新花材
  45. if (isset($apply['all']) && $apply['all'] == 1) {
  46. MainClass::addMainInitItem($main, $live);
  47. } else {
  48. //单品不需要导入花材
  49. $mainId = $main->id ?? 0;
  50. $classData = ['mainId' => $mainId, 'name' => '默认分类', 'inTurn' => -1, 'isDefault' => 1,];
  51. ItemClassClass::add($classData, true);
  52. }
  53. //初始化或更新产品
  54. //PtCpService::initMainCp($main);
  55. $respond = MerchantService::initGhsBaseInfo($apply, $main, true);
  56. $pfShop = $respond['shop'] ?? [];
  57. $lsShop->pfShopId = $pfShop->id ?? 0;
  58. $lsShop->save();
  59. $pfShop->lsShopId = $lsShop->id ?? 0;
  60. $pfShop->save();
  61. return $respond;
  62. }
  63. }