AreaLogic.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. 'reduce_shipping_money' => $params['reduce_shipping_money']??0,
  40. 'reduce_shipping_fee' => $params['reduce_shipping_fee']??0,
  41. 'free_shipping_money' => $params['free_shipping_money']??0,
  42. 'shipping_fee' => $params['shipping_fee'] ?? 0,
  43. 'sort' => $params['sort'] ?? 0,
  44. 'is_show' => $params['is_show'] ?? YesNoEnum::YES,
  45. 'create_time' => time(),
  46. ];
  47. SpecialArea::create($data);
  48. }
  49. /**
  50. * @notes 查看文章/帮助详情
  51. * @param $params
  52. * @return array
  53. * @author Tab
  54. * @date 2021/7/13 16:53
  55. */
  56. public static function detail($params)
  57. {
  58. return SpecialArea::field('id,name,reduce_shipping_money,reduce_shipping_fee,free_shipping_money,shipping_fee,sort,is_show,is_show as is_show_desc')->findOrEmpty($params['id'])->toArray();
  59. }
  60. /**
  61. * @notes 编辑地区信息
  62. * @param $params
  63. * @author Tab
  64. * @date 2021/7/14 9:21
  65. */
  66. public static function edit($params)
  67. {
  68. $data = [
  69. 'id' => $params['id'],
  70. 'name' => $params['name'],
  71. 'reduce_shipping_money' => $params['reduce_shipping_money']??0,
  72. 'reduce_shipping_fee' => $params['reduce_shipping_fee']??0,
  73. 'free_shipping_money' => $params['free_shipping_money']??0,
  74. 'shipping_fee' => $params['shipping_fee'] ?? 0,
  75. 'sort' => $params['sort'] ?? 0,
  76. 'is_show' => $params['is_show'] ?? YesNoEnum::YES,
  77. ];
  78. SpecialArea::update($data);
  79. }
  80. /**
  81. * @notes 删除地区信息
  82. * @param $params
  83. * @author Tab
  84. * @date 2021/7/14 9:23
  85. */
  86. public static function delete($params)
  87. {
  88. SpecialArea::destroy($params['id']);
  89. }
  90. /**
  91. * @notes 修改是否显示状态
  92. * @param $params
  93. * @throws \think\db\exception\DataNotFoundException
  94. * @throws \think\db\exception\DbException
  95. * @throws \think\db\exception\ModelNotFoundException
  96. * @author Tab
  97. * @date 2021/7/14 11:36
  98. */
  99. public static function isShow($params)
  100. {
  101. $area = SpecialArea::find($params['id']);
  102. if(empty($area)){
  103. return false;
  104. }
  105. $area->is_show = $area->getData('is_show') ? 0: 1;
  106. $area->save();
  107. }
  108. }