添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
<?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\validate;
use app\common\model\DistributionOrder;
use app\common\model\OrderGoods;
use app\common\server\ConfigServer;
use think\Db;
use think\Validate;
class AfterSale extends Validate
{
protected $rule = [
'id' => 'require',
'order_id' => 'require',
'reason' => 'require',
'item_id' => 'require',
'refund_type' => 'require',
'express_name' => 'require',
'invoice_no' => 'require|alphaNum',
];
protected $message = [
'id.require' => '参数错误',
'reason.require' => '请选择退款原因',
'order_id.require' => '参数错误',
'item_id.require' => '参数错误',
'refund_type.require' => '参数错误',
'express_name.require' => '请填写物流公司名称',
'invoice_no.require' => '请填写快递单号',
'invoice_no.alphaNum' => '请填写正确的快递单号',
];
//申请售后
protected function sceneAdd()
{
$this->only(['item_id', 'order_id', 'reason', 'refund_type'])
->append('order_id', 'checkAbleApply');
}
//售后详情
protected function sceneInfo()
{
$this->only(['order_id', 'item_id']);
}
//售后快递
protected function sceneExpress()
{
$this->only(['id', 'express_name', 'invoice_no'])
->append('id', 'checkExpress');
}
//撤销售后
protected function sceneCancel()
{
$this->only(['id'])
->append('id', 'checkCancel');
}
//重新申请
protected function sceneAgain()
{
$this->only(['id', 'reason', 'refund_type'])->append('id', 'checkAgain');
}
//验证是否允许重新申请
protected function checkAgain($value, $rule, $data)
{
$after_sale = Db::name('after_sale')
->where('id', $value)
->find();
if (!$after_sale) {
return '订单信息错误';
}
//商家拒绝,商家拒收货可以重新发起申请
$able = [
\app\common\model\AfterSale::STATUS_REFUSE_REFUND,
\app\common\model\AfterSale::STATUS_REFUSE_RECEIVE_GOODS,
];
if (in_array($after_sale['status'], $able)) {
return true;
}
return '此订单暂不可重新申请';
}
//验证订单是否在售后时间内
protected function checkAbleApply($value, $rule, $data)
{
$now = time();
$where = [];
$where[] = ['o.id', '=', $value];
$where[] = ['g.item_id', '=', $data['item_id']];
$where[] = ['o.order_status', 'in', [\app\common\model\Order::STATUS_WAIT_RECEIVE, \app\common\model\Order::STATUS_FINISH]];
$order = Db::name('order o')
->field('o.order_status,o.confirm_take_time,g.refund_status')
->join('order_goods g', 'o.id = g.order_id')
->where($where)
->find();
if (!$order) {
return '此订单暂不可申请售后';
}
if ($order['refund_status'] == OrderGoods::REFUND_STATUS_APPLY) {
return '此订单正在审核中';
}
if ($order['refund_status'] == OrderGoods::REFUND_STATUS_WAIT) {
return '此订单等待退款中';
}
if ($order['refund_status'] == OrderGoods::REFUND_STATUS_SUCCESS) {
return '此订单商品已退款成功';
}
$refund_days = ConfigServer::get('after_sale', 'refund_days', 0);
if ($refund_days == 0) {
return true;
}
if ($order['order_status'] == \app\common\model\Order::STATUS_FINISH) {
$check_time = intval($order['confirm_take_time'] + ($refund_days * 24 * 60 * 60));
if ($now > $check_time) {
return '不在售后时间内';
}
}
//验证订单是否已生成分佣订单且分佣, 有的不允许再发起售后
$distribution = Db::name('distribution_order_goods')->alias('d')
->join('order_goods og', 'og.id = d.order_goods_id')
->where('og.order_id', $value)
->where('og.item_id', $data['item_id'])
->where('d.status', '=',DistributionOrder::STATUS_SUCCESS)
->find();
if ($distribution) {
return '已发生分佣, 无法再次发起售后';
}
return true;
}
//验证售后订单
protected function checkExpress($value, $rule, $data)
{
$after_sale = Db::name('after_sale')
->where('id', $value)
->find();
if (!$after_sale) {
return '订单信息错误';
}
if ($after_sale['status'] == \app\common\model\AfterSale::STATUS_WAIT_RETURN_GOODS) {
return true;
}
return '此订单正在审核中';
}
//验证撤销售后订单
protected function checkCancel($value, $data)
{
$after_sale = Db::name('after_sale')
->where('id', $value)
->find();
if (!$after_sale) {
return '订单信息错误';
}
$check = [
\app\common\model\AfterSale::STATUS_WAIT_REFUND,
\app\common\model\AfterSale::STATUS_SUCCESS_REFUND,
];
if (in_array($after_sale['status'], $check)){
return '订单等待退款或已退款,无法撤销售后';
}
return true;
}
}

View File

@@ -0,0 +1,32 @@
<?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\validate;
use app\common\model\Client_;
use think\Validate;
class App extends Validate
{
protected $rule = [
'client' => 'require|in:'.Client_::ios.','.Client_::android,
];
}

