12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
- * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
- * @author pillar<ltmn@qq.com>
- * 信息配置
- */
- namespace app\allwin\model;
- use think\Model;
- class AllwinInfoConfig extends Model{
- protected $pk = 'id';
- /**
- * 读取信息配置
- * @return void
- */
- public static function config(int $id){
- return self::where(['member_miniapp_id' => $id])->find();
- }
- /**
- * 配置
- * @return void
- */
- public static function edit(array $param,int $miniapp_id){
- $today = [];
- foreach ($param['today'] as $key => $value) {
- switch ($key) {
- case 1:
- $today[$key]['day'] = 7;
- break;
- case 2:
- $today[$key]['day'] = 15;
- break;
- case 3:
- $today[$key]['day'] = 30;
- break;
- default:
- $today[$key]['day'] = 2;
- break;
- }
- $today[$key]['money'] = $value*100;
- }
- $data['topday'] = json_encode($today);
- $data['charge'] = $param['charge'];
- $data['bring'] = $param['bring'];
- $data['reward'] = $param['reward'];
- $rel = self::where(['member_miniapp_id' => $miniapp_id])->find();
- if(empty($rel)){
- $data['member_miniapp_id'] = $miniapp_id;
- return self::insert($data);
- }else{
- return self::where(['member_miniapp_id' => $miniapp_id])->update($data);
- }
- }
- }
|