|
@@ -6,7 +6,9 @@ namespace app\Admin\controller;
|
|
|
use app\admin\model\ActionLog;
|
|
|
use app\admin\model\ProcessOrder;
|
|
|
use think\App;
|
|
|
+use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
+use think\facade\Validate;
|
|
|
|
|
|
//退货单
|
|
|
class Orderback extends \app\BaseController
|
|
@@ -341,4 +343,65 @@ class Orderback extends \app\BaseController
|
|
|
return error_show(1004,$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //新写一个退货接口
|
|
|
+ public function ExamNew()
|
|
|
+ {
|
|
|
+ $param = $this->request->only(['thNo', 'status', 'remark', 'can_sell_wsm' => '', 'can_sell_num' => 0, 'defective_wsm' => '', 'defective_num' => 0, 'loss_num' => 0], 'post', 'trim');
|
|
|
+
|
|
|
+ $val = Validate::rule(['thNo|退货编码' => 'require', 'status|状态' => 'require|number|in:4,2,1', 'remark|备注' => 'checkRemark:']);
|
|
|
+
|
|
|
+ $val->extend('checkRemark', function ($val, $rule, $data) {
|
|
|
+ return $data['status'] == 4 ? true : (empty($val) ? '请填写备注' : true);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!$val->check($param)) return error_show(1004, $val->getError());
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $info = Db::name("order_back")
|
|
|
+ ->field('id,order_type,status')
|
|
|
+ ->where(['thNo' => $param['thNo'], 'is_del' => 0])
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if (empty($info)) throw new Exception('未找到数据');
|
|
|
+
|
|
|
+ $update_data = ['status' => $param['status'], 'updatetime' => date('Y-m-d H:i:s')];
|
|
|
+
|
|
|
+ //status==4通过,其他值表示驳回
|
|
|
+ if ($param['status'] != 4) $update_data['remark'] = $param['remark'];
|
|
|
+ else {
|
|
|
+ $update_data['can_sell_wsm'] = $param['can_sell_wsm'];
|
|
|
+ $update_data['can_sell_num'] = $param['can_sell_num'];
|
|
|
+ $update_data['defective_wsm'] = $param['defective_wsm'];
|
|
|
+ $update_data['defective_num'] = $param['defective_num'];
|
|
|
+ $update_data['loss_num'] = $param['loss_num'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $res = Db::name("order_back")
|
|
|
+ ->where(['id' => $info['id']])
|
|
|
+ ->update($update_data);
|
|
|
+
|
|
|
+ if ($res) {
|
|
|
+
|
|
|
+ $stn = ["order_code" => $param['thNo'], "status" => $param['status'], "action_remark" => '', "action_type" => "edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'], $stn, $info['order_type'] == 2 ? "ZXCKTHD" : "CKTHD", $info['status'], $stn);
|
|
|
+ $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => $info['order_type'] == 2 ? "ZXCKTHD" : "CKTHD"];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'], $process);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ return app_show(0, '操作成功');
|
|
|
+ } else throw new Exception('操作失败');
|
|
|
+
|
|
|
+ } catch (Exception $exception) {
|
|
|
+
|
|
|
+ Db::rollback();
|
|
|
+
|
|
|
+ return error_show(1005, $exception->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|