ApplyService.php 2.7 KB

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