截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ShopWithdrawValidate.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\validate;
  20. use app\common\basics\Validate;
  21. use app\common\model\shop\Shop;
  22. use app\common\model\shop\ShopBank;
  23. use app\common\server\ConfigServer;
  24. /**
  25. * 商家提现验证
  26. * Class ShopWithdrawValidate
  27. * @package app\shopapi\validate
  28. */
  29. class ShopWithdrawValidate extends Validate{
  30. protected $rule = [
  31. 'money' => 'require|gt:0|checkMoney',
  32. 'bank_id' => 'require|checkBank',
  33. ];
  34. protected $message = [
  35. 'money.require' => '请输入提现金额',
  36. 'money.gt' => '提现金额必须大于零',
  37. 'bank_id.require' => '请现在提现账户',
  38. ];
  39. //验证提现金额是否满足条件
  40. protected function checkMoney($value,$rule,$data){
  41. $min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0);
  42. $max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0);
  43. $wallet = Shop::where(['id'=>$data['shop_id']])
  44. ->value("wallet");
  45. if($wallet < $value){
  46. return '当前账户仅剩:'.$wallet.'元';
  47. }
  48. if($min_withdrawal_money > $value){
  49. return '最低提现金额:'.$min_withdrawal_money.'元';
  50. }
  51. if($max_withdrawal_money < $value){
  52. return '最高提现金额:'.$max_withdrawal_money.'元';
  53. }
  54. return true;
  55. }
  56. //验证提现账户是否存在
  57. protected function checkBank($value,$rule,$data){
  58. if(ShopBank::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0])->find()){
  59. return true;
  60. }
  61. return '账户不存在,请重新选择';
  62. }
  63. }