ShippingTemplateFreeRepository.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\common\repositories\store\shipping;
  12. use app\common\repositories\BaseRepository;
  13. use app\common\dao\store\shipping\ShippingTemplateFreeDao as dao;
  14. class ShippingTemplateFreeRepository extends BaseRepository
  15. {
  16. /**
  17. * ShippingTemplateFreeRepository constructor.
  18. * @param dao $dao
  19. */
  20. public function __construct(dao $dao)
  21. {
  22. $this->dao = $dao;
  23. }
  24. /**
  25. * @Author:Qinii
  26. * @Date: 2020/5/8
  27. * @param $merId
  28. * @param $id
  29. * @return bool
  30. */
  31. public function merExists($merId , $id)
  32. {
  33. $result = $this->dao->get($id);
  34. $make = app()->make(ShippingTemplateRepository::class);
  35. if ($result)
  36. return $make->merExists($merId,$result['temp_id']);
  37. return false;
  38. }
  39. /**
  40. * @Author:Qinii
  41. * @Date: 2020/5/8
  42. * @param $id
  43. * @param $data
  44. */
  45. public function update($id,$data)
  46. {
  47. foreach ($data as $item){
  48. if(isset($item['shipping_template_free_id']) && $item['shipping_template_free_id']){
  49. $item['city_id'] = implode('/',$item['city_id']);
  50. $this->dao->update($item['shipping_template_free_id'],$item);
  51. }else{
  52. $item['temp_id'] = $id;
  53. $this->dao->create($item);
  54. }
  55. }
  56. }
  57. /**
  58. * @Author:Qinii
  59. * @Date: 2020/5/13
  60. * @param array $data
  61. * @return mixed
  62. */
  63. public function insertAll(array $data)
  64. {
  65. return $this->dao->insertAll($data);
  66. }
  67. }