public function indexAction() { $queryAdd = I('get.condition'); $data = array(); if (is_numeric($queryAdd)) { $openId = get_openid(); $orderFormModel = new OrderFormModel(); $orderFormModel->setQueryAdd($queryAdd); $orderFormModel->setOpenId($openId); $orderForm = $orderFormModel->getOrderFormInfo(); $num = count($orderForm); if ($num < 1) { $data['content'] = $this->fetch('noForm'); } else { $orderGoods = new OrderGoodsModel(); $orderGoods->setOrderForm($orderForm); $res = $orderGoods->getOrderGoods(); $this->assign('res', $res); $data['content'] = $this->fetch('list'); } $data['state'] = 0; //表示返回的订单信息 } else { $goodsDetailUrl = U('Goods/GoodsDetail/index'); $this->assign('goodsDetailUrl', $goodsDetailUrl); $goodsModel = new GoodsModel(); $goodsModel->setPageSize($this->pageSize); $goodsModel->setName($queryAdd); $num = $goodsModel->likeNameCount(); if ($num == 0) { $data['content'] = 'soory'; } else { if ($num > $this->pageSize) { $this->assign('nextPageNum', 2); $data['page'] = $this->fetch('page'); } $res = $goodsModel->goodsList(); //添加物流方式 $logistic = new LogisticsModel(); $key = 'logistics_mode'; $res = $logistic->getLogisticInfo($res, $key); //添加来源 $source = new SourceModel(); $key = 'source'; $keyRes = 'source'; $res = $source->getInfoById($res, $key, $keyRes); $this->assign('list', $res); $data['content'] = $this->fetch($this->goodsList); } $data['state'] = 1; //表示返回的商品信息 } $jsonData = json_encode($data); echo $jsonData; }
public function chooseAllAction() { $orderForm = new OrderFormModel(); $orderForm->setCustomerId($this->customerId); $resOrderForm = $orderForm->getOrderFormInfo(); $num = count($resOrderForm); if ($num < 1) { $HomeUrl = U('Home/Index/index'); $this->assign('HomeUrl', $HomeUrl); $data = $this->fetch('noForm'); } else { $orderGoods = new OrderGoodsModel(); $orderGoods->setOrderForm($resOrderForm); $res = $orderGoods->getOrderGoods(); $this->assign('res', $res); $data = $this->fetch('list'); } echo $data; }
public function payNowAction() { $openid = get_openid(); $ids = I('get.ids', '', false); $counts = I('get.counts', '', false); $coupon = I("get.coupons", '', false); //字符串转为数组 if ($ids == '') { $ids = array(); } else { $ids = explode("-", $ids); } if ($counts == '') { $counts = array(); } else { $counts = explode("-", $counts); } if ($coupon == '') { $coupon = array(); } else { $coupon = explode("-", $coupon); } //取出商品信息,总计信息 $group = new SubmitController(); $product = $group->dataAccess($ids, $counts); if ($product == false) { return; } $goods = $product[0]; $totalInfo = $product[1]; $countTotal = $totalInfo['totalCount']; //看优惠券数量是否大于商品数量 if (count($coupon) > $countTotal) { //跳转至报错界面 return; } //送入优惠券ID组成的数组,按ID值取出优惠券信息 $couponModel = new CouponModel(); $couponInfo = $couponModel->getInfo($coupon, $openid); //利用foreach,计算优惠券总金额(过期优惠券\已使用优惠券直接抛弃) $couponTotal = 0; foreach ($couponInfo as $key => $value) { /* 优惠券使用为0,未使用为1*/ if ($value['end_time'] > time() && (int) $value['state'] & 1 == 1) { $couponTotal += $value['cover']; } } $totalInfo['totalCoupon'] = $couponTotal; $totalInfo['totalPayable'] -= $couponTotal; $totalInfo['totalPayable'] = $totalInfo['totalPayable'] > 0 ? $totalInfo['totalPayable'] : 1; //接收收货地址信息,通过收货地址,取详细信息 $addressId = I('get.addressId', ''); $address = new CustomerAddressModel(); $address->setId($addressId); $addressInfo = $address->getAddress(); $totalInfo['addressInfo'] = $addressInfo; $totalInfo['buyOpenid'] = $openid; //接收支付类型,类型为0为微信支付,类型为1为其它支付方式 // $payType = I('get.payType','0'); //传入总金额,生成订单支付数据 $orderRelation = new OrderRelationModel(); $orderRelation->setTotalInfo($totalInfo); $payId = $orderRelation->addOrder(); //传入订单信息,生成订单数据,返回订单ID /* * $payid, 支付id * $openid, * $logisticsMode, 物流方式 * $source, 来源 * $payable, 总金额 * $weightTotal, 总重量 * $countTotal,商品总数量 * $address,收货地址 * $telephone, 收货电话 * $name,则货人姓名 * $frontId, 身份证正面ID * $backId, 身份证反面ID * $idNo, 身份证号 * $couponTotal, 优惠总数 * $directTotal, 直销返点总数 * $lineTotal,线销返点总数 * $logisticFee,物流费用 * $maxAmonut,最大优惠金额 * $coupon,使用优惠券信息 */ $orderForm = new OrderFormModel(); $orderForm->setPayid($payId); $orderForm->setOpenid($openid); foreach ($goods as $key => $value) { $orderForm->setLogisticsMode($value['logisticType']['name']); $orderForm->setSource($value['source']['name']); $orderForm->setPayable($value['payable']); $orderForm->setWeight($value['weightTotal']); $orderForm->setCountTotal($value['countTotal']); $orderForm->setDirectFee($value['directTotal']); $orderForm->setLineFee($value['lineTotal']); $orderForm->setLogisticFee($value['logisticFee']); $orderForm->setMaxAmonut($value['maxAmonut']); $orderId = $orderForm->addOrder(); /*生成订单-商品数据**************/ $orderGoods = new OrderGoodsModel(); $orderGoods->addOrderGoods($orderId, $value['goods']); /*添加商品的销量********************/ $goodsM = new GoodsModel(); $goodsM->updateSaled($value['goods']); } /*删除购物车数据******************/ $shoppingCart = new ShoppingCartModel(); $shoppingCart->deleteGoods($openid, $goods); /*将当前使用优惠券做使用处理*/ $couponModel->updateUsed($coupon); /* 判断支付类型,拼接好URL后跳转 1为其它支付方式 0为微信支付 * 注意,在不同模式下,U方法将生成不同的路径,必须按U方法生成的目录设置微信的授权目录 * 否则将导致出现 get_brand_wcpay_request:fail_invalid appid错误( */ // if($payType == 1) // { // $url = U('WxPay/OtherPay/payNow?payid=' . $payId); // } // else // { // $url = U('WxPay/Pay/payNow?payid=' . $payId); // //$url1 = U('WxPay/Pay/payNow') . '?payid=' . $payId; // } $url = U('Pay/Index/index') . '?payid=' . $payId; redirect_url($url); }
public function unPayManageAction() { $orderGoods = new OrderGoodsModel(); $orderForm = new OrderFormModel(); $orderForm->setOpenid($this->open_id); $resOrderForm = $orderForm->getOrderFormInfo(); $orderGoods->setOrderForm($resOrderForm); $res = $orderGoods->getOrderGoods(); $relation = M('order_relation'); $map[buy_openid] = $this->open_id; $map[is_payed] = 0; $map[is_cancel] = 0; $unpayOrder = array(); $unpayOrder = $relation->where($map)->select(); //为payOrder拼接所含订单数据 foreach ($unpayOrder as $key => $value) { $map1[payid] = $value[id]; $form = M('order_form'); $unpayOrder[$key][order_form] = $form->where($map1)->select(); foreach ($unpayOrder[$key][order_form] as $value) { $unpayOrder[$key][count] = $value[total_prices]; } } $this->assign('topay', U('Pay/Index/index') . '?payid='); $this->assign('tocancel', U('noPaytoCancel') . '?id='); $this->assign('list', $unpayOrder); $url = U('orderManageDetails') . '?id='; $this->assign('key', $key); $this->assign('url', $url); $this->assign("YZBody", $this->fetch()); $this->display(YZ_TEMPLATE); }