|
@@ -18,6 +18,7 @@ class Sale extends BaseController
|
|
|
//发货单列表
|
|
|
public function saleout()
|
|
|
{
|
|
|
+ $this->post = $this->request->filter('trim')->post();
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
|
|
|
$size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
|
|
|
$where = [["a.is_del", "=", 0], ['wpo.supplierNo', '=', $this->request->user['supplierNo']]];
|
|
@@ -145,32 +146,34 @@ class Sale extends BaseController
|
|
|
$value['sendtime'] = $value['status'] < 2 ? '' : $value['sendtime'];
|
|
|
$data[] = $value;
|
|
|
}
|
|
|
- return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|
|
|
+ return json_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|
|
|
}
|
|
|
|
|
|
|
|
|
//发货单详情
|
|
|
public function saleOutInfo()
|
|
|
{
|
|
|
+ $this->post = $this->request->filter('trim')->post();
|
|
|
+
|
|
|
$outCode = isset($this->post['outCode']) && $this->post['outCode'] !== "" ? trim($this->post['outCode']) : "";
|
|
|
if ($outCode == "") {
|
|
|
- return error_show(1002, "参数outcode不能为空");
|
|
|
+ return json_show(1002, "参数outcode不能为空");
|
|
|
}
|
|
|
$codeinfo = Db::name("order_out")->where(['outCode' => $outCode, "is_del" => 0])->find();
|
|
|
if (empty($codeinfo)) {
|
|
|
- return error_show(1002, "未找到出库数据");
|
|
|
+ return json_show(1002, "未找到出库数据");
|
|
|
}
|
|
|
$item = Db::name("sale")->where(['orderCode' => $codeinfo['orderCode']])->find();
|
|
|
if ($item['order_type'] == 3) {
|
|
|
$goodinfo = Db::name("good_zixun")->where(["spuCode" => $item['good_code'], "is_del" => 0])->find();
|
|
|
if ($goodinfo == false) {
|
|
|
- return error_show(1004, "未找到商品数据");
|
|
|
+ return json_show(1004, "未找到商品数据");
|
|
|
}
|
|
|
} else {
|
|
|
$goodinfo = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
|
|
|
->where(['a.skuCode' => $item['skuCode']])->find();
|
|
|
if ($goodinfo == false) {
|
|
|
- return error_show(1002, "未找到商品数据");
|
|
|
+ return json_show(1002, "未找到商品数据");
|
|
|
}
|
|
|
}
|
|
|
$int = isset($goodinfo['cat_id']) && $goodinfo['cat_id'] != 0 ? made($goodinfo['cat_id']) : [];
|
|
@@ -200,35 +203,36 @@ class Sale extends BaseController
|
|
|
$codeinfo['order_source'] = $item['order_source'];
|
|
|
$orderReturn = Db::name("order_return")->where(["outCode" => $outCode, "is_del" => 0])->order("id desc")->find();
|
|
|
$codeinfo['order_return'] = $orderReturn;
|
|
|
- return app_show(0, "获取成功", $codeinfo);
|
|
|
+ return json_show(0, "获取成功", $codeinfo);
|
|
|
}
|
|
|
|
|
|
//库管发货
|
|
|
public function outSend()
|
|
|
{
|
|
|
+ $this->post = $this->request->filter('trim')->post();
|
|
|
$outCode = isset($this->post['outCode']) && $this->post['outCode'] != "" ? trim($this->post['outCode']) : "";
|
|
|
if ($outCode == "") {
|
|
|
- return error_show(1004, "参数outCode不能为空");
|
|
|
+ return json_show(1004, "参数outCode不能为空");
|
|
|
}
|
|
|
$outinfo = Db::name("order_out")->where(["outCode" => $outCode, "is_del" => 0])->find();
|
|
|
if ($outinfo == false) {
|
|
|
- return error_show(1004, "发货数据未找到");
|
|
|
+ return json_show(1004, "发货数据未找到");
|
|
|
}
|
|
|
$einfo = Db::name('sale')->where(['orderCode' => $outinfo['orderCode'], 'is_del' => 0])->find();
|
|
|
if (empty($einfo)) {
|
|
|
- return error_show(1002, "未找到销售订单数据");
|
|
|
+ return json_show(1002, "未找到销售订单数据");
|
|
|
}
|
|
|
$is_reurn = Db::name("sale_return")->where(['orderCode' => $outinfo['orderCode'], 'is_del' => 0])->where("status", "<", 4)->find();
|
|
|
if ($is_reurn != false) {
|
|
|
- return error_show(1002, "销售单存在退货未处理完成");
|
|
|
+ return json_show(1002, "销售单存在退货未处理完成");
|
|
|
}
|
|
|
$post_name = isset($this->post['post_name']) && $this->post['post_name'] != "" ? trim($this->post['post_name']) : "";
|
|
|
if ($post_name == "") {
|
|
|
- return error_show(1004, "参数post_name不能为空");
|
|
|
+ return json_show(1004, "参数post_name不能为空");
|
|
|
}
|
|
|
$post_code = isset($this->post['post_code']) && $this->post['post_code'] != "" ? trim($this->post['post_code']) : "";
|
|
|
if ($post_code == "") {
|
|
|
- return error_show(1004, "参数post_code不能为空");
|
|
|
+ return json_show(1004, "参数post_code不能为空");
|
|
|
}
|
|
|
$remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
|
|
|
$post_fee = isset($this->post['post_fee']) && $this->post['post_fee'] != "" ? floatval($this->post['post_fee']) : "";
|
|
@@ -241,16 +245,15 @@ class Sale extends BaseController
|
|
|
$outinfo['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$outinfo['remark'] = $remark;
|
|
|
if ($einfo['wsend_num'] < $outinfo['send_num']) {
|
|
|
- return error_show(1004, "订单未发货数量不足");
|
|
|
+ return json_show(1004, "订单未发货数量不足");
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$up = Db::name("order_out")->save($outinfo);
|
|
|
|
|
|
- $user_info = GetUserInfo($this->post['token']);
|
|
|
- $uid = isset($user_info['data']['id']) ? $user_info['data']['id'] : 0;
|
|
|
- $uname = isset($user_info['data']['nickname']) ? $user_info['data']['nickname'] : '';
|
|
|
-
|
|
|
+// $user_info = GetUserInfo($this->post['token']);
|
|
|
+ $uid = $this->request->user['uid'];
|
|
|
+ $uname = $this->request->user['nickname'];
|
|
|
|
|
|
if ($up) {
|
|
|
//修改状态,添加待办
|
|
@@ -268,8 +271,8 @@ class Sale extends BaseController
|
|
|
"order_id" => $outinfo['id'],
|
|
|
"order_status" => $outinfo['status'],
|
|
|
"before_status" => $old_outinfo_status,
|
|
|
- 'wait_id'=>$outinfo['apply_id'],
|
|
|
- 'wait_name'=>$outinfo['apply_name'],
|
|
|
+ 'wait_id' => $outinfo['apply_id'],
|
|
|
+ 'wait_name' => $outinfo['apply_name'],
|
|
|
]);
|
|
|
$orderstatus = $einfo['status'];
|
|
|
$einfo['send_num'] += $outinfo['send_num'];
|
|
@@ -280,7 +283,7 @@ class Sale extends BaseController
|
|
|
$saleup = Db::name("sale")->save($einfo);
|
|
|
if ($saleup == false) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1002, "销售单状态更新失败");
|
|
|
+ return json_show(1002, "销售单状态更新失败");
|
|
|
}
|
|
|
// }
|
|
|
//修改状态,添加待办
|
|
@@ -303,11 +306,11 @@ class Sale extends BaseController
|
|
|
$stokc = Db::name("good_stock")->where(['spuCode' => $einfo['good_code'], "wsm_code" => $outinfo['wsm_code'], "is_del" => 0])->find();
|
|
|
if ($stokc == false) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1002, "未找到库存数据");
|
|
|
+ return json_show(1002, "未找到库存数据");
|
|
|
} else {
|
|
|
if ($outinfo['send_num'] > $stokc['wait_out_stock']) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1002, "超出库存数量");
|
|
|
+ return json_show(1002, "超出库存数量");
|
|
|
}
|
|
|
$stokc['wait_out_stock'] -= $outinfo['send_num'];
|
|
|
$stokc['total_stock'] = $stokc['wait_out_stock'] + $stokc['usable_stock'];
|
|
@@ -317,7 +320,7 @@ class Sale extends BaseController
|
|
|
$stoc = Db::name("good_stock")->save($stokc);
|
|
|
if ($stoc == false) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1002, "库存更新失败");
|
|
|
+ return json_show(1002, "库存更新失败");
|
|
|
}
|
|
|
$good_data[] = ['good_log_code' => $outCode, "stock_id" => $stokc['id'], "type" => 2, 'stock' => $outinfo['send_num'], "stock_name" => "wait_out_stock"];
|
|
|
|
|
@@ -328,7 +331,7 @@ class Sale extends BaseController
|
|
|
|
|
|
} else {
|
|
|
Db::rollback();
|
|
|
- return error_show(1004, "发货失败");
|
|
|
+ return json_show(1004, "发货失败");
|
|
|
}
|
|
|
|
|
|
//如果是有赞订单的话,将发货信息推到有赞
|
|
@@ -336,14 +339,14 @@ class Sale extends BaseController
|
|
|
if ($einfo['order_source'] == 5) {
|
|
|
$res = curl_request(config('app.yz_domain') . 'api/yz_out_send', ['orderCode' => $einfo['orderCode'], 'out_stype' => $post_name, 'post_code' => $post_code, 'uid' => $uid, 'uname' => $uname, 'order_out' => $outCode]);
|
|
|
$res = json_decode($res, true);
|
|
|
- if ($res['code'] != 0) return app_show(0, '发货成功,' . $res['message']);
|
|
|
+ if ($res['code'] != 0) return json_show(0, '发货成功,' . $res['message']);
|
|
|
}
|
|
|
|
|
|
- return app_show(0, "发货成功");
|
|
|
+ return json_show(0, "发货成功");
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1004, $e->getMessage());
|
|
|
+ return json_show(1004, $e->getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -354,11 +357,11 @@ class Sale extends BaseController
|
|
|
|
|
|
$param = $this->request->only(['list', 'token'], 'post', 'trim');
|
|
|
|
|
|
- if (empty($param['list'])) return error_show(1005, 'list参数不能为空');
|
|
|
+ if (empty($param['list'])) return json_show(1005, 'list参数不能为空');
|
|
|
|
|
|
- $user = GetUserInfo($param['token']);
|
|
|
- $createrid = isset($user['data']['id']) ? $user['data']['id'] : 0;
|
|
|
- $creater = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
|
|
|
+// $user = GetUserInfo($param['token']);
|
|
|
+ $createrid = $this->request->user['uid'];
|
|
|
+ $creater = $this->request->user['nickname'];
|
|
|
|
|
|
//所有发货单信息
|
|
|
$order_out_infos = Db::name("order_out")
|
|
@@ -389,7 +392,7 @@ class Sale extends BaseController
|
|
|
//判断发货单是否重复
|
|
|
if (isset($temp_out_codes[$value['outCode']])) {
|
|
|
Db::rollback();
|
|
|
- return app_show(1005, '下列发货申请单号重复', [$value]);
|
|
|
+ return json_show(1005, '下列发货申请单号重复', [$value]);
|
|
|
} else $temp_out_codes[$value['outCode']] = $value['outCode'];
|
|
|
|
|
|
//【发货单】
|
|
@@ -490,24 +493,22 @@ class Sale extends BaseController
|
|
|
|
|
|
|
|
|
} else throw new Exception($value['outCode'] . '发货失败');
|
|
|
- Cache::store("redis")->handler()->lPush("SENDOUT",$value['outCode']);
|
|
|
+ Cache::store("redis")->handler()->lPush("SENDOUT", $value['outCode']);
|
|
|
}
|
|
|
|
|
|
if (!empty($good_data)) GoodLog::LogAdd(['id' => $createrid, 'nickname' => $creater], $good_data, "CKD");
|
|
|
|
|
|
Db::commit();
|
|
|
|
|
|
- return app_show(0, '发货成功');
|
|
|
+ return json_show(0, '发货成功');
|
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
|
- return error_show(1004, $exception->getMessage());
|
|
|
+ return json_show(1004, $exception->getMessage());
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|