diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php new file mode 100644 index 0000000..6d47142 --- /dev/null +++ b/app/Http/Controllers/Api/OrderController.php @@ -0,0 +1,66 @@ +input('goods_number',''); + $data['goods_id'] = $request->input('goods_id',''); + + if($request->input('goods_attr', '') != ''){$data['goods_attr'] = $request->input('goods_attr');} + if($request->input('shop_id', '') != ''){$data['shop_id'] = $request->input('shop_id');} + $data['add_time'] = time(); + $data['user_id'] = Token::$uid; + + if($data['goods_number']=='' || $data['goods_id']=='') + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + return Order::cartAdd($data); + } + + //删除订单 + public function cartDelete(Request $request) + { + $id = $request->input('id',''); + + if($id=='') + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + $res = Cart::remove($id,Token::$uid); + if($res === true) + { + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/CartController.php b/app/Http/Controllers/Weixin/CartController.php index 11264c9..3c9f794 100644 --- a/app/Http/Controllers/Weixin/CartController.php +++ b/app/Http/Controllers/Weixin/CartController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Weixin; use App\Http\Controllers\Weixin\CommonController; use Illuminate\Http\Request; +use App\Common\ReturnData; class CartController extends CommonController { @@ -94,8 +95,53 @@ class CartController extends CommonController ); $url = env('APP_API_URL')."/user_available_bonus_list"; $res = curl_request($url,$postdata,'GET'); - $data['bonus_list'] = $res['data']; + $data['bonus_list'] = $res['data']['list']; return view('weixin.cart.cartCheckout', $data); } + + //生成订单 + public function cartDone(Request $request) + { + $cartids = $request->input('cartids',''); //购物车商品id,8_9 + $default_address_id = $request->input('default_address_id',''); //收货地址id + $payid = $request->input('payid',''); //支付方式:1余额支付,2微信,3支付宝 + $user_bonus_id = $request->input('user_bonus_id',0); //优惠券id,0没有优惠券 + $shipping_costs = $request->input('shipping_costs',''); //运费 + $message = $request->input('message',''); //买家留言 + + if($default_address_id==''){$this->error_jump('请选择收货地址');} + if($payid==''){$this->error_jump('请选择支付方式');} + if($cartids==''){$this->error_jump(ReturnData::PARAMS_ERROR);} + + //订单提交 + $postdata = array( + 'cartids' => $cartids, + 'default_address_id' => $default_address_id, + 'payid' => $payid, + 'user_bonus_id' => $user_bonus_id, + 'shipping_costs' => $shipping_costs, + 'message' => $message, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/order_add"; + $res = curl_request($url,$postdata,'POST'); + + if($res['code'] == ReturnData::SUCCESS) + { + /* $url = U('Order/orderlist'); + header("Location: $url"); + exit(); */ + } + else + { + $ReturnMsg = '生成订单失败'; + if($res['msg']) + { + $ReturnMsg = $res['msg']; + } + + $this->error_jump($ReturnMsg); + } + } } \ No newline at end of file diff --git a/app/Http/Model/UserBonus.php b/app/Http/Model/UserBonus.php index f77abfd..31a1f24 100644 --- a/app/Http/Model/UserBonus.php +++ b/app/Http/Model/UserBonus.php @@ -110,7 +110,7 @@ class UserBonus extends BaseModel if(isset($status)){$where['bonus.status'] = 0;} $model = new UserBonus; - if(isset($min_amount)){$model = $model->where('bonus.min_amount', '<=', $min_amount);} //满多少使用 + if(isset($min_amount)){$model = $model->where('bonus.min_amount', '<=', $min_amount)->where('bonus.money', '<=', $min_amount);} //满多少使用 if(isset($bonus_end_time)){$model = $model->where('bonus.end_time', '>=', date('Y-m-d H:i:s'));} //有效期 $bonus_list = $model->join('bonus', 'bonus.id', '=', 'user_bonus.bonus_id')->where($where) diff --git a/resources/views/weixin/cart/cartCheckout.blade.php b/resources/views/weixin/cart/cartCheckout.blade.php index 423eea4..2a70a34 100644 --- a/resources/views/weixin/cart/cartCheckout.blade.php +++ b/resources/views/weixin/cart/cartCheckout.blade.php @@ -64,7 +64,7 @@ function selectaddress()
共件商品
-运费:¥0
-满¥15.00减¥1.00
-商品总价:¥
-应付款金额:¥99
+ + + +应付款金额:¥