林一峰
7 years ago
26 changed files with 491 additions and 144 deletions
-
31app/Http/Controllers/Api/PaymentController.php
-
12app/Http/Controllers/Api/UserAddressController.php
-
82app/Http/Controllers/Api/UserRechargeController.php
-
18app/Http/Controllers/Weixin/CartController.php
-
6app/Http/Controllers/Weixin/UserController.php
-
80app/Http/Model/Payment.php
-
49app/Http/Model/UserAddress.php
-
2app/Http/Model/UserBonus.php
-
6app/Http/Model/UserMoney.php
-
6app/Http/Model/UserPoint.php
-
86app/Http/Model/UserRecharge.php
-
12resources/views/weixin/address/index.blade.php
-
13resources/views/weixin/address/userAddressAdd.blade.php
-
13resources/views/weixin/address/userAddressUpdate.blade.php
-
14resources/views/weixin/article/category.blade.php
-
12resources/views/weixin/article/detail.blade.php
-
23resources/views/weixin/cart/cartCheckout.blade.php
-
14resources/views/weixin/cart/index.blade.php
-
10resources/views/weixin/common/headerNav.blade.php
-
12resources/views/weixin/goods/goodsDetail.blade.php
-
13resources/views/weixin/user/login.blade.php
-
13resources/views/weixin/user/register.blade.php
-
4resources/views/weixin/user/userAccount.blade.php
-
89resources/views/weixin/user/userRecharge.blade.php
-
12resources/views/weixin/user/userinfo.blade.php
-
3routes/web.php
@ -0,0 +1,31 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
use App\Http\Model\Payment; |
|||
|
|||
class PaymentController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
//获取支付方式列表
|
|||
public function paymentList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['status'] = $request->input('status', -1); |
|||
|
|||
$res = Payment::getList($data); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,82 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
use App\Http\Model\UserRecharge; |
|||
|
|||
class UserRechargeController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
//用户充值列表
|
|||
public function userRechargeList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['limit'] = $request->input('limit', 10); |
|||
$data['offset'] = $request->input('offset', 0); |
|||
$data['status'] = $request->input('status', -1); |
|||
|
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
$res = UserRecharge::getList($data); |
|||
if($res === false) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//添加充值记录
|
|||
public function userRechargeAdd(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['money'] = $request->input('money',''); |
|||
if($request->input('status', '') != ''){$data['status'] = $request->input('status');} |
|||
if($request->input('pay_type', '') != ''){$data['pay_type'] = $request->input('pay_type');} |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['money']=='') |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = UserRecharge::add($data); |
|||
if($res === false) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//修改充值记录
|
|||
public function userRechargeUpdate(Request $request) |
|||
{ |
|||
//参数
|
|||
$id = $request->input('id',''); |
|||
$data['trade_no'] = $request->input('trade_no',''); |
|||
$data['pay_time'] = $request->input('pay_time',''); |
|||
$data['status'] = UserRecharge::COMPLETE_PAY; |
|||
$data['updated_at'] = date('Y-m-d H:i:s',time()); |
|||
|
|||
if($id=='' || $data['trade_no']=='' || $data['pay_time']=='') |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = UserRecharge::modify(array('id'=>$id,'user_id'=>Token::$uid),$data); |
|||
if($res === false) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS); |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
use App\Common\ReturnData; |
|||
|
|||
class Payment extends BaseModel |
|||
{ |
|||
//用户优惠券
|
|||
|
|||
protected $table = 'payment'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = array(); |
|||
|
|||
const STATUS = 1; // 可用支付方式
|
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$model = new Payment; |
|||
|
|||
if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
|
|||
|
|||
if(isset($where)){$model = $model->where($where);} |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->orderBy('listorder','desc')->get(); |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($where) |
|||
{ |
|||
return self::where($where)->first(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if(self::where(array('pay_code'=>$data['pay_code']))->first()){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'支付方式已存在');} |
|||
|
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return ReturnData::create(ReturnData::SUCCESS,$id); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove($id) |
|||
{ |
|||
if (!self::whereIn('id', explode(',', $id))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,86 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
use App\Common\ReturnData; |
|||
|
|||
class UserRecharge extends BaseModel |
|||
{ |
|||
//用户余额明细
|
|||
|
|||
protected $table = 'user_recharge'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = array(); |
|||
|
|||
const COMPLETE_PAY = 1; |
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$where['user_id'] = $user_id; |
|||
$limit = isset($limit) ? $limit : 10; |
|||
$offset = isset($offset) ? $offset : 0; |
|||
|
|||
$model = new UserRecharge; |
|||
|
|||
if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
|
|||
|
|||
$model = $model->where($where); |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get(); |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($where) |
|||
{ |
|||
return self::where($where)->first(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return $id; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data) === false) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove($id) |
|||
{ |
|||
if (!self::whereIn('id', explode(',', $id))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
<div class="flool tpnavf cl"> |
|||
<div class="nav_list"> |
|||
<ul> |
|||
<a href="<?php echo route('weixin'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/home_icon.png"><p>首页</p></li></a> |
|||
<a href="<?php echo route('weixin_category'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/brand_icon.png"><p>分类</p></li></a> |
|||
<a href="<?php echo route('weixin_cart'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/car_icon.png"><p>购物车</p></li></a> |
|||
<a href="<?php echo route('weixin_user'); ?>"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/center_icon.png"><p>个人中心</p></li></a></ul> |
|||
<div class="cl"></div> |
|||
</div> |
|||
</div> |
@ -0,0 +1,89 @@ |
|||
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/> |
|||
<title>充值</title><meta name="keywords" content="关键词"><meta name="description" content="描述"><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet"> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script> |
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script> |
|||
<link href="<?php echo env('APP_URL'); ?>/css/font-awesome.min.css" type="text/css" rel="stylesheet"></head><body> |
|||
<div class="classreturn loginsignup"> |
|||
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div> |
|||
<div class="ds-in-bl tit center"><span>充值</span></div> |
|||
</div> |
|||
|
|||
<style> |
|||
.account{text-align:center;margin-top:30px;} |
|||
.account .icon{color:#FFCC00;font-size:100px;}
|
|||
.account .money{color:#353535;font-size:36px;}
|
|||
.account .tit{color:#000;font-size:18px;}
|
|||
.bottoma{display:block;font-size:18px;padding:10px;border-radius:2px;} |
|||
</style> |
|||
<div class="floor account"> |
|||
<div class="icon"><i class="fa fa-google-wallet"></i></div><br> |
|||
<div class="tit"><b style="color:#f23030;">1、填写金额</b> > 2、确认并支付 > 3、完成</div> |
|||
<br> |
|||
<div style="margin:10px;"><input name="money" min="10" max="10000" type="text" id="money" placeholder="充值金额(元)、整数" style="width:100%;text-align:center;border:1px solid #bfbfbf;color:#999;box-sizing:border-box;" class="bottoma"></div> |
|||
<a style="margin:0 10px 10px 10px;background-color:#1aad19;text-align:center;color:#fff;border:1px solid #179e16;" class="bottoma" href="javascript:chongzhi();">开始充值</a> |
|||
<!-- <p style="margin:0 10px 10px 10px;">支付金额:<span style="color:#f23030;">¥ 99.80</span> |
|||
实际到账:¥ 100.00</p> --> |
|||
</div> |
|||
|
|||
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script> |
|||
<script> |
|||
function chongzhi() |
|||
{ |
|||
var money = $('#money').val(); |
|||
var re = /^[0-9]+$/; //判断字符串是否为数字
|
|||
|
|||
if(money == '') |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: '请输入充值金额' |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
if(!re.test(money)) |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: '金额格式不正确' |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//询问框
|
|||
layer.open({ |
|||
content: '确定要充值吗?' |
|||
,btn: ['确定', '取消'] |
|||
,yes: function(){ |
|||
var url = '<?php echo env('APP_API_URL')."/user_address_delete"; ?>'; |
|||
$.post(url,{access_token:'<?php echo $_SESSION['weixin_user_info']['access_token']; ?>',id:id},function(res) |
|||
{ |
|||
//提示
|
|||
layer.open({ |
|||
content: res.msg |
|||
,skin: 'msg' |
|||
,time: 2 //2秒后自动关闭
|
|||
}); |
|||
|
|||
if(res.code==0) |
|||
{ |
|||
location.reload(); |
|||
} |
|||
else |
|||
{ |
|||
|
|||
} |
|||
},'json'); |
|||
} |
|||
}); |
|||
} |
|||
</script> |
|||
@include('weixin.common.footer') |
|||
</body></html> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue