作者 王晓刚
1 个管道 的构建 通过 耗费 4 秒

跳了好多东西

@@ -87,4 +87,29 @@ class OrderController extends WeChatBaseController @@ -87,4 +87,29 @@ class OrderController extends WeChatBaseController
87 } 87 }
88 $this->success('SUCCESS'); 88 $this->success('SUCCESS');
89 } 89 }
  90 + public function delivery(){
  91 + $id = $this->request->param('indent_id',0,'intval');
  92 + if(empty($id)){
  93 + $this->error('缺少必要参数');
  94 + }
  95 + $where1['id'] = ['eq',$id];
  96 + $indentModel = new IndentModel();
  97 + $data = $indentModel->findData($where1);
  98 + if(empty($data)){
  99 + $this->error('缺少必要参数','','','');
  100 + }
  101 + $where2['indent_id'] = ['eq',$data['id']];
  102 + $indentGoodsModel = new IndentGoodsModel();
  103 + $indentGoods = $indentGoodsModel->selectData($where2);
  104 + $data['indent_goods'] = $indentGoods;
  105 + $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
  106 + if($data['state'] != 5){
  107 + $this->error('订单不是待收货状态','','','');
  108 + }
  109 + $result = $indentModel->updateData($where1,['state'=>3]);
  110 + if(empty($result)){
  111 + $this->error('sql执行失败','','','');
  112 + }
  113 + $this->success('SUCCESS','',$data);
  114 + }
90 } 115 }
@@ -168,7 +168,7 @@ class OrderSalesmanController extends WeChatBaseController @@ -168,7 +168,7 @@ class OrderSalesmanController extends WeChatBaseController
168 $this->error('缺少必参数','','',''); 168 $this->error('缺少必参数','','','');
169 } 169 }
170 $indentModel = new IndentModel(); 170 $indentModel = new IndentModel();
171 - $indent = $indentModel->findData(['id'=>$id]); 171 + $indent = $indentModel->findData(['id'=>$id])->toArray();
172 if(empty($indent)){ 172 if(empty($indent)){
173 $this->error('查询为空'); 173 $this->error('查询为空');
174 } 174 }
@@ -176,7 +176,7 @@ class OrderSalesmanController extends WeChatBaseController @@ -176,7 +176,7 @@ class OrderSalesmanController extends WeChatBaseController
176 $indent_goods = $indentGoodsModel->selectData(['indent_id'=>$indent['id']]); 176 $indent_goods = $indentGoodsModel->selectData(['indent_id'=>$indent['id']]);
177 if(!empty($indent['indent_address'])){ 177 if(!empty($indent['indent_address'])){
178 $addressModel = new AddressModel(); 178 $addressModel = new AddressModel();
179 - $indent_address = $addressModel->findData(['id'=>$indent['indent_address']]); 179 + $indent_address = $addressModel->findData(['id'=>$indent['indent_address']])->toArray();
180 $indent['indent_address'] = $indent_address; 180 $indent['indent_address'] = $indent_address;
181 } 181 }
182 $indent['indent_goods'] = $indent_goods; 182 $indent['indent_goods'] = $indent_goods;
@@ -97,6 +97,7 @@ @@ -97,6 +97,7 @@
97 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}"> 97 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}">
98 <div class="myorder_bottom2_2">查看物流</div> 98 <div class="myorder_bottom2_2">查看物流</div>
99 </a> 99 </a>
  100 + <div class="myorder_bottom2_2 delivery" data-id="{$vo.id}">确认收货</div>
100 <elseif condition="$vo.state eq 3"/> 101 <elseif condition="$vo.state eq 3"/>
101 <div class="myorder_bottom2_2">去评价</div> 102 <div class="myorder_bottom2_2">去评价</div>
102 </if> 103 </if>
@@ -172,6 +173,7 @@ @@ -172,6 +173,7 @@
172 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}"> 173 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}">
173 <div class="myorder_bottom2_2">查看物流</div> 174 <div class="myorder_bottom2_2">查看物流</div>
174 </a> 175 </a>
  176 + <div class="myorder_bottom2_2 delivery" data-id="{$vo.id}">确认收货</div>
175 <elseif condition="$vo.state eq 3"/> 177 <elseif condition="$vo.state eq 3"/>
176 <div class="myorder_bottom2_2">去评价</div> 178 <div class="myorder_bottom2_2">去评价</div>
177 </if> 179 </if>
@@ -248,8 +250,10 @@ @@ -248,8 +250,10 @@
248 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}"> 250 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}">
249 <div class="myorder_bottom2_2">查看物流</div> 251 <div class="myorder_bottom2_2">查看物流</div>
250 </a> 252 </a>
  253 + <div class="myorder_bottom2_2 delivery" data-id="{$vo.id}">确认收货</div>
  254 + <div class="myorder_bottom2_2 delivery">确认收货</div>
251 <elseif condition="$vo.state eq 3"/> 255 <elseif condition="$vo.state eq 3"/>
252 - <div class="myorder_bottom2_2">去评价</div> 256 + <!--<div class="myorder_bottom2_2">去评价</div>-->
253 </if> 257 </if>
254 </div> 258 </div>
255 </div> 259 </div>
@@ -324,8 +328,9 @@ @@ -324,8 +328,9 @@
324 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}"> 328 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}">
325 <div class="myorder_bottom2_2">查看物流</div> 329 <div class="myorder_bottom2_2">查看物流</div>
326 </a> 330 </a>
  331 + <div class="myorder_bottom2_2 delivery" data-id="{$vo.id}">确认收货</div>
