app版本管理和商户商品的修改批发价格

This commit is contained in:
liu 2024-03-19 10:59:11 +08:00
parent 224f7707f1
commit 3371a7391e
5 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\dao\system;
use app\common\dao\BaseDao;
use app\common\model\BaseModel;
use app\common\model\system\AppUpdate;
use think\db\exception\DbException;
/**
* Class AppUpdateDao
* @package app\common\dao\system
* @author xaboy
* @day 2020-04-24
*/
class AppUpdateDao extends BaseDao
{
/**
* @return BaseModel
* @author xaboy
* @day 2020-03-30
*/
protected function getModel(): string
{
return AppUpdate::class;
}
public function search(array $where = [])
{
return AppUpdate::getDB()
->when(isset($where['id']) && $where['id'] !== '',function($query) use($where){
$query->where('id',$where['id']);
})
->when(isset($where['type']) && $where['type'] !== '',function($query) use($where){
$query->where('type',$where['type']);
});
}
public function delete(int $id)
{
return ($this->getModel()::getDB())->where('id', $id)->delete();
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace app\common\model\system;
use app\common\model\BaseModel;
class AppUpdate extends BaseModel
{
public static function tablePk(): string
{
return 'id';
}
public static function tableName(): string
{
return 'app_update';
}
}

View File

@ -308,6 +308,7 @@ class ProductRepository extends BaseRepository
unset($data['admin_info']); unset($data['admin_info']);
} }
return Db::transaction(function () use ($id, $data, $productType, $settleParams, $content, $product, $spuData, $merId) { return Db::transaction(function () use ($id, $data, $productType, $settleParams, $content, $product, $spuData, $merId) {
$productData = $this->save($id, $settleParams, $content, $product, $productType); $productData = $this->save($id, $settleParams, $content, $product, $productType);
if ($productType == 1) { //秒杀商品 if ($productType == 1) { //秒杀商品
@ -652,6 +653,8 @@ class ProductRepository extends BaseRepository
!$cdkeey_stock ?: $value['stock'] = $cdkeey_stock; !$cdkeey_stock ?: $value['stock'] = $cdkeey_stock;
} }
$new_price = $value['price'] ? (($value['price'] < 0) ? 0 : $value['price']) : 0; $new_price = $value['price'] ? (($value['price'] < 0) ? 0 : $value['price']) : 0;
$wholesale_price = $value['wholesale_price'] ? (($value['wholesale_price'] < 0) ? 0 : $value['wholesale_price']) : 0;
$new_stock = $value['stock'] ? (($value['stock'] < 0) ? 0 : $value['stock']) : 0; $new_stock = $value['stock'] ? (($value['stock'] < 0) ? 0 : $value['stock']) : 0;
$array = [ $array = [
'detail' => json_encode($value['detail'] ?? ''), 'detail' => json_encode($value['detail'] ?? ''),
@ -659,6 +662,7 @@ class ProductRepository extends BaseRepository
"image" => $value["image"] ?? '', "image" => $value["image"] ?? '',
"cost" => $value['cost'] ? (($value['cost'] < 0) ? 0 : $value['cost']) : 0, "cost" => $value['cost'] ? (($value['cost'] < 0) ? 0 : $value['cost']) : 0,
"price" => $new_price, "price" => $new_price,
"wholesale_price" => $wholesale_price,
"volume" => isset($value['volume']) ? ($value['volume'] ? (($value['volume'] < 0) ? 0 : $value['volume']) : 0) : 0, "volume" => isset($value['volume']) ? ($value['volume'] ? (($value['volume'] < 0) ? 0 : $value['volume']) : 0) : 0,
"weight" => isset($value['weight']) ? ($value['weight'] ? (($value['weight'] < 0) ? 0 : $value['weight']) : 0) : 0, "weight" => isset($value['weight']) ? ($value['weight'] ? (($value['weight'] < 0) ? 0 : $value['weight']) : 0) : 0,
"stock" => $new_stock, "stock" => $new_stock,

View File

@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\repositories\system;
use app\common\dao\system\AppUpdateDao;
use app\common\repositories\BaseRepository;
use think\db\exception\DbException;
use think\exception\ValidateException;
use think\facade\Cache;
/**
* Class LhappRepository
* @package app\common\repositories\system
* @author xaboy
* @day 2020-04-24
* @mixin CacheDao
*/
class LhappRepository extends BaseRepository
{
/**
* CacheRepository constructor.
* @param CacheDao $dao
*/
public function __construct(AppUpdateDao $dao)
{
$this->dao = $dao;
}
public function getList($where, $page, $limit)
{
$query = $this->dao->search($where);
$count = $query->count();
$list = $query->page($page, $limit)->order('id DESC')->select();
return compact('count', 'list');
}
public function detail($id)
{
$find = $this->dao->search(['id' => $id])->find();
if (!$find) throw new ValidateException('数据不存在');
return $find;
}
public function delete($id)
{
$res = $this->dao->delete($id);
return $res;
}
}

View File

@ -0,0 +1,84 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\system;
use app\common\repositories\system\LhappRepository;
use think\exception\ValidateException;
use crmeb\basic\BaseController;
use think\App;
class Lhapp extends BaseController
{
/**
* @var LhappRepository
*/
protected $repository;
/**
* CacheRepository constructor.
* @param App $app
*/
public function __construct(App $app, LhappRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
}
public function list()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['type']);
return app('json')->success($this->repository->getList($where, $page, $limit));
}
public function create()
{
$this->repository->create($this->getValidParams());
return app('json')->success('添加成功');
}
public function update($id)
{
if (!$this->repository->exists($id)) {
return app('json')->fail('数据不存在');
}
$this->repository->update($id, $this->getValidParams());
return app('json')->success('修改成功');
}
public function detail($id)
{
$data = $this->repository->detail($id);
return app('json')->success($data);
}
public function delete($id)
{
$res = $this->repository->delete($id);
if ($res) {
return app('json')->success('删除成功');
} else {
return app('json')->fail('删除失败');
}
}
protected function getValidParams()
{
$data = $this->request->params(['title', 'content', 'type', 'phone_brand', 'version', 'dow_url', 'force', 'quiet']);
if (empty($data['title'])) throw new ValidateException('title标题不能为空');
if (empty($data['content'])) throw new ValidateException('content内容不能为空');
if (empty($data['type'])) throw new ValidateException('type类型不能为空');
if (empty($data['version'])) throw new ValidateException('version版本号不能为空');
if (empty($data['dow_url'])) throw new ValidateException('dow_url下载地址不能为空');
return $data;
}
}