View File

@@ -0,0 +1,144 @@
<?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\validate;
use app\common\model\BargainLaunch;
use think\Db;
use think\Validate;
class Bargain extends Validate{
protected $rule = [
'id' => 'require',
'bargain_id' => 'require',
'item_id' => 'require|checkGoods',
'url' => 'require',
];
protected $message = [
'id.require' => '请选择砍价订单',
'bargain_id.require' => '请选择活动',
'item_id.require' => '请选择规格',
'url.require' => '缺少参数',
];
//砍价商品详情验证场景
public function sceneDetail()
{
$this->only(['bargain_id'])
->append('bargain_id','checkBargain');
}
//发起砍价验证
public function sceneSponsor()
{
$this->only(['bargain_id','item_id']);
}
//砍价详情验证
public function sceneBargainDetail(){
$this->only(['id']);
}
//分享验证
public function sceneShare(){
$this->only(['id','url'])
->append('id','checkBargainLaunch');
}
//助力验证
public function sceneKnife(){
$this->only(['id'])
->append('id','checkBnife');
}
//验证活动是否开启
protected function checkBargain($value,$rule,$data){
$now = time();
$bargain = Db::name('bargain')
->where([
['id','=',$value],
['del','=', 0],
['activity_start_time','<',$now],
['activity_end_time','>',$now],
['status','=',1]
])
->find();
if(empty($bargain)){
return '该砍价活动已下架';
}
return true;
}
//验证商品库存
protected function checkGoods($value,$rule,$data){
$stock = Db::name('goods_item')
->where(['id'=>$value])
->value('stock');
if($stock < 1){
return '该商品库存不足';
}
return true;
}
//验证该砍价订单是否结束
protected function checkBargainLaunch($value,$rule,$data){
$bargain_launch = new BargainLaunch();
$bargain_launch = $bargain_launch
->where(['id'=>$value])
->find();
if($bargain_launch['launch_end_time'] <= time()){
return '该砍价已结束';
}
return true;
}
//验证该砍价订单是否可助力
protected function checkBnife($value,$rule,$data){
$bargain_launch = new BargainLaunch();
$bargain_launch = $bargain_launch
->where(['id'=>$value])
->find()->toarray();
if(0 != $bargain_launch['status']){
return '该砍价已结束';
}
if($bargain_launch['launch_end_time'] <= time()){
return '该砍价已结束';
}
if($bargain_launch['user_id'] === $data['user_id']){
return '不能助力自己的砍价活动';
}
if($bargain_launch['current_price'] < 0){
return '该砍价活动已成功';
}
//当前活动是砍到低价,且已经低于等于活动低价时,砍价成功
if(1 == $bargain_launch['bargain_snap']['payment_where'] && $bargain_launch['current_price'] <= $bargain_launch['bargain_price']){
return '该砍价活动已成功';
}
$bargain_knife = Db::name('bargain_knife')
->where(['launch_id'=>$value,'user_id'=>$data['user_id']])
->find();
if($bargain_knife){
return '您已助力过了';
}
return true;
}
}

View File

@@ -0,0 +1,91 @@
<?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\validate;
use think\Db;
use think\Validate;
class Cart extends Validate
{
protected $rule = [
'param' => 'require',
'cart_id' => 'require|checkCart',
'item_id' => 'require|checkGoods',
'goods_num' => 'require|integer|gt:0',
'selected' => 'require|in:0,1',
];
protected $message = [
'item_id' => '请选择商品',
'goods_num.require' => '商品数量不能为0',
'goods_num.gt' => '商品数量需大于0',
'goods_num.integer' => '商品数量需为整数',
'cart_id.require' => '参数错误',
'param.require' => '参数错误',
'selected.require' => '参数错误',
'selected.in' => '参数错误',
];
protected function sceneAdd()
{
$this->only(['item_id', 'goods_num']);
}
protected function sceneDel()
{
$this->only(['cart_id']);
}
protected function sceneSelected()
{
$this->only(['cart_id', 'selected']);
}
protected function sceneChange()
{
$this->only(['cart_id', 'goods_num']);
}
protected function checkCart($value, $rule, $data)
{
$cart = Db::name('cart')->where(['id' => $value])->find();
if (!$cart){
return '购物车不存在';
}
return true;
}
protected function checkGoods($value, $rule, $data)
{
$goods = Db::name('goods g')
->field('g.status')
->join('goods_item i', 'i.goods_id = g.id')
->where(['i.id' => $value, 'g.del' => 0])
->find();
if (!$goods || $goods['status'] == 0) {
return '商品已下架';
}
return true;
}
}

View File

