diff --git a/app/portal/controller/OrderController.php b/app/portal/controller/OrderController.php index 0992371..4798ba8 100644 --- a/app/portal/controller/OrderController.php +++ b/app/portal/controller/OrderController.php @@ -13,6 +13,7 @@ use app\portal\model\AddressModel; use app\portal\model\IndentGoodsModel; use app\portal\model\IndentModel; use cmf\controller\WeChatBaseController; +use think\Db; class OrderController extends WeChatBaseController { @@ -112,4 +113,105 @@ class OrderController extends WeChatBaseController } $this->success('SUCCESS','',$data); } + + /** + * 判断用户去支付是否为上级业务员所卖书籍 + */ + public function is_my_salesman(){ + + $uid = cmf_get_current_user_id(); + $indent_id = $_POST['indent_id']; + //获取这条订单 + $indent = Db::name('indent') -> where('id',$indent_id) -> find(); + //如果这条订单为平台订单 + if($indent['indent_type'] == 1){ + //获取这条订单下的所有商品 + $pingtai_goods = Db::name('indent_goods') -> where('indent_id',$indent_id) -> select(); + //循环判断商品是否存在是否下架 + foreach ($pingtai_goods as $key => $val){ + $pt_goods = Db::name('goods') -> where('id',$val['goods_id']) -> find(); + //判断商品是否存在 + if(empty($pt_goods)){ + return false; + } + //判断商品是否下架 + if($pt_goods['is_out'] == 0){ + return false; + } + } + return true; + } + + //获取当前用户身份 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find(); + //判断用户身份 获取上级业务员 + if($my_user['status'] == 3){ + //当为老师时 + $salesman = Db::name('my_user') -> where('id',$my_user['pid']) -> find(); + if(empty($salesman)){ + return false; + } + } + if($my_user['status'] == 4){ + //当为学生时 + $teacher = Db::name('my_user') -> where('id',$my_user['pid']) -> find(); + if(empty($teacher)){ + return false; + } + $salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find(); + } + + //获取订单下的商品 + $indent_goods = Db::name('indent_goods') -> where('indent_id',$indent_id) -> select(); + foreach ($indent_goods as $key => $val){ + $goods = Db::name('goods') -> where('id',$val['goods_id']) -> find(); + //判断商品是否存在 + if(empty($goods)){ + return false; + } + //判断商品是否下架 + if($goods['is_out'] == 0){ + return false; + } + if($salesman['uid'] != $goods['uid']){ + return false; + } + + } + return true; + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } \ No newline at end of file diff --git a/public/themes/simpleboot3/portal/order/get_all.html b/public/themes/simpleboot3/portal/order/get_all.html index 9b9bafd..2ebdbf3 100755 --- a/public/themes/simpleboot3/portal/order/get_all.html +++ b/public/themes/simpleboot3/portal/order/get_all.html @@ -86,9 +86,9 @@ <div class="myorder_bottom2"> <if condition="$vo.state eq 4"> <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}"> - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div> - </a> + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">--> + <div class="myorder_bottom2_2" data-id="{$vo.id}" onclick="is_my_salesman({$vo.id})">去支付</div> + <!--</a>--> <elseif condition="$vo.state eq 2"/> <!--<a href="w_Ypayment.html">--> <!--<div class="myorder_bottom2_2">查看订单</div>--> @@ -162,9 +162,9 @@ <div class="myorder_bottom2"> <if condition="$vo.state eq 4"> <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}"> - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div> - </a> + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">--> + <div class="myorder_bottom2_2" data-id="{$vo.id}" onclick="is_my_salesman({$vo.id})">去支付</div> + <!--</a>--> <elseif condition="$vo.state eq 2"/> <!--<a href="w_Ypayment.html">--> <!--<div class="myorder_bottom2_2">查看订单</div>--> @@ -317,9 +317,9 @@ <div class="myorder_bottom2"> <if condition="$vo.state eq 4"> <div class="myorder_bottom2_1 cancel_order" data-id="{$vo.id}">取消订单</div> - <a href="{:url('portal/pay/index',array('id'=>$vo['id']))}"> - <div class="myorder_bottom2_2" data-id="{$vo.id}">去支付</div> - </a> + <!--<a href="{:url('portal/pay/index',array('id'=>$vo['id']))}">--> + <div class="myorder_bottom2_2" data-id="{$vo.id}" >去支付</div> + <!--</a>--> <elseif condition="$vo.state eq 2"/> <!--<a href="w_Ypayment.html">--> <!--<div class="myorder_bottom2_2">查看订单</div>--> @@ -421,6 +421,22 @@ <script src="__TMPL__/public/assets/js/base.js"></script> <script src="__TMPL__/public/assets/js/jquery.js"></script> <script> + /** + *去支付之前判断物品是否为上级业务员的所卖的书 + */ + function is_my_salesman(id){ + + $.post("{:url('Order/is_my_salesman')}",{indent_id:id},function(data){ + if(data){ + window.location.href = "{:url('portal/pay/index')}?id="+id; + }else{ + alert('不再此区域销售'); + } + }); + + } +</script> +<script> function load() { var index = $(".myor_title ul li").index($('.myor_title_active')); $(".myorder_con1").eq(index).show().siblings().hide();