IntegralGoods.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\common\model;
  20. use app\common\enum\IntegralGoodsEnum;
  21. use app\common\service\FileService;
  22. use think\model\concern\SoftDelete;
  23. /**
  24. * 积分商品模型
  25. * Class IntegralGoods
  26. * @package app\common\model
  27. */
  28. class IntegralGoods extends BaseModel
  29. {
  30. use SoftDelete;
  31. protected $deleteTime = 'delete_time';
  32. // 设置内容图片域名
  33. public function getContentAttr($value, $data)
  34. {
  35. $preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
  36. $fileUrl = FileService::getFileUrl();
  37. return preg_replace($preg, "\${1}$fileUrl\${2}\${3}", $value);
  38. }
  39. // 去除内容图片域名
  40. public function setContentAttr($value, $data)
  41. {
  42. $fileUrl = FileService::getFileUrl();
  43. $content = str_replace($fileUrl, '/', $value);
  44. return $content;
  45. }
  46. /**
  47. * @notes 商品类型描述
  48. * @param $value
  49. * @param $data
  50. * @return string|string[]
  51. * @author 段誉
  52. * @date 2022/3/30 11:59
  53. */
  54. public function getTypeDescAttr($value, $data)
  55. {
  56. return IntegralGoodsEnum::getTypeDesc($data['type']);
  57. }
  58. /**
  59. * @notes 兑换所需描述
  60. * @param $value
  61. * @param $data
  62. * @return string
  63. * @author 段誉
  64. * @date 2022/3/30 11:59
  65. */
  66. public function getNeedDescAttr($value, $data)
  67. {
  68. $desc = $data['need_integral'] . '积分+' . $data['need_money'] . '元';
  69. if ($data['type'] == IntegralGoodsEnum::TYPE_BALANCE || $data['exchange_way'] == IntegralGoodsEnum::EXCHANGE_WAY_INTEGRAL) {
  70. $desc = $data['need_integral'] . '积分';
  71. }
  72. return $desc;
  73. }
  74. }