|
|
@@ -226,38 +226,61 @@ class WorkOrder extends Api
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * U8工单资料删除
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
+ * U8工单资料删除(软删除)
|
|
|
+ * @param string Uniqid 工单Uniqid
|
|
|
*/
|
|
|
-
|
|
|
-
|
|
|
public function orderDataDel()
|
|
|
{
|
|
|
- if($this->request->isGet() === false){
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- $workOrder = input('Uniqid');
|
|
|
- if (empty($workOrder)){
|
|
|
+ $uniqid = $this->request->param('Uniqid');
|
|
|
+ if (empty($uniqid)) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $order = \db('工单_基本资料')->where('UniqId',$workOrder)->find();
|
|
|
- \db()->startTrans();
|
|
|
+
|
|
|
+ $order = Db::table('工单_基本资料')
|
|
|
+ ->where('Uniqid|UniqId', $uniqid)
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->field('Uniqid,UniqId,订单编号')
|
|
|
+ ->find();
|
|
|
+ if (empty($order)) {
|
|
|
+ $this->error('工单不存在或已删除');
|
|
|
+ }
|
|
|
+
|
|
|
+ $orderNo = $order['订单编号'];
|
|
|
+ $now = date('Y-m-d H:i:s');
|
|
|
+ $softDelete = ['Mod_rq' => $now];
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
try {
|
|
|
- \db('工单_印件资料')->where('订单编号',$order['订单编号'])->update(['Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
- \db('工单_工艺资料')->where('订单编号',$order['订单编号'])->update(['Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
- $res = \db('工单_基本资料')->where('UniqId',$workOrder)->update(['Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
- \db()->commit();
|
|
|
- } catch (\Exception $e){
|
|
|
- \db()->rollback();
|
|
|
- }
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
+ Db::table('工单_印件资料')
|
|
|
+ ->where('订单编号', $orderNo)
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->update($softDelete);
|
|
|
+ Db::table('工单_工艺资料')
|
|
|
+ ->where('订单编号', $orderNo)
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->update($softDelete);
|
|
|
+ $result = Db::table('工单_基本资料')
|
|
|
+ ->where('Uniqid|UniqId', $uniqid)
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->update($softDelete);
|
|
|
+ if ($result === false) {
|
|
|
+ throw new \Exception('删除工单失败');
|
|
|
+ }
|
|
|
+ if ($result === 0) {
|
|
|
+ throw new \Exception('未找到可删除的工单');
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (\think\exception\HttpResponseException $e) {
|
|
|
+ throw $e;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('删除失败:' . $e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
}
|
|
|
|
|
|
|