其余文件
This commit is contained in:
68
app/shopapi/validate/AdminPasswordValidate.php
Normal file
68
app/shopapi/validate/AdminPasswordValidate.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?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\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
|
||||
/**
|
||||
* 管理员密码
|
||||
* Class AdminPasswordValidate
|
||||
* @package app\admin\validate
|
||||
*/
|
||||
class AdminPasswordValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'old_password' => 'require|verify',
|
||||
'password' => 'require|length:6,16|confirm',
|
||||
// 'password_confirm' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'old_password.require' => '当前密码不能为空',
|
||||
'old_password.verify' => '当前密码输入不正确',
|
||||
'password.require' => '新密码不能为空',
|
||||
'password.length' => '密码长度必须为6到16位之间',
|
||||
'password.confirm' => '两次密码输入不一致',
|
||||
'password_confirm.require' => '请输入确认密码',
|
||||
];
|
||||
|
||||
/**
|
||||
* 密码验证
|
||||
* @param $old_password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
protected function verify($old_password, $other, $data)
|
||||
{
|
||||
$admin = ShopAdmin::find($data['admin_id']);
|
||||
$password = generatePassword($old_password, $admin['salt']);
|
||||
|
||||
if ($password != $admin['password']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
90
app/shopapi/validate/LoginValidate.php
Normal file
90
app/shopapi/validate/LoginValidate.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 商家移动端登录验证
|
||||
* Class LoginValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class LoginValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'client' => 'require|in:1,2,3,4,5,6',
|
||||
'account' => 'require',
|
||||
'password' => 'require|checkPassword',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'password.require' => '请输入密码',
|
||||
'password.checkPassword' => '账号或密码错误',
|
||||
'client.require' => '请输入客户端',
|
||||
'client.in' => '无效的客户端',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验密码
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2021/11/9 16:02
|
||||
*/
|
||||
protected function checkPassword($password, $other, $data)
|
||||
{
|
||||
if (false === $this->safe()) {
|
||||
$this->message['password.password'] .= ':多次输入错误';
|
||||
return false;
|
||||
}
|
||||
|
||||
$admin_info = (new ShopAdmin())->alias('a')
|
||||
->field('a.*')
|
||||
->join('shop s', 's.id = a.shop_id')
|
||||
->where(['a.account' => $data['account'], 'a.del' => 0])
|
||||
->find();
|
||||
|
||||
if (empty($admin_info)) {
|
||||
$this->safe(true);
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
if ($admin_info['disable']) {
|
||||
return '账号被禁用';
|
||||
}
|
||||
|
||||
$password = generatePassword($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 = 'shop_api_login_error_count' . request()->ip();
|
||||
if ($add) {
|
||||
$admin_login_error_count = Cache::get($cache_name);
|
||||
$admin_login_error_count++;
|
||||
Cache::tag('shop_api_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;
|
||||
}
|
||||
}
|
||||
242
app/shopapi/validate/OrderValidate.php
Normal file
242
app/shopapi/validate/OrderValidate.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?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\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\Delivery;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\Team;
|
||||
use app\common\model\team\TeamJoin;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 商家移动端订单管理验证器
|
||||
* Class OrderValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class OrderValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'consignee' => 'require',
|
||||
'province' => 'require',
|
||||
'city' => 'require',
|
||||
'district' => 'require',
|
||||
'address' => 'require',
|
||||
'mobile' => [ 'require', 'checkMobile' => [ 'check' => [ 'land', 'hk' ] ] ],
|
||||
'send_type' => 'require|in:1,2',
|
||||
'shipping_id' => 'requireIf:send_type,1',
|
||||
'invoice_no' => 'requireIf:send_type,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'consignee.require' => '请填写收件人',
|
||||
'province.require' => '地址参数缺失',
|
||||
'city.require' => '地址参数缺失',
|
||||
'district.require' => '地址参数缺失',
|
||||
'address.require' => '请填写详细',
|
||||
'mobile.require' => '请填写手机号码',
|
||||
'mobile.mobile' => '请填写正确的手机号码',
|
||||
'send_type.require' => '请选择快递方式',
|
||||
'send_type.in' => '快递方式参数错误',
|
||||
'shipping_id.requireIf' => '请选择快递公司',
|
||||
'invoice_no.requireIf' => '请填写快递单号',
|
||||
];
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkCancel');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkDel');
|
||||
}
|
||||
|
||||
public function sceneEditAddress()
|
||||
{
|
||||
return $this->only(['id','consignee','province','city','district','address','mobile']);
|
||||
}
|
||||
|
||||
public function sceneDelivery()
|
||||
{
|
||||
return $this->only(['id','send_type','shipping_id','invoice_no'])
|
||||
->append('id','checkDelivery');
|
||||
}
|
||||
|
||||
public function sceneConfirm()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkConfirm');
|
||||
}
|
||||
|
||||
public function sceneLogistics()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkLogistics');
|
||||
}
|
||||
|
||||
public function sceneGetAddress()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 3:25 下午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0,'delete'=>0])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否可以取消
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 4:38 下午
|
||||
*/
|
||||
public function checkCancel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id']])->findOrEmpty();
|
||||
|
||||
if ($result['order_status'] > OrderEnum::ORDER_STATUS_DELIVERY && $result['delivery_type'] != 2) {
|
||||
return '此订单不可取消';
|
||||
}
|
||||
|
||||
if ($result['order_status'] > OrderEnum::ORDER_STATUS_GOODS && $result['delivery_type'] == 2) {
|
||||
return '此订单不可取消';
|
||||
}
|
||||
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$found = Db::name('team_join')->where(['order_id' => $order['id']])->find();
|
||||
if ($found['status'] == Team::STATUS_WAIT_SUCCESS) {
|
||||
return '已支付的拼团订单需要有拼团结果才可以取消';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否删除
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/10 5:21 下午
|
||||
*/
|
||||
public function checkDel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value,'shop_id'=>$data['shop_id']])->findOrEmpty();
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_DOWN) {
|
||||
return '此订单不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否发货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 10:25 上午
|
||||
*/
|
||||
public function checkDelivery($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
|
||||
if ($result['shipping_status'] == 1) {
|
||||
return '订单已发货';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$join = TeamJoin::where(['order_id' => $result['id']])->findOrEmpty();
|
||||
if ($join['status'] != Team::STATUS_SUCCESS) {
|
||||
return '已支付的拼团订单需要等待拼团成功后才能发货';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否确认收货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:22 上午
|
||||
*/
|
||||
public function checkConfirm($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
|
||||
if ($result['shipping_status'] != 1 || $result['order_status'] != OrderEnum::ORDER_STATUS_GOODS) {
|
||||
return '此订单不允许确认收货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单是否有物流信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2021/11/11 11:34 上午
|
||||
*/
|
||||
public function checkLogistics($value,$rule,$data)
|
||||
{
|
||||
$order = Order::where(['id'=>$value])->findOrEmpty();
|
||||
$delivery = Delivery::where('order_id',$value)->findOrEmpty();
|
||||
|
||||
if (($order['order_status'] != OrderEnum::ORDER_STATUS_GOODS && $order['order_status'] != OrderEnum::ORDER_STATUS_COMPLETE) || $delivery['send_type'] == 2) {
|
||||
return '暂无物流信息';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
180
app/shopapi/validate/ShopDataSetValidate.php
Normal file
180
app/shopapi/validate/ShopDataSetValidate.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 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\shopapi\validate;
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\ShopEnum;
|
||||
|
||||
/**
|
||||
* 商家信息验证
|
||||
* Class ShopInfoValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class ShopDataSetValidate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'dataset' => 'require|checkData',
|
||||
];
|
||||
protected $message = [
|
||||
'dataset.require' => '请输入信息',
|
||||
];
|
||||
|
||||
|
||||
protected $allow_fields = [
|
||||
'nickname', //联系人
|
||||
'mobile' => 'checkMobile', //联系电话
|
||||
'intro', //简介
|
||||
'is_run' => 'checkRund', //营业状态
|
||||
'province_id', //省id
|
||||
'city_id', //城市id
|
||||
'district_id', //区id
|
||||
'address', //详情地址
|
||||
'refund_address' => 'checkRefund', //退款地址
|
||||
'weekdays' => 'checkWeekDay', //营业时间
|
||||
'run_start_time' => 'checkTime', //每天营业开始时间
|
||||
'run_end_time' => 'checkTime', //每天营业结束时间
|
||||
'open_invoice', //发票开关 0- 关闭 1-开启
|
||||
'spec_invoice', //是否支持专票 0-不支持 1-支持
|
||||
];
|
||||
|
||||
protected function checkData($dataset,$rule,$data){
|
||||
foreach ($dataset as $field => $value){
|
||||
|
||||
$allow_fields = array_keys($this->allow_fields);
|
||||
if(!in_array($field,$allow_fields)){
|
||||
return '该信息不允许修改';
|
||||
}
|
||||
|
||||
$func = $this->allow_fields[$field] ?? '';
|
||||
if($func){
|
||||
$result = call_user_func([ShopDataSetValidate::class,$func],$data);
|
||||
if(true !== $result){
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证手机号码是否正确
|
||||
public function checkMobile($value, $rule, $data){
|
||||
$mobile = $data['mobile'];
|
||||
$check = $this->checkRule($mobile, 'mobile');
|
||||
if(false === $check){
|
||||
return '手机号格式错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证营业状态是否正确
|
||||
protected function checkRund($data){
|
||||
if(!in_array($data['is_run'],[ShopEnum::SHOP_RUN_CLOSE,ShopEnum::SHOP_RUN_OPEN])){
|
||||
return '营业状态错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证营业天是否正确
|
||||
protected function checkWeekDay($data){
|
||||
foreach ($data['weekdays'] as $day){
|
||||
if(!in_array($day,[0,1,2,3,4,5,6])){
|
||||
return '工作日错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证时间是否正确
|
||||
protected function checkTime($data){
|
||||
if(empty($data['run_start_time']) || empty($data['run_end_time'])){
|
||||
return '请选择营业时间';
|
||||
}
|
||||
if($data['run_start_time'] >= $data['run_end_time']){
|
||||
return '营业时间错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证退款信息
|
||||
protected function checkRefund($data){
|
||||
$refund_address = $data['refund_address'];
|
||||
if(empty($refund_address)){
|
||||
return '请输入退款地址';
|
||||
}
|
||||
|
||||
foreach ($refund_address as $index => $value){
|
||||
switch ($index){
|
||||
case "nickname":
|
||||
if(empty($value)){
|
||||
return '请输入退款联系人';
|
||||
}
|
||||
break;
|
||||
case "mobile":
|
||||
$check = $this->checkRule($value, 'mobile');
|
||||
if(false === $check){
|
||||
return '手机号格式错误';
|
||||
}
|
||||
break;
|
||||
case "province_id":
|
||||
if(empty($value)){
|
||||
return '请选择省份';
|
||||
}
|
||||
break;
|
||||
case "city_id":
|
||||
if(empty($value)){
|
||||
return '请选择城市';
|
||||
}
|
||||
break;
|
||||
case "district_id":
|
||||
if(empty($value)){
|
||||
return '请选择地区';
|
||||
}
|
||||
break;
|
||||
case "address":
|
||||
if(empty($value)){
|
||||
return '请输入详情地址';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
73
app/shopapi/validate/ShopWithdrawValidate.php
Normal file
73
app/shopapi/validate/ShopWithdrawValidate.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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\shopapi\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\shop\ShopBank;
|
||||
use app\common\server\ConfigServer;
|
||||
|
||||
/**
|
||||
* 商家提现验证
|
||||
* Class ShopWithdrawValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class ShopWithdrawValidate extends Validate{
|
||||
protected $rule = [
|
||||
'money' => 'require|gt:0|checkMoney',
|
||||
'bank_id' => 'require|checkBank',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'money.require' => '请输入提现金额',
|
||||
'money.gt' => '提现金额必须大于零',
|
||||
'bank_id.require' => '请现在提现账户',
|
||||
];
|
||||
|
||||
//验证提现金额是否满足条件
|
||||
protected function checkMoney($value,$rule,$data){
|
||||
$min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0);
|
||||
$max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0);
|
||||
|
||||
$wallet = Shop::where(['id'=>$data['shop_id']])
|
||||
->value("wallet");
|
||||
|
||||
if($wallet < $value){
|
||||
return '当前账户仅剩:'.$wallet.'元';
|
||||
}
|
||||
if($min_withdrawal_money > $value){
|
||||
return '最低提现金额:'.$min_withdrawal_money.'元';
|
||||
}
|
||||
if($max_withdrawal_money < $value){
|
||||
return '最高提现金额:'.$max_withdrawal_money.'元';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//验证提现账户是否存在
|
||||
protected function checkBank($value,$rule,$data){
|
||||
if(ShopBank::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0])->find()){
|
||||
return true;
|
||||
}
|
||||
return '账户不存在,请重新选择';
|
||||
}
|
||||
|
||||
}
|
||||
89
app/shopapi/validate/TokenValidate.php
Normal file
89
app/shopapi/validate/TokenValidate.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?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\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\shop\ShopAdmin;
|
||||
use app\common\model\ShopSession as SessionModel;
|
||||
|
||||
/**
|
||||
* 商家移动端管理员登录token验证
|
||||
* Class TokenValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class TokenValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'token' => 'require|valid|admin',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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 = SessionModel::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 admin($token, $other, $data)
|
||||
{
|
||||
$admin_id = SessionModel::where(['token' => $token])
|
||||
->value('admin_id');
|
||||
|
||||
$admin_info = ShopAdmin::where(['id' => $admin_id, 'del' => 0])
|
||||
->find();
|
||||
if (empty($admin_info)) {
|
||||
return '用户不存在';
|
||||
}
|
||||
if ($admin_info['disable'] == 1) {
|
||||
return '用户被禁用';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
146
app/shopapi/validate/VerificationValidate.php
Normal file
146
app/shopapi/validate/VerificationValidate.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\TeamEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\TeamJoin;
|
||||
|
||||
/**
|
||||
* 自提核销验证
|
||||
* Class VerificationValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VerificationValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'pickup_code' => 'require|checkPickupCode',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'pickup_code.require' => '请填写核销码',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return VerificationValidate
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:18
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['pickup_code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 确认核销
|
||||
* @return VerificationValidate
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:18
|
||||
*/
|
||||
public function sceneConfirm()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkVerification');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:41
|
||||
*/
|
||||
public function checkId($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单是否可以提货核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:42
|
||||
*/
|
||||
public function checkVerification($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)
|
||||
->where('shop_id', $data['shop_id'])
|
||||
->findOrEmpty();
|
||||
if ($result['pay_status'] != PayEnum::ISPAID) {
|
||||
return '订单未支付,不允许核销';
|
||||
}
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_SELF) {
|
||||
return '非自提订单,不允许核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) {
|
||||
return '订单已核销';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$teamcheck = TeamJoin::where(['order_id' => $value, 'status' => TeamEnum::TEAM_STATUS_SUCCESS])->findOrEmpty();
|
||||
if ($teamcheck->isEmpty()) {
|
||||
return '拼团成功后才能核销';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 收货码核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 18:04
|
||||
*/
|
||||
public function checkPickupCode($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['pickup_code'=>$value, 'shop_id' => $data['shop_id']])->find();
|
||||
if (empty($result)) {
|
||||
return '提货码不正确';
|
||||
}
|
||||
if (!in_array($result['order_status'],[OrderEnum::ORDER_STATUS_DELIVERY,OrderEnum::ORDER_STATUS_GOODS])) {
|
||||
return '订单不允许核销';
|
||||
}
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_SELF) {
|
||||
return '不是自提订单,不允许核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) {
|
||||
return '订单已核销';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER){
|
||||
$teamcheck = TeamJoin::where(['order_id' => $result['id'], 'status' => TeamEnum::TEAM_STATUS_SUCCESS])->findOrEmpty();
|
||||
if ($teamcheck->isEmpty()) {
|
||||
return '拼团成功后才能核销';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
app/shopapi/validate/VirtualDeliveryValidate.php
Normal file
52
app/shopapi/validate/VirtualDeliveryValidate.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 虚拟发货验证
|
||||
* Class virtualDeliveryValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VirtualDeliveryValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require|checkOrder',
|
||||
'delivery_content' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '缺少ID字段',
|
||||
'delivery_content.require' => '请填写发货内容',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 校验订单信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/7 18:26
|
||||
*/
|
||||
protected function checkOrder($value, $rule, $data)
|
||||
{
|
||||
$order = Order::findOrEmpty($value);
|
||||
if ($order->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
|
||||
if ($order['del'] == 1) {
|
||||
return '订单已删除';
|
||||
}
|
||||
|
||||
if ($order['shipping_status'] == 1) {
|
||||
return '此订单已发货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user