| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace biz\goods\services;
- use biz\admin\services\AdminService;
- use biz\base\services\BaseService;
- use biz\goods\classes\GoodsCategoryClass;
- use biz\goods\classes\GoodsClass;
- use common\components\util;
- use Yii;
- use linslin\yii2\curl;
- class GoodsService extends BaseService
- {
- public static $baseFile = '\biz\goods\classes\GoodsClass';
- //后台列表 shish 2019.12.7
- public static function getGoodsList($where)
- {
- if (isset($where['cId'])) {
- $data = GoodsCategoryClass::getList('*', $where, 'inTurn DESC', 'goods');
- $list = [];
- if (isset($data['list']) && !empty($data['list'])) {
- foreach ($data['list'] as $val) {
- $list[] = $val['goods'];
- }
- }
- } else {
- $data = GoodsClass::getList('*', $where, 'inTurn DESC,updateTime DESC');
- $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
- }
- if (empty($list)) {
- return $data;
- }
- $data['list'] = GoodsClass::groupGoodsBaseInfo($list);
- return $data;
- }
- //获取商品完整详情,包括分类 shish 2019.12.3
- public static function getGoodsInfo($id)
- {
- return GoodsClass::getGoodsInfo($id);
- }
- //删除商品 shish 2019.12.7
- public static function deleteGoods($goods)
- {
- $id = $goods['id'];
- GoodsClass::updateById($id, ['delStatus' => 1]);
- GoodsCategoryClass::updateByCondition(['gId' => $id], ['delStatus' => 1]);
- }
- //添加商品 shish 2019.12.7
- public static function addGoods($data)
- {
- return GoodsClass::addGoods($data);
- }
- //更新商品 shish 2019.12.7
- public static function updateGoods($id, $data)
- {
- return GoodsClass::updateGoods($id, $data);
- }
- //验证对此商品的操作权限 shish 2019.12.7
- public static function valid($info, $merchantId)
- {
- if (empty($info)) {
- util::fail('没有找到商品');
- }
- if ($info['merchantId'] != $merchantId) {
- util::fail('您没有权限操作');
- }
- }
- //上下架 shish 2019.12.8
- public static function changeStatus($id, $status)
- {
- GoodsClass::changeStatus($id, $status);
- }
- }
|