ShippingTemplateUndeliveRepository.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\ShippingTemplateUndeliveryDao as dao;
  14. class ShippingTemplateUndeliveRepository extends BaseRepository
  15. {
  16. /**
  17. * ShippingTemplateUndeliveRepository 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. if(isset($data['shipping_template_undelivery_id']) && $data['shipping_template_undelivery_id']){
  48. $data['city_id'] = implode('/',$data['city_id']);
  49. $this->dao->update($data['shipping_template_undelivery_id'],$data);
  50. }else{
  51. $data['temp_id'] = $id;
  52. $this->dao->create($data);
  53. }
  54. }
  55. }