更新pcb后台

parent 824cf469
......@@ -2,6 +2,7 @@
namespace App\Model\Pcb;
use League\Flysystem\Exception;
use Request;
use DB;
......@@ -43,7 +44,7 @@ class PcbPublicModel
* 插入后台客服审核结果
*/
public function orderShipping($user_id,$data){
$con = DB::connection('pcb');
$datas = [
'shipping_type'=>1,
'relevance_id'=>$data['order_id'],
......@@ -53,21 +54,34 @@ class PcbPublicModel
'shipping_id'=>$data['shipping_id'],
'status'=>1,
'update_time'=>time(),
'create_time'=>time(),
];
$shippingCon = $con->table("shipping");
$checkHave =$shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->first();
if ($checkHave){
$in = $shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->update($datas);
}else{
$data['create_time'] = time();
try{
$con = DB::connection('pcb');
$con->beginTransaction();
//插入物流信息
$shippingCon = $con->table("shipping");
$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);
return [0,'成功'];
}else{
return [1001,'失败'];
$con->commit();
return [0, '成功'];
}catch (\Exception $e) {
$con->rollBack();
return [10002, '失败'.$e->getMessage()];
}
}
......
......@@ -156,6 +156,10 @@ layui.use(['table','form','element','layer', 'laydate'], function() {
//确定发货
function SendStock() {
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
$.ajax({
url:'/api/ApiSendStock',
type:'post',
......@@ -171,12 +175,19 @@ function SendStock() {
}else{
alert_err(res.errmsg)
}
},
done:function () {
layer.closeAll();
}
})
}
//转采购
function AddPurchase(order_id) {
alert_confirm("确定填写此订单转采购?",function () {
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
$.ajax({
url:'/api/ApiAddPurchase',
type:'post',
......@@ -190,8 +201,11 @@ function AddPurchase(order_id) {
window.location.href = "/web/PcbPurchaseList"
})
}else{
alert_err(res.errmsg)
alert_err(res.err_msg)
}
},
done:function () {
layer.closeAll();
}
})
})
......
......@@ -91,7 +91,7 @@
@{{# 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>
@{{# } }}
@{{# 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>
@{{# } }}
</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