更新pcb后台

parent 824cf469
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Model\Pcb; namespace App\Model\Pcb;
use League\Flysystem\Exception;
use Request; use Request;
use DB; use DB;
...@@ -43,7 +44,7 @@ class PcbPublicModel ...@@ -43,7 +44,7 @@ class PcbPublicModel
* 插入后台客服审核结果 * 插入后台客服审核结果
*/ */
public function orderShipping($user_id,$data){ public function orderShipping($user_id,$data){
$con = DB::connection('pcb');
$datas = [ $datas = [
'shipping_type'=>1, 'shipping_type'=>1,
'relevance_id'=>$data['order_id'], 'relevance_id'=>$data['order_id'],
...@@ -53,21 +54,34 @@ class PcbPublicModel ...@@ -53,21 +54,34 @@ class PcbPublicModel
'shipping_id'=>$data['shipping_id'], 'shipping_id'=>$data['shipping_id'],
'status'=>1, 'status'=>1,
'update_time'=>time(), 'update_time'=>time(),
'create_time'=>time(),
]; ];
$shippingCon = $con->table("shipping");
$checkHave =$shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->first();
if ($checkHave){ try{
$in = $shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->update($datas); $con = DB::connection('pcb');
}else{ $con->beginTransaction();
$data['create_time'] = time();
//插入物流信息
$shippingCon = $con->table("shipping");
$in = $shippingCon->insert($datas); $in = $shippingCon->insert($datas);
} if (!$in){
if ($in){ throw new Exception("插入发货信息失败");
}
//修改发货时间
$updete = (new PcbOrderModel())->where("order_id",$data['order_id'])->update(['shipping_time'=>time()]);
if (!$updete){
throw new Exception("更新订单发货时间失败");
}
//日志
PcbActionLogModel::log(1,'admin_add_shipping',"后台填写发货信息","",$data['order_id'],$user_id); PcbActionLogModel::log(1,'admin_add_shipping',"后台填写发货信息","",$data['order_id'],$user_id);
return [0,'成功'];
}else{ $con->commit();
return [1001,'失败'];
return [0, '成功'];
}catch (\Exception $e) {
$con->rollBack();
return [10002, '失败'.$e->getMessage()];
} }
} }
......
...@@ -156,6 +156,10 @@ layui.use(['table','form','element','layer', 'laydate'], function() { ...@@ -156,6 +156,10 @@ layui.use(['table','form','element','layer', 'laydate'], function() {
//确定发货 //确定发货
function SendStock() { function SendStock() {
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
$.ajax({ $.ajax({
url:'/api/ApiSendStock', url:'/api/ApiSendStock',
type:'post', type:'post',
...@@ -171,12 +175,19 @@ function SendStock() { ...@@ -171,12 +175,19 @@ function SendStock() {
}else{ }else{
alert_err(res.errmsg) alert_err(res.errmsg)
} }
},
done:function () {
layer.closeAll();
} }
}) })
} }
//转采购 //转采购
function AddPurchase(order_id) { function AddPurchase(order_id) {
alert_confirm("确定填写此订单转采购?",function () { alert_confirm("确定填写此订单转采购?",function () {
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
$.ajax({ $.ajax({
url:'/api/ApiAddPurchase', url:'/api/ApiAddPurchase',
type:'post', type:'post',
...@@ -190,8 +201,11 @@ function AddPurchase(order_id) { ...@@ -190,8 +201,11 @@ function AddPurchase(order_id) {
window.location.href = "/web/PcbPurchaseList" window.location.href = "/web/PcbPurchaseList"
}) })
}else{ }else{
alert_err(res.errmsg) alert_err(res.err_msg)
} }
},
done:function () {
layer.closeAll();
} }
}) })
}) })
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
@{{# if(d.status==1){ }} @{{# if(d.status==1){ }}
<button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" onclick="AddPurchase(@{{ d.order_id }})">发起采购</button> <button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" onclick="AddPurchase(@{{ d.order_id }})">发起采购</button>
@{{# } }} @{{# } }}
@{{# if(d.status==14){ }} @{{# if(d.status==14 && d.shipping_time == 0){ }}
<button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" lay-filter="SendPurchase">发货</button> <button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" lay-filter="SendPurchase">发货</button>
@{{# } }} @{{# } }}
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment