123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace app\admin\server\package;
- use app\admin\controller\package\Package;
- use app\admin\model\PackageGoods;
- use app\admin\model\SystemAdmin;
- use app\admin\model\SystemMenu;
- use app\admin\model\SystemRole;
- class PackageGoodsServer
- {
- /**
- * Notes:产品列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: QJF
- * Date: 2022/9/20
- */
- public static function getPackageGoodsList(int $page, int $limit, $keywords)
- {
- [$list, $count] = PackageGoods::getPackageGoodsList($page, $limit, $keywords);
- return compact('list', 'page', 'limit', 'count');
- }
- /**
- * Notes: 添加产品
- * @param array $param
- * @return int
- * User: QJF
- * Date: 2022/9/20
- */
- public static function insertPackage(array $param)
- {
- SystemRole::affairBegin();
- try {
- $param['goods_create_time'] = time();
- $param['goods_update_time'] = time();
- $result = PackageGoods::insertGetId($param);
- if (!empty($result)){
- SystemRole::affairCommit();
- return $result;
- }
- throw new \Exception('操作失败!');
- }catch (\Exception $exception){
- SystemRole::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:修改角色
- * @param array $param
- * @return int
- * User: QJF
- * Date: 2022/9/19
- */
- public static function updatePackageGoods($param)
- {
- SystemRole::affairBegin();
- try {
- $where = [];
- $where['goods_id'] = $param['goods_id'];
- $param['goods_update_time'] = time();
- $result = PackageGoods::where($where)->update($param);
- if ($result !== false){
- SystemRole::affairCommit();
- return true;
- }
- throw new \Exception('操作失败!');
- }catch (\Exception $exception){
- SystemRole::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:任务
- * @param int $role_id
- * @return int
- * User: QJF
- * Date: 2022/9/19
- */
- public static function delPackageGoods($goods_id,$goods_status)
- {
- SystemRole::affairBegin();
- try {
- $where = [];
- $where['goods_id'] = $goods_id;
- $data['goods_status'] = $goods_status;
- $data['goods_update_time'] = time();
- $result = PackageGoods::where($where)->update($data);
- if (!empty($result)){
- SystemRole::affairCommit();
- return true;
- }else{
- return false;
- }
- }catch (\Exception $exception){
- SystemRole::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:获取权益包详情
- * @param int $package_id
- * @return int
- * User: QJF
- * Date: 2022/9/19
- */
- public static function infoPackage($goods_id)
- {
- SystemRole::affairBegin();
- try {
- $where = [];
- $where['goods_id'] = $goods_id;
- $result = PackageGoods::where($where)->first();
- if (!empty($result)){
- SystemRole::affairCommit();
- return $result;
- }else{
- return false;
- }
- }catch (\Exception $exception){
- SystemRole::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- }
|