作者 guosheng
1 个管道 的构建 通过 耗费 5 秒

个人中心我的订单退款、取消、付款流程调试

... ... @@ -9,6 +9,7 @@ use app\admin\model\Vipdesc;
use app\common\controller\Frontend;
use app\index\model\Goodscollect;
use app\index\model\OrderInfo;
use app\index\model\OrderRefund;
use app\index\model\Price;
use app\index\model\Store;
use app\index\model\Storecollect;
... ... @@ -104,6 +105,10 @@ class Member extends Frontend
'4' => '待评价',
'5' => '售后',
'6' => '已完成',
'7' => '已取消',
'8' => '退款中',
'9' => '已退款',
'10' => '已删除',
];
foreach ($list as $k=>$v) {
$order[$k]['store_name'] = $store_model->where('id',$v['store_id'])->value('name');
... ... @@ -157,10 +162,137 @@ class Member extends Frontend
case '8':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
case '9':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
case '10':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
}
return $operate;
}
// 付款
public function topay() {
if($this->request->isAjax()) {
$param = $this->request->param();
$order_detail_model = new \app\index\model\OrderDetail();
$where = [
'id' => $param['order_id']
];
$order = $order_detail_model
->where($where)
->find();
if(!$order) {
$this->error('订单不存在');
}
if($order['status'] != 1) {
$this->error('当前订单状态无法付款');
}
$return = [
'pay_type' => $order['pay_type'],
'order_id'=>$param['order_id'],
'url'=>url("index/order/pay",array('order_id'=>$param['order_id']),false,true)
];
$this->success('SUCCESS','',$return);
}
}
// 取消订单
public function cancel_submit() {
if($this->request->isAjax()) {
$param = $this->request->param();
$order_detail_model = new \app\index\model\OrderDetail();
$where = [
'id' => $param['order_id']
];
$order = $order_detail_model
->where($where)
->find();
if(!$order) {
$this->error('订单不存在');
}
if($order['status'] != 1) {
$this->error('当前订单状态无法取消');
}
// 修改订单状态
$result_order = $order_detail_model->save(['status'=>7],['id'=>$param['order_id']]);
if(!$result_order) {
$this->error('订单取消失败');
}
$this->success('订单取消成功');
}
}
// 退款
public function refund() {
$order_id = $this->request->param('order_id');
$order_detail_model = new \app\index\model\OrderDetail();
$order_info_model = new OrderInfo();
$store_model = new Store();
$where = [
'id' => $order_id
];
$order = $order_detail_model
->where($where)
->find();
$status = [
'1' => '待支付',
'2' => '待发货',
'3' => '待收货',
'4' => '待评价',
'5' => '售后',
'6' => '已完成',
'7' => '已取消',
'8' => '退款中',
'9' => '已退款',
'10' => '已删除',
];
$order['store_name'] = $store_model->where('id',$order['store_id'])->value('name');
$order['goods'] = $order_info_model->where('order_id',$order['id'])->select();
$order['status'] = $status[$order['status']];
$this->view->assign('order',$order);
return $this->view->fetch();
}
// 提交退款申请
public function refund_submit() {
if($this->request->isAjax()) {
$param = $this->request->param();
$order_detail_model = new \app\index\model\OrderDetail();
$where = [
'id' => $param['order_id']
];
$order = $order_detail_model
->where($where)
->find();
if(!$order) {
$this->error('订单不存在');
}
if(!in_array($order['status'],['2','3'])) {
$this->error('当前订单状态无法退款');
}
Db::startTrans();
// 记录退款申请
$order_refund_model = new OrderRefund();
$insert = [
'order_id' => $param['order_id'],
'user_id' => $this->auth->id,
'content' => $param['content'],
'images' => $param['images']
];
$result_refund = $order_refund_model->isUpdate(false)->save($insert);
// 修改订单状态
$result_order = $order_detail_model->save(['status'=>8],['id'=>$param['order_id']]);
if(!$result_refund || !$result_order) {
Db::rollback();
$this->error('退款申请失败');
}
Db::commit();
$this->success('退款申请成功');
}
}
// 我的会员
public function member()
{
... ...
<?php
namespace app\index\model;
use think\Model;
class OrderRefund extends Model
{
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
}
\ No newline at end of file
... ...
... ... @@ -713,6 +713,97 @@
left: 0;
}
</style>
<style>
#payModal{
display: none;
}
.modal-box {
width: 716px;
height: 438px;
top: 25%;
left: 50%;
transform: translateX(-50%);
z-index: 666;
overflow: hidden;
position: fixed;
border: 6px solid #bbb;
background-color: #fff;
-webkit-animation: scale-in both cubic-bezier(.4, 0, 0, 1.5) .3s;
animation: scale-in both cubic-bezier(.4, 0, 0, 1.5) .3s;
}
.modal-left {
float: left;
width: 333px;
padding: 20px 50px 25px 45px;
}
#payModal .modal-qrcode {
width: 210px;
height: 210px;
display: block;
margin: 0 auto 20px;
}
.icon-qrcode {
width: 16px;
height: 16px;
margin-right: 3px;
position: relative;
display: inline-block;
vertical-align: middle;
background-position: 0 -88px;
}
.modal-left .icon {
font-size: 0;
background-image: url(https://mpay.meituan.com/resource/cashier/img/icon-common@2x.rcJBe.png);
background-size: 168px;
}
#payModal .modal-info {
color: #f80;
font-size: 12px;
padding: 13px 0;
text-align: center;
background-color: #f7f7f7;
}
.modal-right {
float: left;
}
#payModal p{
font-size: 18px;
text-align: center;
line-height: 32px;
margin-bottom: 16px;
}
#payModal .orange {
color: #f80;
}
#payModal .modal-qr{
padding-top: 20px;
border: 1px solid #ddd;
}
.icon-clock {
width: 12px;
height: 12px;
margin-right: 5px;
}
.icon-close {
top: 13px;
right: 13px;
width: 13px;
height: 13px;
z-index: 5;
cursor: pointer;
position: absolute;
background-position: -17px -88px;
}
.modal-right .icon {
font-size: 0;
background-image: url(https://mpay.meituan.com/resource/cashier/img/icon-common@2x.rcJBe.png);
background-size: 168px;
}
#payModal .model-right img {
width: 371px;
height: 438px;
}
</style>
</head>
<body>
<!--公共头部-->
... ... @@ -1473,6 +1564,34 @@
</div>
</div>
{include file="public/footer"}
<!--begin:提示弹层-->
<div class="toast">提示框</div>
<div class="bg"></div>
<!--支付窗口-->
<div id="payModal">
<div class="modal-box">
<div class="modal-left">
<p>
<span>请使用 </span>
<span class="orange">微信 </span>
<i class="icon icon-qrcode"></i>
<span class="orange"> 扫一扫</span><br>扫描二维码支付
</p>
<div class="modal-qr">
<img class="modal-qrcode"
src=""
alt="您的浏览器版本太低, 请升级您的浏览器">
<div class="modal-info">
<img class="icon-clock" src="__CDN__/assets/store/images/clock.png">
<span>二维码有效时长为2小时, 请尽快支付</span>
</div>
</div>
</div>
<div class="modal-right"><i class="icon icon-close"></i><img
src="https://mpay.meituan.com/resource/cashier/img/weixin-qrcode.1xf1oN.jpg" alt="微信扫码">
</div>
</div>
</div>
<script>
var status = 0;
var id = 'allOrder';
... ... @@ -1612,7 +1731,39 @@
});
}
//付款
// 付款
$('.order_inform').on('click','.topay',function () {
var order_id = $(this).parent().data('order_id');
var data = {
order_id: order_id
};
$.ajax({
type: "post",
url: "{:url('topay')}",
data: data,
dataType: "json",
success: function (e) {
if(e.code == 1) {
if(e.data.pay_type == 1){
//微信支付
order_id = e.data.order_id;
$('#payModal').show();
$('.modal-left .modal-qrcode').attr('src',e.data.url);
}else if(e.data.pay_type == 2){
//支付宝支付
order_id = e.data.order_id;
window.open(e.data.url);
}
} else {
toast(e.msg);
}
},
error: function (e) {
console.log(e);
toast('网络错误,请重试');
}
});
});
function payment() {
$.message({
message: '此处调用付款方法',
... ... @@ -1626,11 +1777,50 @@
}
//取消订单
function cancelOrder() {
$.message({
message: '此处调用取消订单方法',
type: 'success'
$('.order_inform').on('click','.cancel',function () {
var order_id = $(this).parent().data('order_id');
var data = {
order_id: order_id
};
$.ajax({
type: "post",
url: "{:url('cancel_submit')}",
data: data,
dataType: "json",
success: function (e) {
if(e.code == 1) {
toast(e.msg,1000,1);
} else {
toast(e.msg);
}
},
error: function (e) {
console.log(e);
toast('网络错误,请重试');
}
});
});
// 退款
$('.order_inform').on('click','.refund',function () {
var order_id = $(this).parent().data('order_id');
var base_url = "{:url('refund')}";
var base_arr = base_url.split('.');
var url = base_arr[0] + '/order_id/' + order_id + '.' + base_arr[1];
window.location.href = url;
});
//提示弹层
function toast(msg='玩命加载中~',time=2000, reload = 0){
$('.toast').text(msg);
$('.toast').fadeToggle();
$('.bg').show();
setTimeout(function(){
$('.toast').fadeToggle();
$('.bg').hide();
if(reload == 1) {
location.reload();
}
},time);
}
</script>
</body>
... ...
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>退款</title>
{include file="public/head"}
<style>
li{
list-style-type: none;
}
ul{
margin: 0;
}
.clear{
clear: both;
}
/*菜单样式*/
.content{
width: 100%;
font-size: 0;
background:rgba(249,249,249,1);
}
.content .navBarBox{
width: 100%;
height: 50px;
background: rgba(0,159,142,1);
}
.content .navBarBox ul{
width: 1200px;
height: 100%;
margin: 0 auto;
padding: 0;
font-size: 16px;
font-family: PingFangSC-Semibold;
color:rgba(255,255,255,1);
}
.content .navBarBox ul li{
width: 144px;
height: 100%;
line-height: 50px;
list-style-type: none;
float: left;
}
.content .navBarBox ul li a{
color: rgba(255,255,255,1);
}
.content .titleImgContent{
width: 100%;
height: 146px;
}
.content .titleImgContent img{
width: 100%;
height: 100%;
}
/*主要内容*/
.contentBox{
width: 100%;
background-color: #FFFFFF;
margin-top: 12px;
}
.contentMain{
margin: auto;
width: 1200px;
}
.contentTop{
padding: 20px 0 28px;
}
.titleText{
padding-left: 17px;
height:22px;
line-height:22px;
font-size:16px;
font-family:PingFang SC;
font-weight:800;
color:rgba(0,159,142,1);
vertical-align: middle;
}
.titleLine{
line-height: 20px;
display: inline-block;
width: 6px;
height:20px;
background:rgba(0,159,142,1);
opacity:1;
border-radius:2px;
vertical-align: middle;
}
.contentList{
background:rgba(249,249,249,1);
border-radius:8px;
margin-bottom: 12px;
}
/*商品信息*/
.detailHeader {
padding: 0 30px;
height: 60px;
line-height: 60px;
border-bottom: 1px solid rgba(238,238,238,1);
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(61,68,77,1)
}
.detailHeader li{
float: left;
}
.storeName{
padding-right: 40px;
font-weight:500;
}
.orderNum{
width: 227px;
}
.orderTime{
width: 218px;
}
.orderNumTime{
font-weight:400;
padding: 0 40px;
overflow: hidden;/*超出部分隐藏*/
text-overflow:ellipsis;/* 超出部分显示省略号 */
white-space: nowrap;/*规定段落中的文本不进行换行 */
}
.detailTitle{
font-size:16px;
font-family:PingFang SC;
font-weight:500;
color:rgba(61,68,77,1);
width: 162px;
text-align: center;
vertical-align: middle;
}
.detailContent li{
display: inline-block;
}
.detailContent{
padding: 0 30px;
}
.goodsDesc {
width: 652px;
padding: 24px 24px 24px 0;
}
.goodsPic{
width: 72px;
height: 72px;
}
.goodsName{
margin-left: 15px;
font-weight:500;
color:rgba(91,94,99,1);
vertical-align: middle;
font-size:14px;
font-family:PingFang SC;
display: inline-block;
width: 196px;
}
/*退款原因*/
.refundReason{
height: 183px;
padding: 25px 30px;
}
.refundReasonLabel{
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(61,68,77,1);
}
.refundReasonTextarea{
padding: 6px 0;
border: 0!important;
box-shadow: none!important;
background-color: transparent!important;
resize: none;
}
/*输入框中placeholer文字颜色*/
.refundReasonTextarea::-webkit-input-placeholder { /* WebKit browsers */
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(140,145,152,1)
}
.refundReasonTextarea:-moz-placeholder{ /* Mozilla Firefox 4 to 18 */
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(140,145,152,1)
}
.refundReasonTextarea::-moz-placeholder{ /* Mozilla Firefox 19+ */
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(140,145,152,1)
}
.refundReasonTextarea:-ms-input-placeholder { /* Internet Explorer 10+ */
font-size:14px;
font-family:PingFang SC;
font-weight:500;
color:rgba(140,145,152,1)
}
/*按钮样式*/
.refundBtn{
margin: 28px 0 98px;
background-color:rgba(0,159,142,1);
color: #fff;
width: 170px;
height: 52px;
font-size:16px;
font-family:PingFang SC;
font-weight:500;
color:rgba(255,255,255,1);
border: 0;
}
.refundBtn:hover,.refundBtn:visited,.refundBtn:focus{
color: #fff;
color:rgba(255,255,255,1);
border: 0;
}
</style>
<style>
.box {
display: flex;
}
.imgClick {
width: 150px!important;
height: 96px!important;
font-size: 0;
position: relative;
background: url(/assets/store/images/idCardBoxFileupload.png) no-repeat;
}
.imgClick input {
width: 150px;
height: 96px;
opacity: 0;
position: absolute;
top: 0;
left: 0;
}
.images{
display: flex;
align-items: center;
flex-wrap: wrap;
padding-left:0!important;
padding-right: 0!important;
}
.imagesItem{
width:150px!important;
height:96px!important;
font-size: 0;
display:flex;
align-items: center;
position: relative;
padding: 0 10px 0 0!important;
}
.imagesItem img{
width:100%;
height:100%;
}
.closeImage{
position: absolute;
top: -5px;
right: 5px;
width: 18px!important;
height: 18px!important;
background: rgba(197, 197, 197, 1);
border-radius: 50%;
padding: 0!important;
font-size: 16px;
text-align: center;
line-height: 18px;
color: #efefef;
font-style: normal;
cursor: pointer;
z-index: 777;
}
</style>
</head>
<body>
{include file="public/header"}
<!--主要内容-->
<div class="content">
{include file="public/nav"}
<!--主要内容-->
<div class="contentBox">
<div class="contentMain">
<div class="contentTop">
<span class="titleLine"></span>
<span class="titleText">
退款申请
</span>
</div>
<!--商品信息-->
<div class="contentList">
<ul class="detailHeader">
<li class="storeName">
{$order.store_name}
</li>
<li class="orderNumTime orderNum">
订单号:{$order.num}
</li>
<li class="orderNumTime orderTime">
{$order.createtime}
</li>
<li class="detailTitle">
数量
</li>
<li class="detailTitle">
金额
</li>
<li class="detailTitle">
订单状态
</li>
<div class="clear">
</div>
</ul>
{volist name="order.goods" id="vo"}
<ul class="detailContent">
<li class="goodsDesc">
<img class="goodsPic" src="{$vo.goods_image}" alt="">
<span class="goodsName">{$vo.goodsname}</span>
</li>
<li class="detailTitle">
×{$vo.number}
</li>
<li class="detailTitle">
¥{$vo.goods_price}
</li>
<li class="detailTitle">
{$order.status}
</li>
<div class="clear">
</div>
</ul>
{/volist}
</div>
<!--退款原因-->
<div class="contentList refundReason">
<p class="refundReasonLabel">退款原因</p>
<textarea rows="5" class="form-control refundReasonTextarea" placeholder="请输入退款原因"></textarea>
</div>
<!--上传凭证-->
<div class="contentList">
<div class="detailHeader">
上传凭证
</div>
<div class="detailContent">
<div class="box">
<div class="images"></div>
<div class="imgClick">
<input type="file" name="file" multiple id="refundBox"/>
</div>
</div>
</div>
</div>
<button type="button" class="btn refundBtn">提交申请</button>
</div>
</div>
</div>
{include file="public/footer"}
<!--begin:提示弹层-->
<div class="toast">提示框</div>
<div class="bg"></div>
<script>
var img = [];
//上传手持身份证照片
$('body').on('change', '#refundBox', function () {
var self = $(this);
var filePath = self.val();
var fileFormat = filePath.substring(filePath.lastIndexOf(".")).toLowerCase();
console.log(filePath);
// 检查是否是图片
if (filePath == '') {
toast('未选择任何图片');
return false;
}
if (!fileFormat.match(/.png|.jpg|.jpeg/)) {
toast('上传错误,文件格式必须为:png/jpg/jpeg');
return false;
}
var files = this.files;
upload(files,self);
});
//上传图片
function upload(files,self){
$(files).each(function (key, file) {
console.log(file);
var formdata = new FormData();
formdata.append("file", file);
$.ajax({
url: "{:url('api/common/upload')}",
type: "POST",
data: formdata,
cache: false,
processData: false, // 不处理发送的数据,因为data值是Formdata对象,不需要对数据做处理
contentType: false, // 不设置Content-type请求头
success: function (res) {
console.log(res);
if (res.code == 1) {
var html = '<div class="imagesItem">\n' +
' <img src="'+res.data.url+'" alt="">\n' +
' <div class="closeImage">×</div>\n' +
' </div>';
img.push(res.data.url);
self.parent().prev().append(html);
// idCardImgFileArr.push(res.data.url);
}
},
error: function(res){
toast('与服务器断开连接');
}
});
});
}
//删除图片
$('.images').on('click', '.closeImage', function () {
$(this).parent().remove();
var src = $(this).prev().attr('src');
var pos = $.inArray(src,img);
img.splice(pos,1);
console.log(img);
});
// 提交退款申请
$('.refundBtn').click(function () {
var content = $('.refundReasonTextarea').val();
var images = img.join(',');
if(content.length == 0) {
toast('请填写退款原因');
}
if(img.length == 0) {
toast('请上传凭证');
}
var data = {
order_id: "{$order.id}",
content: content,
images: images
};
$.ajax({
type: "post",
url: "{:url('refund_submit')}",
data: data,
dataType: "json",
success: function (e) {
if(e.code == 1) {
toast(e.msg);
} else {
toast(e.msg);
}
},
error: function (e) {
console.log(e);
toast('网络错误,请重试');
}
});
});
//提示弹层
function toast(msg='玩命加载中~',time=2000, location = 0){
$('.toast').text(msg);
$('.toast').fadeToggle();
$('.bg').show();
setTimeout(function(){
$('.toast').fadeToggle();
$('.bg').hide();
if(location == 1) {
history.back(-1);
}
},time);
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -698,15 +698,6 @@
支付宝
</div>
</li>
<li onclick="changePayMode(this,'yunPay')">
<div class="imgBox">
<img class="checkImg" src="__CDN__/assets/store/images/radioUnSelect.png" alt="img">
</div>
<div class="contentBox">
<img src="__CDN__/assets/store/images/yunshanfu.png" alt="img">
云闪付
</div>
</li>
</ul>
</div>
... ...