添加网站文件
This commit is contained in:
31
application/api/model/AfterSale.php
Normal file
31
application/api/model/AfterSale.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class AfterSale extends Model
|
||||
{
|
||||
public function orderGoods()
|
||||
{
|
||||
return $this->hasOne('order_goods','id','order_goods_id')
|
||||
->field('id,goods_id,item_id,total_pay_price,goods_num,goods_price,goods_info,total_price');
|
||||
}
|
||||
}
|
||||
37
application/api/model/Cart.php
Normal file
37
application/api/model/Cart.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Cart extends Model
|
||||
{
|
||||
protected $name = 'cart';
|
||||
|
||||
const IS_SELECTED = 1;//选中
|
||||
const NO_SELECTED = 0;//未选中
|
||||
|
||||
|
||||
public function goods()
|
||||
{
|
||||
return $this->hasOne('Goods', 'goods_id', 'goods_id');
|
||||
}
|
||||
|
||||
}
|
||||
44
application/api/model/Coupon.php
Normal file
44
application/api/model/Coupon.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Coupon extends Model
|
||||
{
|
||||
public function couponGoods()
|
||||
{
|
||||
return $this->hasMany('couponGoods', 'coupon_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
//通过(coupon_list)获取优惠券信息
|
||||
public static function getCouponByClId($coupon_id)
|
||||
{
|
||||
$result = Db::name('coupon c')
|
||||
->join('coupon_list cl', 'c.id = cl.coupon_id')
|
||||
->where(['cl.id ' => $coupon_id, 'c.del' => 0, 'cl.del' => 0, 'cl.status' => 0])
|
||||
->field('c.*')
|
||||
->find();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
24
application/api/model/CouponGoods.php
Normal file
24
application/api/model/CouponGoods.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use think\Model;
|
||||
|
||||
class CouponGoods extends Model{
|
||||
|
||||
}
|
||||
171
application/api/model/Goods.php
Normal file
171
application/api/model/Goods.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Goods extends Model{
|
||||
//商品图片
|
||||
public function getImageAttr($value,$data){
|
||||
if($value){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
//商品视频
|
||||
public function getVideoAttr($value,$data){
|
||||
if($value){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
//商品详情
|
||||
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);
|
||||
}
|
||||
//商品库存
|
||||
public function getStockAttr($value,$data){
|
||||
if($data['is_show_stock']){
|
||||
return $value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//商品轮播图
|
||||
public function GoodsImage(){
|
||||
return $this->hasMany('GoodsImage','goods_id','id')->field('goods_id,uri');
|
||||
}
|
||||
public function Spec()
|
||||
{
|
||||
return $this->hasMany('GoodsSpec', 'goods_id', 'id');
|
||||
}
|
||||
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');
|
||||
}
|
||||
public function GoodsSpecValue(){
|
||||
|
||||
return $this->hasMany('GoodsSpecValue','goods_id','id');
|
||||
}
|
||||
|
||||
public function GoodsSpec()
|
||||
{
|
||||
$spec = $this->Spec->toArray();
|
||||
$spec_value = $this->GoodsSpecValue;
|
||||
$spec = array_column($spec,null,'id');
|
||||
$goods_item = $this->getAttr('goods_item');
|
||||
|
||||
//将商品价格替换成商品规格价
|
||||
$this->setAttr('price',$goods_item[0]['price']);
|
||||
$this->setAttr('market_price',$goods_item[0]['market_price']);
|
||||
|
||||
//拼接规格
|
||||
foreach ($spec_value as $item){
|
||||
if(isset($spec[$item['spec_id']])){
|
||||
$spec[$item['spec_id']]['spec_value'][]= $item;
|
||||
}
|
||||
}
|
||||
$this->setAttr('goods_spec',array_values($spec));
|
||||
//规格图片为空则替换商品主图
|
||||
foreach ($goods_item as $item_key => $item_value){
|
||||
if(empty($item_value['image'])){
|
||||
$goods_item[$item_key]['image'] = $this->getAttr('image');
|
||||
}
|
||||
}
|
||||
$this->setAttr('goods_item',$goods_item);
|
||||
}
|
||||
|
||||
public function Like(){
|
||||
$goods = new self();
|
||||
$like_list = $goods->where(['del'=>0,'is_like'=>1,'status'=>1])->field('id,name,image,min_price as price,market_price')->orderRaw('rand()')->limit(5)->select();
|
||||
|
||||
$this->setAttr('like',$like_list);
|
||||
}
|
||||
|
||||
//下单赠送积分
|
||||
public function getOrderGiveIntegralAttr($value,$data)
|
||||
{
|
||||
$data['give_integral'] = empty($data['give_integral']) ? 0 : $data['give_integral'];
|
||||
if (1 === $data['give_integral_type']) {
|
||||
return intval($data['give_integral']);
|
||||
}
|
||||
return intval($data['max_price'] * $data['give_integral'] / 100);
|
||||
}
|
||||
|
||||
public function getCommentAttr($value,$data){
|
||||
$comment = [];
|
||||
$goods_comment = Db::name('goods_comment g')
|
||||
->join('user u','g.user_id = u.id')
|
||||
->where(['goods_id'=>$data['id'],'g.del'=>0,'u.del'=>0,'g.status'=>1])
|
||||
->order('g.id desc')
|
||||
->field('g.id,user_id,item_id,comment,g.create_time,nickname,avatar')
|
||||
->find();
|
||||
if($goods_comment){
|
||||
//好评人数
|
||||
$goods_count = Db::name('goods_comment')
|
||||
->where(['goods_id'=>$data['id'],'del'=>0])
|
||||
->where('goods_comment','>',3)
|
||||
->count();
|
||||
//总评论人数
|
||||
$comment_count = Db::name('goods_comment')
|
||||
->where(['goods_id'=>$data['id'],'del'=>0])
|
||||
->count();
|
||||
//评论图片
|
||||
$comment_image = Db::name('goods_comment_image')->where(['goods_comment_id'=>$goods_comment])->column('uri');
|
||||
|
||||
$comment = $goods_comment;
|
||||
$comment['goods_rate'] = round(($goods_count/$comment_count)*100).'%';
|
||||
$comment['avatar'] = UrlServer::getFileUrl($comment['avatar']);
|
||||
$comment['spec_value_str'] = '';
|
||||
$comment['create_time'] = date('Y-m-d H:i:s',$comment['create_time']);
|
||||
foreach ($comment_image as &$image_item){
|
||||
$image_item = UrlServer::getFileUrl($image_item);
|
||||
}
|
||||
$comment['image'] = $comment_image;
|
||||
foreach ($this->goods_item as $item){
|
||||
if($item['id'] == $comment['item_id']){
|
||||
$comment['spec_value_str'] = $item['spec_value_str'];
|
||||
}
|
||||
}
|
||||
if(empty($comment['comment'])){
|
||||
$comment['comment'] = '此用户没有填写评论';
|
||||
}
|
||||
}
|
||||
return $comment;
|
||||
}
|
||||
|
||||
|
||||
//详情页显示佣金金额
|
||||
public function getCommissionPriceAttr($value, $data)
|
||||
{
|
||||
$open_distribution = ConfigServer::get('distribution', 'is_open', 1);
|
||||
$show_commission = ConfigServer::get('distribution', 'show_commission', 0);
|
||||
$first_ratio = empty($data['first_ratio']) ? 0 : $data['first_ratio'];
|
||||
|
||||
if ($open_distribution && $show_commission && $data['is_commission'] && $first_ratio > 0) {
|
||||
$money = round($first_ratio * $data['max_price'] / 100, 2);
|
||||
if ($money > 0) {
|
||||
return $money;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
27
application/api/model/GoodsImage.php
Normal file
27
application/api/model/GoodsImage.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Model;
|
||||
|
||||
class GoodsImage extends Model{
|
||||
public function getUriAttr($value,$data){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
}
|
||||
30
application/api/model/GoodsItem.php
Normal file
30
application/api/model/GoodsItem.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Model;
|
||||
|
||||
class GoodsItem extends Model {
|
||||
public function getImageAttr($value,$data){
|
||||
if($value){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
26
application/api/model/GoodsSpec.php
Normal file
26
application/api/model/GoodsSpec.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use think\Model;
|
||||
|
||||
class GoodsSpec extends Model {
|
||||
public function GoodsSpecValue(){
|
||||
return $this->hasMany('GoodsSpecValue','spec_id','id');
|
||||
}
|
||||
}
|
||||
27
application/api/model/GoodsSpecValue.php
Normal file
27
application/api/model/GoodsSpecValue.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use think\Model;
|
||||
|
||||
class GoodsSpecValue extends Model {
|
||||
public function GoodsSepc(){
|
||||
return $this->hasMany('GoodsSpec', 'goods_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
249
application/api/model/Order.php
Normal file
249
application/api/model/Order.php
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\model\Pay;
|
||||
use app\common\server\AreaServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
use app\common\model\Order as CommonOrder;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
protected $name = 'order';
|
||||
|
||||
/*
|
||||
* 下单时间
|
||||
*/
|
||||
public function getCreateTimeAttr($value, $data)
|
||||
{
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
/*
|
||||
* 付款时间
|
||||
*/
|
||||
public function getPayTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* 发货时间
|
||||
*/
|
||||
public function getShippingTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 取消时间
|
||||
*/
|
||||
public function getCancelTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 确认收货时间
|
||||
*/
|
||||
public function getConfirmTakeTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* 支付方式
|
||||
*/
|
||||
public function getPayWayTextAttr($value, $data)
|
||||
{
|
||||
return Pay::getPayWay($data['pay_way']);
|
||||
}
|
||||
|
||||
public function orderGoods()
|
||||
{
|
||||
return $this->hasMany('order_goods', 'order_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function getGoodsCountAttr($value, $data)
|
||||
{
|
||||
return count($this->order_goods);
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示支付按钮
|
||||
*/
|
||||
public function getPayBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_PAY && $data['pay_status'] == Pay::UNPAID) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示取消订单按钮
|
||||
*/
|
||||
public function getCancelBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
//多长时间内允许客户自动取消
|
||||
$cancel_limit = ConfigServer::get('trading', 'customer_cancel_limit', 0);
|
||||
$limit_time = $data['create_time'] + $cancel_limit * 60;
|
||||
if ($limit_time < time()) {
|
||||
return $btn = 0;
|
||||
}
|
||||
|
||||
if (($data['order_status'] == CommonOrder::STATUS_WAIT_PAY && $data['pay_status'] == Pay::UNPAID)
|
||||
|| ($data['pay_status'] == Pay::ISPAID && $data['order_status'] == CommonOrder::STATUS_WAIT_DELIVERY)) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示物流按钮
|
||||
*/
|
||||
public function getDeliveryBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_RECEIVE && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示确认收货按钮
|
||||
*/
|
||||
public function getTakeBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_RECEIVE && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示删除按钮
|
||||
*/
|
||||
public function getDelBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if (
|
||||
($data['order_status'] == CommonOrder::STATUS_CLOSE && $data['pay_status'] == Pay::UNPAID) ||
|
||||
($data['order_status'] == CommonOrder::STATUS_CLOSE && $data['pay_status'] == Pay::REFUNDED)
|
||||
) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示已完成按钮
|
||||
*/
|
||||
public function getFinishBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $data['pay_status'] == Pay::ISPAID) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示去评论按钮
|
||||
*/
|
||||
public function getCommentBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
$comment_count = 0;
|
||||
if ($data['pay_status'] == Pay::ISPAID && $data['order_status'] == CommonOrder::STATUS_FINISH) {
|
||||
$btn = 1;
|
||||
foreach ($this->order_goods as $item) {
|
||||
if ($item['is_comment'] == 1) {
|
||||
$comment_count += 1;
|
||||
};
|
||||
}
|
||||
if (count($this->orderGoods) == $comment_count) {
|
||||
$btn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示申请退款按钮
|
||||
*/
|
||||
public function getRefundBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
$refund_days = $data['confirm_take_time'] + ConfigServer::get('after_sale', 'refund_days', '', 0) * 86400;
|
||||
$now = time();
|
||||
|
||||
//订单已完成、在售后期内。未申请退款、
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $refund_days > $now && $data['refund_status'] = \app\common\model\OrderGoods::REFUND_STATUS_NO) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
//收货地址
|
||||
public function getDeliveryAddressAttr($value, $data)
|
||||
{
|
||||
$region_desc = AreaServer::getAddress([$data['province'], $data['city'], $data['district']], $data['address']);
|
||||
return $region_desc;
|
||||
}
|
||||
|
||||
public function getOrderCancelTimeAttr($value, $data)
|
||||
{
|
||||
$end_time = '';
|
||||
if ($data['order_status'] == 0 && $data['pay_status'] == 0) {
|
||||
$order_cancel_time = ConfigServer::get('trading', 'order_cancel', 30);
|
||||
$end_time = $data['create_time'] + $order_cancel_time * 60;
|
||||
}
|
||||
return $end_time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
31
application/api/model/OrderGoods.php
Normal file
31
application/api/model/OrderGoods.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Model;
|
||||
|
||||
class OrderGoods extends Model {
|
||||
public function getImageAttr($value,$data){
|
||||
if($value){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
249
application/api/model/Orderexe.php
Normal file
249
application/api/model/Orderexe.php
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\model\Pay;
|
||||
use app\common\server\AreaServer;
|
||||
use app\common\server\ConfigServer;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
use app\common\model\Order as CommonOrder;
|
||||
|
||||
class Orderexe extends Model
|
||||
{
|
||||
protected $name = 'order_exe';
|
||||
|
||||
/*
|
||||
* 下单时间
|
||||
*/
|
||||
public function getCreateTimeAttr($value, $data)
|
||||
{
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
/*
|
||||
* 付款时间
|
||||
*/
|
||||
public function getPayTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* 发货时间
|
||||
*/
|
||||
public function getShippingTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 取消时间
|
||||
*/
|
||||
public function getCancelTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 确认收货时间
|
||||
*/
|
||||
public function getConfirmTakeTimeAttr($value, $data)
|
||||
{
|
||||
if ($value) {
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
* 支付方式
|
||||
*/
|
||||
public function getPayWayTextAttr($value, $data)
|
||||
{
|
||||
return Pay::getPayWay($data['pay_way']);
|
||||
}
|
||||
|
||||
public function orderGoods()
|
||||
{
|
||||
return $this->hasMany('order_goods', 'order_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function getGoodsCountAttr($value, $data)
|
||||
{
|
||||
return count($this->order_goods);
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示支付按钮
|
||||
*/
|
||||
public function getPayBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_PAY && $data['pay_status'] == Pay::UNPAID) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示取消订单按钮
|
||||
*/
|
||||
public function getCancelBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
//多长时间内允许客户自动取消
|
||||
$cancel_limit = ConfigServer::get('trading', 'customer_cancel_limit', 0);
|
||||
$limit_time = $data['create_time'] + $cancel_limit * 60;
|
||||
if ($limit_time < time()) {
|
||||
return $btn = 0;
|
||||
}
|
||||
|
||||
if (($data['order_status'] == CommonOrder::STATUS_WAIT_PAY && $data['pay_status'] == Pay::UNPAID)
|
||||
|| ($data['pay_status'] == Pay::ISPAID && $data['order_status'] == CommonOrder::STATUS_WAIT_DELIVERY)) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示物流按钮
|
||||
*/
|
||||
public function getDeliveryBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_RECEIVE && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示确认收货按钮
|
||||
*/
|
||||
public function getTakeBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_WAIT_RECEIVE && $data['pay_status'] == Pay::ISPAID && $data['shipping_status'] == 1) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示删除按钮
|
||||
*/
|
||||
public function getDelBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if (
|
||||
($data['order_status'] == CommonOrder::STATUS_CLOSE && $data['pay_status'] == Pay::UNPAID) ||
|
||||
($data['order_status'] == CommonOrder::STATUS_CLOSE && $data['pay_status'] == Pay::REFUNDED)
|
||||
) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示已完成按钮
|
||||
*/
|
||||
public function getFinishBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $data['pay_status'] == Pay::ISPAID) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示去评论按钮
|
||||
*/
|
||||
public function getCommentBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
$comment_count = 0;
|
||||
if ($data['pay_status'] == Pay::ISPAID && $data['order_status'] == CommonOrder::STATUS_FINISH) {
|
||||
$btn = 1;
|
||||
foreach ($this->order_goods as $item) {
|
||||
if ($item['is_comment'] == 1) {
|
||||
$comment_count += 1;
|
||||
};
|
||||
}
|
||||
if (count($this->orderGoods) == $comment_count) {
|
||||
$btn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $btn;
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回是否显示申请退款按钮
|
||||
*/
|
||||
public function getRefundBtnAttr($value, $data)
|
||||
{
|
||||
$btn = 0;
|
||||
$refund_days = $data['confirm_take_time'] + ConfigServer::get('after_sale', 'refund_days', '', 0) * 86400;
|
||||
$now = time();
|
||||
|
||||
//订单已完成、在售后期内。未申请退款、
|
||||
if ($data['order_status'] == CommonOrder::STATUS_FINISH && $refund_days > $now && $data['refund_status'] = \app\common\model\OrderGoods::REFUND_STATUS_NO) {
|
||||
$btn = 1;
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
//收货地址
|
||||
public function getDeliveryAddressAttr($value, $data)
|
||||
{
|
||||
$region_desc = AreaServer::getAddress([$data['province'], $data['city'], $data['district']], $data['address']);
|
||||
return $region_desc;
|
||||
}
|
||||
|
||||
public function getOrderCancelTimeAttr($value, $data)
|
||||
{
|
||||
$end_time = '';
|
||||
if ($data['order_status'] == 0 && $data['pay_status'] == 0) {
|
||||
$order_cancel_time = ConfigServer::get('trading', 'order_cancel', 30);
|
||||
$end_time = $data['create_time'] + $order_cancel_time * 60;
|
||||
}
|
||||
return $end_time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
24
application/api/model/Shop.php
Normal file
24
application/api/model/Shop.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use think\Model;
|
||||
|
||||
class Shop extends Model{
|
||||
|
||||
}
|
||||
66
application/api/model/User.php
Normal file
66
application/api/model/User.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 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团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\model;
|
||||
use app\common\model\DistributionOrder;
|
||||
use app\common\server\UrlServer;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class User extends Model{
|
||||
|
||||
public function getAvatarAttr($value,$data){
|
||||
if($value){
|
||||
return UrlServer::getFileUrl($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getLevelAttr($value,$data){
|
||||
$level_name = '普通买家';
|
||||
if($value){
|
||||
$level_name = Db::name('user_level')->where(['del'=>0,'id'=>$value])->value('name');
|
||||
}
|
||||
return $level_name;
|
||||
|
||||
}
|
||||
|
||||
public function getFansDistributionAttr($value,$data)
|
||||
{
|
||||
$distribution_order = Db::name('distribution_order_goods')
|
||||
->field('count(id) as order_num, sum(money) as money')
|
||||
->where(['user_id' => $data['id'], 'status' => DistributionOrder::STATUS_SUCCESS])
|
||||
->find();
|
||||
|
||||
$where1 = [
|
||||
['first_leader', '=', $data['id']],
|
||||
];
|
||||
$where2 = [
|
||||
['second_leader', '=', $data['id']],
|
||||
];
|
||||
$fans = Db::name('user')
|
||||
->whereOr([$where1,$where2])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'fans' => $fans,
|
||||
'order_num' => $distribution_order['order_num'] ?? 0,
|
||||
'money' => $distribution_order['money'] ?? 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user