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

4

@@ -13,6 +13,7 @@ use app\portal\model\AddressModel; @@ -13,6 +13,7 @@ use app\portal\model\AddressModel;
13 use app\portal\model\IndentGoodsModel; 13 use app\portal\model\IndentGoodsModel;
14 use app\portal\model\IndentModel; 14 use app\portal\model\IndentModel;
15 use cmf\controller\WeChatBaseController; 15 use cmf\controller\WeChatBaseController;
  16 +use think\Db;
16 17
17 class OrderController extends WeChatBaseController 18 class OrderController extends WeChatBaseController
18 { 19 {
@@ -112,4 +113,105 @@ class OrderController extends WeChatBaseController @@ -112,4 +113,105 @@ class OrderController extends WeChatBaseController
112 } 113 }
113 $this->success('SUCCESS','',$data); 114 $this->success('SUCCESS','',$data);
114 } 115 }
  116 +
  117 + /**
  118 + * 判断用户去支付是否为上级业务员所卖书籍
  119 + */
  120 + public function is_my_salesman(){
  121 +
  122 + $uid = cmf_get_current_user_id();
  123 + $indent_id = $_POST['indent_id'];
  124 + //获取这条订单
  125 + $indent = Db::name('indent') -> where('id',$indent_id) -> find();
  126 + //如果这条订单为平台订单
  127 + if($indent['indent_type'] == 1){
  128 + //获取这条订单下的所有商品
  129 + $pingtai_goods = Db::name('indent_goods') -> where('indent_id',$indent_id) -> select();
  130 + //循环判断商品是否存在是否下架
  131 + foreach ($pingtai_goods as $key => $val){
  132 + $pt_goods = Db::name('goods') -> where('id',$val['goods_id']) -> find();
  133 + //判断商品是否存在
  134 + if(empty($pt_goods)){
  135 + return false;
  136 + }
  137 + //判断商品是否下架
  138 + if($pt_goods['is_out'] == 0){
  139 + return false;
  140 + }
  141 + }
  142 + return true;
  143 + }
  144 +
  145 + //获取当前用户身份
  146 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find();
  147 + //判断用户身份 获取上级业务员
  148 + if($my_user['status'] == 3){
  149 + //当为老师时
  150 + $salesman = Db::name('my_user') -> where('id',$my_user['pid']) -> find();
  151 + if(empty($salesman)){
  152 + return false;
  153 + }
  154 + }
  155 + if($my_user['status'] == 4){
  156 + //当为学生时
  157 + $teacher = Db::name('my_user') -> where('id',$my_user['pid']) -> find();
  158 + if(empty($teacher)){
  159 + return false;
  160 + }
  161 + $salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
  162 + }
  163 +
  164 + //获取订单下的商品
  165 + $indent_goods = Db::name('indent_goods') -> where('indent_id',$indent_id) -> select();
  166 + foreach ($indent_goods as $key => $val){
  167 + $goods = Db::name('goods') -> where('id',$val['goods_id']) -> find();
  168 + //判断商品是否存在
  169 + if(empty($goods)){
  170 + return false;
  171 + }
  172 + //判断商品是否下架
  173 + if($goods['is_out'] == 0){
  174 + return false;
  175 + }
  176 + if($salesman['uid'] != $goods['uid']){
  177 + return false;
  178 + }
  179 +
  180 + }
  181 + return true;
  182 +
  183 + }
  184 +
  185 +
  186 +
  187 +
  188 +
  189 +
  190 +
  191 +
  192 +
  193 +
  194 +
  195 +
  196 +
  197 +
  198 +
  199 +
  200 +
  201 +
  202 +
  203 +
  204 +
  205 +
  206 +
  207 +
  208 +
  209 +
  210 +
  211 +
  212 +
  213 +
  214 +
  215 +
  216 +
115 } 217 }
@@ -86,9 +86,9 @@ @@ -86,9 +86,9 @@
86 <div class="myorder_bottom2"> 86 <div class="myorder_bottom2">
87 <if condition="$vo.state eq 4"> 87 <if condition="$vo.state eq 4">
88 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> 88 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div>
89 - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">  
90 - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div>  
91 - </a> 89 + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">-->
  90 + <div class="myorder_bottom2_2" data-id="{$vo.id}" onclick="is_my_salesman({$vo.id})">去支付</div>
  91 + <!--</a>-->
92 <elseif condition="$vo.state eq 2"/> 92 <elseif condition="$vo.state eq 2"/>
93 <!--<a href="w_Ypayment.html">--> 93 <!--<a href="w_Ypayment.html">-->
94 <!--<div class="myorder_bottom2_2">查看订单</div>--> 94 <!--<div class="myorder_bottom2_2">查看订单</div>-->
@@ -162,9 +162,9 @@ @@ -162,9 +162,9 @@
162 <div class="myorder_bottom2"> 162 <div class="myorder_bottom2">
163 <if condition="$vo.state eq 4"> 163 <if condition="$vo.state eq 4">
164 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> 164 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div>
165 - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">  
166 - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div>  
167 - </a> 165 + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">-->
  166 + <div class="myorder_bottom2_2" data-id="{$vo.id}" onclick="is_my_salesman({$vo.id})">去支付</div>
  167 + <!--</a>-->
168 <elseif condition="$vo.state eq 2"/> 168 <elseif condition="$vo.state eq 2"/>
169 <!--<a href="w_Ypayment.html">--> 169 <!--<a href="w_Ypayment.html">-->
170 <!--<div class="myorder_bottom2_2">查看订单</div>--> 170 <!--<div class="myorder_bottom2_2">查看订单</div>-->
@@ -317,9 +317,9 @@ @@ -317,9 +317,9 @@
317 <div class="myorder_bottom2"> 317 <div class="myorder_bottom2">
318 <if condition="$vo.state eq 4"> 318 <if condition="$vo.state eq 4">
319 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> 319 <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div>
320 - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">  
321 - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div>  
322 - </a> 320 + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">-->
  321 + <div class="myorder_bottom2_2" data-id="{$vo.id}" >去支付</div>
  322 + <!--</a>-->
323 <elseif condition="$vo.state eq 2"/> 323 <elseif condition="$vo.state eq 2"/>
324 <!--<a href="w_Ypayment.html">--> 324 <!--<a href="w_Ypayment.html">-->
325 <!--<div class="myorder_bottom2_2">查看订单</div>--> 325 <!--<div class="myorder_bottom2_2">查看订单</div>-->
@@ -421,6 +421,22 @@ @@ -421,6 +421,22 @@
421 <script src="__TMPL__/public/assets/js/base.js"></script> 421 <script src="__TMPL__/public/assets/js/base.js"></script>
422 <script src="__TMPL__/public/assets/js/jquery.js"></script> 422 <script src="__TMPL__/public/assets/js/jquery.js"></script>
423 <script> 423 <script>
  424 + /**
  425 + *去支付之前判断物品是否为上级业务员的所卖的书
  426 + */
  427 + function is_my_salesman(id){
  428 +
  429 + $.post("{:url('Order/is_my_salesman')}",{indent_id:id},function(data){
  430 + if(data){
  431 + window.location.href = "{:url('portal/pay/index')}?id="+id;
  432 + }else{
  433 + alert('不再此区域销售');
  434 + }
  435 + });
  436 +
  437 + }
  438 +</script>
  439 +<script>
424 function load() { 440 function load() {
425 var index = $(".myor_title ul li").index($('.myor_title_active')); 441 var index = $(".myor_title ul li").index($('.myor_title_active'));
426 $(".myorder_con1").eq(index).show().siblings().hide(); 442 $(".myorder_con1").eq(index).show().siblings().hide();