第一次更新,完成了初版调整

This commit is contained in:
2026-09-07 22:05:51 +08:00
parent b5a26a8848
commit 4d6a7e7aac
198 changed files with 6142 additions and 3856 deletions
@@ -1,85 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use app\common\library\helper;
/**
* 合作商关联商品券模型
* Class PartnersGoods
* @package app\common\model
*/
class PartnersGoods extends BaseModel
{
// 定义表名
protected $name = 'partners_goods';
// 定义主键
protected $pk = 'id';
/**
* 关联模型:商品
* @return \think\model\relation\HasOne
*/
public function goods(): \think\model\relation\HasOne
{
return $this->hasOne('Goods', 'id', 'goods_id');
}
/**
* 获取商品信息详情
* @param int $partnersId
* @param int $goodsId
* @return array|null|static
*/
public static function detail(int $partnersId, int $goodsId)
{
return static::get(['partners_id' => $partnersId, 'goods_id' => $goodsId]);
}
/**
* 获取合作商商品列表
* @param int $partnersId 合作商ID
* @return \think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getGoodsList(int $partnersId): \think\Collection
{
return (new static)->where('partners_id', '=', $partnersId)->order(['id' => 'asc'])->select();
}
/**
* 累计合作商使用数量
* @param int|array $where
* @param int $num
* @return mixed
*/
public static function setIncUseNum($where, int $num)
{
return (new static)->setInc($where, 'use_num', $num);
}
/**
* 减少合作商库存数量
* @param int|array $where
* @param int $num
* @return mixed
*/
public static function setDecStockNum($where, int $num)
{
return (new static)->setDec($where, 'stock_num', $num);
}
}
@@ -1,54 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model\partners;
use cores\BaseModel;
/**
* 合作商库存变动记录
* Class StockLog
* @package app\common\model\partners
*/
class StockLog extends BaseModel
{
// 定义表名
protected $name = 'partners_stock_log';
// 定义主键
protected $pk = 'id';
protected $updateTime = false;
/**
* 关联合作商记录表
* @return \think\model\relation\BelongsTo
*/
public function partners()
{
$module = self::getCalledModule();
return $this->belongsTo("app\\{$module}\\model\\Partners");
}
/**
* 新增记录
* @param array $data
*/
public static function add(array $data)
{
$model = new static;
$model->save(array_merge([
'store_id' => $model::$storeId
], $data));
}
}