where(['userid'=>$this->auth->id])->order('isdefault desc')->find(); if(empty($address)) { $address=[]; } }else{ #地址 $address=db('user_address')->where(['id'=>$addressid])->order('isdefault desc')->find(); if(empty($address)) { $address=[]; } } #商品 $goods=db('goods_cart')->where(['userid'=>$this->auth->id,'isselected'=>1])->select(); if(empty($goods)) { return $this->fetch('emptysubmit'); } $proids=db('goods_cart')->where(['userid'=>$this->auth->id,'isselected'=>1])->column('goodsid'); $goodsmoney=db('goods_cart')->where(['userid'=>$this->auth->id,'isselected'=>1])->sum('price'); $delivery=db('goods')->where(['id'=>['in',$proids]])->sum('delivery'); $this->view->assign([ 'goods'=>$goods, 'address'=>$address, 'delivery'=>$delivery, 'total'=>$delivery+$goodsmoney, ]); return $this->fetch(); } function addresslist() { $type=input('type'); if(empty($type)) { $type=0; } $this->view->assign("type",$type); $list=db('user_address')->where(['userid'=>$this->auth->id])->select(); $this->view->assign("list",$list); return $this->fetch(); } function addressadd() { $type=input('type'); if(empty($type)) { $type=0; } $this->view->assign("type",$type); return $this->fetch(); } function addressedit() { $id=input('id'); $type=input('type'); if(empty($type)) { $type=0; } $this->view->assign("type",$type); $info=db('user_address')->where(['id'=>$id])->find(); $this->view->assign("info",$info); return $this->fetch(); } function orddetailed() { $orderid=input('orderid'); $orderinfo=db('order')->where(['id'=>$orderid])->find(); if($orderinfo['orderStatus'] == 1) { if($orderinfo['isrefund'] == 1) { $orderinfo['status']='退款中'; }else{ $orderinfo['status']='待发货'; } }else{ $orderinfo['status']=config('orderStatus')[$orderinfo['orderStatus']]; } $this->view->assign("info",$orderinfo); $ordGoods=db('order_goods')->where(['orderid'=>$orderid])->select(); $this->view->assign("ordGoods",$ordGoods); return $this->fetch(); } function pay() { $goodsid=input('goodsid'); $goodsinfo=db('goods')->where(['id'=>$goodsid])->find(); $trade=db('trade')->where(['status'=>4,'goodsid'=>$goodsid])->order('id desc')->find(); if($trade) { $goodsinfo['price']=$trade['nums']*(1+$goodsinfo['radio']*0.01); } $feeconfig=db('bonus_config')->where(['config_type'=>3])->find(); $pingtaibi=db('bonus_config')->where(['config_type'=>5,'user_level'=>$goodsinfo['catid']])->find(); $total=$pingtaibi['value']+$feeconfig['value']*0.01* $goodsinfo['price']; $suser=get_user_data($goodsinfo['userid']); $this->view->assign([ "goods"=>$goodsinfo, 'selluser'=>$suser, 'totalfee'=>$total ]); return $this->fetch('index'); } function topay() { $orderid=input('orderid'); $orderinfo=db('order')->where(['id'=>$orderid,'orderStatus' => -2])->find(); if(empty($orderinfo)) { $this->error('订单不存在或状态已改变'); } $type=input('type'); if($type != 1 && $type != 2) { $this->error('支付类型有误'); } if($type == 1) { $payType=11; }else{ $payType=21; } $merchant=config('site')['merchant']; if(empty($merchant)) { $this->error('请前往后台设置商户号'); } $key=config('site')['paykey']; if(empty($key)) { $this->error('请前往后台设置支付密钥'); } $data = [ "orderAmount"=>$orderinfo['needPay'], //金额 "orderId"=>$orderinfo['orderNo'],//订单号 "merchant"=>$merchant, //商户号 'method'=>$type, "type"=>$payType, "out"=>"no", ]; ksort($data);//函数对关联数组按照键名进行升序排序。 $postString = http_build_query($data);//返回一个 URL 编码后的字符串。 $signMyself = strtoupper(md5($postString.$key)); $data["sign"] = $signMyself; $data['createTime'] = time(); $data['returnUrl'] = 'http://' . $_SERVER['HTTP_HOST'] .'/shop/order/orderlist'; $data['notifyUrl'] = 'http://' . $_SERVER['HTTP_HOST'] .'/api/shop/notify'; $postString = http_build_query($data); $url="http://47.104.25.167/index.php/Api/Index/index?".$postString; header('Location:'.$url); } /* 退款 */ function refund() { $orderid=input('orderid'); $this->view->assign("orderid",$orderid); return $this->fetch(); } function appraise() { $orderid=input('orderid'); $ordGoods=db('order_goods')->where(['orderid'=>$orderid])->select(); $this->view->assign("ordGoods",$ordGoods); return $this->fetch(); } /* 订单列表 */ function orderlist() { return $this->fetch(); } function orderlist1() { return $this->fetch(); } function orderlist2() { return $this->fetch(); } function orderlist3() { return $this->fetch(); } function orderlist4() { return $this->fetch(); } }