AllwinInfoConfig.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 信息配置
  7. */
  8. namespace app\allwin\model;
  9. use think\Model;
  10. class AllwinInfoConfig extends Model{
  11. protected $pk = 'id';
  12. /**
  13. * 读取信息配置
  14. * @return void
  15. */
  16. public static function config(int $id){
  17. return self::where(['member_miniapp_id' => $id])->find();
  18. }
  19. /**
  20. * 配置
  21. * @return void
  22. */
  23. public static function edit(array $param,int $miniapp_id){
  24. $today = [];
  25. foreach ($param['today'] as $key => $value) {
  26. switch ($key) {
  27. case 1:
  28. $today[$key]['day'] = 7;
  29. break;
  30. case 2:
  31. $today[$key]['day'] = 15;
  32. break;
  33. case 3:
  34. $today[$key]['day'] = 30;
  35. break;
  36. default:
  37. $today[$key]['day'] = 2;
  38. break;
  39. }
  40. $today[$key]['money'] = $value*100;
  41. }
  42. $data['topday'] = json_encode($today);
  43. $data['charge'] = $param['charge'];
  44. $data['bring'] = $param['bring'];
  45. $data['reward'] = $param['reward'];
  46. $rel = self::where(['member_miniapp_id' => $miniapp_id])->find();
  47. if(empty($rel)){
  48. $data['member_miniapp_id'] = $miniapp_id;
  49. return self::insert($data);
  50. }else{
  51. return self::where(['member_miniapp_id' => $miniapp_id])->update($data);
  52. }
  53. }
  54. }