Example #1
0
 /**
  * 商品选择
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function lists($id)
 {
     if ($id) {
         $products = PhoneSku::where(['product_id' => $id])->get();
         if (count($products)) {
             return view('home.product.list')->withProducts($products);
         }
     }
     return redirect()->back();
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id) {
         $skus = PhoneSku::where('product_id', '=', $id)->get();
         if ($skus) {
             foreach ($skus as $sku) {
                 $sku->delete();
             }
         }
         $product = PhoneProduct::find($id);
         $product->delete();
     }
     return redirect()->back();
 }
 /**
  * 删除商品SKU
  *
  * @param $pid
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($pid, $id)
 {
     if ($pid and $id) {
         $sku = PhoneSku::find($id);
         $sku->delete();
     }
     return redirect()->back();
 }
Example #4
0
 public function couponUsed()
 {
     $data = [];
     $data['msg'] = '亲~服务器繁忙,现金卷使用失败~请稍后再试。';
     $data['code'] = 404;
     $skuId = Input::get('product_id', 0);
     $couponId = Input::get('coupon_id', 0);
     if ($skuId and $couponId) {
         $sku = PhoneSku::find($skuId);
         $coupon = AdminCoupon::find($couponId);
         if ($sku and $coupon) {
             $couponPrice = floatval($coupon->coupon_price);
             $skuPrice = floatval($sku->price);
             $data['code'] = 200;
             $data['msg'] = "亲~恭喜您,商品总价已经为您减免¥{$couponPrice}元";
             $data['ret'] = [];
             $data['ret']['couponPrice'] = $couponPrice;
             if ($skuPrice > $couponPrice) {
                 $data['ret']['skuPrice'] = $skuPrice - $couponPrice;
             } else {
                 $data['ret']['skuPrice'] = 0;
             }
         }
     }
     $this->response($data);
 }