截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MarketingConfigLogic.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\admin\logic\setting;
  3. use app\common\basics\Logic;
  4. use app\common\server\ConfigServer;
  5. use think\facade\Validate;
  6. /**
  7. * 营销逻辑
  8. * Class MarketingConfigLogic
  9. * @package app\admin\logic\setting
  10. */
  11. class MarketingConfigLogic extends Logic
  12. {
  13. /**
  14. * @notes 设置消费奖励
  15. * @param $post
  16. * @throws \think\Exception
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @author ljj
  21. * @date 2022/2/18 4:22 下午
  22. */
  23. public static function setOrderAward($post)
  24. {
  25. $open_award = isset($post['open_award']) && $post['open_award'] == 'on' ? 1 : 0;
  26. $award_event = $post['award_event'] ?? 0;
  27. $award_ratio = $post['award_ratio'] ?? '';
  28. if ($open_award == 1) {
  29. if (!isset($post['award_event']) || $post['award_event'] == '') {
  30. return '开启消费送积分时,赠送积分事件不能为空';
  31. }
  32. if (!isset($post['award_ratio']) || $post['award_ratio'] == '') {
  33. return '开启消费送积分时,赠送积分比例不能为空';
  34. }
  35. if (!Validate::isNumber($award_ratio)) {
  36. return '赠送积分比率必须为纯数字';
  37. }
  38. }
  39. ConfigServer::set('order_award','open_award',$open_award);
  40. ConfigServer::set('order_award','award_event',$award_event);
  41. ConfigServer::set('order_award','award_ratio',$award_ratio);
  42. return true;
  43. }
  44. }