DeliveryRule.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 cores\BaseModel;
  14. use app\common\library\helper;
  15. /**
  16. * 配送模板区域及运费模型
  17. * Class DeliveryRule
  18. * @package app\store\model
  19. */
  20. class DeliveryRule extends BaseModel
  21. {
  22. // 定义表名
  23. protected $name = 'delivery_rule';
  24. // 定义主键
  25. protected $pk = 'rule_id';
  26. protected $updateTime = false;
  27. /**
  28. * 获取器:可配送区域转为数组格式
  29. * @param $value
  30. * @return array
  31. */
  32. public function getRegionAttr(string $value)
  33. {
  34. return helper::jsonDecode($value);
  35. }
  36. /**
  37. * 修改器:可配送区域转为json格式
  38. * @param array $value
  39. * @return string
  40. */
  41. public function setRegionAttr(array $value)
  42. {
  43. return helper::jsonEncode($value);
  44. }
  45. /**
  46. * 获取器:可配送区域(文字展示)转为数组格式
  47. * @param $value
  48. * @return array
  49. */
  50. public function getRegionTextAttr(string $value)
  51. {
  52. return helper::jsonDecode($value);
  53. }
  54. /**
  55. * 修改器:可配送区域转(文字展示)为json格式
  56. * @param array $value
  57. * @return string
  58. */
  59. public function setRegionTextAttr(array $value)
  60. {
  61. return helper::jsonEncode($value);
  62. }
  63. }