@@ -0,0 +1,97 @@
<?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\validate;
use app\common\logic\SmsLogic;
use app\common\model\Client_;
use think\Db;
use think\Validate;
class ChangeMobile extends Validate
{
protected $rule = [
'client' => 'require|in:'. Client_::oa . ',' . Client_::ios . ',' . Client_::android. ',' .Client_::pc. ','. Client_::h5,
'mobile' => 'require|mobile',
'new_mobile' => 'require|mobile|checkMobile',
];
protected $message = [
'mobile.require' => '参数缺失',
'mobile.mobile' => '请填写正确的手机号',
'new_mobile.mobile' => '请填写正确的手机号',
'new_mobile.require' => '请填写手机号',
'client.require' => '参数缺失',
'client.in' => '信息错误',
];
// public function sceneChange()
// {
// $this->only(['client', 'mobile', 'new_mobile']);
// }
public function sceneBinding(){
$this->only(['client','new_mobile']);
}
protected function checkMobile($value, $rule, $data)
{
//检查新手机号是否已存在
$user = Db::name('user')
->where([
['mobile', '=', $value],
['id', '<>', $data['user_id']]
])
->find();
if ($user) {
return '此手机号已被使用';
}
//非小程序端,更换手机号需要手机验证码
// if ($data['client'] == Client_::mnp) {
// return true;
// }
if (!isset($data['code'])) {
return '请填写验证码';
}
$mobile = $data['new_mobile'];
if(isset($data['action']) && 'change' == $data['action']){
$mobile = $data['mobile'];
}
$sms_logic = new SmsLogic($data['message_key'],$mobile, $data['code']);
$check = $sms_logic->checkCode();
//检查验证码是否正确
if ($check !== true) {
return $check;
}
//标记验证码已验证
$sms_logic->cancelCode();
return true;
}
}

View File

@@ -0,0 +1,35 @@
<?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\validate;
use think\Validate;
class changeUserInfo extends Validate{
protected $rule = [
'nickname' => 'require',
'sex' => 'require|in:0,1,2',
];
protected $message = [
'nickname.require' => '请输入昵称',
'sex.require' => '请选择性别',
'sex.in' => '性别设置错误',
];
public function scenePc(){
$this->only(['nickname','sex']);
}
}

View File

@@ -0,0 +1,61 @@
<?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\validate;
use think\Db;
use think\Validate;
class DistributionApply extends Validate
{
protected $rule = [
'user_id' => 'apply',
'real_name' => 'require',
// 'mobile' => 'require|mobile',
'province' => 'require|number',
'city' => 'require|number',
'district' => 'require|number',
'reason' => 'require',
];
protected $message = [
'real_name.require' => '请填写真实姓名',
'mobile.require' => '请填写手机号码',
'mobile.mobile' => '请填写正确的手机号码',
'province.province' => '请填写省份',
'city.city' => '请填写城市',
'district.district' => '请填写县区',
'reason.require' => '请填写申请原因',
];
protected function apply($user_id, $other, $data)
{
$result = Db::name('distribution_member_apply')
->where('user_id', $user_id)
->where('status', 0)
->find();
if ($result) {
return '正在审核中,请勿重复提交';
}
return true;
}
}

View File

@@ -0,0 +1,75 @@
<?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\validate;
use think\Db;
use think\Validate;
class DistributionCode extends Validate
{
protected $rule = [
'code' => 'require|checkCode',
];
protected $message = [
'code.require' => '请输入邀请码',
];
/**
* 填写邀请码验证
* @param $code
* @param $other
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function checkCode($code, $other, $data)
{
$my_first_leader = Db::name('user')
->where(['id' => $data['user_id']])
->value('first_leader');
if ($my_first_leader) {
return '已有邀请人';
}
$first_leader = Db::name('user')
->field(['is_distribution', 'id', 'ancestor_relation'])
->where(['distribution_code' => $code])
->find();
if (empty($first_leader)) {
return '请填写有效的邀请码';
}
if ($first_leader['is_distribution'] == 0) {
return '对方不是分销会员';
}
if ($first_leader['id'] == $data['user_id']) {
return '不能邀请自己';
}
$ancestor_relation = explode(',', $first_leader['ancestor_relation']);
if (!empty($ancestor_relation) && in_array($data['user_id'], $ancestor_relation)) {
return '不能填写所有下级的任意一人的邀请码';
}
return true;
}
}

View File

@@ -0,0 +1,72 @@
<?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\validate;
use think\Db;
use think\Validate;
class GetCoupon extends Validate{
protected $rule = [
'id' => 'require|checkCoupon',
];
protected $message = [
'id.require' => '请选择优惠券',
];
public function checkCoupon($value,$rule,$data){
$coupon = Db::name('coupon')->where(['id'=>$value,'status'=>1,'del'=>0,'get_type'=>1])->find();
if(!$coupon){
return '优惠券已下架';
}
$now = time();
if($coupon['send_time_start'] > $now || $coupon['send_time_end'] < $now){
return '未到领取时间';
}
//限量发放,验证是否达到数量
if($coupon['send_total_type'] == 2){
$total_coupon = Db::name('coupon_list')->where(['coupon_id'=>$value,'del'=>0])->count();
if($total_coupon >= $coupon['send_total']){
return '优惠券已领完';
}
}
//限制每人领取次数
if($coupon['get_num_type'] == 2){
$total_coupon = Db::name('coupon_list')->where(['user_id'=>$data['user_id'],'coupon_id'=>$value,'del'=>0])->count();
if($total_coupon >= $coupon['get_num']) {
return '您已达到领取次数了';
}
}
if($coupon['get_num_type'] == 3){
$today = date("Y-m-d");
$tomorrow = date("Y-m-d",strtotime("+1 day"));
$total_coupon = Db::name('coupon_list')->where(['user_id'=>$data['user_id'],'coupon_id'=>$value,'del'=>0])
->whereTime('create_time', 'between',[$today,$tomorrow])
->count();
if($total_coupon >= $coupon['get_num']) {
return '您已达到领取次数了';
}
}
return true;
}
}

View 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\validate;
use think\Db;
use think\Validate;
class GetRegisterCoupon extends Validate {
protected $rule = [
'coupon_ids' => 'checkCoupon',
];
protected function checkCoupon($value,$rule,$data){
return true;
}
}

View File

@@ -0,0 +1,70 @@
<?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\validate;
use think\Validate;
class GoodsComment extends Validate
{
protected $rule = [
'goods_comment' =>'require',
'description_comment' =>'require',
'service_comment' =>'require',
'express_comment' =>'require',
];
protected $message = [
'goods_comment.require' =>'请进行商品评价',
'description_comment.require' =>'请进行描述相符评价',
'service_comment.require' =>'请进行服务态度评价',
'express_comment.require' =>'请进行配送服务评价',
];
/**
* 添加
*/
public function sceneAdd()
{
return $this->remove('id','require');
}
/**
* 编辑
*/
public function sceneEdit()
{
}
/**
* 删除
*/
public function sceneDel()
{
return $this->only(['id']);
}
}

