DeliveryRule.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model;
  13. use app\common\library\helper;
  14. /**
  15. * 配送模板区域及运费模型
  16. * Class DeliveryRule
  17. * @package app\store\model
  18. */
  19. class DeliveryRule extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'delivery_rule';
  23. // 定义主键
  24. protected $pk = 'rule_id';
  25. protected $updateTime = false;
  26. /**
  27. * 获取器:可配送区域转为数组格式
  28. * @param $value
  29. * @return array
  30. */
  31. public function getRegionAttr(string $value)
  32. {
  33. return helper::jsonDecode($value);
  34. }
  35. /**
  36. * 修改器:可配送区域转为json格式
  37. * @param array $value
  38. * @return string
  39. */
  40. public function setRegionAttr(array $value)
  41. {
  42. return helper::jsonEncode($value);
  43. }
  44. /**
  45. * 获取器:可配送区域(文字展示)转为数组格式
  46. * @param $value
  47. * @return array
  48. */
  49. public function getRegionTextAttr(string $value)
  50. {
  51. return helper::jsonDecode($value);
  52. }
  53. /**
  54. * 修改器:可配送区域转(文字展示)为json格式
  55. * @param array $value
  56. * @return string
  57. */
  58. public function setRegionTextAttr(array $value)
  59. {
  60. return helper::jsonEncode($value);
  61. }
  62. }