22 changed files with 625 additions and 753 deletions
-
8app/Http/Controllers/Admin/OrderController.php
-
7app/Http/Controllers/Api/BonusController.php
-
6app/Http/Controllers/Api/GoodsController.php
-
151app/Http/Controllers/Api/OrderController.php
-
140app/Http/Controllers/Api/UserAddressController.php
-
10app/Http/Controllers/Weixin/OrderController.php
-
4app/Http/Logic/GoodsLogic.php
-
156app/Http/Logic/OrderLogic.php
-
114app/Http/Logic/UserAddressLogic.php
-
2app/Http/Logic/UserLogic.php
-
71app/Http/Model/Bonus.php
-
10app/Http/Model/Cart.php
-
14app/Http/Model/Goods.php
-
307app/Http/Model/Order.php
-
6app/Http/Model/Region.php
-
8app/Http/Model/User.php
-
205app/Http/Model/UserAddress.php
-
4app/Http/Requests/OrderRequest.php
-
115app/Http/Requests/UserAddressRequest.php
-
4resources/views/weixin/collect_goods/index.blade.php
-
2resources/views/weixin/goods/goodsDetail.blade.php
-
2resources/views/weixin/user/userGoodsHistory.blade.php
@ -0,0 +1,115 @@ |
|||||
|
<?php |
||||
|
namespace App\Http\Requests; |
||||
|
|
||||
|
class UserAddressRequest extends BaseRequest |
||||
|
{ |
||||
|
//总的验证规则
|
||||
|
protected $rules = [ |
||||
|
'id' => 'required|integer', |
||||
|
'user_id' => 'required|integer', |
||||
|
'name' => 'required|max:60', |
||||
|
'country' => 'required|integer', |
||||
|
'province' => 'required|integer', |
||||
|
'city' => 'required|integer', |
||||
|
'district' => 'required|integer', |
||||
|
'address' => 'required|max:120', |
||||
|
'zipcode' => 'integer', |
||||
|
'telphone' => 'max:60', |
||||
|
'mobile' => 'required|max:60', |
||||
|
'is_default' => 'required|integer|between:0,1', |
||||
|
]; |
||||
|
|
||||
|
//总的自定义错误信息
|
||||
|
protected $messages = [ |
||||
|
'id.required' => 'ID必填', |
||||
|
'id.integer' => 'ID必须为数字', |
||||
|
'user_id.required' => '用户ID必填', |
||||
|
'user_id.integer' => '用户ID必须为数字', |
||||
|
'name.required' => '收货人名字必填', |
||||
|
'name.max' => '收货人名字不能超过60个字符', |
||||
|
'country.required' => '国家ID必填', |
||||
|
'country.integer' => '国家ID必须为数字', |
||||
|
'province.required' => '省份ID必填', |
||||
|
'province.integer' => '省份ID必须为数字', |
||||
|
'city.required' => '城市ID必填', |
||||
|
'city.integer' => '城市ID必须为数字', |
||||
|
'district.required' => '地区ID必填', |
||||
|
'district.integer' => '地区ID必须为数字', |
||||
|
'address.required' => '收货人的详细地址必填', |
||||
|
'address.max' => '收货人的详细地址不能超过120个字符', |
||||
|
'zipcode.integer' => '收货人邮编必须为数字', |
||||
|
'telphone.max' => '固定电话不能超过60个字符', |
||||
|
'mobile.required' => '收货人手机号必填', |
||||
|
'mobile.max' => '收货人手机号不能超过20个字符', |
||||
|
'is_default.required' => '是否默认必填', |
||||
|
'is_default.integer' => '是否默认必须是数字', |
||||
|
'is_default.between' => '是否默认,0:为非默认,1:默认', |
||||
|
]; |
||||
|
|
||||
|
//场景验证规则
|
||||
|
protected $scene = [ |
||||
|
'add' => ['user_id', 'name', 'province', 'city', 'district', 'address', 'zipcode', 'telphone', 'mobile', 'is_default'], |
||||
|
'edit' => ['zipcode', 'telphone', 'is_default'], |
||||
|
'del' => ['user_id', 'id'], |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
return true; //修改为true
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
return $this->rules; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取被定义验证规则的错误消息. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function messages() |
||||
|
{ |
||||
|
return $this->messages; |
||||
|
} |
||||
|
|
||||
|
//获取场景验证规则
|
||||
|
public function getSceneRules($name, $fields = null) |
||||
|
{ |
||||
|
$res = array(); |
||||
|
|
||||
|
if(!isset($this->scene[$name])) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
$scene = $this->scene[$name]; |
||||
|
if($fields != null && is_array($fields)) |
||||
|
{ |
||||
|
$scene = $fields; |
||||
|
} |
||||
|
|
||||
|
foreach($scene as $k=>$v) |
||||
|
{ |
||||
|
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} |
||||
|
} |
||||
|
|
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
//获取场景验证规则自定义错误信息
|
||||
|
public function getSceneRulesMessages() |
||||
|
{ |
||||
|
return $this->messages; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue