| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 | 
							- <?php
 
- namespace app\admin\server\index;
 
- use app\admin\model\Activity;
 
- use app\admin\model\SystemMenu;
 
- use support\Redis;
 
- class ActivityServer
 
- {
 
-     /**
 
-      * Notes:获取活动列表
 
-      * @param string $keywords
 
-      * @param int $page
 
-      * @param int $limit
 
-      * @return array
 
-      * User: YCP
 
-      * Date: 2023/2/23
 
-      */
 
-     public static function getActivityList(int $page, int $limit, string $keywords)
 
-     {
 
-         [$list, $count] =  Activity::getActivityList($page, $limit, $keywords);
 
-         return compact('list', 'page', 'limit', 'count');
 
-     }
 
-     /**
 
-      * Notes: 添加活动
 
-      * @param string $goods_name
 
-      * @param array $goods_rules
 
-      * @return int
 
-      * User: YCP
 
-      * Date: 2023/2/23
 
-      */
 
-     public static function insertActivity(array $params, int $admin_id)
 
-     {
 
-         Activity::affairBegin();
 
-         try {
 
-             $params['config_create_time'] = time();
 
-             $result =  Activity::insertGetId($params);
 
-             if (!empty($result)){
 
-                 $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '添加营销活动-编号: ' . $result;
 
-                 plog('life-activity-create', '添加营销活动', $msg);
 
-                 Activity::affairCommit();
 
-                 return $result;
 
-             }
 
-             throw new \Exception('操作失败!');
 
-         }catch (\Exception $exception){
 
-             Activity::affairRollback();
 
-             throw new \Exception($exception->getMessage(), 500);
 
-         }
 
-     }
 
-     /**
 
-      * Notes:修改活动
 
-      * @param string $goods_name
 
-      * @param int $goods_id
 
-      * @return int
 
-      * User: YCP
 
-      * Date: 2023/2/23
 
-      */
 
-     public static function updateActivity(array $params, int $admin_id)
 
-     {
 
-         Activity::affairBegin();
 
-         try {     
 
-             $where = [];
 
-             $where['config_id'] = $params['config_id'];
 
-             $info = Activity::where($where)->first();
 
-             if(empty($info) || $info === false)
 
-             {
 
-                 throw new \Exception('活动信息不存在');
 
-             }
 
-             $params['config_update_time'] = time();
 
-             $result = Activity::where($where)->update($params);
 
-             if ($result !== false){
 
-                 $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改营销活动-编号: ' . $params['config_id'];
 
-                 plog('life-activity-update', '修改营销活动', $msg);
 
-                 Activity::affairCommit();
 
-                 return true;
 
-             }
 
-             throw new \Exception('操作失败!');
 
-         }catch (\Exception $exception){
 
-             Activity::affairRollback();
 
-             throw new \Exception($exception->getMessage(), 500);
 
-         }
 
-     }
 
-     /**
 
-      * Notes:删除活动
 
-      * @param int $goods_id
 
-      * @return int
 
-      * User: YCP
 
-      * Date: 2023/2/23
 
-      */
 
-     public static function delActivity($config_id,$admin_id)
 
-     {
 
-         Activity::affairBegin();
 
-         try {
 
-             $where = [];
 
-             $where['config_id'] = $config_id;
 
-             $data['config_is_del'] = 1;
 
-             $result = Activity::where($where)->update($data);
 
-             if (!empty($result)){
 
-                 $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除营销活动-编号: ' . $config_id;
 
-                 plog('life-activity-delete', '删除营销活动', $msg);
 
-                 Activity::affairCommit();
 
-                 return true;
 
-             }else{
 
-                 return false;
 
-             }
 
-         }catch (\Exception $exception){
 
-             Activity::affairRollback();
 
-             throw new \Exception($exception->getMessage(), 500);
 
-         }
 
-     }
 
-     /**
 
-      * Notes:查询活动
 
-      * @param int $goods_id
 
-      * @return int
 
-      * User: YCP
 
-      * Date: 2022/10/18
 
-      */
 
-     public static function activityInfo($config_id)
 
-     {
 
-         $where = [];
 
-         $where['config_id'] = $config_id;
 
-         $result = Activity::where($where)->first();
 
-         if(empty($result) || $result === false)
 
-         {
 
-             throw new \Exception('活动信息不存在');
 
-         }
 
-         $result['activity_url'] = "https://service.wanyuewellness.cn/h5/#/?act=".$config_id;
 
-         return $result;
 
-     }
 
- }
 
 
  |