try{
if($shopid && !in_array($shopid, $shopIds)){
throw new \Exception('非法操作');
}
$info = M('logistics_returns')->where(['did' => $did,'shop_id' => $shopid,'storage_status' => 'undeal'])->find();
if (empty($info)){
throw new \Exception('未查询到此运单');
}
M()->startTrans();
$res = M('logistics_returns')->delete($did);
$res1 = M('deliver')->where(['Did' => $did,'apply_return' => 1])->save(['apply_return' => 0]);
if ($res1 && $res){
M()->commit();
ajax_return($did,'取消申请成功',1);
}else{
throw new \Exception("取消申请失败");
}
}catch (\Exception $e) {
M()->rollback();
ajax_return($did,$e->getMessage(),0);
}
<script>
function cancelIntercept(obj){
var msg = '确定要取消申请吗';
var shopid=$(obj).attr('shopid');
var orderid=$(obj).attr('orderid');
var did=$(obj).attr('did');
if (confirm(msg) == true){
$.ajax({
type: 'GET',
url: '/Admin/SelfDeliveryOrder/cancelIntercept',
cache:false,
data: {orderid:orderid,shopid:shopid,did:did},
dataType: 'json',
success: function (e){
console.log(e);
if (e.error_code == 1) {
alert(e.error_message);
location.replace(location);
} else {
alert(e.error_message);
}
}
});
}else{
return false;
}
}
</script>
<a href="javascript:;" did="<?=$v['did']?>" orderid="<?=$v['orderid']?>" shopid="<?=$v['shop_id']?>" onClick="cancelIntercept(this)">取消申请</a>