AreaLogic.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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\adminapi\logic;
  20. use app\common\enum\ArticleEnum;
  21. use app\common\enum\DefaultEnum;
  22. use app\common\enum\YesNoEnum;
  23. use app\common\logic\BaseLogic;
  24. use app\common\model\Article;
  25. use app\common\model\SpecialArea;
  26. use app\common\service\FileService;
  27. class AreaLogic extends BaseLogic
  28. {
  29. /**
  30. * @notes 添加地区
  31. * @param $params
  32. * @author Tab
  33. * @date 2021/7/13 15:59
  34. */
  35. public static function add($params)
  36. {
  37. $data = [
  38. 'name' => $params['name'],
  39. 'free_shipping_money' => $params['free_shipping_money']??0,
  40. 'shipping_fee' => $params['shipping_fee'] ?? 0,
  41. 'sort' => $params['sort'] ?? 0,
  42. 'is_show' => $params['is_show'] ?? YesNoEnum::YES,
  43. 'create_time' => time(),
  44. ];
  45. SpecialArea::create($data);
  46. }
  47. /**
  48. * @notes 查看文章/帮助详情
  49. * @param $params
  50. * @return array
  51. * @author Tab
  52. * @date 2021/7/13 16:53
  53. */
  54. public static function detail($params)
  55. {
  56. return SpecialArea::field('id,name,free_shipping_money,shipping_fee,sort,is_show,is_show as is_show_desc')->findOrEmpty($params['id'])->toArray();
  57. }
  58. /**
  59. * @notes 编辑地区信息
  60. * @param $params
  61. * @author Tab
  62. * @date 2021/7/14 9:21
  63. */
  64. public static function edit($params)
  65. {
  66. $data = [
  67. 'id' => $params['id'],
  68. 'name' => $params['name'],
  69. 'free_shipping_money' => $params['free_shipping_money']??0,
  70. 'shipping_fee' => $params['shipping_fee'] ?? 0,
  71. 'sort' => $params['sort'] ?? 0,
  72. 'is_show' => $params['is_show'] ?? YesNoEnum::YES,
  73. ];
  74. SpecialArea::update($data);
  75. }
  76. /**
  77. * @notes 删除地区信息
  78. * @param $params
  79. * @author Tab
  80. * @date 2021/7/14 9:23
  81. */
  82. public static function delete($params)
  83. {
  84. SpecialArea::destroy($params['id']);
  85. }
  86. /**
  87. * @notes 修改是否显示状态
  88. * @param $params
  89. * @throws \think\db\exception\DataNotFoundException
  90. * @throws \think\db\exception\DbException
  91. * @throws \think\db\exception\ModelNotFoundException
  92. * @author Tab
  93. * @date 2021/7/14 11:36
  94. */
  95. public static function isShow($params)
  96. {
  97. $area = SpecialArea::find($params['id']);
  98. $area->is_show = $area->getData('is_show') ? 0: 1;
  99. $area->save();
  100. }
  101. }