View File

@@ -0,0 +1,134 @@
<?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\validate;
use app\common\model\Client_;
use http\Client;
use think\Db;
use think\facade\Cache;
use think\Validate;
use app\common\logic\SmsLogic;
class Login extends Validate
{
public function __construct(array $rules = [], array $message = [], array $field = [])
{
parent::__construct($rules, $message, $field);
}
protected $rule = [
'account' => 'require',
'password' => 'require|password',
'client' => 'require|in:' . Client_::oa . ',' . Client_::ios . ',' . Client_::android. ',' .Client_::pc. ','. Client_::h5. ','. Client_::tt,
'code'=>'require|checkCode',
];
protected $message = [
'account.require' => '请输入账号或手机号',
'password.require' => '请输入密码',
'password.password' => '密码错误',
'client.in' => '当前只支持h5和app登录',
'code.require'=>'请输入验证码',
];
public function scenePassword()
{
$this->remove(['code']);
}
public function sceneCode()
{
$this->only(['account','code','client']);
}
public static function checkCode($value,$rule,$data){
$sms_logic = new SmsLogic($data['message_key'],$data['account'],$value);
$check = $sms_logic->checkCode();
//检查验证码是否正确
if($check !== true){
return $check;
}
//标记验证码已验证
$sms_logic->cancelCode();
return true;
}
/**
* 账号密码验证码
* @param $password
* @param $other
* @param $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function password($password, $other, $data)
{
if ($this->safe() === false) {
$this->message['password.password'] .= ':多次输入错误';
return false;
}
$admin_info = Db::name('user')
->where(['account|mobile' => $data['account'], 'del' => 0])
->find();
if (empty($admin_info)) {
$this->safe(true);
return false;
}
if ($admin_info['disable']) {
return '账号被禁用';
}
$password = create_password($password, $admin_info['salt']);
if ($password != $admin_info['password']) {
$this->safe(true);
return false;
}
return true;
}
/**
* 连续30分钟内15次输错密码无法登录
* @param bool $add
* @return bool
*/
protected function safe($add = false)
{
$cache_name = 'app_login_error_count' . request()->ip();
if ($add) {
$admin_login_error_count = Cache::get($cache_name);
$admin_login_error_count++;
Cache::tag('app_login_error_count')->set($cache_name, $admin_login_error_count, 1800);
}
$count = Cache::get($cache_name);
if (!empty($count) && $count >= 15) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,76 @@
<?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\validate;
use app\common\logic\SmsLogic;
use think\Validate;
class LoginPassword extends Validate
{
protected $regex = [ 'password' => '^(?=.*[a-zA-Z0-9].*)(?=.*[a-zA-Z\\W].*)(?=.*[0-9\\W].*).{6,20}$'];
protected $rule = [
'mobile'=>'require|mobile',
'password'=>'require|confirm:password|regex:password',
'repassword'=>'require|confirm:password',
'code'=>'require|checkCode',
];
protected $message = [
'mobile.require'=>'请输入手机号',
'password.require'=>'请输入密码',
'password.regex'=>'密码格式错误',
'repassword.require'=>'请再次输入密码',
'repassword.confirm'=>'两次密码输入不一致',
'code.require'=>'请输入验证码',
'mobile.mobile'=>'非有效手机号码'
];
public static function checkCode($value,$rule,$data){
$sms_logic = new SmsLogic($data['message_key'],$data['mobile'],$value);
$check = $sms_logic->checkCode();
//检查验证码是否正确
if($check !== true){
return $check;
}
//标记验证码已验证
$sms_logic->cancelCode();
return true;
}
public function sceneCode()
{
$this->only(['mobile','code']);
}
public function sceneAdd()
{
$this->only(['mobile','password']);
}
public function sceneForget()
{
}
}

View 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\validate;
use think\Validate;
class MnpLogin extends Validate
{
protected $rule = [
'code' => 'require',
];
}

View 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\validate;
use think\Validate;
class OaLogin extends Validate
{
protected $rule = [
'code' => 'require',
];
}

View File

@@ -0,0 +1,33 @@
<?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\validate;
use app\common\model\Client_;
use think\Validate;
class OpLogin extends Validate
{
protected $rule = [
'code' => 'require',
'client' => 'require|in:'.Client_::ios.','.Client_::android,
];
}

View File

@@ -0,0 +1,188 @@
<?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\validate;
use app\api\logic\SeckillLogic;
use think\Db;
use think\Validate;
class Order extends Validate
{
protected $rule = [
'goods' => 'require|array|checkGoods',
'action' => 'require',
'coupon_id' =>'checkCoupon',
];
protected $message = [
'goods.require' => '参数错误',
'action.require' => '参数缺失',
];
protected function sceneBuy()
{
$this->only(['action', 'goods', 'coupon_id']);
}
protected function checkGoods($value, $rule, $data)
{
foreach ($value as $item){
if (!$item['item_id'] || !$item['num']){
return '参数缺失';
}
}
return true;
}
//验证优惠券
protected function checkCoupon($value,$rule,$data){
if($value){
$coupon = Db::name('coupon c')
->join('coupon_list cl','c.id = cl.coupon_id')
->where(['cl.id '=>$value, 'c.del'=>0,'cl.del'=>0,'cl.status'=>0])
->field('c.*,cl.create_time as get_coupon_time')
->find();
if(empty($coupon)){
return '优惠券不存在';
}
$tips = true;
$now = time();
if($coupon['use_time_type'] == 1){
if($coupon['use_time_start'] > $now || $coupon['use_time_end'] < $now){
$tips = '优惠券不在使用时间范围内';
}
}else{//领券当天X天可用
$coupon['use_time'] = $coupon['get_coupon_time']+86400*$coupon['use_time'];
if($coupon['use_time_type'] == 3){ //领券次日起X天可用
$coupon['use_time'] = $coupon['create_time'] + 86400*$coupon['use_time']+86400;
}
if($coupon['use_time'] - $now < 0){
$tips = '优惠券不在使用时间范围内';
}
}
$item_ids = array_column($data['goods'], 'item_id');
$item_num = array_column($data['goods'], 'num', 'item_id');
$goods_price_array = Db::name('goods_item')->alias('gi')
->join('goods g', 'gi.goods_id = g.id')
->where(['gi.id' => $item_ids])
->column('gi.*,g.is_member', 'gi.id');
//会员折扣价格
$user_id = $data['user_id'] ?? 0;
$level_discount = Db::name('user u')
->join('user_level l', 'u.level = l.id')
->where('u.id', $user_id)
->value('discount');
$seckill_list = SeckillLogic::getSeckillGoods();
$seckill_goods = $seckill_list['seckill_goods'];
//会员折扣价(优先级最高且不和其他活动重叠) > 活动价格
foreach ($goods_price_array as $key => $item){
if ($item['is_member'] == 1 && $level_discount > 0) {
$goods_price_array[$key]['price'] = round($item['price'] * $level_discount / 10, 2);
continue;
}
if(isset($seckill_goods[$item['id']])){
$goods_price_array[$key]['price'] = $seckill_goods[$item['id']]['price'];
continue;
}
}
//所有的商品id
$goods_ids = array_column($goods_price_array, 'goods_id');
//优惠券商品
$coupon_goods = Db::name('coupon_goods')->where(['coupon_id' => $coupon['id']])->column('goods_id');
//与当前优惠券关联的商品id
$intersect_goods = array_intersect($goods_ids, $coupon_goods);
//全部商品可用、满足金额可用
if($coupon['use_goods_type'] == 1 && $coupon['condition_type'] == 2){
$total_price = 0;
foreach ($data['goods'] as $goods_item){
$price = isset($goods_price_array[$goods_item['item_id']]) ? $goods_price_array[$goods_item['item_id']]['price'] : 0;
$total_price += $price * $goods_item['num'];
}
//结算商品未满足金额
if($total_price < $coupon['condition_money']){
$tips = '所结算的商品中未满足使用的金额';
}
}
//指定商品可用
if($coupon['use_goods_type'] == 2) {
//未包含指定商品
if(empty($intersect_goods)){
$tips = '所结算的商品中未包含指定商品';
}
if($intersect_goods && $coupon['condition_type'] == 2){
$total_price = 0;
foreach ($intersect_goods as $goods_item){
foreach ($goods_price_array as $price_item){
if($price_item['goods_id'] == $goods_item){
$num = $item_num[$price_item['id']] ?? 0;
$total_price += $price_item['price'] * $num;
}
}
}
//结算商品未满足金额
if($total_price < $coupon['condition_money']){
$tips = '所结算的商品中未满足使用的金额';
}
}
}
//指定商品不可用
if($coupon['use_goods_type'] == 3) {
//包含不可用商品
if($intersect_goods){
$tips = '所结算的商品中包含指定不可用商品';
}
//满足金额可用
if(empty($intersect_goods) && $coupon['condition_type'] == 2){
$diff_goods = array_diff($goods_ids,$coupon_goods);
$total_price = 0;
foreach ($diff_goods as $goods_item){
foreach ($goods_price_array as $price_item){
if($price_item['goods_id'] == $goods_item){
$num = $item_num[$price_item['id']] ?? 0;
$total_price += $price_item['price'] * $num;
}
}
}
//结算商品未满足金额
if($total_price < $coupon['condition_money']){
$tips = '所结算的商品中未满足使用的金额';
}
}
}
return $tips;
}
}
}

View File

@@ -0,0 +1,62 @@
<?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\validate;
use app\common\server\ConfigServer;
use think\Db;
use think\Validate;
class Recharge extends Validate{
protected $rule = [
'id' => 'checkRecharge',
'money' => 'checkRecharge',
'pay_way' => 'require',
];
protected $message = [
'pay_way.require' => '请选择支付方式',
];
protected function checkRecharge($value,$rule,$data){
$open_racharge = ConfigServer::get('recharge','open_racharge',0);
if(!$open_racharge){
return '充值功能已关闭,无法充值';
}
if(empty($value) && $data['money']){
return '请输入充值金额';
}
if(isset($data['id'])){
$remplate = Db::name('recharge_template')
->where(['id'=>$value,'del'=>0])
->find();
if(empty($remplate)){
return '该充值模板不存在';
}
}else{
$min_money = ConfigServer::get('recharge', 'min_money',0);
if($data['money'] < $min_money){
return '最低充值金额为'.$min_money;
}
}
return true;
}
}

View File

@@ -0,0 +1,90 @@
<?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\validate;
use think\Db;
use think\Validate;
use app\common\logic\SmsLogic;
class Register extends Validate
{
protected $regex = ['password' => '^(?=.*[a-zA-Z0-9].*)(?=.*[a-zA-Z\\W].*)(?=.*[0-9\\W].*).{6,20}$'];
protected $rule = [
'mobile' => 'require|mobile|checkMobile',
'password' => 'require|confirm:password|regex:password',
'code' => 'requireIf:check_code,1|checkCode',
];
protected $message = [
'mobile.require' => '请输入手机号',
'password.require' => '请输入密码',
'password.regex' => '密码格式错误',
'code.requireIf' => '请输入验证码',
'mobile.mobile' => '非有效手机号码'
];
public function checkCode($value, $rule, $data)
{
$sms_logic = new SmsLogic('ZCYZ', $data['mobile'], $value);
$check = $sms_logic->checkCode();
//检查验证码是否正确
if ($check !== true) {
return $check;
}
//标记验证码已验证
$sms_logic->cancelCode();
return true;
}
public function sceneCode()
{
$this->only(['mobile', 'code']);
}
public function sceneAdd()
{
$this->only(['mobile', 'password']);
}
public function sceneForget()
{
}
public function checkMobile($value, $data, $rule)
{
//检查手机号是否已存在
$user = Db::name('user')
->where('mobile', '=', $value)
->find();
if ($user) {
return '此手机号已被使用';
}
return true;
}
}

View 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\validate;
use think\Validate;
/**
* 更新微信信息验证器
* Class UpdateWechatUser
* @package app\api\validate
*/
class SetWechatUser extends Validate
{
protected $rule = [
'nickname' => 'require',
'avatar' => 'require',
'sex' => 'require',
];
protected $message = [
'nickname.require' => '参数缺失',
'avatar.require' => '参数缺失',
'sex.require' => '参数缺失',
];
}

View File

@@ -0,0 +1,40 @@
<?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\validate;
use think\Db;
use think\Validate;
class Sign extends Validate{
protected $rule = [
'user_id' => 'checkSign',
];
public function checkSign($value,$data,$rule){
$today = Db::name('user_sign')
->where('del',0)
->where('user_id',$value)
->whereTime('sign_time', 'today')
->find();
if($today){
return '您今天已签到过了';
}
return true;
}
}

View File

@@ -0,0 +1,78 @@
<?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\validate;
use app\api\logic\LoginLogic;
use app\api\model\User;
use app\common\model\NoticeSetting;
use think\{
Db,
Validate
};
class SmsSend extends Validate
{
protected $rule = [
'mobile' => 'require|checkSms',
'key' => 'checkMobile',
];
protected $message = [
'mobile.require' => '请输入手机号码',
];
protected function checkSms($value, $rule, $data)
{
$message_key = NoticeSetting::SMS_SCENE[$data['key']];
$send_time = Db::name('sms_log')
->where(['message_key' => $message_key, 'mobile' => $value, 'is_verify' => 0])
->order('id desc')
->value('send_time');
//一分钟内不能频繁发送
if ($send_time && $send_time + 60 > time()) {
return '验证码发送频繁,请稍后在发送';
}
return true;
}
protected function checkMobile($value, $rule, $data)
{
$user = User::get(['mobile' => $data['mobile'], 'del' => 0]);
switch ($value) {
case 'ZCYZ': //注册验证
case 'BDSJHM': //绑定手机号码
if ($user) return '该手机号码已存在';
break;
case 'YZMDL': //验证码登录
if (empty($user) || !$user) { //账号不存在, 给他注册
$post = request()->post();
$post['password'] = '';
LoginLogic::register($post);
}
break;
case 'ZHMM': //找回密码
case 'BGSJHM': //变更手机号码
case 'ZHZFMM': // 找回支付密码
if (empty($user)) return '手机号码不存在';
break;
}
return true;
}
}

View File

@@ -0,0 +1,126 @@
<?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\validate;
use think\Db;
use think\Validate;
class Team extends Validate
{
protected $rule = [
'item_id' => 'require|integer|checkTeamGoods',
'goods_num' => 'require|integer',
'action' => 'require',
'pay_way' =>'require|in:1,2,3',
'found_id' => 'checkTeamFound',
'order_id' => 'require',
'team_id' => 'require|checkTeam',
];
protected $message = [
'item_id.require' => '请选择商品规格',
'goods_num.require' => '请选择商品数量',
'goods_num.integer' => '商品数量错误',
'action.require' => '订单错误',
'pay_way.require' => '支付方式错误',
'found_id.require' => '参数缺失',
'order_id.require' => '参数缺失',
'team_id.require' => '参数缺失',
];
protected function sceneAdd()
{
$this->only(['action', 'pay_way', 'goods_num', 'item_id', 'found_id', 'team_id']);
}
protected function sceneCheck()
{
$this->only(['team_id', 'found_id']);
}
//验证是否为拼团商品
protected function checkTeamGoods($value, $rule, $data = [])
{
$team_goods = Db::name('team_activity')->alias('a')
->join('team_goods_item ti', 'ti.team_id = a.team_id')
->join('goods_item gi', 'gi.id = ti.item_id')
->where(['a.status' => 1, 'a.del' => 0])
->whereBetweenTimeField('a.start_time','a.end_time')
->where(['ti.item_id' => $value])
->find();
if (!$team_goods){
return '不在活动时间内或活动已结束';
}
//商品库存是否足够
if ($data['goods_num'] > $team_goods['stock']){
return '库存不足';
}
return true;
}
//参团时验证团
protected function checkTeamFound($value, $rule, $data = [])
{
if (empty($value)){
return true;
}
$team_found = Db::name('team_found')
->where(['id' => $value, 'status' => 0])
->find();
if (!$team_found){
return '该团已结束';
}
// if ($team_found['join'] >= $team_found['need']){
// return ['code' => 20001, 'msg' => '该团已满员'];
// }
//
//当前用户是否已参与团
$follow = Db::name('team_follow')
->where(['found_id' => $value, 'follow_user_id' => $data['user_id']])
->find();
if ($follow){
return '你已参加该团,无法再次参加了!';
}
return true;
}
protected function checkTeam($value, $rule, $data = [])
{
$team = Db::name('team_activity')->where(['team_id' => $value])->find();
if ($team['end_time'] < time()){
return '已过拼团活动截止时间';
}
return true;
}
}

View File

@@ -0,0 +1,86 @@
<?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\validate;
use think\Db;
use think\Validate;
class Token extends Validate
{
protected $rule = [
'token' => 'require|valid|user',
];
/**
* User: 意象信息科技 lr
* Desc: token验证
* @param $token
* @param $other
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function valid($token, $other, $data)
{
$session = Db::name('session')
->where(['token' => $token])
->find();
if (empty($session)) {
return '会话失效,请重新登录';
}
if ($session['expire_time'] <= time()) {
return '登录超时,请重新登录';
}
return true;
}
/**
* User: 意象信息科技 lr
* Desc 用户验证
* @param $token
* @param $other
* @param $data
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function user($token, $other, $data)
{
$user_id = Db::name('session')
->where(['token' => $token])
->value('user_id');
$user_info = Db::name('user')
->where(['id' => $user_id, 'del' => 0])
->find();
if (empty($user_info)) {
return '用户不存在';
}
if ($user_info['disable'] == 1) {
return '用户被禁用';
}
return true;
}
}

View File

@@ -0,0 +1,53 @@
<?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\validate;
use app\common\logic\SmsLogic;
use app\common\model\Client_;
use think\Db;
use think\Validate;
class UpdateUser extends Validate
{
protected $rule = [
'field' => 'require|checkField',
'value' => 'require',
];
protected $message = [
'field.require' => '参数缺失',
'value.require' => '请填写完整',
];
public function sceneSet()
{
$this->only(['field', 'value']);
}
protected function checkField($value, $rule, $data)
{
$allow_field = ['nickname', 'sex', 'avatar', 'mobile'];
if (in_array($value, $allow_field)) {
return true;
}
return '操作失败';
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace app\api\validate;
use think\Validate;
class User extends Validate
{
protected $rule = [
'pay_password' => 'require|length:4,8|alphaDash', // 字母、数字、下划线、破折号
'transferTo' => 'require',
'money' => 'require|gt:0'
];
protected $message = [
'pay_password.require' => '支付密码不能为空',
'pay_password.length' => '支付密码必须在4-8位之间',
'pay_password.alphaDash' => '支付密码须为字母、数字、下划线或破折号',
'user_type.require' => '用户类型不能为空',
'transferTo.require' => '收款人不能为空',
'money.require' => '转账金额不能为空',
'money.gt' => '转账金额必须大于0',
];
/**
* 设置支付密码
*/
public function sceneSetPayPassword()
{
return $this->only(['pay_password']);
}
/**
* 会员转账
*/
public function sceneTransfer()
{
return $this->only(['pay_password', 'transferTo', 'money'])
->remove('pay_password',['length','alphaDash']);
}
}

View File

@@ -0,0 +1,108 @@
<?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\validate;
use think\Validate;
class UserAddress extends Validate
{
protected $rule = [
'id' => 'require|integer',
'contact' => 'require',
'telephone' => 'require|mobile',
'province_id' => 'require',
'city_id' => 'require',
'district_id' => 'require',
'address' => 'require',
'is_default' => 'require',
];
protected $message = [
'id.require' => 'id不能为空',
'id.integer' => 'id参数错误',
'contact.require' => '收货人不能为空',
'telephone.require' => '联系方式不能为空',
'telephone.mobile' => '非有效手机号',
'province_id.require' => '所选地区不能为空',
'city_id.require' => '请选择完整地址',
'district_id.require' => '请选择完整地址',
'address.require' => '详细地址不能为空',
'is_default.require' => '是否默认不能为空',
'province.require' => '省不能为空',
'city.require' => '市不能为空',
'district.require' => '区不能为空',
];
/**
* 添加
*/
public function sceneAdd()
{
return $this->remove('id');
}
/**
* 编辑
*/
public function sceneEdit()
{
}
/**
* 删除
*/
public function sceneDel()
{
return $this->only(['id']);
}
/**
* 获取一条地址
*/
public function sceneOne()
{
return $this->only(['id']);
}
/**
* 设置默认地址
*/
public function sceneSet()
{
return $this->only(['id']);
}
/**
* 获取省市区id
*/
public function sceneHandleRegion()
{
return $this->only(['province','city','district'])
->append('province','require')
->append('city','require')
->append('district','require');
}
}

View 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\validate;
use think\Validate;
class WechatMobile extends Validate
{
protected $rule = [
'code' => 'require',
'encrypted_data' => 'require',
'iv' => 'require',
];
}

View File

@@ -0,0 +1,87 @@
<?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\validate;
use app\api\logic\DistributionLogic;
use app\common\server\ConfigServer;
use think\Db;
use think\Validate;
class Withdraw extends Validate
{
protected $rule = [
'id' => 'require', //参数缺失
'type' => 'require|in:1,2,3,4,5',//提现类型
'money' => 'require|checkMoney',//提现佣金
'account' => 'requireIf:type,3|requireIf:type,4|requireIf:type,5',//账户类型
'real_name' => 'requireIf:type,3|requireIf:type,4|requireIf:type,5|chs',//真实姓名
'money_qr_code' => 'requireIf:type,3|requireIf:type,4',//收款码
'bank' => 'requireIf:type,5', // 提现银行
'subbank' => 'requireIf:type,5', // 银行支行
];
protected $message = [
'id.require' => '参数缺失',
'type.require' => '参数错误',
'type.in' => '提现类型错误',
'money.require' => '参数错误',
'account.requireIf' => '请填写账号',
'real_name.requireIf' => '请填写真实姓名',
'real_name.chs' => '请填写真实姓名',
'money_qr_code.requireIf' => '请上传收款码',
'bank.requireIf' => '请填写提现银行',
'subbank.requireIf' => '请填写银行支行',
];
//申请提现
public function sceneApply()
{
return $this->only(['type', 'money', 'account', 'real_name', 'money_qr_code', 'bank', 'subbank']);
}
//申请详情
public function sceneInfo()
{
return $this->only(['id']);
}
//提现佣金验证
protected function checkMoney($value, $rule, $data = [])
{
$able_withdraw = Db::name('user')->where('id', $data['user_id'])->value('earnings');
if ($value > $able_withdraw){
return '可提现金额不足';
}
//1.最低提现金额
$min_withdraw = ConfigServer::get('withdraw', 'min_withdraw', 0);
if($value < $min_withdraw){
return '最低提现'.$min_withdraw.'元';
}
//2,最高提现金额
$max_withdraw = ConfigServer::get('withdraw', 'max_withdraw', 0);
if ($value > $max_withdraw){
return '最高提现'.$max_withdraw.'元';
}
return true;
}
}