其余文件
This commit is contained in:
190
app/common/model/goods/Goods.php
Normal file
190
app/common/model/goods/Goods.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
use app\common\basics\Models;
|
||||
use app\common\model\distribution\DistributionGoods;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
|
||||
/**
|
||||
* 商品-模型
|
||||
* Class Goods
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class Goods extends Models
|
||||
{
|
||||
/**
|
||||
* 商品轮播图 关联模型
|
||||
*/
|
||||
public function GoodsImage()
|
||||
{
|
||||
return $this->hasMany('GoodsImage', 'goods_id', 'id')->field('goods_id, uri');
|
||||
}
|
||||
/**
|
||||
* 商品SKU 关联模型
|
||||
*/
|
||||
public function GoodsItem()
|
||||
{
|
||||
return $this->hasMany('GoodsItem', 'goods_id', 'id')
|
||||
->field('id, goods_id, image, spec_value_ids, spec_value_str, market_price, price, stock, chengben_price');
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺 关联模型
|
||||
*/
|
||||
public function Shop()
|
||||
{
|
||||
return $this->hasOne(Shop::class, 'id', 'shop_id')
|
||||
->field('id, name, logo, type, star, score, intro,is_pay, mobile,is_freeze,is_run,expire_time')
|
||||
->append([ 'is_expire' ]);
|
||||
}
|
||||
|
||||
public function getIsDistributionDescAttr($value, $data)
|
||||
{
|
||||
return $data['is_distribution'] ? '是': '否';
|
||||
}
|
||||
|
||||
function getIsMemberDescAttr($value, $data)
|
||||
{
|
||||
return $data['is_member'] ? '是': '否';
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id获取商品名称
|
||||
*/
|
||||
public function getGoodsNameById($goods_id)
|
||||
{
|
||||
return $this->where('id',$goods_id)->value('name');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id查询商品是否上架
|
||||
*/
|
||||
public function checkStatusById($goods_id)
|
||||
{
|
||||
$status = $this
|
||||
->where([
|
||||
['id','=',$goods_id],
|
||||
['del','=',0],
|
||||
])
|
||||
->value('status');
|
||||
if ($status){
|
||||
if ($status == 1){
|
||||
return true;
|
||||
}
|
||||
if (empty($status) || $status ===0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据goods_id查询商品配送方式及所需信息
|
||||
*/
|
||||
public function getExpressType($goods_id)
|
||||
{
|
||||
return $this->where('id',$goods_id)->column('express_type,express_money,express_template_id')[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 最小值与最大值范围
|
||||
*/
|
||||
public function getMinMaxPriceAttr($value, $data)
|
||||
{
|
||||
return '¥ ' . $data['min_price'] . '~ ¥ '. $data['max_price'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品是否参与分销
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author Tab
|
||||
* @date 2021/9/1 17:29
|
||||
*/
|
||||
public function getDistributionFlagAttr($value)
|
||||
{
|
||||
$data = DistributionGoods::where('goods_id', $value)->findOrEmpty()->toArray();
|
||||
if (!empty($data) && $data['is_distribution'] == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 商品详情
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return array|string|string[]|null
|
||||
* @author 段誉
|
||||
* @date 2022/6/13 10:50
|
||||
*/
|
||||
public function getContentAttr($value,$data){
|
||||
/* $preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';*/
|
||||
// $local_url = UrlServer::getFileUrl('/');
|
||||
// return preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
|
||||
$content = $data['content'];
|
||||
if (!empty($content)) {
|
||||
$content = HtmlGetImage($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
public function setContentAttr($value,$data)
|
||||
{
|
||||
$content = $data['content'];
|
||||
if (!empty($content)) {
|
||||
$content = HtmlSetImage($content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 分销状态搜索器
|
||||
* @param $query
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @author Tab
|
||||
* @date 2021/9/2 9:55
|
||||
*/
|
||||
public function searchIsDistributionAttr($query, $value, $data)
|
||||
{
|
||||
// 不参与分销
|
||||
if (isset($data['is_distribution']) && $data['is_distribution'] == '0') {
|
||||
// 先找出参与分销的商品id
|
||||
$ids = DistributionGoods::where('is_distribution', 1)->column('goods_id');
|
||||
// 在搜索条件中将它们排除掉
|
||||
$query->where('id', 'not in', $ids);
|
||||
|
||||
}
|
||||
// 参与分销
|
||||
if (isset($data['is_distribution']) && $data['is_distribution'] == '1') {
|
||||
// 先找出参与分销的商品id
|
||||
$ids = DistributionGoods::where('is_distribution', 1)->column('goods_id');
|
||||
// 在搜索条件中使用它们来进行过滤
|
||||
$query->where('id', 'in', $ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
47
app/common/model/goods/GoodsBrand.php
Normal file
47
app/common/model/goods/GoodsBrand.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
/**
|
||||
* 商品品牌
|
||||
* Class GoodsBrand
|
||||
* @package app\common\model
|
||||
*/
|
||||
class GoodsBrand extends Models
|
||||
{
|
||||
/**
|
||||
* Notes: 获取以id为键的数据
|
||||
* @author 段誉(2021/4/19 17:35)
|
||||
* @return array
|
||||
*/
|
||||
public static function getNameColumn()
|
||||
{
|
||||
$lists = self::where([
|
||||
'del' => 0,
|
||||
'is_show' => 1
|
||||
])->column('id,name', 'id');
|
||||
|
||||
return empty($lists) ? [] : $lists;
|
||||
}
|
||||
}
|
||||
37
app/common/model/goods/GoodsCategory.php
Normal file
37
app/common/model/goods/GoodsCategory.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\common\model\goods;
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
/**
|
||||
* 平台商品分类
|
||||
* Class GoodsBrand
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsCategory extends Models
|
||||
{
|
||||
/**
|
||||
* 子分类
|
||||
*/
|
||||
public function sons()
|
||||
{
|
||||
return $this->hasMany(self::class, 'pid', 'id')->where(['del' => 0]);
|
||||
}
|
||||
}
|
||||
35
app/common/model/goods/GoodsClick.php
Normal file
35
app/common/model/goods/GoodsClick.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 商品点击
|
||||
* Class GoodsClick
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsClick extends Models
|
||||
{
|
||||
|
||||
}
|
||||
35
app/common/model/goods/GoodsCollect.php
Normal file
35
app/common/model/goods/GoodsCollect.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 商品收藏
|
||||
* Class GoodsCollect
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsCollect extends Models
|
||||
{
|
||||
|
||||
}
|
||||
34
app/common/model/goods/GoodsColumn.php
Normal file
34
app/common/model/goods/GoodsColumn.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
* Class GoodsUnit
|
||||
* @package app\common\model
|
||||
*/
|
||||
class GoodsColumn extends Models
|
||||
{
|
||||
|
||||
}
|
||||
90
app/common/model/goods/GoodsComment.php
Normal file
90
app/common/model/goods/GoodsComment.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
use app\common\model\order\OrderGoods;
|
||||
|
||||
class GoodsComment extends Models
|
||||
{
|
||||
/**
|
||||
* 关联商品
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
return $this->hasOne(Goods::class, 'id', 'goods_id')
|
||||
->field('id,name,image');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联SKU
|
||||
*/
|
||||
public function goodsItem()
|
||||
{
|
||||
return $this->hasOne(GoodsItem::class, 'id', 'item_id')
|
||||
->field('id,image,spec_value_str');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联订单商品
|
||||
*/
|
||||
public function orderGoods()
|
||||
{
|
||||
return $this->hasOne(OrderGoods::class, 'id', 'order_goods_id')
|
||||
->field('id,total_pay_price');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联图片评论
|
||||
*/
|
||||
public function goodsCommentImage()
|
||||
{
|
||||
return $this->hasMany(GoodsCommentImage::class, 'goods_comment_id', 'id');
|
||||
}
|
||||
|
||||
public function getStatusDescAttr($value)
|
||||
{
|
||||
return $value ? '显示' : '隐藏';
|
||||
}
|
||||
|
||||
public function getGoodsCommentDescAttr($value)
|
||||
{
|
||||
$desc = [1=>'差评',2=>'差评',3=>'中评',4=>'好评',5=>'好评',];
|
||||
return $desc[$value];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评论内容 xss
|
||||
* @param $comment
|
||||
* @return mixed|string
|
||||
* @author lbzy
|
||||
* @datetime 2023-09-06 14:36:25
|
||||
*/
|
||||
function getCommentAttr($comment)
|
||||
{
|
||||
if (in_array(app('http')->getName(), [ 'admin', 'shop' ]) && request()->isAjax()) {
|
||||
$comment = htmlspecialchars($comment);
|
||||
}
|
||||
|
||||
return $comment;
|
||||
}
|
||||
}
|
||||
29
app/common/model/goods/GoodsCommentImage.php
Normal file
29
app/common/model/goods/GoodsCommentImage.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
class GoodsCommentImage extends Models
|
||||
{
|
||||
|
||||
}
|
||||
35
app/common/model/goods/GoodsImage.php
Normal file
35
app/common/model/goods/GoodsImage.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 商品图片
|
||||
* Class GoodsImage
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsImage extends Models
|
||||
{
|
||||
|
||||
}
|
||||
151
app/common/model/goods/GoodsItem.php
Normal file
151
app/common/model/goods/GoodsItem.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\admin\validate\SeckillTime;
|
||||
use app\api\logic\SeckillLogic;
|
||||
use app\common\basics\Models;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\api\logic\OrderLogic;
|
||||
use app\common\model\seckill\SeckillGoods;
|
||||
use app\common\model\seckill\SeckillTime as SeckillTimeModel;
|
||||
use app\common\server\UrlServer;
|
||||
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
* Class GoodsItem
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsItem extends Models
|
||||
{
|
||||
/**
|
||||
* @notes notes
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string
|
||||
* @author lbzy
|
||||
* @datetime 2024-04-03 09:53:03
|
||||
*/
|
||||
function getMarketPriceAttr($value, $data)
|
||||
{
|
||||
return $value <= 0 ? '' : $value;
|
||||
}
|
||||
|
||||
function getChengbenPriceAttr($value, $data)
|
||||
{
|
||||
return $value <= 0 ? '' : $value;
|
||||
}
|
||||
|
||||
function getWeightAttr($value, $data)
|
||||
{
|
||||
return $value <= 0 ? '' : $value;
|
||||
}
|
||||
|
||||
function getVolumeAttr($value, $data)
|
||||
{
|
||||
return $value <= 0 ? '' : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取订单商品价格
|
||||
* @param $item
|
||||
* @return int|mixed
|
||||
* @author lbzy
|
||||
* @datetime 2023-07-27 15:19:11
|
||||
*/
|
||||
static function getGoodsItemPrice($item)
|
||||
{
|
||||
$seckill_goods_price = self::isSeckill($item['id']);
|
||||
|
||||
return $seckill_goods_price != 0 ? $seckill_goods_price : $item['price'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据goods_id,num和item_id计算价格
|
||||
*/
|
||||
public function sumGoodsPrice($goods_id, $item_id, $num,$discount)
|
||||
{
|
||||
$goods_price = $this
|
||||
->where([
|
||||
['goods_id', '=', $goods_id],
|
||||
['id', '=', $item_id],
|
||||
])
|
||||
->value('price');
|
||||
$seckill_goods_price = self::isSeckill($item_id);
|
||||
if($seckill_goods_price != 0){
|
||||
$goods_price = $seckill_goods_price;
|
||||
OrderLogic::$order_type = OrderEnum::SECKILL_ORDER;
|
||||
}
|
||||
$is_member = Goods::where('id',$goods_id)->value('is_member');
|
||||
|
||||
if ($is_member === 0 || empty($is_member)){//不参与会员价
|
||||
$price = round($goods_price*$num,2);
|
||||
}
|
||||
if ($is_member == 1){
|
||||
$price = max(round($goods_price*$discount/10,2), 0.01) * $num;
|
||||
}
|
||||
return $price;
|
||||
}
|
||||
|
||||
public function sumMemberPrice($goods_id, $item_id, $num,$discount)
|
||||
{
|
||||
$goods_price = $this
|
||||
->where([
|
||||
['goods_id', '=', $goods_id],
|
||||
['id', '=', $item_id],
|
||||
])
|
||||
->value('price');
|
||||
$seckill_goods_price = self::isSeckill($item_id);
|
||||
if($seckill_goods_price != 0){
|
||||
$goods_price = $seckill_goods_price;
|
||||
OrderLogic::$order_type = OrderEnum::SECKILL_ORDER;
|
||||
}
|
||||
$is_member = Goods::where('id',$goods_id)->value('is_member');
|
||||
|
||||
if ($is_member === 0 || empty($is_member)){//不参与会员价
|
||||
$price = 0;
|
||||
}
|
||||
if ($is_member == 1){
|
||||
$price = ($goods_price - max(round($goods_price*$discount/10,2), 0.01)) * $num;
|
||||
}
|
||||
return $price;
|
||||
}
|
||||
/***
|
||||
*
|
||||
*是否为秒杀商品
|
||||
*
|
||||
***/
|
||||
public static function isSeckill($item_id){
|
||||
|
||||
//当前时段秒杀商品
|
||||
$seckill = SeckillLogic::getSeckillGoods();
|
||||
$seckill_goods = $seckill['seckill_goods'];
|
||||
|
||||
//当前商品规格是否为秒杀商品
|
||||
if (isset($seckill_goods[$item_id])) {
|
||||
return $seckill_goods[$item_id]['price'];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
app/common/model/goods/GoodsSpec.php
Normal file
41
app/common/model/goods/GoodsSpec.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
* Class GoodsSpec
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsSpec extends Models
|
||||
{
|
||||
/**
|
||||
* 规格值 关联模型
|
||||
*/
|
||||
public function specValue()
|
||||
{
|
||||
return $this->hasMany('GoodsSpecValue', 'spec_id', 'id');
|
||||
}
|
||||
}
|
||||
35
app/common/model/goods/GoodsSpecValue.php
Normal file
35
app/common/model/goods/GoodsSpecValue.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 商品规格值
|
||||
* Class GoodsSpecValue
|
||||
* @package app\common\model\goods
|
||||
*/
|
||||
class GoodsSpecValue extends Models
|
||||
{
|
||||
|
||||
}
|
||||
41
app/common/model/goods/GoodsUnit.php
Normal file
41
app/common/model/goods/GoodsUnit.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
* Class GoodsUnit
|
||||
* @package app\common\model
|
||||
*/
|
||||
class GoodsUnit extends Models
|
||||
{
|
||||
public static function getNameColumn()
|
||||
{
|
||||
$lists = self::where([
|
||||
'del' => 0,
|
||||
])->column('id,name', 'id');
|
||||
|
||||
return empty($lists) ? [] : $lists;
|
||||
}
|
||||
}
|
||||
53
app/common/model/goods/Supplier.php
Normal file
53
app/common/model/goods/Supplier.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\goods;
|
||||
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
|
||||
/**
|
||||
* 供货商
|
||||
* Class Supplier
|
||||
* @package app\common\model
|
||||
*/
|
||||
class Supplier extends Models
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 获取以id为键的名称
|
||||
* @author 段誉(2021/4/19 18:31)
|
||||
* @return array
|
||||
*/
|
||||
public static function getNameColumn($shop_id = 0)
|
||||
{
|
||||
$condition[] = ['del', '=', 0];
|
||||
|
||||
if ($shop_id > 0) {
|
||||
$condition[] = ['shop_id', '=', $shop_id];
|
||||
}
|
||||
|
||||
$lists = self::where($condition)->column('id,name', 'id');
|
||||
|
||||
return empty($lists) ? [] : $lists;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user