327 <elseif condition="$vo.state eq 3"/> 332 <elseif condition="$vo.state eq 3"/>
328 - <div class="myorder_bottom2_2">去评价</div> 333 + <!--<div class="myorder_bottom2_2">去评价</div>-->
329 </if> 334 </if>
330 </div> 335 </div>
331 </div> 336 </div>
@@ -400,8 +405,10 @@ @@ -400,8 +405,10 @@
400 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}"> 405 <a href="{:url('logistics/index',array('indent_id'=>$vo['id']))}">
401 <div class="myorder_bottom2_2">查看物流</div> 406 <div class="myorder_bottom2_2">查看物流</div>
402 </a> 407 </a>
  408 + <div class="myorder_bottom2_2 delivery" data-id="{$vo.id}">确认收货</div>
  409 + <div class="myorder_bottom2_2 delivery">确认收货</div>
403 <elseif condition="$vo.state eq 3"/> 410 <elseif condition="$vo.state eq 3"/>
404 - <div class="myorder_bottom2_2">去评价</div> 411 + <!--<div class="myorder_bottom2_2">去评价</div>-->
405 </if> 412 </if>
406 </div> 413 </div>
407 </div> 414 </div>
@@ -454,6 +461,76 @@ @@ -454,6 +461,76 @@
454 } 461 }
455 }) 462 })
456 }) 463 })
  464 + $("body").on('click','.delivery',function(){
  465 + var index = $(".myor_title ul li").index($('.myor_title_active'));
  466 + var indent_id = $(this).attr('data-id');
  467 + console.log(indent_id);
  468 + $.ajax({
  469 + url:"{:url('portal/order/delivery')}",
  470 + type:"GET",
  471 + data:{"indent_id":indent_id},
  472 + success:function(res){
  473 + if(res.code == 1){
  474 + var data = res.data;
  475 + var indent_goods = "";
  476 + $(data.indent_goods).each(function(key,vo){
  477 + indent_goods += "<li>\n" +
  478 + " <div class=\"order_newsImg\">\n" +
  479 + " <img src=\""+vo.thumbnail+"\" alt=\"\"/>\n" +
  480 + " </div>\n" +
  481 + " <div class=\"order_newsCon\">\n" +
  482 + " <div class=\"order_newsTxt1 txt-cut\">\n" +
  483 + " "+vo.book_name+"\n" +
  484 + " </div>\n" +
  485 + " <div class=\"order_newsTxt2\">×<span>"+vo.number+"</span></div>\n" +
  486 + " <div class=\"order_newsTxt3\">\n" +
  487 + " <p class=\"de_topTxt1_1\">¥<span>"+vo.price+"</span></p>\n" +
  488 + " <p class=\"de_topTxt1_2\">¥<span>"+vo.pricing+"</span></p>\n" +
  489 + " </div>\n" +
  490 + " </div>\n" +
  491 + " </li>";
  492 + });
  493 + var length = data.indent_goods.length;
  494 + var html = "<div class=\"myorder_information dom_cancel_order_"+data.id+"\" >\n" +
  495 + " <!-- 订单 -->\n" +
  496 + " <a href=\"{:url('order/get_one','',false,true)}/id/"+data.id+"\">\n" +
  497 + " <div class=\"myorder_the\">\n" +
  498 + " <p class=\"order_dan\">订单号:"+data.order_number+"</p>\n" +
  499 + " <div class=\"myorder_state1\">\n" +
  500 + " 已完成\n" +
  501 + " </div>\n" +
  502 + " </div>\n" +
  503 + " <ul class=\"order_newsUl myorder_border\">"+indent_goods+"\n" +
  504 + " <div class=\"my_ordera\">\n" +
  505 + " <span>共"+length+"件商品 合计:</span>\n" +
  506 + " <p>¥"+data.money+"</p>\n" +
  507 + " </div>\n" +
  508 + " </ul>\n" +
  509 + " </a>\n" +
  510 + " <!-- 时间/底部 -->\n" +
  511 + " <div class=\"myorder_bottom\">\n" +
  512 + " <div class=\"myorder_bottom1\">\n" +
  513 + " <div class=\"myorder_bottom1Img\">\n" +
  514 + " <img src=\"__TMPL__/public/assets/images/52.png\" alt=\"\"/>\n" +
  515 + " </div>\n" +
  516 + " <p class=\"myorder_bottom1Txt\">"+data.create_time+"</p>\n" +
  517 + " </div>\n" +
  518 + " <div class=\"myorder_bottom2\">\n" +
  519 + " </div>\n" +
  520 + " </div>\n" +
  521 + " </div>";
  522 + $('.myorder_con1').eq(4).prepend(html);
  523 + $('.myorder_con1').eq(index).find('.dom_cancel_order_' + indent_id).remove();
  524 + alert('收货成功')
  525 + }else{
  526 + alert('出错啦,请稍后再试!')
  527 + }
  528 + },
  529 + error:function(){
  530 + alert('与服务器断开连接')
  531 + }
  532 + })
  533 + })
457 }) 534 })
458 </script> 535 </script>
459 </body> 536 </body>