Browse Source

开票新增删除

anderx 1 year ago
parent
commit
64d828c5f6

+ 17 - 0
src/main/java/com/goafanti/order/controller/OrderInvoiceApiController.java

@@ -12,6 +12,7 @@ import com.goafanti.order.bo.TOrderInvoiceBo;
 import com.goafanti.order.service.OrderInvoiceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -216,4 +217,20 @@ public class OrderInvoiceApiController extends CertifyApiController {
 		return res;
 	}
 
+	/**
+	 * 删除开票申请
+	 * @param id
+	 * @return
+	 */
+	@PostMapping("/delete")
+	public Result delete(Integer id) {
+		Result res = new Result();
+		if (orderInvoiceService.checkDelete(id)){
+			res.getError().add(buildError("该申请状态,无法删除。"));
+			return res;
+		}
+		res.data(orderInvoiceService.delete(id));
+		return res;
+	}
+
 }

+ 4 - 0
src/main/java/com/goafanti/order/service/OrderInvoiceService.java

@@ -45,4 +45,8 @@ public interface OrderInvoiceService {
 
 
     List<OutInvoiceLog> InvoiceLog(Integer id);
+
+    boolean checkDelete(Integer id);
+
+	Object delete(Integer id);
 }

+ 15 - 0
src/main/java/com/goafanti/order/service/impl/OrderInvoiceServiceImpl.java

@@ -408,4 +408,19 @@ public class OrderInvoiceServiceImpl extends BaseMybatisDao<TOrderInvoiceMapper>
 		List<OutInvoiceLog>  list=tOrderInvoiceMapper.selectInvoiceLog(id);
 		return list;
 	}
+
+	@Override
+	public boolean checkDelete(Integer id) {
+		TOrderInvoice t=tOrderInvoiceMapper.selectByPrimaryKey(id);
+        return t.getStatus() == 1 || t.getStatus() == 2;
+    }
+
+	@Override
+	public Object delete(Integer id) {
+		TOrderInvoice t=new TOrderInvoice();
+		t.setId(id);
+		t.setStatus(4);
+
+		return tOrderInvoiceMapper.updateByPrimaryKeySelective(t);
+	}
 }